public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* using dwfl_module_build_id in systemtap
@ 2007-10-16  9:49 Roland McGrath
  0 siblings, 0 replies; only message in thread
From: Roland McGrath @ 2007-10-16  9:49 UTC (permalink / raw)
  To: systemtap

Now on the systemtap ftp site and coming soon to Fedora systems near you,
is elfutils-0.130.  This version adds support for build IDs.  These are
present in Fedora 8 builds (both in the Fedora-supplied builds and in all
normal compiles done with F8 tools) and will eventually become the norm in
all new systems with new toolchains.  

Build ID support has various good effects on finding and using separate
debuginfo files.  These are implicit just by installing the new library,
and are not especially apropros to Systemtap.

The interesting addition is dwfl_module_build_id (see libdwfl.h).  For each
given module (vmlinux, .ko, etc.) this tells you about the build ID.  It
returns 0 if there is no ID, or the length of the ID.  When there is an ID
it yields both the bitstring and the address at which those bits should
appear in the module's loaded memory image.  This address should be treated
like other addresses from libdwfl, adjusted with dwfl_module_relocate_address.

What this enables is having module code do something like:

static const unsigned char mod_kernel_id[40] __initdata = { 0xab, 0xcd, ... };

__init int module_init()	
{
	...
#define mod_kernel_id_vaddr ((void *)relocated_addr(kernel, 0x123467))
	if (memcmp(mod_kernel_id, mod_kernel_id, mod_kernel_id_vaddr))
		return -EXDEV;	/* some pithy error */
	...
}

and another such for each module whose ELF or DWARF info informed the probe
translation.  This is a very reliable way to sanity check that you really
are dealing with the target code you compiled for, before you insert kprobes.


Enjoy,
Roland

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-16  9:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-16  9:49 using dwfl_module_build_id in systemtap Roland McGrath

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).