This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: overhead of bfd_{get,put}*()
- From: David Miller <davem at davemloft dot net>
- To: vapier at gentoo dot org
- Cc: binutils at sourceware dot org, joseph at codesourcery dot com, hjl dot tools at gmail dot com, iant at google dot com
- Date: Fri, 05 Mar 2010 11:53:12 -0800 (PST)
- Subject: Re: overhead of bfd_{get,put}*()
- References: <6dc9ffc81002231058k4877b728iaa0651d5d7e44061@mail.gmail.com> <Pine.LNX.4.64.1002231918040.7244@digraph.polyomino.org.uk> <201003051441.57656.vapier@gentoo.org>
From: Mike Frysinger <vapier@gentoo.org>
Date: Fri, 5 Mar 2010 14:41:56 -0500
> 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.
That doesn't apply here, as discussed elsewhere in this thread,
because the incoming pointer is "void *" and the compiler has
therefore no type information from which to make alignment
decisions.