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
2
votes
1 answer

`__attribute__((destructor))` not running in some cases?

I am writing a toy malloc(3) implementation, loaded with LD_PRELOAD, as an exercise. I have a function annotated with __attribute__((destructor)) to dump a list of allocations and their status on exit for debugging purposes but I found it doesn't…
markdrayton
  • 485
  • 6
  • 11
2
votes
1 answer

can I do nested calls for system functions loaded by LD_PRELOAD

Hi I am trying to override sscanf() which gets called from localtime(), But its not calling sscanf() of my library loaded rather its calling sscanf() of glibc. Is there something I am missing? Files content mentioned…
Ami
  • 233
  • 2
  • 9
2
votes
2 answers

Not able to use function from my dynamic library loaded via LD_PRELOAD

I am trying to use sscanf() from preload.so which is generated from preload.c. To check my sscanf() from preload.so is called, I added extra print statement: printf("test\n"); Is there something I am missing? Files content mentioned…
Ami
  • 233
  • 2
  • 9
2
votes
1 answer

Is it possible to override C syscall open without LD_PRELOAD?

The source gets printed, but no open: or open64: gets printed. How to fix this? Thanks! /* gcc -o emload emload.c -ldl ./emload */ // emload.c #define _GNU_SOURCE #include #include #include #include…
Vadim Kantorov
  • 930
  • 1
  • 10
  • 28
2
votes
1 answer

Wrap clone syscall using LD_PRELOAD

Variatic functions such as printf can be wrapped using dlsym because it has a va_list version vprintf. So, int printf(const char *format, ...); //is equivalent to int vprintf(const char *format, va_list ap); citing…
antrix
  • 41
  • 2
2
votes
2 answers

Segmentation fault when replacing `malloc`, `calloc`, `realloc` and `free` via `LD_PRELOAD`

Background I am experimenting to replace malloc(3)/calloc(3)/realloc(3)/free(3) via LD_PRELOAD environment variable. I have tried to use the customized functions statically linked, they worked perfectly. But, when I attached it as shared library to…
Ammar Faizi
  • 1,393
  • 2
  • 11
  • 26
2
votes
1 answer

Unload LD_PRELOAD without restart process

I using LD_PRELOAD to hook function like LD_PRELOAD=my_lib.so ./my_exec How can I unload my_lib.so when the hook function called without restart the process?
Lpoiu0099
  • 31
  • 3
2
votes
2 answers

Constructor in shared object not called in when LD_PRELOAD-ing a go executable

There is a strange behavior around GO executable built in Alpine images where standard LD_PRELOAD feature is not working correctly. It looks like constructor functions are not called by the dynamic loader! I have an example go application…
Ben Hirschberg
  • 1,410
  • 1
  • 12
  • 17
2
votes
1 answer

LD_PRELOAD-ed open() + __xstat() + syslog() result into EBADF

I am on a Fedora 30 box with GLIBC 2.29 and kernel 5.2.18-200.fc30.x86_64 $ rpm -qf /usr/lib64/libc.so.6 glibc-2.29-28.fc30.x86_64 override.c : #define open Oopen #define __xstat __Xxstat #define _GNU_SOURCE #include #include…
Nehal J Wani
  • 16,071
  • 3
  • 64
  • 89
2
votes
2 answers

How to prevent LD_PRELOAD on a binary?

I write binary in C code. How can I prevent another user from using LD_PRELOAD on my binary? When using LD_PRELOAD, is there any signal that I can handle and break the program? If I compile the binary statically, I heard that LD_PRELOAD will not…
yfr24493AzzrggAcom
  • 159
  • 1
  • 2
  • 13
2
votes
1 answer

ERROR: LD_PRELOAD cannot be preloaded :ignored

I just installed wine from this link to run windows applications in my ubuntu 18.04(Bionic beaver) but when i run wine --version the output was ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded…
Nischaya Sharma
  • 431
  • 2
  • 6
  • 16
2
votes
3 answers

Interpose statically linked binaries

There's a well-known technique for interposing dynamically linked binaries: creating a shared library and and using LD_PRELOAD variable. But it doesn't work for statically-linked binaries. One way is to write a static library that interpose the…
P.P
  • 117,907
  • 20
  • 175
  • 238
2
votes
1 answer

How to find out what functions to intercept with LD_PRELOAD?

I am trying to intercept all dynamically loaded functions that call syscall openat with a library comm.so using LD_PRELOAD mechanism. Consider the following use of /sbin/depmod command: #strace -f /sbin/depmod…
Mark Galeck
  • 6,155
  • 1
  • 28
  • 55
2
votes
2 answers

Using LD_PRELOAD with Apache Spark (or YARN)

We are running Spark jobs on Apache Hadoop YARN. I have a special need to use the "LD_PRELOAD trick" on these jobs. (Before anyone panics, it's not for production runs; this is part of automated job testing). I know how to submit additional files…
Todd Owen
  • 15,650
  • 7
  • 54
  • 52
2
votes
0 answers

Redirect writes to Linux frame buffer /dev/fb0

I'm writing a ptrace based debugging/testing suite for an embedded application. The application runs on raraspbery-pi-like hardware and writes directly to the Linux framebuffer, without any display server involved. The testing suite should run on…
hannesh
  • 21
  • 1