Skip to content

Commit 88eff22

Browse files
jcmvbkbcjacmet
authored andcommitted
package/binutils: fix loops relaxation in bare sections
The commit 197b5f9 ("package/binutils: fix loops relaxation in xtensa gas") changed the way loop opcodes are relaxed resulting in build failures in hand-made assembly code that has loops in sections without .literal_position pseudo op or equivalent construct. This e.g. breaks xtensa linux kernel build. Fix that by adding literal position to the beginning of every section. Fixes: 197b5f9 ("package/binutils: fix loops relaxation in xtensa gas") Signed-off-by: Max Filippov <[email protected]> Signed-off-by: Thomas Petazzoni <[email protected]> (cherry picked from commit de1d157) [Peter: drop 2.32 patch] Signed-off-by: Peter Korsgaard <[email protected]>
1 parent c0ce796 commit 88eff22

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
From 471702ac4a57878a06e8167f063274cf413e548d Mon Sep 17 00:00:00 2001
2+
From: Max Filippov <[email protected]>
3+
Date: Mon, 8 Apr 2019 13:47:18 -0700
4+
Subject: [PATCH] xtensa: gas: put .literal_position at section start
5+
6+
Provide literal position at the beginning of each section for literal
7+
space reserved by relaxations when text-section-literals or
8+
auto-litpools options are used. Remove code that adds fill frag to the
9+
literal section for every .literal_position directive to avoid creation
10+
of empty literal sections.
11+
12+
Fix auto-litpools tests that got literal pool address changes.
13+
14+
gas/
15+
2019-04-11 Max Filippov <[email protected]>
16+
17+
* config/tc-xtensa.c (xtensa_is_init_fini): Add declaration.
18+
(xtensa_mark_literal_pool_location): Don't add fill frag to literal
19+
section that records literal pool location.
20+
(md_begin): Call xtensa_mark_literal_pool_location when text
21+
section literals or auto litpools are used.
22+
(xtensa_elf_section_change_hook): Call
23+
xtensa_mark_literal_pool_location when text section literals or
24+
auto litpools are used, there's no literal pool location defined
25+
for the current section and it's not .init or .fini.
26+
27+
Signed-off-by: Max Filippov <[email protected]>
28+
---
29+
gas/config/tc-xtensa.c | 22 +++++++++-------------
30+
1 file changed, 9 insertions(+), 13 deletions(-)
31+
32+
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
33+
index 0cc06361cf6f..6a80e76fed8c 100644
34+
--- a/gas/config/tc-xtensa.c
35+
+++ b/gas/config/tc-xtensa.c
36+
@@ -497,6 +497,7 @@ static fixS *xg_append_jump (fragS *fragP, symbolS *sym, offsetT offset);
37+
static void xtensa_maybe_create_literal_pool_frag (bfd_boolean, bfd_boolean);
38+
static bfd_boolean auto_litpools = FALSE;
39+
static int auto_litpool_limit = 0;
40+
+static bfd_boolean xtensa_is_init_fini (segT seg);
41+
42+
/* Alignment Functions. */
43+
44+
@@ -4797,7 +4798,6 @@ xtensa_mark_literal_pool_location (void)
45+
{
46+
/* Any labels pointing to the current location need
47+
to be adjusted to after the literal pool. */
48+
- emit_state s;
49+
fragS *pool_location;
50+
51+
if (use_literal_section)
52+
@@ -4818,19 +4818,7 @@ xtensa_mark_literal_pool_location (void)
53+
RELAX_LITERAL_POOL_END, NULL, 0, NULL);
54+
xtensa_set_frag_assembly_state (frag_now);
55+
56+
- /* Now put a frag into the literal pool that points to this location. */
57+
set_literal_pool_location (now_seg, pool_location);
58+
- xtensa_switch_to_non_abs_literal_fragment (&s);
59+
- frag_align (2, 0, 0);
60+
- record_alignment (now_seg, 2);
61+
-
62+
- /* Close whatever frag is there. */
63+
- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL);
64+
- xtensa_set_frag_assembly_state (frag_now);
65+
- frag_now->tc_frag_data.literal_frag = pool_location;
66+
- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL);
67+
- xtensa_restore_emit_state (&s);
68+
- xtensa_set_frag_assembly_state (frag_now);
69+
}
70+
71+
72+
@@ -5334,6 +5322,9 @@ md_begin (void)
73+
/* Set up the assembly state. */
74+
if (!frag_now->tc_frag_data.is_assembly_state_set)
75+
xtensa_set_frag_assembly_state (frag_now);
76+
+
77+
+ if (!use_literal_section)
78+
+ xtensa_mark_literal_pool_location ();
79+
}
80+
81+
82+
@@ -5933,6 +5924,11 @@ xtensa_elf_section_change_hook (void)
83+
/* Set up the assembly state. */
84+
if (!frag_now->tc_frag_data.is_assembly_state_set)
85+
xtensa_set_frag_assembly_state (frag_now);
86+
+
87+
+ if (!use_literal_section
88+
+ && seg_info (now_seg)->tc_segment_info_data.literal_pool_loc == NULL
89+
+ && !xtensa_is_init_fini (now_seg))
90+
+ xtensa_mark_literal_pool_location ();
91+
}
92+
93+
94+
--
95+
2.11.0
96+

0 commit comments

Comments
 (0)