Odin icon indicating copy to clipboard operation
Odin copied to clipboard

src: "Fix" the system call intrinsic for FreeBSD

Open Yawning opened this issue 4 years ago • 0 comments

Untested: I do not have a FreeBSD target. Someone else needs to check to see if this works.

FreeBSD's systemcall handler clears out R8, R9, and R10 prior to sysretq, and additionally returns positive errno (with CF) set on error. This modifies the syscall intrinsic such that LLVM knows about the additional clobbered registers.

Note that propagating CF back to the caller of the syscall intrinsic is left for a future PR. As far as I can tell, Darwin does not use the syscall intrinsic at all, and FreeBSD only uses it for SYS_GETTID, so this should be "ok" for now.

See: sys/amd64/amd64/exception.S in the FreeBSD src for more details.

Also part of: #1307

Yawning avatar Nov 13 '21 20:11 Yawning