https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93492

--- Comment #7 from Fangrui Song <i at maskray dot me> ---
> Is -fasynchronous-unwind-tables compatible with -fpatchable-function-entry?

Apparently the Linux kernel does not care about it. To make it usable in
userspace, we should place .cfi_startproc in a reasonable place.
(A more concerning issue is that __patchable_function_entries can be stripped
by -Wl,--gc-sections , as the bug I linked above describes)

#### Interaction with -g1 (line table)

% clang -g -fpatchable-function-entry=2 a.c -o a  # latest clang
% addr2line -e a 0x$(nm a | awk '/ main/{print $1}')
/tmp/c/a.c:1

% gcc -g -fpatchable-function-entry=2 a.c -o a
% addr2line -e a 0x$(nm a | awk '/ main/{print $1}')
??:?

For M>0, I think it is fine to leave NOPs before the function entry uncovered
by line table information. clang -fpatchable-function-entry=2,1 layout is the
same as #c2, except for a NOP above foo:

% clang -g -fpatchable-function-entry=2,1 a.c -o a
# or gcc -g -fpatchable-function-entry=2,1 a.c -o a
% addr2line -e a $(nm a | ruby -ane 'print ($F[0].to_i(16)-1).to_s(16) if /
main/')
crtstuff.c:?

Reply via email to