This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: overhead of bfd_{get,put}*()
From: "Joseph S. Myers" <joseph@codesourcery.com>
Date: Tue, 23 Feb 2010 19:24:42 +0000 (UTC)
> 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.
Yes, that works if you do something like use a type with the
'packed' attribute or similar for the unaligned thing. But
as the code stands now the object pointer is of type "void *"
so the compiler can't tell anything about the object size or
alignment.