This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] m68k: fix weak undefined PIE tests
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: binutils at sourceware dot org
- Date: Mon, 23 Apr 2012 20:04:40 +0200
- Subject: [PATCH] m68k: fix weak undefined PIE tests
This fixes the "weak undefined" and "weak undefined data" tests from
ld-pie/pie.exp for m68k. I didn't seen them before because they are
only run during native build. Tested on m68k-linux.
Andreas.
* elf32-m68k.c (elf_m68k_check_relocs): Mark non-GOT references
also when generating PIE.
(elf_m68k_discard_copies): Mark undefined weak symbols referenced
by relocations as dynamic.
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index d398fba..5c95eec 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -2827,7 +2827,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
turns out to be a function defined by a dynamic object. */
h->plt.refcount++;
- if (!info->shared)
+ if (!info->shared || info->executable)
/* This symbol needs a non-GOT reference. */
h->non_got_ref = 1;
}
@@ -3479,6 +3479,18 @@ elf_m68k_discard_copies (h, inf)
}
}
+ /* Make sure undefined weak symbols are output as a dynamic symbol
+ in PIEs. */
+ if (h->non_got_ref
+ && h->root.type == bfd_link_hash_undefweak
+ && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ && h->dynindx == -1
+ && !h->forced_local)
+ {
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
+ }
+
return TRUE;
}
--
1.7.10
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."