aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/armelf.em
diff options
context:
space:
mode:
authorYury Usishchev <y.usishchev@samsung.com>2015-12-22 15:50:13 +0000
committerNick Clifton <nickc@redhat.com>2015-12-22 15:50:13 +0000
commit491d01d3da18fb61fa6c7c61c091b4cb8c5773f7 (patch)
tree4f325fdc33925c18aa4db39125a2f91ef8d39e7c /ld/emultempl/armelf.em
parent4abd5ed2221c826bcb843794286777452de5c50b (diff)
downloadgdb-491d01d3da18fb61fa6c7c61c091b4cb8c5773f7.zip
gdb-491d01d3da18fb61fa6c7c61c091b4cb8c5773f7.tar.gz
gdb-491d01d3da18fb61fa6c7c61c091b4cb8c5773f7.tar.bz2
ARM: Fix exidx coverage for relocatable builds.
bfd * elf-bfd.h: Add callback to count additional relocations. * elf32-arm.c (_arm_elf_section_data): Add new counter. (insert_cantunwind_after): Increment relocations counter. (elf32_arm_fix_exidx_coverage): Remove exidx entries and add terminating CANTUNWIND entry only in final builds. (elf32_arm_add_relocation): New function. (elf32_arm_write_section): Add relocations in relocatable builds. (elf32_arm_count_additional_relocs): New function. (elf_backend_count_additional_relocs): New define. * bfd/elflink.c (bfd_elf_final_link): Use callback and adjust size of .rel section. * bfd/elfxx-target.h (elf_backend_count_additional_relocs): New define. ld * emultempl/armelf.em (gld${EMULATION_NAME}_after_allocation): Call elf32_arm_fix_exidx_coverage for relocatable builds. ld/testsuite * ld-arm/arm-elf.exp: New test. * ld-arm/unwind-rel.d: New file. * ld-arm/unwind-rel1.s: New file. * ld-arm/unwind-rel2.s: New file. * ld-arm/unwind-rel3.s: New file.
Diffstat (limited to 'ld/emultempl/armelf.em')
-rw-r--r--ld/emultempl/armelf.em73
1 files changed, 35 insertions, 38 deletions
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 2931a49..aae45d1 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -293,55 +293,52 @@ gld${EMULATION_NAME}_after_allocation (void)
{
int ret;
- if (!bfd_link_relocatable (&link_info))
+ /* Build a sorted list of input text sections, then use that to process
+ the unwind table index. */
+ unsigned int list_size = 10;
+ asection **sec_list = (asection **)
+ xmalloc (list_size * sizeof (asection *));
+ unsigned int sec_count = 0;
+
+ LANG_FOR_EACH_INPUT_STATEMENT (is)
{
- /* Build a sorted list of input text sections, then use that to process
- the unwind table index. */
- unsigned int list_size = 10;
- asection **sec_list = (asection **)
- xmalloc (list_size * sizeof (asection *));
- unsigned int sec_count = 0;
+ bfd *abfd = is->the_bfd;
+ asection *sec;
- LANG_FOR_EACH_INPUT_STATEMENT (is)
- {
- bfd *abfd = is->the_bfd;
- asection *sec;
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
+ continue;
- if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
- continue;
-
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
+ for (sec = abfd->sections; sec != NULL; sec = sec->next)
+ {
+ asection *out_sec = sec->output_section;
+
+ if (out_sec
+ && elf_section_data (sec)
+ && elf_section_type (sec) == SHT_PROGBITS
+ && (elf_section_flags (sec) & SHF_EXECINSTR) != 0
+ && (sec->flags & SEC_EXCLUDE) == 0
+ && sec->sec_info_type != SEC_INFO_TYPE_JUST_SYMS
+ && out_sec != bfd_abs_section_ptr)
{
- asection *out_sec = sec->output_section;
-
- if (out_sec
- && elf_section_data (sec)
- && elf_section_type (sec) == SHT_PROGBITS
- && (elf_section_flags (sec) & SHF_EXECINSTR) != 0
- && (sec->flags & SEC_EXCLUDE) == 0
- && sec->sec_info_type != SEC_INFO_TYPE_JUST_SYMS
- && out_sec != bfd_abs_section_ptr)
+ if (sec_count == list_size)
{
- if (sec_count == list_size)
- {
- list_size *= 2;
- sec_list = (asection **)
- xrealloc (sec_list, list_size * sizeof (asection *));
- }
-
- sec_list[sec_count++] = sec;
+ list_size *= 2;
+ sec_list = (asection **)
+ xrealloc (sec_list, list_size * sizeof (asection *));
}
+
+ sec_list[sec_count++] = sec;
}
}
+ }
- qsort (sec_list, sec_count, sizeof (asection *), &compare_output_sec_vma);
+ qsort (sec_list, sec_count, sizeof (asection *), &compare_output_sec_vma);
- if (elf32_arm_fix_exidx_coverage (sec_list, sec_count, &link_info,
- merge_exidx_entries))
- need_laying_out = 1;
+ if (elf32_arm_fix_exidx_coverage (sec_list, sec_count, &link_info,
+ merge_exidx_entries))
+ need_laying_out = 1;
- free (sec_list);
- }
+ free (sec_list);
/* bfd_elf32_discard_info just plays with debugging sections,
ie. doesn't affect any code, so we can delay resizing the