/* Read ELF (Executable and Linking Format) object files for GDB.
- Copyright (C) 1991-2021 Free Software Foundation, Inc.
+ Copyright (C) 1991-2022 Free Software Foundation, Inc.
Written by Fred Fish at Cygnus Support.
#include "symfile.h"
#include "objfiles.h"
#include "stabsread.h"
-#include "complaints.h"
#include "demangle.h"
#include "psympriv.h"
#include "filenames.h"
#include "debuginfod-support.h"
#include "dwarf2/public.h"
-/* A subclass of psymbol_functions that arranges to read the DWARF
- partial symbols when needed. */
-struct lazy_dwarf_reader : public psymbol_functions
-{
- using psymbol_functions::psymbol_functions;
-
- bool can_lazily_read_symbols () override
- {
- return true;
- }
-
- void read_partial_symbols (struct objfile *objfile) override
- {
- if (dwarf2_has_info (objfile, nullptr))
- dwarf2_build_psymtabs (objfile, this);
- }
-};
-
-extern const struct sym_fns elf_sym_fns_lazy_psyms;
-
/* The struct elfinfo is available only during ELF symbol table and
psymtab reading. It is destroyed at the completion of psymtab-reading.
It's local to elf_symfile_read. */
continue;
}
+ elf_symbol_type *elf_sym = (elf_symbol_type *) sym;
+
/* Skip "special" symbols, e.g. ARM mapping symbols. These are
symbols which do not correspond to objects in the symbol table,
but have some other target-specific meaning. */
NOTE: uweigand-20071112: Synthetic symbols do not
have an ELF-private part, so do not touch those. */
unsigned int shndx = type == ST_SYNTHETIC ? 0 :
- ((elf_symbol_type *) sym)->internal_elf_sym.st_shndx;
+ elf_sym->internal_elf_sym.st_shndx;
switch (shndx)
{
if (type != ST_SYNTHETIC)
{
/* Pass symbol size field in via BFD. FIXME!!! */
- elf_symbol_type *elf_sym = (elf_symbol_type *) sym;
SET_MSYMBOL_SIZE (msym, elf_sym->internal_elf_sym.st_size);
}
if (msym != NULL)
{
const char *atsign = strchr (sym->name, '@');
-
- if (atsign != NULL && atsign[1] == '@' && atsign > sym->name)
+ bool is_at_symbol = atsign != nullptr && atsign > sym->name;
+ bool is_plt = is_at_symbol && strcmp (atsign, "@plt") == 0;
+ int len = is_at_symbol ? atsign - sym->name : 0;
+
+ if (is_at_symbol
+ && !is_plt
+ && (elf_sym->version & VERSYM_HIDDEN) == 0)
+ record_minimal_symbol (reader,
+ gdb::string_view (sym->name, len),
+ true, symaddr, ms_type, sym->section,
+ objfile);
+ else if (is_plt)
{
- int len = atsign - sym->name;
-
- record_minimal_symbol (reader,
- gdb::string_view (sym->name, len),
- true, symaddr, ms_type, sym->section,
- objfile);
- }
- }
-
- /* For @plt symbols, also record a trampoline to the
- destination symbol. The @plt symbol will be used in
- disassembly, and the trampoline will be used when we are
- trying to find the target. */
- if (msym && ms_type == mst_text && type == ST_SYNTHETIC)
- {
- int len = strlen (sym->name);
-
- if (len > 4 && strcmp (sym->name + len - 4, "@plt") == 0)
- {
- struct minimal_symbol *mtramp;
-
- mtramp = record_minimal_symbol
- (reader, gdb::string_view (sym->name, len - 4), true,
- symaddr, mst_solib_trampoline, sym->section, objfile);
- if (mtramp)
+ /* For @plt symbols, also record a trampoline to the
+ destination symbol. The @plt symbol will be used
+ in disassembly, and the trampoline will be used
+ when we are trying to find the target. */
+ if (ms_type == mst_text && type == ST_SYNTHETIC)
{
- SET_MSYMBOL_SIZE (mtramp, MSYMBOL_SIZE (msym));
- mtramp->created_by_gdb = 1;
- mtramp->filename = filesymname;
- if (elf_make_msymbol_special_p)
- gdbarch_elf_make_msymbol_special (gdbarch,
- sym, mtramp);
+ struct minimal_symbol *mtramp;
+
+ mtramp = record_minimal_symbol
+ (reader, gdb::string_view (sym->name, len), true,
+ symaddr, mst_solib_trampoline, sym->section, objfile);
+ if (mtramp)
+ {
+ SET_MSYMBOL_SIZE (mtramp, MSYMBOL_SIZE (msym));
+ mtramp->created_by_gdb = 1;
+ mtramp->filename = filesymname;
+ if (elf_make_msymbol_special_p)
+ gdbarch_elf_make_msymbol_special (gdbarch,
+ sym, mtramp);
+ }
}
}
}
value = allocate_value (value_type);
gdbarch_return_value (gdbarch, func_func, value_type, regcache,
- value_contents_raw (value), NULL);
+ value_contents_raw (value).data (), NULL);
resolved_address = value_as_address (value);
resolved_pc = gdbarch_convert_from_func_ptr_addr
(gdbarch, resolved_address, current_inferior ()->top_target ());
}
if (dwarf2_has_info (objfile, NULL, true))
- {
- dw_index_kind index_kind;
-
- if (dwarf2_initialize_objfile (objfile, &index_kind))
- {
- switch (index_kind)
- {
- case dw_index_kind::GDB_INDEX:
- objfile->qf.push_front (make_dwarf_gdb_index ());
- break;
- case dw_index_kind::DEBUG_NAMES:
- objfile->qf.push_front (make_dwarf_debug_names ());
- break;
- }
- }
- else
- objfile->qf.emplace_front (new lazy_dwarf_reader);
- }
+ dwarf2_initialize_objfile (objfile);
/* If the file has its own symbol tables it has no separate debug
info. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to
SYMTABS/PSYMTABS. `.gnu_debuglink' may no longer be present with