* [PATCH] win32: Lookup symbols in the EA Table by ordinal
@ 2011-06-12 11:57 Paul Bolle
2011-06-13 18:39 ` Christopher Faylor
0 siblings, 1 reply; 3+ messages in thread
From: Paul Bolle @ 2011-06-12 11:57 UTC (permalink / raw)
To: gdb-patches
Gdb currently looks up the address of a symbol in the Ordinal/Name
Pointer Table and Export Address Table as if those tables have the same
ordering. That is not always correct. Therefore gdb should look up a
symbol's ordinal in the O/NP table and use that ordinal to look up the
symbol's address in the EA table.
This should fix http://sourceware.org/bugzilla/show_bug.cgi?id=12716
Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
gdb/ChangeLog | 6 ++++++
gdb/coff-pe-read.c | 16 +++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c72fda4..84d6892 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-12 Paul Bolle <pebolle@tiscali.nl>
+
+ * coff-pe-read.c (read_pe_exported_syms): Lookup symbols in the Export
+ Address Table by ordinal.
+ * coff-pe-read.c (pe_as16): New.
+
2011-06-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* symtab.c (output_partial_symbol_filename): Exchange the filename and
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)
}
}
\f
+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;
--
1.7.5.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] win32: Lookup symbols in the EA Table by ordinal
2011-06-12 11:57 [PATCH] win32: Lookup symbols in the EA Table by ordinal Paul Bolle
@ 2011-06-13 18:39 ` Christopher Faylor
2011-06-15 8:14 ` Paul Bolle
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Faylor @ 2011-06-13 18:39 UTC (permalink / raw)
To: Paul Bolle, gdb-patches
On Sun, Jun 12, 2011 at 01:56:51PM +0200, Paul Bolle wrote:
>Gdb currently looks up the address of a symbol in the Ordinal/Name
>Pointer Table and Export Address Table as if those tables have the same
>ordering. That is not always correct. Therefore gdb should look up a
>symbol's ordinal in the O/NP table and use that ordinal to look up the
>symbol's address in the EA table.
>
>This should fix http://sourceware.org/bugzilla/show_bug.cgi?id=12716
>
>Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
>---
> gdb/ChangeLog | 6 ++++++
> gdb/coff-pe-read.c | 16 +++++++++++++---
> 2 files changed, 19 insertions(+), 3 deletions(-)
>
>diff --git a/gdb/ChangeLog b/gdb/ChangeLog
>index c72fda4..84d6892 100644
>--- a/gdb/ChangeLog
>+++ b/gdb/ChangeLog
>@@ -1,3 +1,9 @@
>+2011-06-12 Paul Bolle <pebolle@tiscali.nl>
>+
>+ * coff-pe-read.c (read_pe_exported_syms): Lookup symbols in the Export
>+ Address Table by ordinal.
>+ * coff-pe-read.c (pe_as16): New.
>+
This looks ok except for the unneeded reordering of the function. I didn't see
any reason to move ordbase or expdata.
cgf
> 2011-06-10 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * symtab.c (output_partial_symbol_filename): Exchange the filename and
>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)
> }
> }
> \f
>+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;
>--
>1.7.5.4
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] win32: Lookup symbols in the EA Table by ordinal
2011-06-13 18:39 ` Christopher Faylor
@ 2011-06-15 8:14 ` Paul Bolle
0 siblings, 0 replies; 3+ messages in thread
From: Paul Bolle @ 2011-06-15 8:14 UTC (permalink / raw)
To: gdb-patches
On Mon, 2011-06-13 at 14:38 -0400, Christopher Faylor wrote:
> This looks ok except for the unneeded reordering of the function. I didn't see
> any reason to move ordbase or expdata.
0) Thanks for the review.
1) Moving ordbase and exp_funcbase was mainly a nitpick (which wouldn't
justify a separate patch): I prefer file parsing code to match the
structure of the file format it parses (wherever that is feasible). And
here the code is jumping around the PE format for no apparent reason.
Paul Bolle
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-06-15 8:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-12 11:57 [PATCH] win32: Lookup symbols in the EA Table by ordinal Paul Bolle
2011-06-13 18:39 ` Christopher Faylor
2011-06-15 8:14 ` Paul Bolle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox