This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: [patch][gold] Avoid invalid unaligned write


> We already have Swap and Swap_unaligned templates. Rather than
> pessimize the Swap template, we should be using Swap_unaligned
> wherever the target of the relocation might be unaligned. The arm,
> powerpc, and sparc targets already do this. The i386 and x86_64
> targets don't, but we haven't got into trouble only because
> (presumably) no one has ever tried to build a cross-linker for those
> targets on a platform where aligned accesses are required.
>
> I'd prefer to see _unaligned variants of all necessary functions in
> Relocate_functions, and have i386 and x86_64 targets use those. The
> mips target may also need this.
>
> Before doing that, however, the non-byte-swapping versions of the
> Swap_unaligned class templates need to be rewritten to use memcpy so
> that we don't generate horrible code when hosted on a platform that
> supports unaligned access. I'm not sure yet whether the byte-swapping
> versions should remain as written (byte-at-a-time, taking care of
> unaligned loads and byte swapping together), or whether they should
> use memcpy and Convert::convert_host. (The latter would be far
> simpler.)
>
> As you've pointed out, unaligned accesses on x86 aren't hurting us, so
> I don't see this as a high priority. It's just something to take care
> of before someone tries to build a cross linker for x86 hosted on a
> platform that doesn't tolerate unaligned access.

Yes, I started this just to get the alignment sanitizer working to
test my other patch (unaligned access on X86), so this would probably
be a bit to much work for that.

BTW, is there an architecture where it is known that the
malloc+memcpy+aligned access is faster than doing unaligned accesses?
I tested X86 and power8le and both got faster with unaligned. I can
try on ARM when I get back home on Monday.

If all current architectures are faster with unaligned accesses, maybe
we could just drop the malloc case?

Cheers,
Rafael


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