public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Teach a few targets to resolve BFD_RELOC_8
@ 2019-03-20 22:46 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2019-03-20 22:46 UTC (permalink / raw)
  To: binutils; +Cc: Dave Brolley, Michael Eager

and tidy "forward" test.  The fact that the "forward" test wasn't run
on cr16 (presumably it failed at some point) illustrates why it's
better to xfail targets rather than excluding them in the .exp file or
via notarget in a .d file, unless there is a solid reason why the
target won't ever pass a particular test.  If cr16 had been xfail'd
we'd have gotten an xpass when whatever bug/missing support was
rectified, and the test should have been enabled at that point.

I've removed some checks in d30v md_apply_fix that have no business
being there.  Any symbol problems will be caught later in
tc_gen_reloc, and overflow checking is done in gas/write.c.

Note the comment for mep and microblaze.  I haven't looked into why
one of the relocs has a reference to "minus_one", but that seems like
it might be a bug.  I'm leaving that investigation to target
maintainers.

	* config/tc-d10v.c (md_apply_fix): Apply BFD_RELOC_8.
	* config/tc-pdp11.c (md_apply_fix): Likewise.
	* config/tc-d30v.c (md_apply_fix): Don't emit errors for BFD_RELOC_8,
	BFD_RELOC_16, and BFD_RELOC_64.
	* testsuite/gas/all/gas.exp: Move target exclusions for forward
	test, but not cr16, to..
	* testsuite/gas/all/forward.d: ..here, with explanation.  Remove
	d10v, d30v, and pdp11 xfails.

diff --git a/gas/config/tc-d10v.c b/gas/config/tc-d10v.c
index c2e3a190fe..9f6c82e1f9 100644
--- a/gas/config/tc-d10v.c
+++ b/gas/config/tc-d10v.c
@@ -1580,6 +1580,9 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
     case BFD_RELOC_16:
       bfd_putb16 ((bfd_vma) value, (unsigned char *) where);
       break;
+    case BFD_RELOC_8:
+      *where = value;
+      break;
 
     case BFD_RELOC_VTABLE_INHERIT:
     case BFD_RELOC_VTABLE_ENTRY:
diff --git a/gas/config/tc-d30v.c b/gas/config/tc-d30v.c
index f11cc958ba..086215e306 100644
--- a/gas/config/tc-d30v.c
+++ b/gas/config/tc-d30v.c
@@ -1918,37 +1918,17 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 
   switch (fixP->fx_r_type)
     {
-    case BFD_RELOC_8:  /* Check for a bad .byte directive.  */
-      if (fixP->fx_addsy != NULL)
-	as_bad (_("line %d: unable to place address of symbol '%s' into a byte"),
-		fixP->fx_line, S_GET_NAME (fixP->fx_addsy));
-      else if (((unsigned)value) > 0xff)
-	as_bad (_("line %d: unable to place value %lx into a byte"),
-		fixP->fx_line, value);
-      else
-	*(unsigned char *) where = value;
+    case BFD_RELOC_8:
+      *(unsigned char *) where = value;
       break;
 
-    case BFD_RELOC_16:  /* Check for a bad .short directive.  */
-      if (fixP->fx_addsy != NULL)
-	as_bad (_("line %d: unable to place address of symbol '%s' into a short"),
-		fixP->fx_line, S_GET_NAME (fixP->fx_addsy));
-      else if (((unsigned)value) > 0xffff)
-	as_bad (_("line %d: unable to place value %lx into a short"),
-		fixP->fx_line, value);
-      else
-	bfd_putb16 ((bfd_vma) value, (unsigned char *) where);
+    case BFD_RELOC_16:
+      bfd_putb16 ((bfd_vma) value, (unsigned char *) where);
       break;
 
-    case BFD_RELOC_64:  /* Check for a bad .quad directive.  */
-      if (fixP->fx_addsy != NULL)
-	as_bad (_("line %d: unable to place address of symbol '%s' into a quad"),
-		fixP->fx_line, S_GET_NAME (fixP->fx_addsy));
-      else
-	{
-	  bfd_putb32 ((bfd_vma) value, (unsigned char *) where);
-	  bfd_putb32 (0, ((unsigned char *) where) + 4);
-	}
+    case BFD_RELOC_64:
+      bfd_putb32 ((bfd_vma) value, (unsigned char *) where);
+      bfd_putb32 (0, ((unsigned char *) where) + 4);
       break;
 
     case BFD_RELOC_D30V_6:
diff --git a/gas/config/tc-pdp11.c b/gas/config/tc-pdp11.c
index f00fa0b03e..1be07eaf59 100644
--- a/gas/config/tc-pdp11.c
+++ b/gas/config/tc-pdp11.c
@@ -248,6 +248,10 @@ md_apply_fix (fixS *fixP,
 
   switch (fixP->fx_r_type)
     {
+    case BFD_RELOC_8:
+      mask = 0xff;
+      shift = 0;
+      break;
     case BFD_RELOC_16:
     case BFD_RELOC_16_PCREL:
       mask = 0xffff;
diff --git a/gas/testsuite/gas/all/forward.d b/gas/testsuite/gas/all/forward.d
index 5a7f370a17..d921ec517b 100644
--- a/gas/testsuite/gas/all/forward.d
+++ b/gas/testsuite/gas/all/forward.d
@@ -1,7 +1,17 @@
 #objdump: -s -j .data
 #name: forward references
-# Some targets don't manage to resolve BFD_RELOC_8 for constants.
-#xfail: *c30-*-* *c4x-*-* d10v-*-* d30v-*-* pdp11-*-*
+# tic30 and tic4x have 4 octets per byte, tic54x has 2 octets per byte
+#notarget: *c30-*-* *c4x-*-* *c54x-*-*
+# hppa uses non-standard .equ syntax
+#notarget: hppa*-*-*
+# linkrelax targets should really resolve the relocs in this test but some
+# choose to emit them even though the relocs are in .data, leading to
+# "redefined symbol cannot be used on reloc".
+#xfail: am33*-*-* crx*-*-* h8300*-*-* mn10200*-*-* mn10300*-*-*
+# mep and microblaze use complex relocs and don't resolve the relocs.
+# one of the relocs references minus_one, which is a bug, but no one
+# seems bothered enough to fix this.
+#xfail: mep-*-* microblaze-*-*
 
 .*: .*
 
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index e771184c45..9ea95c62a9 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -99,23 +99,7 @@ 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 {
-    { am3*-*-* } { }
-    { *c54x*-*-* } { }
-    { cr16*-*-* } { }
-    { crx*-*-* } { }
-    { h8300*-*-* } { }
-    { hppa*-*-* } { }
-    { mep-*-* } { }
-    { microblaze-*-* } { }
-    { mn10\[23\]00*-*-* } { }
-    default {
-	run_dump_test forward
-    }
-}
+run_dump_test forward
 
 # aout relocs are often weird, so is mep. don't bother testing
 # som doesn't use a .text section

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-03-20 22:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 22:46 Teach a few targets to resolve BFD_RELOC_8 Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).