* gdb.arch/i386-sse.exp, gdb.arch/i386-sse.c: New tests.
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index 360d8590d01f7daa45d8d12dcc7def832a7a727a..f9eb7db643435b315a58eb5a2963544676b7e09f 100644 (file)
@@ -561,7 +561,8 @@ elf64_x86_64_copy_indirect_symbol (const struct elf_backend_data *bed,
       (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
                                   | ELF_LINK_HASH_REF_REGULAR
                                   | ELF_LINK_HASH_REF_REGULAR_NONWEAK
-                                  | ELF_LINK_HASH_NEEDS_PLT));
+                                  | ELF_LINK_HASH_NEEDS_PLT
+                                  | ELF_LINK_POINTER_EQUALITY_NEEDED));
   else
     _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
 }
@@ -812,6 +813,8 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
              /* We may need a .plt entry if the function this reloc
                 refers to is in a shared lib.  */
              h->plt.refcount += 1;
+             if (r_type != R_X86_64_PC32)
+               h->elf_link_hash_flags |= ELF_LINK_POINTER_EQUALITY_NEEDED;
            }
 
          /* If we are creating a shared library, and this is a reloc
@@ -1908,9 +1911,11 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
          if (off >= (bfd_vma) -2)
            abort ();
 
-         relocation = htab->sgot->output_offset + off;
-         if (r_type == R_X86_64_GOTPCREL)
-           relocation += htab->sgot->output_section->vma;
+         relocation = htab->sgot->output_section->vma
+                      + htab->sgot->output_offset + off;
+         if (r_type != R_X86_64_GOTPCREL)
+           relocation -= htab->sgotplt->output_section->vma
+                         - htab->sgotplt->output_offset;
 
          break;
 
@@ -2519,11 +2524,16 @@ elf64_x86_64_finish_dynamic_symbol (bfd *output_bfd,
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
        {
          /* Mark the symbol as undefined, rather than as defined in
-            the .plt section.  Leave the value alone.  This is a clue
+            the .plt section.  Leave the value if there were any
+            relocations where pointer equality matters (this is a clue
             for the dynamic linker, to make function pointer
             comparisons work between an application and shared
-            library.  */
+            library), otherwise set it to zero.  If a function is only
+            called from a binary, there is no need to slow down
+            shared libraries because of that.  */
          sym->st_shndx = SHN_UNDEF;
+         if ((h->elf_link_hash_flags & ELF_LINK_POINTER_EQUALITY_NEEDED) == 0)
+           sym->st_value = 0;
        }
     }
 
@@ -2656,7 +2666,8 @@ elf64_x86_64_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *inf
              continue;
 
            case DT_PLTGOT:
-             dyn.d_un.d_ptr = htab->sgot->output_section->vma;
+             s = htab->sgotplt;
+             dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              break;
 
            case DT_JMPREL:
@@ -2747,6 +2758,10 @@ elf64_x86_64_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *inf
        GOT_ENTRY_SIZE;
     }
 
+  if (htab->sgot && htab->sgot->_raw_size > 0)
+    elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize
+      = GOT_ENTRY_SIZE;
+
   return TRUE;
 }
 
This page took 0.024832 seconds and 4 git commands to generate.