]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* elf32-rl78.c (GET_RELOC): Assert that there are relocs to get.
authorDJ Delorie <dj@redhat.com>
Tue, 2 Apr 2013 23:29:51 +0000 (23:29 +0000)
committerDJ Delorie <dj@redhat.com>
Tue, 2 Apr 2013 23:29:51 +0000 (23:29 +0000)
(rl78_elf_relax_section): Only fetch the next reloc if there is
one expected.

bfd/ChangeLog
bfd/elf32-rl78.c

index ddb4577872e4187c8773bb2773619e1dca7da51f..d854fd0f8fcd83694fb497f80792a389e02d3eca 100644 (file)
@@ -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
index 2130311059001c591dde56e11585a610311f2449..11d1ecc74571020d06573b4c3c1ab04430ce6247 100644 (file)
@@ -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 */