[PATCH] ld: Keep PREINIT_ARRAY/INIT_ARRAY/FINI_ARRAY sections for -r --gc-section

Nick Clifton nickc@redhat.com
Fri Jan 12 10:29:00 GMT 2018

Hi Alan,

> I'm wondering why we need this part
> given that if these were not wrapped in ${RELOCATING+} it seems like
> KEEP in the script ought to be good enough?

Ah ha - well I can answer that.  If we are performing a relocatable link
then we need to preserve the section names because they may contain a
priority suffix.  So for example we can input names like:


If the relocatable linker script contains something like:

  .init_array { KEEP (*(.init_array.*)) }

then these priority suffixes will be lost.


More information about the Binutils mailing list