summaryrefslogtreecommitdiff
path: root/bfd/elf32-rl78.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2013-06-11 19:16:07 +0000
committerDJ Delorie <dj@delorie.com>2013-06-11 19:16:07 +0000
commit142a4c245ed9a79ce295588c85fbc63739b7971b (patch)
tree10063186473fc1e0211b154e2abfa9826bdf28c1 /bfd/elf32-rl78.c
parente05713dd030d5dbad35b7a4f2fce547641e737e7 (diff)
downloadgdb-142a4c245ed9a79ce295588c85fbc63739b7971b.tar.gz
* elf32-rl78.c (rl78_elf_relocate_section): Fix OPsub math.
Diffstat (limited to 'bfd/elf32-rl78.c')
-rw-r--r--bfd/elf32-rl78.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
index fb31176da04..651a8bdce69 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -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;