Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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/ld-linux.so.2 /bin/ls /usr
bin  games  include  lib  lib64  local  sbin  share  src

This fails:

$ ./elf/ld-linux.so.2 /bin/true
Segmentation fault

But this works:

/lib/ld-linux.so.2 /bin/true

False, grep, and cat and everything else I've tried in /bin 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.

like image 816
user2856949 Avatar asked Oct 31 '13 15:10

user2856949


1 Answers

This fails:

$ ./elf/ld-linux.so.2 /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/ld-linux.so.2 /bin/true, you are using your own build of ld-linux, but the system version of libc.so.6, 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/ld-linux.so.2 /bin/true

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

You can fix this by using e.g.

./elf/ld-linux.so.2 --library-path . /bin/true

which will then use ./libc.so.6

like image 68
Employed Russian Avatar answered Nov 02 '22 07:11

Employed Russian