diff options
author | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-07-11 12:11:22 +0000 |
---|---|---|
committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-07-11 12:11:22 +0000 |
commit | d7e2580a1494a8a05d4a97fa472612df84c1539b (patch) | |
tree | e23c554da8b8ad2c8233026a47468178df6e90fe | |
parent | e541cf8316bb787df0f19c43132c517482cf24a6 (diff) | |
download | src-d7e2580a1494a8a05d4a97fa472612df84c1539b.tar.gz src-d7e2580a1494a8a05d4a97fa472612df84c1539b.zip |
csu: Add the prologue and epilogue to the _init and _fini on i386
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, imp
Differential Revision: https://reviews.freebsd.org/D40948
-rw-r--r-- | lib/csu/i386/crti.S | 8 | ||||
-rw-r--r-- | lib/csu/i386/crtn.S | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/csu/i386/crti.S b/lib/csu/i386/crti.S index 77e4e77722d7..f5883db0ba0f 100644 --- a/lib/csu/i386/crti.S +++ b/lib/csu/i386/crti.S @@ -31,13 +31,17 @@ __FBSDID("$FreeBSD$"); .globl _init .type _init,@function _init: - sub $12,%esp /* re-align stack pointer */ + pushl %ebp + movl %esp,%ebp + subl $8,%esp /* re-align stack pointer */ .section .fini,"ax",@progbits .align 4 .globl _fini .type _fini,@function _fini: - sub $12,%esp /* re-align stack pointer */ + pushl %ebp + movl %esp,%ebp + subl $8,%esp /* re-align stack pointer */ .section .note.GNU-stack,"",%progbits diff --git a/lib/csu/i386/crtn.S b/lib/csu/i386/crtn.S index 0264e22540f1..f223062bb787 100644 --- a/lib/csu/i386/crtn.S +++ b/lib/csu/i386/crtn.S @@ -27,11 +27,13 @@ __FBSDID("$FreeBSD$"); .section .init,"ax",@progbits - add $12,%esp + addl $8,%esp + popl %ebp ret .section .fini,"ax",@progbits - add $12,%esp + addl $8,%esp + popl %ebp ret .section .note.GNU-stack,"",%progbits |