Use TLS_SLOT_THREAD_ID macro in vfork.S
No functional change intended.
Bug: none
Test: bionic unit tests
Change-Id: I7ee0a2b3f0e3807abe88bfa34ef3cd56c150a8f6
diff --git a/libc/arch-arm/bionic/vfork.S b/libc/arch-arm/bionic/vfork.S
index 8329111..0b17d64 100644
--- a/libc/arch-arm/bionic/vfork.S
+++ b/libc/arch-arm/bionic/vfork.S
@@ -27,12 +27,13 @@
*/
#include <private/bionic_asm.h>
+#include <private/bionic_asm_tls.h>
ENTRY(vfork)
__BIONIC_WEAK_ASM_FOR_NATIVE_BRIDGE(vfork)
// __get_tls()[TLS_SLOT_THREAD_ID]->cached_pid_ = 0
mrc p15, 0, r3, c13, c0, 3
- ldr r3, [r3, #4]
+ ldr r3, [r3, #(TLS_SLOT_THREAD_ID * 4)]
mov r0, #0
str r0, [r3, #12]
diff --git a/libc/arch-arm64/bionic/vfork.S b/libc/arch-arm64/bionic/vfork.S
index 0a83cc7..6acd64b 100644
--- a/libc/arch-arm64/bionic/vfork.S
+++ b/libc/arch-arm64/bionic/vfork.S
@@ -27,6 +27,7 @@
*/
#include <private/bionic_asm.h>
+#include <private/bionic_asm_tls.h>
#include <asm/signal.h>
#include <linux/sched.h>
@@ -34,7 +35,7 @@
__BIONIC_WEAK_ASM_FOR_NATIVE_BRIDGE(vfork)
// __get_tls()[TLS_SLOT_THREAD_ID]->cached_pid_ = 0
mrs x0, tpidr_el0
- ldr x0, [x0, #8]
+ ldr x0, [x0, #(TLS_SLOT_THREAD_ID * 8)]
str wzr, [x0, #20]
mov x0, #(CLONE_VM | CLONE_VFORK | SIGCHLD)
diff --git a/libc/arch-x86/bionic/vfork.S b/libc/arch-x86/bionic/vfork.S
index 79d7899..24ede3d 100644
--- a/libc/arch-x86/bionic/vfork.S
+++ b/libc/arch-x86/bionic/vfork.S
@@ -27,6 +27,7 @@
*/
#include <private/bionic_asm.h>
+#include <private/bionic_asm_tls.h>
// This custom code preserves the return address across the system call.
@@ -38,7 +39,7 @@
// __get_tls()[TLS_SLOT_THREAD_ID]->cached_pid_ = 0
movl %gs:0, %eax
- movl 4(%eax), %eax
+ movl (TLS_SLOT_THREAD_ID * 4)(%eax), %eax
movl $0, 12(%eax)
movl $__NR_vfork, %eax
diff --git a/libc/arch-x86_64/bionic/vfork.S b/libc/arch-x86_64/bionic/vfork.S
index ce96a8c..e32b517 100644
--- a/libc/arch-x86_64/bionic/vfork.S
+++ b/libc/arch-x86_64/bionic/vfork.S
@@ -27,6 +27,7 @@
*/
#include <private/bionic_asm.h>
+#include <private/bionic_asm_tls.h>
// This custom code preserves the return address across the system call.
@@ -36,7 +37,7 @@
// __get_tls()[TLS_SLOT_THREAD_ID]->cached_pid_ = 0
mov %fs:0, %rax
- mov 8(%rax), %rax
+ mov (TLS_SLOT_THREAD_ID * 8)(%rax), %rax
movl $0, 20(%rax)
movl $__NR_vfork, %eax