RX: Incorrect output for displacement of subtruct expression
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
Commit Message
Assembling the following code results in incorrect displacement values:
1: mov.L 2f-1b[r0],r0
If you write a subtraction formula in the displacement field, the value
will simply be the result of the subtraction, which will not be the
expected value for word and longword sizes.
gas/
* config/rx-parse.y (displacement): use BFD_RELOC_RX_GPREL in subtract expression.
* testsuite/gas/rx/mov.sm: Add subtruct expression displacement.
* testsuite/gas/rx/mov.d: Likewise.
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
gas/config/rx-parse.y | 35 ++++++++++++-----------------------
gas/testsuite/gas/rx/mov.d | 3 +++
gas/testsuite/gas/rx/mov.sm | 7 +++++++
3 files changed, 22 insertions(+), 23 deletions(-)
@@ -1934,32 +1934,21 @@ displacement (expressionS exp, int msize)
valueT val;
int vshift = 0;
- if (exp.X_op == O_symbol
- && exp.X_md)
+ if ((exp.X_op == O_symbol && exp.X_md == BFD_RELOC_GPREL16) ||
+ (exp.X_op == O_subtract))
{
- switch (exp.X_md)
+ switch (msize)
{
- case BFD_RELOC_GPREL16:
- switch (msize)
- {
- case BSIZE:
- exp.X_md = BFD_RELOC_RX_GPRELB;
- break;
- case WSIZE:
- exp.X_md = BFD_RELOC_RX_GPRELW;
- break;
- case LSIZE:
- exp.X_md = BFD_RELOC_RX_GPRELL;
- break;
- }
- O2 (exp);
- return 2;
+ case BSIZE:
+ exp.X_md = BFD_RELOC_RX_GPRELB;
+ break;
+ case WSIZE:
+ exp.X_md = BFD_RELOC_RX_GPRELW;
+ break;
+ case LSIZE:
+ exp.X_md = BFD_RELOC_RX_GPRELL;
+ break;
}
- }
-
- if (exp.X_op == O_subtract)
- {
- exp.X_md = BFD_RELOC_RX_DIFF;
O2 (exp);
return 2;
}
@@ -528,3 +528,6 @@ Disassembly of section .*:
[0-9a-f]+: fd 2e 0f mov.l \[-r0\], r15
[0-9a-f]+: fd 2e f0 mov.l \[-r15\], r0
[0-9a-f]+: fd 2e ff mov.l \[-r15\], r15
+ [0-9a-f]+: ce 00 04 00 mov.b 4\[r0\], r0
+ [0-9a-f]+: de 00 02 00 mov.w 4\[r0\], r0
+ [0-9a-f]+: ee 00 01 00 mov.l 4\[r0\], r0
@@ -31,3 +31,10 @@
mov{bwl} [{reg}+],{reg}
mov{bwl} {reg},[-{reg}]
mov{bwl} [-{reg}],{reg}
+
+1: mov.B 2f - 1b[r0], r0
+2:
+1: mov.W 2f - 1b[r0], r0
+2:
+1: mov.L 2f - 1b[r0], r0
+2: