dynamic-linking

Changing the path opened by openat of a program using LD_PRELOAD

Changing the path opened by openat of a program using LD_PRELOAD I want to change a path that a program actually opens on filesystem for some paths. The reason is that I want to run a program in parallel, but that program uses /tmp/somedir/ as its temporary directory and parallel instances run into conflicts. I …

Total answers: 1

Making changes to the shared library

Making changes to the shared library Suppose we have a C program that uses the shared library. If you make changes to a shared library and rebuild it, all programs using that library will automatically receive those changes the next time they run. In the case of a static library, the changes become visible only …

Total answers: 3

gdbus symbol look up error

gdbus symbol look up error I’m using Archlinux. After a recent update, I find that the gdbus doesn’t work and it presents a symbol lookup error: ➜ tidedra@ZgrArch ~ gdbus gdbus: symbol lookup error: /usr/lib/libgobject-2.0.so.0: undefined symbol: g_string_free_and_steal Then I thought it was probably a problem about the version of library, so I checked the …

Total answers: 2

Figuring out location of a loaded shared library

Figuring out location of a loaded shared library I’m maintaining a C-program, that uses Oracle client libraries. The libraries expect the ORACLE_HOME environment variable to be set, and fail to work without it — in many cases. In our situation, the value of the variable is always derived from the location of the shared libraries …

Total answers: 2

apt packages – static vs dynamic libraries

apt packages – static vs dynamic libraries I use Ubuntu 18.04. I install libraries using apt, for example: sudo apt install freeglut3-dev Does apt always install dynamic libraries or I can determine if a package contains static or dynamic library ? Asked By: Irbis || Source By convention: libfoo1 will contain a dynamic library, while …

Total answers: 1

What is the gold linker?

What is the gold linker? Has anyone used the gold linker before? To link a fairly large project, I had to use this as opposed to the GNU ld, which threw up a few errors and failed to link. How is the gold linker able to link large projects where ld fails? Is there some …

Total answers: 4

How can the dynamic linker/loader itself be dynamically linked as reported by `file`?

How can the dynamic linker/loader itself be dynamically linked as reported by `file`? Consider the shared object dependencies of /bin/bash, which includes /lib64/ld-linux-x86-64.so.2 (dynamic linker/loader): ldd /bin/bash linux-vdso.so.1 (0x00007fffd0887000) libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f57a04e3000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57a04de000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57a031d000) /lib64/ld-linux-x86-64.so.2 (0x00007f57a0652000) Inspecting /lib64/ld-linux-x86-64.so.2 shows that it is a symlink to /lib/x86_64-linux-gnu/ld-2.28.so: ls -la …

Total answers: 2

Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library?

Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library? I have a binary executable named “alpha” that requires a linked library (libz.so.1.2.7) which is placed at /home/username/myproduct/lib/libz.so.1.2.7 I export the same to my terminal instance before spawning my binary executable by executing the following command. export LD_LIBRARY_PATH=/home/username/myproduct/lib/:$LD_LIBRARY_PATH …

Total answers: 1

Get hex-only output from objdump

Get hex-only output from objdump Say for example I’ve got this C function: void f(int *x, int *y) { (*x) = (*x) * (*y); } When saved to f.c, compiling with gcc -c f.c produces f.o. objdump -d f.o gives this: f.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <f>: 0: 55 push %rbp …

Total answers: 4

Why should or should not shared libraries be executable (e.g. Red Hat vs Debian)?

Why should or should not shared libraries be executable (e.g. Red Hat vs Debian)? This is almost but not quite a duplicate of "https://unix.stackexchange.com/questions/61646/why-are-so-files-executable". I note that on Red Hat based systems shared libraries have execute permission but on Debian they do not. Logically shard libraries are not executable themselves unless they are by design …

Total answers: 1

Linux executable fails with "File not found" even though the file is there and in PATH

Linux executable fails with "File not found" even though the file is there and in PATH I want to launch the wine executable (Version 2.12), but I get the following error ($=shell prompt): $ wine bash: /usr/bin/wine: No such file or directory $ /usr/bin/wine bash: /usr/bin/wine: No such file or directory $ cd /usr/bin $ …

Total answers: 6

Where to get "/etc/ld.so.nohwcap" file from?

Where to get "/etc/ld.so.nohwcap" file from? When I run a command through strace utility I can see access errors such as access(“/etc/ld.so.nohwcap”, F_OK) = -1 ENOENT (No such file or directory) Now I’ve read somewhere that what’s happening on the above line is that a linker is looking for optimized version of the command that …

Total answers: 1

Find out if library is in path

Find out if library is in path Assuming I want to test if a library is installed and usable by a program. I can use ldconfig -p | grep mylib to find out if it’s installed on the system. but what if the library is only known via setting LD_LIBRARY_PATH? In that case, the program …

Total answers: 5

Why can't I install multiple versions of a shared library?

Why can't I install multiple versions of a shared library? There are often instances where a certain program will depend on library version x.y and another on x.z but, as far as I’m aware, no package manager will allow me to install both x.y and x.z. Sometimes they will allow both major versions (such as …

Total answers: 2

Memory layout of dynamic loaded/linked library

Memory layout of dynamic loaded/linked library when loading a shared library in Linux system, what is the memory layout of the shared library? For instance, the original memory layout is the following: +———–+ |heap(ori) | +———–+ |stack(ori) | +———–+ |.data(ori) | +———–+ |.text(ori) | +———–+ When I dlopen foo.so, will the memory layout be A …

Total answers: 1

How to use libraries installed by nix at run-time?

How to use libraries installed by nix at run-time? I’m using nix in “single-user mode” in a system where I’m not the root (see below for a description of my nix setup). I wanted to quickly run one of my binaries which is dynamically linked with a library which is absent in the system. So, …

Total answers: 2

libGLEW.so.1.11: cannot open shared object file

libGLEW.so.1.11: cannot open shared object file I am trying to compile an opengl program which results in: error while loading shared libraries: libGLEW.so.1.11: cannot open shared object file: No such file or directory compile: g++ -o triangle triangle.cpp LoadShaders.cpp -I/home/mks/myGL/oglpg/include/ -L/home/mks/myGL/oglpg/lib -L/usr/lib64 -lglut -lGL -lGLU -lGLEW In /home/mks/myGL/oglpg/lib there are all the libraries: libGLEW.so libGLEW.so.1.11.0 …

Total answers: 2

libcurl.so.4 undefined reference error

libcurl.so.4 undefined reference error Even after installation of curl and all concerned libcurl packages such as curl libcurl3 libcurl3-gnutls libcurl4-doc libcurl4-nss-dev libcurl-ocaml libcurl3-dbg libcurl3-nss libcurl4-gnutls-dev libcurl4-openssl-dev libcurl-ocaml-dev I get errors such as , /usr/lib/x86_64-linux-gnu/libcurl.so.4: undefined reference to `SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0′ /usr/lib/x86_64-linux-gnu/libcurl.so.4: undefined reference to `SSL_CTX_set_verify@OPENSSL_1.0.0′ /usr/lib/x86_64-linux-gnu/libcurl.so.4: undefined reference to `ASN1_STRING_type@OPENSSL_1.0.0′ /usr/lib/x86_64-linux-gnu/libcurl.so.4: undefined reference to `CRYPTO_free@OPENSSL_1.0.0′ /usr/lib/x86_64-linux-gnu/libcurl.so.4: undefined …

Total answers: 3

Identifying running programs that are using the old version of a library I just replaced

Identifying running programs that are using the old version of a library I just replaced After installing updates to address CVE-2014-0160 (the OpenSSL Heartbleed bug), I had to take care to restart anything that might be using libssl — many services, such as Apache and my VPN software, still had the old vulnerable libssl loaded …

Total answers: 2

Using alternate libc with ld-linux.so hacks; cleaner method?

Using alternate libc with ld-linux.so hacks; cleaner method? I have a legacy system with a very old glibc, which we can’t upgrade without incurring a mountain of testing/validation work. I have needed to run newer programs (such as Java 1.7) on that system several times now. I opted for a chroot solution, where I package …

Total answers: 1