Fix PR10378 which is SH relax bug.
authorKaz Kojima <kkojima@rr.iij4u.or.jp>
Fri, 1 Aug 2014 10:13:39 +0000 (19:13 +0900)
committerKaz Kojima <kkojima@rr.iij4u.or.jp>
Fri, 1 Aug 2014 10:13:39 +0000 (19:13 +0900)
gas/ChangeLog
gas/config/tc-sh.c
ld/testsuite/ChangeLog
ld/testsuite/ld-sh/adjsw8.s [new file with mode: 0644]
ld/testsuite/ld-sh/sh.exp

index 72d54dbb7f89e36db9c2f6150a223845905947ae..b7926f45aa0422dafb4bc690728d9c302c27b54e 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-01  Takashi Yoshii  <yoshii.takashi@renesas.com>
+
+       PR 10378
+       * config/tc-sh.c (tc_gen_reloc): Fix initialization of addend in
+       SWITCH_TABLE case.
+
 2014-07-29  Matthew Fortune  <matthew.fortune@imgtec.com>
 
        * config/tc-mips.c: Rename INSN_LOAD_COPROC_DELAY to INSN_LOAD_COPROC
index a0cd212641efa8cf7d18d95dee28aec557d87f8c..6e9ae921deb094827c56f799326ae79c87acea9b 100644 (file)
@@ -4435,7 +4435,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   if (SWITCH_TABLE (fixp))
     {
       *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
-      rel->addend = 0;
+      rel->addend = rel->address - S_GET_VALUE(fixp->fx_subsy);
       if (r_type == BFD_RELOC_16)
        r_type = BFD_RELOC_SH_SWITCH16;
       else if (r_type == BFD_RELOC_8)
index 02f9dc4f068198aaad5ea4d1222060a632997b88..773a6389e8619c267c08975c7d98a34c763beb35 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-01  Takashi Yoshii  <yoshii.takashi@renesas.com>
+
+       PR 10378
+       * ld-sh/adjsw8.s: New.
+       * ld-sh/sh.exp: Add switch8 adjustment test.
+
 2014-07-29  Matthew Fortune  <matthew.fortune@imgtec.com>
 
        * ld-mips-elf/abiflags-strip1-ph.d: New.
diff --git a/ld/testsuite/ld-sh/adjsw8.s b/ld/testsuite/ld-sh/adjsw8.s
new file mode 100644 (file)
index 0000000..6518e26
--- /dev/null
@@ -0,0 +1,16 @@
+L0:    .byte   L1-L0
+       .byte   L2-L0
+       .byte   L3-L0
+       .align  1
+L1:    mov.l   1f,r1
+       .uses   L1
+       jmp     @r1
+       nop
+L2:    mov.l   1f,r1
+       .uses   L2
+       jmp     @r1
+       nop
+L3:    nop
+       .align  2
+1:     .long   2f
+2:
index 31181a945f80235b30ed71849dd56bb3e62c0a9b..a2704005db84dd67ed92223a078b7b419ced622a 100644 (file)
@@ -110,6 +110,26 @@ if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
     }
 }
 
+set testadjsw8 "SH switch8 adjustment after relax"
+if ![ld_assemble $as "-relax $srcdir/$subdir/adjsw8.s" tmpdir/adjsw8.o] {
+    unresolved $testadjsw8
+} else {
+    if ![ld_simple_link $ld tmpdir/adjsw8 "-relax tmpdir/adjsw8.o"] {
+       fail $testadjsw8
+    } else {
+       send_log "exec $objdump -s tmpdir/adjsw8\n"
+       verbose "exec $objdump -s tmpdir/adjsw8"
+       catch "exec $objdump -s tmpdir/adjsw8" exec_output
+       if [string match "*04080c00*" $exec_output] {
+           pass $testadjsw8
+       } else {
+           send_log "bad switch table\n"
+           verbose "bad switch table"
+           fail $testadjsw8
+       }
+    }
+}
+
 set testlink "SH relaxing"
 set testjsr "SH confirm relaxing"
 set testrun "SH relaxing execution"