kubo / plthook

Hook function calls by replacing PLT(Procedure Linkage Table) entries.
762 stars 156 forks source link

uClibc support #28

Closed speidy closed 4 years ago

speidy commented 4 years ago

uClibc doesn't implement the dlinfo() and dladdr1() dl functions. The existing Android solution fits for the uClibc case as well.

I’ve ran the test program locally when compiling with uClibc toolchain grabbed from: https://toolchains.bootlin.com.

I'll be happy if you can add the uClibc toolchain to the Travis CI system as well.

kubo commented 4 years ago

@speidy Could you post the environment information you tested on? I failed to set up a uClibc environment to check your pull request.

I have a question. Why features.h is included? It is a linux-specific header. It prevent compiling on other platforms.

speidy commented 4 years ago

Hi @kubo,

  1. Regarding #include <features.h> - its redundant. Iv'e omitted this include now.
  2. I've managed to test it in a chrooted environment by using the sysroot directory provided in the toolchain: 2.1. Download x86_64 uclibc toolchain from the link iv'e provided (iv'e got x86-64-core-i7--uclibc--stable-2018.11-1) 2.2. Export the toolchain's bin directory containing the gcc compiler to your $PATH. (e.g. export PATH=$PATH:~/toolchains/x86-64-core-i7--uclibc--stable-2018.11-1/bin). 2.3. Build plthook tests while specifying the new compiler: make CC=x86_64-buildroot-linux-uclibc-gcc 2.4. Now, change directory to the toolchain' sysroot directory, e.g.: ~/toolchains/x86-64-core-i7--uclibc--stable-2018.11-1/x86_64-buildroot-linux-uclibc/sysroot 2.5. Now copy testprog to <sysroot>/usr/bin and libtest.so to <sysroot>/usr/lib. 2.6. Now you also need to mount the procfs (as plthook using it): sudo mount -t proc none <sysroot>/proc 2.6. now run the test binary under the chrooted sysroot: sudo chroot . ./usr/bin/testprog (run from sysroot directory)

Let me know if that works for you.

kubo commented 4 years ago

Thanks. I verified your code. Merged.

kubo commented 4 years ago

Tests for uclibc support was added. https://github.com/kubo/plthook/commit/0a4c2a1d0e69cebe567dbae38d016299c4dd9a64

speidy commented 4 years ago

Thanks @kubo !