diff options
author | Nick Clifton <nickc@redhat.com> | 2010-11-03 17:18:23 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2010-11-03 17:18:23 +0000 |
commit | e597fa086665187c4d0dea1c45d5c044e297af66 (patch) | |
tree | 425160e0e61155ace9a561b8166d4f3fc29c067c /ld/ldlang.c | |
parent | 74cea91bbb82d5e4afa212b67eaf53710fd99dcd (diff) | |
download | gdb-e597fa086665187c4d0dea1c45d5c044e297af66.zip gdb-e597fa086665187c4d0dea1c45d5c044e297af66.tar.gz gdb-e597fa086665187c4d0dea1c45d5c044e297af66.tar.bz2 |
PR ld/12001
* ldlang.c (ldlang_def_chain_list): New variable. Contains a list
of symbols defined via the --defsym command line option and
currently waiting assignment.
(insert_defined): Add a defined symbol to the symbol table.
(ldlang_add_def): Add a entry to the ldlang_def_chain_list.
(lang_place_defineds): Walk ldlang_def_chain_list defining the
symbols.
(lang_process): Call lang_place_defineds.
(lang_add_assignment): If the assignment has come from a --defsym
command line option then call lang_add_def.
* ld-script/default-script2.d: Fix expected address for text
section.
PR gold/12001
* script.h (class Symbol_assignment: name): New member. Returns
the name of the symbol.
* scrfipt.cc (Script_options::is_pending_assignment): New member.
Returns true if the given symbol name is on the list of
assignments wating to be processed.
* archive.cc (should_incldue_member): If the symbol is undefined,
check to see if it is on the list of symbols pending assignment.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index 95ef5f5..798d7a1 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -3344,6 +3344,65 @@ lang_place_undefineds (void) insert_undefined (ptr->name); } +typedef struct bfd_sym_chain ldlang_def_chain_list_type; + +static ldlang_def_chain_list_type ldlang_def_chain_list_head; + +/* Insert NAME as defined in the symbol table. */ + +static void +insert_defined (const char *name) +{ + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, name, TRUE, FALSE, TRUE); + if (h == NULL) + einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); + if (h->type == bfd_link_hash_new + || h->type == bfd_link_hash_undefined + || h->type == bfd_link_hash_undefweak) + { + h->type = bfd_link_hash_defined; + h->u.def.section = bfd_abs_section_ptr; + h->u.def.value = 0; + } +} + +/* Like lang_add_undef, but this time for symbols defined on the + command line. */ + +static void +ldlang_add_def (const char *const name) +{ + if (link_info.output_bfd != NULL) + insert_defined (xstrdup (name)); + else + { + ldlang_def_chain_list_type *new_def; + + new_def = (ldlang_def_chain_list_type *) stat_alloc (sizeof (*new_def)); + new_def->next = ldlang_def_chain_list_head.next; + ldlang_def_chain_list_head.next = new_def; + + new_def->name = xstrdup (name); + } +} + +/* Run through the list of defineds created above and place them + into the linker hash table as defined symbols belonging to the + script file. */ + +static void +lang_place_defineds (void) +{ + ldlang_def_chain_list_type *ptr; + + for (ptr = ldlang_def_chain_list_head.next; + ptr != NULL; + ptr = ptr->next) + insert_defined (ptr->name); +} + /* Check for all readonly or some readwrite sections. */ static void @@ -6350,6 +6409,7 @@ lang_process (void) /* Add to the hash table all undefineds on the command line. */ lang_place_undefineds (); + lang_place_defineds (); if (!bfd_section_already_linked_table_init ()) einfo (_("%P%F: Failed to create hash table\n")); @@ -6634,6 +6694,10 @@ lang_add_assignment (etree_type *exp) { lang_assignment_statement_type *new_stmt; + extern int parsing_defsym; + if (parsing_defsym) + ldlang_add_def (exp->assign.dst); + new_stmt = new_stat (lang_assignment_statement, stat_ptr); new_stmt->exp = exp; return new_stmt; |