* elflink.h (elf_gc_sections): Warn when gc-sections option is ignored.
authorAlan Modra <amodra@gmail.com>
Thu, 1 Jan 2004 10:01:45 +0000 (10:01 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 1 Jan 2004 10:01:45 +0000 (10:01 +0000)
* elf32-h8300.c (elf32_h8_gc_mark_hook): New function.
(elf32_h8_gc_sweep_hook): New function.
(elf_backend_gc_mark_hook): Define.
(elf_backend_gc_sweep_hook): Define.
(elf_backend_can_gc_sections): Define.

bfd/ChangeLog
bfd/elf32-h8300.c
bfd/elflink.h

index 9665466..3999988 100644 (file)
@@ -1,3 +1,12 @@
+2004-01-01  Grant Edwards <grante@visi.com>
+
+       * elflink.h (elf_gc_sections): Warn when gc-sections option is ignored.
+       * elf32-h8300.c (elf32_h8_gc_mark_hook): New function.
+       (elf32_h8_gc_sweep_hook): New function.
+       (elf_backend_gc_mark_hook): Define.
+       (elf_backend_gc_sweep_hook): Define.
+       (elf_backend_can_gc_sections): Define.
+
 2003-12-19  Kazuhiro Inaoka  <inaoka.kazuhiro@renesas.com>
 
        Adfd m32r-linux and PIC support.  Add new ABI that uses RELA.
 
        * peXXigen.c (_bfd_XXi_swap_scnhdr_out): Ensure that correct flags
        are set on known section types.
-       
+
 2003-12-12  Nick Clifton  <nickc@redhat.com>
 
        * po/ro.po: Updated translation.
        * bfd-in2.h: Regenerate.
        * cpu-m32r.c : Add new machine type.
        * elf32-m32r.c (m32r_elf_object_p, m32r_elf_final_write_processing,
-        m32r_elf_merge_private_bfd_data): Add support for new machine
+       m32r_elf_merge_private_bfd_data): Add support for new machine
        type.
 
 2003-12-03  Dave Airlie  <airlied@linux.ie>
index 18d87d4..3c5f298 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for Renesas H8/300 ELF binaries.
-   Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2003
+   Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -47,6 +47,11 @@ static bfd_boolean elf32_h8_symbol_address_p
 static bfd_byte *elf32_h8_get_relocated_section_contents
   (bfd *, struct bfd_link_info *, struct bfd_link_order *,
    bfd_byte *, bfd_boolean, asymbol **);
+static asection * elf32_h8_gc_mark_hook
+  (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
+   struct elf_link_hash_entry *, Elf_Internal_Sym *);
+static bfd_boolean elf32_h8_gc_sweep_hook
+  (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
 static bfd_reloc_status_type elf32_h8_final_link_relocate
   (unsigned long, bfd *, bfd *, asection *,
    bfd_byte *, bfd_vma, bfd_vma, bfd_vma,
@@ -1428,6 +1433,42 @@ elf32_h8_get_relocated_section_contents (bfd *output_bfd,
   return NULL;
 }
 
+static asection *
+elf32_h8_gc_mark_hook (asection *sec,
+                      struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                      Elf_Internal_Rela *rel ATTRIBUTE_UNUSED,
+                      struct elf_link_hash_entry *h,
+                      Elf_Internal_Sym *sym)
+{
+  if (h != NULL)
+    {
+      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;
+}
+
+static bfd_boolean
+elf32_h8_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
+                       struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                        asection *sec ATTRIBUTE_UNUSED,
+                       const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
 
 #define TARGET_BIG_SYM                 bfd_elf32_h8300_vec
 #define TARGET_BIG_NAME                        "elf32-h8300"
@@ -1446,6 +1487,8 @@ elf32_h8_get_relocated_section_contents (bfd *output_bfd,
   elf32_h8_object_p
 #define bfd_elf32_bfd_merge_private_bfd_data \
   elf32_h8_merge_private_bfd_data
+#define elf_backend_gc_mark_hook        elf32_h8_gc_mark_hook
+#define elf_backend_gc_sweep_hook       elf32_h8_gc_sweep_hook
 
 /* ??? when elf_backend_relocate_section is not defined, elf32-target.h
    defaults to using _bfd_generic_link_hash_table_create, but
@@ -1457,6 +1500,7 @@ elf32_h8_get_relocated_section_contents (bfd *output_bfd,
 /* Use an H8 specific linker, not the ELF generic linker.  */
 #define elf_backend_relocate_section elf32_h8_relocate_section
 #define elf_backend_rela_normal                1
+#define elf_backend_can_gc_sections    1
 
 /* And relaxing stuff.  */
 #define bfd_elf32_bfd_relax_section     elf32_h8_relax_section
index f558e1c..c37d739 100644 (file)
@@ -5801,7 +5801,10 @@ elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
       || info->emitrelocations
       || !is_elf_hash_table (info->hash)
       || elf_hash_table (info)->dynamic_sections_created)
-    return TRUE;
+    {
+      (*_bfd_error_handler)(_("Warning: gc-sections option ignored"));
+      return TRUE;
+    }
 
   /* Apply transitive closure to the vtable entry usage info.  */
   elf_link_hash_traverse (elf_hash_table (info),