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