Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ld-linux location

I have find out that to load libraries, a executable first opens /lib/ld-linux-x86-64.so.2. All the functionality regarding loading shared libraries (search in many paths, using rpath, etc) will work only after ld-linux is loaded, because it is ld-linux that implements these functionality.

It seemed to me that ld-linux.so location is hardcoded in executable (invoking strings on my executable reinforces this theory). My problem is that in my linux distribution, the compiler (g++) sets the ld-linux location to /lib/ld-linux-x86-64.so.2. While on Ubuntu (which is more popular) it is located at /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2.

I was wondering if I can make my executable looks for ld-linux.so at /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2(which is also present in my distro as a symbolic link).

like image 905
André Puel Avatar asked Feb 17 '23 15:02

André Puel


1 Answers

Try adding -Wl,--dynamic-linker=/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 to your LDFLAGS.

like image 110
nneonneo Avatar answered Feb 27 '23 10:02

nneonneo