public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Gas: making md_long_jump_size mutable
@ 2004-10-29 15:34 Hans-Peter Nilsson
  2004-10-29 15:45 ` Ian Lance Taylor
  0 siblings, 1 reply; 6+ messages in thread
From: Hans-Peter Nilsson @ 2004-10-29 15:34 UTC (permalink / raw)
  To: binutils

Sensitive people might want to skip this message, as it only
matters to targets with "broken dot word" support.  (Though
there seems to be 13 of them, judging from number of definitions
of md_long_jump_size.)

I'd like to commit a CRIS variant called CRISv32.  Support for
crisv32-*-* is already in the imported config.sub and
config.guess.  The binutils support will be both as separate
crisv32-*-* targets and as options for the cris-*-* ELF targets.

However, CRISv32 needs a different value for md_long_jump_size
than CRIS.  I see two solutions: remove the "const" from the
extern declaration in symbols.c and write.c (!) or wrap them
#ifndef md_long_jump_size_declaration (or similar).  (Actually,
the first step would be to move declarations to tc.h but let's
keep that separate to the discussion.)

I'd prefer to just remove the "const".

(No, I'm not interested in alternative 3: remove BROKEN_DOT_WORD
support.  At least not for the time being. ;-)

brgds, H-P

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

* Re: Gas: making md_long_jump_size mutable
  2004-10-29 15:34 Gas: making md_long_jump_size mutable Hans-Peter Nilsson
@ 2004-10-29 15:45 ` Ian Lance Taylor
  2004-11-03  0:45   ` [RFA:] unconstify md_short_jump_size, md_long_jump_size (was: Re: Gas: making md_long_jump_size mutable) Hans-Peter Nilsson
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Lance Taylor @ 2004-10-29 15:45 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:

> However, CRISv32 needs a different value for md_long_jump_size
> than CRIS.  I see two solutions: remove the "const" from the
> extern declaration in symbols.c and write.c (!) or wrap them
> #ifndef md_long_jump_size_declaration (or similar).  (Actually,
> the first step would be to move declarations to tc.h but let's
> keep that separate to the discussion.)
> 
> I'd prefer to just remove the "const".

I agree.

> (No, I'm not interested in alternative 3: remove BROKEN_DOT_WORD
> support.  At least not for the time being. ;-)

Ah, but take a look at CASE_VECTOR_SHORTEN_MODE in gcc.  I recently
employed it to good effect in Thumb code (haven't contributed it back
yet).  Now that gcc keeps good track of instruction lengths, there is
much less need for BROKEN_DOT_WORD.

Ian

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

* [RFA:] unconstify md_short_jump_size, md_long_jump_size (was: Re: Gas: making md_long_jump_size mutable)
  2004-10-29 15:45 ` Ian Lance Taylor
@ 2004-11-03  0:45   ` Hans-Peter Nilsson
  2004-11-03  0:59     ` Alan Modra
  2004-11-04  1:53     ` Ian Lance Taylor
  0 siblings, 2 replies; 6+ messages in thread
From: Hans-Peter Nilsson @ 2004-11-03  0:45 UTC (permalink / raw)
  To: binutils

> From: Ian Lance Taylor <ian@wasabisystems.com>
> Date: 29 Oct 2004 11:45:48 -0400

> Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:
> > I'd prefer to just remove the "const".
> 
> I agree.

The patch below is an implementation.

> > (No, I'm not interested in alternative 3: remove BROKEN_DOT_WORD
> > support.  At least not for the time being. ;-)
> 
> Ah, but take a look at CASE_VECTOR_SHORTEN_MODE in gcc.  I recently
> employed it to good effect in Thumb code (haven't contributed it back
> yet).  Now that gcc keeps good track of instruction lengths, there is
> much less need for BROKEN_DOT_WORD.

Oh, I know about CASE_VECTOR_SHORTEN_MODE and agree it would be
an improvement to get e.g. byte offsets most of the time, but
for the time being, my plate is full and the broken dot word
support works fine--at least when incentived to stay working
through a few test-cases.  BTW, beware of the length of asm:s
when using CASE_VECTOR_SHORTEN_MODE; they *really* should be set
to max (can be done through define_asm_attributes it seems), so
that a branch across them can never be "shortened", not set to
some max length of a normal insn.

Based on gas/configure.in and grepping on jump_size, I tested this patch
on cross from i686-pc-linux-gnu (FC2) to the following targets:
avr-unknown-elf
cris-axis-elf
i370-unknown-elf
m68k-unknown-elf
mcore-unknown-elf
msp430-unknown-elf
ns32k-unknown-netbsd
or32-unknown-elf
pdp11-unknown-aout
tic4x-unknown-coff
vax-unknown-linux-gnu
except I didn't run the ld-elf/sec64k.exp (on cris-axis-elf, the only arch
where that test is enabled anyway due to excessive test execution time).

There were no changes in compilation output (i.e. no changes in warnings)
and no test regressions.  I couldn't test tahoe-unknown-aout, because of
brokenness in bfd support for it, which I was unable to trivially work
around: adding a bfd_tahoe_arch declaration just moved failure to some
macro in aout-host.c IIRC.

I would consider this obvious if it wasn't that I was unable to simply
test-compile the tahoe changes (so presumably another path would be to
*not* perform this change for tc-tahoe.c).

Ok to commit?

	* symbols.c (colon) [!WORKING_DOT_WORD]: Don't declare
	md_short_jump_size, md_long_jump_size.
	* write.c [!WORKING_DOT_WORD]: Ditto.
	* tc.h [!WORKING_DOT_WORD]: Declare them here.  Drop const
	qualifier.
	* config/tc-cris.h (md_short_jump_size, md_long_jump_size): Don't
	declare.
	* config/tc-cris.c (md_short_jump_size, md_long_jump_size): Drop
	const qualifier in these definitions.
	* config/tc-i370.c, config/tc-m68k.c, config/tc-pdp11.c,
	config/tc-s390.c, config/tc-tahoe.c, config/tc-vax.c: Ditto.

Index: symbols.c
===================================================================
RCS file: /cvs/src/src/gas/symbols.c,v
retrieving revision 1.50
diff -u -p -r1.50 symbols.c
--- symbols.c	21 Jun 2004 10:59:54 -0000	1.50
+++ symbols.c	2 Nov 2004 23:06:56 -0000
@@ -299,9 +299,6 @@ colon (/* Just seen "x:" - rattle symbol
       fragS *frag_tmp;
       char *frag_opcode;
 
-      extern const int md_short_jump_size;
-      extern const int md_long_jump_size;
-
       if (now_seg == absolute_section)
 	{
 	  as_bad (_("cannot define symbol `%s' in absolute section"), sym_name);
Index: tc.h
===================================================================
RCS file: /cvs/src/src/gas/tc.h,v
retrieving revision 1.7
diff -u -p -r1.7 tc.h
--- tc.h	17 Aug 2004 12:19:55 -0000	1.7
+++ tc.h	2 Nov 2004 23:06:56 -0000
@@ -54,6 +54,10 @@ void   md_begin (void);
 void   md_number_to_chars (char *, valueT, int);
 void   md_apply_fix3 (fixS *, valueT *, segT);
 
+#ifndef WORKING_DOT_WORD
+extern int md_short_jump_size;
+extern int md_long_jump_size;
+#endif
 
 #ifndef md_create_long_jump
 void    md_create_long_jump (char *, addressT, addressT, fragS *, symbolS *);
Index: write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.78
diff -u -p -r1.78 write.c
--- write.c	5 Aug 2004 16:55:00 -0000	1.78
+++ write.c	2 Nov 2004 23:07:01 -0000
@@ -97,11 +97,6 @@
 #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from (FIX)
 #endif
 
-#ifndef WORKING_DOT_WORD
-extern const int md_short_jump_size;
-extern const int md_long_jump_size;
-#endif
-
 /* Used to control final evaluation of expressions.  */
 int finalize_syms = 0;
 
Index: config/tc-cris.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-cris.c,v
retrieving revision 1.29
diff -u -p -r1.29 tc-cris.c
--- config/tc-cris.c	21 Mar 2004 23:50:38 -0000	1.29
+++ config/tc-cris.c	2 Nov 2004 23:07:08 -0000
@@ -341,8 +341,8 @@ const char *md_shortopts = "hHN";
    Note that we can't add relocs, because relaxation uses these fixed
    numbers, and md_create_short_jump is called after relaxation.  */
 
-const int md_short_jump_size = 6;
-const int md_long_jump_size = 6;
+int md_short_jump_size = 6;
+int md_long_jump_size = 6;
 
 /* Report output format.  Small changes in output format (like elf
    variants below) can happen until all options are parsed, but after
Index: config/tc-cris.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-cris.h,v
retrieving revision 1.9
diff -u -p -r1.9 tc-cris.h
--- config/tc-cris.h	16 Jun 2003 00:38:58 -0000	1.9
+++ config/tc-cris.h	2 Nov 2004 23:07:08 -0000
@@ -65,9 +65,6 @@ extern const char FLT_CHARS[];
 
 #define md_number_to_chars number_to_chars_littleendian
 
-extern const int md_short_jump_size;
-extern const int md_long_jump_size;
-
 /* There's no use having different functions for this; the sizes are the
    same.  Note that we can't #define md_short_jump_size here.  */
 #define md_create_short_jump md_create_long_jump
Index: config/tc-i370.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i370.c,v
retrieving revision 1.20
diff -u -p -r1.20 tc-i370.c
--- config/tc-i370.c	21 Nov 2003 14:38:06 -0000	1.20
+++ config/tc-i370.c	2 Nov 2004 23:07:14 -0000
@@ -425,8 +425,8 @@ static enum { SHLIB_NONE, SHLIB_PIC, SHI
 static flagword i370_flags = 0;
 
 #ifndef WORKING_DOT_WORD
-const int md_short_jump_size = 4;
-const int md_long_jump_size = 4;
+int md_short_jump_size = 4;
+int md_long_jump_size = 4;
 #endif
 \f
 #ifdef OBJ_ELF
Index: config/tc-m68k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.c,v
retrieving revision 1.59
diff -u -p -r1.59 tc-m68k.c
--- config/tc-m68k.c	8 Oct 2004 08:45:54 -0000	1.59
+++ config/tc-m68k.c	2 Nov 2004 23:07:26 -0000
@@ -5128,8 +5128,8 @@ tc_aout_fix_to_chars (char *where, fixS 
 #endif /* OBJ_AOUT or OBJ_BOUT */
 
 #ifndef WORKING_DOT_WORD
-const int md_short_jump_size = 4;
-const int md_long_jump_size = 6;
+int md_short_jump_size = 4;
+int md_long_jump_size = 6;
 
 void
 md_create_short_jump (char *ptr, addressT from_addr, addressT to_addr,
Index: config/tc-pdp11.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-pdp11.c,v
retrieving revision 1.11
diff -u -p -r1.11 tc-pdp11.c
--- config/tc-pdp11.c	1 Oct 2004 11:19:37 -0000	1.11
+++ config/tc-pdp11.c	2 Nov 2004 23:07:28 -0000
@@ -1020,8 +1020,8 @@ md_convert_frag (headers, seg, fragP)
 {
 }
 
-const int md_short_jump_size = 2;
-const int md_long_jump_size = 4;
+int md_short_jump_size = 2;
+int md_long_jump_size = 4;
 
 void
 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
Index: config/tc-s390.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-s390.c,v
retrieving revision 1.41
diff -u -p -r1.41 tc-s390.c
--- config/tc-s390.c	2 Oct 2004 00:18:31 -0000	1.41
+++ config/tc-s390.c	2 Nov 2004 23:07:32 -0000
@@ -312,8 +312,8 @@ static flagword s390_flags = 0;
 symbolS *GOT_symbol;		/* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
 
 #ifndef WORKING_DOT_WORD
-const int md_short_jump_size = 4;
-const int md_long_jump_size = 4;
+int md_short_jump_size = 4;
+int md_long_jump_size = 4;
 #endif
 
 const char *md_shortopts = "A:m:kVQ:";
Index: config/tc-tahoe.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-tahoe.c,v
retrieving revision 1.13
diff -u -p -r1.13 tc-tahoe.c
--- config/tc-tahoe.c	22 Nov 2003 15:32:28 -0000	1.13
+++ config/tc-tahoe.c	2 Nov 2004 23:07:36 -0000
@@ -572,7 +572,7 @@ tc_aout_fix_to_chars (where, fixP, segme
 /* Relocate byte stuff */
 \f
 /* This is for broken word.  */
-const int md_short_jump_size = 3;
+int md_short_jump_size = 3;
 
 void
 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
@@ -588,7 +588,7 @@ md_create_short_jump (ptr, from_addr, to
   md_number_to_chars (ptr, offset, 2);
 }
 
-const int md_long_jump_size = 6;
+int md_long_jump_size = 6;
 const int md_reloc_size = 8;	/* Size of relocation record */
 
 void
Index: config/tc-vax.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-vax.c,v
retrieving revision 1.19
diff -u -p -r1.19 tc-vax.c
--- config/tc-vax.c	3 Dec 2003 15:07:16 -0000	1.19
+++ config/tc-vax.c	2 Nov 2004 23:07:43 -0000
@@ -3214,8 +3214,8 @@ mumble (text, value)
 
 /* end: vip_op.c */
 
-const int md_short_jump_size = 3;
-const int md_long_jump_size = 6;
+int md_short_jump_size = 3;
+int md_long_jump_size = 6;
 const int md_reloc_size = 8;	/* Size of relocation record */
 
 void

brgds, H-P

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

* Re: [RFA:] unconstify md_short_jump_size, md_long_jump_size (was: Re: Gas: making md_long_jump_size mutable)
  2004-11-03  0:45   ` [RFA:] unconstify md_short_jump_size, md_long_jump_size (was: Re: Gas: making md_long_jump_size mutable) Hans-Peter Nilsson
@ 2004-11-03  0:59     ` Alan Modra
  2004-11-04  1:53     ` Ian Lance Taylor
  1 sibling, 0 replies; 6+ messages in thread
From: Alan Modra @ 2004-11-03  0:59 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

On Wed, Nov 03, 2004 at 01:45:42AM +0100, Hans-Peter Nilsson wrote:
> 	* symbols.c (colon) [!WORKING_DOT_WORD]: Don't declare
> 	md_short_jump_size, md_long_jump_size.
> 	* write.c [!WORKING_DOT_WORD]: Ditto.
> 	* tc.h [!WORKING_DOT_WORD]: Declare them here.  Drop const
> 	qualifier.
> 	* config/tc-cris.h (md_short_jump_size, md_long_jump_size): Don't
> 	declare.
> 	* config/tc-cris.c (md_short_jump_size, md_long_jump_size): Drop
> 	const qualifier in these definitions.
> 	* config/tc-i370.c, config/tc-m68k.c, config/tc-pdp11.c,
> 	config/tc-s390.c, config/tc-tahoe.c, config/tc-vax.c: Ditto.

OK.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: [RFA:] unconstify md_short_jump_size, md_long_jump_size (was: Re: Gas: making md_long_jump_size mutable)
  2004-11-03  0:45   ` [RFA:] unconstify md_short_jump_size, md_long_jump_size (was: Re: Gas: making md_long_jump_size mutable) Hans-Peter Nilsson
  2004-11-03  0:59     ` Alan Modra
@ 2004-11-04  1:53     ` Ian Lance Taylor
  2004-11-04  2:21       ` Hans-Peter Nilsson
  1 sibling, 1 reply; 6+ messages in thread
From: Ian Lance Taylor @ 2004-11-04  1:53 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:

> BTW, beware of the length of asm:s
> when using CASE_VECTOR_SHORTEN_MODE; they *really* should be set
> to max (can be done through define_asm_attributes it seems), so
> that a branch across them can never be "shortened", not set to
> some max length of a normal insn.

I'm working with Thumb code, which already completely breaks if the
code includes asms with the wrong length.  The Thumb compiler depends
upon knowing the length of every instruction in order to correctly
pick which branch instruction to use, and in order to place the
constant pools.

In practice I doubt many people use asms with Thumb code, as there
isn't much the Thumb can do which gcc can not do easily enough.
Interesting stuff would probably always be done in ARM mode.

Ian

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

* Re: [RFA:] unconstify md_short_jump_size, md_long_jump_size (was: Re: Gas: making md_long_jump_size mutable)
  2004-11-04  1:53     ` Ian Lance Taylor
@ 2004-11-04  2:21       ` Hans-Peter Nilsson
  0 siblings, 0 replies; 6+ messages in thread
From: Hans-Peter Nilsson @ 2004-11-04  2:21 UTC (permalink / raw)
  To: ian; +Cc: hans-peter.nilsson, binutils, gcc

> From: Ian Lance Taylor <ian@wasabisystems.com>
> Date: 03 Nov 2004 20:53:10 -0500

> Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:
> 
> > BTW, beware of the length of asm:s
> > when using CASE_VECTOR_SHORTEN_MODE; they *really* should be set
> > to max (can be done through define_asm_attributes it seems), so
> > that a branch across them can never be "shortened", not set to
> > some max length of a normal insn.
> 
> I'm working with Thumb code, which already completely breaks if the
> code includes asms with the wrong length.  The Thumb compiler depends
> upon knowing the length of every instruction in order to correctly
> pick which branch instruction to use, and in order to place the
> constant pools.

By your description it still sounds as if it's just a safe upper
limit, similar to most other attribute-length ports.  I just
mean that asms can break this safe-upper-limits handled by the
port, and they shouldn't be allowed to do that.

Hmm, this could be solved by allowing the programmer to specify
__attribute__ ((__length__)) on an asm.  That seems natural and
maybe it Just Works, but it isn't mentioned in extend.texi in
@subsection Size of an @code{asm}.  Getting off-topic here, so
moving the thread to gcc@.

> In practice I doubt many people use asms with Thumb code, as there
> isn't much the Thumb can do which gcc can not do easily enough.
> Interesting stuff would probably always be done in ARM mode.

Directives and section tricks such as used in Linux in the
get_user and put_user macros (include/asm/uaccess.h) comes to
mind.  FWIW, some people would appreciate the kernel compilable
in thumb mode; this doesn't work currently AFAIK.  Right, those
macros are unlikely to give asm length problems, they're just an
example of Creative Use of Asms.

brgds, H-P

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

end of thread, other threads:[~2004-11-04  2:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-29 15:34 Gas: making md_long_jump_size mutable Hans-Peter Nilsson
2004-10-29 15:45 ` Ian Lance Taylor
2004-11-03  0:45   ` [RFA:] unconstify md_short_jump_size, md_long_jump_size (was: Re: Gas: making md_long_jump_size mutable) Hans-Peter Nilsson
2004-11-03  0:59     ` Alan Modra
2004-11-04  1:53     ` Ian Lance Taylor
2004-11-04  2:21       ` Hans-Peter Nilsson

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).