* elf-bfd.h (struct elf_size_info): Add swap_symbol_in field.
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index a82b99c137ac4ec0a668e01a1053b44ec5889a2d..0ec6392dffa08dbededbfaf8015b581136a06b52 100644 (file)
@@ -125,6 +125,10 @@ static reloc_howto_type *elf64_x86_64_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void elf64_x86_64_info_to_howto
   PARAMS ((bfd *, arelent *, Elf64_Internal_Rela *));
+static boolean elf64_x86_64_grok_prstatus
+  PARAMS ((bfd *, Elf_Internal_Note *));
+static boolean elf64_x86_64_grok_psinfo
+  PARAMS ((bfd *, Elf_Internal_Note *));
 static struct bfd_link_hash_table *elf64_x86_64_link_hash_table_create
   PARAMS ((bfd *));
 static boolean elf64_x86_64_elf_object_p PARAMS ((bfd *abfd));
@@ -208,6 +212,73 @@ elf64_x86_64_info_to_howto (abfd, cache_ptr, dst)
   BFD_ASSERT (r_type == cache_ptr->howto->type);
 }
 \f
+/* Support for core dump NOTE sections.  */
+static boolean
+elf64_x86_64_grok_prstatus (abfd, note)
+     bfd *abfd;
+     Elf_Internal_Note *note;
+{
+  int offset;
+  size_t raw_size;
+
+  switch (note->descsz)
+    {
+      default:
+       return false;
+
+      case 336:                /* sizeof(istruct elf_prstatus) on Linux/x86_64 */
+       /* pr_cursig */
+       elf_tdata (abfd)->core_signal
+         = bfd_get_16 (abfd, note->descdata + 12);
+
+       /* pr_pid */
+       elf_tdata (abfd)->core_pid
+         = bfd_get_32 (abfd, note->descdata + 32);
+
+       /* pr_reg */
+       offset = 112;
+       raw_size = 216;
+
+       break;
+    }
+
+  /* Make a ".reg/999" section.  */
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+                                         raw_size, note->descpos + offset);
+}
+
+static boolean
+elf64_x86_64_grok_psinfo (abfd, note)
+     bfd *abfd;
+     Elf_Internal_Note *note;
+{
+  switch (note->descsz)
+    {
+      default:
+       return false;
+
+      case 136:                /* sizeof(struct elf_prpsinfo) on Linux/x86_64 */
+       elf_tdata (abfd)->core_program
+        = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
+       elf_tdata (abfd)->core_command
+        = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
+    }
+
+  /* Note that for some reason, a spurious space is tacked
+     onto the end of the args in some (at least one anyway)
+     implementations, so strip it off if it exists.  */
+
+  {
+    char *command = elf_tdata (abfd)->core_command;
+    int n = strlen (command);
+
+    if (0 < n && command[n - 1] == ' ')
+      command[n - 1] = '\0';
+  }
+
+  return true;
+}
+\f
 /* Functions for the x86-64 ELF linker.         */
 
 /* The name of the dynamic interpreter.         This is put in the .interp
@@ -246,7 +317,7 @@ static const bfd_byte elf64_x86_64_plt_entry[PLT_ENTRY_SIZE] =
 };
 
 /* The x86-64 linker needs to keep track of the number of relocs that
-   decides to copy as dynamic relocs in check_relocs for each symbol.
+   it decides to copy as dynamic relocs in check_relocs for each symbol.
    This is so that it can later discard them if they are found to be
    unnecessary.  We store the information in a field extending the
    regular ELF linker hash table.  */
@@ -340,13 +411,13 @@ elf64_x86_64_link_hash_table_create (abfd)
   struct elf64_x86_64_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf64_x86_64_link_hash_table);
 
-  ret = (struct elf64_x86_64_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf64_x86_64_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1016,7 +1087,7 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
 
   /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker
      to copy the initial value out of the dynamic object and into the
-     runtime process image. */
+     runtime process image.  */
   if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
     {
       htab->srelbss->_raw_size += sizeof (Elf64_External_Rela);
@@ -1494,6 +1565,9 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
 
+  if (info->relocateable)
+    return true;
+
   htab = elf64_x86_64_hash_table (info);
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -1524,30 +1598,9 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
          bfd_set_error (bfd_error_bad_value);
          return false;
        }
-      howto = x86_64_elf_howto_table + r_type;
 
+      howto = x86_64_elf_howto_table + r_type;
       r_symndx = ELF64_R_SYM (rel->r_info);
-
-      if (info->relocateable)
-       {
-         /* This is a relocateable link.  We don't have to change
-            anything, unless the reloc is against a section symbol,
-            in which case we have to adjust according to where the
-            section symbol winds up in the output section.  */
-         if (r_symndx < symtab_hdr->sh_info)
-           {
-             sym = local_syms + r_symndx;
-             if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
-               {
-                 sec = local_sections[r_symndx];
-                 rel->r_addend += sec->output_offset + sym->st_value;
-               }
-           }
-
-         continue;
-       }
-
-      /* This is a final link. */
       h = NULL;
       sym = NULL;
       sec = NULL;
@@ -2230,6 +2283,7 @@ elf64_x86_64_finish_dynamic_sections (output_bfd, info)
 #define elf_backend_want_plt_sym           0
 #define elf_backend_got_header_size        (GOT_ENTRY_SIZE*3)
 #define elf_backend_plt_header_size        PLT_ENTRY_SIZE
+#define elf_backend_rela_normal                    1
 
 #define elf_info_to_howto                  elf64_x86_64_info_to_howto
 
@@ -2245,6 +2299,8 @@ elf64_x86_64_finish_dynamic_sections (output_bfd, info)
 #define elf_backend_finish_dynamic_symbol   elf64_x86_64_finish_dynamic_symbol
 #define elf_backend_gc_mark_hook           elf64_x86_64_gc_mark_hook
 #define elf_backend_gc_sweep_hook          elf64_x86_64_gc_sweep_hook
+#define elf_backend_grok_prstatus          elf64_x86_64_grok_prstatus
+#define elf_backend_grok_psinfo                    elf64_x86_64_grok_psinfo
 #define elf_backend_reloc_type_class       elf64_x86_64_reloc_type_class
 #define elf_backend_relocate_section       elf64_x86_64_relocate_section
 #define elf_backend_size_dynamic_sections   elf64_x86_64_size_dynamic_sections
This page took 0.025649 seconds and 4 git commands to generate.