binutils: fix xtensa gas segfault with --text-section-literals
[buildroot-gz.git] / package / binutils / 2.22 / 912-xtensa-fix-gas-segfault-with-text-section-literals.patch
blob4a3de2c839a9d317c8e74e40976006b6e3a89625
1 From 2d0522e76e4afeeb2e104e0a4332d94fa0d2fbf6 Mon Sep 17 00:00:00 2001
2 From: Max Filippov <jcmvbkbc@gmail.com>
3 Date: Sun, 17 May 2015 06:46:15 +0300
4 Subject: [PATCH] xtensa: fix gas segfault with --text-section-literals
6 When --text-section-literals is used and code in the .init or .fini
7 emits literal in the absence of .literal_position, xtensa_move_literals
8 segfaults.
10 Check that search_frag is non-NULL in the xtensa_move_literals and
11 report error otherwise.
13 2015-05-26 Max Filippov <jcmvbkbc@gmail.com>
14 gas/
15 * config/tc-xtensa.c (xtensa_move_literals): Check that
16 search_frag is non-NULL. Report error if literal frag is not
17 found.
19 Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
20 ---
21 Backported from: 4de0562a4c69fef4952aa7e19d7bda359f02e8b4
22 Changes to ChangeLog are dropped.
24 gas/config/tc-xtensa.c | 10 +++++++++-
25 1 file changed, 9 insertions(+), 1 deletion(-)
27 diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
28 index 31c0b6b..18307c1 100644
29 --- a/gas/config/tc-xtensa.c
30 +++ b/gas/config/tc-xtensa.c
31 @@ -10808,13 +10808,21 @@ xtensa_move_literals (void)
32 frchain_to = NULL;
33 frag_splice = &(frchain_from->frch_root);
35 - while (!search_frag->tc_frag_data.literal_frag)
36 + while (search_frag && !search_frag->tc_frag_data.literal_frag)
38 gas_assert (search_frag->fr_fix == 0
39 || search_frag->fr_type == rs_align);
40 search_frag = search_frag->fr_next;
43 + if (!search_frag)
44 + {
45 + search_frag = frchain_from->frch_root;
46 + as_bad_where (search_frag->fr_file, search_frag->fr_line,
47 + _("literal pool location required for text-section-literals; specify with .literal_position"));
48 + continue;
49 + }
51 gas_assert (search_frag->tc_frag_data.literal_frag->fr_subtype
52 == RELAX_LITERAL_POOL_BEGIN);
53 xtensa_switch_section_emit_state (&state, segment->seg, 0);
54 --
55 1.8.1.4