seL4_tools icon indicating copy to clipboard operation
seL4_tools copied to clipboard

IMAGE_START_ADDR vs actual start address on RISC-V

Open Ivan-Velickovic opened this issue 2 years ago • 1 comments

I am trying to understand some of the code for the ELF loader on RISC-V. I've come across an autogenerated define called IMAGE_START_ADDR. On the Spike platform for example (looking at the build for sel4test), this becomes 0x80a0c000. This define is then used in the linker script as the address of the _text section. However, since seL4 uses OpenSBI with FW_PAYLOAD, my understanding is that it will start the payload (in this case the ELF loader) at 0x8020000. This is confirmed by the following output using sel4test:

ELF-loader started on (HART 0) (NODES 1)
    paddr=[8020000...806a4037]

So if the IMAGE_START_ADDR is different to the actual address the image is started at, why are there no issues with the ELF loader? I'm sure I'm just misunderstanding something, so if anyone could point it out that would be great.

Thanks.

Ivan-Velickovic avatar Jun 29 '22 08:06 Ivan-Velickovic

There are some pending branches (https://github.com/seL4/seL4_tools/pull/135) that try to remove all these RISC-V hacks/quirks, I just did not find enough time recently to review/sync/upstream all this. We might be just lucky that this works due to relative branches in the code?

axel-h avatar Jul 01 '22 00:07 axel-h