Currently LLD doesn't let the virtual addresses of sections reach the
end of the address space. However, this is permitted by the GNU linker.
Fix this by checking the VA of the last byte of the section rather than
the one past the end. For empty sections, we require that the base VA
fits, i.e. they behave like sections with a size of 1 byte.
I'f I've got this right then on a 32-bit target we can write a 0 sized OutputSection with a base address higher than UINT32_MAX and pass the check.
Perhaps something like:
uint64_t last_byte = (os->size) ? os->addr + (os->size - 1) : os->addr;