glibc/glibc-aarch64-workaround-nzcv-clobber-in-tlsdesc.patch
Kyle McMartin b66a135726 AArch64: Save & restore NZCV (flags) upon entry to _dl_tlsdesc_dynamic
in order to work around GCC reordering compares across the TLS
  descriptor sequence (GCC PR61545.) Committing a (temporary) fix here
  allows us to avoid rebuilding the world with gcc 4.9.0-11.fc21.
2014-06-20 11:49:56 -04:00

34 lines
953 B
Diff

diff --git a/sysdeps/aarch64/dl-tlsdesc.S b/sysdeps/aarch64/dl-tlsdesc.S
index ded5471..7d28496 100644
--- a/sysdeps/aarch64/dl-tlsdesc.S
+++ b/sysdeps/aarch64/dl-tlsdesc.S
@@ -140,7 +140,7 @@ _dl_tlsdesc_undefweak:
cfi_startproc
.align 2
_dl_tlsdesc_dynamic:
-# define NSAVEXREGPAIRS 2
+# define NSAVEXREGPAIRS 3
stp x29, x30, [sp,#-(32+16*NSAVEXREGPAIRS)]!
cfi_adjust_cfa_offset (32+16*NSAVEXREGPAIRS)
mov x29, sp
@@ -151,6 +151,10 @@ _dl_tlsdesc_dynamic:
stp x1, x2, [sp, #32+16*0]
stp x3, x4, [sp, #32+16*1]
+ /* Work around GCC rescheduling compares across tlsdesc calls. */
+ mrs x30, nzcv
+ stp xzr, x30, [sp, #32+16*2]
+
mrs x4, tpidr_el0
ldr x1, [x0,#8]
ldr x0, [x4]
@@ -169,6 +173,8 @@ _dl_tlsdesc_dynamic:
1:
ldp x1, x2, [sp, #32+16*0]
ldp x3, x4, [sp, #32+16*1]
+ ldp xzr, x30, [sp, #32+16*2]
+ msr nzcv, x30
ldp x29, x30, [sp], #(32+16*NSAVEXREGPAIRS)
cfi_adjust_cfa_offset (32+16*NSAVEXREGPAIRS)