[ELF][ARM] Implement --fix-cortex-a8 to fix erratum 657417
authorPeter Smith <peter.smith@linaro.org>
Mon, 16 Sep 2019 09:38:38 +0000 (09:38 +0000)
committerPeter Smith <peter.smith@linaro.org>
Mon, 16 Sep 2019 09:38:38 +0000 (09:38 +0000)
commitea99ce5e9b49cf7164355009435a29897934182b
treeb84fd0d099469f04b4cd83bf75a0ad6988d2f943
parentad7a7cea89717daf6b56f35e4bc0b95afe0498a2
[ELF][ARM] Implement --fix-cortex-a8 to fix erratum 657417

The --fix-cortex-a8 option implements a linker workaround for the
coretex-a8 erratum 657417. A summary of the erratum conditions is:
- A 32-bit Thumb-2 branch instruction B.w, Bcc.w, BL, BLX spans two
4KiB regions.
- The destination of the branch is to the first 4KiB region.
- The instruction before the branch is a 32-bit Thumb-2 non-branch
instruction.

The linker fix is to redirect the branch to a patch not in the first
4KiB region. The patch forwards the branch on to its target.

The cortex-a8, is an old CPU, with the first implementation of this
workaround in ld.bfd appearing in 2009. The cortex-a8 has been used in
early Android Phones and there are some critical applications that still
need to run on a cortex-a8 that have the erratum. The patch is applied
roughly 10 times on LLD and 20 on Clang when they are built with
--fix-cortex-a8 on an Arm system.

The formal erratum description is avaliable in the ARM Core Cortex-A8
(AT400/AT401) Errata Notice document. This is available from Arm on
request but it seems to be findable via a web search.

Differential Revision: https://reviews.llvm.org/D67284

llvm-svn: 371965
14 files changed:
lld/ELF/AArch64ErrataFix.cpp
lld/ELF/ARMErrataFix.cpp [new file with mode: 0644]
lld/ELF/ARMErrataFix.h [new file with mode: 0644]
lld/ELF/CMakeLists.txt
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/ELF/Writer.cpp
lld/test/ELF/arm-fix-cortex-a8-blx.s [new file with mode: 0644]
lld/test/ELF/arm-fix-cortex-a8-nopatch.s [new file with mode: 0644]
lld/test/ELF/arm-fix-cortex-a8-plt.s [new file with mode: 0644]
lld/test/ELF/arm-fix-cortex-a8-recognize.s [new file with mode: 0644]
lld/test/ELF/arm-fix-cortex-a8-thunk.s [new file with mode: 0644]
lld/test/ELF/arm-fix-cortex-a8-toolarge.s [new file with mode: 0644]