OSDN Git Service

Set x86 TLS limit to 0xfffff, not PAGE_SIZE.
authorElliott Hughes <enh@google.com>
Wed, 10 Feb 2016 06:44:16 +0000 (22:44 -0800)
committerElliott Hughes <enh@google.com>
Wed, 10 Feb 2016 06:44:16 +0000 (22:44 -0800)
Not least because we set limit_in_pages to 1. PAGE_SIZE pages was never
anyone's intention.

Change-Id: Ide867f44a2fb20d4d5d0cd67ced468e8665a0193

libc/Android.mk
libc/arch-x86/bionic/__set_tls.cpp [moved from libc/arch-x86/bionic/__set_tls.c with 92% similarity]
libc/bionic/pthread_create.cpp

index ee352eb..42f717e 100644 (file)
@@ -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
similarity index 92%
rename from libc/arch-x86/bionic/__set_tls.c
rename to libc/arch-x86/bionic/__set_tls.cpp
index 38ed3c9..b26fd56 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <asm/ldt.h>
 
-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<uintptr_t>(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);
 
index 34826db..08d9bed 100644 (file)
@@ -46,7 +46,7 @@
 // x86 uses segment descriptors rather than a direct pointer to TLS.
 #if __i386__
 #include <asm/ldt.h>
-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;