This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: dwfl_module_relocate_address() versus base address
- From: Mark Wielaard <mjw at redhat dot com>
- To: systemtap <systemtap at sources dot redhat dot com>
- Date: Fri, 12 Dec 2008 19:15:06 +0100
- Subject: Re: dwfl_module_relocate_address() versus base address
- References: <1229103422.3397.98.camel@dijkstra.wildebeest.org>
On Fri, 2008-12-12 at 18:37 +0100, Mark Wielaard wrote:
> (*) A simple reproducer, without the above patch applied, is compiling
> this little library:
>
> $ gcc usymbols_lib.c -fPIC -shared -o libusymbols.so
>
> And doing:
> $ stap -k -d /lib/libc.so.6 -d `pwd`/libusymbols.so \
> -e 'probe begin {exit()}'
>
> Where usymbols_lib.c contains just one function like:
>
> void lib_main () {}
>
> You will see that the stap-symbols.h file will contain libusymbols
> addresses that have dwarf_module_base added, while the libc symbol
> addresses don't have those.
So just for reference. This is what you will get:
struct _stp_symbol _stp_module_1_symbols_0[] = {
{ 0x200428, "_init" },
{ 0x200460, "call_gmon_start" },
{ 0x200480, "__do_global_dtors_aux" },
{ 0x200500, "frame_dummy" },
{ 0x200534, "lib_main" },
{ 0x200540, "__do_global_ctors_aux" },
{ 0x200578, "_fini" },
};
struct _stp_section _stp_module_1_sections[] = {
{
.name = ".dynamic",
.symbols = _stp_module_1_symbols_0,
.num_symbols = sizeof(_stp_module_1_symbols_0)/sizeof(struct
_stp_symbol)
},
};
struct _stp_module _stp_module_1 = {
.name = "/tmp/libusymbols.so",
.dwarf_module_base = 0x200000,
[...]
Note how the dwarf_module_base is included in the addresses.
But for libc you will get:
struct _stp_symbol _stp_module_0_symbols_0[] = {
{ 0x7e74b0, "__libc_global_ctors" },
{ 0x7e74e0, "__libc_fini" },
{ 0x7e750f, "__i686.get_pc_thunk.bx" },
{ 0x7e7520, "__libc_init_first" },
{ 0x7e7530, "_dl_start" },
{ 0x7e7540, "_init" },
[...]
};
struct _stp_section _stp_module_0_sections[] = {
{
.name = ".dynamic",
.symbols = _stp_module_0_symbols_0,
.num_symbols = sizeof(_stp_module_0_symbols_0)/sizeof(struct
_stp_symbol)
},
};
struct _stp_module _stp_module_0 = {
.name = "/lib/libc.so.6",
.dwarf_module_base = 0x7d1000,
So the dwarf base is already extracted from the symbol addresses.