I'm on a macOS x86_64 system.
I have this little C program in a file named test.c :
void fx(){
int y = 20;
y++;
}
int main(){
int x = 10;
x++;
fx();
}
If I compile this with "clang test.c -o test" and then use "otool -tV test" I get :
(__TEXT,__text) section
_fx:
0000000100003f70 pushq %rbp
0000000100003f71 movq %rsp, %rbp
0000000100003f74 movl $0x14, -0x4(%rbp)
0000000100003f7b movl -0x4(%rbp), %eax
0000000100003f7e addl $0x1, %eax
0000000100003f81 movl %eax, -0x4(%rbp)
0000000100003f84 popq %rbp
0000000100003f85 retq
0000000100003f86 nopw %cs:(%rax,%rax)
_main:
0000000100003f90 pushq %rbp
0000000100003f91 movq %rsp, %rbp
0000000100003f94 subq $0x10, %rsp
0000000100003f98 movl $0xa, -0x4(%rbp)
0000000100003f9f movl -0x4(%rbp), %eax
0000000100003fa2 addl $0x1, %eax
0000000100003fa5 movl %eax, -0x4(%rbp)
0000000100003fa8 callq _fx
0000000100003fad xorl %eax, %eax
0000000100003faf addq $0x10, %rsp
0000000100003fb3 popq %rbp
0000000100003fb4 retq
My questions :
Are the virtual addresses shown by the disassembler definitive or they ( could ) change ?
Do these addresses correspond to the addresses that we would get if we were to take addresses for example by using printf in run time ?
If they are not definitive virtual addresses, why adding another layer of complexity behind the virtual-physical mechanism so that it becomes something like virtual to virtual to physical ?