diff options
author | Tom Tromey <tom@tromey.com> | 2018-05-03 16:36:21 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-07-26 09:18:31 -0600 |
commit | 7974897237f7708d440c45bc74cdfb70a2db8124 (patch) | |
tree | be125266c70e1b0f8595874080bfedad1b971687 /gdb/dbxread.c | |
parent | 52948f01e4a11f5fcebdca112036f907ac69e7ad (diff) | |
download | gdb-7974897237f7708d440c45bc74cdfb70a2db8124.zip gdb-7974897237f7708d440c45bc74cdfb70a2db8124.tar.gz gdb-7974897237f7708d440c45bc74cdfb70a2db8124.tar.bz2 |
Make psymbols and psymtabs independent of the program space
This patch finally makes partial symbols and partial symtabs
independent of the program space.
Specifically:
It changes add_psymbol_to_list to accept a section index, and changes
the psymbol readers to pass this. At the same time it removes the
code to add the objfile's section offset to the psymbol.
It adds an objfile argument to the psymtab textlow and texthigh
accessors and changes some code to use the raw variants instead.
It removes the "relocate" method from struct quick_symbol_functions,
as it is no longer needed any more.
It changes partial_symbol::address so that the relevant offset is now
applied at the point of use.
gdb/ChangeLog
2018-07-26 Tom Tromey <tom@tromey.com>
* dwarf-index-write.c (add_address_entry): Don't add objfile
offsets.
* dbxread.c (find_stab_function): Rename from
find_stab_function_addr. Return a bound_minimal_symbol.
(read_dbx_symtab): Use raw_text_low, raw_text_high.
Don't add objfile offsets.
(end_psymtab): Use raw_text_low, raw_text_high,
MSYMBOL_VALUE_RAW_ADDRESS.
(read_ofile_symtab): Update.
(process_one_symbol): Update.
* dwarf2read.c (create_addrmap_from_index): Don't add objfile
offsets.
(dw2_relocate): Remove.
(dw2_find_pc_sect_symtab): Bias PC by the text offset before
searching addrmap.
(dwarf2_gdb_index_functions, dwarf2_debug_names_functions):
Update.
(process_psymtab_comp_unit_reader, add_partial_symbol)
(add_partial_subprogram, dwarf2_ranges_read): Update.
(load_partial_dies): Update.
(add_address_entry): Don't add objfile offsets.
(dwarf2_build_include_psymtabs): Update.
(create_addrmap_from_aranges): Don't add objfile offsets.
(dw2_find_pc_sect_compunit_symtab): Update.
* mdebugread.c (parse_symbol): Don't add objfile offsets.
(parse_lines): Remove 'pst' parameter, replace with 'textlow'.
Update.
(parse_partial_symbols): Don't add objfile offsets. Use
raw_text_low, raw_text_high. Update.
(handle_psymbol_enumerators, psymtab_to_symtab_1): Update.
* objfiles.c (objfile_relocate1): Don't relocate psymtabs_addrmap
or call 'relocate' quick function. Clear psymbol_map.
* psympriv.h (struct partial_symbol) <address>: Add section
offset.
<set_unrelocated_address>: Rename from set_address.
<raw_text_low, raw_text_high>: New methods.
<text_low, text_high>: Add objfile parameter.
(add_psymbol_to_bcache): Add 'section' parameter. Call
set_unrelocated_address.
* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymtab)
(find_pc_psymbol): Update.
(fixup_psymbol_section, relocate_psymtabs): Remove.
(dump_psymtab, psym_functions): Update.
(add_psymbol_to_bcache, add_psymbol_to_list): Add 'section'
parameter.
(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
(start_psymtab_common): Update.
* symfile-debug.c (debug_qf_relocate): Remove.
(debug_sym_quick_functions): Update.
* symfile.h (struct quick_symbol_functions) <relocate>: Remove.
* xcoffread.c (scan_xcoff_symtab): Don't add objfile offsets.
Update.
Diffstat (limited to 'gdb/dbxread.c')
-rw-r--r-- | gdb/dbxread.c | 137 |
1 files changed, 51 insertions, 86 deletions
diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 5409a72..e004e8c 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -902,9 +902,9 @@ set_namestring (struct objfile *objfile, const struct internal_nlist *nlist) return namestring; } -static CORE_ADDR -find_stab_function_addr (const char *namestring, const char *filename, - struct objfile *objfile) +static struct bound_minimal_symbol +find_stab_function (const char *namestring, const char *filename, + struct objfile *objfile) { struct bound_minimal_symbol msym; int n; @@ -944,7 +944,7 @@ find_stab_function_addr (const char *namestring, const char *filename, msym = lookup_minimal_symbol (p, NULL, objfile); } - return msym.minsym == NULL ? 0 : BMSYMBOL_VALUE_ADDRESS (msym); + return msym; } static void @@ -1137,18 +1137,15 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) || (namestring[(nsl = strlen (namestring)) - 1] == 'o' && namestring[nsl - 2] == '.')) { - nlist.n_value += ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); - if (past_first_source_file && pst /* The gould NP1 uses low values for .o and -l symbols which are not the address. */ - && nlist.n_value >= pst->text_low ()) + && nlist.n_value >= pst->raw_text_low ()) { dbx_end_psymtab (objfile, pst, psymtab_include_list, includes_used, symnum * symbol_size, - nlist.n_value > pst->text_high () - ? nlist.n_value : pst->text_high (), + nlist.n_value > pst->raw_text_high () + ? nlist.n_value : pst->raw_text_high (), dependency_list, dependencies_used, textlow_not_set); pst = (struct partial_symtab *) 0; @@ -1235,8 +1232,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) static const char *dirname_nso; int prev_textlow_not_set; - valu = nlist.n_value + ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); + valu = nlist.n_value; prev_textlow_not_set = textlow_not_set; @@ -1263,8 +1259,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) { dbx_end_psymtab (objfile, pst, psymtab_include_list, includes_used, symnum * symbol_size, - (valu > pst->text_high () - ? valu : pst->text_high ()), + (valu > pst->raw_text_high () + ? valu : pst->raw_text_high ()), dependency_list, dependencies_used, prev_textlow_not_set); pst = (struct partial_symtab *) 0; @@ -1438,7 +1434,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) function relative stabs, or the address of the function's end for old style stabs. */ valu = nlist.n_value + last_function_start; - if (pst->text_high () == 0 || valu > pst->text_high ()) + if (pst->raw_text_high () == 0 || valu > pst->raw_text_high ()) pst->set_text_high (valu); break; } @@ -1478,25 +1474,22 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) switch (p[1]) { case 'S': - nlist.n_value += ANOFFSET (objfile->section_offsets, - data_sect_index); - if (gdbarch_static_transform_name_p (gdbarch)) gdbarch_static_transform_name (gdbarch, namestring); add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_STATIC, + data_sect_index, &objfile->static_psymbols, nlist.n_value, psymtab_language, objfile); continue; case 'G': - nlist.n_value += ANOFFSET (objfile->section_offsets, - data_sect_index); /* The addresses in these entries are reported to be wrong. See the code that reads 'G's for symtabs. */ add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_STATIC, + data_sect_index, &objfile->global_psymbols, nlist.n_value, psymtab_language, objfile); continue; @@ -1513,14 +1506,14 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) && namestring[0] != ' ')) { add_psymbol_to_list (sym_name, sym_len, 1, - STRUCT_DOMAIN, LOC_TYPEDEF, + STRUCT_DOMAIN, LOC_TYPEDEF, -1, &objfile->static_psymbols, 0, psymtab_language, objfile); if (p[2] == 't') { /* Also a typedef with the same name. */ add_psymbol_to_list (sym_name, sym_len, 1, - VAR_DOMAIN, LOC_TYPEDEF, + VAR_DOMAIN, LOC_TYPEDEF, -1, &objfile->static_psymbols, 0, psymtab_language, objfile); p += 1; @@ -1532,7 +1525,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) if (p != namestring) /* a name is there, not just :T... */ { add_psymbol_to_list (sym_name, sym_len, 1, - VAR_DOMAIN, LOC_TYPEDEF, + VAR_DOMAIN, LOC_TYPEDEF, -1, &objfile->static_psymbols, 0, psymtab_language, objfile); } @@ -1593,7 +1586,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) /* Note that the value doesn't matter for enum constants in psymtabs, just in symtabs. */ add_psymbol_to_list (p, q - p, 1, - VAR_DOMAIN, LOC_CONST, + VAR_DOMAIN, LOC_CONST, -1, &objfile->static_psymbols, 0, psymtab_language, objfile); /* Point past the name. */ @@ -1611,7 +1604,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) case 'c': /* Constant, e.g. from "const" in Pascal. */ add_psymbol_to_list (sym_name, sym_len, 1, - VAR_DOMAIN, LOC_CONST, + VAR_DOMAIN, LOC_CONST, -1, &objfile->static_psymbols, 0, psymtab_language, objfile); continue; @@ -1627,28 +1620,19 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) function_outside_compilation_unit_complaint (name); xfree (name); } - nlist.n_value += ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); /* Kludges for ELF/STABS with Sun ACC. */ last_function_name = namestring; /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit value for the bottom of the text seg in those cases. */ - if (nlist.n_value == ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)) + if (nlist.n_value == 0 && gdbarch_sofun_address_maybe_missing (gdbarch)) { - CORE_ADDR minsym_valu = - find_stab_function_addr (namestring, - pst ? pst->filename : NULL, - objfile); - - /* find_stab_function_addr will return 0 if the minimal - symbol wasn't found. (Unfortunately, this might also - be a valid address.) Anyway, if it *does* return 0, - it is likely that the value was set correctly to begin - with... */ - if (minsym_valu != 0) - nlist.n_value = minsym_valu; + struct bound_minimal_symbol minsym + = find_stab_function (namestring, + pst ? pst->filename : NULL, + objfile); + if (minsym.minsym != NULL) + nlist.n_value = MSYMBOL_VALUE_RAW_ADDRESS (minsym.minsym); } if (pst && textlow_not_set && gdbarch_sofun_address_maybe_missing (gdbarch)) @@ -1668,16 +1652,15 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) the partial symbol table. */ if (pst && (textlow_not_set - || (nlist.n_value < pst->text_low () - && (nlist.n_value - != ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)))))) + || (nlist.n_value < pst->raw_text_low () + && (nlist.n_value != 0)))) { pst->set_text_low (nlist.n_value); textlow_not_set = 0; } add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_BLOCK, + SECT_OFF_TEXT (objfile), &objfile->static_psymbols, nlist.n_value, psymtab_language, objfile); continue; @@ -1696,28 +1679,19 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) function_outside_compilation_unit_complaint (name); xfree (name); } - nlist.n_value += ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); /* Kludges for ELF/STABS with Sun ACC. */ last_function_name = namestring; /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit value for the bottom of the text seg in those cases. */ - if (nlist.n_value == ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)) + if (nlist.n_value == 0 && gdbarch_sofun_address_maybe_missing (gdbarch)) { - CORE_ADDR minsym_valu = - find_stab_function_addr (namestring, - pst ? pst->filename : NULL, - objfile); - - /* find_stab_function_addr will return 0 if the minimal - symbol wasn't found. (Unfortunately, this might also - be a valid address.) Anyway, if it *does* return 0, - it is likely that the value was set correctly to begin - with... */ - if (minsym_valu != 0) - nlist.n_value = minsym_valu; + struct bound_minimal_symbol minsym + = find_stab_function (namestring, + pst ? pst->filename : NULL, + objfile); + if (minsym.minsym != NULL) + nlist.n_value = MSYMBOL_VALUE_RAW_ADDRESS (minsym.minsym); } if (pst && textlow_not_set && gdbarch_sofun_address_maybe_missing (gdbarch)) @@ -1737,16 +1711,15 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) the partial symbol table. */ if (pst && (textlow_not_set - || (nlist.n_value < pst->text_low () - && (nlist.n_value - != ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)))))) + || (nlist.n_value < pst->raw_text_low () + && (nlist.n_value != 0)))) { pst->set_text_low (nlist.n_value); textlow_not_set = 0; } add_psymbol_to_list (sym_name, sym_len, 1, VAR_DOMAIN, LOC_BLOCK, + SECT_OFF_TEXT (objfile), &objfile->global_psymbols, nlist.n_value, psymtab_language, objfile); continue; @@ -1922,15 +1895,14 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile) is. */ CORE_ADDR text_end = (lowest_text_address == (CORE_ADDR) -1 - ? (text_addr + ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile))) + ? text_addr : lowest_text_address) + text_size; dbx_end_psymtab (objfile, pst, psymtab_include_list, includes_used, symnum * symbol_size, - (text_end > pst->text_high () - ? text_end : pst->text_high ()), + (text_end > pst->raw_text_high () + ? text_end : pst->raw_text_high ()), dependency_list, dependencies_used, textlow_not_set); } } @@ -2029,7 +2001,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst, } if (minsym.minsym) - pst->set_text_high (BMSYMBOL_VALUE_ADDRESS (minsym) + pst->set_text_high (MSYMBOL_VALUE_RAW_ADDRESS (minsym.minsym) + MSYMBOL_SIZE (minsym.minsym)); last_function_name = NULL; @@ -2039,7 +2011,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst, ; /* This test will be true if the last .o file is only data. */ else if (textlow_not_set) - pst->set_text_low (pst->text_high ()); + pst->set_text_low (pst->raw_text_high ()); else { struct partial_symtab *p1; @@ -2052,7 +2024,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst, ALL_OBJFILE_PSYMTABS (objfile, p1) { if (!p1->text_high_valid && p1->text_low_valid && p1 != pst) - p1->set_text_high (pst->text_low ()); + p1->set_text_high (pst->raw_text_low ()); } } @@ -2238,8 +2210,8 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst) sym_offset = LDSYMOFF (pst); sym_size = LDSYMLEN (pst); - text_offset = pst->text_low (); - text_size = pst->text_high () - pst->text_low (); + text_offset = pst->text_low (objfile); + text_size = pst->text_high (objfile) - pst->text_low (objfile); section_offsets = objfile->section_offsets; dbxread_objfile = objfile; @@ -2849,18 +2821,11 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name, SECT_OFF_TEXT (objfile)) && gdbarch_sofun_address_maybe_missing (gdbarch)) { - CORE_ADDR minsym_valu = - find_stab_function_addr (name, get_last_source_file (), - objfile); - - /* The function find_stab_function_addr will return - 0 if the minimal symbol wasn't found. - (Unfortunately, this might also be a valid - address.) Anyway, if it *does* return 0, it is - likely that the value was set correctly to begin - with... */ - if (minsym_valu != 0) - valu = minsym_valu; + struct bound_minimal_symbol minsym + = find_stab_function (name, get_last_source_file (), + objfile); + if (minsym.minsym != NULL) + valu = BMSYMBOL_VALUE_ADDRESS (minsym); } /* These addresses are absolute. */ |