[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] [PATCH 20/27] ARM: fix non-signal-frame local unw_resu
From: |
Tommi Rantala |
Subject: |
[Libunwind-devel] [PATCH 20/27] ARM: fix non-signal-frame local unw_resume() due to compiler optimization cleverness |
Date: |
Wed, 22 Aug 2012 14:28:46 +0300 |
When cross-compiling libunwind with optimizations (-O1 or higher),
gcc-4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) optimizes away the memory
writes prior to the inline asm() statement in arm_local_resume() in the
non-signal-frame path, causing the `regs' array to be only allocated on
the stack, but not populated. This means that we are restoring garbage
to the registers.
As suggested in the GCC docs, add a fixed size input memory constraint
for the array content. This is enough to get the desired code to be
generated.
Adding __builtin_unreachable() to the point that we should never reach
was also in itself enough to inhibit the optimization. It also reduces
the function size by a few instructions.
---
src/arm/Gresume.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/arm/Gresume.c b/src/arm/Gresume.c
index da45dec..4100d87 100644
--- a/src/arm/Gresume.c
+++ b/src/arm/Gresume.c
@@ -1,6 +1,7 @@
/* libunwind - a platform-independent unwind library
Copyright (C) 2008 CodeSourcery
Copyright 2011 Linaro Limited
+ Copyright (C) 2012 Tommi Rantala <address@hidden>
This file is part of libunwind.
@@ -51,11 +52,16 @@ arm_local_resume (unw_addr_space_t as, unw_cursor_t
*cursor, void *arg)
regs[8] = uc->regs[13]; /* SP */
regs[9] = uc->regs[14]; /* LR */
+ struct regs_overlay {
+ char x[sizeof(regs)];
+ };
+
asm __volatile__ (
"ldmia %0, {r4-r12, lr}\n"
"mov sp, r12\n"
"bx lr\n"
- : : "r" (regs)
+ : : "r" (regs),
+ "m" (*(struct regs_overlay *)regs)
);
}
else
@@ -90,6 +96,7 @@ arm_local_resume (unw_addr_space_t as, unw_cursor_t *cursor,
void *arg)
: : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc)
);
}
+ __builtin_unreachable();
#else
printf ("%s: implement me\n", __FUNCTION__);
#endif
--
1.7.9.5
- [Libunwind-devel] [PATCH 10/27] Stop using nonportable echo arguments in tests, (continued)
- [Libunwind-devel] [PATCH 10/27] Stop using nonportable echo arguments in tests, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 14/27] ARM: implement dwarf_to_unw_regnum() macro without table, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 17/27] Use constants for ELF magic bytes in _UCD_create.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 23/27] Avoid -Wunused-value warning in tests/Gtest-exc.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 18/27] Remove unneeded length modifier from suppressed match in sscanf() format in tests/crasher.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 19/27] Fix memory leaks in unw_create_addr_space() wrong-endian error paths, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 16/27] Fix plain return from main() in tests/test-async-sig.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 22/27] test-resume-sig-rt: test unw_resume() in presence of "realtime" signal frame, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 25/27] Place `inline' at beginning of declaration of invalidate_edi(), Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 20/27] ARM: fix non-signal-frame local unw_resume() due to compiler optimization cleverness,
Tommi Rantala <=
- [Libunwind-devel] [PATCH 21/27] ARM: fix with-signal-frame local unw_resume(), Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 24/27] Flush icache with __builtin___clear_cache() in tests when compiling with GCC, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 26/27] Fix function name duplication in Debug() output, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 27/27] Add missing newline to debug message in _UCD_access_reg_linux.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 02/27] HPPA: add `global_cache' member to unw_addr_space struct, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 09/27] Run `autoupdate' to stop using obsoleted macros in `configure.in', Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 01/27] HPPA: fix tdep_put_unwind_info() macro, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 06/27] Eliminate unused parameters in tests, Tommi Rantala, 2012/08/22