7

I have a weird Linux system where most of the software is compiled against Glibc and some others against 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.

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

Any ideas?

Ben Hirschberg
  • 1,410
  • 1
  • 12
  • 17

3 Answers3

6

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

You should be specifying the correct dynamic loader while building against uClibc, using the linker --dynamic-linker argument. E.g.

gcc -nostdlib -Wl,--dynamic-linker=/lib/ld-uClibc.so.0 \
   /lib/uClibc-crt1.o main.o -L/path/to/uClibc -lc
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
2

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

Bogi
  • 2,274
  • 5
  • 26
  • 34
0

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. See the man page for elf(5). See readelf to dump what you have and see; you are trying to change ld-linux-xxx.so.x to whatever you come up with.

Actually, it looks to me as if you just want to point to your alternative ld.so as the INTERP.

bmargulies
  • 97,814
  • 39
  • 186
  • 310