I'll try to answer your question for Solaris. I'm not sure I
fully understand the question, but I think I understand enough
to do the experiment. I do understand that you're trying to use
SHF_LINK_ORDER to represent a relationship between a text section
and a related "meta data" section, and that you're trying to achieve
this without using the ELF comdat group mechanism.
From Alan's comments in the bug, I gather that the sections refer
to each other, or perhaps to themselves, using SHF_LINK_ORDER. I'm
not sure how to interpret "self-link", but I'm sure it's one of those:
> How exactly is the proposed SHF_LINK_ORDER trick supposed
> to work? A reference to start_foo/stop_foo symbols from
> a kept section currently marks all input sections named
> foo as kept. Are you suggesting that any section named
> foo that is SHF_LINK_ORDER with a self-link should not
> be marked? But those foo that do not have a self-link
> should be marked?
I can't easily create your exact scenario, but I did an experiment
using this little hello world variant:
#include <stdio.h>
static void f2(void);
static void
f1(void)
{
printf("f1 \n");
f2();
}
static void
f2(void)
{
printf("f2 \n");
f1();
}
int
main(int argc, char **argv)
{
printf("hello \n");
}
If f1 or f2 were ever called, this program would fill the
stack and die, but here, they're unused, and just a way
to experiment with unused material processing.
Compiling this with the option to put each function in a separate
section yields sections for f1() and f2(), which are related to
each other, but not accessed by anything else. If I link this normally,
the sections are kept, but if I link with the option to discard
unused sections, f1() and f2() are discarded.
With that as a baseline, I took a copy of the relocatable object,
and modified the section headers for the f1 and f2 sections to add
SHF_LINK_ORDER and set sh_link. I did 2 versions of this experiment:
1) The sh_link for f1 references f2, and the sh_link for
f2 references f1.
2) The sh_link for each section references itself.
In both cases, the objects linked cleanly, with no infinite
loops, and turning on the option to discard unused sections
eliminated the f1 and f2 sections. In both cases, the apparent
behavior is as if none of these SHF_LINK_ORDER games were being
played.
I hope that helps. If I've misunderstood your question to the
point where the above isn't useful, let me know.
- Ali