diff options
author | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-07-01 07:52:10 +0000 |
---|---|---|
committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-07-01 07:52:10 +0000 |
commit | f049c92ad6c38ef42265956545897d8e3be1c228 (patch) | |
tree | 8e1deb325ecccb0cf1f26f79b2526f05f1c4ff55 | |
parent | 3bdf68086de8bee79f09cba28fd0df3be6565216 (diff) | |
download | src-f049c92ad6c38ef42265956545897d8e3be1c228.tar.gz src-f049c92ad6c38ef42265956545897d8e3be1c228.zip |
csu: Add the prologue and epilogue to the _init and _fini on x86_64
Normally, modern unwinders uses Dwarf information to unwind stack,
however in case when the code is not annotated by Dwarf instructions,
unwinders fallbacks to a frame-pointer based algorithm.
That is allows libunwind to unwind stack from global constructors and
destructors. Also it makes gdb happy as it printed nonexistent frame
before.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D40795
-rw-r--r-- | lib/csu/amd64/crti.S | 6 | ||||
-rw-r--r-- | lib/csu/amd64/crtn.S | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/csu/amd64/crti.S b/lib/csu/amd64/crti.S index 618dca178877..05b8ad8a431a 100644 --- a/lib/csu/amd64/crti.S +++ b/lib/csu/amd64/crti.S @@ -31,13 +31,15 @@ __FBSDID("$FreeBSD$"); .globl _init .type _init,@function _init: - subq $8,%rsp + pushq %rbp + movq %rsp,%rbp .section .fini,"ax",@progbits .align 4 .globl _fini .type _fini,@function _fini: - subq $8,%rsp + pushq %rbp + movq %rsp,%rbp .section .note.GNU-stack,"",%progbits diff --git a/lib/csu/amd64/crtn.S b/lib/csu/amd64/crtn.S index c411f001ac1f..50b5003b9f7c 100644 --- a/lib/csu/amd64/crtn.S +++ b/lib/csu/amd64/crtn.S @@ -27,11 +27,11 @@ __FBSDID("$FreeBSD$"); .section .init,"ax",@progbits - addq $8,%rsp + popq %rbp ret .section .fini,"ax",@progbits - addq $8,%rsp + popq %rbp ret .section .note.GNU-stack,"",%progbits |