From e364774d7ca0a78db1b8457d5094b747eb2df318 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 13 Oct 2017 10:23:48 -0400 Subject: fix access by setjmp and longjmp to __hwcap on arm built as thumb2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this is a subtle issue with how the assembler/linker work. for the adr pseudo-instruction used to find __hwcap, the assembler in thumb mode generates a 16-bit thumb add instruction which can only represent word-aligned addresses, despite not knowing the alignment of the label. if the setjmp function is assigned a non-multiple-of-4 address at link time, the load then loads from the wrong address (the last instruction rather than the data containing the offset) and ends up reading nonsense instead of the value of __hwcap. this in turn causes the checks for floating-point/vector register sets (e.g. IWMMX) to evaluate incorrectly, crashing when setjmp/longjmp try to save/restore those registers. fix based on bug report by Felix Hädicke. --- src/setjmp/arm/longjmp.s | 1 + src/setjmp/arm/setjmp.s | 1 + 2 files changed, 2 insertions(+) (limited to 'src/setjmp') diff --git a/src/setjmp/arm/longjmp.s b/src/setjmp/arm/longjmp.s index 6191ab26..76cc2920 100644 --- a/src/setjmp/arm/longjmp.s +++ b/src/setjmp/arm/longjmp.s @@ -39,4 +39,5 @@ longjmp: 3: bx lr .hidden __hwcap +.align 2 1: .word __hwcap-1b diff --git a/src/setjmp/arm/setjmp.s b/src/setjmp/arm/setjmp.s index c6fe1bb2..011315b7 100644 --- a/src/setjmp/arm/setjmp.s +++ b/src/setjmp/arm/setjmp.s @@ -41,4 +41,5 @@ setjmp: 3: bx lr .hidden __hwcap +.align 2 1: .word __hwcap-1b -- cgit v1.2.3-70-g09d2