Segfault from ld-linux in my glibc assembly

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 

It 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 it works:

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

False , grep and cat and everything else that I tried in /bin segfault in the same way. Is there a problem with the source? Am I compiling it incorrectly?

It should also be noted that I downloaded the correct version (slightly newer) for raspberry pi (ARM), compiled it and does not have segfaults.

+6
source share
1 answer

This fails:

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

This is a fully expected result.

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

When you run ./elf/ld-linux.so.2 /bin/true you use your own ld-linux assembly, but the system version of libc.so.6 , which was not obtained from your assembly.

You can confirm that this is really what happens when using:

 LD_DEBUG=files,libs ./elf/ld-linux.so.2 /bin/true 

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

You can fix this using, for example,

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

which will then use ./libc.so.6

+9
source

Source: https://habr.com/ru/post/957130/


All Articles