Skip to content

Commit

Permalink
aarch64: fix stack missing after sp is updated
Browse files Browse the repository at this point in the history
After sp is updated, the CFA offset should be set before next instruction.
Tested in glibc-2.28:
Thread 2 "xxxxxxx" hit Breakpoint 1, _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149
149		stp	x1,  x2, [sp, #-32]!
Missing separate debuginfos, use: dnf debuginfo-install libgcc-7.3.0-20190804.h24.aarch64
(gdb) bt
#0  _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149
Plagman#1  0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184)
    at /home/test/test_function.c:30
Plagman#2  0x0000000000400c08 in initaaa () at thread.c:58
Plagman#3  0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71
#4  0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486
#5  0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78
(gdb) ni
_dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150
150		stp	x3,  x4, [sp, #16]
(gdb) bt
#0  _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150
Plagman#1  0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184)
    at /home/test/test_function.c:30
Plagman#2  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) ni
_dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157
157		mrs	x4, tpidr_el0
(gdb) bt
#0  _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157
Plagman#1  0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184)
    at /home/test/test_function.c:30
Plagman#2  0x0000000000400c08 in initaaa () at thread.c:58
Plagman#3  0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71
#4  0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486
#5  0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78

Signed-off-by: liqingqing <[email protected]>
Signed-off-by: Shuo Wang <[email protected]>
  • Loading branch information
Shuo Wang authored and nsz-arm committed Jan 4, 2021
1 parent f5a6f84 commit cd62740
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sysdeps/aarch64/dl-tlsdesc.S
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ _dl_tlsdesc_dynamic:
/* Save just enough registers to support fast path, if we fall
into slow path we will save additional registers. */
stp x1, x2, [sp, #-32]!
stp x3, x4, [sp, #16]
cfi_adjust_cfa_offset (32)
stp x3, x4, [sp, #16]
cfi_rel_offset (x1, 0)
cfi_rel_offset (x2, 8)
cfi_rel_offset (x3, 16)
Expand Down

0 comments on commit cd62740

Please sign in to comment.