seL4_tools
seL4_tools copied to clipboard
Changes to enable linking with LLVM/lld
The rv32imac,gcc failure is likely due to old Binutils installed on the test machines. This could either be fixed by upgrading Binutils there, or maybe use "-z nostart-stop-gc" (as per the commit message) to the linker flags.
Err, I may be mixing up the meaning of (NOLOAD)
in the linker script and the meaning of the ALLOC
and LOAD
flags in the section table, and what they mean about whether contents are allocated in the ELF file data, allocated in the program image and initialized by the loader (or zeroed). And then what the implicit rules are with .bss, .tbss and other special named sections in the GCC toolchains. Would you be able to add a summary @heshamelmatary ?
Err, I may be mixing up the meaning of
(NOLOAD)
in the linker script and the meaning of theALLOC
andLOAD
flags in the section table, and what they mean about whether contents are allocated in the ELF file data, allocated in the program image and initialized by the loader (or zeroed). And then what the implicit rules are with .bss, .tbss and other special named sections in the GCC toolchains. Would you be able to add a summary @heshamelmatary ?
Most linkers heuristically recognise common section names and apply the proper flags to them. .[t]bss sections for example should be recognised and linkers mark them ALLOC, NOLOAD, which means that they don't occupy space in the ELF image and shouldn't be loaded at run-time, but they should be allocated space at run-time in the process image when loaded.
Adding NOLOAD (similar to the seL4's kernel) is good for intentionality, and for linkers that might not automatically flag .[t]bss at NOLOAD. I've come across a bug in lld that actually allocated space in the ELF before, but I believe that got fixed.
I will add that explanation to the commit message.
I dropped custom Arm's linker handling for sections and directives and rather added a new commit that unifies the linker script between Arm and RISC-V to include fixes for both and to make it more portable to build with lld and ld
Also I modified the "retain" attribute to check if the toolchain supports it or not as this may fail on older GCC versions