so, in C this snippet: int fd = open(/*etc...*/); according to Godbolt is directly running system call number, whatever it is, by firstly placing the necessary params in the correct registers, but manual testing shows that's not true, this snippet is actually a call to a custom made function in glibc (since I am running gcc to compile this snippet) which is declared according to the preprocessor as:
# 168 "/usr/include/fcntl.h" 3 4
extern int open (const char *__file, int __oflag, ...) __attribute__ ((__nonnull__ (1)));
but its implementation is not visible since glibc has no debug symbols, cause I have not recompiled gcc and therefore glibc with debug symbols, but the debugger does pinpoint to the nonexistent on my system file that does have the implementation:
https://github.com/lattera/glibc/blob/master/sysdeps/unix/sysv/linux/open64.c#L36
so... how did a call to open magically turn into a call to __libc_open64 (some linker symbol resolution magic maybe??? ),
and most importantly,
return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS,
mode);
what does this funky macro SYSCALL_CANCEL do?