When compiling a baremetal implementation of software like an OS or bootloader, one will have a platform specific linker script will specify what addresses each section will go into. The linker script will be written according to the platform's memory map.
When the operating system loads an executable, the operating system loaded will read the various sections in your elf file and ensure that each gets placed into the correct section of the process's memory map. The OS loader will then fix any unlinked addresses as required.