From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2131 invoked by alias); 12 Dec 2008 18:15:43 -0000 Received: (qmail 2122 invoked by uid 22791); 12 Dec 2008 18:15:42 -0000 X-Spam-Level: * X-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_MX,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Dec 2008 18:15:09 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id mBCIF7R5012260 for ; Fri, 12 Dec 2008 13:15:08 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mBCIF7ep008211 for ; Fri, 12 Dec 2008 13:15:07 -0500 Received: from [10.32.10.26] (vpn-10-26.str.redhat.com [10.32.10.26]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mBCIF6iV012411 for ; Fri, 12 Dec 2008 13:15:07 -0500 Subject: Re: dwfl_module_relocate_address() versus base address From: Mark Wielaard To: systemtap In-Reply-To: <1229103422.3397.98.camel@dijkstra.wildebeest.org> References: <1229103422.3397.98.camel@dijkstra.wildebeest.org> Content-Type: text/plain Date: Fri, 12 Dec 2008 18:15:00 -0000 Message-Id: <1229105706.3397.120.camel@dijkstra.wildebeest.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2008-q4/txt/msg00557.txt.bz2 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.