summaryrefslogtreecommitdiff
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
commit8dfa01881ff9ef48218af54fea4ec507278fa3d7 (patch)
tree2d0ce7b5d459620c22ab9835ed8eff1b6cce2e7f /gas/cond.c
parent2002-07-17 Michal Ludvig <michal@suse.cz> (diff)
downloadbinutils-gdb-8dfa01881ff9ef48218af54fea4ec507278fa3d7.tar.gz
binutils-gdb-8dfa01881ff9ef48218af54fea4ec507278fa3d7.tar.bz2
binutils-gdb-8dfa01881ff9ef48218af54fea4ec507278fa3d7.zip
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 73304cbcbd5..b7a4082c528 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