From 3d4d4302b99ee621e11ac8ef60ac9185da94654b Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 29 Jun 2012 14:46:03 +0000 Subject: * section.c (bfd_get_linker_section): New function. * elf32-arm.c: When retrieving SEC_LINKER_CREATED sections, use the above throughout rather than bfd_get_section_by_name. Use bfd_make_section_anyway rather than bfd_make_section when creating them. * elf32-bfin.c: Likewise. * elf32-cr16.c: Likewise. * elf32-cris.c: Likewise. * elf32-frv.c: Likewise. * elf32-hppa.c: Likewise. * elf32-i370.c: Likewise. * elf32-i386.c: Likewise. * elf32-lm32.c: Likewise. * elf32-m32c.c: Likewise. * elf32-m32r.c: Likewise. * elf32-m68k.c: Likewise. * elf32-microblaze.c: Likewise. * elf32-ppc.c: Likewise. * elf32-rl78.c: Likewise. * elf32-s390.c: Likewise. * elf32-score.c: Likewise. * elf32-score7.c: Likewise. * elf32-sh.c: Likewise. * elf32-tic6x.c: Likewise. * elf32-tilepro.c: Likewise. * elf32-vax.c: Likewise. * elf32-xstormy16.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ia64-vms.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise. * elf64-sh64.c: Likewise. * elf64-sparc.c: Likewise. * elf64-x86-64.c: Likewise. * elfnn-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elfxx-sparc.c: Likewise. * elfxx-tilegx.c: Likewise. * elflink.c: Likewise. * elf-vxworks.c: Likewise. * elf-m10300.c: Likewise. Also make use of htab plt, got and gotplt shortcuts. * bfd-in2.h: Regenerate. * elf32-lm32.c (lm32_elf_check_relocs): Use the correct bfd when calling create_rofixup_section. * elflink.c (bfd_elf_final_link): Simplify test for .dynstr. --- bfd/elf32-xtensa.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'bfd/elf32-xtensa.c') diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index c6c9c12..2de9480 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -1414,11 +1414,11 @@ elf_xtensa_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) /* First do all the standard stuff. */ if (! _bfd_elf_create_dynamic_sections (dynobj, info)) return FALSE; - htab->splt = bfd_get_section_by_name (dynobj, ".plt"); - htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt"); - htab->sgot = bfd_get_section_by_name (dynobj, ".got"); - htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); - htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + htab->splt = bfd_get_linker_section (dynobj, ".plt"); + htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt"); + htab->sgot = bfd_get_linker_section (dynobj, ".got"); + htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt"); + htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got"); /* Create any extra PLT sections in case check_relocs has already been called on all the non-dynamic input files. */ @@ -1435,14 +1435,15 @@ elf_xtensa_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) return FALSE; /* Create ".got.loc" (literal tables for use by dynamic linker). */ - htab->sgotloc = bfd_make_section_with_flags (dynobj, ".got.loc", flags); + htab->sgotloc = bfd_make_section_anyway_with_flags (dynobj, ".got.loc", + flags); if (htab->sgotloc == NULL || ! bfd_set_section_alignment (dynobj, htab->sgotloc, 2)) return FALSE; /* Create ".xt.lit.plt" (literal table for ".got.plt*"). */ - htab->spltlittbl = bfd_make_section_with_flags (dynobj, ".xt.lit.plt", - noalloc_flags); + htab->spltlittbl = bfd_make_section_anyway_with_flags (dynobj, ".xt.lit.plt", + noalloc_flags); if (htab->spltlittbl == NULL || ! bfd_set_section_alignment (dynobj, htab->spltlittbl, 2)) return FALSE; @@ -1474,14 +1475,14 @@ add_extra_plt_sections (struct bfd_link_info *info, int count) sname = (char *) bfd_malloc (10); sprintf (sname, ".plt.%u", chunk); - s = bfd_make_section_with_flags (dynobj, sname, flags | SEC_CODE); + s = bfd_make_section_anyway_with_flags (dynobj, sname, flags | SEC_CODE); if (s == NULL || ! bfd_set_section_alignment (dynobj, s, 2)) return FALSE; sname = (char *) bfd_malloc (14); sprintf (sname, ".got.plt.%u", chunk); - s = bfd_make_section_with_flags (dynobj, sname, flags); + s = bfd_make_section_anyway_with_flags (dynobj, sname, flags); if (s == NULL || ! bfd_set_section_alignment (dynobj, s, 2)) return FALSE; @@ -1636,7 +1637,7 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Set the contents of the .interp section to the interpreter. */ if (info->executable) { - s = bfd_get_section_by_name (dynobj, ".interp"); + s = bfd_get_linker_section (dynobj, ".interp"); if (s == NULL) abort (); s->size = sizeof ELF_DYNAMIC_INTERPRETER; @@ -3275,7 +3276,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd, return FALSE; dynobj = elf_hash_table (info)->dynobj; - sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); + sdyn = bfd_get_linker_section (dynobj, ".dynamic"); BFD_ASSERT (sdyn != NULL); /* Set the first entry in the global offset table to the address of @@ -10275,7 +10276,7 @@ elf_xtensa_get_plt_section (struct bfd_link_info *info, int chunk) dynobj = elf_hash_table (info)->dynobj; sprintf (plt_name, ".plt.%u", chunk); - return bfd_get_section_by_name (dynobj, plt_name); + return bfd_get_linker_section (dynobj, plt_name); } @@ -10296,7 +10297,7 @@ elf_xtensa_get_gotplt_section (struct bfd_link_info *info, int chunk) dynobj = elf_hash_table (info)->dynobj; sprintf (got_name, ".got.plt.%u", chunk); - return bfd_get_section_by_name (dynobj, got_name); + return bfd_get_linker_section (dynobj, got_name); } @@ -10675,7 +10676,7 @@ xtensa_callback_required_dependence (bfd *abfd, /* Find the corresponding ".got.plt*" section. */ if (sec->name[4] == '\0') - sgotplt = bfd_get_section_by_name (sec->owner, ".got.plt"); + sgotplt = bfd_get_linker_section (sec->owner, ".got.plt"); else { char got_name[14]; @@ -10685,7 +10686,7 @@ xtensa_callback_required_dependence (bfd *abfd, chunk = strtol (&sec->name[5], NULL, 10); sprintf (got_name, ".got.plt.%u", chunk); - sgotplt = bfd_get_section_by_name (sec->owner, got_name); + sgotplt = bfd_get_linker_section (sec->owner, got_name); } BFD_ASSERT (sgotplt); -- cgit v1.1