aboutsummaryrefslogtreecommitdiff
path: root/ld/ldexp.c
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2003-10-11 09:16:20 +0000
committerHans-Peter Nilsson <hp@axis.com>2003-10-11 09:16:20 +0000
commit420e579cc4f1252a4e915ad866b49f76bda0c1cd (patch)
tree29b5a094a982cb9d580baa4e6c9640f0d7fd8f8a /ld/ldexp.c
parenta8f4cde1ae3d737931ac9d9b58865da965f2b9b9 (diff)
downloadgdb-420e579cc4f1252a4e915ad866b49f76bda0c1cd.zip
gdb-420e579cc4f1252a4e915ad866b49f76bda0c1cd.tar.gz
gdb-420e579cc4f1252a4e915ad866b49f76bda0c1cd.tar.bz2
* ld.texinfo (Builtin Functions) <DEFINED>: Say that only symbols
defined before the statement using DEFINED yield 1. * ldexp.c (fold_name) <case DEFINED>: In lang_first_phase_enum, call lang_track_definedness on symbol. In subsequent phases, use lang_symbol_definition_iteration and lang_statement_iteration to check whether the symbol was defined before the current statement. (exp_fold_tree) <case etree_assign et al>: Call lang_update_definedness before updating symbol type when setting symbol. * ldlang.c (lang_definedness_table): New variable. (lang_definedness_newfunc, lang_track_definedness) (lang_symbol_definition_iteration, lang_update_definedness): New functions. (lang_init): Initialize lang_definedness_table and lang_statement_iteration. (lang_finish): Destroy bfd_hash_table_free. (lang_size_sections): Increment lang_statement_iteration. (lang_do_assignments_1): New function with former lang_do_assignments contents. Change recursive calls to call this function. (lang_do_assignments): Evacuate contents. Increment lang_statement_iteration, then just call lang_do_assignments_1. * ldlang.h (struct lang_definedness_hash_entry) (lang_statement_iteration, lang_track_definedness) (lang_symbol_definition_iteration, lang_update_definedness): Declare.
Diffstat (limited to 'ld/ldexp.c')
-rw-r--r--ld/ldexp.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ld/ldexp.c b/ld/ldexp.c
index cce0cdf..80d79cf 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -485,10 +485,15 @@ fold_name (etree_type *tree,
break;
case DEFINED:
if (allocation_done == lang_first_phase_enum)
- result.valid_p = FALSE;
+ {
+ lang_track_definedness (tree->name.name);
+ result.valid_p = FALSE;
+ }
else
{
struct bfd_link_hash_entry *h;
+ int def_iteration
+ = lang_symbol_definition_iteration (tree->name.name);
h = bfd_wrapped_link_hash_lookup (output_bfd, &link_info,
tree->name.name,
@@ -496,7 +501,9 @@ fold_name (etree_type *tree,
result.value = (h != NULL
&& (h->type == bfd_link_hash_defined
|| h->type == bfd_link_hash_defweak
- || h->type == bfd_link_hash_common));
+ || h->type == bfd_link_hash_common)
+ && (def_iteration == lang_statement_iteration
+ || def_iteration == -1));
result.section = abs_output_section;
result.valid_p = TRUE;
}
@@ -738,6 +745,7 @@ exp_fold_tree (etree_type *tree,
{
/* FIXME: Should we worry if the symbol is already
defined? */
+ lang_update_definedness (tree->assign.dst, h);
h->type = bfd_link_hash_defined;
h->u.def.value = result.value;
h->u.def.section = result.section->bfd_section;