Page 1 of 1
LD a.out format emulation?
Posted: Fri Jun 19, 2015 6:03 am
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
)
Re: LD a.out format emulation?
Posted: Fri Jun 19, 2015 11:54 am
by Techel
Use other formats like elf.
Re: LD a.out format emulation?
Posted: Fri Jun 19, 2015 3:35 pm
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.
Re: LD a.out format emulation?
Posted: Sat Jun 20, 2015 1:55 am
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).
Re: LD a.out format emulation?
Posted: Sat Jun 20, 2015 1:59 am
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.
Re: LD a.out format emulation?
Posted: Sat Jun 20, 2015 11:50 am
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
EDIT: I get "invalid bdf format" for both -O a.out and -O aout. Does this mean it is not supported?
Re: LD a.out format emulation?
Posted: Sat Jun 20, 2015 12:45 pm
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.
Re: LD a.out format emulation?
Posted: Sat Jun 20, 2015 1:03 pm
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?
Re: LD a.out format emulation?
Posted: Sat Jun 20, 2015 1:28 pm
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).