From c05d2d43a0394809f89fb657b51d76c1105df3ce Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sun, 20 Mar 1994 23:27:37 +0000 Subject: [PATCH] * som.c (bfd_section_from_som_symbol): Renamed from som_section_from_subspace_index. Pass in a native SOM symbol. For executables, iterate through the sections to find out which contains the symbol's address rather than using the symbol_info field. (symbol_info has a different meaning for dynamicly linked executables.) --- bfd/ChangeLog | 7 +++++++ bfd/som.c | 47 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 7dcfd9b73db..b8db4c440ba 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,12 @@ Sun Mar 20 09:24:36 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + * som.c (bfd_section_from_som_symbol): Renamed from + som_section_from_subspace_index. Pass in a native SOM symbol. + For executables, iterate through the sections to find out + which contains the symbol's address rather than using the + symbol_info field. (symbol_info has a different meaning for + dynamicly linked executables.) + * trad-core.c (trad_unix_core_file_p): Don't pass abfd to bfd_zmalloc. diff --git a/bfd/som.c b/bfd/som.c index c5ba4d70953..495db709392 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -166,8 +166,8 @@ static boolean som_find_nearest_line PARAMS ((bfd *, asection *, CONST char **, unsigned int *)); static void som_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); -static asection * som_section_from_subspace_index PARAMS ((bfd *, - unsigned int)); +static asection * bfd_section_from_som_symbol PARAMS ((bfd *, + struct symbol_dictionary_record *)); static int log2 PARAMS ((unsigned int)); static bfd_reloc_status_type hppa_som_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, @@ -3616,18 +3616,41 @@ som_get_symtab_upper_bound (abfd) /* Convert from a SOM subspace index to a BFD section. */ static asection * -som_section_from_subspace_index (abfd, index) +bfd_section_from_som_symbol (abfd, symbol) bfd *abfd; - unsigned int index; + struct symbol_dictionary_record *symbol; { asection *section; - for (section = abfd->sections; section != NULL; section = section->next) - if (section->target_index == index) - return section; + /* The meaning of the symbol_info field changes for executables. So + only use the quick symbol_info mapping for incomplete objects. */ + if ((abfd->flags & EXEC_P) == 0) + { + unsigned int index = symbol->symbol_info; + for (section = abfd->sections; section != NULL; section = section->next) + if (section->target_index == index) + return section; - /* Should never happen. */ - abort(); + /* Should never happen. */ + abort(); + } + else + { + unsigned int value = symbol->symbol_value; + unsigned int found = 0; + + /* For executables we will have to use the symbol's address and + find out what section would contain that address. Yuk. */ + for (section = abfd->sections; section; section = section->next) + { + if (value >= section->vma + && value <= section->vma + section->_cooked_size) + return section; + } + + /* Should never happen. */ + abort (); + } } /* Read and save the symbol table associated with the given BFD. */ @@ -3762,8 +3785,7 @@ som_slurp_symbol_table (abfd) case SS_UNIVERSAL: sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL); - sym->symbol.section - = som_section_from_subspace_index (abfd, bufp->symbol_info); + sym->symbol.section = bfd_section_from_som_symbol (abfd, bufp); sym->symbol.value -= sym->symbol.section->vma; break; @@ -3774,8 +3796,7 @@ som_slurp_symbol_table (abfd) #endif case SS_LOCAL: sym->symbol.flags |= BSF_LOCAL; - sym->symbol.section - = som_section_from_subspace_index (abfd, bufp->symbol_info); + sym->symbol.section = bfd_section_from_som_symbol (abfd, bufp); sym->symbol.value -= sym->symbol.section->vma; break; } -- 2.30.2