[GOLD] Reduce size of class Symbol
Alan Modra
amodra@gmail.com
Fri Aug 4 06:05:00 GMT 2017
More information about the Binutils mailing list
Fri Aug 4 06:05:00 GMT 2017
- Previous message (by thread): [GOLD] Reduce size of class Symbol
- Next message (by thread): [GOLD] Reduce size of class Symbol
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Aug 03, 2017 at 10:12:52PM -0700, Cary Coutant wrote:
> 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 6.5.2.3 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.
[snip]
8 EXAMPLE 3
The following is a valid fragment:
union {
struct {
int alltypes;
} n;
struct {
int type;
int intnode;
} ni;
struct {
int type;
double doublenode;
} nf;
} u;
u.nf.type = 1;
u.nf.doublenode = 3.14;
/* ... */
if (u.n.alltypes == 1)
if (sin(u.nf.doublenode) == 0.0)
/* ... */
--
Alan Modra
Australia Development Lab, IBM
- Previous message (by thread): [GOLD] Reduce size of class Symbol
- Next message (by thread): [GOLD] Reduce size of class Symbol
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list