summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2013-04-02 23:29:50 +0000
committerDJ Delorie <dj@delorie.com>2013-04-02 23:29:50 +0000
commit8365ea4b9616d0d315bb29db42ac52cf9de6bb0f (patch)
tree0ce3e8e9a287e6651e3b53acdeb0778a5777063e
parent0666c31aeb21d0b9529e80d0fc15aadb826215ca (diff)
downloadgdb-8365ea4b9616d0d315bb29db42ac52cf9de6bb0f.tar.gz
* elf32-rl78.c (GET_RELOC): Assert that there are relocs to get.
(rl78_elf_relax_section): Only fetch the next reloc if there is one expected.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf32-rl78.c12
2 files changed, 17 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ddb4577872e..d854fd0f8fc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2013-04-02 DJ Delorie <dj@redhat.com>
+
+ * elf32-rl78.c (GET_RELOC): Assert that there are relocs to get.
+ (rl78_elf_relax_section): Only fetch the next reloc if there is
+ one expected.
+
2013-03-30 Alan Modra <amodra@gmail.com>
PR ld/15323
diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
index 21303110590..11d1ecc7457 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -2193,6 +2193,7 @@ rl78_elf_relax_section
+ srel->r_offset;
#define GET_RELOC \
+ BFD_ASSERT (nrelocs > 0); \
symval = OFFSET_FOR_RELOC (srel, &srel, &scale); \
pcrel = symval - pc + srel->r_addend; \
nrelocs --;
@@ -2233,7 +2234,13 @@ rl78_elf_relax_section
if (irel->r_addend & RL78_RELAXA_BRA)
{
- GET_RELOC;
+ /* SKIP opcodes that skip non-branches will have a relax tag
+ but no corresponding symbol to relax against; we just
+ skip those. */
+ if (irel->r_addend & RL78_RELAXA_RNUM)
+ {
+ GET_RELOC;
+ }
switch (insn[0])
{
@@ -2302,6 +2309,9 @@ rl78_elf_relax_section
/* For SKIP/BR, we change the BR opcode and delete the
SKIP. That way, we don't have to find and change the
relocation for the BR. */
+ /* Note that, for the case where we're skipping some
+ other insn, we have no "other" reloc but that's safe
+ here anyway. */
switch (insn[1])
{
case 0xc8: /* SKC */