diff options
author | wilco <wilco@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-09-21 12:16:31 +0000 |
---|---|---|
committer | wilco <wilco@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-09-21 12:16:31 +0000 |
commit | cf111e854f7a563bdf0fdf1cf930f147e3e24ab8 (patch) | |
tree | 28c54d24d3c994387fd70a2dab93fb342e7cabba | |
parent | 401aef63de6bac04bb158b5e0d461ae73a8c8307 (diff) | |
download | gcc-cf111e854f7a563bdf0fdf1cf930f147e3e24ab8.tar.gz |
PR71951: Fix unwinding with -fomit-frame-pointer
As described in PR71951, if libgcc is built with -fomit-frame-pointer,
unwinding crashes, for example while doing a backtrace. The underlying
reason is the Dwarf unwinder does not setup the frame pointer register
in the initialization code. When later unwinding a function that uses
the frame pointer, it tries to read FP using _Unwind_GetGR, and this
crashes if has never restored FP. To unwind correctly the first frame
must save and restore FP (it is unwound in a special way so that it
uses SP instead of FP). This is done by adding -fno-omit-frame-pointer.
gcc/
PR target/71951
* config/aarch64/aarch64.h (LIBGCC2_UNWIND_ATTRIBUTE): Define.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@253063 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64.h | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0f689ba0103..20841cf0fbc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-09-21 Wilco Dijkstra <wdijkstr@arm.com> + + PR target/71951 + * config/aarch64/aarch64.h (LIBGCC2_UNWIND_ATTRIBUTE): Define. + 2017-09-19 Uros Bizjak <ubizjak@gmail.com> * config/i386/i386.c (fold_builtin_cpu): Add M_AMDFAM17H diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index e4fb96fd037..52d6414cbf4 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -958,4 +958,12 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); extern tree aarch64_fp16_type_node; extern tree aarch64_fp16_ptr_type_node; +/* The generic unwind code in libgcc does not initialize the frame pointer. + So in order to unwind a function using a frame pointer, the very first + function that is unwound must save the frame pointer. That way the frame + pointer is restored and its value is now valid - otherwise _Unwind_GetGR + crashes. Libgcc can now be safely built with -fomit-frame-pointer. */ +#define LIBGCC2_UNWIND_ATTRIBUTE \ + __attribute__((optimize ("no-omit-frame-pointer"))) + #endif /* GCC_AARCH64_H */ |