seL4 / seL4_tools

Basic tools for building seL4 projects
https://sel4.systems
Other
43 stars 91 forks source link

elfloader: issues with Arm's linker script #172

Open heshamelmatary opened 1 year ago

heshamelmatary commented 1 year ago

The shared Arm's linker script includes some sections and directive that might not be necessary. For example, .interp and .hash here:

SECTIONS { .interp : { *(.interp) } } INSERT BEFORE .hash;

What's the reason this section exists in the elfloader, and why the INSERT BEFORE .hash? I am able to remove them and ELF linking works just fine. However, when building with LLVM/lld, they trigger a linking error as .hash and .interp don't exist.

aarch64-none-elf-ld.lld: error: unable to insert .interp before .hash aarch64-none-elf-ld.lld: error: unable to insert ._archive_cpio after .eh_frame

Similarly, INSERT AFTER .eh_frame;

I do have local fixes that remove them, I'd be happy to submit a PR if there's no good reason those sections/directives exist.

kent-mcleod commented 1 year ago

Since https://github.com/seL4/seL4_tools/commit/a0ffb71ce8db26816c33adba307c1e53c579a78e, the script has been a fragment that's applied to the linker's builtin default script.

I think historically the same script was used for both EFI and non-EFI targets which complicated having a complete script. Now the EFI builds use their own script so it'd probably be possible to provide a simple, but complete, one like the kernel.

I'm happy if you want to put up a PR for this :)