aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-05 14:18:30 +0000
committerPaul Brook <paul@codesourcery.com>2009-05-05 14:18:30 +0000
commit2468f9c95d416f2880a007190d3bf6c475d279c2 (patch)
treeabc67d2909c8e50810239b241dba5d1021c602d8 /ld/emultempl
parentfb14de7bbddf9dc2f97af953b95b5aa5ea9889c4 (diff)
downloadgdb-2468f9c95d416f2880a007190d3bf6c475d279c2.zip
gdb-2468f9c95d416f2880a007190d3bf6c475d279c2.tar.gz
gdb-2468f9c95d416f2880a007190d3bf6c475d279c2.tar.bz2
2009-05-05 Paul Brook <paul@codesourcery.com>
bfd/ * bfd-in.h (elf32_arm_fix_exidx_coverage): Add prototype. * bfd-in2.h: Regenerate. * elf32-arm.c (arm_unwind_edit_type, arm_unwind_table_edit): Define. (_arm_elf_section_data): Add text and exidx fields. (add_unwind_table_edit, get_arm_elf_section_data, adjust_exidx_size, insert_cantunwind_after, elf32_arm_fix_exidx_coverage, offset_prel31, copy_exidx_entry): New functions. (elf32_arm_write_section): Fixup .ARM.exidx contents. ld/ * emultempl/armelf.em (compare_output_sec_vma): New function. (gld${EMULATION_NAME}_finish): Add exidx munging code. ld/testsuite/ * ld-arm/arm.ld: Add .ARM.exidx and .ARM.extab. * ld-arm/arm-elf.exp: Add unwind-[1-4]. * ld-arm/unwind-1.d: New test. * ld-arm/unwind-1.s: New test. * ld-arm/unwind-2.d: New test. * ld-arm/unwind-2.s: New test. * ld-arm/unwind-3.d: New test. * ld-arm/unwind-3.s: New test. * ld-arm/unwind-4.d: New test. * ld-arm/unwind-4.s: New test.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/armelf.em68
1 files changed, 68 insertions, 0 deletions
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 2f0c3af..2d63a63 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -258,10 +258,78 @@ build_section_lists (lang_statement_union_type *statement)
}
}
+static int
+compare_output_sec_vma (const void *a, const void *b)
+{
+ asection *asec = *(asection **) a, *bsec = *(asection **) b;
+ asection *aout = asec->output_section, *bout = bsec->output_section;
+ bfd_vma avma, bvma;
+
+ /* If there's no output section for some reason, compare equal. */
+ if (!aout || !bout)
+ return 0;
+
+ avma = aout->vma + asec->output_offset;
+ bvma = bout->vma + bsec->output_offset;
+
+ if (avma > bvma)
+ return 1;
+ else if (avma < bvma)
+ return -1;
+
+ return 0;
+}
+
static void
gld${EMULATION_NAME}_finish (void)
{
struct bfd_link_hash_entry * h;
+ unsigned int list_size = 10;
+ asection **sec_list = xmalloc (list_size * sizeof (asection *));
+ unsigned int sec_count = 0;
+
+ if (!link_info.relocatable)
+ {
+ /* Build a sorted list of input text sections, then use that to process
+ the unwind table index. */
+ LANG_FOR_EACH_INPUT_STATEMENT (is)
+ {
+ bfd *abfd = is->the_bfd;
+ asection *sec;
+
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
+ continue;
+
+ for (sec = abfd->sections; sec != NULL; sec = sec->next)
+ {
+ asection *out_sec = sec->output_section;
+
+ if (out_sec
+ && elf_section_type (sec) == SHT_PROGBITS
+ && (elf_section_flags (sec) & SHF_EXECINSTR) != 0
+ && (sec->flags & SEC_EXCLUDE) == 0
+ && sec->sec_info_type != ELF_INFO_TYPE_JUST_SYMS
+ && out_sec != bfd_abs_section_ptr)
+ {
+ if (sec_count == list_size)
+ {
+ list_size *= 2;
+ sec_list = xrealloc (sec_list,
+ list_size * sizeof (asection *));
+ }
+
+ sec_list[sec_count++] = sec;
+ }
+ }
+ }
+
+ qsort (sec_list, sec_count, sizeof (asection *), &compare_output_sec_vma);
+
+ if (elf32_arm_fix_exidx_coverage (sec_list, sec_count, &link_info))
+ need_laying_out = 1;
+
+ free (sec_list);
+ }
/* bfd_elf32_discard_info just plays with debugging sections,
ie. doesn't affect any code, so we can delay resizing the