bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug binutils/19446] BFD linker discards section without alloc secti


From: Nick Clifton
Subject: Re: [Bug binutils/19446] BFD linker discards section without alloc section attribute under certain conditions
Date: Fri, 22 Jan 2016 09:43:47 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

Hi Xinliangli,

However I do think ld's behavior is
not correct here. Should linker first decide if some sections are 'root'
sections that should not be throw away and then decide if other sections should
be GCed? Here linker first prunes the references and then is forced to discard
section not because it should do so, but to make the link succeed.

Yes, but... the linker has not been told that the UNREF section is a root 
section.  If the test had used a linker script that specified that the UNREF 
section should be kept[1] then the linker would have acted differently.  It 
would keep the UNREF section and g0 variable and everything would have worked 
as expected.

Since however the UNREF section is an orphan section, the linker has more latitude in what it can do. The LD linker decides that since the section has relocations against it, and since these relocations refers to symbols which are otherwise unused, then it makes sense to discard the section. You disagree with this decision. I don't. But since there are several available workarounds, and, as far as I know, it is not breaking real programs, I do not plan to make any changes to the linker.

Cheers
  Nick

[1] ie:

  UNREF : { KEEP (*(UNREF)) }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]