Run --gc-sections tests only if supported.
[deliverable/binutils-gdb.git] / bfd / elf32-lm32.c
index 68195c3bf2d01840ecbdfc153453b7eeefdc8a8a..07add20c478aa22b52983acbceada4b176e660a0 100644 (file)
@@ -1,5 +1,5 @@
 /* Lattice Mico32-specific support for 32-bit ELF
-   Copyright 2008, 2009, 2010  Free Software Foundation, Inc.
+   Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Jon Beniston <jon@beniston.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -829,7 +829,7 @@ lm32_elf_relocate_section (bfd *output_bfd,
   struct elf_lm32_link_hash_table *htab = lm32_elf_hash_table (info);
   bfd *dynobj;
   bfd_vma *local_got_offsets;
-  asection *sgot, *splt, *sreloc;
+  asection *sgot;
 
   if (htab == NULL)
     return FALSE;
@@ -838,8 +838,6 @@ lm32_elf_relocate_section (bfd *output_bfd,
   local_got_offsets = elf_local_got_offsets (input_bfd);
 
   sgot = htab->sgot;
-  splt = htab->splt;
-  sreloc = NULL;
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -858,7 +856,6 @@ lm32_elf_relocate_section (bfd *output_bfd,
       bfd_vma gp;
       bfd_reloc_status_type r;
       const char *name = NULL;
-      asection *osec;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
@@ -877,7 +874,7 @@ lm32_elf_relocate_section (bfd *output_bfd,
         {
           /* It's a local symbol.  */
           sym = local_syms + r_symndx;
-          osec = sec = local_sections[r_symndx];
+          sec = local_sections[r_symndx];
           relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
           name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
@@ -893,20 +890,12 @@ lm32_elf_relocate_section (bfd *output_bfd,
                                   r_symndx, symtab_hdr, sym_hashes,
                                   h, sec, relocation,
                                   unresolved_reloc, warned);
-         osec = sec;
          name = h->root.root.string;
         }
 
       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;
-       }
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, relend, howto, contents);
 
       if (info->relocatable)
         {
@@ -1291,14 +1280,10 @@ lm32_elf_check_relocs (bfd *abfd,
   const Elf_Internal_Rela *rel_end;
   struct elf_lm32_link_hash_table *htab;
   bfd *dynobj;
-  bfd_vma *local_got_offsets;
-  asection *sgot, *srelgot, *sreloc;
 
   if (info->relocatable)
     return TRUE;
 
-  sgot = srelgot = sreloc = NULL;
-
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_External_Sym);
@@ -1310,7 +1295,6 @@ lm32_elf_check_relocs (bfd *abfd,
     return FALSE;
 
   dynobj = htab->root.dynobj;
-  local_got_offsets = elf_local_got_offsets (abfd);
 
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
@@ -1458,7 +1442,6 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
       for (; dyncon < dynconend; dyncon++)
         {
           Elf_Internal_Dyn dyn;
-          const char *name;
           asection *s;
 
           bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
@@ -1469,11 +1452,9 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
               break;
 
             case DT_PLTGOT:
-              name = ".got";
               s = htab->sgot->output_section;
               goto get_vma;
             case DT_JMPREL:
-              name = ".rela.plt";
               s = htab->srelplt->output_section;
             get_vma:
               BFD_ASSERT (s != NULL);
@@ -1615,15 +1596,12 @@ lm32_elf_finish_dynamic_symbol (bfd *output_bfd,
                                Elf_Internal_Sym *sym)
 {
   struct elf_lm32_link_hash_table *htab;
-  bfd *dynobj;
   bfd_byte *loc;
 
   htab = lm32_elf_hash_table (info);
   if (htab == NULL)
     return FALSE;
 
-  dynobj = htab->root.dynobj;
-
   if (h->plt.offset != (bfd_vma) -1)
     {
       asection *splt;
@@ -1940,12 +1918,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
 
-  if (h->root.type == bfd_link_hash_warning)
-    /* When warning symbols are created, they **replace** the "real"
-       entry in the hash table, thus we never get to see the real
-       symbol in a hash traversal.  So look at it now.  */
-    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
   info = (struct bfd_link_info *) inf;
   htab = lm32_elf_hash_table (info);
   if (htab == NULL)
@@ -2132,9 +2104,6 @@ readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
   struct elf_lm32_link_hash_entry *eh;
   struct elf_lm32_dyn_relocs *p;
 
-  if (h->root.type == bfd_link_hash_warning)
-    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
   eh = (struct elf_lm32_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
@@ -2868,6 +2837,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 
 
 #define ELF_ARCH                bfd_arch_lm32
+#define ELF_TARGET_ID          LM32_ELF_DATA
 #define ELF_MACHINE_CODE        EM_LATTICEMICO32
 #define ELF_MAXPAGESIZE         0x1000
 
This page took 0.026699 seconds and 4 git commands to generate.