From 01b85d5df3744449471b327d7afd6c1d5854bd11 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 9 Feb 2016 22:44:16 -0800 Subject: [PATCH] Set x86 TLS limit to 0xfffff, not PAGE_SIZE. Not least because we set limit_in_pages to 1. PAGE_SIZE pages was never anyone's intention. Change-Id: Ide867f44a2fb20d4d5d0cd67ced468e8665a0193 --- libc/Android.mk | 2 +- libc/arch-x86/bionic/{__set_tls.c => __set_tls.cpp} | 8 ++++---- libc/bionic/pthread_create.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename libc/arch-x86/bionic/{__set_tls.c => __set_tls.cpp} (92%) diff --git a/libc/Android.mk b/libc/Android.mk index ee352eb04..42f717eaf 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -675,7 +675,7 @@ LOCAL_SRC_FILES := \ bionic/__stack_chk_fail.cpp \ LOCAL_SRC_FILES_arm64 := arch-arm64/bionic/__set_tls.c -LOCAL_SRC_FILES_x86 := arch-x86/bionic/__set_tls.c +LOCAL_SRC_FILES_x86 := arch-x86/bionic/__set_tls.cpp LOCAL_SRC_FILES_x86_64 := arch-x86_64/bionic/__set_tls.c LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector diff --git a/libc/arch-x86/bionic/__set_tls.c b/libc/arch-x86/bionic/__set_tls.cpp similarity index 92% rename from libc/arch-x86/bionic/__set_tls.c rename to libc/arch-x86/bionic/__set_tls.cpp index 38ed3c9cf..b26fd564f 100644 --- a/libc/arch-x86/bionic/__set_tls.c +++ b/libc/arch-x86/bionic/__set_tls.cpp @@ -32,7 +32,7 @@ #include -extern int __set_thread_area(struct user_desc*); +extern "C" int __set_thread_area(struct user_desc*); __LIBC_HIDDEN__ void __init_user_desc(struct user_desc* result, bool allocate, void* base_addr) { if (allocate) { @@ -45,9 +45,9 @@ __LIBC_HIDDEN__ void __init_user_desc(struct user_desc* result, bool allocate, v result->entry_number = (gs & 0xffff) >> 3; } - result->base_addr = (uintptr_t) base_addr; + result->base_addr = reinterpret_cast(base_addr); - result->limit = PAGE_SIZE; + result->limit = 0xfffff; result->seg_32bit = 1; result->contents = MODIFY_LDT_CONTENTS_DATA; @@ -57,7 +57,7 @@ __LIBC_HIDDEN__ void __init_user_desc(struct user_desc* result, bool allocate, v result->useable = 1; } -__LIBC_HIDDEN__ int __set_tls(void* ptr) { +extern "C" __LIBC_HIDDEN__ int __set_tls(void* ptr) { struct user_desc tls_descriptor; __init_user_desc(&tls_descriptor, true, ptr); diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp index 34826dba6..08d9bed9e 100644 --- a/libc/bionic/pthread_create.cpp +++ b/libc/bionic/pthread_create.cpp @@ -46,7 +46,7 @@ // x86 uses segment descriptors rather than a direct pointer to TLS. #if __i386__ #include -extern "C" __LIBC_HIDDEN__ void __init_user_desc(struct user_desc*, int, void*); +void __init_user_desc(struct user_desc*, bool, void*); #endif extern "C" int __isthreaded;