Cleanup pointer mangling.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
ldp x23, x24, [x0, #JB_X23<<3]
ldp x25, x26, [x0, #JB_X25<<3]
ldp x27, x28, [x0, #JB_X27<<3]
-#ifdef PTR_DEMANGLE
- ldp x29, x4, [x0, #JB_X29<<3]
- PTR_DEMANGLE (30, 4, 3, 2)
-#else
ldp x29, x30, [x0, #JB_X29<<3]
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (x30, x30, x3)
#endif
/* longjmp probe takes 3 arguments, address of jump buffer as
first argument (8@x0), return value as second argument (-4@x1),
cfi_same_value(d13)
cfi_same_value(d14)
cfi_same_value(d15)
-#ifdef PTR_DEMANGLE
+
ldr x4, [x0, #JB_SP<<3]
- PTR_DEMANGLE (5, 4, 3, 2)
-#else
- ldr x5, [x0, #JB_SP<<3]
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (x4, x4, x3)
#endif
- mov sp, x5
+ mov sp, x4
/* longjmp_target probe takes 3 arguments, address of jump buffer
as first argument (8@x0), return value as second argument (-4@x1),
and target address (8@x30), respectively. */
LIBC_PROBE (longjmp_target, 3, 8@x0, -4@x1, 8@x30)
- cmp x1, #0
- mov x0, #1
- csel x0, x1, x0, ne
+
+ cmp x1, 0
+ cinc x0, x1, eq
+
/* Use br instead of ret because ret is guaranteed to mispredict */
br x30
END (__longjmp)
b 1f
END (setjmp)
-ENTRY (_setjmp)
+ENTRY_ALIGN (_setjmp, 2)
mov x1, #0
b 1f
END (_setjmp)
libc_hidden_def (_setjmp)
-ENTRY (__sigsetjmp)
+ENTRY_ALIGN (__sigsetjmp, 2)
1:
stp x19, x20, [x0, #JB_X19<<3]
stp x21, x22, [x0, #JB_X21<<3]
stp x27, x28, [x0, #JB_X27<<3]
#ifdef PTR_MANGLE
- PTR_MANGLE (4, 30, 3, 2)
+ PTR_MANGLE (x4, x30, x3)
stp x29, x4, [x0, #JB_X29<<3]
#else
stp x29, x30, [x0, #JB_X29<<3]
str x2, [x0, #JB_GCSPR]
L(gcs_done):
+ mov x2, sp
#ifdef PTR_MANGLE
- mov x4, sp
- PTR_MANGLE (5, 4, 3, 2)
- str x5, [x0, #JB_SP<<3]
-#else
- mov x2, sp
- str x2, [x0, #JB_SP<<3]
+ PTR_MANGLE (x2, x2, x3)
#endif
+ str x2, [x0, #JB_SP<<3]
#if IS_IN (rtld)
/* In ld.so we never save the signal mask */
mov w0, #0
# define L(name) .L##name
#endif
-/* Load or store to/from a pc-relative EXPR into/from R, using T.
- Note R and T are register numbers and not register names. */
-#define LDST_PCREL(OP, R, T, EXPR) \
- adrp x##T, EXPR; \
- OP x##R, [x##T, #:lo12:EXPR]; \
-
-/* Load or store to/from a got-relative EXPR into/from R, using T.
- Note R and T are register numbers and not register names. */
-#define LDST_GLOBAL(OP, R, T, EXPR) \
- adrp x##T, :got:EXPR; \
- ldr x##T, [x##T, #:got_lo12:EXPR]; \
- OP x##R, [x##T];
-
/* Since C identifiers are not normally prefixed with an underscore
on this system, the asm identifier `syscall_error' intrudes on the
C name space. Make sure we use an innocuous name. */
|| (!defined SHARED && (IS_IN (libc) \
|| IS_IN (libpthread))))
# ifdef __ASSEMBLER__
-/* Note, dst, src, guard, and tmp are all register numbers rather than
- register names so they will work with both ILP32 and LP64. */
-# define PTR_MANGLE(dst, src, guard, tmp) \
- LDST_PCREL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local)); \
- PTR_MANGLE2 (dst, src, guard)
-/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
-# define PTR_MANGLE2(dst, src, guard)\
- eor x##dst, x##src, x##guard
-# define PTR_DEMANGLE(dst, src, guard, tmp)\
- PTR_MANGLE (dst, src, guard, tmp)
-# define PTR_DEMANGLE2(dst, src, guard)\
- PTR_MANGLE2 (dst, src, guard)
+# define PTR_MANGLE(dst, src, tmp) \
+ adrp tmp, C_SYMBOL_NAME(__pointer_chk_guard_local); \
+ ldr tmp, [tmp, :lo12:C_SYMBOL_NAME(__pointer_chk_guard_local)]; \
+ eor dst, src, tmp
+# define PTR_DEMANGLE(dst, src, tmp) PTR_MANGLE (dst, src, tmp)
# else
extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
# define PTR_MANGLE(var) \
# endif
#else
# ifdef __ASSEMBLER__
-/* Note, dst, src, guard, and tmp are all register numbers rather than
- register names so they will work with both ILP32 and LP64. */
-# define PTR_MANGLE(dst, src, guard, tmp) \
- LDST_GLOBAL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard)); \
- PTR_MANGLE2 (dst, src, guard)
-/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
-# define PTR_MANGLE2(dst, src, guard)\
- eor x##dst, x##src, x##guard
-# define PTR_DEMANGLE(dst, src, guard, tmp)\
- PTR_MANGLE (dst, src, guard, tmp)
-# define PTR_DEMANGLE2(dst, src, guard)\
- PTR_MANGLE2 (dst, src, guard)
+# define PTR_MANGLE(dst, src, tmp) \
+ adrp tmp, :got:C_SYMBOL_NAME(__pointer_chk_guard); \
+ ldr tmp, [tmp, :got_lo12:C_SYMBOL_NAME(__pointer_chk_guard)]; \
+ ldr tmp, [tmp]; \
+ eor dst, src, tmp;
+# define PTR_DEMANGLE(dst, src, tmp) PTR_MANGLE (dst, src, tmp)
# else
# include <stdint.h>
extern uintptr_t __pointer_chk_guard attribute_relro;