diff options
author | Yury Usishchev <y.usishchev@samsung.com> | 2015-12-22 15:50:13 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2015-12-22 15:50:13 +0000 |
commit | 491d01d3da18fb61fa6c7c61c091b4cb8c5773f7 (patch) | |
tree | 4f325fdc33925c18aa4db39125a2f91ef8d39e7c /ld | |
parent | 4abd5ed2221c826bcb843794286777452de5c50b (diff) | |
download | gdb-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')
-rw-r--r-- | ld/ChangeLog | 5 | ||||
-rw-r--r-- | ld/emultempl/armelf.em | 73 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 24 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/arm-elf.exp | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/unwind-rel.d | 31 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/unwind-rel1.s | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/unwind-rel2.s | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/unwind-rel3.s | 9 |
8 files changed, 117 insertions, 46 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 576e3dc..a7014d5 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2015-12-22 Yury Usishchev <y.usishchev@samsung.com> + + * emultempl/armelf.em (gld${EMULATION_NAME}_after_allocation): Call + elf32_arm_fix_exidx_coverage for relocatable builds. + 2015-12-10 Kwok Cheung Yeung <kcy@codesourcery.com> PR ld/18199 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 diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index d5982b9..d8b2d3c 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,14 +1,22 @@ +2015-12-21 Yury Usishchev <y.usishchev@samsung.com> + + * 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. + 2015-12-22 Mickael Guene <mickael.guene@st.com> * ld-arm/arm-elf.exp: New tests. - * ld-arm/thumb1-input-section-flag-match.d: New - * ld-arm/thumb1-input-section-flag-match.s: New - * ld-arm/thumb1-noread-not-present-mixing-two-section.d: New - * ld-arm/thumb1-noread-not-present-mixing-two-section.s: New - * ld-arm/thumb1-noread-present-one-section.d: New - * ld-arm/thumb1-noread-present-one-section.s: New - * ld-arm/thumb1-noread-present-two-section.d: New - * ld-arm/thumb1-noread-present-two-section.s: New + * ld-arm/thumb1-input-section-flag-match.d: New. + * ld-arm/thumb1-input-section-flag-match.s: New. + * ld-arm/thumb1-noread-not-present-mixing-two-section.d: New. + * ld-arm/thumb1-noread-not-present-mixing-two-section.s: New. + * ld-arm/thumb1-noread-present-one-section.d: New. + * ld-arm/thumb1-noread-present-one-section.s: New. + * ld-arm/thumb1-noread-present-two-section.d: New. + * ld-arm/thumb1-noread-present-two-section.s: New. 2015-12-16 Mickael Guene <mickael.guene@st.com> diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index a970dba..ac2abf1 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -941,3 +941,9 @@ run_dump_test "gc-hidden-1" run_dump_test "protected-data" run_dump_test "stm32l4xx-cannot-fix-it-block" run_dump_test "stm32l4xx-cannot-fix-far-ldm" +set arm_unwind_tests { + {"unwind-rel" "-r -Tarm.ld" "" "" {unwind-rel1.s unwind-rel2.s unwind-rel3.s} + {{readelf -ur unwind-rel.d}} + "unwind-rel"} +} +run_ld_link_tests $arm_unwind_tests diff --git a/ld/testsuite/ld-arm/unwind-rel.d b/ld/testsuite/ld-arm/unwind-rel.d new file mode 100644 index 0000000..b2aa6e2 --- /dev/null +++ b/ld/testsuite/ld-arm/unwind-rel.d @@ -0,0 +1,31 @@ + +Relocation section '\.rel\.text' at offset .* contains 3 entries: + Offset Info Type Sym\.Value Sym\. Name +00000000 00000028 R_ARM_V4BX +00000004 00000028 R_ARM_V4BX +00000008 00000028 R_ARM_V4BX + +Relocation section '\.rel\.ARM\.exidx' at offset .* contains 5 entries: + Offset Info Type Sym\.Value Sym\. Name +00000000 0000012a R_ARM_PREL31 00000000 \.text +00000000 00000e00 R_ARM_NONE 00000000 __aeabi_unwind_cpp_pr0 +00000008 0000012a R_ARM_PREL31 00000000 \.text +00000010 0000012a R_ARM_PREL31 00000000 \.text +00000010 00000e00 R_ARM_NONE 00000000 __aeabi_unwind_cpp_pr0 + +Unwind table index '\.ARM\.exidx' at offset .* contains 3 entries: + +0x0: 0x80a8b0b0 + Compact model index: 0 + 0xa8 pop {r4, r14} + 0xb0 finish + 0xb0 finish + +0x4 <test>: 0x1 \[cantunwind\] + +0x8 <end>: 0x80a8b0b0 + Compact model index: 0 + 0xa8 pop {r4, r14} + 0xb0 finish + 0xb0 finish + diff --git a/ld/testsuite/ld-arm/unwind-rel1.s b/ld/testsuite/ld-arm/unwind-rel1.s new file mode 100644 index 0000000..9efb78b --- /dev/null +++ b/ld/testsuite/ld-arm/unwind-rel1.s @@ -0,0 +1,9 @@ + .syntax unified + .text + .global _start + .type _start, %function +_start: + .fnstart + .save {r4, lr} + bx lr + .fnend diff --git a/ld/testsuite/ld-arm/unwind-rel2.s b/ld/testsuite/ld-arm/unwind-rel2.s new file mode 100644 index 0000000..1001743 --- /dev/null +++ b/ld/testsuite/ld-arm/unwind-rel2.s @@ -0,0 +1,6 @@ + .syntax unified + .text + .global test + .type test, %function +test: + bx lr diff --git a/ld/testsuite/ld-arm/unwind-rel3.s b/ld/testsuite/ld-arm/unwind-rel3.s new file mode 100644 index 0000000..8511339 --- /dev/null +++ b/ld/testsuite/ld-arm/unwind-rel3.s @@ -0,0 +1,9 @@ + .syntax unified + .text + .global end + .type end, %function +end: + .fnstart + .save {r4, lr} + bx lr + .fnend |