OSDN Git Service

bfd/ChangeLog:
authorAlexandre Oliva <aoliva@redhat.com>
Mon, 21 Jun 2004 14:45:41 +0000 (14:45 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Mon, 21 Jun 2004 14:45:41 +0000 (14:45 +0000)
* elf-bfd.h (struct elf_backend_data): Added
elf_backend_omit_section_dynsym.
(_bfd_elf_link_omit_section_dynsym): Declare.
* elf32-frv.c (_frvfdpic_link_omit_section_dynsym): New.
(elf_backend_omit_section_dynsym): Use it for frvfdpic.
* elflink.c (_bfd_elf_link_omit_section_dynsym): Split out of...
(_bfd_elf_link_renumber_dynsyms): ... this function.
* elfxx-target.h (elf_backend_omit_section_dynsym): Default to
_bfd_elf_link_omit_section_dynsym).
(elfNN_bed): Added elf_backend_omit_section_dynsym.
ld/ChangeLog:
* emulparams/elf32frvfd.sh (GENERATE_PIE_SCRIPT): Set to yes.
ld/testsuite/ChangeLog:
* ld-frv/fdpic-pie-1.d: Adjust for pie-specific link script.
* ld-frv/fdpic-pie-2.d: Likewise.
* ld-frv/fdpic-pie-6.d: Likewise.
* ld-frv/fdpic-pie-7.d: Likewise.
* ld-frv/fdpic-pie-8.d: Likewise.
* ld-frv/fdpic-shared-1.d: Likewise.
* ld-frv/fdpic-shared-2.d: Likewise.
* ld-frv/fdpic-shared-3.d: Likewise.
* ld-frv/fdpic-shared-4.d: Likewise.
* ld-frv/fdpic-shared-5.d: Likewise.
* ld-frv/fdpic-shared-6.d: Likewise.
* ld-frv/fdpic-shared-7.d: Likewise.
* ld-frv/fdpic-shared-8.d: Likewise.
* ld-frv/fdpic-shared-local-2.d: Likewise.
* ld-frv/fdpic-shared-local-8.d: Likewise.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf32-frv.c
bfd/elflink.c
bfd/elfxx-target.h

index 79c506e..ec5c63e 100644 (file)
@@ -1,3 +1,16 @@
+2004-06-21  Alexandre Oliva  <aoliva@redhat.com>
+
+       * elf-bfd.h (struct elf_backend_data): Added
+       elf_backend_omit_section_dynsym.
+       (_bfd_elf_link_omit_section_dynsym): Declare.
+       * elf32-frv.c (_frvfdpic_link_omit_section_dynsym): New.
+       (elf_backend_omit_section_dynsym): Use it for frvfdpic.
+       * elflink.c (_bfd_elf_link_omit_section_dynsym): Split out of...
+       (_bfd_elf_link_renumber_dynsyms): ... this function.
+       * elfxx-target.h (elf_backend_omit_section_dynsym): Default to
+       _bfd_elf_link_omit_section_dynsym).
+       (elfNN_bed): Added elf_backend_omit_section_dynsym.
+
 2004-06-21  Nick Clifton  <nickc@redhat.com>
 
        * coffcode.h (styp_to_sec_flags): Ignore IMAGE_SCN_MEM_NOT_PAGED
index 220e401..e140c68 100644 (file)
@@ -646,6 +646,11 @@ struct elf_backend_data
   bfd_boolean (*elf_backend_create_dynamic_sections)
     (bfd *abfd, struct bfd_link_info *info);
 
+  /* When creating a shared library, determine whether to omit the
+     dynamic symbol for the section.  */
+  bfd_boolean (*elf_backend_omit_section_dynsym)
+    (bfd *output_bfd, struct bfd_link_info *info, asection *osec);
+
   /* The CHECK_RELOCS function is called by the add_symbols phase of
      the ELF backend linker.  It is called once for each section with
      relocs of an object file, just after the symbols for the object
@@ -1520,6 +1525,8 @@ extern bfd_boolean _bfd_elf_validate_reloc
 
 extern bfd_boolean _bfd_elf_link_create_dynamic_sections
   (bfd *, struct bfd_link_info *);
+extern bfd_boolean _bfd_elf_link_omit_section_dynsym
+  (bfd *, struct bfd_link_info *, asection *);
 extern bfd_boolean _bfd_elf_create_dynamic_sections
   (bfd *, struct bfd_link_info *);
 extern bfd_boolean _bfd_elf_create_got_section
index cf3195a..ad2c324 100644 (file)
@@ -2685,6 +2685,30 @@ elf32_frv_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
   return TRUE;
 }
 
+/* We need dynamic symbols for every section, since segments can
+   relocate independently.  */
+static bfd_boolean
+_frvfdpic_link_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED,
+                                   struct bfd_link_info *info
+                                   ATTRIBUTE_UNUSED,
+                                   asection *p ATTRIBUTE_UNUSED)
+{
+  switch (elf_section_data (p)->this_hdr.sh_type)
+    {
+    case SHT_PROGBITS:
+    case SHT_NOBITS:
+      /* If sh_type is yet undecided, assume it could be
+        SHT_PROGBITS/SHT_NOBITS.  */
+    case SHT_NULL:
+      return FALSE;
+
+      /* There shouldn't be section relative relocations
+        against any other section.  */
+    default:
+      return TRUE;
+    }
+}
+
 /* Create  a .got section, as well as its additional info field.  This
    is almost entirely copied from
    elflink.c:_bfd_elf_create_got_section().  */
@@ -4825,4 +4849,7 @@ frv_elf_print_private_bfd_data (abfd, ptr)
 #undef elf_backend_default_use_rela_p
 #define elf_backend_default_use_rela_p  1
 
+#undef elf_backend_omit_section_dynsym
+#define elf_backend_omit_section_dynsym _frvfdpic_link_omit_section_dynsym
+
 #include "elf32-target.h"
index 37b113b..622d406 100644 (file)
@@ -608,6 +608,43 @@ elf_link_renumber_hash_table_dynsyms (struct elf_link_hash_entry *h,
   return TRUE;
 }
 
+/* Return true if the dynamic symbol for a given section should be
+   omitted when creating a shared library.  */
+bfd_boolean
+_bfd_elf_link_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED,
+                                  struct bfd_link_info *info,
+                                  asection *p)
+{
+  switch (elf_section_data (p)->this_hdr.sh_type)
+    {
+    case SHT_PROGBITS:
+    case SHT_NOBITS:
+      /* If sh_type is yet undecided, assume it could be
+        SHT_PROGBITS/SHT_NOBITS.  */
+    case SHT_NULL:
+      if (strcmp (p->name, ".got") == 0
+         || strcmp (p->name, ".got.plt") == 0
+         || strcmp (p->name, ".plt") == 0)
+       {
+         asection *ip;
+         bfd *dynobj = elf_hash_table (info)->dynobj;
+
+         if (dynobj != NULL
+             && (ip = bfd_get_section_by_name (dynobj, p->name))
+             != NULL
+             && (ip->flags & SEC_LINKER_CREATED)
+             && ip->output_section == p)
+           return TRUE;
+       }
+      return FALSE;
+
+      /* There shouldn't be section relative relocations
+        against any other section.  */
+    default:
+      return TRUE;
+    }
+}
+
 /* Assign dynsym indices.  In a shared library we generate a section
    symbol for each output section, which come first.  Next come all of
    the back-end allocated local dynamic syms, followed by the rest of
@@ -620,38 +657,13 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd, struct bfd_link_info *info)
 
   if (info->shared)
     {
+      const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
       asection *p;
       for (p = output_bfd->sections; p ; p = p->next)
        if ((p->flags & SEC_EXCLUDE) == 0
-           && (p->flags & SEC_ALLOC) != 0)
-         switch (elf_section_data (p)->this_hdr.sh_type)
-           {
-           case SHT_PROGBITS:
-           case SHT_NOBITS:
-             /* If sh_type is yet undecided, assume it could be
-                SHT_PROGBITS/SHT_NOBITS.  */
-           case SHT_NULL:
-             if (strcmp (p->name, ".got") == 0
-                 || strcmp (p->name, ".got.plt") == 0
-                 || strcmp (p->name, ".plt") == 0)
-               {
-                 asection *ip;
-                 bfd *dynobj = elf_hash_table (info)->dynobj;
-
-                 if (dynobj != NULL
-                     && (ip = bfd_get_section_by_name (dynobj, p->name))
-                        != NULL
-                     && (ip->flags & SEC_LINKER_CREATED)
-                     && ip->output_section == p)
-                   continue;
-               }
-             elf_section_data (p)->dynindx = ++dynsymcount;
-             break;
-             /* There shouldn't be section relative relocations
-                against any other section.  */
-           default:
-             break;
-           }
+           && (p->flags & SEC_ALLOC) != 0
+           && !(*bed->elf_backend_omit_section_dynsym) (output_bfd, info, p))
+         elf_section_data (p)->dynindx = ++dynsymcount;
     }
 
   if (elf_hash_table (info)->dynlocal)
index d0773e5..af04ecb 100644 (file)
 #ifndef elf_backend_create_dynamic_sections
 #define elf_backend_create_dynamic_sections 0
 #endif
+#ifndef elf_backend_omit_section_dynsym
+#define elf_backend_omit_section_dynsym _bfd_elf_link_omit_section_dynsym
+#endif
 #ifndef elf_backend_check_relocs
 #define elf_backend_check_relocs       0
 #endif
@@ -505,6 +508,7 @@ static const struct elf_backend_data elfNN_bed =
   elf_backend_add_symbol_hook,
   elf_backend_link_output_symbol_hook,
   elf_backend_create_dynamic_sections,
+  elf_backend_omit_section_dynsym,
   elf_backend_check_relocs,
   elf_backend_adjust_dynamic_symbol,
   elf_backend_always_size_sections,