LD a.out format emulation?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
ThisMayWork
Member
Member
Posts: 65
Joined: Sat Mar 22, 2014 1:14 pm
Location: /bin

LD a.out format emulation?

Post by ThisMayWork »

Since I started the development of my OS I have been using the cross compiler binaries for OSX provided in the wiki. Everything has been working correctly until today. I need to produce some user space objects in a.out format and apparently that version of ld does not support it. Is there any way to emulate it or do I have to rebuild the toolchain from scratch? If it is the latter, could somebody provide binaries? (I know, building it on my own is a very good learning experience but at the moment I am developing on a 64GB SSD and there isn't even enough space for the source code download :P)
"Programming is an art form that fights back."
-Kudzu
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: LD a.out format emulation?

Post by Techel »

Use other formats like elf.
User avatar
ThisMayWork
Member
Member
Posts: 65
Joined: Sat Mar 22, 2014 1:14 pm
Location: /bin

Re: LD a.out format emulation?

Post by ThisMayWork »

a.out is easier to parse that is why I chose it. I have seen it's possible to do, that's why I am asking about it.
"Programming is an art form that fights back."
-Kudzu
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: LD a.out format emulation?

Post by iansjack »

If you haven't got enough storage space left to build a cross-compiler then you are going to have a lot of problems. In your position I would buy an external drive and use that (at least to build the cross-compiler).
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: LD a.out format emulation?

Post by Nable »

You can try to convert ELF files to a.out using objcopy. Even if your objcopy doesn't support a.out format, you can rebuild just the "binutils" package, not the whole toolchain.
User avatar
ThisMayWork
Member
Member
Posts: 65
Joined: Sat Mar 22, 2014 1:14 pm
Location: /bin

Re: LD a.out format emulation?

Post by ThisMayWork »

Nable wrote:You can try to convert ELF files to a.out using objcopy. Even if your objcopy doesn't support a.out format, you can rebuild just the "binutils" package, not the whole toolchain.
Godsend! Thank you very much :D

EDIT: I get "invalid bdf format" for both -O a.out and -O aout. Does this mean it is not supported?
"Programming is an art form that fights back."
-Kudzu
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: LD a.out format emulation?

Post by Nable »

ThisMayWork wrote:EDIT: I get "invalid bdf format" for both -O a.out and -O aout. Does this mean it is not supported?
No, this only means that you aren't eager enough to read the documentation (sorry, but "--help" parameter and manual pages really help in most cases). Just look at it:

Code: Select all

$ objcopy --help
Usage: objcopy [option(s)] in-file [out-file]
 Copies a binary file, possibly transforming it in the process
 The options are:
[...]
objcopy: supported targets: elf64-x86-64 elf32-i386 elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-x86-64 pe-bigobj-x86-64 pe-i386 plugin srec symbolsrec verilog tekhex binary ihex
Report bugs to <http://www.sourceware.org/bugzilla/>
If "a.out-<something>" isn't in the list of supported formats, then it really means that your toolchain doesn't support a.out and you should finally choose another format or rebuild binutils.
User avatar
ThisMayWork
Member
Member
Posts: 65
Joined: Sat Mar 22, 2014 1:14 pm
Location: /bin

Re: LD a.out format emulation?

Post by ThisMayWork »

Sorry about that, instead of reading the manuals I googled and landed on an ancient hit. Still, it does not allow a.out :( What do I have to change in the binutils build process in order to get it to support a.out?
"Programming is an art form that fights back."
-Kudzu
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: LD a.out format emulation?

Post by Nable »

You should specify additional targets for libbfd.
In "bfd" sub-directory there's a separate "configure" that accepts this parameter:

Code: Select all

  --enable-targets        alternative target configurations
I've never used it so I can't say exactly what to specify. But you can read build scripts from your favorite linux distro and look how additional formats are added there (in the previous post I've shown large list of supported targets from Debian's binutils).
Post Reply