通过链接器运行程序时出现错误?

时间:2022-09-06 15:19:33

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

我下载了libc6的源代码并成功完成了构建过程。 (虽然我没有故意进行make安装)。

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.

使用在buil-dir / elf / ld.so中构建的新链接器,我运行了一个程序,将其作为新构建的链接器的参数提供。

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

    测试代码打印一些字符串,然后打印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:

    在将测试二进制文件作为新构建的链接器的参数运行时,我在elf / dl-addr.c:132处获得了Seg Fault,它是:

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

    131 / *防止并发加载和卸载。 * /

    132 __rtld_lock_lock_recursive (GL(dl_load_lock));

    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.

    这是seg错误之前的最后一帧,并通过测试程序调用malloc()来调用。

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

(系统详情GCC 4.8.22,eglibc-2.15 Ubuntu 12.10 64bit

1 个解决方案

#1


1  

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.

使用在buil-dir / elf / ld.so中构建的新链接器,我运行了一个程序,将其作为新构建的链接器的参数提供。

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).

这就是你所做的一切,然后崩溃是预期的,因为你将新构建的加载器与系统库混合(这不起作用:glibc的所有部分必须来自它的相同构建)。

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.

要搜索的目录列表必须包含程序使用的所有库(glibc的一部分)。

#1


1  

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.

使用在buil-dir / elf / ld.so中构建的新链接器,我运行了一个程序,将其作为新构建的链接器的参数提供。

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).

这就是你所做的一切,然后崩溃是预期的,因为你将新构建的加载器与系统库混合(这不起作用:glibc的所有部分必须来自它的相同构建)。

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.

要搜索的目录列表必须包含程序使用的所有库(glibc的一部分)。