audk/BaseTools/Source/C/GenFw
Ard Biesheuvel 026a82abf0 BaseTools/GenFw AARCH64: convert ADRP to ADR instructions if binary size allows it
The ADRP instruction in the AArch64 ISA requires the link time and load time
offsets of a binary to be equal modulo 4 KB. The reason is that this instruction
always produces a multiple of 4 KB, and relies on a subsequent ADD or LDR
instruction to set the offset into the page. The resulting symbol reference
only produces the correct value if the symbol in question resides at that
exact offset into the page, and so loading the binary at arbitrary offsets
is not possible.

Due to the various levels of padding when packing FVs into FVs into FDs, this
alignment is very costly for XIP code, and so we would like to relax this
alignment requirement if possible.

Given that symbols that are sufficiently close (within 1 MB) of the reference
can also be reached using an ADR instruction which does not suffer from this
alignment issue, let's replace ADRP instructions with ADR after linking if
the offset can be encoded in this instruction's immediate field. Note that
this only makes sense if the section alignment is < 4 KB. Otherwise,
replacing the ADRP has no benefit, considering that the subsequent ADD or
LDR instruction is retained, and that micro-architectures are more likely
to be optimized for ADRP/ADD pairs (i.e., via micro op fusing) than for
ADR/ADD pairs, which are non-typical.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2016-08-02 10:58:07 +02:00
..
Elf32Convert.c BaseTools/GenFw: Fix a bug for GCC build 2016-02-18 11:25:54 +08:00
Elf32Convert.h License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Elf64Convert.c BaseTools/GenFw AARCH64: convert ADRP to ADR instructions if binary size allows it 2016-08-02 10:58:07 +02:00
Elf64Convert.h License header updated to match correct format. 2014-08-28 13:53:34 +00:00
ElfConvert.c BaseTools: Update GenFw to support 4K alignment. 2015-06-29 03:17:34 +00:00
ElfConvert.h BaseTools/GenFw: Enhance error message for bad symbol definitions 2016-02-17 13:21:44 +08:00
GNUmakefile Sync BaseTool trunk (version r2599) into EDKII BaseTools. 2013-08-23 02:18:16 +00:00
GenFw.c BaseTools/GenFw: enhance to use Magic Field to identify the image 2016-05-16 09:06:05 +08:00
GenFw.h License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Makefile Sync EDKII BaseTools to BaseTools project r1971 2010-05-18 05:04:32 +00:00
elf32.h Sync BaseTool trunk (version r2649) into EDKII BaseTools. 2014-01-27 05:23:15 +00:00
elf64.h Sync BaseTool trunk (version r2649) into EDKII BaseTools. 2014-01-27 05:23:15 +00:00
elf_common.h Sync BaseTool trunk (version r2649) into EDKII BaseTools. 2014-01-27 05:23:15 +00:00