aboutsummaryrefslogtreecommitdiff
path: root/gas/read.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@cygnus>1994-12-31 00:08:40 +0000
committerKen Raeburn <raeburn@cygnus>1994-12-31 00:08:40 +0000
commitcd3b81bd4cda2f9e04cca02ea6539be322a46986 (patch)
tree3ec294699834a687853664c804eb37fc98da8ab1 /gas/read.c
parente12533e3e9b498fdd0702d5c1719eaf0bf05e5a6 (diff)
downloadgdb-cd3b81bd4cda2f9e04cca02ea6539be322a46986.zip
gdb-cd3b81bd4cda2f9e04cca02ea6539be322a46986.tar.gz
gdb-cd3b81bd4cda2f9e04cca02ea6539be322a46986.tar.bz2
Handle .space directive with non-constant operand:
* read.c (s_space): Rewrite to handle general expressions. Generate rs_space frags for non-constant values. * write.c (cvt_frag_to_fill): Treat rs_align_code and rs_space like rs_align and rs_org. Verify that fr_offset is non-negative, and force frag type to rs_fill only after assertion checks. (relax_segment): Treat rs_align_code like rs_align. Treat rs_space like rs_org in the first switch; in the second, force the operand to a constant, and use it for the growth size.
Diffstat (limited to 'gas/read.c')
-rw-r--r--gas/read.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/gas/read.c b/gas/read.c
index 3bedd14..2b20177 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -1425,38 +1425,54 @@ void
s_space (mult)
int mult;
{
- long temp_repeat;
- register long temp_fill;
- register char *p;
+ expressionS exp;
+ long temp_repeat, temp_fill;
+ char *p = 0;
/* Just like .fill, but temp_size = 1 */
- if (get_absolute_expression_and_terminator (&temp_repeat) == ',')
+ expression (&exp);
+ if (exp.X_op == O_constant
+ /* for testing purposes */
+ && 0)
{
- temp_fill = get_absolute_expression ();
+ long repeat;
+
+ repeat = exp.X_add_number;
+ if (mult)
+ repeat *= mult;
+ if (repeat <= 0)
+ {
+ as_warn (".space repeat count is %s, ignored",
+ repeat ? "negative" : "zero");
+ ignore_rest_of_line ();
+ return;
+ }
+
+ if (!need_pass_2)
+ p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0,
+ temp_repeat, (char *) 0);
}
else
{
- input_line_pointer--; /* Backup over what was not a ','. */
- temp_fill = 0;
+ if (!need_pass_2)
+ p = frag_var (rs_space, 1, 1, (relax_substateT) 0,
+ make_expr_symbol (&exp), 0L, (char *) 0);
}
- if (mult)
+ if (get_absolute_expression_and_terminator (&temp_repeat) == ',')
{
- temp_repeat *= mult;
+ temp_fill = get_absolute_expression ();
}
- if (temp_repeat <= 0)
+ else
{
- as_warn ("Repeat < 0, .space ignored");
- ignore_rest_of_line ();
- return;
+ input_line_pointer--; /* Backup over what was not a ','. */
+ temp_fill = 0;
}
- if (!need_pass_2)
+ if (p)
{
- p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0,
- temp_repeat, (char *) 0);
*p = temp_fill;
}
demand_empty_rest_of_line ();
-} /* s_space() */
+}
void
s_text (ignore)
@@ -1969,7 +1985,7 @@ parse_bitfield_cons (exp, nbytes)
widths, positions, and masks which most
of our current object formats don't
support.
-
+
In the specific case where a symbol
*is* defined in this assembly, we
*could* build fixups and track it, but
@@ -2481,7 +2497,7 @@ get_absolute_expression ()
if (exp.X_op != O_constant)
{
if (exp.X_op != O_absent)
- as_bad ("bad absolute expression; zero assumed");
+ as_bad ("bad or irreducible absolute expression; zero assumed");
exp.X_add_number = 0;
}
return exp.X_add_number;