Index: Makefile =================================================================== --- Makefile (nonexistent) +++ Makefile (revision 13673) @@ -0,0 +1,14 @@ +CXXFLAGS=-fPIC +all: a c.so +clean: + rm -f a *.o *.so +a: a.o b.so + $(CXX) -Wl,-rpath=. -o $@ $^ +b.so: b.o + $(CXX) -shared -o $@ $^ +c.so: c.o + $(CXX) -shared -o $@ $^ +a.o: a.cpp +b.o: b.cpp +c.o: c.cpp + Index: a.cpp =================================================================== --- a.cpp (nonexistent) +++ a.cpp (revision 13673) @@ -0,0 +1,23 @@ +#include +#include "b.h" + +class X { +public: + X(int i); +}; + + +X::X(int i) { + printf("x %d\n", i); +} + +int normal(int x); + + +int main() +{ + X x(3); + B b(1); + B *b2 = new B(2); + normal(5); +} Index: b.cpp =================================================================== --- b.cpp (nonexistent) +++ b.cpp (revision 13673) @@ -0,0 +1,15 @@ +#include +#include "b.h" + +B::B(int y) { + x = y; + printf("foo %d\n", x); +} +int B::bar(int x) { + printf("bar %d\n", x); +} + +int normal(int x) { + printf("normal %d\n", x); +} + Index: b.h =================================================================== --- b.h (nonexistent) +++ b.h (revision 13673) @@ -0,0 +1,7 @@ +class B{ +public: + B(int); + int bar(int x); + int x; +}; + Index: c.cpp =================================================================== --- c.cpp (nonexistent) +++ c.cpp (revision 13673) @@ -0,0 +1,20 @@ +#include +#include +#include "b.h" + + +B::B(int y) { + x = y; + void (B::*member)(int) = 0; + void *p = dlsym(RTLD_NEXT,"_ZN1BC1Ei"); + printf("magic %d %p %p\n", x, p, this); + reinterpret_cast(member) = p; +// printf("x %d p %p pp %p\n", x, p, (void*)(this->*member)); + (this->*member)(7); + printf("x %d\n", x); +} + +int normal(int x) { + printf("normal2 %d\n", x); +} +