* [Buildroot] [PATCH] binutils: fix xtensa gas segfault with --text-section-literals
@ 2015-05-26 8:24 Max Filippov
2015-07-11 10:33 ` Thomas Petazzoni
0 siblings, 1 reply; 2+ messages in thread
From: Max Filippov @ 2015-05-26 8:24 UTC (permalink / raw)
To: buildroot
Building libgcc with TARGET_ABI flags results in assembler segfault on
xtensa, because code in sections .init and .fini emits literals w/o
.literal_position directive. This patch turns the segfault into assembly
error.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
...x-gas-segfault-with-text-section-literals.patch | 56 ++++++++++++++++++++++
...x-gas-segfault-with-text-section-literals.patch | 56 ++++++++++++++++++++++
...x-gas-segfault-with-text-section-literals.patch | 56 ++++++++++++++++++++++
...x-gas-segfault-with-text-section-literals.patch | 56 ++++++++++++++++++++++
4 files changed, 224 insertions(+)
create mode 100644 package/binutils/2.22/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
create mode 100644 package/binutils/2.23.2/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
create mode 100644 package/binutils/2.24/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
create mode 100644 package/binutils/2.25/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
diff --git a/package/binutils/2.22/912-xtensa-fix-gas-segfault-with-text-section-literals.patch b/package/binutils/2.22/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
new file mode 100644
index 0000000..4a3de2c
--- /dev/null
+++ b/package/binutils/2.22/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
@@ -0,0 +1,56 @@
+From 2d0522e76e4afeeb2e104e0a4332d94fa0d2fbf6 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sun, 17 May 2015 06:46:15 +0300
+Subject: [PATCH] xtensa: fix gas segfault with --text-section-literals
+
+When --text-section-literals is used and code in the .init or .fini
+emits literal in the absence of .literal_position, xtensa_move_literals
+segfaults.
+
+Check that search_frag is non-NULL in the xtensa_move_literals and
+report error otherwise.
+
+2015-05-26 Max Filippov <jcmvbkbc@gmail.com>
+gas/
+ * config/tc-xtensa.c (xtensa_move_literals): Check that
+ search_frag is non-NULL. Report error if literal frag is not
+ found.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: 4de0562a4c69fef4952aa7e19d7bda359f02e8b4
+Changes to ChangeLog are dropped.
+
+ gas/config/tc-xtensa.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
+index 31c0b6b..18307c1 100644
+--- a/gas/config/tc-xtensa.c
++++ b/gas/config/tc-xtensa.c
+@@ -10808,13 +10808,21 @@ xtensa_move_literals (void)
+ frchain_to = NULL;
+ frag_splice = &(frchain_from->frch_root);
+
+- while (!search_frag->tc_frag_data.literal_frag)
++ while (search_frag && !search_frag->tc_frag_data.literal_frag)
+ {
+ gas_assert (search_frag->fr_fix == 0
+ || search_frag->fr_type == rs_align);
+ search_frag = search_frag->fr_next;
+ }
+
++ if (!search_frag)
++ {
++ search_frag = frchain_from->frch_root;
++ as_bad_where (search_frag->fr_file, search_frag->fr_line,
++ _("literal pool location required for text-section-literals; specify with .literal_position"));
++ continue;
++ }
++
+ gas_assert (search_frag->tc_frag_data.literal_frag->fr_subtype
+ == RELAX_LITERAL_POOL_BEGIN);
+ xtensa_switch_section_emit_state (&state, segment->seg, 0);
+--
+1.8.1.4
+
diff --git a/package/binutils/2.23.2/912-xtensa-fix-gas-segfault-with-text-section-literals.patch b/package/binutils/2.23.2/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
new file mode 100644
index 0000000..4a3de2c
--- /dev/null
+++ b/package/binutils/2.23.2/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
@@ -0,0 +1,56 @@
+From 2d0522e76e4afeeb2e104e0a4332d94fa0d2fbf6 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sun, 17 May 2015 06:46:15 +0300
+Subject: [PATCH] xtensa: fix gas segfault with --text-section-literals
+
+When --text-section-literals is used and code in the .init or .fini
+emits literal in the absence of .literal_position, xtensa_move_literals
+segfaults.
+
+Check that search_frag is non-NULL in the xtensa_move_literals and
+report error otherwise.
+
+2015-05-26 Max Filippov <jcmvbkbc@gmail.com>
+gas/
+ * config/tc-xtensa.c (xtensa_move_literals): Check that
+ search_frag is non-NULL. Report error if literal frag is not
+ found.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: 4de0562a4c69fef4952aa7e19d7bda359f02e8b4
+Changes to ChangeLog are dropped.
+
+ gas/config/tc-xtensa.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
+index 31c0b6b..18307c1 100644
+--- a/gas/config/tc-xtensa.c
++++ b/gas/config/tc-xtensa.c
+@@ -10808,13 +10808,21 @@ xtensa_move_literals (void)
+ frchain_to = NULL;
+ frag_splice = &(frchain_from->frch_root);
+
+- while (!search_frag->tc_frag_data.literal_frag)
++ while (search_frag && !search_frag->tc_frag_data.literal_frag)
+ {
+ gas_assert (search_frag->fr_fix == 0
+ || search_frag->fr_type == rs_align);
+ search_frag = search_frag->fr_next;
+ }
+
++ if (!search_frag)
++ {
++ search_frag = frchain_from->frch_root;
++ as_bad_where (search_frag->fr_file, search_frag->fr_line,
++ _("literal pool location required for text-section-literals; specify with .literal_position"));
++ continue;
++ }
++
+ gas_assert (search_frag->tc_frag_data.literal_frag->fr_subtype
+ == RELAX_LITERAL_POOL_BEGIN);
+ xtensa_switch_section_emit_state (&state, segment->seg, 0);
+--
+1.8.1.4
+
diff --git a/package/binutils/2.24/912-xtensa-fix-gas-segfault-with-text-section-literals.patch b/package/binutils/2.24/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
new file mode 100644
index 0000000..4a3de2c
--- /dev/null
+++ b/package/binutils/2.24/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
@@ -0,0 +1,56 @@
+From 2d0522e76e4afeeb2e104e0a4332d94fa0d2fbf6 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sun, 17 May 2015 06:46:15 +0300
+Subject: [PATCH] xtensa: fix gas segfault with --text-section-literals
+
+When --text-section-literals is used and code in the .init or .fini
+emits literal in the absence of .literal_position, xtensa_move_literals
+segfaults.
+
+Check that search_frag is non-NULL in the xtensa_move_literals and
+report error otherwise.
+
+2015-05-26 Max Filippov <jcmvbkbc@gmail.com>
+gas/
+ * config/tc-xtensa.c (xtensa_move_literals): Check that
+ search_frag is non-NULL. Report error if literal frag is not
+ found.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: 4de0562a4c69fef4952aa7e19d7bda359f02e8b4
+Changes to ChangeLog are dropped.
+
+ gas/config/tc-xtensa.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
+index 31c0b6b..18307c1 100644
+--- a/gas/config/tc-xtensa.c
++++ b/gas/config/tc-xtensa.c
+@@ -10808,13 +10808,21 @@ xtensa_move_literals (void)
+ frchain_to = NULL;
+ frag_splice = &(frchain_from->frch_root);
+
+- while (!search_frag->tc_frag_data.literal_frag)
++ while (search_frag && !search_frag->tc_frag_data.literal_frag)
+ {
+ gas_assert (search_frag->fr_fix == 0
+ || search_frag->fr_type == rs_align);
+ search_frag = search_frag->fr_next;
+ }
+
++ if (!search_frag)
++ {
++ search_frag = frchain_from->frch_root;
++ as_bad_where (search_frag->fr_file, search_frag->fr_line,
++ _("literal pool location required for text-section-literals; specify with .literal_position"));
++ continue;
++ }
++
+ gas_assert (search_frag->tc_frag_data.literal_frag->fr_subtype
+ == RELAX_LITERAL_POOL_BEGIN);
+ xtensa_switch_section_emit_state (&state, segment->seg, 0);
+--
+1.8.1.4
+
diff --git a/package/binutils/2.25/912-xtensa-fix-gas-segfault-with-text-section-literals.patch b/package/binutils/2.25/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
new file mode 100644
index 0000000..4a3de2c
--- /dev/null
+++ b/package/binutils/2.25/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
@@ -0,0 +1,56 @@
+From 2d0522e76e4afeeb2e104e0a4332d94fa0d2fbf6 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sun, 17 May 2015 06:46:15 +0300
+Subject: [PATCH] xtensa: fix gas segfault with --text-section-literals
+
+When --text-section-literals is used and code in the .init or .fini
+emits literal in the absence of .literal_position, xtensa_move_literals
+segfaults.
+
+Check that search_frag is non-NULL in the xtensa_move_literals and
+report error otherwise.
+
+2015-05-26 Max Filippov <jcmvbkbc@gmail.com>
+gas/
+ * config/tc-xtensa.c (xtensa_move_literals): Check that
+ search_frag is non-NULL. Report error if literal frag is not
+ found.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: 4de0562a4c69fef4952aa7e19d7bda359f02e8b4
+Changes to ChangeLog are dropped.
+
+ gas/config/tc-xtensa.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
+index 31c0b6b..18307c1 100644
+--- a/gas/config/tc-xtensa.c
++++ b/gas/config/tc-xtensa.c
+@@ -10808,13 +10808,21 @@ xtensa_move_literals (void)
+ frchain_to = NULL;
+ frag_splice = &(frchain_from->frch_root);
+
+- while (!search_frag->tc_frag_data.literal_frag)
++ while (search_frag && !search_frag->tc_frag_data.literal_frag)
+ {
+ gas_assert (search_frag->fr_fix == 0
+ || search_frag->fr_type == rs_align);
+ search_frag = search_frag->fr_next;
+ }
+
++ if (!search_frag)
++ {
++ search_frag = frchain_from->frch_root;
++ as_bad_where (search_frag->fr_file, search_frag->fr_line,
++ _("literal pool location required for text-section-literals; specify with .literal_position"));
++ continue;
++ }
++
+ gas_assert (search_frag->tc_frag_data.literal_frag->fr_subtype
+ == RELAX_LITERAL_POOL_BEGIN);
+ xtensa_switch_section_emit_state (&state, segment->seg, 0);
+--
+1.8.1.4
+
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* [Buildroot] [PATCH] binutils: fix xtensa gas segfault with --text-section-literals
2015-05-26 8:24 [Buildroot] [PATCH] binutils: fix xtensa gas segfault with --text-section-literals Max Filippov
@ 2015-07-11 10:33 ` Thomas Petazzoni
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni @ 2015-07-11 10:33 UTC (permalink / raw)
To: buildroot
Dear Max Filippov,
On Tue, 26 May 2015 11:24:00 +0300, Max Filippov wrote:
> Building libgcc with TARGET_ABI flags results in assembler segfault on
> xtensa, because code in sections .init and .fini emits literals w/o
> .literal_position directive. This patch turns the segfault into assembly
> error.
>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
> ...x-gas-segfault-with-text-section-literals.patch | 56 ++++++++++++++++++++++
> ...x-gas-segfault-with-text-section-literals.patch | 56 ++++++++++++++++++++++
> ...x-gas-segfault-with-text-section-literals.patch | 56 ++++++++++++++++++++++
> ...x-gas-segfault-with-text-section-literals.patch | 56 ++++++++++++++++++++++
> 4 files changed, 224 insertions(+)
> create mode 100644 package/binutils/2.22/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
> create mode 100644 package/binutils/2.23.2/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
> create mode 100644 package/binutils/2.24/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
> create mode 100644 package/binutils/2.25/912-xtensa-fix-gas-segfault-with-text-section-literals.patch
Applied, thanks.
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-11 10:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-26 8:24 [Buildroot] [PATCH] binutils: fix xtensa gas segfault with --text-section-literals Max Filippov
2015-07-11 10:33 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox