From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29443 invoked by alias); 16 Feb 2005 11:57:04 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 29049 invoked from network); 16 Feb 2005 11:56:38 -0000 Received: from unknown (HELO gizmo01ps.bigpond.com) (144.140.71.11) by sourceware.org with SMTP; 16 Feb 2005 11:56:38 -0000 Received: (qmail 31136 invoked from network); 16 Feb 2005 11:56:35 -0000 Received: from unknown (HELO psmam12.bigpond.com) (144.135.25.103) by gizmo01ps.bigpond.com with SMTP; 16 Feb 2005 11:56:35 -0000 Received: from cpe-144-136-221-26.sa.bigpond.net.au ([144.136.221.26]) by psmam12.bigpond.com(MAM REL_3_4_2a 234/8602194) with SMTP id 8602194; Wed, 16 Feb 2005 21:56:35 +1000 Received: by bubble.modra.org (Postfix, from userid 500) id 7D02346A79; Wed, 16 Feb 2005 22:26:35 +1030 Date: Wed, 16 Feb 2005 14:15:00 -0000 From: Alan Modra To: binutils@sources.redhat.com Subject: Making generic ld testcases pass on more targets Message-ID: <20050216115635.GR10128@bubble.modra.org> Mail-Followup-To: binutils@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2005-02/txt/msg00365.txt.bz2 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