What is the point of the prolog for syscall wrappers? For instance, from FreeBSD 12.4 amd64 in Intel format
In C that's just making function pointer call of via __libc_interposing
The TCO is clear enough.
What is the use of pushing and popping rbp? Is this always done with -fno-omit-frame-pointer?
The only side effect that I see is that the contents of rbp will still be just below the stack pointer.
Code:
0000000000092b20 <msync>:
92b20: 55 push rbp
92b21: 48 89 e5 mov rbp,rsp
92b24: 48 8b 05 95 52 13 00 mov rax,QWORD PTR [rip+0x135295] # 1c7dc0 <svc_maxfd+0x78>
92b2b: 5d pop rbp
92b2c: ff e0 jmp rax
92b2e: cc int3
92b2f: cc int3
In C that's just making function pointer call of via __libc_interposing
- Push the base pointer
- Copy the stack pointer to the base pointer
- Copy the rip-relative address of _msync into rax (objdump doesn't seem to be able to figure that out)
- Jump to _msync which looks like
Code:
│ > 0x800397440 <_msync> mov $0x41,%eax
│ 0x800397445 <_msync+5> mov %rcx,%r10
│ 0x800397448 <_msync+8> syscall
│ 0x80039744a <_msync+10> jb 0x8004055b4 <.cerror>
│ 0x800397450 <_msync+16> ret
The TCO is clear enough.
What is the use of pushing and popping rbp? Is this always done with -fno-omit-frame-pointer?
The only side effect that I see is that the contents of rbp will still be just below the stack pointer.