[v2] gas: xtensa: fix trampoline placement

Message ID 1518455417-26563-1-git-send-email-jcmvbkbc@gmail.com
State New
Headers show
Series
  • [v2] gas: xtensa: fix trampoline placement
Related show

Commit Message

Max Filippov Feb. 12, 2018, 5:10 p.m.
For jumps requiring multiple trampolines trampoline placement code may
place multiple sequential trampolines into the same frag. Don't do that.

gas/
2018-02-10  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (xg_find_best_trampoline): Skip trampoline
	frag that contains source address.
---
Changes v1->v2:
- change code formatting according to GNU coding standard

 gas/config/tc-xtensa.c | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
2.1.4

Comments

Nick Clifton Feb. 13, 2018, 8:19 a.m. | #1
Hi Max,

> gas/

> 2018-02-10  Max Filippov  <jcmvbkbc@gmail.com>

> 

> 	* config/tc-xtensa.c (xg_find_best_trampoline): Skip trampoline

> 	frag that contains source address.


Approved - please apply.

Cheers
  Nick
Max Filippov Feb. 13, 2018, 5:36 p.m. | #2
On Tue, Feb 13, 2018 at 12:19 AM, Nick Clifton <nickc@redhat.com> wrote:
> Hi Max,

>

>> gas/

>> 2018-02-10  Max Filippov  <jcmvbkbc@gmail.com>

>>

>>       * config/tc-xtensa.c (xg_find_best_trampoline): Skip trampoline

>>       frag that contains source address.

>

> Approved - please apply.


Thanks, applied to master.
I'd also like to apply it to the 2.30 branch, is it OK?

-- 
Thanks.
-- Max
Nick Clifton Feb. 14, 2018, 9:32 a.m. | #3
Hi Max,

>>>       * config/tc-xtensa.c (xg_find_best_trampoline): Skip trampoline

>>>       frag that contains source address.

>>

>> Approved - please apply.

> 

> Thanks, applied to master.

> I'd also like to apply it to the 2.30 branch, is it OK?


That is fine, please go ahead.

Cheers
  Nick
Max Filippov Feb. 14, 2018, 5:04 p.m. | #4
On Wed, Feb 14, 2018 at 1:32 AM, Nick Clifton <nickc@redhat.com> wrote:
>>>>       * config/tc-xtensa.c (xg_find_best_trampoline): Skip trampoline

>>>>       frag that contains source address.

>>>

>>> Approved - please apply.

>>

>> Thanks, applied to master.

>> I'd also like to apply it to the 2.30 branch, is it OK?

>

> That is fine, please go ahead.


Thanks, applied.

-- Max

Patch

diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 58c2e10c1878..b522447b5131 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -9339,6 +9339,12 @@  static size_t xg_find_best_trampoline (struct trampoline_index *idx,
 		 trampoline_frag->fr_address > target))
 	      continue;
 
+	    /* Don't choose trampoline that contains the source.  */
+	    if (source >= trampoline_frag->fr_address
+		&& source <= trampoline_frag->fr_address +
+		trampoline_frag->fr_fix)
+	      continue;
+
 	    off = trampoline_frag->fr_address - fulcrum;
 	    /* Stop if some trampoline is found and the search is more than
 	       J_RANGE / 4 from the projected fulcrum.  A trampoline w/o jump