This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: [PATCH, MIPS] Relax alignment check for LDPC
- From: Matthew Fortune <Matthew dot Fortune at imgtec dot com>
- To: Richard Sandiford <rdsandiford at googlemail dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 18 Dec 2014 17:05:03 +0000
- Subject: RE: [PATCH, MIPS] Relax alignment check for LDPC
- Authentication-results: sourceware.org; auth=none
- References: <6D39441BF12EF246A7ABCE6654B0235320F882C9 at LEMAIL01 dot le dot imgtec dot org> <87oar3fhln dot fsf at googlemail dot com> <6D39441BF12EF246A7ABCE6654B0235320F88AD0 at LEMAIL01 dot le dot imgtec dot org>
> > So I think we should either check S_GET_VALUE (fx_addsy) + fx_offset is
> > aligned or (probably better, if it works) check that the low 3 bits of
> > *valP are the same as the low three bits of:
> >
> > fixP->fx_where + fixP->fx_frag->fr_address
I've gone with the S_GET_VALUE approach as it is an accurate representation
of the restriction. I have ignored the case of REL losing a bit when the
offset is not a multiple of 8 for two reasons... Firstly I don't think the
use case is very important but more importantly LDPC and this reloc can
only really be used with N32 or N64 which are both RELA.
I also updated the error message for PCREL18_S3 and PCREL19_S2. And added
more tests.
OK to commit?
(tested on a wide number of mips target triplets)
Thanks,
Matthew
gas/
* config/tc-mips.c (md_apply_fix): Apply alignment check
to the target rather than *valP for BFD_RELOC_MIPS_18_PCREL_S3.
Also update the error message for BFD_RELOC_MIPS_19_PCREL_S2.
gas/testsuite/
* gas/mips/r6-64.s: Remove .align directives from LDPC
instructions and add further tests for LDPC.
* gas/mips/r6-64-n32.d: remove the NOPs from LDPC expected
output and update for new tests.
* gas/mips/r6-64-n64.d: Likewise.
* gas/mips/ldpc-unalign.l: New file.
* gas/mips/ldpc-unalign.s: Likewise.
* gas/mips/mips.exp: Run ldpc-unalign test.
---
gas/config/tc-mips.c | 6 ++---
gas/testsuite/gas/mips/ldpc-unalign.l | 5 ++++
gas/testsuite/gas/mips/ldpc-unalign.s | 16 ++++++++++++
gas/testsuite/gas/mips/mips.exp | 1 +
gas/testsuite/gas/mips/r6-64-n32.d | 26 +++++++++++++-------
gas/testsuite/gas/mips/r6-64-n64.d | 46 ++++++++++++++++++++++++-----------
gas/testsuite/gas/mips/r6-64.s | 24 ++++++++++++------
7 files changed, 91 insertions(+), 33 deletions(-)
create mode 100644 gas/testsuite/gas/mips/ldpc-unalign.l
create mode 100644 gas/testsuite/gas/mips/ldpc-unalign.s
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index c9266db..8568c10 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -15009,10 +15009,10 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
break;
case BFD_RELOC_MIPS_18_PCREL_S3:
- if ((*valP & 0x7) != 0)
+ if (((S_GET_VALUE (fixP->fx_addsy) + fixP->fx_offset) & 0x7) != 0)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("PC-relative access to misaligned address (%lx)"),
- (long) *valP);
+ (long) (S_GET_VALUE (fixP->fx_addsy) + fixP->fx_offset));
gas_assert (!fixP->fx_done);
break;
@@ -15021,7 +15021,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
if ((*valP & 0x3) != 0)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("PC-relative access to misaligned address (%lx)"),
- (long) *valP);
+ (long) (S_GET_VALUE (fixP->fx_addsy) + fixP->fx_offset));
gas_assert (!fixP->fx_done);
break;
diff --git a/gas/testsuite/gas/mips/ldpc-unalign.l b/gas/testsuite/gas/mips/ldpc-unalign.l
new file mode 100644
index 0000000..7554b83
--- /dev/null
+++ b/gas/testsuite/gas/mips/ldpc-unalign.l
@@ -0,0 +1,5 @@
+.*: Assembler messages:
+.*:2: Error: PC-relative access to misaligned address \(14\)
+.*:3: Error: PC-relative access to misaligned address \(14\)
+.*:4: Error: PC-relative access to misaligned address \(14\)
+.*:5: Error: PC-relative access to misaligned address \(14\)
diff --git a/gas/testsuite/gas/mips/ldpc-unalign.s b/gas/testsuite/gas/mips/ldpc-unalign.s
new file mode 100644
index 0000000..8124993
--- /dev/null
+++ b/gas/testsuite/gas/mips/ldpc-unalign.s
@@ -0,0 +1,16 @@
+ .text
+ ldpc $4, 1f+4
+ ldpc $4, 1f+4
+ ldpc $4, 2f
+ ldpc $4, 2f
+ .align 3
+1:
+ nop
+2:
+ nop
+ nop
+ nop
+
+# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 2
+ .space 8
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index b0de13a..d2cbc50 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -1450,6 +1450,7 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test_arches "r6-n64" [mips_arch_list_matching mips64r6]
run_dump_test_arches "r6-64-n32" [mips_arch_list_matching mips64r6]
run_dump_test_arches "r6-64-n64" [mips_arch_list_matching mips64r6]
+ run_list_test_arches "ldpc-unalign" "-64" [mips_arch_list_matching mips64r6]
}
run_list_test_arches "r6-removed" "-32" [mips_arch_list_matching mips32r6]
run_list_test_arches "r6-64-removed" [mips_arch_list_matching mips64r6]
diff --git a/gas/testsuite/gas/mips/r6-64-n32.d b/gas/testsuite/gas/mips/r6-64-n32.d
index 6d471c6..6ff8feb 100644
--- a/gas/testsuite/gas/mips/r6-64-n32.d
+++ b/gas/testsuite/gas/mips/r6-64-n32.d
@@ -44,18 +44,26 @@ Disassembly of section .text:
[ ]*78: R_MIPS_PC19_S2 L0.+0xffffc
0+007c <[^>]*> ec940000 lwupc a0,fff0007c <[^>]*>
0+0080 <[^>]*> ec93ffff lwupc a0,0010007c <[^>]*>
-0+0084 <[^>]*> 00000000 nop
+0+0084 <[^>]*> ec980000 ldpc a0,00000080 <[^>]*>
+[ ]*84: R_MIPS_PC18_S3 \.L1.1
0+0088 <[^>]*> ec980000 ldpc a0,00000088 <[^>]*>
[ ]*88: R_MIPS_PC18_S3 \.L1.1
-0+008c <[^>]*> 00000000 nop
+0+008c <[^>]*> ec980000 ldpc a0,00000088 <[^>]*>
+[ ]*8c: R_MIPS_PC18_S3 \.L2.1\+0x4
0+0090 <[^>]*> ec980000 ldpc a0,00000090 <[^>]*>
-[ ]*90: R_MIPS_PC18_S3 L0.-0x100000
+[ ]*90: R_MIPS_PC18_S3 \.L2.1\+0x4
0+0094 <[^>]*> 00000000 nop
0+0098 <[^>]*> ec980000 ldpc a0,00000098 <[^>]*>
-[ ]*98: R_MIPS_PC18_S3 L0.+0xffff8
-0+009c <[^>]*> 00000000 nop
-0+00a0 <[^>]*> ec9a0000 ldpc a0,fff000a0 <[^>]*>
-0+00a4 <[^>]*> 00000000 nop
-0+00a8 <[^>]*> ec99ffff ldpc a0,001000a0 <[^>]*>
-0+00ac <[^>]*> 00000000 nop
+[ ]*98: R_MIPS_PC18_S3 \.L3.1-0x100000
+0+009c <[^>]*> ec980000 ldpc a0,00000098 <[^>]*>
+[ ]*9c: R_MIPS_PC18_S3 \.L3.1-0x100000
+0+00a0 <[^>]*> ec980000 ldpc a0,000000a0 <[^>]*>
+[ ]*a0: R_MIPS_PC18_S3 \.L3.2\+0xffff8
+0+00a4 <[^>]*> ec980000 ldpc a0,000000a0 <[^>]*>
+[ ]*a4: R_MIPS_PC18_S3 \.L3.2\+0xffff8
+0+00a8 <[^>]*> ec9a0000 ldpc a0,fff000a8 <[^>]*>
+0+00ac <[^>]*> ec9a0000 ldpc a0,fff000a8 <[^>]*>
+0+00b0 <[^>]*> ec99ffff ldpc a0,001000a8 <[^>]*>
+0+00b4 <[^>]*> ec99ffff ldpc a0,001000a8 <[^>]*>
+0+00b8 <[^>]*> 00000000 nop
\.\.\.
diff --git a/gas/testsuite/gas/mips/r6-64-n64.d b/gas/testsuite/gas/mips/r6-64-n64.d
index 2202820..abbf2d2 100644
--- a/gas/testsuite/gas/mips/r6-64-n64.d
+++ b/gas/testsuite/gas/mips/r6-64-n64.d
@@ -50,24 +50,42 @@ Disassembly of section .text:
[ ]*78: R_MIPS_NONE \*ABS\*\+0xffffc
0+007c <[^>]*> ec940000 lwupc a0,f+ff0007c <[^>]*>
0+0080 <[^>]*> ec93ffff lwupc a0,0+010007c <[^>]*>
-0+0084 <[^>]*> 00000000 nop
+0+0084 <[^>]*> ec980000 ldpc a0,0+0000080 <[^>]*>
+[ ]*84: R_MIPS_PC18_S3 .L1.1
+[ ]*84: R_MIPS_NONE \*ABS\*
+[ ]*84: R_MIPS_NONE \*ABS\*
0+0088 <[^>]*> ec980000 ldpc a0,0+0000088 <[^>]*>
-[ ]*88: R_MIPS_PC18_S3 \.L1.1
+[ ]*88: R_MIPS_PC18_S3 .L1.1
[ ]*88: R_MIPS_NONE \*ABS\*
[ ]*88: R_MIPS_NONE \*ABS\*
-0+008c <[^>]*> 00000000 nop
+0+008c <[^>]*> ec980000 ldpc a0,0+0000088 <[^>]*>
+[ ]*8c: R_MIPS_PC18_S3 .L2.1\+0x4
+[ ]*8c: R_MIPS_NONE \*ABS\*\+0x4
+[ ]*8c: R_MIPS_NONE \*ABS\*\+0x4
0+0090 <[^>]*> ec980000 ldpc a0,0+0000090 <[^>]*>
-[ ]*90: R_MIPS_PC18_S3 L0.-0x100000
-[ ]*90: R_MIPS_NONE \*ABS\*-0x100000
-[ ]*90: R_MIPS_NONE \*ABS\*-0x100000
+[ ]*90: R_MIPS_PC18_S3 .L2.1\+0x4
+[ ]*90: R_MIPS_NONE \*ABS\*\+0x4
+[ ]*90: R_MIPS_NONE \*ABS\*\+0x4
0+0094 <[^>]*> 00000000 nop
0+0098 <[^>]*> ec980000 ldpc a0,0+0000098 <[^>]*>
-[ ]*98: R_MIPS_PC18_S3 L0.\+0xffff8
-[ ]*98: R_MIPS_NONE \*ABS\*\+0xffff8
-[ ]*98: R_MIPS_NONE \*ABS\*\+0xffff8
-0+009c <[^>]*> 00000000 nop
-0+00a0 <[^>]*> ec9a0000 ldpc a0,f+ff000a0 <[^>]*>
-0+00a4 <[^>]*> 00000000 nop
-0+00a8 <[^>]*> ec99ffff ldpc a0,0+01000a0 <[^>]*>
-0+00ac <[^>]*> 00000000 nop
+[ ]*98: R_MIPS_PC18_S3 .L3.1-0x100000
+[ ]*98: R_MIPS_NONE \*ABS\*-0x100000
+[ ]*98: R_MIPS_NONE \*ABS\*-0x100000
+0+009c <[^>]*> ec980000 ldpc a0,0+0000098 <[^>]*>
+[ ]*9c: R_MIPS_PC18_S3 .L3.1-0x100000
+[ ]*9c: R_MIPS_NONE \*ABS\*-0x100000
+[ ]*9c: R_MIPS_NONE \*ABS\*-0x100000
+0+00a0 <[^>]*> ec980000 ldpc a0,0+00000a0 <[^>]*>
+[ ]*a0: R_MIPS_PC18_S3 .L3.2\+0xffff8
+[ ]*a0: R_MIPS_NONE \*ABS\*\+0xffff8
+[ ]*a0: R_MIPS_NONE \*ABS\*\+0xffff8
+0+00a4 <[^>]*> ec980000 ldpc a0,0+00000a0 <[^>]*>
+[ ]*a4: R_MIPS_PC18_S3 .L3.2\+0xffff8
+[ ]*a4: R_MIPS_NONE \*ABS\*\+0xffff8
+[ ]*a4: R_MIPS_NONE \*ABS\*\+0xffff8
+0+00a8 <[^>]*> ec9a0000 ldpc a0,f+ff000a8 <[^>]*>
+0+00ac <[^>]*> ec9a0000 ldpc a0,f+ff000a8 <[^>]*>
+0+00b0 <[^>]*> ec99ffff ldpc a0,0+01000a8 <[^>]*>
+0+00b4 <[^>]*> ec99ffff ldpc a0,0+01000a8 <[^>]*>
+0+00b8 <[^>]*> 00000000 nop
\.\.\.
diff --git a/gas/testsuite/gas/mips/r6-64.s b/gas/testsuite/gas/mips/r6-64.s
index 7a97ad2..13b5a28 100644
--- a/gas/testsuite/gas/mips/r6-64.s
+++ b/gas/testsuite/gas/mips/r6-64.s
@@ -40,19 +40,29 @@
lwu $4, (-262144 << 2)($pc)
lwu $4, (262143 << 2)($pc)
- .align 3
ldpc $4, 1f
- .align 3
- ldpc $4, .+(-131072 << 3)
- .align 3
- ldpc $4, .+(131071 << 3)
- .align 3
+ ldpc $4, 1f
+ ldpc $4, 2f+4
+ ldpc $4, 2f+4
+ .align 3
+3:
+ ldpc $4, 3b+(-131072 << 3)
+ ldpc $4, 3b+(-131072 << 3)
+ .align 3
+3:
+ ldpc $4, 3b+(131071 << 3)
+ ldpc $4, 3b+(131071 << 3)
ld $4, (-131072 << 3)($pc)
- .align 3
+ ld $4, (-131072 << 3)($pc)
+ ld $4, (131071 << 3)($pc)
ld $4, (131071 << 3)($pc)
.align 3
1:
nop
+2:
+ nop
+ nop
+ nop
# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
.align 2
--
1.9.4