Bug 12578

Summary: Alignment of a common symbol overridden by a definition
Product: binutils Reporter: Dmitry Gorbachev <d.g.gorbachev>
Component: ldAssignee: unassigned
Status: RESOLVED INVALID    
Severity: normal    
Priority: P2    
Version: 2.22   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: Testcase

Description Dmitry Gorbachev 2011-03-13 17:37:50 UTC
(I don't know is it related to / a duplicate of PR12564.)

ld.bfd gives a warning: "/usr/bin/ld: Warning: alignment 4 of symbol `baz' in /tmp/ccEJaaP0.o is smaller than 16 in /tmp/ccs1dDrt.o"; ld.gold doesn't even warn.

I think the linker should choose the largest alignment, as it already does when merging multiple common symbols.
Comment 1 Dmitry Gorbachev 2011-03-13 17:38:56 UTC
Created attachment 5303 [details]
Testcase

Compile it with GCC 4.5 or later and `-O3 -march=pentium3' options.
Comment 2 H.J. Lu 2011-03-14 13:48:29 UTC
Linker can change alignment of a common symbol. But
it can't change alignment of a definition.