overhead of bfd_{get,put}*()
Joseph S. Myers
joseph@codesourcery.com
Tue Feb 23 22:35:00 GMT 2010
On Tue, 23 Feb 2010, H.J. Lu wrote:
> That would make it gcc specific. On the other hand, you can easily
> check strict alignment in configure.
On the contrary, checking strict alignment in configure is impossible;
just because the compiler appears not to optimize a particular instance of
code involving undefined behavior (pointers not sufficiently aligned for
their target type) in a way that causes it to break is no guarantee of
what will happen with any other instance of the same undefined behavior in
BFD. You can't condition this on the host triplet as that will be liable
to break when someone builds with new tools that decide to use new,
alignment-requiring, load or store instructions on a processor that
previously didn't have those instructions.
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.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Binutils
mailing list