This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Does gold support deadcode elimination on relocatable files
"Neo Jia" <neojia@gmail.com> writes:
>> There is work underway to do deadcode elimination, but not during a
>> relocatable link.
>
> Could you show the reason why you don't have this for a relocatable file?
To expand on what Cary said, garbage collection for a relocatable link
is significantly different from garbage collection for a link of an
executable. When linking an executable you have a precisely defined
root set for garbage collection: the entry point, any symbols
specified with -u, any symbols in certain magic sections like .ctors.
When doing a relocatable link there is no root set. You wind up
keeping everything.
After the garbage collection patch for executables is committed, it
would be perfectly reasonable to extend it by providing a mechanism
for specifying an explicit root set. At that time it would be
reasonable to enable garbage collection for relocatable links when a
root set is specified. This work would not require any significant
changes to the existing garbage collection work.
Ian