text base address of a library
Hi -
Is there a way(function) to find the text base address of a loaded
library?
a.c:
main()
{
b();
}
b.c:b()
{}
%gcc -c b.c
%gcc -shared -o b.sl b.o
%gcc -o a a.c ./b.sl
%ldd a
./c.sl => ./c.sl (0x2000000000044000) <---------- how can i find this address within a program?
thanks,
Umut
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Umut Aymakoglu
Umut> Hi - Is there a way(function) to find the text base address of Umut> a loaded library?
Umut> a.c: main() { b(); }
Umut> b.c: b() {}
Umut> %gcc -c b.c %gcc -shared -o b.sl b.o %gcc -o a a.c ./b.sl
Umut> %ldd a ./c.sl => ./c.sl (0x2000000000044000) <---------- how Umut> can i find this address within a program?
dl_iterate_phdr() is probably what you want. For better or worse, it is said to be a trivial interface which requires no documentation [1]. libunwind has some sample code which may help you (see src/ia64/tables-ia64.c).
--david
[1] http://sources.redhat.com/ml/libc-alpha/2003-02/msg00031.html