* 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.
* NEWS: Mention the new feature.

* testsuite/gas/all/gas.exp: Include new test "strings".
* testsuite/gas/all/string.s: New
* testsuite/gas/all/string.d: New.
This commit is contained in:
Nick Clifton 2007-10-04 17:05:37 +00:00
parent 45d42143d4
commit 38a57ae7a5
19 changed files with 160 additions and 41 deletions

View File

@ -1,3 +1,25 @@
2007-10-04 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.
* NEWS: Mention the new feature.
2007-10-03 Nick Clifton <nickc@redhat.com>
PR gas/5078

View File

@ -1,4 +1,7 @@
-*- text -*-
* Support for generating wide character strings has been added via the new
pseudo ops: .string16, .string32 and .string64.
* Support for SSE5 has been added to the i386 port.
Changes in 2.18:

View File

@ -497,7 +497,7 @@ obj_coff_ident (int ignore ATTRIBUTE_UNUSED)
subseg_new (".comment", 0);
#endif
stringer (1);
stringer (8 + 1);
subseg_set (current_seg, current_subseg);
}

View File

@ -1618,7 +1618,7 @@ obj_elf_ident (int ignore ATTRIBUTE_UNUSED)
}
else
subseg_set (comment_section, 0);
stringer (1);
stringer (8 + 1);
subseg_set (old_section, old_subsection);
}

View File

@ -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. */

View File

@ -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},

View File

@ -8150,7 +8150,7 @@ pa_stringer (int append_zero)
}
}
}
stringer (append_zero);
stringer (8 + append_zero);
pa_undefine_label ();
}

View File

@ -5089,8 +5089,7 @@ dot_xfloat_cons (kind)
}
static void
dot_xstringer (zero)
int zero;
dot_xstringer (int zero)
{
cross_section (zero, stringer, 0);
}
@ -5527,8 +5526,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 +5584,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 },

View File

@ -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. */

View File

@ -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 },

View File

@ -1109,7 +1109,7 @@ static const pseudo_typeS mips_pseudo_table[] =
/* 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},

View File

@ -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 }
};

View File

@ -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},

View File

@ -3776,7 +3776,7 @@ Some machine configurations provide additional directives.
@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 additional directives.
* Stab:: @code{.stabd, .stabn, .stabs}
@end ifset
* String:: @code{.string "@var{str}"}
* String:: @code{.string "@var{str}"}, @code{.string8 "@var{str}"}, @code{.string16 "@var{str}"}, @code{.string32 "@var{str}"}, @code{.string64 "@var{str}"}
* Struct:: @code{.struct @var{expression}}
@ifset ELF
* SubSection:: @code{.subsection}
@ -5932,16 +5932,39 @@ All five fields are specified.
@c end have-stabs
@node String
@section @code{.string} "@var{str}"
@section @code{.string} "@var{str}", @code{.string8} "@var{str}", @code{.string16}
"@var{str}", @code{.string32} "@var{str}", @code{.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 @code{string} pseudo opcode in that each 8-bit character from @var{str} is
copied and expanded to 16, 32 or 64 bits respectively. The expanded characters
are stored in target endianness byte order.
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}}

View File

@ -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},
@ -4961,16 +4965,52 @@ s_leb128 (int sign)
demand_empty_rest_of_line ();
}
/* We read 0 or more ',' separated, double-quoted strings.
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);
}
/* Worker to do .ascii etc statements.
Reads 0 or more ',' separated, double-quoted strings.
Caller should have checked need_pass_2 is FALSE because we don't
check it. */
check it.
Checks for end-of-line.
BITS_APPENDZERO says how many bits are in a target char.
The bottom bit is set if a NUL char should be appended to the strings. */
void
stringer (/* Worker to do .ascii etc statements. */
/* Checks end-of-line. */
register int append_zero /* 0: don't append '\0', else 1. */)
stringer (int bits_appendzero)
{
register unsigned int c;
const int bitsize = bits_appendzero & ~7;
const int append_zero = bits_appendzero & 1;
unsigned int c;
char *start;
#ifdef md_flush_pending_output
@ -5008,14 +5048,13 @@ stringer (/* Worker to do .ascii etc statements. */
case '\"':
++input_line_pointer; /*->1st char of string. */
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] == '\"');
#ifndef NO_LISTING
@ -5042,11 +5081,10 @@ stringer (/* Worker to do .ascii etc statements. */
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>"));
}
as_bad (_("expected <nn>"));
input_line_pointer++;
break;
case ',':
@ -5058,7 +5096,7 @@ stringer (/* Worker to do .ascii etc statements. */
}
demand_empty_rest_of_line ();
} /* stringer() */
}
/* FIXME-SOMEDAY: I had trouble here on characters with the
high bits set. We'll probably also have trouble with

View File

@ -1,3 +1,9 @@
2007-10-04 Helge Deller <deller@gmx.de>
* gas/all/gas.exp: Include new test "strings".
* gas/all/string.s: New
* gas/all/string.d: New.
2007-10-01 Tristan Gingold <gingold@adacore.com>
* gas/ppc/altivec_xcoff.s: Do not use .machine pseudo-ops as it

View File

@ -297,6 +297,8 @@ gas_test_error "weakref2.s" "" "e: would close weakref loop: e => a => b => c =>
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]] "" ""

View File

@ -0,0 +1,12 @@
#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

View File

@ -0,0 +1,14 @@
.data
.string "str8"
.balign 16
.string8 "strnew8"
.balign 16
.string16 "str16"
.balign 16
.string32 "32"
.balign 16
.string64 "64"