Bug 10378 - SH: jump table for switch/case got invalid adjustment during relaxing.
Summary: SH: jump table for switch/case got invalid adjustment during relaxing.
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-08 05:56 UTC by Takashi YOSHII
Modified: 2014-08-02 15:21 UTC (History)
3 users (show)

See Also:
Host:
Target: sh
Build:
Last reconfirmed:


Attachments
test program (104 bytes, text/plain)
2009-07-08 06:03 UTC, Takashi YOSHII
Details
patch to fix (1.04 KB, patch)
2009-07-08 06:38 UTC, Takashi YOSHII
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Takashi YOSHII 2009-07-08 05:56:49 UTC
R_SH_SWITCH8(.byte Label2-Label1) can be alterd if codes between two labels got
shorter by relaxing. But currently the adjustment value seems to be bad.
Comment 1 Takashi YOSHII 2009-07-08 06:03:22 UTC
Created attachment 4044 [details]
test program

as -relax adjsw8.s -o adjsw8.o; ld -relax adjsw8.o; objdump -t; objdump -s
and see if first 3 bytes are L1-L0,L2-L0,L3-L0 (should be 04 08 0c).
HEAD of CVS produces 04 06 0a.
Comment 2 Takashi YOSHII 2009-07-08 06:38:45 UTC
Created attachment 4045 [details]
patch to fix

I added small code to gas as bfd/elf-sh.c expects r_addend holds the different
between reloc address and label1. I can't find any official documents(ELF-ps or
so), though.
Tested for target=sh4-unknown-linux-gnu host=build=x86_64-pc-linux-gnu with 
$ make check-bfd check-gas check-ld RUNTESTFLAGS="--target_board=sh-sim
SIM=$PWD/sim/sh/run"
New test case and even old sh.exp:"SH relaxing execution" can detect this
issue.
Comment 3 Oleg Endo 2014-06-20 22:48:55 UTC
I believe this is a (partial) dup of PR 3298.
Comment 4 Oleg Endo 2014-08-02 15:21:52 UTC
The issue has been fixed on trunk and should be available in the next release that follows binutils 2.24.