系统相关
首页 > 系统相关> > 如何覆盖Linux下elf可执行文件的.interp标头中指定的链接器?

如何覆盖Linux下elf可执行文件的.interp标头中指定的链接器?

作者:互联网

我有一个交叉编译器,在其.interp标头中指定了一个自定义加载器:

objdump -s beaglebone/x86_64-angstromsdk-linux/usr/bin/armv7a-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-g++ | head

beaglebone/x86_64-angstromsdk-linux/usr/bin/armv7a-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-g++:     file format elf64-x86-64

Contents of section .interp:
 400200 2f757372 2f6c6f63 616c2f6f 65636f72  /usr/local/oecor
 400210 652d7838 365f3634 2f737973 726f6f74  e-x86_64/sysroot
 400220 732f7838 365f3634 2d616e67 7374726f  s/x86_64-angstro
 400230 6d73646b 2d6c696e 75782f6c 69622f6c  msdk-linux/lib/l
 400240 642d6c69 6e75782d 7838362d 36342e73  d-linux-x86-64.s
 400250 6f2e3200                             o.2.            

我希望能够在不将其安装到系统位置的情况下使用该二进制文件.是否可以覆盖.interp标头中指定的加载程序,并指示Linux使用系统加载程序(/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)?尽管无法执行支持程序,但在/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2上运行arm-angstrom-linux-gnueabi-g可以手动进行.

解决方法:

http://nixos.org/patchelf.html

标签:dynamic-linking,elf,cross-compiling,linux
来源: https://codeday.me/bug/20191201/2078869.html