Hi Roland,
Thanks for the concrete description. Saying that
I "failed to account" gives me too much credit --- I
didn't really understand the "why" underneath this
question at all, so this is very helpful.
I'm not sure that I agree that there's necessarily a bug
in the ELF spec regarding the handling of the signature symbol.
The spec says nothing about the signature symbol itself --- it
is merely a name donor. That, and the presence of the flags
field (with unassigned bits as well as GRP_COMDAT) suggests
that the intent is to allow flexibility for possible future uses,
which may or may not involve comdat. One can at least imagine
some scenarios where a local symbol might be appropriate for one
of these unknown future uses. At the same time, substituting the
section name for the nameless STT_SECTION symbol is something
that happens in other contexts, and if the section symbol provides a
sufficiently unique name, I don't know why a compiler should
have to create some other symbol (probably with the same name)
just to avoid using it.
So it's arguable. Maybe you're right, but another way to view
this is that the design isn't wrong, but simply provides a great
deal of flexibility by intentionally not over specifying (which
is very ELF-like, IMO). In any event, changing it would be way
too painful now, so let's try to assume that it's right, and see
if there isn't a "correct" solution that fits the existing rules.
I think your solution A is it. To expand, I think that
there are logically 2 distinct groups involved: an initial
COMDAT group, and then later, a new non-COMDAT one. Confusingly,
they have the same name, and contain the same sections, but
they serve different purposes.
When a link-editor creates a "final" object (executable
or shared object), one of the things it does, after processing
groups, is to discard the group section, and the SHF_GROUP flags,
from the result. At this point, their purpose has been served,
and their continued presence would be confusing at best.
It seems to me that the step (3) in your description below is a
sort of finalization, in which the COMDAT processing has been
done. It would make sense for objcopy to remove the group section,
and flags, after doing this.
However, we also want to indicate to the next linking stage, that
garbage collection on these sections is indivisible. A group
is also the answer to that problem, but not a COMDAT group,
just a plain group. Logically, you might view this as finalizing
away the COMDAT group, and then creating a new non-COMDAT group
with the same name, and sections, for this distinct new purpose. Of
course, given that only the GRP_COMDAT flag differs between the old
group and the new one, we don't really have to do all that. Removing
the GRP_COMDAT flag amounts to the same thing.
To sum up, it sounds to me like objcopy failing to remove the
GRP_COMDAT as part of step 3 in this process was the bug, and
that your solution A is the right fix. And of course, it's *way*
easier and quicker than solution B. And, far more straightforward
than requiring future link-edits to second guess the intent
behind mislabeled GRP_COMDAT groups based on the type of their
signature symbol.
- Ali
> To unsubscribe from this group and stop receiving emails from it, send an email to
generic-abi...@googlegroups.com <mailto:
generic-abi%2Bunsu...@googlegroups.com>.
> <
https://groups.google.com/d/msgid/generic-abi/8997d0f8-92d5-60fd-e20b-8dc7435965d3%40emvision.com>.
>
> --
> You received this message because you are subscribed to the Google Groups "Generic System V Application Binary Interface" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
generic-abi...@googlegroups.com <mailto:
generic-abi...@googlegroups.com>.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/generic-abi/CAB%3D4xho8wnuiMDTtYc9AWh1wrHVS8wABRCu7pbaY_Qk0PoRpsA%40mail.gmail.com
> <
https://groups.google.com/d/msgid/generic-abi/CAB%3D4xho8wnuiMDTtYc9AWh1wrHVS8wABRCu7pbaY_Qk0PoRpsA%40mail.gmail.com?utm_medium=email&utm_source=footer>.