+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
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
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
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(). */
#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"
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
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)
#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
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,