Fix generic linker symbol output when weak is overridden by strong

Alan Modra amodra@gmail.com
Wed Dec 24 04:52:00 GMT 2014


This fixes defined6 failures for ELF targets using the generic linker.
When a weak symbol is overridden by a strong one, we want the output
symbol to be strong rather than weak.  Yes, I know this also affects
bfd_link_hash_indirect due to the fall through, but output of indirect
and warning symbols looks quite broken anyway.  Presumably no one
cares about such things.

	* linker.c (_bfd_generic_link_output_symbols): Remove BSF_WEAK
	flag from bfd_link_hash_defined symbols.

diff --git a/bfd/linker.c b/bfd/linker.c
index 9223810..083a250 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -2136,7 +2136,7 @@ _bfd_generic_link_output_symbols (bfd *output_bfd,
 		  /* fall through */
 		case bfd_link_hash_defined:
 		  sym->flags |= BSF_GLOBAL;
-		  sym->flags &=~ BSF_CONSTRUCTOR;
+		  sym->flags &=~ (BSF_WEAK | BSF_CONSTRUCTOR);
 		  sym->value = h->root.u.def.value;
 		  sym->section = h->root.u.def.section;
 		  break;

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list