gcc -static gives GNU/Linux instead of SYSV?
Victor van der Veen
vvdveen at gmail.com
Fri Jun 17 12:21:12 UTC 2011
Hi all,
Not sure if this is a bug or a feature, but when compiling the following
program (called main.c, using Ubuntu 11.04 or 10.10):
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv) {
char buff[32];
if (argc >= 2) strcpy(buff, argv[1]);
return (0);
}
with
#gcc main.c -o main
#gcc -static main.c -o main_static
and then do a file command on the executables, I get unexpected results:
#file main
main: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not
stripped
#file main_static
main_static: ELF 32-bit LSB executable, Intel 80386, version 1
(GNU/Linux), statically linked, for GNU/Linux 2.6.15, not stripped
Note that the main_static binary is identified as GNU/Linux, while main
is SYSV. On Ubuntu 7.04, however, things are better. The same sequence
of commands ends up with:
#file main_static
main: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.6.8, statically linked, not stripped
This header differences (readelf -h calls it OS/ABI) gives me trouble
doing other stuff.
I found [1], but that doesn't help me much further.
Is this a bug? Or a feature? :) How do I compile main.c statically and
end up with a SYSV type binary in the end?
Thanks in advance,
Bye,
Victor
[1]. http://comments.gmane.org/gmane.comp.gcc.help/34230
More information about the Ubuntu-devel-discuss
mailing list