Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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?

like image 986
Ben Hirschberg Avatar asked Aug 16 '14 21:08

Ben Hirschberg


People also ask

What is the name of the dynamic linker loader on linux?

LD_ASSUME_KERNEL can be used to cause the dynamic linker to assume that it is running on a system with a different kernel ABI version. For example, the following command line causes the dynamic linker to assume it is running on Linux 2.2.

What is ld_ bind_ now?

LD_BIND_NOW : Dynamic Libraries can be instructed to load at system startup by setting the LD_BIND_NOW variable with ld. so, the dynamic linker/loader. This means that the first time that your code calls a function in a dynamic library, the runtime environment calls the dynamic linker.

What is ld so preload?

LD_PRELOAD. A list of additional, user-specified, ELF shared libraries to be loaded before all others. The items of the list can be separated by spaces or colons. This can be used to selectively override functions in other shared libraries.

What is Lib Ld linux so?

/lib/ld.so a.out dynamic linker/loader /lib/ld-linux.so.{1,2} ELF dynamic linker/loader /etc/ld.so.cache. File containing a compiled list of directories in which to search for libraries and an ordered list of candidate libraries.


2 Answers

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
like image 131
Employed Russian Avatar answered Oct 06 '22 01:10

Employed Russian


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

like image 39
Bogi Avatar answered Oct 06 '22 00:10

Bogi