* 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
* Re: Making generic ld testcases pass on more targets
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-17 7:44 ` Hans-Peter Nilsson
1 sibling, 1 reply; 9+ messages in thread
From: Nick Clifton @ 2005-02-16 17:03 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
Hi Alan,
> +#ifdef BFD_ASSEMBLER
> + {"dc.a", cons, 0},
> +#endif
I like this, but why make the pseudo specific to BFD_ASSEMBLERs ?
> +#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;
It might make sense to allow for individual targets to override this
computation with their own value if they so wish.
Cheers
Nick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Making generic ld testcases pass on more targets
2005-02-16 17:03 ` Nick Clifton
@ 2005-02-16 18:48 ` Alan Modra
2005-02-16 19:48 ` Nick Clifton
0 siblings, 1 reply; 9+ messages in thread
From: Alan Modra @ 2005-02-16 18:48 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils
On Wed, Feb 16, 2005 at 12:14:09PM +0000, Nick Clifton wrote:
> >+#ifdef BFD_ASSEMBLER
> >+ {"dc.a", cons, 0},
> >+#endif
>
> I like this, but why make the pseudo specific to BFD_ASSEMBLERs ?
Because only BFD_ASSEMBLER has arch_info.
> >+ nbytes = (stdoutput->arch_info->bits_per_address - 1) / 8;
>
> It might make sense to allow for individual targets to override this
> computation with their own value if they so wish.
Yes, that would allow non-BFD_ASSEMBLER to use dc.a too.
Another approach occurred to me also, a variation on using
__address_size. Instead of the assembler providing the symbol, we could
have the test harness feed a suitable --defsym to the assembler, chosen
by target name.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Making generic ld testcases pass on more targets
2005-02-16 18:48 ` Alan Modra
@ 2005-02-16 19:48 ` Nick Clifton
0 siblings, 0 replies; 9+ messages in thread
From: Nick Clifton @ 2005-02-16 19:48 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
Hi Alan,
>>>+#ifdef BFD_ASSEMBLER
>>>+ {"dc.a", cons, 0},
>>>+#endif
>>
>>I like this, but why make the pseudo specific to BFD_ASSEMBLERs ?
>
> Because only BFD_ASSEMBLER has arch_info.
Ah - but if we want to use the pseudo in ld testcases then it would need
to be present for non BFD assemblers as well.
>>>+ nbytes = (stdoutput->arch_info->bits_per_address - 1) / 8;
>>
>>It might make sense to allow for individual targets to override this
>>computation with their own value if they so wish.
>
> Yes, that would allow non-BFD_ASSEMBLER to use dc.a too.
OK - this would be my preferred solution.
> Another approach occurred to me also, a variation on using
> __address_size. Instead of the assembler providing the symbol, we could
> have the test harness feed a suitable --defsym to the assembler, chosen
> by target name.
The problem here is remembering to do this when creating a new target.
Plus it is a duplication of information. As you have pointed out the
address size is already in the arch_info structure (for BFD assemblers)
so why force the developer to put it into the testsuite as well.
Plus it introduces target specific information into a file that might
otherwise be generic.
Cheers
Nick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Making generic ld testcases pass on more targets
2005-02-16 14:15 Making generic ld testcases pass on more targets Alan Modra
2005-02-16 17:03 ` 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
1 sibling, 2 replies; 9+ messages in thread
From: Hans-Peter Nilsson @ 2005-02-17 7:44 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
On Wed, 16 Feb 2005, Alan Modra wrote:
> Another way is to define a new pseudo, .dc.a say, that magically does
> the above.
I do like the idea (in contrast to the --defsym suggestion).
But please make the name less collision-prone. How about
".gnu.dc.a"?
While you're at it, some fixed-size relocs would be nice too:
".gnu.dc.1" .. ".gnu.dc.4" (and 8 for 64-bitters).
brgds, H-P
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Making generic ld testcases pass on more targets
2005-02-17 7:44 ` Hans-Peter Nilsson
@ 2005-02-17 12:26 ` Hans-Peter Nilsson
2005-02-17 12:58 ` Alan Modra
1 sibling, 0 replies; 9+ messages in thread
From: Hans-Peter Nilsson @ 2005-02-17 12:26 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
On Wed, 16 Feb 2005, Hans-Peter Nilsson wrote:
> While you're at it, some fixed-size relocs would be nice too:
s/relocs/pseudos/
brgds, H-P
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Making generic ld testcases pass on more targets
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
1 sibling, 1 reply; 9+ messages in thread
From: Alan Modra @ 2005-02-17 12:58 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: binutils
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?
> 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.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Making generic ld testcases pass on more targets
2005-02-17 12:58 ` Alan Modra
@ 2005-02-17 13:02 ` Hans-Peter Nilsson
2005-02-21 15:51 ` Alan Modra
0 siblings, 1 reply; 9+ messages in thread
From: Hans-Peter Nilsson @ 2005-02-17 13:02 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
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).
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?
> > 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.
brgds, H-P
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Making generic ld testcases pass on more targets
2005-02-17 13:02 ` Hans-Peter Nilsson
@ 2005-02-21 15:51 ` Alan Modra
0 siblings, 0 replies; 9+ messages in thread
From: Alan Modra @ 2005-02-21 15:51 UTC (permalink / raw)
To: binutils
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;
}
\f
+#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
^ 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).