Relocation tables still exist. They do not need to be in a .reloc
section, the important part is that the Relocation Direction RVA entry of the data directories array in the "optional header" (not 'optional' for executables) points to it. However, it often is in a .reloc
section anyway.
It's just a legacy? I have opened several .exe x64 files in the IDA and don't see the .reloc segment there.
I found such a section in for example notepad.exe, calc.exe (very small relocation section), 7z.exe, subl.exe, various other common tools. It's not rare. I did not use IDA though, I used CFF Explorer.
Normally on x64, to refer to an address that is fixed relative to IMAGE BASE, RIP-relative lea
(or RIP-relative addressing in general) is used, which adds a constant offset to the address of the byte directly after it (not to IMAGE BASE). x64 does not have many places where a 64-bit absolute address can be used directly in instructions (a 64-bit address can be loaded into a register the same as any 64-bit integer, or used as an address but only in mov
to and from rax/eax/ax/al
), making it inconvenient (though possible) to rely on relocations completely.
On the other hand, relocations are useful to update addresses that are stored in data segments, which are usually absolute addresses (otherwise they would be inconvenient to use, making them RIP-relative doesn't really work at all (which RIP), and putting a raw RVA would work but requires adding IMAGE BASE manually at every use). For other architectures such as ARM, MIPS, RISC-V, relocations may be more important (and maybe more complicated).
By the way contrary to what Wikipedia says:
When running native 64-bit binaries on Windows Vista and above, ASLR is mandatory[citation needed], and thus relocation sections cannot be omitted by the compiler.
The relocation section can certainly be omitted if no relocations are used, and you can create non-trivial executables like that. Just don't use absolute addresses. Or patch them yourself.