* elf32-frv.c (_frvfdpic_check_discarded_relocs): New.
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index b6c973f6dbc8bff6acabd1fc49b8cc4c6f9bd0c9..236079ad22cb6ee852c5c70bc2ce1749ae941ba5 100644 (file)
@@ -1,5 +1,5 @@
 /* X86-64 specific support for 64-bit ELF
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
    Contributed by Jan Hubicka <jh@suse.cz>.
 
@@ -19,8 +19,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
@@ -246,6 +246,23 @@ elf64_x86_64_reloc_type_lookup (bfd *abfd,
   return 0;
 }
 
+static reloc_howto_type *
+elf64_x86_64_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                               const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < (sizeof (x86_64_elf_howto_table)
+           / sizeof (x86_64_elf_howto_table[0]));
+       i++)
+    if (x86_64_elf_howto_table[i].name != NULL
+       && strcasecmp (x86_64_elf_howto_table[i].name, r_name) == 0)
+      return &x86_64_elf_howto_table[i];
+
+  return NULL;
+}
+
 /* Given an x86_64 ELF reloc type, fill in an arelent structure.  */
 
 static void
@@ -2062,9 +2079,6 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
 
-  if (info->relocatable)
-    return TRUE;
-
   htab = elf64_x86_64_hash_table (info);
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -2120,6 +2134,21 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                                   h, sec, relocation,
                                   unresolved_reloc, warned);
        }
+
+      if (sec != NULL && elf_discarded_section (sec))
+       {
+         /* For relocs against symbols from removed linkonce sections,
+            or sections discarded by a linker script, we just want the
+            section contents zeroed.  Avoid any special processing.  */
+         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
+         rel->r_info = 0;
+         rel->r_addend = 0;
+         continue;
+       }
+
+      if (info->relocatable)
+       continue;
+
       /* When generating a shared object, the relocations handled here are
         copied into the output file to be resolved at run time.  */
       switch (r_type)
@@ -2367,15 +2396,6 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
          /* FIXME: The ABI says the linker should make sure the value is
             the same when it's zeroextended to 64 bit.  */
 
-         /* r_symndx will be zero only for relocs against symbols
-            from removed linkonce sections, or sections discarded by
-            a linker script.  */
-         if (r_symndx == 0)
-           {
-             _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-             break;
-           }
-
          if ((input_section->flags & SEC_ALLOC) == 0)
            break;
 
@@ -3657,6 +3677,8 @@ static const struct bfd_elf_special_section
 #define bfd_elf64_bfd_link_hash_table_create \
   elf64_x86_64_link_hash_table_create
 #define bfd_elf64_bfd_reloc_type_lookup            elf64_x86_64_reloc_type_lookup
+#define bfd_elf64_bfd_reloc_name_lookup \
+  elf64_x86_64_reloc_name_lookup
 
 #define elf_backend_adjust_dynamic_symbol   elf64_x86_64_adjust_dynamic_symbol
 #define elf_backend_check_relocs           elf64_x86_64_check_relocs
@@ -3710,24 +3732,11 @@ static const struct bfd_elf_special_section
 #undef  TARGET_LITTLE_NAME
 #define TARGET_LITTLE_NAME                 "elf64-x86-64-freebsd"
 
-/* The kernel recognizes executables as valid only if they carry a
-   "FreeBSD" label in the ELF header.  So we put this label on all
-   executables and (for simplicity) also all other object files.  */
-
-static void
-elf64_x86_64_fbsd_post_process_headers (bfd * abfd,
-                                       struct bfd_link_info * link_info ATTRIBUTE_UNUSED)
-{
-  Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form.  */
-
-  i_ehdrp = elf_elfheader (abfd);
-
-  /* Put an ABI label supported by FreeBSD >= 4.1.  */
-  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
-}
+#undef ELF_OSABI
+#define        ELF_OSABI                           ELFOSABI_FREEBSD
 
 #undef  elf_backend_post_process_headers
-#define elf_backend_post_process_headers  elf64_x86_64_fbsd_post_process_headers
+#define elf_backend_post_process_headers  _bfd_elf_set_osabi
 
 #undef  elf64_bed
 #define elf64_bed elf64_x86_64_fbsd_bed
This page took 0.031018 seconds and 4 git commands to generate.