> What ruins this for C is the existence of pointers. Stacks aren't freely relocatable since pointers into the stack could exist.
I sometimes wonder what computing would be like if the 80286 hadn't sucked, if segmentation had won over flat address spaces, and if we'd been able to do relocation pain-free by changing a segment base register in one spot instead of rewriting linear pointers everywhere. We could have done paging within segments.
Oh well.
mmap with MAP_FIXED has allowed you to do this for some time.
That'd only help for one object per address space. Main thing needing relocation - shared libraries - needs arbitrarily-many segment bases.
And when you're not a library, relocation is just a mild probabalistic security improvement (...that'd be massively-more bypassable than it already is if the program was littered full of gadgets of "read register as unrelocated offset and use it with its correct base" instructions).