From 4af386446017ed68977d203f844584d12e630952 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Tue, 27 Apr 2004 21:28:16 +0000 Subject: [PATCH] * elf32-xtensa.c (xtensa_read_table_entries): Use section _cooked_size if set. Check reloc_done flag before applying relocations. Use output addresses, both when applying relocations and when comparing against the specified section. (elf_xtensa_relocate_section): Use output address to check if dynamic reloc is in a literal pool. Set section's reloc_done flag. --- bfd/ChangeLog | 9 +++++++++ bfd/elf32-xtensa.c | 23 ++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 18d734fa1b..9962fb5377 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2004-04-27 Bob Wilson + + * elf32-xtensa.c (xtensa_read_table_entries): Use section _cooked_size + if set. Check reloc_done flag before applying relocations. Use + output addresses, both when applying relocations and when comparing + against the specified section. + (elf_xtensa_relocate_section): Use output address to check if dynamic + reloc is in a literal pool. Set section's reloc_done flag. + 2004-04-27 H.J. Lu * elf32-sh64.c (elf_backend_section_flags): New. Defined. diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index b7639b7508..710a1a6c28 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -497,13 +497,15 @@ xtensa_read_table_entries (abfd, section, table_p, sec_name) int block_count; bfd_size_type num_records; Elf_Internal_Rela *internal_relocs; + bfd_vma section_addr; table_section_name = xtensa_get_property_section_name (section, sec_name); table_section = bfd_get_section_by_name (abfd, table_section_name); free (table_section_name); if (table_section != NULL) - table_size = bfd_get_section_size_before_reloc (table_section); + table_size = (table_section->_cooked_size + ? table_section->_cooked_size : table_section->_raw_size); if (table_size == 0) { @@ -517,10 +519,12 @@ xtensa_read_table_entries (abfd, section, table_p, sec_name) bfd_malloc (num_records * sizeof (property_table_entry)); block_count = 0; + section_addr = section->output_section->vma + section->output_offset; + /* If the file has not yet been relocated, process the relocations and sort out the table entries that apply to the specified section. */ internal_relocs = retrieve_internal_relocs (abfd, table_section, TRUE); - if (internal_relocs) + if (internal_relocs && !table_section->reloc_done) { unsigned i; @@ -539,7 +543,7 @@ xtensa_read_table_entries (abfd, section, table_p, sec_name) { bfd_vma sym_off = get_elf_r_symndx_offset (abfd, r_symndx); blocks[block_count].address = - (section->vma + sym_off + rel->r_addend + (section_addr + sym_off + rel->r_addend + bfd_get_32 (abfd, table_data + rel->r_offset)); blocks[block_count].size = bfd_get_32 (abfd, table_data + rel->r_offset + 4); @@ -549,16 +553,16 @@ xtensa_read_table_entries (abfd, section, table_p, sec_name) } else { - /* No relocations. Presumably the file has been relocated - and the addresses are already in the table. */ + /* The file has already been relocated and the addresses are + already in the table. */ bfd_vma off; for (off = 0; off < table_size; off += 8) { bfd_vma address = bfd_get_32 (abfd, table_data + off); - if (address >= section->vma - && address < ( section->vma + section->_raw_size)) + if (address >= section_addr + && address < ( section_addr + section->_raw_size)) { blocks[block_count].address = address; blocks[block_count].size = @@ -2044,8 +2048,7 @@ elf_xtensa_relocate_section (output_bfd, info, input_bfd, and not in a literal pool. */ if ((input_section->flags & SEC_READONLY) != 0 && !elf_xtensa_in_literal_pool (lit_table, ltblsize, - input_section->vma - + rel->r_offset)) + outrel.r_offset)) { error_message = _("dynamic relocation in read-only section"); @@ -2145,6 +2148,8 @@ elf_xtensa_relocate_section (output_bfd, info, input_bfd, if (lit_table) free (lit_table); + input_section->reloc_done = TRUE; + return TRUE; } -- 2.11.0