riscv-software-src / opensbi

RISC-V Open Source Supervisor Binary Interface
Other
1.02k stars 510 forks source link

ld.bfd: unrecognized option --exclude-libs #343

Open yogo1212 opened 9 months ago

yogo1212 commented 9 months ago
CROSS_COMPILE=riscv64-elf- make -C build/opensbi PLATFORM=generic FW_TEXT_START=0x40000000 FW_OPTIONS=0
 ELF       platform/generic/firmware/payloads/test.elf
/usr/lib/gcc/riscv64-elf/12.2.0/../../../../riscv64-elf/bin/ld.bfd: unrecognized option '--exclude-libs'
/usr/lib/gcc/riscv64-elf/12.2.0/../../../../riscv64-elf/bin/ld.bfd: use the --help option for usage information
collect2: error: ld returned 1 exit status

Is this because the toolchain is for bare-metal? Should the toolchain be checked before --exclude-libs is added to ELFFLAGS?

yogo1212 commented 9 months ago

Without the --exclude-libs, there's a failure linking fw_dynamic.elf:

/usr/lib/gcc/riscv64-elf/12.2.0/../../../../riscv64-elf/bin/ld.bfd:/home/leon/git/arch-star64-img/build/opensbi/build/platform/generic/firmware/fw_dynamic.elf.ld:54: undefined section `.dynsym' referenced in expression
yogo1212 commented 9 months ago

Simply removing SIZEOF(.dynsym) from the sum in the linker script re-enables the build. Am I confident in the resulting image? :shrug:

If there are exported symbols, there's no need for a dynsym section, or am I wrong? I'll create a PR discarding the section.