audk/BaseTools/Source/C
Ard Biesheuvel f55c76b301 BaseTools/GenFw AARCH64: disregard ADRP instructions that are patched already
In order to permit the use of compilers that only implement the small
code model [which involves the use of ADRP instructions that require
4 KB segment alignment] for generating PE/COFF binaries with a small
footprint, we patch ADRP instructions into ADR instructions while doing
the ELF to PE/COFF conversion.

As it turns out, the linker may be doing the same, but for different
reasons: there is a silicon erratum #843419 for ARM Cortex-A53 which
affects ADRP instructions appearing at a certain offset in memory, and
one of the mitigations for this erratum is to patch them into ADR
instructions at link time if the symbol reference is within -/+ 1 MB.
However, the LD linker fails to update the static relocation tables, and
so we end up with an ADR instruction in the fully linked binary, but
with a relocation entry in the RELA section identifying it as an ADRP
instruction.

Since the linker has already updated the symbol reference, there is no
handling needed in GenFw for such instructions, and we can simply treat
it as an ordinary ADR. However, since it is guaranteed to be accompanied
by an add or load instruction with a LO12 relocation referencing the same
symbol, the section offset check we apply to ADR instructions is going to
take place anyway, so we can just disregard the ADR instruction entirely.

Reported-by: Eugene Cohen <eugene@hp.com>
Suggested-by: Eugene Cohen <eugene@hp.com>
Tested-by: Eugene Cohen <eugene@hp.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Acked-by: Liming Gao <liming.gao@intel.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2019-11-08 08:58:15 +01:00
..
BrotliCompress BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
Common BaseTools: Fix various typos 2019-07-08 08:59:29 +08:00
DevicePath BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
EfiRom BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
GenCrc32 BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
GenFfs BaseTools: Fixed issue in MultiThread Genfds function 2019-04-10 13:32:10 +08:00
GenFv BaseTools: Add support for parseing map files generated by CLANG9 in GenFv 2019-11-08 08:29:36 +08:00
GenFw BaseTools/GenFw AARCH64: disregard ADRP instructions that are patched already 2019-11-08 08:58:15 +01:00
GenSec BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
Include BaseTools: use stdint.h for GCC ProcessorBind.h typedefs 2019-10-01 10:55:38 +01:00
LzmaCompress BaseTools/LzmaCompress: Fix the option "d" dictionary size 2019-09-30 15:04:08 +08:00
Makefiles BaseTools: strip trailing whitespace 2019-10-04 11:18:22 +01:00
PyEfiCompressor BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
Split BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
TianoCompress BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
VfrCompile BaseTools: strip trailing whitespace 2019-10-04 11:18:22 +01:00
VolInfo BaseTools: Check the fread function and avoid dead loop 2019-05-10 17:18:00 +08:00
GNUmakefile BaseTools: strip trailing whitespace 2019-10-04 11:18:22 +01:00
Makefile BaseTools: Robustness for multiple build environments 2019-09-11 22:30:16 +08:00