From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2124) id 5C46E3858C5E; Thu, 23 Feb 2023 10:48:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C46E3858C5E Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Clifton To: bfd-cvs@sourceware.org Subject: [binutils-gdb] bfd: xtensa: fix __stop_SECTION literal drop X-Act-Checkin: binutils-gdb X-Git-Author: Alexey Lapshin X-Git-Refname: refs/heads/master X-Git-Oldrev: e0b74a85b879354d2aa1a6b5026d5de58c78ec45 X-Git-Newrev: d273049e140ef324be2b018e235ae0ba8021a769 Message-Id: <20230223104842.5C46E3858C5E@sourceware.org> Date: Thu, 23 Feb 2023 10:48:42 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2023 10:48:42 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd273049e140e= f324be2b018e235ae0ba8021a769 commit d273049e140ef324be2b018e235ae0ba8021a769 Author: Alexey Lapshin Date: Thu Feb 23 10:48:16 2023 +0000 bfd: xtensa: fix __stop_SECTION literal drop Diff: --- bfd/elf32-xtensa.c | 7 +++++++ ld/testsuite/ld- | 6 ++++++ ld/testsuite/ld-xtensa/startstop.d | 6 ++++++ ld/testsuite/ld-xtensa/startstop.s | 16 ++++++++++++++++ ld/testsuite/ld-xtensa/xtensa.exp | 2 ++ 5 files changed, 37 insertions(+) diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 84ff9004433..7772e2a5f90 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -5230,6 +5230,13 @@ literal_value_equal (const literal_value *src1, (if undefined or weak). */ h1 =3D r_reloc_get_hash_entry (&src1->r_rel); h2 =3D r_reloc_get_hash_entry (&src2->r_rel); + + /* Keep start_stop literals always unique to avoid dropping it due to th= em + having late initialization. + Now they are equal because initialized with zeroed values. */ + if (h2 && h2->start_stop) + return false; + if (r_reloc_is_defined (&src1->r_rel) && (final_static_link || ((!h1 || h1->root.type !=3D bfd_link_hash_defweak) diff --git a/ld/testsuite/ld- b/ld/testsuite/ld- new file mode 100644 index 00000000000..6cea49add33 --- /dev/null +++ b/ld/testsuite/ld- @@ -0,0 +1,6 @@ +#as: +#ld: +#objdump: -h +#... +.*TEST_SECTION\.literal[ ]*00000008.* +#... diff --git a/ld/testsuite/ld-xtensa/startstop.d b/ld/testsuite/ld-xtensa/st= artstop.d new file mode 100644 index 00000000000..6cea49add33 --- /dev/null +++ b/ld/testsuite/ld-xtensa/startstop.d @@ -0,0 +1,6 @@ +#as: +#ld: +#objdump: -h +#... +.*TEST_SECTION\.literal[ ]*00000008.* +#... diff --git a/ld/testsuite/ld-xtensa/startstop.s b/ld/testsuite/ld-xtensa/st= artstop.s new file mode 100644 index 00000000000..b94b0ec573c --- /dev/null +++ b/ld/testsuite/ld-xtensa/startstop.s @@ -0,0 +1,16 @@ + .file "startstop.s" + .text + .section .rodata + .align 4 +.LC0: + .section TEST_SECTION,"aw" + .align 4 + .literal_position + .literal .LC1, __start_TEST_SECTION + .literal .LC2, __stop_TEST_SECTION + .align 4 + .global _start + .type _start, @function +_start: + l32r a2, .LC1 + l32r a3, .LC2 diff --git a/ld/testsuite/ld-xtensa/xtensa.exp b/ld/testsuite/ld-xtensa/xte= nsa.exp index e671cabae4a..9af59f9fc5a 100644 --- a/ld/testsuite/ld-xtensa/xtensa.exp +++ b/ld/testsuite/ld-xtensa/xtensa.exp @@ -41,3 +41,5 @@ run_dump_test "relax-undef-weak-pie-export-dynamic" run_dump_test "relax-undef-weak-local-pie" run_dump_test "relax-undef-weak-shared" run_dump_test "relax-undef-weak-local-shared" + +run_dump_test "startstop"