This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Making generic ld testcases pass on more targets
On Wed, Feb 16, 2005 at 10:37:44PM -0500, Hans-Peter Nilsson wrote:
> On Thu, 17 Feb 2005, Alan Modra wrote:
>
> > On Wed, Feb 16, 2005 at 08:31:25PM -0500, Hans-Peter Nilsson wrote:
> > > But please make the name less collision-prone. How about
> > > ".gnu.dc.a"?
> >
> > Hmm. Do you know of some other assembler that uses dc.a?
>
> Nope. But I know of some other that use .dc.C (C=b,w).
Sure. We do too.
> It just seems painlessly safer to use a unique prefix, now that
> we don't *have* to cast *any* doubt whatsoever of colliding with
> any pre-existing convention. I mean, why not?
I think the GNU tools have evolved far enough that it's reasonable to
let other competing toolchains worry about being compatible with us. ;)
> > > While you're at it, some fixed-size relocs would be nice too:
> > > ".gnu.dc.1" .. ".gnu.dc.4" (and 8 for 64-bitters).
> >
> > You already have them. Lots of 'em. See read.c potable.
>
> But still only with the "dc." prefix and similar.
Which are perfectly good to use.
gas/
* read.c (address_bytes): New function.
(TC_ADDRESS_BYTES): Default for BSD_ASSEMBLER to address_bytes.
(potable): Add "dc.a".
(cons_worker): Handle "dc.a".
* doc/internals.texi (TC_ADDRESS_BYTES): Document.
ld/testsuite/
* ld-elf/exclude1.s: Use ".dc.a".
* ld-elfvsb/hidden2.s: Likewise.
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.90
diff -u -p -r1.90 read.c
--- gas/read.c 19 Feb 2005 08:56:08 -0000 1.90
+++ gas/read.c 21 Feb 2005 06:41:47 -0000
@@ -243,6 +243,24 @@ read_begin (void)
lex_type['?'] = 3;
}
+#ifndef TC_ADDRESS_BYTES
+#ifdef BFD_ASSEMBLER
+#define TC_ADDRESS_BYTES address_bytes
+
+static inline int
+address_bytes (void)
+{
+ /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
+ contain an address. */
+ int n = (stdoutput->arch_info->bits_per_address - 1) / 8;
+ n |= n >> 1;
+ n |= n >> 2;
+ n += 1;
+ return n;
+}
+#endif
+#endif
+
/* Set up pseudo-op tables. */
static struct hash_control *po_hash;
@@ -263,6 +281,9 @@ static const pseudo_typeS potable[] = {
{"common.s", s_mri_common, 1},
{"data", s_data, 0},
{"dc", cons, 2},
+#ifdef TC_ADDRESS_BYTES
+ {"dc.a", cons, 0},
+#endif
{"dc.b", cons, 1},
{"dc.d", float_cons, 'd'},
{"dc.l", cons, 4},
@@ -3335,6 +3356,11 @@ cons_worker (register int nbytes, /* 1=.
return;
}
+#ifdef TC_ADDRESS_BYTES
+ if (nbytes == 0)
+ nbytes = TC_ADDRESS_BYTES ();
+#endif
+
#ifdef md_cons_align
md_cons_align (nbytes);
#endif
Index: gas/doc/internals.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/internals.texi,v
retrieving revision 1.41
diff -u -p -r1.41 internals.texi
--- gas/doc/internals.texi 19 Feb 2005 08:56:08 -0000 1.41
+++ gas/doc/internals.texi 21 Feb 2005 06:59:14 -0000
@@ -1114,6 +1114,11 @@ pseudo-op.
@cindex TC_CONS_FIX_NEW
You may define this macro to generate a fixup for a data allocation pseudo-op.
+@item TC_ADDRESS_BYTES
+@cindex TC_ADDRESS_BYTES
+Define this macro to specify the number of bytes used to store an address.
+Used to implement @code{dc.a}. The target must have a reloc for this size.
+
@item TC_INIT_FIX_DATA (@var{fixp})
@cindex TC_INIT_FIX_DATA
A C statement to initialize the target specific fields of fixup @var{fixp}.
Index: ld/testsuite/ld-elf/exclude1.s
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/exclude1.s,v
retrieving revision 1.2
diff -u -p -r1.2 exclude1.s
--- ld/testsuite/ld-elf/exclude1.s 19 Oct 2004 17:14:38 -0000 1.2
+++ ld/testsuite/ld-elf/exclude1.s 21 Feb 2005 06:14:07 -0000
@@ -1,4 +1,4 @@
.globl include_sym
.data
include_sym:
- .long exclude_sym
+ .dc.a exclude_sym
Index: ld/testsuite/ld-elfvsb/hidden2.s
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elfvsb/hidden2.s,v
retrieving revision 1.2
diff -u -p -r1.2 hidden2.s
--- ld/testsuite/ld-elfvsb/hidden2.s 11 Feb 2005 14:25:13 -0000 1.2
+++ ld/testsuite/ld-elfvsb/hidden2.s 21 Feb 2005 06:14:08 -0000
@@ -1,4 +1,4 @@
.data
.hidden foo
.global foo
- .long foo
+ .dc.a foo
--
Alan Modra
IBM OzLabs - Linux Technology Centre