HomeFreeBSD

amd64: Add CFI directives for libc syscall stubs

Description

amd64: Add CFI directives for libc syscall stubs

No functional change (in program code). Additional DWARF metadata is
generated in the .eh_frame section. Also, it is now a compile-time
requirement that machine/asm.h ENTRY() and END() macros are paired. (This
is subject to ongoing discussion and may change.)

This DWARF metadata allows llvm-libunwind to unwind program stacks when the
program is executing the function. The goal is to collect accurate
userspace stacktraces when programs have entered syscalls.

(The motivation for "Call Frame Information," or CFI for short -- not to be
confused with Control Flow Integrity -- is to sufficiently annotate assembly
functions such that stack unwinders can unwind out of the local frame
without the requirement of a dedicated framepointer register; i.e.,
-fomit-frame-pointer. This is necessary for C++ exception handling or
collecting backtraces.)

For the curious, a more thorough description of the metadata and some
examples may be found at [1] and documentation at [2]. You can also look at
'cc -S -o - foo.c | less' and search for '.cfi_' to see the CFI directives
generated by your C compiler.

[1]: https://www.imperialviolet.org/2017/01/18/cfi.html
[2]: https://sourceware.org/binutils/docs/as/CFI-directives.html

Reviewed by: emaste, kib (with reservations)
Differential Revision: https://reviews.freebsd.org/D22122

Details

Provenance
cemAuthored on
Reviewer
emaste
Differential Revision
D22122: amd64: Add CFI directives for libc syscall stubs
Parents
rS353958: libthr: Add missing END() directive for umtx_op_err (amd64)
Branches
Unknown
Tags
Unknown