From 94197a8c49751eabe73ff2849fce183ac8ead3fd Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Sun, 6 Aug 2023 10:45:36 +0530 Subject: [PATCH] fw_base.S: Fix assembler error with clang 16+ Attempting to build OpenSBI with clang 16 and the following command: $ make LLVM=1 PLATFORM=generic Results in the following error: AS platform/generic/firmware/fw_dynamic.o /tmp/fw_dynamic-d000a6.s:429:9: error: symbol '_fw_start' can not be undefined in a subtraction expression .dword _fw_rw_start - _fw_start Work around this issue by eliminating the __fw_rw_offset variable and performing the offset calculation at run-time instead. This takes advantage of the fact that the a4 register contains the value of _fw_start. Signed-off-by: Mitchell Horne Reviewed-by: Anup Patel --- firmware/fw_base.S | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index b947423..ca34b4c 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -309,8 +309,8 @@ _scratch_init: REG_S a5, SBI_SCRATCH_FW_SIZE_OFFSET(tp) /* Store R/W section's offset in scratch space */ - lla a4, __fw_rw_offset - REG_L a5, 0(a4) + lla a5, _fw_rw_start + sub a5, a5, a4 REG_S a5, SBI_SCRATCH_FW_RW_OFFSET(tp) /* Store fw_heap_offset and fw_heap_size in scratch space */ @@ -536,8 +536,6 @@ _link_start: RISCV_PTR FW_TEXT_START _link_end: RISCV_PTR _fw_reloc_end -__fw_rw_offset: - RISCV_PTR _fw_rw_start - _fw_start .section .entry, "ax", %progbits .align 3