-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLT hook segfault from <__fentry__@plt> on GCC7 #100
Comments
Thanks for the report. In principle, PLT hook should work same for both of But this is a special entry for the |
Okey. 😄 |
If uftrace is built by GCC7, plthook_entry() has `movaps` insn. So the stack pointer must be aligned on a 16-byte boundary. This was handled by the commit 7b80ea8 ("mcount: Fix segfault on GCC7") However, the commit didn't handle the below `-pg -mfentry` case: $ gcc -o hello -pg -mfentry hello.c $ uftrace ./hello child terminated by signal: 11: Segmentation fault # DURATION TID FUNCTION 1.741 us [14660] | __monstartup(); 1.519 us [14660] | __cxa_atexit(); So fix it, this situation was mentioned on namhyung#100. Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
I pushed the fix to check/plthook-fix-v1. Could you please verify it? |
Sure ! |
Nice work, but the output is a bit changed.
|
Ah ok. Thanks for checking! |
I read the commits of your |
This problem is similar to #92 and #91 .
But this only
-pg -mfentry
case is like below.-pg -mfentry
case (with uftrace built byGCC7
)(Sure,
normal tracing
anddynamic tracing
are fine)--no-libcall
, there isn't segfault.This problem is related to the 16-byte stack alignment required from GCC7 because of
movaps
.AYK, you can check "rsp % 16 != 0" (i.e. 0x7fff69e18618 % 16 = 0x8).
And I checked all values of
rsp%16
at the very beginning ofplt_hooker()
each time it is called with GDB.<__libc_start_main@plt>
case from _start()0x7fffffffddf8 % 16 = 0x8
<__monstartup@plt>
case from gmon_start()0x7fffffffdcd8 % 16 = 0x8
<__cxa_atexit@plt>
case from _init()0x7fffffffdce8 % 16 = 0x8
<__fentry__@plt>
case from main()0x7fffffffdd30 % 16 = 0x0
I thought plt_hooker() adjusts
rsp
for (rsp % 16 == 0) because of the 16-byte alignment,but
<__fentry__@plt>
case is already "rsp % 16 == 0" before plt_hooker() is called.So we need to add some if-else statement into arch/x86_64/plthook.S ?
Or, my investigation way is wrong ?
The text was updated successfully, but these errors were encountered: