简体   繁体   English

指定在Linux上启动可执行文件时要使用的动态链接器/加载器

[英]Specifying the dynamic linker / loader to be used when launching an executable on Linux

I have a weird Linux system where most of the software is compiled against Glibc and some others against uClibc. 我有一个奇怪的Linux系统,其中大多数软件是针对Glibc编译的,而另一些则针对uClibc编译的。

Since the Linux is a standard distro when I launch and executable the standard dynamic linker is invoked (/lib/ld.so.1) from glibc. 由于当我启动并执行Linux时是Linux的标准发行版,因此会从glibc调用(/lib/ld.so.1)标准动态链接器。

I'm looking for a way to specify the dynamic loader before launching any executable so when I want to run software which was compiled against uClibc I can define the launching mechanism to use uClibc dynamic loader (/lib/ld-uClibc.so.0). 我正在寻找一种在启动任何可执行文件之前指定动态加载器的方法,因此当我要运行针对uClibc编译的软件时,我可以定义启动机制以使用uClibc动态加载器(/lib/ld-uClibc.so.0 )。

Any ideas? 有任何想法吗?

I'm looking for a way to specify the dynamic loader before launching any executable so when I want to run software which was compiled against uClibc 我正在寻找一种在启动任何可执行文件之前指定动态加载器的方法,以便在我要运行针对uClibc编译的软件时

You should be specifying the correct dynamic loader while building against uClibc , using the linker --dynamic-linker argument. 使用链接器--dynamic-linker参数针对uClibc 进行构建时,您应该指定正确的动态加载--dynamic-linker Eg 例如

gcc -nostdlib -Wl,--dynamic-linker=/lib/ld-uClibc.so.0 \
   /lib/uClibc-crt1.o main.o -L/path/to/uClibc -lc

Looks to me as if you need to set PT_INTERP to point to an alternative interpreter that in turn prefers your prefered ld.so device. 在我看来,您好像需要将PT_INTERP设置为指向备用解释器,该解释器反过来会偏爱您首选的ld.so设备。 See the man page for elf(5). 请参见elf(5)的手册页。 See readelf to dump what you have and see; 请参阅readelf来转储您所拥有的并查看; you are trying to change ld-linux-xxx.so.x to whatever you come up with. 您正在尝试将ld-linux-xxx.so.x更改为您想要的。

Actually, it looks to me as if you just want to point to your alternative ld.so as the INTERP. 实际上,在我看来,好像您只是要指向替代ld.so(即INTERP)一样。

Just put the full path to the dynamic linker before calling the executable, for example: 只需在调用可执行文件之前将完整路径放在动态链接器中,例如:

/home/x20/tools/codescape-2016.05-3-mips-mti-linux-gnu/2016.05-03/sysroot/mipsel-r2-hard/lib64/ld-2.20.so out.gn/mipsel/d8

d8 is the binary we want to execute and ld-2.20.so is the dynamic linker d8是我们要执行的二进制文件,而ld-2.20.so是动态链接器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM