94084c
commit 93aabf891e96e93f100081ee07989c23d7107d17
94084c
Author: Florian Weimer <fweimer@redhat.com>
94084c
Date:   Fri Dec 17 11:48:41 2021 +0100
94084c
94084c
    arm: Guard ucontext _rtld_global_ro access by SHARED, not PIC macro
94084c
    
94084c
    Due to PIE-by-default, PIC is now defined in more cases.  libc.a
94084c
    does not have _rtld_global_ro, and statically linking setcontext
94084c
    fails.  SHARED is the right condition to use, so that libc.a
94084c
    references _dl_hwcap instead of _rtld_global_ro.
94084c
    
94084c
    For static PIE support, the !SHARED case would still have to be made
94084c
    PIC.  This patch does not achieve that.
94084c
    
94084c
    Fixes commit 23645707f12f2dd9d80b51effb2d9618a7b65565
94084c
    ("Replace --enable-static-pie with --disable-default-pie").
94084c
    
94084c
    Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
94084c
    Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
94084c
    (cherry picked from commit ce1e5b11229f19820b86f8b19d651f16009552b0)
94084c
94084c
diff --git a/sysdeps/unix/sysv/linux/arm/getcontext.S b/sysdeps/unix/sysv/linux/arm/getcontext.S
94084c
index 3aa581c4da6d1166..11bfcbe5f53afc6e 100644
94084c
--- a/sysdeps/unix/sysv/linux/arm/getcontext.S
94084c
+++ b/sysdeps/unix/sysv/linux/arm/getcontext.S
94084c
@@ -50,7 +50,7 @@ ENTRY(__getcontext)
94084c
 
94084c
 	/* Store FP regs.  Much of the FP code is copied from arm/setjmp.S.  */
94084c
 
94084c
-#ifdef PIC
94084c
+#ifdef SHARED
94084c
 	ldr     r2, 1f
94084c
 	ldr     r1, .Lrtld_global_ro
94084c
 0:      add     r2, pc, r2
94084c
@@ -102,7 +102,7 @@ ENTRY(__getcontext)
94084c
 
94084c
 END(__getcontext)
94084c
 
94084c
-#ifdef PIC
94084c
+#ifdef SHARED
94084c
 1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
94084c
 .Lrtld_global_ro:
94084c
 	.long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)
94084c
diff --git a/sysdeps/unix/sysv/linux/arm/setcontext.S b/sysdeps/unix/sysv/linux/arm/setcontext.S
94084c
index 8be8beefea13883e..4c7c6e550944138c 100644
94084c
--- a/sysdeps/unix/sysv/linux/arm/setcontext.S
94084c
+++ b/sysdeps/unix/sysv/linux/arm/setcontext.S
94084c
@@ -32,7 +32,7 @@ ENTRY(__setcontext)
94084c
 	add	r0, r0, #UCONTEXT_REGSPACE
94084c
 
94084c
 	/* Restore the VFP registers.  Copied from arm/__longjmp.S.  */
94084c
-#ifdef PIC
94084c
+#ifdef SHARED
94084c
 	ldr     r2, 1f
94084c
 	ldr     r1, .Lrtld_global_ro
94084c
 0:      add     r2, pc, r2
94084c
@@ -101,7 +101,7 @@ ENTRY(__startcontext)
94084c
 	.fnend
94084c
 END(__startcontext)
94084c
 
94084c
-#ifdef PIC
94084c
+#ifdef SHARED
94084c
 1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
94084c
 .Lrtld_global_ro:
94084c
 	.long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)