From cab0ad8332b5c0f3d010d55ff094b08ffd278a88 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Thu, 26 Apr 2012 14:38:45 +0000 Subject: [PATCH] * 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. --- bfd/ChangeLog | 7 +++++++ bfd/elf32-m68k.c | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 115cd7c0eba..a85cee116f2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2012-04-26 Andreas Schwab + + * 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. + 2012-04-26 Hans-Peter Nilsson Provide a way for programs to recognize BFD_ASSERT calls. diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 47dece2c4e0..78d7464f427 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->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; } -- 2.30.2