Make .ifdef treat a referenced but not yet defined symbol as if it were

undefined, in exactly the same way as .equiv.
This commit is contained in:
Nick Clifton 2002-07-19 11:35:06 +00:00
parent fb16b90083
commit 8dfa01881f
3 changed files with 59 additions and 26 deletions

View file

@ -1,3 +1,14 @@
2002-07-19 Miroslav Tichy <tichm9am@ss1000.ms.mff.cuni.cz>
Nick Clifton <nickc@redhat.com>
* cond.c (s_ifdef): Treat a referenced but not yet defined
symbol as if it were undefined, in exactly the same way as
.equiv.
* doc/as.texinfo: Document that .ifdef, .ifndef and .equiv
consider referenced bug not yet defined symbols to be
undefined.
2002-07-18 Denis Chertykov <denisc@overta.ru> 2002-07-18 Denis Chertykov <denisc@overta.ru>
Frank Ch. Eigler <fche@redhat.com> Frank Ch. Eigler <fche@redhat.com>
Alan Lehotsky <alehotsky@cygnus.com> Alan Lehotsky <alehotsky@cygnus.com>

View file

@ -60,15 +60,19 @@ static char *get_mri_string PARAMS ((int, int *));
static struct conditional_frame *current_cframe = NULL; static struct conditional_frame *current_cframe = NULL;
/* Performs the .ifdef (test_defined == 1) and
the .ifndef (test_defined == 0) pseudo op. */
void void
s_ifdef (arg) s_ifdef (test_defined)
int arg; int test_defined;
{ {
/* Points to name of symbol. */ /* Points to name of symbol. */
register char *name; char *name;
/* Points to symbol. */ /* Points to symbol. */
register symbolS *symbolP; symbolS *symbolP;
struct conditional_frame cframe; struct conditional_frame cframe;
char c;
/* Leading whitespace is part of operand. */ /* Leading whitespace is part of operand. */
SKIP_WHITESPACE (); SKIP_WHITESPACE ();
@ -79,29 +83,43 @@ s_ifdef (arg)
as_bad (_("invalid identifier for \".ifdef\"")); as_bad (_("invalid identifier for \".ifdef\""));
obstack_1grow (&cond_obstack, 0); obstack_1grow (&cond_obstack, 0);
ignore_rest_of_line (); ignore_rest_of_line ();
return;
} }
c = get_symbol_end ();
symbolP = symbol_find (name);
*input_line_pointer = c;
initialize_cframe (&cframe);
if (cframe.dead_tree)
cframe.ignoring = 1;
else else
{ {
char c; int is_defined;
c = get_symbol_end (); /* Use the same definition of 'defined' as .equiv so that a symbol
symbolP = symbol_find (name); which has been referenced but not yet given a value/address is
*input_line_pointer = c; considered to be undefined. */
is_defined =
symbolP != NULL
&& S_IS_DEFINED (symbolP)
&& S_GET_SEGMENT (symbolP) != reg_section;
initialize_cframe (&cframe); cframe.ignoring = ! (test_defined ^ is_defined);
cframe.ignoring = cframe.dead_tree || !((symbolP != 0) ^ arg); }
current_cframe = ((struct conditional_frame *)
obstack_copy (&cond_obstack, &cframe,
sizeof (cframe)));
if (LISTING_SKIP_COND () current_cframe = ((struct conditional_frame *)
&& cframe.ignoring obstack_copy (&cond_obstack, &cframe,
&& (cframe.previous_cframe == NULL sizeof (cframe)));
|| ! cframe.previous_cframe->ignoring))
listing_list (2);
demand_empty_rest_of_line (); if (LISTING_SKIP_COND ()
} /* if a valid identifyer name */ && cframe.ignoring
&& (cframe.previous_cframe == NULL
|| ! cframe.previous_cframe->ignoring))
listing_list (2);
demand_empty_rest_of_line ();
} }
void void

View file

@ -241,7 +241,7 @@ code for @value{TARGET} architectures.
@cindex option summary @cindex option summary
@cindex summary of options @cindex summary of options
Here is a brief summary of how to invoke @command{@value{AS}}. For details, Here is a brief summary of how to invoke @command{@value{AS}}. For details,
@pxref{Invoking,,Comand-Line Options}. @pxref{Invoking,,Command-Line Options}.
@c man title AS the portable GNU assembler. @c man title AS the portable GNU assembler.
@ -686,7 +686,7 @@ Scenix IP2K series.
Specifies that the extended IP2022 instructions are allowed. Specifies that the extended IP2022 instructions are allowed.
@item -mip2022 @item -mip2022
Restores the default behaviour, which restricts the permited instructions to Restores the default behaviour, which restricts the permitted instructions to
just the basic IP2022 ones. just the basic IP2022 ones.
@end table @end table
@ -1580,7 +1580,7 @@ dump appears on the left hand side of the listing output.
@kindex --listing-lhs-width2 @kindex --listing-lhs-width2
@cindex Width of continuation lines of disassembly output @cindex Width of continuation lines of disassembly output
Sets the maximum width, in words, of any further lines of the hex byte dump for Sets the maximum width, in words, of any further lines of the hex byte dump for
a given inut source line. If this value is not specified, it defaults to being a given input source line. If this value is not specified, it defaults to being
the same as the value specified for @samp{--listing-lhs-width}. If neither the same as the value specified for @samp{--listing-lhs-width}. If neither
switch is used the default is to one. switch is used the default is to one.
@ -4074,7 +4074,9 @@ The syntax for @code{equ} on the HPPA is
@section @code{.equiv @var{symbol}, @var{expression}} @section @code{.equiv @var{symbol}, @var{expression}}
@cindex @code{equiv} directive @cindex @code{equiv} directive
The @code{.equiv} directive is like @code{.equ} and @code{.set}, except that The @code{.equiv} directive is like @code{.equ} and @code{.set}, except that
the assembler will signal an error if @var{symbol} is already defined. the assembler will signal an error if @var{symbol} is already defined. Note a
symbol which has been referenced but not actually defined is considered to be
undefined.
Except for the contents of the error message, this is roughly equivalent to Except for the contents of the error message, this is roughly equivalent to
@smallexample @smallexample
@ -4273,7 +4275,8 @@ The following variants of @code{.if} are also supported:
@cindex @code{ifdef} directive @cindex @code{ifdef} directive
@item .ifdef @var{symbol} @item .ifdef @var{symbol}
Assembles the following section of code if the specified @var{symbol} Assembles the following section of code if the specified @var{symbol}
has been defined. has been defined. Note a symbol which has been referenced but not yet defined
is considered to be undefined.
@cindex @code{ifc} directive @cindex @code{ifc} directive
@item .ifc @var{string1},@var{string2} @item .ifc @var{string1},@var{string2}
@ -4319,7 +4322,8 @@ following section of code if the two strings are not the same.
@item .ifndef @var{symbol} @item .ifndef @var{symbol}
@itemx .ifnotdef @var{symbol} @itemx .ifnotdef @var{symbol}
Assembles the following section of code if the specified @var{symbol} Assembles the following section of code if the specified @var{symbol}
has not been defined. Both spelling variants are equivalent. has not been defined. Both spelling variants are equivalent. Note a symbol
which has been referenced but not yet defined is considered to be undefined.
@cindex @code{ifne} directive @cindex @code{ifne} directive
@item .ifne @var{absolute expression} @item .ifne @var{absolute expression}