Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a.out format problem

Status
Not open for further replies.

jreawjdskkd

Programmer
Jul 27, 2006
5
0
0
SE
I am using the NASM assembler in order to write a small portion of assembly code I need for my OS. I need the object file in a.out format, and that is no problem for NASM. The problem is the linker (ld), that sais it doesn't recognize the file format! Are there some other linker that support a.out?
 
A google sear for [tt]a.out[/tt] produced:

Results 1 - 10 of about 4,300,000 for a.out. (0.56 seconds)


Hope this helps.

[vampire][bat]
 
Well, I've tried that but that is also the answer til that I'm asking here! I need a more strict answer.
 
Isn't a.out an executable format? I've never needed to link an a.out to produce an executable. I looked at the NASM manual, and found:

nasm [ -f format ] [ -o outfile ] [ options... ] infile


Have you tried:

nasm -f aout -o yourfile yourfile.asm
 
Yes I have! The problem is the following: I have an aout object file generated from nasm. I need to link it together with som othre object files, generated by gcc in order to create a binary (NOT an executable). The problem is that ld says it doesn't recognize the file format of the inputfile statr.o (that is aout).

After some research I found out that one shouldn't use ld that comes with the MinGW package, but instead the one that comes with Cygwin. So I have installed Cygwin, but the linker still says the same thing.

Then I read the info and man pages about ld, and they said that I should use objdump -i to see the supported input file formats. As I read the list, I saw that aout was NOT supported. Howeever the man pages stated that ld uses the BFD library to recognize the different input formats, and the BFD library DOES support the a.out format.

Now my question is, quite different from my original one: How can I configure Cygwin to make use of the a.out format supported by the BFD library (there should be some kind of configuration file)?
 
Perhaps the issue is that ld isn't expecting aout format object files. Have you tried informing ld that statr.o is an aout file?

ld -o binary [object files] -b input-format statr.o

where input format specifies aout? You should be able to obtain a list of the formats suppored by your linker by issuing the command:

objdump -i

The option above is a lowercase "eye", not a lowercase "el". On my system, the input-format would be a.out-i386-linux, so the ld command above would read something like this:

ld -o binary file1.o file2.o -b a.out-i386-linux statr.o
 
According to objdump -i, the linker currently does NOT support the aout format. but there has to be a way to make it support it, as it relies on the BFD library, that do support a.out. How can I make ld support the a.out format?
 
You could try building a linker script for ld. But, wouldn't it be easier to assemble your statr.asm module into an object format that ld does understand?
 
I am using a linker script, allready. I have tried to change to other object formats, but then either nasm is complaining about something, or thelinker says: "PE operations on non-PE file".
 
You will need to build a GCC cross compiler. This issue is addressed on the mega-tokyo os forums. . Just look under C/C++ compilers to see what you need to do. I think the problem is that Cygwin and Mingw are too Windows oriented. Alternatively, you could build your files on a linux workstations using Nasm and GCC.


Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top