Discussion:
gas simple-forward test
Alan Modra
2018-10-22 12:09:08 UTC
Permalink
Tests that target md_apply_fix can handle fixups that have resolved
down to a constant and thus do not need relocations.

Also a fix for eqv-dot xfails.

* testsuite/gas/all/simple-forward.d,
* testsuite/gas/all/simple-forward.s: New test.
* testsuite/gas/all/gas.exp: Run it.
* testsuite/gas/all/eqv-dot.d: xfail tic30 and tic54x.

diff --git a/gas/testsuite/gas/all/eqv-dot.d b/gas/testsuite/gas/all/eqv-dot.d
index 154530348e..bd825065bb 100644
--- a/gas/testsuite/gas/all/eqv-dot.d
+++ b/gas/testsuite/gas/all/eqv-dot.d
@@ -1,8 +1,8 @@
#objdump: -s -j .data
#name: eqv involving dot
# bfin doesn't support 'symbol = expression'
-# tic4x has 4 octets per byte
-#notarget: bfin-*-* tic4x-*-*
+# tic30 and tic4x have 4 octets per byte, tic54x has 2 octets per byte
+#notarget: bfin-*-* *c30-*-* *c4x-*-* *c54x-*-*

.*: .*

diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index 4296b14a70..7c28f43cc5 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -98,6 +98,8 @@ if { ![istarget "bfin-*-*"] } then {
}
gas_test_error "assign-bad.s" "" "== assignment for symbol already set"

+run_dump_test simple-forward
+
# .equ works differently on some targets.
# linkrelax-ing prevents most forward references from working.
case $target_triplet in {
diff --git a/gas/testsuite/gas/all/simple-forward.d b/gas/testsuite/gas/all/simple-forward.d
new file mode 100644
index 0000000000..63b4077c1c
--- /dev/null
+++ b/gas/testsuite/gas/all/simple-forward.d
@@ -0,0 +1,14 @@
+#objdump: -s -j .data
+#name: simple forward references
+# tic30 and tic4x have 4 octets per byte, tic54x has 2 octets per byte
+#notarget: *c30-*-* *c4x-*-* *c54x-*-*
+# am33, crx and mn10300 all emit relocs unnecessarily for this test,
+# but the code they generate is correct. Others emit incorrect relocs
+# which lead to incorrect results after linking.
+#xfail: am33*-*-* crx-*-* mn10300-*-*
+
+.*: .*
+
+Contents of section \.data:
+ 0000 0c000000 (0c000000 0c000000|000c0000 0000000c) .*
+#pass
diff --git a/gas/testsuite/gas/all/simple-forward.s b/gas/testsuite/gas/all/simple-forward.s
new file mode 100644
index 0000000000..fb7ee63a82
--- /dev/null
+++ b/gas/testsuite/gas/all/simple-forward.s
@@ -0,0 +1,11 @@
+ .data
+ .balign 4
+L0:
+ .balign 4
+ .dc.b L1-L0
+ .balign 4
+ .dc.w L1-L0
+ .balign 4
+ .dc.l L1-L0
+ .balign 4
+L1:
--
Alan Modra
Australia Development Lab, IBM
John Darrington
2018-10-23 08:30:47 UTC
Permalink
S12Z fails this test.

I'm not entirely clear what the test is checking, so I cannot say
whether this reveals a problem with the test or with the S12Z itself.

J'

On Mon, Oct 22, 2018 at 10:39:08PM +1030, Alan Modra wrote:
Tests that target md_apply_fix can handle fixups that have resolved
down to a constant and thus do not need relocations.

Also a fix for eqv-dot xfails.

* testsuite/gas/all/simple-forward.d,
* testsuite/gas/all/simple-forward.s: New test.
* testsuite/gas/all/gas.exp: Run it.
* testsuite/gas/all/eqv-dot.d: xfail tic30 and tic54x.

diff --git a/gas/testsuite/gas/all/eqv-dot.d b/gas/testsuite/gas/all/eqv-dot.d
index 154530348e..bd825065bb 100644
--- a/gas/testsuite/gas/all/eqv-dot.d
+++ b/gas/testsuite/gas/all/eqv-dot.d
@@ -1,8 +1,8 @@
#objdump: -s -j .data
#name: eqv involving dot
# bfin doesn't support 'symbol = expression'
-# tic4x has 4 octets per byte
-#notarget: bfin-*-* tic4x-*-*
+# tic30 and tic4x have 4 octets per byte, tic54x has 2 octets per byte
+#notarget: bfin-*-* *c30-*-* *c4x-*-* *c54x-*-*

.*: .*

diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index 4296b14a70..7c28f43cc5 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -98,6 +98,8 @@ if { ![istarget "bfin-*-*"] } then {
}
gas_test_error "assign-bad.s" "" "== assignment for symbol already set"

+run_dump_test simple-forward
+
# .equ works differently on some targets.
# linkrelax-ing prevents most forward references from working.
case $target_triplet in {
diff --git a/gas/testsuite/gas/all/simple-forward.d b/gas/testsuite/gas/all/simple-forward.d
new file mode 100644
index 0000000000..63b4077c1c
--- /dev/null
+++ b/gas/testsuite/gas/all/simple-forward.d
@@ -0,0 +1,14 @@
+#objdump: -s -j .data
+#name: simple forward references
+# tic30 and tic4x have 4 octets per byte, tic54x has 2 octets per byte
+#notarget: *c30-*-* *c4x-*-* *c54x-*-*
+# am33, crx and mn10300 all emit relocs unnecessarily for this test,
+# but the code they generate is correct. Others emit incorrect relocs
+# which lead to incorrect results after linking.
+#xfail: am33*-*-* crx-*-* mn10300-*-*
+
+.*: .*
+
+Contents of section \.data:
+ 0000 0c000000 (0c000000 0c000000|000c0000 0000000c) .*
+#pass
diff --git a/gas/testsuite/gas/all/simple-forward.s b/gas/testsuite/gas/all/simple-forward.s
new file mode 100644
index 0000000000..fb7ee63a82
--- /dev/null
+++ b/gas/testsuite/gas/all/simple-forward.s
@@ -0,0 +1,11 @@
+ .data
+ .balign 4
+L0:
+ .balign 4
+ .dc.b L1-L0
+ .balign 4
+ .dc.w L1-L0
+ .balign 4
+ .dc.l L1-L0
+ .balign 4
+L1:

--
Alan Modra
Australia Development Lab, IBM
--
Avoid eavesdropping. Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.
Alan Modra
2018-10-23 10:18:37 UTC
Permalink
Post by John Darrington
S12Z fails this test.
I'm not entirely clear what the test is checking, so I cannot say
whether this reveals a problem with the test or with the S12Z itself.
It's testing that ".byte expression" and similar directives are
handled for expressions that are constants, but gas does not know the
fact that they are constant at the time the directive is assembled.
So target code emits a fixup but by the time md_apply_fix is reached,
gas should have resolved the expression down to a constant and
fx_addsy and fx_subsy are both NULL. md_apply_fix should set fx_done
and write out the value.

In the s12z case it looks like you're missing support for .dc.w/.short
since md_apply_fix doesn't handle BFD_RELOC_16. Note that your target
doesn't need to support 16-bit relocs in object files (just like it
currently does not support 8-bit relocs but does handle BFD_RELOC_8
fixups in md_apply_fix).
--
Alan Modra
Australia Development Lab, IBM
John Darrington
2018-10-23 14:51:21 UTC
Permalink
Thanks for the hint.

I pushed a fix for this.

J'
Post by John Darrington
S12Z fails this test.
I'm not entirely clear what the test is checking, so I cannot say
whether this reveals a problem with the test or with the S12Z itself.
It's testing that ".byte expression" and similar directives are
handled for expressions that are constants, but gas does not know the
fact that they are constant at the time the directive is assembled.
So target code emits a fixup but by the time md_apply_fix is reached,
gas should have resolved the expression down to a constant and
fx_addsy and fx_subsy are both NULL. md_apply_fix should set fx_done
and write out the value.

In the s12z case it looks like you're missing support for .dc.w/.short
since md_apply_fix doesn't handle BFD_RELOC_16. Note that your target
doesn't need to support 16-bit relocs in object files (just like it
currently does not support 8-bit relocs but does handle BFD_RELOC_8
fixups in md_apply_fix).

--
Alan Modra
Australia Development Lab, IBM

Loading...