aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c120
1 files changed, 94 insertions, 26 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6995891b5..46325db 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -114,9 +114,9 @@ struct symbol *lookup_symbol_aux_minsyms (const char *name,
struct symtab **symtab);
#endif
-/* This flag is used in hppa-tdep.c, and set in hp-symtab-read.c */
-/* Signals the presence of objects compiled by HP compilers */
-int hp_som_som_object_present = 0;
+/* This flag is used in hppa-tdep.c, and set in hp-symtab-read.c.
+ Signals the presence of objects compiled by HP compilers. */
+int deprecated_hp_som_som_object_present = 0;
static void fixup_section (struct general_symbol_info *, struct objfile *);
@@ -181,21 +181,25 @@ got_symtab:
if (full_path != NULL)
{
- const char *fp = symtab_to_filename (s);
- if (FILENAME_CMP (full_path, fp) == 0)
- {
- return s;
- }
+ const char *fp = symtab_to_fullname (s);
+ if (fp != NULL && FILENAME_CMP (full_path, fp) == 0)
+ {
+ return s;
+ }
}
if (real_path != NULL)
{
- char *rp = gdb_realpath (symtab_to_filename (s));
- make_cleanup (xfree, rp);
- if (FILENAME_CMP (real_path, rp) == 0)
- {
- return s;
- }
+ char *fullname = symtab_to_fullname (s);
+ if (fullname != NULL)
+ {
+ char *rp = gdb_realpath (fullname);
+ make_cleanup (xfree, rp);
+ if (FILENAME_CMP (real_path, rp) == 0)
+ {
+ return s;
+ }
+ }
}
}
@@ -427,9 +431,9 @@ create_demangled_names_hash (struct objfile *objfile)
Choosing a much larger table size wastes memory, and saves only about
1% in symbol reading. */
- objfile->demangled_names_hash = htab_create_alloc_ex
+ objfile->demangled_names_hash = htab_create_alloc
(256, htab_hash_string, (int (*) (const void *, const void *)) streq,
- NULL, objfile->md, xmcalloc, xmfree);
+ NULL, xcalloc, xfree);
}
/* Try to determine the demangled name for a symbol, based on the
@@ -659,6 +663,14 @@ symbol_demangled_name (struct general_symbol_info *gsymbol)
return NULL;
}
+/* Return the search name of a symbol---generally the demangled or
+ linkage name of the symbol, depending on how it will be searched for.
+ If there is no distinct demangled name, then returns the same value
+ (same pointer) as SYMBOL_LINKAGE_NAME. */
+char *symbol_search_name (const struct general_symbol_info *gsymbol) {
+ return symbol_natural_name (gsymbol);
+}
+
/* Initialize the structure fields to zero values. */
void
init_sal (struct symtab_and_line *sal)
@@ -868,6 +880,62 @@ fixup_section (struct general_symbol_info *ginfo, struct objfile *objfile)
ginfo->bfd_section = SYMBOL_BFD_SECTION (msym);
ginfo->section = SYMBOL_SECTION (msym);
}
+ else if (objfile)
+ {
+ /* Static, function-local variables do appear in the linker
+ (minimal) symbols, but are frequently given names that won't
+ be found via lookup_minimal_symbol(). E.g., it has been
+ observed in frv-uclinux (ELF) executables that a static,
+ function-local variable named "foo" might appear in the
+ linker symbols as "foo.6" or "foo.3". Thus, there is no
+ point in attempting to extend the lookup-by-name mechanism to
+ handle this case due to the fact that there can be multiple
+ names.
+
+ So, instead, search the section table when lookup by name has
+ failed. The ``addr'' and ``endaddr'' fields may have already
+ been relocated. If so, the relocation offset (i.e. the
+ ANOFFSET value) needs to be subtracted from these values when
+ performing the comparison. We unconditionally subtract it,
+ because, when no relocation has been performed, the ANOFFSET
+ value will simply be zero.
+
+ The address of the symbol whose section we're fixing up HAS
+ NOT BEEN adjusted (relocated) yet. It can't have been since
+ the section isn't yet known and knowing the section is
+ necessary in order to add the correct relocation value. In
+ other words, we wouldn't even be in this function (attempting
+ to compute the section) if it were already known.
+
+ Note that it is possible to search the minimal symbols
+ (subtracting the relocation value if necessary) to find the
+ matching minimal symbol, but this is overkill and much less
+ efficient. It is not necessary to find the matching minimal
+ symbol, only its section.
+
+ Note that this technique (of doing a section table search)
+ can fail when unrelocated section addresses overlap. For
+ this reason, we still attempt a lookup by name prior to doing
+ a search of the section table. */
+
+ CORE_ADDR addr;
+ struct obj_section *s;
+
+ addr = ginfo->value.address;
+
+ ALL_OBJFILE_OSECTIONS (objfile, s)
+ {
+ int idx = s->the_bfd_section->index;
+ CORE_ADDR offset = ANOFFSET (objfile->section_offsets, idx);
+
+ if (s->addr - offset <= addr && addr < s->endaddr - offset)
+ {
+ ginfo->bfd_section = s->the_bfd_section;
+ ginfo->section = idx;
+ return;
+ }
+ }
+ }
}
struct symbol *
@@ -1467,7 +1535,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
{
do_linear_search = 1;
}
- if (strcmp_iw_ordered (SYMBOL_NATURAL_NAME (*center), name) >= 0)
+ if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center), name) >= 0)
{
top = center;
}
@@ -1482,7 +1550,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
while (top <= real_top
&& (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0
- : SYMBOL_MATCHES_NATURAL_NAME (*top,name)))
+ : SYMBOL_MATCHES_SEARCH_NAME (*top,name)))
{
if (SYMBOL_DOMAIN (*top) == domain)
{
@@ -1503,7 +1571,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
{
if (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0
- : SYMBOL_MATCHES_NATURAL_NAME (*psym, name))
+ : SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
{
return (*psym);
}
@@ -2349,7 +2417,7 @@ find_function_start_sal (struct symbol *sym, int funfirstline)
!section_is_mapped (section))
pc = overlay_unmapped_address (pc, section);
- pc += FUNCTION_START_OFFSET;
+ pc += DEPRECATED_FUNCTION_START_OFFSET;
pc = SKIP_PROLOGUE (pc);
/* For overlays, map pc back into its mapped VMA range */
@@ -3068,12 +3136,12 @@ print_msymbol_info (struct minimal_symbol *msymbol)
char *tmp;
if (TARGET_ADDR_BIT <= 32)
- tmp = local_hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol)
- & (CORE_ADDR) 0xffffffff,
- "08l");
+ tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol)
+ & (CORE_ADDR) 0xffffffff,
+ 8);
else
- tmp = local_hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol),
- "016l");
+ tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol),
+ 16);
printf_filtered ("%s %s\n",
tmp, SYMBOL_PRINT_NAME (msymbol));
}
@@ -3921,7 +3989,7 @@ skip_prologue_using_sal (CORE_ADDR func_addr)
/* Get an initial range for the function. */
find_pc_partial_function (func_addr, NULL, &start_pc, &end_pc);
- start_pc += FUNCTION_START_OFFSET;
+ start_pc += DEPRECATED_FUNCTION_START_OFFSET;
prologue_sal = find_pc_line (start_pc, 0);
if (prologue_sal.line != 0)