[PATCH] efi: arm,arm64: Fix relocations from not being loaded

Heinrich Schuchardt xypron.glpk at gmx.de
Sun Nov 6 10:20:45 CET 2022


On 10/31/22 21:01, Patrick Zacharias wrote:
> Prior to this commit, the relocations would not get loaded by the efi
> loader.
>
> This lead to none of the relocations being applied.
>
> Signed-off-by: Fighter19 <1475802+Fighter19 at users.noreply.github.com>

Thanks Patrick for your contribution.

You can use scripts/get_maintainer.pl to determine to whom a patch
should be sent.

Where did you actually see relocations?
Which code is not position independent?

> ---
>   arch/arm/lib/elf_aarch64_efi.lds | 2 +-
>   arch/arm/lib/elf_arm_efi.lds     | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/lib/elf_aarch64_efi.lds
> b/arch/arm/lib/elf_aarch64_efi.lds
> index c0604dad46..1982864d17 100644
> --- a/arch/arm/lib/elf_aarch64_efi.lds
> +++ b/arch/arm/lib/elf_aarch64_efi.lds
> @@ -46,12 +46,12 @@ SECTIONS
>           *(COMMON)
>           . = ALIGN(512);
>           _bss_end = .;
> -        _edata = .;
>       }
>       .rela.dyn : { *(.rela.dyn) }
>       .rela.plt : { *(.rela.plt) }
>       .rela.got : { *(.rela.got) }
>       .rela.data : { *(.rela.data) *(.rela.data*) }
> +    _edata = .;
>       _data_size = . - _etext;
>
>       . = ALIGN(4096);
> diff --git a/arch/arm/lib/elf_arm_efi.lds b/arch/arm/lib/elf_arm_efi.lds
> index 767ebda635..c1b58a8033 100644
> --- a/arch/arm/lib/elf_arm_efi.lds
> +++ b/arch/arm/lib/elf_arm_efi.lds
> @@ -46,12 +46,12 @@ SECTIONS
>           *(COMMON)
>           . = ALIGN(512);
>           _bss_end = .;
> -        _edata = .;
>       }
>       .rel.dyn : { *(.rel.dyn) }
>       .rel.plt : { *(.rel.plt) }
>       .rel.got : { *(.rel.got) }
>       .rel.data : { *(.rel.data) *(.rel.data*) }
> +    _edata = .;

Relocations (if they exist) should be in the .reloc section, not in the
.data section.

If we want to create a .reloc section, we have to change
arch/arm/lib/crt0_*_efi.S too. Furthermore the relocation section must
be pointed to by field BaseRelocationTable of the Optional Header Data
Directories (see PE-COFF specification).

Please, consider the other UEFI architectures (x86 and RISC-V) too.

Best regards

Heinrich

>       _data_size = . - _etext;
>
>       /DISCARD/ : {



More information about the U-Boot mailing list