summaryrefslogtreecommitdiff
path: root/gas/cond.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-07-19 11:35:06 +0000
committerNick Clifton <nickc@redhat.com>2002-07-19 11:35:06 +0000
commit72b81fca321604554c5596bbd8112cc04b35b9e3 (patch)
treeb9a4b578103dd55ac50d2758b890614ab584b3e4 /gas/cond.c
parent88efa26942ac4cd0e3d5721dfee4a997c1245e00 (diff)
downloadbinutils-redhat-72b81fca321604554c5596bbd8112cc04b35b9e3.tar.gz
Make .ifdef treat a referenced but not yet defined symbol as if it were
undefined, in exactly the same way as .equiv.
Diffstat (limited to 'gas/cond.c')
-rw-r--r--gas/cond.c58
1 files changed, 38 insertions, 20 deletions
diff --git a/gas/cond.c b/gas/cond.c
index 73304cbcbd..b7a4082c52 100644
--- a/gas/cond.c
+++ b/gas/cond.c
@@ -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