This is the mail archive of the
mailing list for the binutils project.
Re: [GOLD] Reduce size of class Symbol
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sun, 27 Aug 2017 22:15:44 -0700
- Subject: Re: [GOLD] Reduce size of class Symbol
- Authentication-results: sourceware.org; auth=none
- References: <20170801041614.GN1956@bubble.grove.modra.org> <CAJimCsGh3rPDRMUDEx97ryrcHJMi5U=ceGXpBXU4ZOSK7H=-iQ@mail.gmail.com> <20170804060056.GA7551@bubble.grove.modra.org>
>> I like the goal, but the problem is that you're always accessing the
>> plt_offset through the u_.from_object variant, no matter what variant
>> is actually there. While you've been careful to make sure that the
>> plt_offset field has the same offset in each variant, it's still both
>> fragile and technically illegal.
> This trick is allowed by the ISO C standard according to the
> following, and I'm assuming is also valid for C++. Re accessing via
> the from_object variant, yes I guess it might be better style to
> create a new struct union member just containing plt_offset.
> From ISO/IEC 9899:1999 section 126.96.36.199 Structure and union members
> 5 One special guarantee is made in order to simplify the use of
> unions: if a union contains several structures that share a common
> initial sequence (see below), and if the union object currently
> contains one of these structures, it is permitted to inspect the
> common initial part of any of them anywhere that a declaration of
> the completed type of the union is visible. Two structures share a
> common initial sequence if corresponding members have compatible
> types (and, for bit-fields, the same widths) for a sequence of one
> or more initial members.
Still seems fragile to me -- you don't get any static checking that
the conditions are met. I prefer to split the union into two.