When adding

    const unsigned short *menu_items[] = {
            u"abc\n",
            u"def\n",
            NULL
    };

to  helloworld.c outside of a function and then referring to the variable
in a function the pointer the reference is incorrect. This is due to not
considering the generated relocations.

Fix the linker script and the PE-COFF header.

Fixes: c65d76ed5f81 ("efi: arm: Add aarch64 EFI app support")
Signed-off-by: Heinrich Schuchardt <[email protected]>
---
 arch/arm/lib/crt0_aarch64_efi.S  | 32 ++++++++++++++++----------------
 arch/arm/lib/elf_aarch64_efi.lds | 11 +++++++----
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/arch/arm/lib/crt0_aarch64_efi.S b/arch/arm/lib/crt0_aarch64_efi.S
index 3c2cef6ec7..3520182217 100644
--- a/arch/arm/lib/crt0_aarch64_efi.S
+++ b/arch/arm/lib/crt0_aarch64_efi.S
@@ -89,22 +89,6 @@ section_table:
         * because EFI applications must be relocatable.  This is a
         * dummy section as far as we are concerned.
         */
-       .ascii  ".reloc"
-       .byte   0
-       .byte   0                       /* end of 0 padding of section name */
-       .long   0
-       .long   0
-       .long   0                       /* SizeOfRawData */
-       .long   0                       /* PointerToRawData */
-       .long   0                       /* PointerToRelocations */
-       .long   0                       /* PointerToLineNumbers */
-       .short  0                       /* NumberOfRelocations */
-       .short  0                       /* NumberOfLineNumbers */
-       /* Characteristics (section flags) */
-       .long   (IMAGE_SCN_MEM_READ | \
-                IMAGE_SCN_MEM_DISCARDABLE | \
-                IMAGE_SCN_CNT_INITIALIZED_DATA)
-
        .ascii  ".text"
        .byte   0
        .byte   0
@@ -139,6 +123,22 @@ section_table:
                 IMAGE_SCN_MEM_READ | \
                 IMAGE_SCN_CNT_INITIALIZED_DATA)
 
+       .ascii  ".reloc"
+       .byte   0
+       .byte   0                       /* end of 0 padding of section name */
+       .long   _relo_size              /* VirtualSize */
+       .long   _relo - ImageBase       /* VirtualAddress */
+       .long   _relo_size              /* SizeOfRawData */
+       .long   _relo - ImageBase       /* PointerToRawData */
+       .long   0                       /* PointerToRelocations */
+       .long   0                       /* PointerToLineNumbers */
+       .short  0                       /* NumberOfRelocations */
+       .short  0                       /* NumberOfLineNumbers */
+       /* Characteristics (section flags) */
+       .long   (IMAGE_SCN_MEM_READ | \
+                IMAGE_SCN_MEM_DISCARDABLE | \
+                IMAGE_SCN_CNT_INITIALIZED_DATA)
+
        .align          12
 _start:
        stp             x29, x30, [sp, #-32]!
diff --git a/arch/arm/lib/elf_aarch64_efi.lds b/arch/arm/lib/elf_aarch64_efi.lds
index 3e3da47d6a..1ec2e7fec8 100644
--- a/arch/arm/lib/elf_aarch64_efi.lds
+++ b/arch/arm/lib/elf_aarch64_efi.lds
@@ -57,10 +57,13 @@ SECTIONS
                _edata = .;
        } :data
        _data_size = _edata - _data;
-       .rela.dyn : { *(.rela.dyn) }
-       .rela.plt : { *(.rela.plt) }
-       .rela.got : { *(.rela.got) }
-       .rela.data : { *(.rela.data) *(.rela.data*) }
+       . = ALIGN(4096);
+       .reloc : {
+               _relo = .;
+               *(.rela*)
+               _erelo = .;
+       }
+       _relo_size = _erelo - _relo;
 
        . = ALIGN(4096);
        .dynsym   : { *(.dynsym) }
-- 
2.37.2

Reply via email to