+2002-03-04 H.J. Lu <hjl@gnu.org>
+
+ * elf.c (bfd_section_from_shdr): Handle special sections,
+ .init_array, .fini_array and .preinit_array.
+ (elf_fake_sections): Likewise.
+
+ * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Create the
+ DT entry only if the section is in output for .init_array,
+ .fini_array and .preinit_array. Complain about .preinit_array
+ section in DSO.
+ (elf_bfd_final_link): Warn zero size for .init_array,
+ .fini_array and .preinit_array sections.
+
+ * elfxx-ia64.c (elfNN_ia64_section_from_shdr): Remove
+ SHT_INIT_ARRAY, SHT_FINI_ARRAY and SHT_PREINIT_ARRAY.
+ (elfNN_ia64_fake_sections): Remove .init_array, .fini_array and
+ .preinit_array.
+
2002-03-04 Alan Modra <amodra@bigpond.net.au>
* configure.in (WIN32LIBADD): Don't eval PICFLAG assignment.
case SHT_NOBITS: /* .bss section. */
case SHT_HASH: /* .hash section. */
case SHT_NOTE: /* .note section. */
+ case SHT_INIT_ARRAY: /* .init_array section. */
+ case SHT_FINI_ARRAY: /* .fini_array section. */
+ case SHT_PREINIT_ARRAY: /* .preinit_array section. */
return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
case SHT_SYMTAB: /* A symbol table */
this_hdr->sh_type = SHT_REL;
this_hdr->sh_entsize = bed->s->sizeof_rel;
}
+ else if (strcmp (asect->name, ".init_array") == 0)
+ this_hdr->sh_type = SHT_INIT_ARRAY;
+ else if (strcmp (asect->name, ".fini_array") == 0)
+ this_hdr->sh_type = SHT_FINI_ARRAY;
+ else if (strcmp (asect->name, ".preinit_array") == 0)
+ this_hdr->sh_type = SHT_PREINIT_ARRAY;
else if (strncmp (asect->name, ".note", 5) == 0)
this_hdr->sh_type = SHT_NOTE;
else if (strncmp (asect->name, ".stab", 5) == 0
struct bfd_elf_version_tree *verdefs;
{
bfd_size_type soname_indx;
- bfd *dynobj, *sub;
- asection *o;
- int need_preinit_array = 0, need_init_array = 0, need_fini_array = 0;
+ bfd *dynobj;
struct elf_backend_data *bed;
struct elf_assign_sym_version_info asvinfo;
return false;
}
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- for (o = sub->sections; o != NULL; o = o->next)
- {
- /* yuck, more matching by name... */
-
- if (strcmp (bfd_section_name (sub, o), ".preinit_array") == 0)
- need_preinit_array = 1;
- if (strcmp (bfd_section_name (sub, o), ".init_array") == 0)
- need_init_array = 1;
- if (strcmp (bfd_section_name (sub, o), ".fini_array") == 0)
- need_fini_array = 1;
- }
- if (need_preinit_array)
+ if (bfd_get_section_by_name (output_bfd, ".preinit_array") != NULL)
{
+ /* DT_PREINIT_ARRAY is not allowed in shared library. */
+ if (info->shared)
+ {
+ bfd *sub;
+ asection *o;
+
+ for (sub = info->input_bfds; sub != NULL;
+ sub = sub->link_next)
+ for (o = sub->sections; o != NULL; o = o->next)
+ if (elf_section_data (o)->this_hdr.sh_type
+ == SHT_PREINIT_ARRAY)
+ {
+ (*_bfd_error_handler)
+ (_("%s: .preinit_array section is not allowed in DSO"),
+ bfd_archive_filename (sub));
+ break;
+ }
+
+ return false;
+ }
+
if (!elf_add_dynamic_entry (info, (bfd_vma) DT_PREINIT_ARRAY,
(bfd_vma) 0)
|| !elf_add_dynamic_entry (info, (bfd_vma) DT_PREINIT_ARRAYSZ,
(bfd_vma) 0))
return false;
}
- if (need_init_array)
+ if (bfd_get_section_by_name (output_bfd, ".init_array") != NULL)
{
if (!elf_add_dynamic_entry (info, (bfd_vma) DT_INIT_ARRAY,
(bfd_vma) 0)
(bfd_vma) 0))
return false;
}
- if (need_fini_array)
+ if (bfd_get_section_by_name (output_bfd, ".fini_array") != NULL)
{
if (!elf_add_dynamic_entry (info, (bfd_vma) DT_FINI_ARRAY,
(bfd_vma) 0)
get_size:
o = bfd_get_section_by_name (abfd, name);
BFD_ASSERT (o != NULL);
+ if (o->_raw_size == 0)
+ (*_bfd_error_handler)
+ (_("warning: %s section has zero size"), name);
dyn.d_un.d_val = o->_raw_size;
elf_swap_dyn_out (dynobj, &dyn, dyncon);
break;
switch (hdr->sh_type)
{
case SHT_IA_64_UNWIND:
- case SHT_INIT_ARRAY:
- case SHT_FINI_ARRAY:
- case SHT_PREINIT_ARRAY:
case SHT_IA_64_HP_OPT_ANOT:
break;
}
else if (strcmp (name, ELF_STRING_ia64_archext) == 0)
hdr->sh_type = SHT_IA_64_EXT;
- else if (strcmp (name, ".init_array") == 0)
- hdr->sh_type = SHT_INIT_ARRAY;
- else if (strcmp (name, ".fini_array") == 0)
- hdr->sh_type = SHT_FINI_ARRAY;
- else if (strcmp (name, ".preinit_array") == 0)
- hdr->sh_type = SHT_PREINIT_ARRAY;
else if (strcmp (name, ".HP.opt_annot") == 0)
hdr->sh_type = SHT_IA_64_HP_OPT_ANOT;
else if (strcmp (name, ".reloc") == 0)