package/libunwind: fix build in Thumb-1 mode
PATCH 1/1 package/libunwind: fix build in Thumb-1 mode
When building for a Thumb-1 configuration (BR2_ARM_INSTRUCTIONS_THUMB, e.g. ARMv5/ARMv6), libunwind fails to build:
/tmp/ccX8Ttef.s:58: Error: lo register required -- `ldmia r2,{r4-r12,lr}' make[3]: *** [Makefile:4829: arm/Gresume.lo] Error 1
arm_local_resume() restores the registers with an inline "ldmia %0, {r4-r12, lr}", but Thumb-1 ldmia can only load r0-r7.
Add a patch, sent upstream, that compiles arm_local_resume() in ARM mode on Thumb-1 with __attribute__((target("arm"))). All Thumb-1 capable cores also support the ARM instruction set, and the function is only reached through the resume function pointer, so interworking is handled by the indirect call.
This issue has been present since commit 79310d3275 ("arch/arm: add support for thumb(1) mode"), which made Thumb-1 builds possible while libunwind 1.1 already used this ldmia. It therefore affects 2013.08 and later, including all maintained branches.
Fixes:
https://autobuild.buildroot.org/results/2d5de71842f86b18e14094f3aeb95c3e849c3a21
--- ..._local_resume-in-ARM-mode-on-Thumb-1.patch | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 package/libunwind/0001-arm-build-arm_local_resume-in-ARM-mode-on-Thumb-1.patch
package/libunwind/0001-arm-build-arm_local_resume-in-ARM-mode-on-Thumb-1.patch new file +43 -0
@@ -0,0 +1,43 @@ +From a504993e059c6225e923488e2dbbc4112c277a28 Mon Sep 17 00:00:00 2001 +From: Yegor Yefremov <[email protected]> +Date: Sat, 31 Oct 2026 08:55:20 +0100 +Subject: [PATCH] arm: build arm_local_resume() in ARM mode on Thumb-1 + +When libunwind is built for Thumb-1 (e.g. -march=armv5te -mthumb), +assembling arm_local_resume() fails: + + Error: lo register required -- `ldmia r3,{r4-r12,lr}' + +Thumb-1 ldmia can only load r0-r7, so the register restore sequence +cannot be encoded. Every Thumb-1 capable core also supports the ARM +instruction set, so compile this function in ARM mode with +__attribute__((target("arm"))). It is only reached through the +resume function pointer, so interworking is handled by the +indirect call. Thumb-2 builds are not affected. + +Upstream: https://github.com/libunwind/libunwind/pull/1079 +Assisted-by: Claude:claude-opus-5-5 +Signed-off-by: Yegor Yefremov <[email protected]> +--- + src/arm/Gresume.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/arm/Gresume.c b/src/arm/Gresume.c +index ed284e7..d3b3875 100644 +--- a/src/arm/Gresume.c ++++ b/src/arm/Gresume.c +@@ -29,6 +29,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + + #ifndef UNW_REMOTE_ONLY + ++/* Thumb-1 ldmia can only load the low registers, so build the resume ++ code in ARM mode. */ ++#if defined(__thumb__) && !defined(__thumb2__) ++__attribute__((target("arm"))) ++#endif + HIDDEN inline int + arm_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) + { +-- +2.34.1 +
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot