From 686ff993cb8871e1c688277eca05fa01218d8733 Mon Sep 17 00:00:00 2001 From: Gary Lin Date: Wed, 16 Jun 2021 16:13:32 +0800 Subject: [PATCH] aa64: move .rel* and .dyn* to the separate sections The previous commit(*) merged .rel* and .dyn* into .rodata. However, this makes ld to generate the wrong section size for .rel* to cover other unrelated sections. This commit moves .rel* and .dyn* out of .rodata in the ld script. However, since the related variables, such as _evrodata, _rodata_size, and _rodata_vsize, are moved, so the crafted pe-coff section header for .rodata still covers our new .rela and .dyn sections. (*) 212ba30544f ("arm/aa64 targets: put .rel* and .dyn* in .rodata") Issue: https://github.com/rhboot/shim/issues/371 Signed-off-by: Gary Lin --- Makefile | 2 +- elf_aarch64_efi.lds | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index d80aea82e..2a8897b4f 100644 --- a/Makefile +++ b/Makefile @@ -247,7 +247,7 @@ ifneq ($(OBJCOPY_GTE224),1) endif $(OBJCOPY) -D -j .text -j .sdata -j .data -j .data.ident \ -j .dynamic -j .rodata -j .rel* \ - -j .rela* -j .reloc -j .eh_frame \ + -j .rela* -j .dyn* -j .reloc -j .eh_frame \ -j .vendor_cert -j .sbat \ $(FORMAT) $< $@ ./post-process-pe -vv $@ diff --git a/elf_aarch64_efi.lds b/elf_aarch64_efi.lds index 353b24a05..42825fd93 100644 --- a/elf_aarch64_efi.lds +++ b/elf_aarch64_efi.lds @@ -70,21 +70,29 @@ SECTIONS .rodata : { _rodata = .; - *(.rela.dyn) - *(.rela.plt) - *(.rela.got) - *(.rela.data) - *(.rela.data*) - *(.rodata*) *(.srodata) - *(.dynsym) - *(.dynstr) . = ALIGN(16); *(.note.gnu.build-id) . = ALIGN(4096); *(.vendor_cert) *(.data.ident) + . = ALIGN(4096); + } + . = ALIGN(4096); + .rela : + { + *(.rela.dyn) + *(.rela.plt) + *(.rela.got) + *(.rela.data) + *(.rela.data*) + } + . = ALIGN(4096); + .dyn : + { + *(.dynsym) + *(.dynstr) _evrodata = .; . = ALIGN(4096); }