This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] rl78: fix OPsub math
- From: DJ Delorie <dj at redhat dot com>
- To: binutils at sourceware dot org
- Date: Tue, 11 Jun 2013 15:16:10 -0400
- Subject: [patch] rl78: fix OPsub math
Committed.
* elf32-rl78.c (rl78_elf_relocate_section): Fix OPsub math.
Index: bfd/elf32-rl78.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-rl78.c,v
retrieving revision 1.15
diff -p -U 5 -r1.15 bfd/elf32-rl78.c
--- bfd/elf32-rl78.c 11 Jun 2013 07:21:40 -0000 1.15
+++ bfd/elf32-rl78.c 11 Jun 2013 19:14:44 -0000
@@ -808,14 +808,17 @@ rl78_elf_relocate_section
case R_RL78_OPsub:
{
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;
case R_RL78_OPmul:
{