Question

I downloaded the source for libc6 and completed the build process successfully. (Though I did not performed a make install deliberately).

With the new linker built in buil-dir/elf/ld.so I ran a program supplying it as the argument to the newly built linker.

  • The test code prints some string and then malloc(sizeof(char)*1024).

  • On running the test binary as an argument to the newly built linker I get a Seg Fault at elf/dl-addr.c:132 which is:

    131 /* Protect against concurrent loads and unloads. */

    132 __rtld_lock_lock_recursive (GL(dl_load_lock));

  • This is the last frame before the seg fault and is called through malloc() call from the test program.

Stack Trace at that point :

#0  0x0000000000000000 in ?? ()
#1  0x00007f11a6a94928 in __GI__dl_addr (address=0x7f11a69e67a0 <ptmalloc_init>,   info=0x7fffe9393be0, mapp=0x7fffe9393c00, symbolp=0x0) at dl-addr.c:132
#2  0x00007f11a69e64d7 in ptmalloc_init () at arena.c:381
#3  0x00007f11a69e72b8 in ptmalloc_init () at arena.c:371
#4  malloc_hook_ini (sz=<optimized out>, caller=<optimized out>) at hooks.c:32
#5  0x00000000004005b3 in main () at test.c:20

On running the same program with the default installed linker on the machine the program runs fine.

  • I am not able to understand what can be the issue behind this? (Is it faulting because I am using the newly built linker without installing it first)

-Any suggestions or pointers are highly appreciated. Thanks

(System details GCC 4.8.22, eglibc-2.15 Ubuntu 12.10 64bit

Was it helpful?

Solution

With the new linker built in buil-dir/elf/ld.so I ran a program supplying it as the argument to the newly built linker.

It that's all you did, then the crash is expected, because you are mixing newly-built loader with system libraries (which doesn't work: all parts of glibc must come from the same build of it).

What you need to do is:

buil-dir/elf/ld.so \
  --library-path buil-dir:buil-dir/dlfcn:buil-dir/nptl:... \
  /path/to/a.out

The list of directories to search must include all the libraries (parts of glibc) that your program uses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top