* elf32-rl78.c (rl78_elf_relocate_section): Fix OPsub math.
authorDJ Delorie <dj@redhat.com>
Tue, 11 Jun 2013 19:16:07 +0000 (19:16 +0000)
committerDJ Delorie <dj@redhat.com>
Tue, 11 Jun 2013 19:16:07 +0000 (19:16 +0000)
bfd/ChangeLog
bfd/elf32-rl78.c

index 192c3ee6d09ff24a3fdf8be59788964b73cf1abe..01f050d5675069b8b0648ebf83f14a28d88e5483 100644 (file)
@@ -1,3 +1,7 @@
+2013-06-11  DJ Delorie  <dj@redhat.com>
+
+       * elf32-rl78.c (rl78_elf_relocate_section): Fix OPsub math.
+
 2013-06-11  Will Newton  <will.newton@linaro.org>
 
        * elf64-aarch64.c (elf_aarch64_get_local_sym_hash): Use
index fb31176da04431ea6bbd7620519f45621a8a4644..651a8bdce691a5d5e2e80ed0533bc463ba5c7af4 100644 (file)
@@ -810,10 +810,13 @@ rl78_elf_relocate_section
          {
            int32_t tmp1, tmp2;
 
-           RL78_STACK_POP (tmp2);
-           RL78_STACK_POP (tmp1);
-           tmp2 -= tmp1;
-           RL78_STACK_PUSH (tmp2);
+           /* For the expression "A - B", the assembler pushes A,
+              then B, then OPSUB.  So the first op we pop is B, not
+              A.  */
+           RL78_STACK_POP (tmp2);      /* B */
+           RL78_STACK_POP (tmp1);      /* A */
+           tmp1 -= tmp2;               /* A - B */
+           RL78_STACK_PUSH (tmp1);
          }
          break;