Questions tagged [ld-preload]

LD_PRELOAD is a list of additional ELF shared objects that should be loaded first.

LD_PRELOAD is a list of additional ELF shared objects that should be loaded first.

For more information, visit this website

http://man7.org/linux/man-pages/man8/ld.so.8.html

265 questions
3
votes
0 answers

Is there a way to intercept an internal glibc call?

I am trying to use an old program (where only a binary is available) which simply gets stuck at IO on Debian Buster while working on systems with older glibc releases. Someone found out that the problem is tied to a glibc fix introduced via…
uli42
  • 293
  • 2
  • 9
3
votes
1 answer

Inconsistent seccomp behavior

I am working on containing different applications using Linux's seccomp and I got to an inconsistency I cannot explain. I have tried to give you examples clear enough to reproduce the problem. I am creating a "protector module" which disallows…
Ben Hirschberg
  • 1,410
  • 1
  • 12
  • 17
3
votes
1 answer

ERROR: ld.so: object '/opt/xyz/mylib.so' from LD_PRELOAD cannot be preloaded: ignored

After upgrading a software from 32 to 64-bit, a pre-compiled binary starts to fail with the error: [root@localhost /root]# LD_PRELOAD=/opt/xyz/lib/mylib.so mycommand /inputfile.txt /outputfile.txt ERROR: ld.so: object '/opt/xyz/lib/mylib.so' from…
seba.wagner
  • 3,800
  • 4
  • 28
  • 52
3
votes
0 answers

Override connect() in a PHP script running on Apache with mod_php

How to override connect() system call called from within PHP script, in an Apache request, when PHP is enabled via mod_php? I have my custom connect() version defined in custom-connect.c: #define _GNU_SOURCE 1 #include #include…
Luke 10X
  • 1,071
  • 2
  • 14
  • 30
3
votes
1 answer

dlopen with higher precedence than link time on linux

I am compiling a C program on linux with gcc. The program itself links libc (and not much else) at build-time, so that ldd gives this output : $ ldd myprogram linux-vdso.so.1 => (0x00007fffd31fe000) libc.so.6 =>…
Todd Freed
  • 877
  • 6
  • 19
3
votes
1 answer

Linux: LD_PRELOAD + -z,initfirst

I'm writing a shared-object which is supposed to be LD_PRELOADed into processes. In that shared object I have some initialization like __attribute__((constructor)) void initFunc(); That I'd like to be called before any other code in the…
shoosh
  • 76,898
  • 55
  • 205
  • 325
3
votes
2 answers

LD_PRELOAD and clone()

I'm using a script to run a program with LD_PRELOAD with a library created by me to intercept some calls, it works well but at some point the process calls clone() and I lose the ability to intercept what's next (the program is run again without my…
xception
  • 4,241
  • 1
  • 17
  • 27
3
votes
1 answer

Segmentation fault when calling backtrace() on Linux x86

I am attempting to do the following - write a wrapper for the pthreads library that will log some information whenever each of its APIs it called. One piece of info I would like to record is the stack trace. Below is the minimal snippet from the…
3
votes
2 answers

Android 4.2 - LD_PRELOAD supported or not?

I wonder if LD_PRELOAD is now supported with the newer Android-versions? At the time of 4.0 ICS it wasn't, and in the documentation (NDK docs/SYSTEM-ISSUES.html) there's still: No support for LD_LIBRARY_PATH, LD_PRELOAD, RTLD_LOCAL and many other…
Martin L.
  • 3,006
  • 6
  • 36
  • 60
3
votes
1 answer

Passing arguments to a library loaded with LD_PRELOAD

Is it possible to pass arguments to my library, which is loaded with LD_PRELOAD: LD_PRELOAD=lib.so ./program How can I pass arguments to this library?
3
votes
2 answers

How to escape spaces in library path appended to LD_PRELOAD?

I'm having a problem with LD_PRELOAD on Linux. I'm trying to load a library existing in a directory with spaces in its name, right before launching my application: > export LD_PRELOAD='/home/myuser/MyApp\ Test/lib/mylib.so' However, the path is not…
Dan
  • 1,763
  • 4
  • 26
  • 40
2
votes
1 answer

Inject a thread with LD_PRELOAD and thread-safety

I'm working on a project to inject a shared library in a program with LD_PRELOAD. My injected library creates a new thread when it is injected into the program. All logic happens in this thread (like analyzing network traffic and so on). First you…
2
votes
1 answer

How to invoke compiler with LD_PRELOAD in CMake

Is it possible to have CMake “export an environment variable” such as LD_PRELOAD before invoking the compiler/linker, like you could in a shell? I am using an old 32-bit cross-compiler in WSL2. The source files are on Windows filesystem mounted into…
2
votes
0 answers

Application to overwrite included library's malloc

Objective My application has a custom memory allocator. Also, that application includes an open source third party library. I need to have the third party's allocations/frees call into the custom memory allocator. Specific Requirements Map the…
user1266174
  • 111
  • 2
  • 11
2
votes
0 answers

tcmalloc by default, but overridable

The common usage of tcmalloc vs glibc is "glibc malloc/free is the default; use LD_PRELOAD to use tcmalloc". An application I'm working on, they want the reverse: tcmalloc by default, but glibc's malloc/free as an option. (Environment is RHEL7, gcc…
Underhill
  • 408
  • 2
  • 13