diff options
author | Alan Modra <amodra@gmail.com> | 2002-03-20 07:49:53 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-03-20 07:49:53 +0000 |
commit | fcf0e35b46c1e373f87edfb6d043ed1f064b35d3 (patch) | |
tree | 62151735dac4faa7ac8dd55d1db6770114c22cb4 /ld | |
parent | c429b7ddd8505a241b6c1fc5e14f8cc7847443b0 (diff) | |
download | gdb-fcf0e35b46c1e373f87edfb6d043ed1f064b35d3.zip gdb-fcf0e35b46c1e373f87edfb6d043ed1f064b35d3.tar.gz gdb-fcf0e35b46c1e373f87edfb6d043ed1f064b35d3.tar.bz2 |
* ldlang.c (ldlang_add_undef): If the output bfd has been opened,
add the symbol to the linker hash table immediately.
(lang_place_undefineds): Split symbol creation out..
(insert_undefined): ..to here.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 7 | ||||
-rw-r--r-- | ld/ldlang.c | 41 |
2 files changed, 36 insertions, 12 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 3b55884..dda0b40 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2002-03-20 Alan Modra <amodra@bigpond.net.au> + + * ldlang.c (ldlang_add_undef): If the output bfd has been opened, + add the symbol to the linker hash table immediately. + (lang_place_undefineds): Split symbol creation out.. + (insert_undefined): ..to here. + 2002-03-18 David O'Brien <obrien@FreeBSD.org> * emultempl/elf32.em: Use lbasename vs. basename to fix problem where diff --git a/ld/ldlang.c b/ld/ldlang.c index b176f2d..83f6317 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -92,6 +92,7 @@ static bfd *open_output PARAMS ((const char *)); static void ldlang_open_output PARAMS ((lang_statement_union_type *)); static void open_input_bfds PARAMS ((lang_statement_union_type *, boolean)); static void lang_reasonable_defaults PARAMS ((void)); +static void insert_undefined PARAMS ((const char *)); static void lang_place_undefineds PARAMS ((void)); static void map_input_to_output_sections PARAMS ((lang_statement_union_type *, const char *, @@ -2010,7 +2011,11 @@ lang_reasonable_defaults () } /* Add the supplied name to the symbol table as an undefined reference. - Remove items from the chain as we open input bfds. */ + This is a two step process as the symbol table doesn't even exist at + the time the ld command line is processed. First we put the name + on a list, then, once the output file has been opened, transfer the + name to the symbol table. */ + typedef struct ldlang_undef_chain_list { struct ldlang_undef_chain_list *next; @@ -2031,6 +2036,28 @@ ldlang_add_undef (name) ldlang_undef_chain_list_head = new; new->name = xstrdup (name); + + if (output_bfd != NULL) + insert_undefined (new->name); +} + +/* Insert NAME as undefined in the symbol table. */ + +static void +insert_undefined (name) + const char *name; +{ + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, name, true, false, true); + if (h == (struct bfd_link_hash_entry *) 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->u.undef.abfd = NULL; + bfd_link_add_undef (link_info.hash, h); + } } /* Run through the list of undefineds created above and place them @@ -2046,17 +2073,7 @@ lang_place_undefineds () ptr != (ldlang_undef_chain_list_type *) NULL; ptr = ptr->next) { - struct bfd_link_hash_entry *h; - - h = bfd_link_hash_lookup (link_info.hash, ptr->name, true, false, true); - if (h == (struct bfd_link_hash_entry *) 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->u.undef.abfd = NULL; - bfd_link_add_undef (link_info.hash, h); - } + insert_undefined (ptr->name); } } |