I'm running Fedora Core 4 Linux, bintuils 2.16, and gcc-4.0. Can I
generate an a.out executable file under this circumstances ? Thanks.
Alan Camus <albc...@gmail.com>
Run "info ld" and search for the "--oformat <format>" optional argument to ld.
This may be specified by an invocation such as "gcc -Wl,--oformat,<format>".
Run "objdump -i" and notice 'a.out-i386-linux' as one of the formats
that is supported by libbfd.
--
Thank you. I've try this method before the post, but got results as this:
[root@localhost test]# cat hello.c
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("hello from %s\n", __FILE__);
return 0;
}
[root@localhost test]# gcc -Wl,--oformat,a.out-i386-linux hello.c
/usr/lib/gcc/i386-redhat-linux/4.0.2/libgcc_s.so: could not read
symbols: File in wrong format
collect2: ld returned 1 exit status
Then I tried to compile and link statically, but failed one more:
[root@localhost test]# gcc -Wl,--oformat,a.out-i386-linux hello.c -static
/usr/bin/ld: a.out: can not represent section `.note.ABI-tag' in a.out
object file format
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
[root@localhost test]#
Need I re-compile the GNU binutils (and gcc ? ) to enable `a.out'
generating ? or anything else could I do ?
Thanks again :-)
Alan Camus
If you're targeting a program executable in your Linux, you
may be out of luck here.
The shared libraries called by your program (libc, libgcc) expect
an ELF format executable. The a.out format cannot carry enough
information to link properly with them.
What are you attempting to achieve with a.out?
--
Tauno Voipio
tauno voipio (at) iki fi
Thanks :-) I do not want anything special with `a.out', all the
motivation with this is that somebody has asked me, and I cannot provide
a solution :-)
Alan Camus <albc...@gmail.com>
Yet another question, could I link my program and the essential
libraries (libc.a, libgcc.a) STATICALLY ?
Maybe. You need *all* the referenced libraries in static form.
And - there is no simple way to convert a shared library into a
static library.
You need a kernel able to load and execute the a.out binaries,
though. Static linking is very uneconomical from memory usage
standpoint, so there are good grounds to leave it for special
cases only.
>> What are you attempting to achieve with a.out?
>
> Thanks :-) I do not want anything special with `a.out', all the
> motivation with this is that somebody has asked me, and I cannot provide
> a solution :-)
Ask them what the real application is. Don't be so gullible as
to throw a question on us and expect a solution. It won't happen
until we know what is actually required. For example, Sun bootstraps
in a.out format are generated with elftoaout(1).
And please trim your quotations.
-- Pete
Alan