arm: Introduce and use PC_OFS
authorRichard Henderson <rth@twiddle.net>
Wed, 13 Feb 2013 01:15:52 +0000 (17:15 -0800)
committerRichard Henderson <rth@twiddle.net>
Thu, 28 Feb 2013 08:16:05 +0000 (00:16 -0800)
Scour the source for raw "-8" adjustments that are related to the
offset created by reading the pc.

ports/ChangeLog.arm
ports/sysdeps/arm/__longjmp.S
ports/sysdeps/arm/setjmp.S
ports/sysdeps/arm/sysdep.h
ports/sysdeps/unix/arm/sysdep.S
ports/sysdeps/unix/sysv/linux/arm/getcontext.S
ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h
ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c
ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c
ports/sysdeps/unix/sysv/linux/arm/setcontext.S
ports/sysdeps/unix/sysv/linux/arm/sysdep.h

index da15413..fe0fd46 100644 (file)
        * ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h: Likewise.
        * sysdeps/unix/sysv/linux/arm/sysdep.h: Likewise.
 
+       * sysdeps/arm/sysdep.h (PC_OFS): New macros.
+       * sysdeps/arm/__longjmp.S (__longjmp): Use PC_OFS.
+       * sysdeps/arm/setjmp.S (__sigsetjmp): Likewise.
+       * sysdeps/unix/arm/sysdep.S (__syscall_error): Likewise.
+       * sysdeps/unix/sysv/linux/arm/getcontext.S (__getcontext): Likewise.
+       * sysdeps/unix/sysv/linux/arm/setcontext.S (__startcontext): Likewise.
+       * sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h
+       (SINGLE_THREAD_P): Likewise.
+       * sysdeps/unix/sysv/linux/arm/sysdep.h
+       (SYSCALL_ERROR_HANDLER): Likewise.
+       * sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c
+       (_Unwind_Resume): Use stringified PC_OFS.
+       * sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c
+       (_Unwind_Resume): Likewise.
+
 2013-02-27  Roland McGrath  <roland@hack.frob.com>
 
        * sysdeps/arm/sysdep.h (CFI_SECTIONS): New macro.
index 5c04f36..3d6e114 100644 (file)
@@ -105,12 +105,12 @@ ENTRY (__longjmp)
 
 #ifdef NEED_HWCAP
 # ifdef IS_IN_rtld
-1:     .long   _GLOBAL_OFFSET_TABLE_ - 0b - 8
+1:     .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
 .Lrtld_local_ro:
        .long   C_SYMBOL_NAME(_rtld_local_ro)(GOTOFF)
 # else
 #  ifdef PIC
-1:     .long   _GLOBAL_OFFSET_TABLE_ - 0b - 8
+1:     .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
 .Lrtld_global_ro:
        .long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)
 #  else
index 4b7542a..baa02be 100644 (file)
@@ -91,12 +91,12 @@ ENTRY (__sigsetjmp)
 
 #ifdef NEED_HWCAP
 # ifdef IS_IN_rtld
-1:     .long   _GLOBAL_OFFSET_TABLE_ - 0b - 8
+1:     .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
 .Lrtld_local_ro:
        .long   C_SYMBOL_NAME(_rtld_local_ro)(GOTOFF)
 # else
 #  ifdef PIC
-1:     .long   _GLOBAL_OFFSET_TABLE_ - 0b - 8
+1:     .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
 .Lrtld_global_ro:
        .long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)
 #  else
index f5ddab0..4af7429 100644 (file)
        .eabi_attribute 24, 1
 
 #endif /* __ASSEMBLER__ */
+
+/* This number is the offset from the pc at the current location.  */
+/* ??? At the moment we're not turning on thumb mode in assembly.  */
+#if defined(__thumb__) && !defined(__ASSEMBLER__)
+# define PC_OFS  4
+#else
+# define PC_OFS  8
+#endif
index da07d85..99bca9f 100644 (file)
@@ -50,14 +50,14 @@ __syscall_error:
        mvn r0, #0
        RETINSTR (, ip)
 
-1:     .word errno(gottpoff) + (. - 2b - 8)
+1:     .word errno(gottpoff) + (. - 2b - PC_OFS)
 #elif RTLD_PRIVATE_ERRNO
        ldr r1, 1f
 0:     str r0, [pc, r1]
        mvn r0, $0
        DO_RET(r14)
 
-1:     .word C_SYMBOL_NAME(rtld_errno) - 0b - 8
+1:     .word C_SYMBOL_NAME(rtld_errno) - 0b - PC_OFS
 #else
 #error "Unsupported non-TLS case"
 #endif
index f7857c1..fa00c0b 100644 (file)
@@ -103,7 +103,7 @@ ENTRY(__getcontext)
 END(__getcontext)
 
 #ifdef PIC
-1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - 8
+1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
 .Lrtld_global_ro:
        .long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)
 #else
index 4bd79d4..df85d51 100644 (file)
@@ -208,7 +208,7 @@ extern int __local_multiple_threads attribute_hidden;
        ldr ip, [pc, ip];                                               \
        teq ip, #0;
 #   define PSEUDO_PROLOGUE                                             \
-  1:   .word   __local_multiple_threads - 2f - 8;
+  1:   .word   __local_multiple_threads - 2f - PC_OFS;
 #  endif
 # else
 /*  There is no __local_multiple_threads for librt, so use the TCB.  */
index 58ca9ac..caa6a26 100644 (file)
@@ -84,6 +84,9 @@ __unwind_freeres (void)
    ARM unwinder relies on register state at entrance.  So we write this in
    assembly.  */
 
+#define STR1(S) #S
+#define STR(S)  STR1(S)
+
 asm (
 "      .globl  _Unwind_Resume\n"
 "      .type   _Unwind_Resume, %function\n"
@@ -118,11 +121,7 @@ asm (
 "      b       5b\n"
 "      " CFI_ENDPROC "\n"
 "      .align 2\n"
-#ifdef __thumb2__
-"1:    .word   _GLOBAL_OFFSET_TABLE_ - 3b - 4\n"
-#else
-"1:    .word   _GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
-#endif
+"1:    .word   _GLOBAL_OFFSET_TABLE_ - 3b - " STR (PC_OFS) "\n"
 "2:    .word   libgcc_s_resume(GOTOFF)\n"
 "      .size   _Unwind_Resume, .-_Unwind_Resume\n"
 );
index 0a3ad95..1211599 100644 (file)
@@ -47,6 +47,9 @@ init (void)
    ARM unwinder relies on register state at entrance.  So we write this in
    assembly.  */
 
+#define STR1(S) #S
+#define STR(S)  STR1(S)
+
 asm (
 "      .globl  _Unwind_Resume\n"
 "      .type   _Unwind_Resume, %function\n"
@@ -81,11 +84,7 @@ asm (
 "      b       5b\n"
 "      " CFI_ENDPROC "\n"
 "      .align 2\n"
-#ifdef __thumb2__
-"1:    .word   _GLOBAL_OFFSET_TABLE_ - 3b - 4\n"
-#else
-"1:    .word   _GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
-#endif
+"1:    .word   _GLOBAL_OFFSET_TABLE_ - 3b - " STR (PC_OFS) "\n"
 "2:    .word   libgcc_s_resume(GOTOFF)\n"
 "      .size   _Unwind_Resume, .-_Unwind_Resume\n"
 );
index 8e71f5b..edd17bc 100644 (file)
@@ -93,7 +93,7 @@ ENTRY(__startcontext)
 END(__startcontext)
 
 #ifdef PIC
-1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - 8
+1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
 .Lrtld_global_ro:
        .long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)
 #else
index 676a143..f9b3443 100644 (file)
@@ -114,7 +114,7 @@ __local_syscall_error:                                              \
 0:     str     r0, [pc, r1];                                   \
        mvn     r0, #0;                                         \
        DO_RET(lr);                                             \
-1:     .word C_SYMBOL_NAME(rtld_errno) - 0b - 8;
+1:     .word C_SYMBOL_NAME(rtld_errno) - 0b - PC_OFS;
 # else
 #  if defined(__ARM_ARCH_4T__) && defined(__THUMB_INTERWORK__)
 #   define POP_PC \