nullplan wrote:
Well, in ELF, PIC just means that all accesses to memory happen through a separate pointer table (that gets fixed up by the loader). But I suppose the difference for PE would be rather small. It would just be whether the relocations affect code directly, or only data referenced by code.
I thought, if code and data contains absolute addresses, it's called Position Dependent Code. That's what it is in PE. If it's PIC as well, then what is non PIC?
Octocontrabass wrote:
PE does require RIP-relative addressing if the executable might be loaded above 2GB. That's probably the reason why PIC is always enabled for 64-bit Windows targets.
I am lazy to check if there are x64 base relocation types in the PE spec, but I just looked at my loader, full of global variables and indeed - for the x64 and arm64 images, Base Relocation Directory is empty, where it's not empty for arm32. So, at least specifics of architectures, make images truely PIC. Of course, ELF PIC is quazi PIC, since it needs fixing anyway. Just special "indirection" tables, rather the code/data as in PE.