x86: Add TLS_TRANSITION_IE_TO_LE_P
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 6 Oct 2017 07:11:41 +0000 (00:11 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 6 Oct 2017 07:13:52 +0000 (00:13 -0700)
Add TLS_TRANSITION_IE_TO_LE_P which returns TRUE if TLS IE->LE transition
is OK.

* elfxx-x86.h (TLS_TRANSITION_IE_TO_LE_P): New.
* elf32-i386.c (elf_i386_tls_transition): Use it.
* elf64-x86-64.c (elf_x86_64_tls_transition): Likewise.

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elfxx-x86.h

index 39232290154724827a275881af46a4f2dffd3421..9f267a2c9670d5699916f2eb3796363c448ad96f 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elfxx-x86.h (TLS_TRANSITION_IE_TO_LE_P): New.
+       * elf32-i386.c (elf_i386_tls_transition): Use it.
+       * elf64-x86-64.c (elf_x86_64_tls_transition): Likewise.
+
 2017-10-05  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-ppc.c (readonly_dynrelocs): Add a link_info argument.
index d4adaf48dee83e4ef56d6e457118b42c3d359da0..c4af6b2e02b9bb1de14b5789e1a0b99b0d1a35c6 100644 (file)
@@ -1105,10 +1105,7 @@ elf_i386_tls_transition (struct bfd_link_info *info, bfd *abfd,
        {
          unsigned int new_to_type = to_type;
 
-         if (bfd_link_executable (info)
-             && h != NULL
-             && h->dynindx == -1
-             && (tls_type & GOT_TLS_IE))
+         if (TLS_TRANSITION_IE_TO_LE_P (info, h, tls_type))
            new_to_type = R_386_TLS_LE_32;
 
          if (to_type == R_386_TLS_GD
index 76343cab7bfc1b16287466b39790ab9eba378d24..1bad4d2dff686edecb7adcf9e2aa9177dac1e6da 100644 (file)
@@ -1281,10 +1281,7 @@ elf_x86_64_tls_transition (struct bfd_link_info *info, bfd *abfd,
        {
          unsigned int new_to_type = to_type;
 
-         if (bfd_link_executable (info)
-             && h != NULL
-             && h->dynindx == -1
-             && tls_type == GOT_TLS_IE)
+         if (TLS_TRANSITION_IE_TO_LE_P (info, h, tls_type))
            new_to_type = R_X86_64_TPOFF32;
 
          if (to_type == R_X86_64_TLSGD
index 17aa10cd5606b4ac916046af851867c096cbeb1a..0525c9c0a2efe689b88b41427e22964a8aa9f6ac 100644 (file)
    && ((EH)->elf.root.u.def.section->owner->flags & DYNAMIC) != 0 \
    && ((EH)->elf.root.u.def.section->flags & SEC_CODE) == 0)
 
+/* TRUE if TLS IE->LE transition is OK.  */
+#define TLS_TRANSITION_IE_TO_LE_P(INFO, H, TLS_TYPE) \
+  (bfd_link_executable (INFO) \
+   && (H) != NULL \
+   && (H)->dynindx == -1 \
+   && (TLS_TYPE & GOT_TLS_IE))
+
 /* x86 ELF linker hash entry.  */
 
 struct elf_x86_link_hash_entry