summaryrefslogtreecommitdiff
path: root/firmware/fw_base.ldS
AgeCommit message (Collapse)Author
2025-07-21firmware: Rename __rel_dyn_start/end to __rela_dyn_start/endJessica Clarke
We are using and expecting the RELA format, not the REL format, and this is the conventional linker-generated name for the start/end symbols, so use it rather than confusing things by making it look like we're accessing .rel.dyn, which would be in the REL format with no explicit addend. Signed-off-by: Jessica Clarke <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2024-11-06Makefile: enable --gc-sectionsKele Zhang
The --gc-sections option enables the linker to perform garbage collection of unreferenced code and data, thereby reducing the binary size. The -ffunction-sections option will place each function into a separate section, so it is necessary to add .text.* to the linker script. Signed-off-by: Kele Zhang <[email protected]> Signed-off-by: Yuan Tan <[email protected]> Signed-off-by: Zhangjin Wu <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-05-23firmware: Bring back FW_TEXT_START as an optional parameterAnup Patel
Bring back FW_TEXT_START as an optional parameter to allow users explicitly specify compile time address for loading debug symbols. When not specified, the FW_TEXT_START is assumed to be 0. Fixes: d4d2582eef7a ("firmware: remove FW_TEXT_START") Signed-off-by: Anup Patel <[email protected]> Tested-by: Clément Léger <[email protected]>
2024-04-10firmware: remove FW_TEXT_STARTXiang W
Now opensbi can run at any address via dynamic relocation. We can remove FW_TEXT_START. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2024-02-05firmware: always create dynsym sectionLeon M. Busch-George
With a bare-metal linkers (e.g. riscv64-elf-ld), there exists no dynsym section. The dynsym section is not used by OpenSBI but discarding it makes linkers with dynamic library support unhappy. Signed-off-by: Leon M. Busch-George <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-10-06firmware: Remove handling of R_RISCV_{32,64}Vivian Wang
Since everything is statically linked, we won't actually have R_RISCV_{32,64} relocations. No need to handle these. Fixes: 0f20e8adcf42 ("firmware: Support position independent execution") Signed-off-by: Vivian Wang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-10-06firmware: Remove ALIGN in .rela.dyn in linker scriptVivian Wang
The .rela.dyn section should be exactly the size of the relocations, without padding. On RV64, .rela* sections are already aligned and there's no need for padding. On RV32, this adds padding up to 4 bytes, which, if present, confuses the relocation loop into processing an extra entry past the end of .rela*, and it crashes with an invalid memory access. Fixes: 0f20e8adcf42 ("firmware: Support position independent execution") Signed-off-by: Vivian Wang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-27firmware: Fix fw_rw_offset computation in fw_base.SJessica Clarke
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: c10e3fe5f9a1 ("firmware: Add RW section offset in scratch") Signed-off-by: Jessica Clarke <[email protected]> Reported-by: Lad Prabhakar <[email protected]> Tested-by: Lad Prabhakar <[email protected]> Tested-by: Anup Patel <[email protected]> Signed-off-by: Anup Patel <[email protected]>
2023-01-23firmware: Move dynsym and reladyn sections to RX sectionHimanshu Chauhan
Currently, the dynsym and reladyn sections are under RW data. They are moved to the Read-only/Executable region. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-23firmware: Split RO/RX and RW sectionsHimanshu Chauhan
Split the RO/RX and RW sections so that they can have independent pmp entries with required permissions. The split size is ensured to be a power-of-2 as required by pmp. _fw_rw_offset symbol marks the beginning of the data section. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-11-22firmware: payloads: Optimize usage of "ALIGN"Leizheng Zhang
Delete the redundant "ALIGN" and adjust the position of "ALIGN" Signed-off-by: Leizheng Zhang <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2021-07-27firmware: use _fw_start for load addressXiang W
The previous code uses _start as the load address, this default .entry is the first segment, using _fw_start does not need to make this assumption. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2021-03-19firmware: Support position independent executionVincent Chen
Enable OpenSBI to support position independent execution. Because the position independent code will cause an additional GOT reference when accessing the global variables, it will reduce performance a bit. Therefore, the position independent execution is disabled by default. Users can through specifying "FW_PIC=y" on the make command to enable this feature. In theory, after enabling position-independent execution, the OpenSBI can run at arbitrary address with appropriate alignment. Therefore, the original relocation mechanism will be skipped. In other words, OpenSBI will directly run at the load address without any code movement. Signed-off-by: Vincent Chen <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-06-12firmware: add missing linker sections to fw_base.ldSLukas Auer
The linker sections .sdata and .sbss are missing from the linker script fw_base.ldS. Add them to the .data and .bss sections. On current builds, most variables are in the .sbss section. They are not correctly initialized to zero, because they are not within the boundaries indicated by _bss_start and _bss_end. Currently, this does not cause any issues, however with relocation support lock-ups may occur due to incorrectly initialized lock variables. Signed-off-by: Lukas Auer <[email protected]> Acked-by: Anup Patel <[email protected]>
2019-01-24all: Update copyright header in all filesAnup patel
This patch updates copyright header in all files as follows: 1. Makes "SPDX-License-Identifier: BSD-2-Clause" as first line 2. Change copyright year to 2019 for Western Digital Signed-off-by: Anup Patel <[email protected]>
2018-12-27firmware: Rename fw_common.S to fw_base.SAnup Patel
The fw_common.S is the base firmware extendend by fw_jump and fw_payload. This patch renames fw_common.S to fw_base.S to have more clear/intutive name for base firmware. Signed-off-by: Anup Patel <[email protected]>