This is based on and an alternative to D27613.
It handles all the corner cases if setting a section address:
- If the address is too low, we cannot allocate the program headers.
- If the load address is lowered, we have to do that before finalize
This also shares some code with the linker script since it was already hitting similar cases.
This is used by the freebsd boot loader. It is not clear if we need to support this with a non binary output, but it is not as bad as I was expecting.
Please remove argument names here and below: