firmware: Fix fw_rw_offset computation in fw_base.S

It seems BFD just does totally nonsensical things for SHN_ABS symbols
when producing position-independent outputs (both -pie and -shared)
for various historical reasons, and so SHN_ABS symbols are still
subject to relocation as far as BFD is concerned (except AArch64,
which fixes it in limited cases that don’t apply here...).

The above affects the _fw_rw_offset provided through fw_base.ldS
linker script which results in OpenSBI firmware failing to boot
when loaded at an address different from FW_TEXT_START.

Fixes: c10e3fe5f9 ("firmware: Add RW section offset in scratch")
Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
Reported-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Tested-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
This commit is contained in:
Jessica Clarke 2023-01-26 21:10:03 +05:30 committed by Anup Patel
parent c45992cc2b
commit c8ea836ee3
2 changed files with 2 additions and 2 deletions

View File

@ -526,7 +526,7 @@ _link_start:
_link_end:
RISCV_PTR _fw_reloc_end
__fw_rw_offset:
RISCV_PTR _fw_rw_offset
RISCV_PTR _fw_rw_start - _fw_start
.section .entry, "ax", %progbits
.align 3

View File

@ -64,7 +64,7 @@
. = ALIGN(1 << LOG2CEIL((SIZEOF(.rodata) + SIZEOF(.text)
+ SIZEOF(.dynsym) + SIZEOF(.rela.dyn))));
PROVIDE(_fw_rw_offset = (. - _fw_start));
PROVIDE(_fw_rw_start = .);
/* Beginning of the read-write data sections */