public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Making generic ld testcases pass on more targets
@ 2005-02-16 14:15 Alan Modra
  2005-02-16 17:03 ` Nick Clifton
  2005-02-17  7:44 ` Hans-Peter Nilsson
  0 siblings, 2 replies; 9+ messages in thread
From: Alan Modra @ 2005-02-16 14:15 UTC (permalink / raw)
  To: binutils

There are a number of ld testcases that fail on various targets, all due
to relocation problems.  The typical testcase does something like

 .long foo

and expects this to work regardless of the size of addresses.  On 64-bit
targets, the default linker script might locate foo somewhere above 4G,
which will mean a reloc overflow.  Also, some 64-bit targets don't
support 32-bit relocations in shared libraries.  At the other extreme, a
16-bit target might not even have 32-bit relocs.

So it would be nice to have a means of creating a suitably sized
address, if only for the ld testsuite.  One possibility is to define a
symbol (or trickery a la md_parse_name) which could be tested.  eg.

 .ifle __address_size - 32
  .ifle __address_size - 16
   .word foo
  .else
   .long foo
  .endif
 .else
  .quad foo
 .endif

Another way is to define a new pseudo, .dc.a say, that magically does
the above.  Easily hacked together like the following, but I'd like to
solicit opinion on which approach is better (or something else entirely)
before I commit.

	* read.c (potable): Add "dc.a".
	(cons_worker): Handle dc.a.

Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.88
diff -u -p -r1.88 read.c
--- gas/read.c	31 Jan 2005 14:26:08 -0000	1.88
+++ gas/read.c	16 Feb 2005 11:41:01 -0000
@@ -263,6 +263,9 @@ static const pseudo_typeS potable[] = {
   {"common.s", s_mri_common, 1},
   {"data", s_data, 0},
   {"dc", cons, 2},
+#ifdef BFD_ASSEMBLER
+  {"dc.a", cons, 0},
+#endif
   {"dc.b", cons, 1},
   {"dc.d", float_cons, 'd'},
   {"dc.l", cons, 4},
@@ -3339,6 +3342,18 @@ cons_worker (register int nbytes,	/* 1=.
       return;
     }
 
+#ifdef BFD_ASSEMBLER
+  if (nbytes == 0)
+    {
+      /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
+	 contain an address.  */
+      nbytes = (stdoutput->arch_info->bits_per_address - 1) / 8;
+      nbytes |= nbytes >> 1;
+      nbytes |= nbytes >> 2;
+      nbytes += 1;
+    }
+#endif
+
 #ifdef md_cons_align
   md_cons_align (nbytes);
 #endif

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-02-21  8:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-16 14:15 Making generic ld testcases pass on more targets Alan Modra
2005-02-16 17:03 ` Nick Clifton
2005-02-16 18:48   ` Alan Modra
2005-02-16 19:48     ` Nick Clifton
2005-02-17  7:44 ` Hans-Peter Nilsson
2005-02-17 12:26   ` Hans-Peter Nilsson
2005-02-17 12:58   ` Alan Modra
2005-02-17 13:02     ` Hans-Peter Nilsson
2005-02-21 15:51       ` 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).