overhead of bfd_{get,put}*()
Mike Frysinger
vapier@gentoo.org
Fri Mar 5 19:42:00 GMT 2010
On Tuesday 23 February 2010 14:24:42 Joseph S. Myers wrote:
> If you want to do unaligned accesses, you can either access byte-by-byte
> as at present, or use memcpy to an aligned object (plus byte-swapping as
> needed) and hope the compiler optimizes that, or use packed structures
> (GCC-specific) (plus byte-swapping as needed). Simply dereferencing an
> unaligned pointer is not safe.
i dont think that has worked for a while now. if you have a pointer with a
certain alignment requirement and give it to memcpy(), gcc has no problem
inlining the memcpy() with direct loads even if the source pointer is
unaligned.
hopefully this conveys what i'm talking about:
void foo(int *src, long *dst)
{
memcpy(src, dst, 8);
}
...
{
char buf[12];
long d;
void *s = buf + 1;
foo(s, &d);
}
gcc has no problem assuming that src/dst are always aligned upon entry to
foo() according to the requirements of the "long" type and inlining that
memcpy() into two 4 byte copies.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/binutils/attachments/20100305/e77593da/attachment.sig>
More information about the Binutils
mailing list