Bug 10373

Summary: SH: ld relaxes jmp to bsr.
Product: binutils Reporter: Takashi YOSHII <yoshii.takashi>
Component: ldAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: bug-binutils, kkojima, olegendo
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target: sh-*-*
Build: Last reconfirmed:
Attachments: test program
patch to fix
testcase patch for ld

Description Takashi YOSHII 2009-07-07 07:41:06 UTC
ld relaxes jmp to bsr which should be bra. Apparently, it doesn't care about
jmp, but just generate bsr for R_SH_USES.
Comment 1 Takashi YOSHII 2009-07-07 07:44:58 UTC
Created attachment 4039 [details]
test program

as -relax jmp.s -o jmp.o; ld -relax jmp.o; objdump -d a.out
You will found "bsr" where "bra" should be.
Comment 2 Takashi YOSHII 2009-07-07 08:03:01 UTC
Created attachment 4040 [details]
patch to fix

Because gcc generates .uses(R_SH_USES) both for jmp and jsr,
1. Gcc should not generate .uses for jmp. or
2. Ld should process both jmp and jsr.
I believe 2 is better.
This patch adds "jmp to bra" process to bfd.
Comment 3 Takashi YOSHII 2009-07-07 08:25:10 UTC
Created attachment 4041 [details]
testcase patch for ld

This patch adds test for "jmp to bra relaxing" to ld's testcase.
Comment 4 Oleg Endo 2014-06-20 22:46:47 UTC
I believe this is a (partial) dup of PR 3298.
Comment 5 Oleg Endo 2014-08-02 15:21:24 UTC
The issue has been fixed on trunk and should be available in the next release that follows binutils 2.24.