user2856949 user2856949 - 8 months ago 36
C Question

Segfault from ld-linux in my build of glibc

Running Ubuntu 10.04

$ uname -a
Linux minion 2.6.32-36-generic-pae #79-Ubuntu SMP Tue Nov 8 23:25:26 UTC 2011 i686 GNU/Linux

Downloaded the source and did the following:

CFLAGS="-O2 -U_FORTIFY_SOURCE -fno-stack-protector" '/home/user/Desktop/eglibc-2.11.1/configure' --prefix='/home/user/Desktop/eglibc_pristinebuild'
make -j4
export LD_LIBRARY_PATH=/lib/tls/i686/cmov:/lib:/usr/lib

This works:

$ ./elf/ /bin/ls /usr
bin games include lib lib64 local sbin share src

This fails:

$ ./elf/ /bin/true
Segmentation fault

But this works:

/lib/ /bin/true

, and
and everything else I've tried in
segfault in the same manner. Is there an issue with the source? Am I compiling it incorrectly?

Also of note is that i downloaded the correct version (slightly newer) for the raspberry pi (ARM), compiled it, and it has no segfaults.


This fails:

$ ./elf/ /bin/true
Segmentation fault

That is entirely expected outcome.

GLIBC consists of ~200 separate files, which all must match exactly (must have come from the same build), because they use un-versioned binary interfaces between them.

When you run ./elf/ /bin/true, you are using your own build of ld-linux, but the system version of, which did not come from your build.

You can confirm that that's in fact what is happening by using:

LD_DEBUG=files,libs ./elf/ /bin/true

(this will prove that /lib/ is being used).

You can fix this by using e.g.

./elf/ --library-path . /bin/true

which will then use ./