From d6d6b18ab241417382c3141f8d26db24eea566ea Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 1 Apr 1994 23:01:53 +0000 Subject: [PATCH] * aoutx.h (aout_link_write_symbols): If keep_memory is false, make sure the symbol name is stored in permanent memory before adding it to the string table. --- bfd/ChangeLog | 4 ++++ bfd/aoutx.h | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8bda4bc12b9..f7b00c27dfb 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,9 @@ Fri Apr 1 12:40:58 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + * aoutx.h (aout_link_write_symbols): If keep_memory is false, make + sure the symbol name is stored in permanent memory before adding + it to the string table. + * archive.c (_bfd_write_archive_contents): Once we've found an object, don't bother to look for more when deciding whether to build a map. diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 6a7fba8cb4d..70a722b5d9b 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -3734,6 +3734,7 @@ aout_link_write_symbols (finfo, input_bfd, symbol_map) { const char *name; int type; + struct aout_link_hash_entry *h; boolean skip; asection *symsec; bfd_vma val = 0; @@ -3743,6 +3744,8 @@ aout_link_write_symbols (finfo, input_bfd, symbol_map) type = bfd_h_get_8 (input_bfd, sym->e_type); name = strings + GET_WORD (input_bfd, sym->e_strx); + h = NULL; + if (pass) { /* Pass this symbol through. It is the target of an @@ -3760,7 +3763,6 @@ aout_link_write_symbols (finfo, input_bfd, symbol_map) } else { - struct aout_link_hash_entry *h; struct aout_link_hash_entry *hresolve; /* We have saved the hash table entry for this symbol, if @@ -3949,6 +3951,22 @@ aout_link_write_symbols (finfo, input_bfd, symbol_map) outsym->e_other); bfd_h_put_16 (output_bfd, bfd_h_get_16 (input_bfd, sym->e_desc), outsym->e_desc); + if (! finfo->info->keep_memory) + { + /* name points into a string table which we are going to + free. If there is a hash table entry, use that string. + Otherwise, copy name into memory. */ + if (h != (struct aout_link_hash_entry *) NULL) + name = (*sym_hash)->root.root.string; + else + { + char *n; + + n = bfd_alloc (output_bfd, strlen (name) + 1); + strcpy (n, name); + name = n; + } + } PUT_WORD (output_bfd, add_to_stringtab (output_bfd, name, &finfo->strtab), outsym->e_strx); -- 2.30.2