Problems with my compiler ?

Template-Archiv cs at epag.de
Mon Mar 10 22:38:05 EST 2003


Hi all,

this is absolutely not related to anything here but I do not know where 
to ask else and I think somebody here will definetly know what I am 
doing wrong:

After having plenty of problems on my Solaris 8 x86 box with gcc and the 
  linker provided by solaris I now found out the following which I 
absolutely do not understand and which seems to be the cause of many (if 
not all) of my problems...

schulte-03:58:27:~ >echo "int main() { return 0; }" > conftest.c
schulte-03:58:33:~ >gcc -O3 -static conftest.c -o conftest
schulte-03:58:38:~ >./conftest
Segmentation Fault (core dumped)
schulte-03:58:42:~ >ldd conftest
ldd: conftest: file is not a dynamic executable or shared object
schulte-04:04:11:~ >gcc -O3 conftest.c -o conftest
schulte-04:05:13:~ >./conftest
schulte-04:05:16:~ >ldd conftest
         libc.so.1 =>     /usr/lib/libc.so.1
         libdl.so.1 =>    /usr/lib/libdl.so.1


Because mainly all configure-scripts will do some kind of this and will 
fail with LDFLAGS="-static" in the very beginning I cannot build static 
binaries with gcc and solaris ld. The question is simple: Why does that 
simple binary produce a segfault ? Shouldn't that run ? ldd correctly 
states that conftest is not a shared object (and that is what I want!) 
but however that segfaults. Maybe this is a totally stupid thing to ask 
but after hours of reading manpages of ld and even trying to change 
things in the compilers' spec-file I cannot get gcc to produce a 
statically linked binary which does not segfault ! Because I am not that 
familiar with the compiler and ld (it is Solaris-ld called by gcc with 
no gld being present!) I hope someone has had that before or knows where 
I am too stupid ? I started playing with the -Xlinker option of gcc but 
it is the same result all the time:

schulte-04:30:02:~ >gcc -O3 -Xlinker -dn -Xlinker -Bstatic -Xlinker -a 
conftest.c -o conftest
schulte-04:30:19:~ >./conftest
Segmentation Fault (core dumped)
schulte-04:30:24:~ >ldd conftest
ldd: conftest: file is not a dynamic executable or shared object
schulte-04:30:28:~ >

Here are the versions of the tools being used:

schulte-04:11:06:~ >gcc -v
Reading specs from /usr/local/lib/gcc-lib/i386-pc-solaris2.8/2.95.3/specs
gcc version 2.95.3 20010315 (release)
schulte-04:19:32:~ >ld -V
ld: Software Generation Utilities - Solaris-ELF (4.0)

Can anybody help ?

--Christian--





More information about the Info-cyrus mailing list