Skip to content

Commit 2487ef0

Browse files
committed
bfd: xtensa: fix shrink_dynamic_reloc_sections for export-dynamic
shrink_dynamic_reloc_sections must remove PLT entry that was created for an undefined weak symbol in the presence of --export-dynamic option when relaxation coalesces literals pointing to that symbol. This fixes the following assertion: ld: BFD (GNU Binutils) 2.31.1 internal error, aborting at elf32-xtensa.c:3292 in elf_xtensa_finish_dynamic_sections 2019-03-29 Max Filippov <jcmvbkbc@gmail.com> bfd/ * elf32-xtensa.c (shrink_dynamic_reloc_sections): Add info->export_dynamic to the conditional. ld/ * testsuite/ld-xtensa/relax-undef-weak-pie-export-dynamic.d: New test definition. * testsuite/ld-xtensa/xtensa.exp (relax-undef-weak-pie-export-dynamic): Add new test.
1 parent 5f33607 commit 2487ef0

5 files changed

Lines changed: 29 additions & 1 deletion

File tree

bfd/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019-03-29 Max Filippov <jcmvbkbc@gmail.com>
2+
3+
* elf32-xtensa.c (shrink_dynamic_reloc_sections): Add
4+
info->export_dynamic to the conditional.
5+
16
2019-03-28 Alan Modra <amodra@gmail.com>
27

38
PR 24392

bfd/elf32-xtensa.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10083,7 +10083,8 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
1008310083
&& (input_section->flags & SEC_ALLOC) != 0
1008410084
&& (dynamic_symbol || bfd_link_pic (info))
1008510085
&& (!h || h->root.type != bfd_link_hash_undefweak
10086-
|| (dynamic_symbol && bfd_link_dll (info))))
10086+
|| (dynamic_symbol
10087+
&& (bfd_link_dll (info) || info->export_dynamic))))
1008710088
{
1008810089
asection *srel;
1008910090
bfd_boolean is_plt = FALSE;

ld/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2019-03-29 Max Filippov <jcmvbkbc@gmail.com>
2+
3+
* testsuite/ld-xtensa/relax-undef-weak-pie-export-dynamic.d: New
4+
test definition.
5+
* testsuite/ld-xtensa/xtensa.exp
6+
(relax-undef-weak-pie-export-dynamic): Add new test.
7+
18
2019-03-26 Martin Liska <mliska@suse.cz>
29

310
* plugin.c (get_symbols): Add lto_kind_str, lto_resolution_str,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#source: relax-undef-weak.s
2+
#ld: -pie --export-dynamic
3+
#readelf: -r
4+
#...
5+
Relocation section '\.rela\.dyn' .* 3 .*
6+
#...
7+
.*R_XTENSA_RTLD.*
8+
.*R_XTENSA_RTLD.*
9+
.*R_XTENSA_GLOB_DAT.*fd.*
10+
#...
11+
Relocation section '\.rela\.plt' .* 1 .*
12+
#...
13+
.*R_XTENSA_JMP_SLOT.*fd.*
14+
#...

ld/testsuite/ld-xtensa/xtensa.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ run_dump_test "relax-static-shared"
3434
run_dump_test "relax-static-local-shared"
3535

3636
run_dump_test "relax-undef-weak-pie"
37+
run_dump_test "relax-undef-weak-pie-export-dynamic"
3738
run_dump_test "relax-undef-weak-local-pie"
3839
run_dump_test "relax-undef-weak-shared"
3940
run_dump_test "relax-undef-weak-local-shared"

0 commit comments

Comments
 (0)