diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2015-07-06 15:57:50 +0000 |
---|---|---|
committer | abiesheuvel <abiesheuvel@Edk2> | 2015-07-06 15:57:50 +0000 |
commit | 64a910f3dac273922bbbe5d4817c2a9a6fd11aa0 (patch) | |
tree | d2eb1214204e06ef6777496c7178b16a250fa1ca /BaseTools/Scripts | |
parent | 228593f9068f745193afefa6a1f0184b5d210880 (diff) | |
download | edk2-platforms-64a910f3dac273922bbbe5d4817c2a9a6fd11aa0.tar.xz |
BaseTools: AArch64: use explicit linker scripts
Instead of relying on the builtin linker script of GNU ld, which
may vary based on binutils version (which is not tightly coupled to
the GCC version) and linker command line options, introduce a linker
script for AArch64 to be used by all GCC/binutils versions.
The script is laid out such that two ELF sections .text and .data are
created that map onto the PE/COFF with the same names. By aligning
.data to the minimum alignment of .text, and by not adding any
additional padding -which is what LD's builtin linker script does- the
relative offset between .text and .data is retained after the PE/COFF
conversion. This should prevent problems with debuggers and other
tooling that are ELF based.
Also provided is an overlay linker script that increases the alignment
of .text and .data to 64 KB. This is intended for DXE_RUNTIME_DRIVER
modules, to make them compatible with the newly introduced
Properties Table feature.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Olivier Martin <Olivier.Martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17824 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Scripts')
-rw-r--r-- | BaseTools/Scripts/gcc-aarch64-64K-align-ld-script | 4 | ||||
-rw-r--r-- | BaseTools/Scripts/gcc-aarch64-ld-script | 39 |
2 files changed, 43 insertions, 0 deletions
diff --git a/BaseTools/Scripts/gcc-aarch64-64K-align-ld-script b/BaseTools/Scripts/gcc-aarch64-64K-align-ld-script new file mode 100644 index 0000000000..8aa4c5f08c --- /dev/null +++ b/BaseTools/Scripts/gcc-aarch64-64K-align-ld-script @@ -0,0 +1,4 @@ +SECTIONS { + .text : ALIGN(0x10000) { } + .data : ALIGN(0x10000) { } +} diff --git a/BaseTools/Scripts/gcc-aarch64-ld-script b/BaseTools/Scripts/gcc-aarch64-ld-script new file mode 100644 index 0000000000..29095c268e --- /dev/null +++ b/BaseTools/Scripts/gcc-aarch64-ld-script @@ -0,0 +1,39 @@ +SECTIONS {
+ /*
+ * Put the .text section at 0x0 explicitly. While we know it will minimally
+ * end up at 0x280, (the size of the PE/COFF headers being 0x250 bytes and the
+ * minimum alignment 0x40), choosing 0x280 as the offset causes problems when
+ * linking objects with a greater .text alignment, since the section's base
+ * must adhere to its own alignment.
+ * Using 0x0 will result in the PE/COFF binary's memory layout to be shifted
+ * with respect to the ELF version, but this shouldn't be a problem as long as
+ * the .data's offset relative to .text is kept the same.
+ */
+ .text 0x0 : ALIGN(0x40) {
+ *(.text .text.* .rodata .rodata.*)
+ }
+
+ /*
+ * The alignment of the .data section needs to be less than or equal to the
+ * alignment of the .text section. This ensures that the relative offset
+ * between these sections is the same in the ELF and the PE/COFF version of
+ * this binary.
+ */
+ .data : ALIGN(0x40) {
+ *(.data .data.*)
+ *(.bss .bss.* *COM*)
+ }
+ .rela ALIGN(0x20) : {
+ *(.rela .rela.*)
+ }
+
+ /DISCARD/ : {
+ *(.note.GNU-stack)
+ *(.interp)
+ *(.dynsym)
+ *(.dynstr)
+ *(.dynamic)
+ *(.hash)
+ *(.comment)
+ }
+}
|