Assume we compile this code with gcc -no-pie test.c
.
ASLR is now disabled.
test.c
int main(){
int a = 5;
return a;
}
The allocated initial memory addresses of main
can be seen using objdump
:
0000000000401106 <main>:
401106: f3 0f 1e fa endbr64
Using gdb, I can see the same address at runtime after it's loaded:
(gdb) b main
Breakpoint 1 at 0x401106
Is it safe to say, when executable is not position independent
then the addresses
generated during link time are final virtual memory addresses? if binary is moved to another host with the same OS it will be loaded at the same virtual address?
Is it safe to say, when executable is not position independent then the addresses generated during link time are final virtual memory addresses?
Yes.
if binary is moved to another host with the same OS it will be loaded at the same virtual address?
Yes.
The non-PIE binary linked at a specific address will run correctly only if it is loaded at the linked-at address. Loading it at any other address will cause it to crash.