SHF_LINK_ORDER and --gc-sections

Fangrui Song i@maskray.me
Wed Nov 20 04:33:00 GMT 2019


This ELF spec says very little about SHF_LINK_ORDER http://www.sco.com/developers/gabi/latest/ch4.sheader.html#special_sections :

> SHF_LINK_ORDER
> This flag adds special ordering requirements for link editors. The requirements apply if the sh_link field of this section's header references another section (the linked-to section). If this section is combined with other sections in the output file, it must appear in the same relative order with respect to those sections, as the linked-to section appears with respect to sections the linked-to section is combined with.

In
https://groups.google.com/forum/#!msg/generic-abi/_CbBM6T6WeM/9nNnwRNHAQAJ ,
people reached consensus that we should extend the semantics of
SHF_LINK_ORDER (underexploited before, but gains some usage recently for
metadata) to interact better with garbage collection. The idea was
implemented in lld. Below are the cases that I find GNU ld and lld
differ. Each issue can be seen as a feature request:)

Generalize GC support for SHF_LINK_ORDER
https://sourceware.org/bugzilla/show_bug.cgi?id=24526

Garbage collecting non-alloc SHF_LINK_ORDER sections
https://sourceware.org/bugzilla/show_bug.cgi?id=25021

Make /DISCARD/ discard SHF_LINK_ORDER sections
https://sourceware.org/bugzilla/show_bug.cgi?id=25022



More information about the Binutils mailing list