This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ld 2.11: unaligned memory access for unions


Eberhard Mattes <mattes@azu.informatik.uni-stuttgart.de> writes:

> > Ah OK I understand now.  The code is deliberately casting a void *
> > pointer into a structure pointer, something which strictly speaking it
> > should not do, since GCC then (reasonably) assumes that the pointer is
> > aligned as required for the structure type.
> 
> That cast invokes undefined behavior, so GCC has licence to do
> whatever it likes, including copying word by word.

What is the undefined behaviour here?  Casting a void * pointer to a
struct pointer is defined.  I agree that the void * pointer needs to
satisfy the alignment requirements of the struct, but I don't agree
that the void * pointer needs to satisfy any more strict alignment
requirements.

If BFD is casting a void * pointer which does not satisfy the
alignment requirements of the struct, then we need to understand why
that is happening.  My reading of the code is that it should not
happen.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]