OSDN Git Service

Make .ifdef treat a referenced but not yet defined symbol as if it were
authorNick Clifton <nickc@redhat.com>
Fri, 19 Jul 2002 11:35:06 +0000 (11:35 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 19 Jul 2002 11:35:06 +0000 (11:35 +0000)
undefined, in exactly the same way as .equiv.

gas/ChangeLog
gas/cond.c
gas/doc/as.texinfo

index 1d37c67..8daaa90 100644 (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>
            Frank Ch. Eigler  <fche@redhat.com>
            Alan Lehotsky  <alehotsky@cygnus.com>
index 73304cb..b7a4082 100644 (file)
@@ -60,15 +60,19 @@ static char *get_mri_string PARAMS ((int, int *));
 
 static struct conditional_frame *current_cframe = NULL;
 
+/* Performs the .ifdef (test_defined == 1) and
+   the .ifndef (test_defined == 0) pseudo op.  */
+
 void
-s_ifdef (arg)
-     int arg;
+s_ifdef (test_defined)
+     int test_defined;
 {
   /* Points to name of symbol.  */
-  register char *name;
+  char *name;
   /* Points to symbol.  */
-  register symbolS *symbolP;
+  symbolS *symbolP;
   struct conditional_frame cframe;
+  char c;
 
   /* Leading whitespace is part of operand.  */
   SKIP_WHITESPACE ();
@@ -79,29 +83,43 @@ s_ifdef (arg)
       as_bad (_("invalid identifier for \".ifdef\""));
       obstack_1grow (&cond_obstack, 0);
       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
     {
-      char c;
+      int is_defined;
 
-      c = get_symbol_end ();
-      symbolP = symbol_find (name);
-      *input_line_pointer = c;
+      /* Use the same definition of 'defined' as .equiv so that a symbol
+        which has been referenced but not yet given a value/address is
+        considered to be undefined.  */
+      is_defined =
+       symbolP != NULL
+       && S_IS_DEFINED (symbolP)
+       && S_GET_SEGMENT (symbolP) != reg_section;
 
-      initialize_cframe (&cframe);
-      cframe.ignoring = cframe.dead_tree || !((symbolP != 0) ^ arg);
-      current_cframe = ((struct conditional_frame *)
-                       obstack_copy (&cond_obstack, &cframe,
-                                     sizeof (cframe)));
+      cframe.ignoring = ! (test_defined ^ is_defined);
+    }
 
-      if (LISTING_SKIP_COND ()
-         && cframe.ignoring
-         && (cframe.previous_cframe == NULL
-             || ! cframe.previous_cframe->ignoring))
-       listing_list (2);
+  current_cframe = ((struct conditional_frame *)
+                   obstack_copy (&cond_obstack, &cframe,
+                                 sizeof (cframe)));
+
+  if (LISTING_SKIP_COND ()
+      && cframe.ignoring
+      && (cframe.previous_cframe == NULL
+         || ! cframe.previous_cframe->ignoring))
+    listing_list (2);
 
-      demand_empty_rest_of_line ();
-    }                          /* if a valid identifyer name */
+  demand_empty_rest_of_line ();
 }
 
 void
index 8504e57..a51ae81 100644 (file)
@@ -241,7 +241,7 @@ code for @value{TARGET} architectures.
 @cindex option summary
 @cindex summary of options
 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.
 
@@ -686,7 +686,7 @@ Scenix IP2K series.
 Specifies that the extended IP2022 instructions are allowed.
 
 @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.
 
 @end table
@@ -1580,7 +1580,7 @@ dump appears on the left hand side of the listing output.
 @kindex --listing-lhs-width2
 @cindex Width of continuation lines of disassembly output
 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
 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}}
 @cindex @code{equiv} directive
 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 
 @smallexample
@@ -4273,7 +4275,8 @@ The following variants of @code{.if} are also supported:
 @cindex @code{ifdef} directive
 @item .ifdef @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
 @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}
 @itemx .ifnotdef @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
 @item .ifne @var{absolute expression}