Dynamic linking with LD_PRELOAD - get it compiled



Hello group,

I'm currently working on a tool which generates code that can be compiled with gcc to form a shared object. This shared object then can be preloaded with the LD_PRELOAD variable and shadows other library functions (read, write, printf and such).

The intercepted functions do a dlsym with the RTLD_NEXT parameter on the name of the actual function - then they are called. This gives me the possibilty to hook code in before and after library calls and maybe change the return value of those.

Anyways, it's working nicely with open(), close(), read(), write() and such, but then I tried select() - suddenly the compiler complains:


$ gcc -O2 -Wall -fPIC -shared -ldl -o libtrapper.so libtrapper.c Custom.o
libtrapper.c:155: error: conflicting types for ‘select’
/usr/include/gentoo-multilib/amd64/sys/select.h:112: error: previous declaration of ‘select’ was here
make: *** [libtrapper.so] Error 1

Well, of course I redefine it - however with different parameters. I always use void* in my declaration. I know it is not 100% correct, but it works (at least on x86_64) - but how do I convince gcc to compile the code anyways?

Regards,
Johannes

--
"PS: Ein Realname wäre nett. Ich selbst nutze nur keinen, weil mich die
meisten hier bereits mit Namen kennen." -- Markus Gronotte aka Makus /
Kosst Amojan / maqqusz / Mr. G / Ferdinand Simpson / Quartillia
Rosenberg in dse <45608268$0$5719$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
.



Relevant Pages

  • RE: k3b-mp3 for x86_64?
    ... configure:2310: checking for gcc ... configure:2619: checking for C compiler default output file name ... conftest.c:20: warning: "struct stat" declared inside parameter list ... declaration, which is probably not what you want ...
    (Fedora)
  • BLT compilation
    ... I am trying to install BLT package on my ubuntu machine. ... checking for gcc... ... checking whether the C compiler works... ... checking whether declaration is needed for drand48... ...
    (comp.lang.tcl)
  • Re: without declare parameter [double square(parameter)] return 0 in main
    ... Unless you have a prototype in scope (rather than just a declaration), ... I would have thought a compiler could spot this kind of error: ... But gcc doesn't complain. ...
    (comp.lang.c)
  • Function matching with constructed args
    ... the gcc 3.2 compiler won't match the call to the function. ... with the same function declaration in scope ...
    (comp.lang.cpp)
  • Re: shared lib
    ... > Assume a module/application is using a shared library. ... .so is "shared object". ... compiler like gcc tries to link with shared library. ...
    (comp.os.linux.embedded)