Skip to content

Commit

Permalink
i#1569 AArch64: Implement thread-local storage.
Browse files Browse the repository at this point in the history
In tls_linux_aarchxx.c, used for both ARM (AArch32) and AArch64.

Review-URL: https://codereview.appspot.com/287680043
  • Loading branch information
egrimley-arm committed Apr 12, 2016
1 parent cf47e55 commit f44cd91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 76 deletions.
6 changes: 5 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ if (UNIX)
set(OS_SRCS ${OS_SRCS} unix/memcache.c)
set(OS_SRCS ${OS_SRCS} unix/module_elf.c)
set(OS_SRCS ${OS_SRCS} unix/ksynch_linux.c)
set(OS_SRCS ${OS_SRCS} unix/tls_linux_${ARCH_NAME}.c)
if (ARM OR AARCH64)
set(OS_SRCS ${OS_SRCS} unix/tls_linux_aarchxx.c)
else ()
set(OS_SRCS ${OS_SRCS} unix/tls_linux_${ARCH_NAME}.c)
endif ()
set(OS_SRCS ${OS_SRCS} unix/signal_linux.c)
set(OS_SRCS ${OS_SRCS} unix/signal_linux_${ARCH_NAME}.c)
set(OS_SRCS ${OS_SRCS} unix/native_elf.c)
Expand Down
70 changes: 0 additions & 70 deletions core/unix/tls_linux_aarch64.c

This file was deleted.

17 changes: 12 additions & 5 deletions core/unix/tls_linux_arm.c → core/unix/tls_linux_aarchxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@
*/

/*
* tls_linux_arm.c - TLS support on ARM
* tls_linux_arm.c - thread-local storage for arm and arm64 Linux
*/

#include <stddef.h> /* offsetof */
#include "../globals.h"
#include "tls.h"
#include "include/syscall.h"
#ifndef AARCH64
# include "include/syscall.h"
#endif

#ifndef LINUX
# error Linux-only
#endif

#ifndef ARM
# error ARM-only
#if !(defined(ARM) || defined(AARCH64))
# error ARM/AArch64-only
#endif

#ifndef CLIENT_INTERFACE
# error CLIENT_INTERFACE build only for TLS mangling on ARM
# error CLIENT_INTERFACE build only for TLS mangling on ARM/AArch64
#endif

byte **
Expand All @@ -67,7 +69,12 @@ tls_thread_init(os_local_state_t *os_tls, byte *segment)
LOG(GLOBAL, LOG_THREADS, 2,
"tls_thread_init: cur priv lib tls base is "PFX"\n",
os_tls->os_seg_info.priv_lib_tls_base);
#ifdef AARCH64
asm volatile("msr tpidr_el0, %0" : :
"r"(os_tls->os_seg_info.priv_lib_tls_base));
#else
dynamorio_syscall(SYS_set_tls, 1, os_tls->os_seg_info.priv_lib_tls_base);
#endif
ASSERT(get_segment_base(TLS_REG_LIB) == os_tls->os_seg_info.priv_lib_tls_base);
ASSERT(*get_dr_tls_base_addr() == NULL);
*get_dr_tls_base_addr() = segment;
Expand Down

0 comments on commit f44cd91

Please sign in to comment.