This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld: --gc-sections incompatible with --emit-relocs ?


Hi David,

After some tests, it appears that I also specify --emit-relocs on the
linker line, and removing this --emit-relocs causes --gc-sections to
work as expected.

Is any of you aware of such a limitation ?

Yes. The problem is that if relocations are being emitted, then the linker cannot safely discard sections. This is because the linker does not know why the relocations are being emitted, so it cannot tell if the relocations associated with (potentially) garbage collected sections should be emitted or not.


I did not find any reference in the manual.

True, this should be documented. I will fix that.


I would appreciate any hints on how to try to remove/workaround this limitation.

You would need to add extra code to the linker. Probably a new command line switch to tell the linker to aggressively garbage collect sections. You will need to make sure that any section that is removed in this way also has any relocations associated with it removed from its equivalent *.rel or *.rela section. (Or at least not emitted when the other relocs are emitted).


Cheers
  Nick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]