ld-preload Questions
6
Solved
I'm trying to write a simple shared library that would log malloc calls to stderr (a sort of 'mtrace' if you will).
However, this is not working.
Here's what I do:
/* mtrace.c */
#include <dlf...
Ninety asked 21/5, 2011 at 16:3
2
Solved
I have static linked binary (ELF file) it doesn't have dynamic segment, .dymsym sections and it doesn't perform LD_PRELOAD command and etc.
How could i create fake dummy dynamic segment to activate...
Velocipede asked 3/8, 2016 at 14:0
3
I use the LD_PRELOAD trick to catch open64() calls and I think I know how to do it correctly: with the program foobar compiled from
#include <sys/types.h>
#include <sys/stat.h>
#includ...
Darlington asked 3/3, 2016 at 11:49
2
Is it possible to dynamically modify symbol table at runtime in C (in elf format on Linux)?
My eventual goal is the following:
Inside certain function say foo, I want to override malloc function ...
Xenocrates asked 10/5, 2015 at 2:16
1
Solved
I have a created shared library which interposes malloc() and related calls.
The works well but for some caveats.
There is one thing that does not work. I am expecting to be able to chain interpose...
Foghorn asked 15/4, 2022 at 9:39
1
Solved
When I type the command
proxychains chromium on linux terminal
it gives me this error:
ERROR: ld.so: object 'libproxychains.so.3' from LD_PRELOAD cannot be preloaded (cannot open shared object file...
Marquez asked 24/7, 2020 at 21:6
2
Solved
I'm dynamically overriding malloc() with a fast_malloc() implementation of mine in a glibc benchmark malloc speed test (glibc/benchtests/bench-malloc-thread.c), by writing these functions in my fas...
Lentha asked 29/6, 2021 at 0:22
5
Solved
Relating to a previous question of mine
I've successfully interposed malloc, but calloc seems to be more problematic.
That is with certain hosts, calloc gets stuck in an infinite loop with a pos...
Sachikosachs asked 27/10, 2011 at 1:2
1
Solved
I tried to use perf stat with LD_PRELOAD as prefix for executable such as:
perf stat LD_PRELOAD=$PWD/../user/preload.so ./write 1
It seems not work for perf, are there any way to achieve it?
Caty asked 25/2, 2021 at 1:30
5
I am trying to use LD_PRELOAD to preload a library with an application that has setuid permissions. Tried LD_PRELOAD at first, and it seemed like it was being ignored with the setuid binary, though...
Christen asked 10/2, 2012 at 18:32
1
Solved
Preconditions
A third-party has provided a C++ executable fooapp that uses a shared object libfoo.so. The library also comes with a header foo.hpp so developers can build other applications:
/* f...
Prescind asked 23/1, 2019 at 17:39
3
Solved
I have to perform dynamic linking on a variadic function of following format:
int foo(char *args, const char *f, ...)
Here the number of arguments are variable.
What I want to achieve is that I...
Cocainize asked 1/8, 2018 at 6:8
5
I want to create my own version of assert in which it does some log prints in case assert was called in NDEBUG mode.
I tried to do the LD_PRELOAD trick and redefine the assert macro but it seems t...
Libenson asked 23/2, 2016 at 13:15
1
Solved
In the following minimal example, a library loaded via LD_PRELOAD with functions to intercept fopen and openat is apparently operating before its initialization. (Linux is CentOS 7.3). Why??
libra...
Priscella asked 12/3, 2018 at 1:19
2
Solved
I have this small testcode atfork_demo.c:
#include <stdio.h>
#include <pthread.h>
void hello_from_fork_prepare() {
printf("Hello from atfork prepare.\n");
fflush(stdout);
}
void re...
Scotland asked 20/10, 2017 at 8:48
1
I am trying to inject a SO into a process that starts using systemd init system (using LD_PRELOAD), but it does not loaded into the new process.
I complied a basic SO (unrandom.c):
int rand(){
r...
Nubianubian asked 16/3, 2016 at 11:20
2
Solved
I would like to set LD_PRELOAD to point to a shared library where I might run either a 64bit or 32bit application. It is obvious that the shared library and the executable have to match in bit-ness...
Sarad asked 25/4, 2016 at 19:33
3
Solved
If I use a function from a shared library directly, i.e. by declaring it in my code and linking during compile time, LD_PRELOAD works fine. But if I use dlopen()/dlsym() instead LD_PRELOAD has no e...
Mattock asked 13/6, 2016 at 14:14
1
Solved
I'm familiar with using dlopen() to check if a shared library has been loaded into a process using a prior call to dlopen() without triggering a load if it isn't present, like so:
void* lib = dlo...
Aphrodisia asked 9/6, 2016 at 0:52
1
I have written a library which is intended to be loaded via LD_PRELOAD. On some Linux systems, this is causing the dynamic library loader to segfault during initialisation.
I have a simple test ca...
Nebula asked 5/12, 2014 at 18:21
1
I'm looking for a way to present a userspace filesystem to a specific Linux process but I don't have root access.
The obvious answer is FUSE but without root access I cannot load the kernel module...
Nicky asked 6/8, 2015 at 21:22
2
Solved
Here's the template I use for wrapping a function using LD_PRELOAD:
int gettimeofday(struct timeval *tv, struct timezone *tz) {
static int (*gettimeofday_real)(struct timeval *tv, struct timezone...
Papilionaceous asked 11/2, 2015 at 19:11
3
Solved
Consider the following library which can be preloaded before any program execution:
// g++ -std=c++11 -shared -fPIC preload.cpp -o preload.so
// LD_PRELOAD=./preload.so <command>
#include &l...
Betti asked 24/5, 2014 at 23:30
2
I'm trying to provide my own implementation of the close() function in Linux. Why? Because I just found out you could do that and it sounds fun.
Here's myclose.c:
#include <stdio.h>
int cl...
Expanse asked 28/4, 2014 at 16:9
2
Solved
I am having an annoying problem with the linker. I want to link some symbols from a shared library to a static library, but not export its symbols (ie, I cannot simply merge the libraries or link w...
Lianaliane asked 28/2, 2014 at 17:58
1 Next >
© 2022 - 2025 — McMap. All rights reserved.