[patch] Weak definition operrides strong definition

Paul Brook paul@codesourcery.com
Mon May 2 01:44:00 GMT 2005


When linking a mixture of strong and weak symbols the attributes (size, type) 
of the resulting symbol is the size/type of the last symbol seen, not the 
strong definition. This breaks Arm interworking when linking an arm 
(STT_FUNC) weak definition and a thumb (STT_ARM_TFUNC) strong definition, and 
vice versa. If the weak definition appears after the strong definition the 
symbol is given the STT_FUNC, and the wrong interworking stubs are generated.

This bug could also cause problems with utilities that use the st_size field.

The attached files demonstrate the problem. Compile with gcc foo1.c foo2.c and 
the "foo" symbol will have the address of the smaller routine, but the size 
of the larger.

The attached patch fixes this by skipping weak definitions if we have already 
seen a non-weak definition.

Tested on i686-linux and arm-none-eabi.
Ok?

Paul

2005-05-01  Paul Brook  <paul@codesourcery.com>

	* elflink.c (_bfd_elf_merge_symbol): Skip weak definitions if a strong
	definition has already been seen.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo1.c
Type: text/x-csrc
Size: 53 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20050502/28035cfb/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo2.c
Type: text/x-csrc
Size: 100 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20050502/28035cfb/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.weak_def
Type: text/x-diff
Size: 789 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20050502/28035cfb/attachment-0002.bin>


More information about the Binutils mailing list