+2016-05-13 Alan Modra <amodra@gmail.com>
+
+ * elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_sections): Use
+ linker dynamic sections in calculating size and address of
+ * dynamic tags rather than using output sections. Remove asserts.
+ * elf32-arm.c (elf32_arm_finish_dynamic_sections): Likewise.
+ * elf32-cr16.c (_bfd_cr16_elf_finish_dynamic_sections): Likewise.
+ * elf32-cris.c (elf_cris_finish_dynamic_sections): Likewise.
+ * elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise.
+ * elf32-lm32.c (lm32_elf_finish_dynamic_sections): Likewise.
+ * elf32-m32r.c (m32r_elf_finish_dynamic_sections): Likewise.
+ * elf32-m68k.c (elf_m68k_finish_dynamic_sections): Likewise.
+ * elf32-metag.c (elf_metag_finish_dynamic_sections): Likewise.
+ * elf32-microblaze.c (microblaze_elf_finish_dynamic_sections): Likewise.
+ * elf32-nds32.c (nds32_elf_finish_dynamic_sections): Likewise.
+ * elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Likewise.
+ * elf32-or1k.c (or1k_elf_finish_dynamic_sections): Likewise.
+ * elf32-s390.c (elf_s390_finish_dynamic_sections): Likewise.
+ * elf32-score.c (s3_bfd_score_elf_finish_dynamic_sections): Likewise.
+ * elf32-score7.c (s7_bfd_score_elf_finish_dynamic_sections): Likewise.
+ * elf32-vax.c (elf_vax_finish_dynamic_sections): Likewise.
+ * elf32-xtensa.c (elf_xtensa_finish_dynamic_sections): Likewise.
+ * elf64-alpha.c (elf64_alpha_finish_dynamic_sections): Likewise.
+ * elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
+ * elf64-sh64.c (sh64_elf64_finish_dynamic_sections): Likewise.
+ * elflink.c (bfd_elf_final_link): Likewise.
+ * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Likewise.
+ * elfxx-sparc.c (sparc_finish_dyn): Likewise. Adjust error message.
+ * elf32-arc.c (GET_SYMBOL_OR_SECTION): Remove ASSERT arg and
+ don't set doit. Look up dynobj section.
+ (elf_arc_finish_dynamic_sections): Adjust GET_SYMBOL_OR_SECTION
+ invocation and dynamic tag vma calculation. Don't test
+ boolean var == TRUE.
+ * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_sections): Fix
+ DT_JMPREL calc.
+
2016-05-13 Alan Modra <amodra@gmail.com>
* elflink.c (elf_link_sort_relocs): Wrap overlong lines. Fix
case DT_JMPREL:
name = ".rela.plt";
get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = bfd_get_linker_section (dynobj, name);
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- BFD_ASSERT (s != NULL);
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
the linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
if (s != NULL)
dyn.d_un.d_val -= s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
return TRUE;
}
-#define GET_SYMBOL_OR_SECTION(TAG, SYMBOL, SECTION, ASSERT) \
+#define GET_SYMBOL_OR_SECTION(TAG, SYMBOL, SECTION) \
case TAG: \
if (SYMBOL != NULL) \
- { \
- h = elf_link_hash_lookup (elf_hash_table (info), \
- SYMBOL, FALSE, FALSE, TRUE); \
- } \
+ h = elf_link_hash_lookup (elf_hash_table (info), \
+ SYMBOL, FALSE, FALSE, TRUE); \
else if (SECTION != NULL) \
- { \
- s = bfd_get_section_by_name (output_bfd, SECTION); \
- BFD_ASSERT (s != NULL || !ASSERT); \
- do_it = TRUE; \
- } \
+ s = bfd_get_linker_section (dynobj, SECTION); \
break;
/* Function : elf_arc_finish_dynamic_sections
switch (internal_dyn.d_tag)
{
- GET_SYMBOL_OR_SECTION (DT_INIT, "_init", NULL, TRUE)
- GET_SYMBOL_OR_SECTION (DT_FINI, "_fini", NULL, TRUE)
- GET_SYMBOL_OR_SECTION (DT_PLTGOT, NULL, ".plt", TRUE)
- GET_SYMBOL_OR_SECTION (DT_JMPREL, NULL, ".rela.plt", TRUE)
- GET_SYMBOL_OR_SECTION (DT_PLTRELSZ, NULL, ".rela.plt", TRUE)
- GET_SYMBOL_OR_SECTION (DT_RELASZ, NULL, ".rela.plt", FALSE)
- GET_SYMBOL_OR_SECTION (DT_VERSYM, NULL, ".gnu.version", TRUE)
- GET_SYMBOL_OR_SECTION (DT_VERDEF, NULL, ".gnu.version_d", TRUE)
- GET_SYMBOL_OR_SECTION (DT_VERNEED, NULL, ".gnu.version_r", TRUE)
+ GET_SYMBOL_OR_SECTION (DT_INIT, "_init", NULL)
+ GET_SYMBOL_OR_SECTION (DT_FINI, "_fini", NULL)
+ GET_SYMBOL_OR_SECTION (DT_PLTGOT, NULL, ".plt")
+ GET_SYMBOL_OR_SECTION (DT_JMPREL, NULL, ".rela.plt")
+ GET_SYMBOL_OR_SECTION (DT_PLTRELSZ, NULL, ".rela.plt")
+ GET_SYMBOL_OR_SECTION (DT_RELASZ, NULL, ".rela.plt")
+ GET_SYMBOL_OR_SECTION (DT_VERSYM, NULL, ".gnu.version")
+ GET_SYMBOL_OR_SECTION (DT_VERDEF, NULL, ".gnu.version_d")
+ GET_SYMBOL_OR_SECTION (DT_VERNEED, NULL, ".gnu.version_r")
default:
break;
}
case DT_VERSYM:
case DT_VERDEF:
case DT_VERNEED:
- internal_dyn.d_un.d_ptr = s->vma;
+ internal_dyn.d_un.d_ptr = (s->output_section->vma
+ + s->output_offset);
do_it = TRUE;
break;
}
}
- if (do_it == TRUE)
+ if (do_it)
bfd_elf32_swap_dyn_out (output_bfd, &internal_dyn, dyncon);
}
goto get_vma_if_bpabi;
case DT_PLTGOT:
- name = ".got";
+ name = htab->symbian_p ? ".got" : ".got.plt";
goto get_vma;
case DT_JMPREL:
name = RELOC_SECTION (htab, ".plt");
get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
+ s = bfd_get_linker_section (dynobj, name);
if (s == NULL)
{
- /* PR ld/14397: Issue an error message if a required section is missing. */
(*_bfd_error_handler)
- (_("error: required section '%s' not found in the linker script"), name);
+ (_("could not find section %s"), name);
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
if (!htab->symbian_p)
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
else
/* In the BPABI, tags in the PT_DYNAMIC section point
at the file offset, not the memory address, for the
convenience of the post linker. */
- dyn.d_un.d_ptr = s->filepos;
+ dyn.d_un.d_ptr = s->output_section->filepos + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
break;
case DT_PLTGOT:
- name = ".got";
+ name = ".got.plt";
goto get_vma;
case DT_JMPREL:
name = ".rela.plt";
get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = bfd_get_linker_section (dynobj, name);
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- BFD_ASSERT (s != NULL);
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
the linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
if (s != NULL)
dyn.d_un.d_val -= s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTGOT:
- s = bfd_get_section_by_name (output_bfd, ".got");
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = sgot->output_section->vma + sgot->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_JMPREL:
/* Yes, we *can* have a .plt and no .plt.rela, for instance
if all symbols are found in the .got (not .got.plt). */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- dyn.d_un.d_ptr = s != NULL ? s->vma : 0;
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
+ dyn.d_un.d_ptr = s != NULL ? (s->output_section->vma
+ + s->output_offset) : 0;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
if (s == NULL)
dyn.d_un.d_val = 0;
else
linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
if (s != NULL)
dyn.d_un.d_val -= s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
{
asection *s;
- s = bfd_get_section_by_name (output_bfd, name);
+ s = bfd_get_linker_section (dynobj, name);
if (s == NULL)
dyn.d_un.d_val = 0;
else
{
if (! size)
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
else
dyn.d_un.d_val = s->size;
}
break;
case DT_PLTGOT:
- s = htab->sgot->output_section;
+ s = htab->sgotplt;
goto get_vma;
case DT_JMPREL:
- s = htab->srelplt->output_section;
+ s = htab->srelplt;
get_vma:
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = htab->srelplt->output_section;
- BFD_ASSERT (s != NULL);
+ s = htab->srelplt;
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
about changing the DT_RELA entry. */
if (htab->srelplt != NULL)
{
- s = htab->srelplt->output_section;
+ s = htab->srelplt;
dyn.d_un.d_val -= s->size;
}
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTGOT:
- s = htab->sgot->output_section;
+ s = htab->sgotplt;
goto get_vma;
case DT_JMPREL:
- s = htab->srelplt->output_section;
+ s = htab->srelplt;
get_vma:
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = htab->srelplt->output_section;
- BFD_ASSERT (s != NULL);
+ s = htab->srelplt;
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
about changing the DT_RELA entry. */
if (htab->srelplt != NULL)
{
- s = htab->srelplt->output_section;
+ s = htab->srelplt;
dyn.d_un.d_val -= s->size;
}
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTGOT:
- name = ".got";
+ name = ".got.plt";
goto get_vma;
case DT_JMPREL:
name = ".rela.plt";
get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = bfd_get_linker_section (dynobj, name);
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- BFD_ASSERT (s != NULL);
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
if (s != NULL)
dyn.d_un.d_val -= s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
continue;
case DT_PLTGOT:
- s = htab->sgot->output_section;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma + htab->sgot->output_offset;
+ s = htab->sgot;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_JMPREL:
- s = htab->srelplt->output_section;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = htab->srelplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
{
asection *s;
- s = bfd_get_section_by_name (output_bfd, name);
+ s = bfd_get_linker_section (dynobj, name);
if (s == NULL)
dyn.d_un.d_val = 0;
else
{
if (! size)
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
else
dyn.d_un.d_val = s->size;
}
break;
case DT_PLTGOT:
- /* name = ".got"; */
- s = htab->sgot->output_section;
+ s = htab->sgotplt;
goto get_vma;
case DT_JMPREL:
- s = htab->srelplt->output_section;
+ s = htab->srelplt;
get_vma:
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = htab->srelplt->output_section;
- BFD_ASSERT (s != NULL);
+ s = htab->srelplt;
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
about changing the DT_RELA entry. */
if (htab->srelplt != NULL)
{
- s = htab->srelplt->output_section;
+ s = htab->srelplt;
dyn.d_un.d_val -= s->size;
}
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTGOT:
- s = htab->root.sgot;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->output_section->vma;
+ s = htab->root.sgotplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_JMPREL:
s = htab->root.srelplt;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->output_section->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
s = htab->root.srelplt;
- BFD_ASSERT (s != NULL);
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
break;
case DT_NIOS2_GP:
- s = htab->root.sgot;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->output_section->vma + 0x7ff0;
+ s = htab->root.sgotplt;
+ dyn.d_un.d_ptr
+ = s->output_section->vma + s->output_offset + 0x7ff0;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
}
continue;
case DT_PLTGOT:
- s = htab->sgot->output_section;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = htab->sgotplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_JMPREL:
- s = htab->srelplt->output_section;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = htab->srelplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_PLTRELSZ:
- s = htab->srelplt->output_section;
- BFD_ASSERT (s != NULL);
+ s = htab->srelplt;
dyn.d_un.d_val = s->size;
break;
about changing the DT_RELA entry. */
if (htab->srelplt != NULL)
{
- /* FIXME: this calculation sometimes produces
- wrong result, the problem is that the dyn.d_un.d_val
- is not always correct, needs investigation why
- that happens. In the meantime, reading the
- ".rela.dyn" section by name seems to yield
- correct result.
-
- s = htab->srelplt->output_section;
+ s = htab->srelplt;
dyn.d_un.d_val -= s->size;
- */
-
- s = bfd_get_section_by_name (output_bfd, ".rela.dyn");
- dyn.d_un.d_val = s ? s->size : 0;
}
break;
}
continue;
case DT_PLTGOT:
- dyn.d_un.d_ptr = htab->elf.sgot->output_section->vma;
+ s = htab->elf.sgotplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_JMPREL:
- dyn.d_un.d_ptr = htab->elf.srelplt->output_section->vma;
+ s = htab->elf.srelplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_PLTRELSZ:
- s = htab->elf.srelplt->output_section;
+ s = htab->elf.srelplt;
dyn.d_un.d_val = s->size;
break;
}
switch (dyn.d_tag)
{
case DT_RELENT:
- s = score_elf_rel_dyn_section (dynobj, FALSE);
- BFD_ASSERT (s != NULL);
dyn.d_un.d_val = SCORE_ELF_REL_SIZE (dynobj);
break;
case DT_STRSZ:
/* Rewrite DT_STRSZ. */
- dyn.d_un.d_val = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
- break;
+ dyn.d_un.d_val
+ = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
+ break;
case DT_PLTGOT:
name = ".got";
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = bfd_get_linker_section (dynobj, name);
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_SCORE_BASE_ADDRESS:
case DT_SCORE_SYMTABNO:
name = ".dynsym";
elemsize = SCORE_ELF_SYM_SIZE (output_bfd);
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
-
+ s = bfd_get_linker_section (dynobj, name);
dyn.d_un.d_val = s->size / elemsize;
break;
switch (dyn.d_tag)
{
case DT_RELENT:
- s = score_elf_rel_dyn_section (dynobj, FALSE);
- BFD_ASSERT (s != NULL);
dyn.d_un.d_val = SCORE_ELF_REL_SIZE (dynobj);
break;
case DT_STRSZ:
/* Rewrite DT_STRSZ. */
- dyn.d_un.d_val = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
- break;
+ dyn.d_un.d_val
+ = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
+ break;
case DT_PLTGOT:
name = ".got";
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = bfd_get_linker_section (dynobj, name);
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_SCORE_BASE_ADDRESS:
case DT_SCORE_SYMTABNO:
name = ".dynsym";
elemsize = SCORE_ELF_SYM_SIZE (output_bfd);
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
-
+ s = bfd_get_linker_section (dynobj, name);
dyn.d_un.d_val = s->size / elemsize;
break;
break;
case DT_PLTGOT:
- name = ".got";
+ name = ".got.plt";
goto get_vma;
case DT_JMPREL:
name = ".rela.plt";
get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = bfd_get_linker_section (dynobj, name);
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- BFD_ASSERT (s != NULL);
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
if (s != NULL)
dyn.d_un.d_val -= s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_XTENSA_GOT_LOC_OFF:
- dyn.d_un.d_ptr = htab->sgotloc->output_section->vma;
+ dyn.d_un.d_ptr = (htab->sgotloc->output_section->vma
+ + htab->sgotloc->output_offset);
break;
case DT_PLTGOT:
- dyn.d_un.d_ptr = htab->sgot->output_section->vma;
+ dyn.d_un.d_ptr = (htab->sgot->output_section->vma
+ + htab->sgot->output_offset);
break;
case DT_JMPREL:
- dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
+ dyn.d_un.d_ptr = (htab->srelplt->output_section->vma
+ + htab->srelplt->output_offset);
break;
case DT_PLTRELSZ:
- dyn.d_un.d_val = htab->srelplt->output_section->size;
+ dyn.d_un.d_val = htab->srelplt->size;
break;
case DT_RELASZ:
for .rela.plt to follow all other relocation sections, we
don't have to worry about changing the DT_RELA entry. */
if (htab->srelplt)
- dyn.d_un.d_val -= htab->srelplt->output_section->size;
+ dyn.d_un.d_val -= htab->srelplt->size;
break;
}
bfd_vma plt_vma, gotplt_vma;
splt = bfd_get_linker_section (dynobj, ".plt");
- srelaplt = bfd_get_linker_section (output_bfd, ".rela.plt");
+ srelaplt = bfd_get_linker_section (dynobj, ".rela.plt");
BFD_ASSERT (splt != NULL && sdyn != NULL);
plt_vma = splt->output_section->vma + splt->output_offset;
dyn.d_un.d_val = srelaplt ? srelaplt->size : 0;
break;
case DT_JMPREL:
- dyn.d_un.d_ptr = srelaplt ? srelaplt->vma : 0;
+ dyn.d_un.d_ptr = srelaplt ? (srelaplt->output_section->vma
+ + srelaplt->output_offset) : 0;
break;
case DT_RELASZ:
continue;
case DT_PLTGOT:
- dyn.d_un.d_ptr = htab->elf.sgot->output_section->vma;
+ s = htab->elf.sgotplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_JMPREL:
- dyn.d_un.d_ptr = htab->elf.srelplt->output_section->vma;
+ s = htab->elf.srelplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_PLTRELSZ:
- s = htab->elf.srelplt->output_section;
+ s = htab->elf.srelplt;
dyn.d_un.d_val = s->size;
break;
linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- s = htab->elf.srelplt->output_section;
+ s = htab->elf.srelplt;
dyn.d_un.d_val -= s->size;
break;
}
break;
case DT_PLTGOT:
- name = ".got";
+ name = ".got.plt";
goto get_vma;
case DT_JMPREL:
name = ".rela.plt";
get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ s = bfd_get_linker_section (dynobj, name);
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- BFD_ASSERT (s != NULL);
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
dyn.d_un.d_val = s->size;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
the linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+ s = bfd_get_linker_section (dynobj, ".rela.plt");
if (s != NULL)
dyn.d_un.d_val -= s->size;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
case DT_PREINIT_ARRAYSZ:
name = ".preinit_array";
- goto get_size;
+ goto get_out_size;
case DT_INIT_ARRAYSZ:
name = ".init_array";
- goto get_size;
+ goto get_out_size;
case DT_FINI_ARRAYSZ:
name = ".fini_array";
- get_size:
+ get_out_size:
o = bfd_get_section_by_name (abfd, name);
if (o == NULL)
{
(*_bfd_error_handler)
- (_("%B: could not find output section %s"), abfd, name);
+ (_("could not find section %s"), name);
goto error_return;
}
if (o->size == 0)
case DT_PREINIT_ARRAY:
name = ".preinit_array";
- goto get_vma;
+ goto get_out_vma;
case DT_INIT_ARRAY:
name = ".init_array";
- goto get_vma;
+ goto get_out_vma;
case DT_FINI_ARRAY:
name = ".fini_array";
- goto get_vma;
+ get_out_vma:
+ o = bfd_get_section_by_name (abfd, name);
+ goto do_vma;
case DT_HASH:
name = ".hash";
case DT_VERSYM:
name = ".gnu.version";
get_vma:
- o = bfd_get_section_by_name (abfd, name);
+ o = bfd_get_linker_section (dynobj, name);
+ do_vma:
if (o == NULL)
{
(*_bfd_error_handler)
- (_("%B: could not find output section %s"), abfd, name);
+ (_("could not find section %s"), name);
goto error_return;
}
if (elf_section_data (o->output_section)->this_hdr.sh_type == SHT_NOTE)
bfd_set_error (bfd_error_nonrepresentable_section);
goto error_return;
}
- dyn.d_un.d_ptr = o->vma;
+ dyn.d_un.d_ptr = o->output_section->vma + o->output_offset;
break;
case DT_REL:
break;
case DT_JMPREL:
- dyn.d_un.d_ptr = htab->root.srelplt->output_section->vma;
+ s = htab->root.srelplt;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_PLTRELSZ:
case DT_MIPS_SYMTABNO:
name = ".dynsym";
elemsize = MIPS_ELF_SYM_SIZE (output_bfd);
- s = bfd_get_section_by_name (output_bfd, name);
+ s = bfd_get_linker_section (dynobj, name);
if (s != NULL)
dyn.d_un.d_val = s->size / elemsize;
{
asection *s;
- s = bfd_get_section_by_name (output_bfd, name);
+ s = bfd_get_linker_section (dynobj, name);
if (s == NULL)
dyn.d_un.d_val = 0;
else
{
if (! size)
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
else
dyn.d_un.d_val = s->size;
}
+2016-05-13 Alan Modra <amodra@gmail.com>
+
+ * testsuite/ld-arm/arm-elf.exp: Adjust for arm-no-rel-plt now passing.
+ Use different output file name for static app without .rel.plt.
+ * testsuite/ld-arm/arm-no-rel-plt.ld: Align .rel.dyn and .rela.dyn.
+ * testsuite/ld-arm/arm-no-rel-plt.out: Delete.
+ * testsuite/ld-arm/arm-no-rel-plt.r: New.
+ * testsuite/ld-arm/arm-static-app.d: Don't check file name.
+ * testsuite/ld-arm/arm-static-app.r: Likewise.
+
2016-05-12 H.J. Lu <hongjiu.lu@intel.com>
PR ld/20070
{"Simple static application without .rel.plt in linker script"
"-T arm-no-rel-plt.ld" "" "" {arm-static-app.s}
{{objdump -fdw arm-static-app.d} {objdump -rw arm-static-app.r}}
- "arm-static-app"}
+ "arm-static-app-no-rel-plt"}
{"Simple dynamic application without .rel.plt in linker script"
"tmpdir/arm-lib.so -T arm-no-rel-plt.ld" "" "" {arm-app.s}
- {{ld arm-no-rel-plt.out}}
- "arm-app"}
+ {{readelf -dr arm-no-rel-plt.r}}
+ "arm-app-no-rel-plt"}
{"Non-pcrel function reference" "tmpdir/arm-lib.so" "" "" {arm-app-abs32.s}
{{objdump -fdw arm-app-abs32.d} {objdump -Rw arm-app-abs32.r}}
"arm-app-abs32"}
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
- .rel.dyn :
+ .rel.dyn ALIGN (0x100) :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
PROVIDE_HIDDEN (__rela_iplt_start = .);
PROVIDE_HIDDEN (__rela_iplt_end = .);
}
- .rela.dyn :
+ .rela.dyn ALIGN (0x100) :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
+++ /dev/null
-.*: error: required section '.rel.plt' not found in the linker script
-.*: final link failed: Invalid operation
--- /dev/null
+#...
+ 0x00000017 \(JMPREL\) +0x.*08
+ 0x00000011 \(REL\) +0x.*00
+#...
+
+Relocation section '\.rel\.dyn' at offset 0x.*00 contains 2 entries:
+ Offset +Info +Type +Sym\.Value +Sym\. Name
+.* R_ARM_COPY .* data_obj
+.* R_ARM_JUMP_SLOT .* lib_func1
-tmpdir/arm-static-app: file format elf32-(little|big)arm.*
+.*: file format elf32-(little|big)arm.*
architecture: arm.*, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x.*
-tmpdir/arm-static-app: file format elf32-(little|big)arm.*
+.*: file format elf32-(little|big)arm.*