This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: New keywords (string32) for GNU as ?


Hello Nick,

On Friday 24 November 2006, Nick Clifton wrote:
> Hi Dave, Hi Helge,
> 
> >   BTW, we still need to hear from an official maintainer; I've only got
> > write-after-approval access myself.  But I can certainly recommend this patch
> > as well designed and thoroughly implemented.
> 
> Thank you Helge for writing this patch and thank you Dave for reviewing it.
> 
> Helge - I will be happy to accept and apply your patch once the FSF 
> copyright assignment issue is resolved.   

It took me nearly a year to finalize the FSF copyright assignments.
FSF did filed it as "DellerBinutils321085pdf". If you need more details please let me know.

Do you think you can apply my patches now ?
Since this thread is really a long time ago now, the original thread and patches - for reference - were here:
http://sourceware.org/ml/binutils/2006-11/msg00231.html
http://sourceware.org/ml/binutils/2006-11/msg00230.html

I've cleaned up the patch against current CVS head and attached it below.
Additionally, the full patch can be downloaded at: http://gsyprf11.external.hp.com/~deller/gas_new.diff

Best regards,
Helge

ChangeLog:
2007-10-03  Helge Deller  <deller@gmx.de>

	* read.c (potable): Add string8, string16, string32 and string64.
	Add bit size for stringer function.
	(stringer_append_char): New.
	(stringer): Use stringer_append_char().
	* config/obj-coff.c (obj_coff_ident): Add bit size for stringer function.
	* config/obj-elf.c (obj_elf_ident): Likewise.
	* config/tc-alpha.c (s_alpha_stringer): Likewise.
	* config/tc-dlx.c (dlx_pseudo_table): Likewise.
	* config/tc-hppa.c (pa_stringer): Likewise.
	* config/tc-ia64.c (md_pseudo_table, pseudo_opcode): Likewise.
	* config/tc-m68hc11.c (md_pseudo_table): Likewise.
	* config/tc-mcore.c (md_pseudo_table): Likewise.
	* config/tc-mips.c (mips_pseudo_table): Likewise.
	* config/tc-spu.c (md_pseudo_table): Likewise.
	* config/tc-s390.c (md_pseudo_table): Likewise. Replace '2' by '1'.
	* doc/as.texinfo (ABORT): Fix identing.
	(String): Document new string8, string16, string32, string64 functions.
	* testsuite/gas/all/gas.exp: Include new test "strings"
	* testsuite/gas/all/string.s, testsuite/gas/all/string.d: New.


Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.130
diff -u -p -r1.130 read.c
--- gas/read.c	18 Sep 2007 01:05:44 -0000	1.130
+++ gas/read.c	3 Oct 2007 11:38:47 -0000
@@ -270,8 +270,8 @@ static const pseudo_typeS potable[] = {
   {"abort", s_abort, 0},
   {"align", s_align_ptwo, 0},
   {"altmacro", s_altmacro, 1},
-  {"ascii", stringer, 0},
-  {"asciz", stringer, 1},
+  {"ascii", stringer, 8+0},
+  {"asciz", stringer, 8+1},
   {"balign", s_align_bytes, 0},
   {"balignw", s_align_bytes, -2},
   {"balignl", s_align_bytes, -4},
@@ -416,7 +416,11 @@ static const pseudo_typeS potable[] = {
   {"stabd", s_stab, 'd'},
   {"stabn", s_stab, 'n'},
   {"stabs", s_stab, 's'},
-  {"string", stringer, 1},
+  {"string", stringer, 8+1},
+  {"string8", stringer, 8+1},
+  {"string16", stringer, 16+1},
+  {"string32", stringer, 32+1},
+  {"string64", stringer, 64+1},
   {"struct", s_struct, 0},
 /* tag  */
   {"text", s_text, 0},
@@ -4960,6 +4964,36 @@ s_leb128 (int sign)
   input_line_pointer--;
   demand_empty_rest_of_line ();
 }
+
+static void stringer_append_char( int c, int bitsize )
+{
+   if (!target_big_endian)
+	FRAG_APPEND_1_CHAR(c);
+   switch (bitsize) {
+	case 64:
+		FRAG_APPEND_1_CHAR(0);
+		FRAG_APPEND_1_CHAR(0);
+		FRAG_APPEND_1_CHAR(0);
+		FRAG_APPEND_1_CHAR(0);
+		/* Fall through  */
+	case 32:
+		FRAG_APPEND_1_CHAR(0);
+		FRAG_APPEND_1_CHAR(0);
+		/* Fall through  */
+	case 16:
+		FRAG_APPEND_1_CHAR(0);
+		/* Fall through  */
+	case 8:
+		break;
+	default:
+		/* Called with invalid bitsize argument.  */
+		abort();
+		break;
+   }
+   if (target_big_endian)
+	FRAG_APPEND_1_CHAR(c);
+}
+
 
 /* We read 0 or more ',' separated, double-quoted strings.
    Caller should have checked need_pass_2 is FALSE because we don't
@@ -4968,8 +5002,12 @@ s_leb128 (int sign)
 void
 stringer (/* Worker to do .ascii etc statements.  */
 	  /* Checks end-of-line.  */
-	  register int append_zero	/* 0: don't append '\0', else 1.  */)
+	  int bits_appendzero )
+	  /* bits_appendzero: bit 0 = 0: don't append '\0', else 1.  */
+	  /* Upper bits in bits_appendzero define target char bitsize  */
 {
+  const int bitsize = bits_appendzero & ~7;
+  const int append_zero = bits_appendzero & 1;
   register unsigned int c;
   char *start;
 
@@ -5010,11 +5048,11 @@ stringer (/* Worker to do .ascii etc sta
 	  start = input_line_pointer;
 	  while (is_a_char (c = next_char_of_string ()))
 	    {
-	      FRAG_APPEND_1_CHAR (c);
+	      stringer_append_char (c, bitsize);
 	    }
 	  if (append_zero)
 	    {
-	      FRAG_APPEND_1_CHAR (0);
+	      stringer_append_char (0, bitsize);
 	    }
 	  know (input_line_pointer[-1] == '\"');
 
@@ -5042,7 +5080,7 @@ stringer (/* Worker to do .ascii etc sta
 	case '<':
 	  input_line_pointer++;
 	  c = get_single_number ();
-	  FRAG_APPEND_1_CHAR (c);
+	  stringer_append_char (c, bitsize);
 	  if (*input_line_pointer != '>')
 	    {
 	      as_bad (_("expected <nn>"));
Index: gas/config/obj-coff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-coff.c,v
retrieving revision 1.93
diff -u -p -r1.93 obj-coff.c
--- gas/config/obj-coff.c	17 Sep 2007 17:15:30 -0000	1.93
+++ gas/config/obj-coff.c	3 Oct 2007 11:38:47 -0000
@@ -497,7 +497,7 @@ obj_coff_ident (int ignore ATTRIBUTE_UNU
   subseg_new (".comment", 0);
 #endif
 
-  stringer (1);
+  stringer (8+1);
   subseg_set (current_seg, current_subseg);
 }
 
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.103
diff -u -p -r1.103 obj-elf.c
--- gas/config/obj-elf.c	3 Jul 2007 11:01:04 -0000	1.103
+++ gas/config/obj-elf.c	3 Oct 2007 11:38:47 -0000
@@ -1618,7 +1618,7 @@ obj_elf_ident (int ignore ATTRIBUTE_UNUS
     }
   else
     subseg_set (comment_section, 0);
-  stringer (1);
+  stringer (8+1);
   subseg_set (old_section, old_subsection);
 }
 
Index: gas/config/tc-alpha.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-alpha.c,v
retrieving revision 1.73
diff -u -p -r1.73 tc-alpha.c
--- gas/config/tc-alpha.c	3 Jul 2007 11:01:04 -0000	1.73
+++ gas/config/tc-alpha.c	3 Oct 2007 11:38:48 -0000
@@ -4527,7 +4527,7 @@ s_alpha_stringer (int terminate)
 {
   alpha_current_align = 0;
   alpha_insn_label = NULL;
-  stringer (terminate);
+  stringer (8+terminate);
 }
 
 /* Hook the normal space processing to reset known alignment.  */
Index: gas/config/tc-dlx.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-dlx.c,v
retrieving revision 1.16
diff -u -p -r1.16 tc-dlx.c
--- gas/config/tc-dlx.c	3 Jul 2007 11:01:04 -0000	1.16
+++ gas/config/tc-dlx.c	3 Oct 2007 11:38:48 -0000
@@ -1276,7 +1276,7 @@ const pseudo_typeS
 dlx_pseudo_table[] =
 {
   /* Some additional ops that are used by gcc-dlx.  */
-  {"asciiz", stringer, 1},
+  {"asciiz", stringer, 8+1},
   {"half", cons, 2},
   {"dword", cons, 8},
   {"word", cons, 4},
Index: gas/config/tc-hppa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.c,v
retrieving revision 1.134
diff -u -p -r1.134 tc-hppa.c
--- gas/config/tc-hppa.c	3 Jul 2007 11:01:04 -0000	1.134
+++ gas/config/tc-hppa.c	3 Oct 2007 11:38:48 -0000
@@ -8150,7 +8150,7 @@ pa_stringer (int append_zero)
 	    }
 	}
     }
-  stringer (append_zero);
+  stringer (8+append_zero);
   pa_undefine_label ();
 }
 
Index: gas/config/tc-ia64.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.c,v
retrieving revision 1.194
diff -u -p -r1.194 tc-ia64.c
--- gas/config/tc-ia64.c	26 Sep 2007 06:58:01 -0000	1.194
+++ gas/config/tc-ia64.c	3 Oct 2007 11:38:49 -0000
@@ -5527,8 +5527,8 @@ const pseudo_typeS md_pseudo_table[] =
     { "xreal8", dot_xfloat_cons, 'd' },
     { "xreal10", dot_xfloat_cons, 'x' },
     { "xreal16", dot_xfloat_cons, 'X' },
-    { "xstring", dot_xstringer, 0 },
-    { "xstringz", dot_xstringer, 1 },
+    { "xstring", dot_xstringer, 8+0 },
+    { "xstringz", dot_xstringer, 8+1 },
 
     /* unaligned versions:  */
     { "xdata2.ua", dot_xdata_ua, 2 },
@@ -5585,8 +5585,8 @@ pseudo_opcode[] =
     { "real8", stmt_float_cons, 'd' },
     { "real10", stmt_float_cons, 'x' },
     { "real16", stmt_float_cons, 'X' },
-    { "string", stringer, 0 },
-    { "stringz", stringer, 1 },
+    { "string", stringer, 8+0 },
+    { "stringz", stringer, 8+1 },
 
     /* unaligned versions:  */
     { "data2.ua", stmt_cons_ua, 2 },
Index: gas/config/tc-m68hc11.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68hc11.c,v
retrieving revision 1.52
diff -u -p -r1.52 tc-m68hc11.c
--- gas/config/tc-m68hc11.c	3 Jul 2007 11:01:04 -0000	1.52
+++ gas/config/tc-m68hc11.c	3 Oct 2007 11:38:49 -0000
@@ -263,7 +263,7 @@ const pseudo_typeS md_pseudo_table[] = {
   /* The following pseudo-ops are supported for MRI compatibility.  */
   {"fcb", cons, 1},
   {"fdb", cons, 2},
-  {"fcc", stringer, 1},
+  {"fcc", stringer, 8+1},
   {"rmb", s_space, 0},
 
   /* Motorola ALIS.  */
Index: gas/config/tc-mcore.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mcore.c,v
retrieving revision 1.43
diff -u -p -r1.43 tc-mcore.c
--- gas/config/tc-mcore.c	3 Jul 2007 11:01:04 -0000	1.43
+++ gas/config/tc-mcore.c	3 Oct 2007 11:38:49 -0000
@@ -411,8 +411,8 @@ const pseudo_typeS md_pseudo_table[] =
      occupy can be taken into account when deciding whether or not to
      dump the current literal pool.
      XXX - currently we do not cope with the .space and .dcb.d directives.  */
-  { "ascii",    mcore_stringer,       0 },
-  { "asciz",    mcore_stringer,       1 },
+  { "ascii",    mcore_stringer,     8+0 },
+  { "asciz",    mcore_stringer,     8+1 },
   { "byte",     mcore_cons,           1 },
   { "dc",       mcore_cons,           2 },
   { "dc.b",     mcore_cons,           1 },
@@ -430,7 +430,7 @@ const pseudo_typeS md_pseudo_table[] =
   { "quad",     mcore_cons,           8 },
   { "short",    mcore_cons,           2 },
   { "single",   mcore_float_cons,    'f'},
-  { "string",   mcore_stringer,       1 },
+  { "string",   mcore_stringer,     8+1 },
   { "word",     mcore_cons,           2 },
   { "fill",     mcore_fill,           0 },
 
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.374
diff -u -p -r1.374 tc-mips.c
--- gas/config/tc-mips.c	24 Sep 2007 22:08:20 -0000	1.374
+++ gas/config/tc-mips.c	3 Oct 2007 11:38:50 -0000
@@ -1109,7 +1109,7 @@ static const pseudo_typeS mips_pseudo_ta
 
   /* Relatively generic pseudo-ops that happen to be used on MIPS
      chips.  */
-  {"asciiz", stringer, 1},
+  {"asciiz", stringer, 8+1},
   {"bss", s_change_sec, 'b'},
   {"err", s_err, 0},
   {"half", s_cons, 1},
Index: gas/config/tc-s390.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-s390.c,v
retrieving revision 1.51
diff -u -p -r1.51 tc-s390.c
--- gas/config/tc-s390.c	3 Jul 2007 11:01:04 -0000	1.51
+++ gas/config/tc-s390.c	3 Oct 2007 11:38:50 -0000
@@ -95,7 +95,7 @@ const pseudo_typeS md_pseudo_table[] =
   { "long",	s390_elf_cons,	4 },
   { "quad",     s390_elf_cons,  8 },
   { "ltorg",    s390_literals,  0 },
-  { "string",   stringer,       2 },
+  { "string",   stringer,       8+1 },
   { NULL,	NULL,		0 }
 };
 
Index: gas/config/tc-spu.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-spu.c,v
retrieving revision 1.8
diff -u -p -r1.8 tc-spu.c
--- gas/config/tc-spu.c	4 Sep 2007 04:10:21 -0000	1.8
+++ gas/config/tc-spu.c	3 Oct 2007 11:38:50 -0000
@@ -91,7 +91,7 @@ const pseudo_typeS md_pseudo_table[] =
   {"int", spu_cons, 4},
   {"long", spu_cons, 4},
   {"quad", spu_cons, 8},
-  {"string", stringer, 1},
+  {"string", stringer, 8+1},
   {"word", spu_cons, 4},
   /* Force set to be treated as an instruction.  */
   {"set", NULL, 0},
Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.167
diff -u -p -r1.167 as.texinfo
--- gas/doc/as.texinfo	24 Aug 2007 21:49:55 -0000	1.167
+++ gas/doc/as.texinfo	3 Oct 2007 11:38:51 -0000
@@ -3776,7 +3776,7 @@ Some machine configurations provide addi
 @menu
 * Abort::                       @code{.abort}
 @ifset COFF
-* ABORT (COFF)::                       @code{.ABORT}
+* ABORT (COFF)::		@code{.ABORT}
 @end ifset
 
 * Align::                       @code{.align @var{abs-expr} , @var{abs-expr}}
@@ -3908,7 +3908,7 @@ Some machine configurations provide addi
 * Stab::                        @code{.stabd, .stabn, .stabs}
 @end ifset
 
-* String::                      @code{.string "@var{str}"}
+* String::			@code{.string | .string8 | .string16 | .string32 | .string64 "@var{str}"}
 * Struct::			@code{.struct @var{expression}}
 @ifset ELF
 * SubSection::                  @code{.subsection}
@@ -5932,16 +5932,38 @@ All five fields are specified.
 @c end     have-stabs
 
 @node String
-@section @code{.string} "@var{str}"
+@section @code{.string | .string8 | .string16 | .string32 | .string64 "@var{str}"}
 
 @cindex string, copying to object file
+@cindex string8, copying to object file
+@cindex string16, copying to object file
+@cindex string32, copying to object file
+@cindex string64, copying to object file
 @cindex @code{string} directive
+@cindex @code{string8} directive
+@cindex @code{string16} directive
+@cindex @code{string32} directive
+@cindex @code{string64} directive
 
 Copy the characters in @var{str} to the object file.  You may specify more than
 one string to copy, separated by commas.  Unless otherwise specified for a
 particular machine, the assembler marks the end of each string with a 0 byte.
 You can use any of the escape sequences described in @ref{Strings,,Strings}.
 
+The variants @code{string16}, @code{string32} and @code{string64} differ from 
+the original @code{string} Pseudo Opcode in that way, that each (8 bit) character
+from the @var{STR} string is copied and expanded to 16, 32 or 64bit respectively.
+Each 16, 32 or 64bit value will then be copied in target endianess byte order 
+to the object file.
+
+Example:
+@smallexample
+	.string32 "BYE"
+expands to:
+	.string   "B\0\0\0Y\0\0\0E\0\0\0"  /* on little endian targets  */
+	.string   "\0\0\0B\0\0\0Y\0\0\0E"  /* on big endian targets  */
+@end smallexample
+
 @node Struct
 @section @code{.struct @var{expression}}
 
Index: gas/testsuite/gas/all/gas.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/gas.exp,v
retrieving revision 1.48
diff -u -p -r1.48 gas.exp
--- gas/testsuite/gas/all/gas.exp	28 Aug 2007 13:21:53 -0000	1.48
+++ gas/testsuite/gas/all/gas.exp	3 Oct 2007 11:38:51 -0000
@@ -297,6 +297,8 @@ gas_test_error "weakref2.s" "" "e: would
 gas_test_error "weakref3.s" "" "a: would close weakref loop: a => b => c => d => e => a"
 gas_test_error "weakref4.s" "" "is already defined"
 
+run_dump_test string
+
 load_lib gas-dg.exp
 dg-init
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""



--- ./testsuite/gas/all/string.d.org	2006-11-21 23:54:18.000000000 +0100
+++ ./testsuite/gas/all/string.d	2006-11-21 23:53:32.000000000 +0100
@@ -0,0 +1,13 @@
+#objdump : -s -j .data -j "\$DATA\$"
+#name : .strings tests
+
+.*: .*
+
+Contents of section (\.data|\$DATA\$):
+ 0000 73747238 00000000 00000000 00000000  str8.*
+ 0010 7374726e 65773800 00000000 00000000  strnew8.*
+ 0020 (73007400 72003100 36000000 00000000|00730074 00720031 00360000 00000000).*
+ 0030 (33000000 32000000 00000000 00000000|00000033 00000032 00000000 00000000).*
+ 0040 (36000000 00000000 34000000 00000000|00000000 00000036 00000000 00000034).*
+#pass
+
--- ./testsuite/gas/all/string.s.org	2006-11-21 23:54:21.000000000 +0100
+++ ./testsuite/gas/all/string.s	2006-11-21 23:01:41.000000000 +0100
@@ -0,0 +1,14 @@
+	.data
+	.string 	"str8"
+
+	.align 16
+	.string8	"strnew8"
+
+	.align 16
+	.string16	"str16"
+
+	.align 16
+	.string32	"32"
+
+	.align 16
+	.string64	"64"




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]