Specifying the dynamic linker / loader to be used when launching an executable on Linux
Asked Answered
D

3

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?

Designedly answered 16/8, 2014 at 21:37 Comment(2)
Look into LD_PRELOAD?Intendance
ld.so.1 is the thing that does LD_PRELOAD. That's too late.Lungi
A
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
Aime answered 18/8, 2014 at 1:26 Comment(0)
T
3

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

Triste answered 13/10, 2017 at 9:28 Comment(0)
L
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.

Lungi answered 16/8, 2014 at 22:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.