This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] Fix PR ld/24574
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: binutils at sourceware dot org
- Date: Thu, 05 Sep 2019 17:56:57 +0200
- Subject: [patch] Fix PR ld/24574
Hi,
when I overhauled the auto-import feature of the PE-COFF linker about one year
ago, I dropped a line in pe_find_data_imports because it was surrounded by a
slightly scary comment:
- /* We replace original name with __imp_ prefixed, this
- 1) may trash memory 2) leads to duplicate symbol generation.
- Still, IMHO it's better than having name polluted. */
- undef->root.string = sym->root.string;
As reported in the PR, the __imp_ prefix is needed in DLLs by GDB to recognize
that this is an import symbol and not the real one when the symbol is extern,
so the attached patch simply puts the line back.
Tested on i686-pc-mingw32, OK for mainline, 2.32 and 2.31 branches?
2019-09-05 Eric Botcazou <ebotcazou@adacore.com>
ld/
PR ld/24574
* pe-dll.c (pe_find_data_imports): Replace again the original name of
the undefined symbol with the __imp_ prefixed one after it is resolved.
--
Eric Botcazou
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 81ab116c46..577b911da8 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -1445,6 +1445,11 @@ pe_find_data_imports (const char *symhead,
undef->u.def.value = sym->u.def.value;
undef->u.def.section = sym->u.def.section;
+ /* We replace the original name with the __imp_ prefixed one, this
+ 1) may trash memory 2) leads to duplicate symbols. But this is
+ better than having a misleading name that can confuse GDB. */
+ undef->root.string = sym->root.string;
+
if (link_info.pei386_auto_import == -1)
{
static bfd_boolean warned = FALSE;