Merge "Clean up bionic_macros.h a bit." am: 04164f6d05 am: 95cf20133f
am: 9a1223b986

Change-Id: I2c001dac019e4fa86dc92eec3ce6883f84219ad1
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index 65ec5ff..b68cb94 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -112,10 +112,6 @@
 
   thread_local_dtor* thread_local_dtors;
 
-  void* tls[BIONIC_TLS_SLOTS];
-
-  pthread_key_data_t key_data[BIONIC_PTHREAD_KEY_COUNT];
-
   /*
    * The dynamic linker implements dlerror(3), which makes it hard for us to implement this
    * per-thread buffer by simply using malloc(3) and free(3).
@@ -124,6 +120,12 @@
   char dlerror_buffer[__BIONIC_DLERROR_BUFFER_SIZE];
 
   bionic_tls* bionic_tls;
+
+  pthread_key_data_t key_data[BIONIC_PTHREAD_KEY_COUNT];
+
+  // The thread pointer (__get_tls()) points at this field. This field must come last so that
+  // an executable's TLS segment can be allocated at a fixed offset after the thread pointer.
+  void* tls[BIONIC_TLS_SLOTS];
 };
 
 __LIBC_HIDDEN__ int __init_thread(pthread_internal_t* thread);