aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-sh.c
diff options
context:
space:
mode:
authorKaz Kojima <kkojima@rr.iij4u.or.jp>2014-08-01 19:17:47 +0900
committerKaz Kojima <kkojima@rr.iij4u.or.jp>2014-08-01 19:17:47 +0900
commit8c7840168031ab93432214580bf14ce63d638d22 (patch)
tree94157661b29029d97b79ca23c2b3bcfefe3e0291 /bfd/elf32-sh.c
parentb131d1fcfa5978f105a9ac39057475f54bab9202 (diff)
downloadgdb-8c7840168031ab93432214580bf14ce63d638d22.zip
gdb-8c7840168031ab93432214580bf14ce63d638d22.tar.gz
gdb-8c7840168031ab93432214580bf14ce63d638d22.tar.bz2
Fix PR10373 which is SH relax bug.
Diffstat (limited to 'bfd/elf32-sh.c')
-rw-r--r--bfd/elf32-sh.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 5085830..44a3aa7 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -702,10 +702,10 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Replace the jsr with a bsr. */
+ /* Replace the jmp/jsr with a bra/bsr. */
/* Change the R_SH_USES reloc into an R_SH_IND12W reloc, and
- replace the jsr with a bsr. */
+ replace the jmp/jsr with a bra/bsr. */
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irelfn->r_info), R_SH_IND12W);
/* We used to test (ELF32_R_SYM (irelfn->r_info) < symtab_hdr->sh_info)
here, but that only checks if the symbol is an external symbol,
@@ -716,7 +716,10 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
/* We can't fully resolve this yet, because the external
symbol value may be changed by future relaxing. We let
the final link phase handle it. */
- bfd_put_16 (abfd, (bfd_vma) 0xb000, contents + irel->r_offset);
+ if (bfd_get_16 (abfd, contents + irel->r_offset) & 0x0020)
+ bfd_put_16 (abfd, (bfd_vma) 0xa000, contents + irel->r_offset);
+ else
+ bfd_put_16 (abfd, (bfd_vma) 0xb000, contents + irel->r_offset);
irel->r_addend = -4;