1 From 415480d6471e67aef97c0241d451ef2423a1da9d Mon Sep 17 00:00:00 2001
2 From: Max Filippov <jcmvbkbc@gmail.com>
3 Date: Tue, 25 Nov 2014 21:33:21 +0300
4 Subject: [PATCH] Fix trampolines search code for conditional branches
6 For conditional branches that need more than one trampoline to reach its
7 target assembler couldn't always find suitable trampoline because
8 post-loop condition check was placed inside the loop, resulting in
9 premature loop termination. Move check outside the loop.
11 This fixes the following build errors seen when assembling huge files
13 Error: jump target out of range; no usable trampoline found
14 Error: operand 1 of 'j' has out of range value '307307'
16 2014-11-25 Max Filippov <jcmvbkbc@gmail.com>
19 * config/tc-xtensa.c (search_trampolines): Move post-loop
20 condition check outside the search loop.
23 * gas/xtensa/trampoline.d: Add expected output for branches.
24 * gas/xtensa/trampoline.s: Add test case for branches.
26 Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
28 Backported from: d92b6eece424f0ad35d96fdd85bf207295e8c4c3
29 Changes to ChangeLogs are dropped.
31 gas/config/tc-xtensa.c | 8 ++++----
32 gas/testsuite/gas/xtensa/trampoline.d | 9 +++++++++
33 gas/testsuite/gas/xtensa/trampoline.s | 7 +++++++
34 3 files changed, 20 insertions(+), 4 deletions(-)
36 diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
37 index d11b0c7..f23ccf8 100644
38 --- a/gas/config/tc-xtensa.c
39 +++ b/gas/config/tc-xtensa.c
40 @@ -9514,11 +9514,11 @@ search_trampolines (TInsn *tinsn, fragS *fragP, bfd_boolean unreachable_only)
41 if (next_addr == 0 || addr - next_addr > J_RANGE)
44 - if (abs (addr - this_addr) < J_RANGE)
49 + if (abs (addr - this_addr) < J_RANGE)
54 for ( ; tf; tf = tf->next)
56 diff --git a/gas/testsuite/gas/xtensa/trampoline.d b/gas/testsuite/gas/xtensa/trampoline.d
57 index b4f65dc..5ae32a6 100644
58 --- a/gas/testsuite/gas/xtensa/trampoline.d
59 +++ b/gas/testsuite/gas/xtensa/trampoline.d
64 +.*4940a:.*beqz.n.a2,.0x4940f
73 diff --git a/gas/testsuite/gas/xtensa/trampoline.s b/gas/testsuite/gas/xtensa/trampoline.s
74 index 259a3bb..4465786 100644
75 --- a/gas/testsuite/gas/xtensa/trampoline.s
76 +++ b/gas/testsuite/gas/xtensa/trampoline.s