Skip to contentSkip to conversation

text base address of a library

DISCUSSION Umut Aymakoglu 2 participants 2 messages Sep 16, 2003

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
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