This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Correct elf_merge_st_other arguments for weak symbols
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Sat, 14 Dec 2013 13:19:18 +1030
- Subject: Correct elf_merge_st_other arguments for weak symbols
- Authentication-results: sourceware.org; auth=none
This fixes a bug found when building the Linux kernel for PowerPC64
ELFv2. We were linking an object with a weakly defined fall-back
function following an object with the corresponding strongly defined
function. This wrongly picked up st_other for the weak symbol rather
than keeping the strong symbol's st_other, due to calling
elf_backend_merge_symbol_attribute with "definition" true.
I reckon this case (strong sym followed by weak) shouldn't count as
finding a new definition, and fixing the ppc64 problem in
_bfd_elf_merge_symbol is likely to fix a similar bug in alpha.
BTW, other targets that define elf_backend_merge_symbol_attribute look
quite buggy to me. For example, mips and sh64 don't seem to allow
clearing of bits in st_other when a weak symbol with some st_other
bits set is followed by a strong symbol with zero st_other.
Committed mainline, and will commit to the 2.24 branch after a day or
two if that's OK with you Tristan?
* elflink.c (_bfd_elf_merge_symbol): If merging a new weak
symbol that will be skipped, we don't have a new definition.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 1e6abd9..999cf26 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1437,7 +1437,10 @@ _bfd_elf_merge_symbol (bfd *abfd,
if (!(oldbfd != NULL
&& (oldbfd->flags & BFD_PLUGIN) != 0
&& (abfd->flags & BFD_PLUGIN) == 0))
- *skip = TRUE;
+ {
+ newdef = FALSE;
+ *skip = TRUE;
+ }
/* Merge st_other. If the symbol already has a dynamic index,
but visibility says it should not be visible, turn it into a
--
Alan Modra
Australia Development Lab, IBM