Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I override the linker specified in the .interp header of an elf executable under Linux?

I have a cross compiler that specifies a custom loader in its .interp header:

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.            

I want to be able to use this binary without installing it into system locations. Is it possible to override the loader specified in the .interp header and instruct Linux to use the system loader (/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)? Running arm-angstrom-linux-gnueabi-g++ with /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 manually works to an extent, although it fails to exec support programs.

like image 224
engie Avatar asked Oct 08 '22 11:10

engie


1 Answers

http://nixos.org/patchelf.html

like image 114
Bragi Acculum Avatar answered Oct 12 '22 20:10

Bragi Acculum