* [PATCH] bfd: xtensa: fix __stop_SECTION literal drop,
@ 2022-10-04 16:22 Alexey Lapshin
2022-10-05 11:15 ` Nick Clifton
2023-05-24 11:38 ` Andreas Schwab
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Lapshin @ 2022-10-04 16:22 UTC (permalink / raw)
To: binutils; +Cc: Alexey Gerenkov, Anton Maklakov, Ivan Grokhotkov
From b5cdb6b44dfd6d36608f63e8795cd669da97a123 Mon Sep 17 00:00:00 2001
From: Alexey Lapshin <alexey.lapshin@espressif.com>
Date: Wed, 3 Aug 2022 18:45:39 +0400
Subject: [PATCH] bfd: xtensa: fix __stop_SECTION literal drop
Literals placement algorithm may drop __stop_SECTION symbol as
duplicated because it is not initialized yet and we can not differ it
from __start_SECTION symbol at this stage. Both symbols will be
initialized a bit later.
This workaround prevented start_stop symbols from equality in compare
function
---
bfd/elf32-xtensa.c | 7 +++++++
ld/testsuite/ld-xtensa/startstop.d | 6 ++++++
ld/testsuite/ld-xtensa/startstop.s | 16 ++++++++++++++++
ld/testsuite/ld-xtensa/xtensa.exp | 2 ++
4 files changed, 31 insertions(+)
create mode 100644 ld/testsuite/ld-xtensa/startstop.d
create mode 100644 ld/testsuite/ld-xtensa/startstop.s
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index ce3c46f69e5..cb658483ca6 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -5244,6 +5244,13 @@ literal_value_equal (const literal_value *src1,
(if undefined or weak). */
h1 = r_reloc_get_hash_entry (&src1->r_rel);
h2 = r_reloc_get_hash_entry (&src2->r_rel);
+
+ /* Keep start_stop literals always unique to avoid dropping it due
to they
+ have 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 != bfd_link_hash_defweak)
diff --git a/ld/testsuite/ld-xtensa/startstop.d b/ld/testsuite/ld-
xtensa/startstop.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/startstop.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/xtensa.exp
index 71d1597fc72..c09b865f2b4 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"
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bfd: xtensa: fix __stop_SECTION literal drop,
2022-10-04 16:22 [PATCH] bfd: xtensa: fix __stop_SECTION literal drop, Alexey Lapshin
@ 2022-10-05 11:15 ` Nick Clifton
2023-05-24 11:38 ` Andreas Schwab
1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2022-10-05 11:15 UTC (permalink / raw)
To: Alexey Lapshin, binutils; +Cc: Ivan Grokhotkov, Alexey Gerenkov, Anton Maklakov
Hi Alexey,
> Literals placement algorithm may drop __stop_SECTION symbol as
> duplicated because it is not initialized yet and we can not differ it
> from __start_SECTION symbol at this stage. Both symbols will be
> initialized a bit later.
> This workaround prevented start_stop symbols from equality in compare
> function
> ---
> bfd/elf32-xtensa.c | 7 +++++++
> ld/testsuite/ld-xtensa/startstop.d | 6 ++++++
> ld/testsuite/ld-xtensa/startstop.s | 16 ++++++++++++++++
> ld/testsuite/ld-xtensa/xtensa.exp | 2 ++
Patch approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bfd: xtensa: fix __stop_SECTION literal drop,
2022-10-04 16:22 [PATCH] bfd: xtensa: fix __stop_SECTION literal drop, Alexey Lapshin
2022-10-05 11:15 ` Nick Clifton
@ 2023-05-24 11:38 ` Andreas Schwab
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2023-05-24 11:38 UTC (permalink / raw)
To: Alexey Lapshin via Binutils
Cc: Alexey Lapshin, Ivan Grokhotkov, Alexey Gerenkov, Anton Maklakov
Installed as obvious.
diff --git a/ld/testsuite/ld- b/ld/testsuite/ld-
deleted file mode 100644
index 6cea49add33..00000000000
--- a/ld/testsuite/ld-
+++ /dev/null
@@ -1,6 +0,0 @@
-#as:
-#ld:
-#objdump: -h
-#...
-.*TEST_SECTION\.literal[ ]*00000008.*
-#...
--
2.40.1
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-24 11:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 16:22 [PATCH] bfd: xtensa: fix __stop_SECTION literal drop, Alexey Lapshin
2022-10-05 11:15 ` Nick Clifton
2023-05-24 11:38 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).