aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2007-10-04 17:05:37 +0000
committerNick Clifton <nickc@redhat.com>2007-10-04 17:05:37 +0000
commit38a57ae7a5cafb2eeca853494a6c2aa994efc956 (patch)
treecfb9b9ac767db4859052e315d77269ec398da808
parent45d42143d489a6b7ee78fd118b573906c43ecb0b (diff)
downloadgdb-38a57ae7a5cafb2eeca853494a6c2aa994efc956.zip
gdb-38a57ae7a5cafb2eeca853494a6c2aa994efc956.tar.gz
gdb-38a57ae7a5cafb2eeca853494a6c2aa994efc956.tar.bz2
* 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.
-rw-r--r--gas/ChangeLog22
-rw-r--r--gas/NEWS3
-rw-r--r--gas/config/obj-coff.c2
-rw-r--r--gas/config/obj-elf.c2
-rw-r--r--gas/config/tc-alpha.c2
-rw-r--r--gas/config/tc-dlx.c2
-rw-r--r--gas/config/tc-hppa.c2
-rw-r--r--gas/config/tc-ia64.c11
-rw-r--r--gas/config/tc-m68hc11.c2
-rw-r--r--gas/config/tc-mcore.c6
-rw-r--r--gas/config/tc-mips.c2
-rw-r--r--gas/config/tc-s390.c2
-rw-r--r--gas/config/tc-spu.c2
-rw-r--r--gas/doc/as.texinfo29
-rw-r--r--gas/read.c78
-rw-r--r--gas/testsuite/ChangeLog6
-rw-r--r--gas/testsuite/gas/all/gas.exp2
-rw-r--r--gas/testsuite/gas/all/string.d12
-rw-r--r--gas/testsuite/gas/all/string.s14
19 files changed, 160 insertions, 41 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index ef12adb..6694d98 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -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
diff --git a/gas/NEWS b/gas/NEWS
index 8f6f370..d9c5579 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -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:
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index 9bbeca4..4bcede6 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -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);
}
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 014117a..8f696d7 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -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);
}
diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c
index 69bd575..2b3cb6d 100644
--- a/gas/config/tc-alpha.c
+++ b/gas/config/tc-alpha.c
@@ -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. */
diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c
index 1c751db..e429166 100644
--- a/gas/config/tc-dlx.c
+++ b/gas/config/tc-dlx.c
@@ -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},
diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c
index 05c7f12..996c002 100644
--- a/gas/config/tc-hppa.c
+++ b/gas/config/tc-hppa.c
@@ -8150,7 +8150,7 @@ pa_stringer (int append_zero)
}
}
}
- stringer (append_zero);
+ stringer (8 + append_zero);
pa_undefine_label ();
}
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index 04995cc..55f05a4 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -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 },
diff --git a/gas/config/tc-m68hc11.c b/gas/config/tc-m68hc11.c
index dcd1ce6..b228ea5 100644
--- a/gas/config/tc-m68hc11.c
+++ b/gas/config/tc-m68hc11.c
@@ -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. */
diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c
index fa7c911..0604ad9 100644
--- a/gas/config/tc-mcore.c
+++ b/gas/config/tc-mcore.c
@@ -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 },
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index be50025..6c6baf0 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -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},
diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index dc5ca26..deb7307 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -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 }
};
diff --git a/gas/config/tc-spu.c b/gas/config/tc-spu.c
index f50f716..924c6fc 100644
--- a/gas/config/tc-spu.c
+++ b/gas/config/tc-spu.c
@@ -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},
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index bf8bab7..a59b272 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -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}}
diff --git a/gas/read.c b/gas/read.c
index 4c13d87..baf85be 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -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
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 7967a1a..f2cb037 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -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
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index 081c418..119eeb0 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -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]] "" ""
diff --git a/gas/testsuite/gas/all/string.d b/gas/testsuite/gas/all/string.d
new file mode 100644
index 0000000..da6177d
--- /dev/null
+++ b/gas/testsuite/gas/all/string.d
@@ -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
diff --git a/gas/testsuite/gas/all/string.s b/gas/testsuite/gas/all/string.s
new file mode 100644
index 0000000..80743bb
--- /dev/null
+++ b/gas/testsuite/gas/all/string.s
@@ -0,0 +1,14 @@
+ .data
+ .string "str8"
+
+ .balign 16
+ .string8 "strnew8"
+
+ .balign 16
+ .string16 "str16"
+
+ .balign 16
+ .string32 "32"
+
+ .balign 16
+ .string64 "64"