This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Don't set breakpoints on import stubs on Windows amd64
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 26 Mar 2015 10:21:50 -0000
- Subject: [binutils-gdb] Don't set breakpoints on import stubs on Windows amd64
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=20d35291fb30a2fa5de46af56887f9bc4da7e53e
commit 20d35291fb30a2fa5de46af56887f9bc4da7e53e
Author: Pedro Alves <palves@redhat.com>
Date: Thu Mar 26 10:21:07 2015 +0000
Don't set breakpoints on import stubs on Windows amd64
On Windows amd64, setting a breakpoint on a symbol imported from a
shared library after that library is loaded creates a breakpoint with
two locations, one on the import stub, and another in the shared
library, while on i386, the breakpoint is only set in the shared
library.
This is due to the minimal symbol for the import stub not being
correctly given the type mst_solib_trampoline on Windows amd64, unlike
Windows i386.
As currently written, coff_symfile_read is always skipping over the
character after the "__imp_" (amd64) or "_imp_" (i386) prefix,
assuming that it is '_'. However, while i386 is an underscored
target, amd64 is not.
On x86_64-pc-cygwin, it fixes:
- FAIL: gdb.base/solib-symbol.exp: foo in libmd
+ PASS: gdb.base/solib-symbol.exp: foo in libmd
Unfortunately, several other tests which passed now fail but that's
because this issue was masking other problems.
No change on i686-pc-cygwin.
gdb/ChangeLog:
2015-03-26 Pedro Alves <palves@redhat.com>
Jon TURNEY <jon.turney@dronecode.org.uk>
* coffread.c (coff_symfile_read): When constructing the name of an
import stub symbol from import symbol for amd64, only skip the
char after _imp_ if the target is underscored (like i386) and the
char is indeed the target's leading char.
Diff:
---
gdb/ChangeLog | 8 ++++++++
gdb/coffread.c | 37 ++++++++++++++++++++++++-------------
2 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index febc377..66bfbae 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2015-03-26 Pedro Alves <palves@redhat.com>
+ Jon TURNEY <jon.turney@dronecode.org.uk>
+
+ * coffread.c (coff_symfile_read): When constructing the name of an
+ import stub symbol from import symbol for amd64, only skip the
+ char after _imp_ if the target is underscored (like i386) and the
+ char is indeed the target's leading char.
+
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 28f7b18..3b5a968 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -671,20 +671,31 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
or "_imp_", get rid of the prefix, and search the minimal
symbol in OBJFILE. Note that 'maintenance print msymbols'
shows that type of these "_imp_XXXX" symbols is mst_data. */
- if (MSYMBOL_TYPE (msym) == mst_data
- && (startswith (name, "__imp_")
- || startswith (name, "_imp_")))
+ if (MSYMBOL_TYPE (msym) == mst_data)
{
- const char *name1 = (name[1] == '_' ? &name[7] : &name[6]);
- struct bound_minimal_symbol found;
-
- found = lookup_minimal_symbol (name1, NULL, objfile);
- /* If found, there are symbols named "_imp_foo" and "foo"
- respectively in OBJFILE. Set the type of symbol "foo"
- as 'mst_solib_trampoline'. */
- if (found.minsym != NULL
- && MSYMBOL_TYPE (found.minsym) == mst_text)
- MSYMBOL_TYPE (found.minsym) = mst_solib_trampoline;
+ const char *name1 = NULL;
+
+ if (startswith (name, "_imp_"))
+ name1 = name + 5;
+ else if (startswith (name, "__imp_"))
+ name1 = name + 6;
+ if (name1 != NULL)
+ {
+ int lead = bfd_get_symbol_leading_char (objfile->obfd);
+ struct bound_minimal_symbol found;
+
+ if (lead != '\0' && *name1 == lead)
+ name1 += 1;
+
+ found = lookup_minimal_symbol (name1, NULL, objfile);
+
+ /* If found, there are symbols named "_imp_foo" and "foo"
+ respectively in OBJFILE. Set the type of symbol "foo"
+ as 'mst_solib_trampoline'. */
+ if (found.minsym != NULL
+ && MSYMBOL_TYPE (found.minsym) == mst_text)
+ MSYMBOL_TYPE (found.minsym) = mst_solib_trampoline;
+ }
}
}
}