0

I am writing firmware for an ARM platform in which I want to have the main bootloader relocatable in memory rather than always loaded at a fixed address during boot. This means that I need a relocatable format stored in Flash, like ELF.

If ELF is used then I need an ELF loader stored in the ROM code that first gets execution after reset. While this is okay, I also need that same relocation code in the bootloader .. so I will have a lot of code duplication and loss of Flash space if. My intent for the ROM is to just load the bootloader from Flash, so it really is going to be very simple.

I toyed around with creating simple ROM stub that jumped into the text section of the stored ELF image (linked at the address it is stored at in Flash). While this sort of works, I think it might be overkill for my intent.

tl;dr: All I want/need is a relocatable format to store my binary in Flash. Are there other options that are perhaps simpler than ELF that retain relocation tables?

sherrellbc
  • 3,431
  • 6
  • 35
  • 62
  • Can you compile your main bootloader as [position-indepedent code](https://developer.arm.com/docs/100066/0601/compiling-c-and-c-code/bare-metal-position-independent-executables)? – Dave Tweed May 01 '19 at 01:00
  • @DaveTweed, I had not considered PIE without any image format. While I like the idea, the page you link has that it only works on aarch32. Why might that be? – sherrellbc May 01 '19 at 01:11
  • I don't know. I'm just learning this ARM stuff myself. I just did a quick search to see whether the techniques I've used on other processors also applied to ARM, at least in general. – Dave Tweed May 01 '19 at 01:53
  • I'm pretty sure I used '-fPIC' on Arm GCC years ago for more or less the exact same purpose, and it just worked straight out of the box. – Timo May 01 '19 at 05:57

0 Answers0