audk/BaseTools/Source/C
Ard Biesheuvel d2687f23c9 BaseTools/GenFw AARCH64: fix up GOT based relative relocations
We take great care to avoid GOT based relocations in EDK2 executables,
primarily because they are pointless - we don't care about things like
the CoW footprint or relocations that target read-only sections, and so
GOT entries only bloat the binary.

However, in some cases (e.g., when building the relocatable PrePi SEC
module in ArmVirtPkg with the CLANG38 toolchain), we may end up with
some GOT based relocations nonetheless, which break the build since
GenFw does not know how to deal with them.

The relocations emitted in this case are ADRP/LDR instruction pairs
that are annotated as GOT based, which means that it is the linker's
job to emit the GOT entry and tag it with an appropriate dynamic
relocation that ensures that the correct absolute value is stored into
the GOT entry when the executable is loaded. This dynamic relocation is
not visible to GenFw, and so populating the PE/COFF relocation section
for these entries is non-trivial.

Since each ADRP/LDR pair refers to a single symbol that is local to the
binary (given that shared libraries are not supported), we can actually
convert the ADRP/LDR pair into an ADRP/ADD pair that produces the symbol
address directly rather than loading it from memory. This leaves the
GOT entry in the binary, but since it is now unused, it is no longer
necessary to emit a PE/COFF relocation entry for it.

Acked-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2019-09-04 09:08:39 -07: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: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
GenFw BaseTools/GenFw AARCH64: fix up GOT based relative relocations 2019-09-04 09:08:39 -07:00
GenSec BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
Include BaseTools: Fix various typos 2019-07-08 08:59:29 +08:00
LzmaCompress BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
Makefiles BaseTools: Fix various typos 2019-07-08 08:59:29 +08: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: Fix various typos 2019-07-08 08:59:29 +08:00
VolInfo BaseTools: Check the fread function and avoid dead loop 2019-05-10 17:18:00 +08:00
GNUmakefile Revert "BaseTools/BfmLib: Add a tool BfmLib" 2019-07-11 11:17:48 +08:00
Makefile Revert "BaseTools/BfmLib: Add a tool BfmLib" 2019-07-11 11:17:48 +08:00