davids5 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1691421342
> > 1. 2 entries seem redundant.
>
> Do you mean init_array and init_array.*? init_array could be removed.
>
> > 2. SORT breaks priority. Set by priority or link order. ( When the SORT
keyword is used, the linker will sort the files or sections into ascending
order by name before placing them in the output file.)
>
> No, the patch fixes the priority issue instead, here is the output from
gcc -Wl,-verbose:
>
> ```
> .init_array :
> {
> PROVIDE_HIDDEN (__init_array_start = .);
> KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)
SORT_BY_INIT_PRIORITY(.ctors.*)))
> KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o
*crtend?.o ) .ctors))
> PROVIDE_HIDDEN (__init_array_end = .);
> }
> .fini_array :
> {
> PROVIDE_HIDDEN (__fini_array_start = .);
> KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)
SORT_BY_INIT_PRIORITY(.dtors.*)))
> KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o
*crtend?.o ) .dtors))
> PROVIDE_HIDDEN (__fini_array_end = .);
> }
> ```
>
> you can see the stock linker script add SORT_BY_INIT_PRIORITY. @cuiziweizw
please change SORT to SORT_BY_INIT_PRIORITY.
>
> > 3. If it is not referenced why keep it at all?
>
> since nobody reference symbols in init_array section, the linker will
remove all entries and related code from final image without KEEP. You can see
the stock linker script contain KEEP too.
@xiaoxiang781216 Thank you for digging into the details here.
Is SORT_BY_INIT_PRIORITY portable? What is the default?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]