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

Alan Modra amodra@gmail.com
Fri Jan 12 10:45:00 GMT 2018


On Fri, Jan 12, 2018 at 10:29:45AM +0000, Nick Clifton wrote:
> 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.

Duh!  I hadn't even taken note of the fact that the section match
contained a wild card.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list