]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
i386: Change offset of __private_ss to 0x30 [BZ #23250]
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 12 Jun 2018 13:23:28 +0000 (06:23 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 12 Jun 2018 13:34:48 +0000 (06:34 -0700)
sysdeps/i386/nptl/tls.h has

typedef struct
{
  void *tcb;            /* Pointer to the TCB.  Not necessarily the
                           thread descriptor used by libpthread.  */
  dtv_t *dtv;
  void *self;           /* Pointer to the thread descriptor.  */
  int multiple_threads;
  uintptr_t sysinfo;
  uintptr_t stack_guard;
  uintptr_t pointer_guard;
  int gscope_flag;
  int __glibc_reserved1;
  /* Reservation of some values for the TM ABI.  */
  void *__private_tm[4];
  /* GCC split stack support.  */
  void *__private_ss;
} tcbhead_t;

The offset of __private_ss is 0x34.  But GCC defines

/* We steal the last transactional memory word.  */
 #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30

and libgcc/config/i386/morestack.S has

cmpl %gs:0x30,%eax # See if we have enough space.
movl %eax,%gs:0x30 # Save the new stack boundary.
movl %eax,%gs:0x30 # Save the new stack boundary.
movl %ecx,%gs:0x30 # Save new stack boundary.
movl %eax,%gs:0x30
movl %gs:0x30,%eax
movl %eax,%gs:0x30

Since update TARGET_THREAD_SPLIT_STACK_OFFSET changes split stack ABI,
this patch updates tcbhead_t to match GCC.

[BZ #23250]
[BZ #10686]
* sysdeps/i386/nptl/tls.h (tcbhead_t): Change __private_tm[4]
to _private_tm[3] and add __glibc_reserved2.
Add _Static_assert of offset of __private_ss == 0x30.
* sysdeps/x86_64/nptl/tls.h: Add _Static_assert of offset of
__private_ss == 0x40 for ILP32 and == 0x70 for LP64.

ChangeLog
sysdeps/i386/nptl/tls.h
sysdeps/x86_64/nptl/tls.h

index c1b9cdfd29d005672a757a167314d7d7066d1a70..c1ff22b1912ce8c17dde976d97a3738f86ab1c2a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-06-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+       [BZ #23250]
+       [BZ #10686]
+       * sysdeps/i386/nptl/tls.h (tcbhead_t): Change __private_tm[4]
+       to _private_tm[3] and add __glibc_reserved2.
+       Add _Static_assert of offset of __private_ss == 0x30.
+       * sysdeps/x86_64/nptl/tls.h: Add _Static_assert of offset of
+       __private_ss == 0x40 for ILP32 and == 0x70 for LP64.
+
 2018-06-12  Florian Weimer  <fweimer@redhat.com>
 
        x86: Make strncmp usable from rtld.
index 6c36e58e9c654d71f4d329b6813d5ece9efc2b43..afb71ce4310d8aa78b9c70ae799d262b3c73462b 100644 (file)
@@ -43,11 +43,16 @@ typedef struct
   int gscope_flag;
   int __glibc_reserved1;
   /* Reservation of some values for the TM ABI.  */
-  void *__private_tm[4];
+  void *__private_tm[3];
   /* GCC split stack support.  */
   void *__private_ss;
+  void *__glibc_reserved2;
 } tcbhead_t;
 
+/* morestack.S in libgcc uses offset 0x30 to access __private_ss,   */
+_Static_assert (offsetof (tcbhead_t, __private_ss) == 0x30,
+               "offset of __private_ss != 0x30");
+
 # define TLS_MULTIPLE_THREADS_IN_TCB 1
 
 #else /* __ASSEMBLER__ */
index 6da1c04a985b8057aa6f479e9824078946f82328..65c0051dcf245c24b1030ba1cbc6b030b2ead2a6 100644 (file)
@@ -65,6 +65,16 @@ typedef struct
   void *__padding[8];
 } tcbhead_t;
 
+# ifdef __ILP32__
+/* morestack.S in libgcc uses offset 0x40 to access __private_ss,   */
+_Static_assert (offsetof (tcbhead_t, __private_ss) == 0x40,
+               "offset of __private_ss != 0x40");
+# else
+/* morestack.S in libgcc uses offset 0x70 to access __private_ss,   */
+_Static_assert (offsetof (tcbhead_t, __private_ss) == 0x70,
+               "offset of __private_ss != 0x70");
+# endif
+
 #else /* __ASSEMBLER__ */
 # include <tcb-offsets.h>
 #endif