diff options
| author | Gary Lin <glin@suse.com> | 2021-06-16 16:13:32 +0800 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2021-07-20 09:51:22 -0400 |
| commit | 34e3ef205c5d65139eacba8891fa773c03174679 (patch) | |
| tree | 0c683f95ac56abba5841d499dc80d9ae4a271727 | |
| parent | ada7ff69bd8a95614aa63dd618764daf428f235d (diff) | |
| download | efi-boot-shim-34e3ef205c5d65139eacba8891fa773c03174679.tar.gz efi-boot-shim-34e3ef205c5d65139eacba8891fa773c03174679.zip | |
arm/aa64: fix the size of .rela* sections
The previous commit(*) merged .rel* and .dyn* into .rodata, and this
made ld to generate the wrong size for .rela* sections that covered
other unrelated sections. When the EFI image was loaded, _relocate()
went through the unexpected data and may cause unexpected crash.
This commit moves .rel* and .dyn* out of .rodata in the ld script but
also moves the related variables, such as _evrodata, _rodata_size,
and _rodata_vsize, to the end of the new .dyn section, so that 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")
Fix issue: https://github.com/rhboot/shim/issues/371
Signed-off-by: Gary Lin <glin@suse.com>
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | elf_aarch64_efi.lds | 24 | ||||
| -rw-r--r-- | elf_arm_efi.lds | 24 |
3 files changed, 34 insertions, 18 deletions
@@ -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 $@ @@ -263,7 +263,7 @@ ifneq ($(OBJCOPY_GTE224),1) endif $(OBJCOPY) -D -j .text -j .sdata -j .data \ -j .dynamic -j .rodata -j .rel* \ - -j .rela* -j .reloc -j .eh_frame -j .sbat \ + -j .rela* -j .dyn -j .reloc -j .eh_frame -j .sbat \ -j .debug_info -j .debug_abbrev -j .debug_aranges \ -j .debug_line -j .debug_str -j .debug_ranges \ -j .note.gnu.build-id \ diff --git a/elf_aarch64_efi.lds b/elf_aarch64_efi.lds index 353b24a0..42825fd9 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); } diff --git a/elf_arm_efi.lds b/elf_arm_efi.lds index e4e29bdf..53346219 100644 --- a/elf_arm_efi.lds +++ b/elf_arm_efi.lds @@ -70,21 +70,29 @@ SECTIONS .rodata : { _rodata = .; - *(.rel.dyn) - *(.rel.plt) - *(.rel.got) - *(.rel.data) - *(.rel.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); } |
