*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / elf32-i386.c
index 4e9d492ed75c760837dc79e5e3b5b2913407e281..97054a5ae18ad904ce5a90a63063d4c3e8fc56e9 100644 (file)
@@ -582,10 +582,6 @@ struct elf_i386_link_hash_entry
 #define GOT_TLS_IE_NEG 6
 #define GOT_TLS_IE_BOTH 7
 #define GOT_TLS_GDESC  8
-#define GOT_TLS_MASK   0x0f
-#define GOT_TLS_IE_IE  0x10
-#define GOT_TLS_IE_GD  0x20
-#define GOT_TLS_IE_MASK        0x30
 #define GOT_TLS_GD_BOTH_P(type)                                                \
   ((type) == (GOT_TLS_GD | GOT_TLS_GDESC))
 #define GOT_TLS_GD_P(type)                                             \
@@ -1014,25 +1010,12 @@ elf_i386_check_relocs (bfd *abfd,
              case R_386_TLS_IE_32:
                if (ELF32_R_TYPE (rel->r_info) == r_type)
                  tls_type = GOT_TLS_IE_NEG;
-               else if (h
-                        && ELF32_R_TYPE (rel->r_info) == R_386_TLS_GD)
-                 /* If this is a GD->IE transition, we may use either
-                    of R_386_TLS_TPOFF and R_386_TLS_TPOFF32.  But if
-                    we may have both R_386_TLS_IE and R_386_TLS_GD,
-                    we can't share the same R_386_TLS_TPOFF since
-                    they require different offsets. So we remember
-                    it comes from R_386_TLS_GD.  */
-                 tls_type = GOT_TLS_IE | GOT_TLS_IE_GD;
                else
+                 /* If this is a GD->IE transition, we may use either of
+                    R_386_TLS_TPOFF and R_386_TLS_TPOFF32.  */
                  tls_type = GOT_TLS_IE;
                break;
              case R_386_TLS_IE:
-               if (h)
-                 {
-                   /* We remember it comes from R_386_TLS_IE.  */
-                   tls_type = GOT_TLS_IE_POS | GOT_TLS_IE_IE;
-                   break;
-                 }
              case R_386_TLS_GOTIE:
                tls_type = GOT_TLS_IE_POS; break;
              }
@@ -1072,8 +1055,7 @@ elf_i386_check_relocs (bfd *abfd,
              tls_type |= old_tls_type;
            /* If a TLS symbol is accessed using IE at least once,
               there is no point to use dynamic model for it.  */
-           else if (old_tls_type != tls_type
-                    && old_tls_type != GOT_UNKNOWN
+           else if (old_tls_type != tls_type && old_tls_type != GOT_UNKNOWN
                     && (! GOT_TLS_GD_ANY_P (old_tls_type)
                         || (tls_type & GOT_TLS_IE) == 0))
              {
@@ -1168,7 +1150,7 @@ elf_i386_check_relocs (bfd *abfd,
               && (sec->flags & SEC_ALLOC) != 0
               && (r_type != R_386_PC32
                   || (h != NULL
-                      && (! info->symbolic
+                      && (! SYMBOLIC_BIND (info, h)
                           || h->root.type == bfd_link_hash_defweak
                           || !h->def_regular))))
              || (ELIMINATE_COPY_RELOCS
@@ -1195,7 +1177,7 @@ elf_i386_check_relocs (bfd *abfd,
                  if (name == NULL)
                    return FALSE;
 
-                 if (strncmp (name, ".rel", 4) != 0
+                 if (! CONST_STRNEQ (name, ".rel")
                      || strcmp (bfd_get_section_name (abfd, sec),
                                 name + 4) != 0)
                    {
@@ -1297,38 +1279,20 @@ elf_i386_check_relocs (bfd *abfd,
 
 static asection *
 elf_i386_gc_mark_hook (asection *sec,
-                      struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                      struct bfd_link_info *info,
                       Elf_Internal_Rela *rel,
                       struct elf_link_hash_entry *h,
                       Elf_Internal_Sym *sym)
 {
   if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-       {
-       case R_386_GNU_VTINHERIT:
-       case R_386_GNU_VTENTRY:
-         break;
-
-       default:
-         switch (h->root.type)
-           {
-           case bfd_link_hash_defined:
-           case bfd_link_hash_defweak:
-             return h->root.u.def.section;
-
-           case bfd_link_hash_common:
-             return h->root.u.c.p->section;
-
-           default:
-             break;
-           }
-       }
-    }
-  else
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-
-  return NULL;
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_386_GNU_VTINHERIT:
+      case R_386_GNU_VTENTRY:
+       return NULL;
+      }
+
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
@@ -1703,14 +1667,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       asection *s;
       bfd_boolean dyn;
       int tls_type = elf_i386_hash_entry(h)->tls_type;
-      
-      /* If we have both R_386_TLS_IE and R_386_TLS_GD, GOT_TLS_IE_BOTH
-        should be used.  */
-      if ((tls_type & GOT_TLS_IE_MASK)
-         == (GOT_TLS_IE_IE | GOT_TLS_IE_GD))
-       tls_type = GOT_TLS_IE_BOTH;
-      else
-       tls_type &= GOT_TLS_MASK;
 
       /* Make sure this symbol is output as a dynamic symbol.
         Undefined weak syms won't yet be marked as dynamic.  */
@@ -2055,7 +2011,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
          if (htab->elf.hplt != NULL)
            strip_section = FALSE;
        }
-      else if (strncmp (bfd_get_section_name (dynobj, s), ".rel", 4) == 0)
+      else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rel"))
        {
          if (s->size != 0 && s != htab->srelplt && s != htab->srelplt2)
            relocs = TRUE;
@@ -2655,7 +2611,7 @@ elf_i386_relocate_section (bfd *output_bfd,
                       && h->dynindx != -1
                       && (r_type == R_386_PC32
                           || !info->shared
-                          || !info->symbolic
+                          || !SYMBOLIC_BIND (info, h)
                           || !h->def_regular))
                outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
              else
@@ -2714,13 +2670,6 @@ elf_i386_relocate_section (bfd *output_bfd,
          else if (h != NULL)
            {
              tls_type = elf_i386_hash_entry(h)->tls_type;
-             /* If we have both R_386_TLS_IE and R_386_TLS_GD,
-                GOT_TLS_IE_BOTH should be used.  */
-             if ((tls_type & GOT_TLS_IE_MASK)
-                 == (GOT_TLS_IE_IE | GOT_TLS_IE_GD))
-               tls_type = GOT_TLS_IE_BOTH;
-             else
-               tls_type &= GOT_TLS_MASK;
              if (!info->shared && h->dynindx == -1 && (tls_type & GOT_TLS_IE))
                r_type = R_386_TLS_LE_32;
            }
@@ -2854,8 +2803,9 @@ elf_i386_relocate_section (bfd *output_bfd,
                  val = bfd_get_8 (input_bfd, contents + roff + 1);
                  BFD_ASSERT (val == 0x10);
 
-                 /* Now modify the instruction as appropriate.  */
-                 bfd_put_8 (output_bfd, 0x90, contents + roff);
+                 /* Now modify the instruction as appropriate.  Use
+                    xchg %ax,%ax instead of 2 nops.  */
+                 bfd_put_8 (output_bfd, 0x66, contents + roff);
                  bfd_put_8 (output_bfd, 0x90, contents + roff + 1);
                  continue;
                }
@@ -3175,12 +3125,8 @@ elf_i386_relocate_section (bfd *output_bfd,
                 subl $foo@gottpoff(%reg), %eax
                 into:
                 addl $foo@gotntpoff(%reg), %eax.  */
-             if (r_type == R_386_TLS_GOTIE)
-               {
-                 contents[roff + 6] = 0x03;
-                 if (tls_type == GOT_TLS_IE_BOTH)
-                   off += 4;
-               }
+             if (tls_type == GOT_TLS_IE_POS)
+               contents[roff + 6] = 0x03;
              bfd_put_32 (output_bfd,
                          htab->sgot->output_section->vma
                          + htab->sgot->output_offset + off
@@ -3264,8 +3210,8 @@ elf_i386_relocate_section (bfd *output_bfd,
              /* Now modify the instruction as appropriate.  */
              if (tls_type != GOT_TLS_IE_NEG)
                {
-                 /* nop; nop */
-                 bfd_put_8 (output_bfd, 0x90, contents + roff);
+                 /* xchg %ax,%ax */
+                 bfd_put_8 (output_bfd, 0x66, contents + roff);
                  bfd_put_8 (output_bfd, 0x90, contents + roff + 1);
                }
              else
@@ -3875,6 +3821,18 @@ elf_i386_plt_sym_val (bfd_vma i, const asection *plt,
   return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
 }
 
+/* Return TRUE if symbol should be hashed in the `.gnu.hash' section.  */
+
+static bfd_boolean
+elf_i386_hash_symbol (struct elf_link_hash_entry *h)
+{
+  if (h->plt.offset != (bfd_vma) -1
+      && !h->def_regular
+      && !h->pointer_equality_needed)
+    return FALSE;
+
+  return _bfd_elf_hash_symbol (h);
+}
 
 #define TARGET_LITTLE_SYM              bfd_elf32_i386_vec
 #define TARGET_LITTLE_NAME             "elf32-i386"
@@ -3914,7 +3872,10 @@ elf_i386_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_relocate_section         elf_i386_relocate_section
 #define elf_backend_size_dynamic_sections     elf_i386_size_dynamic_sections
 #define elf_backend_always_size_sections      elf_i386_always_size_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_plt_sym_val                      elf_i386_plt_sym_val
+#define elf_backend_hash_symbol                      elf_i386_hash_symbol
 
 #include "elf32-target.h"
 
This page took 0.029964 seconds and 4 git commands to generate.