[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
> 
>> +  ${RELOCATING+${PREINIT_ARRAY}}
>>    ${RELOCATING+${INIT_ARRAY}}
>>    ${RELOCATING+${FINI_ARRAY}}
> 
> 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:

  .init_array.100
  .fini_array.444
  .preinit_array.33

If the relocatable linker script contains something like:

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

then these priority suffixes will be lost.

Cheers
  Nick



More information about the Binutils mailing list