public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mjw@redhat.com>
To: systemtap <systemtap@sources.redhat.com>
Subject: Re: dwfl_module_relocate_address() versus base address
Date: Fri, 12 Dec 2008 18:15:00 -0000	[thread overview]
Message-ID: <1229105706.3397.120.camel@dijkstra.wildebeest.org> (raw)
In-Reply-To: <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.

  reply	other threads:[~2008-12-12 18:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-12 17:37 Mark Wielaard
2008-12-12 18:15 ` Mark Wielaard [this message]
2008-12-12 20:07 ` Roland McGrath
2008-12-15 12:07   ` Mark Wielaard
2008-12-15 13:42     ` Mark Wielaard
2008-12-16  9:12     ` Roland McGrath
2008-12-16 13:28       ` Mark Wielaard
2008-12-16 23:06         ` Roland McGrath
2008-12-17 15:37           ` Mark Wielaard
2008-12-18  0:00             ` Roland McGrath
2008-12-18 14:50               ` Mark Wielaard
2008-12-18 23:59                 ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1229105706.3397.120.camel@dijkstra.wildebeest.org \
    --to=mjw@redhat.com \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).