#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
const char interp[] __attribute__((section(".interp"))) = "/lib64/ld-linux-x86-64.so.2";
void test() {
printf("test\r\n");
}
extern "C" void _main(int argc, char **argv) {
printf("main\r\n");
test();
exit(0);
}
user@user-Aspire-4530 ~/DEV $ g++ -shared -fPIC -o libtest.so libtest.c -Wl,-e,_main
user@user-Aspire-4530 ~/DEV $ LD_PRELOAD=./libtest.so ls
libtest.c libtest.o libtest.so
user@user-Aspire-4530 ~/DEV $ ./libtest.so
main
test
user@user-Aspire-4530 ~/DEV $ readelf -l /bin/ls | grep interpreter
piątek, grudnia 12, 2014
Executable Linux shared library
Subskrybuj:
Komentarze do posta (Atom)
0 komentarze:
Prześlij komentarz