public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: binutils@sources.redhat.com
Subject: Making generic ld testcases pass on more targets
Date: Wed, 16 Feb 2005 14:15:00 -0000	[thread overview]
Message-ID: <20050216115635.GR10128@bubble.modra.org> (raw)

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

             reply	other threads:[~2005-02-16 11:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-16 14:15 Alan Modra [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050216115635.GR10128@bubble.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).