I know the ELF spec has been unmaintained since ~2015 and acknowledge the
> It was never the intent of the gABI to specify the details of how linkers should combine sections
I am sending the message just to ask about the most sensible behavior regarding
linking unrecognized SHF_LINK_ORDER sections.
The latest wording update about SHF_LINK_ORDER (unofficial but agreed by multiple
parties and implemented in more than one linkers) I can find is
SHF_LINK_ORDER
This flag adds special ordering requirements for link editors. The
requirements apply to the referenced section identified by the sh_link
field of this section's header. If this section is combined with other
sections in the output file, the section must appear in the same
relative order with respect to those sections, as the referenced
section appears with respect to sections the referenced section is
combined with.
A typical use of this flag is to build a table that references
text or data sections in address order.
In addition to adding ordering requirements, SHF_LINK_ORDER indicates
that the section contains metadata describing the referenced section.
When performing unused section elimination, the link editor should
ensure that both the section and the referenced section are retained
or discarded together. Furthermore, relocations from this section
into the referenced section should not be taken as evidence that the
referenced section should be retained.
Say, we have two SHF_LINK_ORDER sections named foo. They link .init and .text, respectively.
sh_link(foo [1]) = .init
sh_link(foo [2]) = .text
(An output section description in a linker script can force the combination rules.
Input section descriptions are name based. Mixing input sections linking to different sections is unavoidable.)
Question 1: Should the linker create two output sections foo? If there is only one output section,
the output section will contain two input sections linking different output sections (.init and .text).
The sh_link field may be arbitrarily set to one of .init and .text, or 0 to represent a mixed status.
Question 2: GNU ld compatible linkers define __start_sectionname / __stop_sectionname (even in the presence of an output section description of foo). When there are multiple output sections named 'foo', __start_foo/__stop_foo can only arbitrarily refer to one of them.
For linker implementers, shall we consider __start_sectionname / __stop_sectionname an ugly hack and say it does not work well with SHF_LINK_ORDER sections?
If so, can we provide an alternative to __start_sectionname / __stop_sectionname?
Note, from the execution view, the section header table is optional. __start_sectionname/__stop_sectionname can be made into DT_SYMTAB