a445492bf6
our tid caching implementation in chromium was depending on internal musl ABI from musl 1.2.4, but we stil have musl 1.1.x by default. Adding patches to get the same struct_pthread layout from mus 1.2 to get our chromium builds compatible with both musl 1.1 and 1.2 closes void-linux#29654
255 lines
7.5 KiB
Diff
255 lines
7.5 KiB
Diff
From ea71a9004e08030a15d45186e263fd2b0c51cc25 Mon Sep 17 00:00:00 2001
|
|
From: Rich Felker <dalias@aerifal.cx>
|
|
Date: Mon, 24 Aug 2020 22:04:52 -0400
|
|
Subject: [PATCH 3/5] deduplicate TP_ADJ logic out of each arch, replace with
|
|
TP_OFFSET
|
|
|
|
the only part of TP_ADJ that was not uniquely determined by
|
|
TLS_ABOVE_TP was the 0x7000 adjustment used mainly on mips and powerpc
|
|
variants.
|
|
---
|
|
arch/aarch64/pthread_arch.h | 1 -
|
|
arch/arm/pthread_arch.h | 1 -
|
|
arch/i386/pthread_arch.h | 2 --
|
|
arch/m68k/pthread_arch.h | 2 +-
|
|
arch/microblaze/pthread_arch.h | 2 --
|
|
arch/mips/pthread_arch.h | 2 +-
|
|
arch/mips64/pthread_arch.h | 2 +-
|
|
arch/mipsn32/pthread_arch.h | 2 +-
|
|
arch/or1k/pthread_arch.h | 1 -
|
|
arch/powerpc/pthread_arch.h | 2 +-
|
|
arch/powerpc64/pthread_arch.h | 2 +-
|
|
arch/riscv64/pthread_arch.h | 1 -
|
|
arch/s390x/pthread_arch.h | 2 --
|
|
arch/sh/pthread_arch.h | 1 -
|
|
arch/x32/pthread_arch.h | 2 --
|
|
arch/x86_64/pthread_arch.h | 2 --
|
|
src/internal/pthread_impl.h | 10 ++++++++++
|
|
17 files changed, 16 insertions(+), 21 deletions(-)
|
|
|
|
diff --git a/arch/aarch64/pthread_arch.h b/arch/aarch64/pthread_arch.h
|
|
index e64b126d..f3c005c7 100644
|
|
--- a/arch/aarch64/pthread_arch.h
|
|
+++ b/arch/aarch64/pthread_arch.h
|
|
@@ -7,6 +7,5 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 16
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
|
|
|
|
#define MC_PC pc
|
|
diff --git a/arch/arm/pthread_arch.h b/arch/arm/pthread_arch.h
|
|
index e689ea21..48640985 100644
|
|
--- a/arch/arm/pthread_arch.h
|
|
+++ b/arch/arm/pthread_arch.h
|
|
@@ -28,6 +28,5 @@ static inline pthread_t __pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 8
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
|
|
|
|
#define MC_PC arm_pc
|
|
diff --git a/arch/i386/pthread_arch.h b/arch/i386/pthread_arch.h
|
|
index 6f600b9e..32570a17 100644
|
|
--- a/arch/i386/pthread_arch.h
|
|
+++ b/arch/i386/pthread_arch.h
|
|
@@ -5,6 +5,4 @@ static inline struct pthread *__pthread_self()
|
|
return self;
|
|
}
|
|
|
|
-#define TP_ADJ(p) (p)
|
|
-
|
|
#define MC_PC gregs[REG_EIP]
|
|
diff --git a/arch/m68k/pthread_arch.h b/arch/m68k/pthread_arch.h
|
|
index 02d5b8a0..7c9990c2 100644
|
|
--- a/arch/m68k/pthread_arch.h
|
|
+++ b/arch/m68k/pthread_arch.h
|
|
@@ -6,8 +6,8 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 0
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
|
|
|
|
+#define TP_OFFSET 0x7000
|
|
#define DTP_OFFSET 0x8000
|
|
|
|
#define MC_PC gregs[R_PC]
|
|
diff --git a/arch/microblaze/pthread_arch.h b/arch/microblaze/pthread_arch.h
|
|
index f6ba8de9..c327f4eb 100644
|
|
--- a/arch/microblaze/pthread_arch.h
|
|
+++ b/arch/microblaze/pthread_arch.h
|
|
@@ -5,6 +5,4 @@ static inline struct pthread *__pthread_self()
|
|
return self;
|
|
}
|
|
|
|
-#define TP_ADJ(p) (p)
|
|
-
|
|
#define MC_PC regs.pc
|
|
diff --git a/arch/mips/pthread_arch.h b/arch/mips/pthread_arch.h
|
|
index 1e7839ea..c22eb34d 100644
|
|
--- a/arch/mips/pthread_arch.h
|
|
+++ b/arch/mips/pthread_arch.h
|
|
@@ -12,8 +12,8 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 0
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
|
|
|
|
+#define TP_OFFSET 0x7000
|
|
#define DTP_OFFSET 0x8000
|
|
|
|
#define MC_PC pc
|
|
diff --git a/arch/mips64/pthread_arch.h b/arch/mips64/pthread_arch.h
|
|
index 1e7839ea..c22eb34d 100644
|
|
--- a/arch/mips64/pthread_arch.h
|
|
+++ b/arch/mips64/pthread_arch.h
|
|
@@ -12,8 +12,8 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 0
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
|
|
|
|
+#define TP_OFFSET 0x7000
|
|
#define DTP_OFFSET 0x8000
|
|
|
|
#define MC_PC pc
|
|
diff --git a/arch/mipsn32/pthread_arch.h b/arch/mipsn32/pthread_arch.h
|
|
index 1e7839ea..c22eb34d 100644
|
|
--- a/arch/mipsn32/pthread_arch.h
|
|
+++ b/arch/mipsn32/pthread_arch.h
|
|
@@ -12,8 +12,8 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 0
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
|
|
|
|
+#define TP_OFFSET 0x7000
|
|
#define DTP_OFFSET 0x8000
|
|
|
|
#define MC_PC pc
|
|
diff --git a/arch/or1k/pthread_arch.h b/arch/or1k/pthread_arch.h
|
|
index 1b806f89..76d0a8bc 100644
|
|
--- a/arch/or1k/pthread_arch.h
|
|
+++ b/arch/or1k/pthread_arch.h
|
|
@@ -13,6 +13,5 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 0
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
|
|
|
|
#define MC_PC regs.pc
|
|
diff --git a/arch/powerpc/pthread_arch.h b/arch/powerpc/pthread_arch.h
|
|
index ae0f28d6..9697046b 100644
|
|
--- a/arch/powerpc/pthread_arch.h
|
|
+++ b/arch/powerpc/pthread_arch.h
|
|
@@ -7,8 +7,8 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 0
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
|
|
|
|
+#define TP_OFFSET 0x7000
|
|
#define DTP_OFFSET 0x8000
|
|
|
|
// the kernel calls the ip "nip", it's the first saved value after the 32
|
|
diff --git a/arch/powerpc64/pthread_arch.h b/arch/powerpc64/pthread_arch.h
|
|
index 79c3ecd8..e9dba43f 100644
|
|
--- a/arch/powerpc64/pthread_arch.h
|
|
+++ b/arch/powerpc64/pthread_arch.h
|
|
@@ -7,8 +7,8 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 0
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
|
|
|
|
+#define TP_OFFSET 0x7000
|
|
#define DTP_OFFSET 0x8000
|
|
|
|
// the kernel calls the ip "nip", it's the first saved value after the 32
|
|
diff --git a/arch/riscv64/pthread_arch.h b/arch/riscv64/pthread_arch.h
|
|
index db414b17..50f0868d 100644
|
|
--- a/arch/riscv64/pthread_arch.h
|
|
+++ b/arch/riscv64/pthread_arch.h
|
|
@@ -7,7 +7,6 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 0
|
|
-#define TP_ADJ(p) ((char *)p + sizeof(struct pthread))
|
|
|
|
#define DTP_OFFSET 0x800
|
|
|
|
diff --git a/arch/s390x/pthread_arch.h b/arch/s390x/pthread_arch.h
|
|
index e2251f1f..5d22546b 100644
|
|
--- a/arch/s390x/pthread_arch.h
|
|
+++ b/arch/s390x/pthread_arch.h
|
|
@@ -9,6 +9,4 @@ static inline struct pthread *__pthread_self()
|
|
return self;
|
|
}
|
|
|
|
-#define TP_ADJ(p) (p)
|
|
-
|
|
#define MC_PC psw.addr
|
|
diff --git a/arch/sh/pthread_arch.h b/arch/sh/pthread_arch.h
|
|
index 3ee9c1a9..c2252908 100644
|
|
--- a/arch/sh/pthread_arch.h
|
|
+++ b/arch/sh/pthread_arch.h
|
|
@@ -7,7 +7,6 @@ static inline struct pthread *__pthread_self()
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 8
|
|
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
|
|
|
|
#define MC_PC sc_pc
|
|
|
|
diff --git a/arch/x32/pthread_arch.h b/arch/x32/pthread_arch.h
|
|
index f640a1a1..fa452839 100644
|
|
--- a/arch/x32/pthread_arch.h
|
|
+++ b/arch/x32/pthread_arch.h
|
|
@@ -5,8 +5,6 @@ static inline struct pthread *__pthread_self()
|
|
return self;
|
|
}
|
|
|
|
-#define TP_ADJ(p) (p)
|
|
-
|
|
#define MC_PC gregs[REG_RIP]
|
|
|
|
#define CANARY canary2
|
|
diff --git a/arch/x86_64/pthread_arch.h b/arch/x86_64/pthread_arch.h
|
|
index 65e880c6..1c64a840 100644
|
|
--- a/arch/x86_64/pthread_arch.h
|
|
+++ b/arch/x86_64/pthread_arch.h
|
|
@@ -5,6 +5,4 @@ static inline struct pthread *__pthread_self()
|
|
return self;
|
|
}
|
|
|
|
-#define TP_ADJ(p) (p)
|
|
-
|
|
#define MC_PC gregs[REG_RIP]
|
|
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
|
|
index 5749a336..3c2bd767 100644
|
|
--- a/src/internal/pthread_impl.h
|
|
+++ b/src/internal/pthread_impl.h
|
|
@@ -105,10 +105,20 @@ struct __timer {
|
|
#define CANARY canary
|
|
#endif
|
|
|
|
+#ifndef TP_OFFSET
|
|
+#define TP_OFFSET 0
|
|
+#endif
|
|
+
|
|
#ifndef DTP_OFFSET
|
|
#define DTP_OFFSET 0
|
|
#endif
|
|
|
|
+#ifdef TLS_ABOVE_TP
|
|
+#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + TP_OFFSET)
|
|
+#else
|
|
+#define TP_ADJ(p) (p)
|
|
+#endif
|
|
+
|
|
#ifndef tls_mod_off_t
|
|
#define tls_mod_off_t size_t
|
|
#endif
|
|
--
|
|
2.47.0
|
|
|