Nable wrote:
I mean RIP-relative (or PC-relative, i.e. relative to program counter) addressing. With such addressing mode one can easily generate position-independent code, i.e. code that can work at any virtual address without fix-ups.
Agreed. The x86 architecture uses PC-relative addressing for all its near CALLs and JMPs (both conditional and unconditional), so there are fewer fixups than would otherwise be required. It is also possible, with convoluted coding, to write position independent data accesses. But that's my point: the x86 architecture
is position independent with Segmentation - the decision to effectively disable this with the flat address model subverts this, and requires convoluted software to replace what the hardware does natively.
For example, with Object Oriented high level languages, polymorphism is a foundational concept. To implement this, you need pointers to functions.
With the flat model, the easy implementation, raw pointers, requires fixups for each pointer. A more convoluted implementation can be written with "thunks", mini-routines to vector to the correct function via indirect pointers. And this is regardless of architecture, and the presence or absence of PC-relative addressing modes.
With the Segmented model, pointers to functions are static: the pointer is relative to the base of the Segment, so no fixups are required. And if LDTs are used, the compiler can pre-assign all the segments too - the LDT is private to each process, so the compiler can have free rein with assigning all the Code, Data, Heap and Stack segments it wants.