From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14728 invoked by alias); 29 Apr 2011 19:20:03 -0000 Received: (qmail 14652 invoked by uid 22791); 29 Apr 2011 19:20:02 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Apr 2011 19:19:48 +0000 From: "pebolle at tiscali dot nl" To: gdb-prs@sourceware.org Subject: [Bug win32/12716] New: addresses of exported symbols of a DLL should be looked up by ordinal X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: win32 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pebolle at tiscali dot nl X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Fri, 29 Apr 2011 19:20:00 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org X-SW-Source: 2011-q2/txt/msg00257.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=12716 Summary: addresses of exported symbols of a DLL should be looked up by ordinal Product: gdb Version: 7.2 Status: NEW Severity: normal Priority: P2 Component: win32 AssignedTo: unassigned@sourceware.org ReportedBy: pebolle@tiscali.nl 0) I ran into a PE32 DLL that exports a number of symbols. objdump shows it uses an "Export Address Table", a "Name Pointer Table" and an "Ordinal Table". 1) If you look at objdump's dump of the EA table and the "[Ordinal/Name Pointer] Table" one sees that the O/NP table is (basically) unsorted: it's neither sorted on ordinal nor (alphabetically) on the symbols. BUT (the version of) gdb (that I use) looks up the address of a symbol in the O/NP table as if that tables has the same order as the EA table. But what gdb actually should do is: look up a symbol in the O/NP table, get its ordinal and look up an address in the EA table using that ordinal. 2) I just happened to use gdb with a couple of symbols (which, as I knew from wine's debugging output, were really used) that gdb mapped to addresses that simply were not used at all in the code paths I apparently ran. This confusing behaviour quickly made me think that gdb never set pending breakpoints in that DLL (which I knew as loaded at runtime through LoadLibraryA). Hence the feeling I ran into the issue reported in bug #9474. 3) A (still untested) patch for this issue: diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index ca87b72..0483158 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -150,6 +150,14 @@ read_pe_truncate_name (char *dll_name) } } +static unsigned int +pe_as16 (void *ptr) +{ + unsigned char *b = ptr; + + return b[0] + (b[1] << 8); +} + /* Low-level support functions, direct from the ld module pe-dll.c. */ static unsigned int pe_get16 (bfd *abfd, int where) @@ -309,11 +317,11 @@ read_pe_exported_syms (struct objfile *objfile) bfd_bread (expdata, (bfd_size_type) export_size, dll); erva = expdata - export_rva; + ordbase = pe_as32 (expdata + 16); /* unused */ nexp = pe_as32 (expdata + 24); + exp_funcbase = pe_as32 (expdata + 28); name_rvas = pe_as32 (expdata + 32); ordinals = pe_as32 (expdata + 36); - ordbase = pe_as32 (expdata + 16); - exp_funcbase = pe_as32 (expdata + 28); /* Use internal dll name instead of full pathname. */ dll_name = pe_as32 (expdata + 12) + erva; @@ -339,8 +347,10 @@ read_pe_exported_syms (struct objfile *objfile) /* Pointer to the names vector. */ unsigned long name_rva = pe_as32 (erva + name_rvas + i * 4); + unsigned long ordinal = pe_as16 (erva + ordinals + i * 2); + /* Pointer to the function address vector. */ - unsigned long func_rva = pe_as32 (erva + exp_funcbase + i * 4); + unsigned long func_rva = pe_as32 (erva + exp_funcbase + ordinal * 4); /* Find this symbol's section in our own array. */ int sectix = 0; -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.