[COFF] Align ARM64 range extension thunks at instruction boundary
authorTom Tan <Tom.Tan@microsoft.com>
Sat, 11 Jan 2020 02:55:56 +0000 (18:55 -0800)
committerTom Tan <Tom.Tan@microsoft.com>
Sat, 11 Jan 2020 03:03:17 +0000 (19:03 -0800)
commit7c816492197aefbaa2ea3ba0e391f7c6905956bc
treee3807f2153a7259a4a1d92fa4108b4f23950a168
parentde0a2247115729eade8249267a47f96f070a7666
[COFF] Align ARM64 range extension thunks at instruction boundary

RangeExtensionThunkARM64 is created for out-of-range branches on Windows ARM64
because branch instructions has limited bits to encode target address.
Currently, RangeExtensionThunkARM64 is appended to its referencing COFF section
from object file at link time without any alignment requirement, so if size of
the preceding COFF section is not aligned to instruction boundary (4 bytes),
RangeExtensionThunkARM64 will emit thunk instructions at unaligned address
which is never a valid branch target on ARM64, and usually triggers invalid
instruction exception when branching to it.

This PR fixes it by requiring such thunks to align at 4 bytes.

Differential revision: https://reviews.llvm.org/D72473
lld/COFF/Chunks.h
lld/test/COFF/arm64-thunks.s