* 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.
This commit is contained in:
Hans-Peter Nilsson
2003-10-11 09:16:20 +00:00
parent a8f4cde1ae
commit 420e579cc4
5 changed files with 184 additions and 17 deletions

View File

@@ -361,6 +361,14 @@ struct unique_sections {
const char *name;
};
/* This structure records symbols for which we need to keep track of
definedness for use in the DEFINED () test. */
struct lang_definedness_hash_entry {
struct bfd_hash_entry root;
int iteration;
};
extern struct unique_sections *unique_section_list;
extern lang_output_section_statement_type *abs_output_section;
@@ -375,6 +383,8 @@ extern const char *entry_section;
extern bfd_boolean entry_from_cmdline;
extern lang_statement_list_type file_chain;
extern int lang_statement_iteration;
extern void lang_init
(void);
extern struct memory_region_struct *lang_memory_region_lookup
@@ -517,5 +527,9 @@ extern void lang_add_unique
(const char *);
extern const char *lang_get_output_target
(void);
extern void lang_track_definedness (const char *);
extern int lang_symbol_definition_iteration (const char *);
extern void lang_update_definedness
(const char *, struct bfd_link_hash_entry *);
#endif