const char *dll_name, struct objfile *objfile)
{
/* Add the stored offset to get the loaded address of the symbol. */
- CORE_ADDR vma = func_rva + section_data->vma_offset;
+ unrelocated_addr vma = unrelocated_addr (func_rva
+ + section_data->vma_offset);
/* Generate a (hopefully unique) qualified name using the first part
of the dll name, e.g. KERNEL32!AddAtomA. This matches the style
const char *forward_func_name, int ordinal,
const char *dll_name, struct objfile *objfile)
{
- CORE_ADDR vma, baseaddr;
struct bound_minimal_symbol msymbol;
enum minimal_symbol_type msymtype;
int forward_dll_name_len = strlen (forward_dll_name);
" \"%s\" in dll \"%s\", pointing to \"%s\"\n"),
sym_name, dll_name, forward_qualified_name.c_str ());
- vma = msymbol.value_address ();
+ unrelocated_addr vma = msymbol.minsym->value_raw_address ();
msymtype = msymbol.minsym->type ();
section = msymbol.minsym->section_index ();
really be relocated properly, but nevertheless we make a stab at
it, choosing an approach consistent with the history of this
code. */
- baseaddr = objfile->text_section_offset ();
- reader.record_with_info (qualified_name.c_str (), vma - baseaddr, msymtype,
- section);
+ reader.record_with_info (qualified_name.c_str (), vma, msymtype, section);
/* Enter the plain name as well, which might not be unique. */
- reader.record_with_info (bare_name.c_str(), vma - baseaddr, msymtype,
- section);
+ reader.record_with_info (bare_name.c_str(), vma, msymtype, section);
return 1;
}
static struct minimal_symbol *
record_minimal_symbol (minimal_symbol_reader &reader,
- struct coff_symbol *cs, CORE_ADDR address,
+ struct coff_symbol *cs, unrelocated_addr address,
enum minimal_symbol_type type, int section,
struct objfile *objfile)
{
tmpaddr = cs->c_value;
/* Don't record unresolved symbols. */
if (!(cs->c_secnum <= 0 && cs->c_value == 0))
- record_minimal_symbol (reader, cs, tmpaddr, mst_text,
- section, objfile);
+ record_minimal_symbol (reader, cs,
+ unrelocated_addr (tmpaddr),
+ mst_text, section, objfile);
fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
fcn_start_addr = tmpaddr;
ms_type = mst_unknown;
}
- msym = record_minimal_symbol (reader, cs, tmpaddr, ms_type,
- sec, objfile);
+ msym = record_minimal_symbol (reader, cs,
+ unrelocated_addr (tmpaddr),
+ ms_type, sec, objfile);
if (msym)
gdbarch_coff_make_msymbol_special (gdbarch,
cs->c_sclass, msym);
need to make guesses based on the symbols (which *are* relocated to
reflect the address it will be loaded at). */
-static CORE_ADDR lowest_text_address;
+static unrelocated_addr lowest_text_address;
/* Non-zero if there is any line number info in the objfile. Prevents
dbx_end_psymtab from discarding an otherwise empty psymtab. */
static void dbx_symfile_finish (struct objfile *);
static void record_minimal_symbol (minimal_symbol_reader &,
- const char *, CORE_ADDR, int,
+ const char *, unrelocated_addr, int,
struct objfile *);
static void add_new_header_file (const char *, int);
\f
static void
record_minimal_symbol (minimal_symbol_reader &reader,
- const char *name, CORE_ADDR address, int type,
+ const char *name, unrelocated_addr address, int type,
struct objfile *objfile)
{
enum minimal_symbol_type ms_type;
set_last_source_file (NULL);
- lowest_text_address = (CORE_ADDR) -1;
+ lowest_text_address = (unrelocated_addr) -1;
symfile_bfd = objfile->obfd.get (); /* For next_text_symbol. */
abfd = objfile->obfd.get ();
record_it:
namestring = set_namestring (objfile, &nlist);
- record_minimal_symbol (reader, namestring, nlist.n_value,
+ record_minimal_symbol (reader, namestring,
+ unrelocated_addr (nlist.n_value),
nlist.n_type, objfile); /* Always */
continue;
pst ? pst->filename : NULL,
objfile);
if (minsym.minsym != NULL)
- nlist.n_value = minsym.minsym->value_raw_address ();
+ nlist.n_value
+ = CORE_ADDR (minsym.minsym->value_raw_address ());
}
if (pst && textlow_not_set
&& gdbarch_sofun_address_maybe_missing (gdbarch))
pst ? pst->filename : NULL,
objfile);
if (minsym.minsym != NULL)
- nlist.n_value = minsym.minsym->value_raw_address ();
+ nlist.n_value
+ = CORE_ADDR (minsym.minsym->value_raw_address ());
}
if (pst && textlow_not_set
&& gdbarch_sofun_address_maybe_missing (gdbarch))
/* Don't set high text address of PST lower than it already
is. */
unrelocated_addr text_end
- = unrelocated_addr ((lowest_text_address == (CORE_ADDR) -1
- ? text_addr
- : lowest_text_address)
- + text_size);
+ = (unrelocated_addr
+ (lowest_text_address == (unrelocated_addr) -1
+ ? text_addr
+ : CORE_ADDR (lowest_text_address)
+ + text_size));
dbx_end_psymtab (objfile, partial_symtabs,
pst, psymtab_include_list, includes_used,
if (minsym.minsym)
pst->set_text_high
- (unrelocated_addr (minsym.minsym->value_raw_address ()
+ (unrelocated_addr (CORE_ADDR (minsym.minsym->value_raw_address ())
+ minsym.minsym->size ()));
last_function_name = NULL;
static struct minimal_symbol *
record_minimal_symbol (minimal_symbol_reader &reader,
gdb::string_view name, bool copy_name,
- CORE_ADDR address,
+ unrelocated_addr address,
enum minimal_symbol_type ms_type,
asection *bfd_section, struct objfile *objfile)
{
if (ms_type == mst_text || ms_type == mst_file_text
|| ms_type == mst_text_gnu_ifunc)
- address = gdbarch_addr_bits_remove (gdbarch, address);
+ address
+ = unrelocated_addr (gdbarch_addr_bits_remove (gdbarch,
+ CORE_ADDR (address)));
/* We only setup section information for allocatable sections. Usually
we'd only expect to find msymbols for allocatable sections, but if the
msym = record_minimal_symbol
(reader, sym->name, copy_names,
- symaddr, mst_solib_trampoline, sect, objfile);
+ unrelocated_addr (symaddr),
+ mst_solib_trampoline, sect, objfile);
if (msym != NULL)
{
msym->filename = filesymname;
continue; /* Skip this symbol. */
}
msym = record_minimal_symbol
- (reader, sym->name, copy_names, symaddr,
+ (reader, sym->name, copy_names, unrelocated_addr (symaddr),
ms_type, sym->section, objfile);
if (msym)
&& (elf_sym->version & VERSYM_HIDDEN) == 0)
record_minimal_symbol (reader,
gdb::string_view (sym->name, len),
- true, symaddr, ms_type, sym->section,
- objfile);
+ true, unrelocated_addr (symaddr),
+ ms_type, sym->section, objfile);
else if (is_plt)
{
/* For @plt symbols, also record a trampoline to the
mtramp = record_minimal_symbol
(reader, gdb::string_view (sym->name, len), true,
- symaddr, mst_solib_trampoline, sym->section, objfile);
+ unrelocated_addr (symaddr),
+ mst_solib_trampoline, sym->section, objfile);
if (mtramp)
{
mtramp->set_size (msym->size());
string_buffer.append (got_suffix, got_suffix + got_suffix_len);
msym = record_minimal_symbol (reader, string_buffer,
- true, address, mst_slot_got_plt,
- msym_section, objfile);
+ true, unrelocated_addr (address),
+ mst_slot_got_plt, msym_section, objfile);
if (msym)
msym->set_size (ptr_size);
}
a TLS variable. */
if (obj_section == NULL
|| (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
- addr = bmsym.minsym->value_raw_address ();
+ addr = CORE_ADDR (bmsym.minsym->value_raw_address ());
else
- addr = bmsym.value_address ();
+ addr = bmsym.value_address ();
if (overlay_debugging)
addr = symbol_overlayed_address (addr, obj_section);
/* Determine address of TLS variable. */
if (sym->flags & (BSF_GLOBAL | BSF_LOCAL | BSF_WEAK))
{
- CORE_ADDR symaddr;
+ unrelocated_addr symaddr;
enum minimal_symbol_type ms_type;
/* Bfd symbols are section relative. */
- symaddr = sym->value + sym->section->vma;
+ symaddr = unrelocated_addr (sym->value + sym->section->vma);
if (sym->section == bfd_abs_section_ptr)
ms_type = mst_abs;
static void
record_minimal_symbol (minimal_symbol_reader &reader,
- const char *name, const CORE_ADDR address,
+ const char *name, const unrelocated_addr address,
enum minimal_symbol_type ms_type, int storage_class,
struct objfile *objfile)
{
for (; ext_in < ext_in_end; ext_in++)
{
enum minimal_symbol_type ms_type = mst_text;
- CORE_ADDR svalue = ext_in->asym.value;
+ unrelocated_addr svalue = unrelocated_addr (ext_in->asym.value);
/* The Irix 5 native tools seem to sometimes generate bogus
external symbols. */
if (sh.st == stStaticProc)
{
namestring = debug_info->ss + fh->issBase + sh.iss;
- record_minimal_symbol (reader, namestring, sh.value,
+ record_minimal_symbol (reader, namestring,
+ unrelocated_addr (sh.value),
mst_file_text, sh.sc,
objfile);
}
case scPData:
case scXData:
namestring = debug_info->ss + fh->issBase + sh.iss;
- record_minimal_symbol (reader, namestring, sh.value,
+ record_minimal_symbol (reader, namestring,
+ unrelocated_addr (sh.value),
mst_file_data, sh.sc,
objfile);
break;
/* FIXME! Shouldn't this use cases for bss,
then have the default be abs? */
namestring = debug_info->ss + fh->issBase + sh.iss;
- record_minimal_symbol (reader, namestring, sh.value,
+ record_minimal_symbol (reader, namestring,
+ unrelocated_addr (sh.value),
mst_file_bss, sh.sc,
objfile);
break;
{
char *sym_name;
enum address_class theclass;
- CORE_ADDR minsym_value;
+ unrelocated_addr minsym_value;
short section = -1;
(*swap_sym_in) (cur_bfd,
sym_name = debug_info->ss + fh->issBase + sh.iss;
- minsym_value = sh.value;
+ minsym_value = unrelocated_addr (sh.value);
switch (sh.sc)
{
/* A helper function that makes *PC section-relative. This searches
the sections of OBJFILE and if *PC is in a section, it subtracts
- the section offset and returns true. Otherwise it returns
- false. */
+ the section offset, stores the result into UNREL_ADDR, and returns
+ true. Otherwise it returns false. */
static int
-frob_address (struct objfile *objfile, CORE_ADDR *pc)
+frob_address (struct objfile *objfile, CORE_ADDR pc,
+ unrelocated_addr *unrel_addr)
{
struct obj_section *iter;
ALL_OBJFILE_OSECTIONS (objfile, iter)
{
- if (*pc >= iter->addr () && *pc < iter->endaddr ())
+ if (pc >= iter->addr () && pc < iter->endaddr ())
{
- *pc -= iter->offset ();
+ *unrel_addr = unrelocated_addr (pc - iter->offset ());
return 1;
}
}
Warning: this code is trickier than it would appear at first. */
- if (frob_address (objfile, &pc)
- && pc >= msymbol[lo].value_raw_address ())
+ unrelocated_addr unrel_pc;
+ if (frob_address (objfile, pc, &unrel_pc)
+ && unrel_pc >= msymbol[lo].value_raw_address ())
{
- while (msymbol[hi].value_raw_address () > pc)
+ while (msymbol[hi].value_raw_address () > unrel_pc)
{
/* pc is still strictly less than highest address. */
/* Note "new" will always be >= lo. */
newobj = (lo + hi) / 2;
- if ((msymbol[newobj].value_raw_address () >= pc)
+ if ((msymbol[newobj].value_raw_address () >= unrel_pc)
|| (lo == newobj))
{
hi = newobj;
the cancellable variants, but both have sizes. */
if (hi > 0
&& msymbol[hi].size () != 0
- && pc >= (msymbol[hi].value_raw_address ()
- + msymbol[hi].size ())
- && pc < (msymbol[hi - 1].value_raw_address ()
- + msymbol[hi - 1].size ()))
+ && unrel_pc >= msymbol[hi].value_raw_end_address ()
+ && unrel_pc < msymbol[hi - 1].value_raw_end_address ())
{
hi--;
continue;
if (hi >= 0
&& msymbol[hi].size () != 0
- && pc >= (msymbol[hi].value_raw_address ()
- + msymbol[hi].size ()))
+ && unrel_pc >= msymbol[hi].value_raw_end_address ())
{
if (best_zero_sized != -1)
hi = best_zero_sized;
/* See minsyms.h. */
void
-minimal_symbol_reader::record (const char *name, CORE_ADDR address,
+minimal_symbol_reader::record (const char *name, unrelocated_addr address,
enum minimal_symbol_type ms_type)
{
int section;
struct minimal_symbol *
minimal_symbol_reader::record_full (gdb::string_view name,
- bool copy_name, CORE_ADDR address,
+ bool copy_name, unrelocated_addr address,
enum minimal_symbol_type ms_type,
int section)
{
return (NULL);
symtab_create_debug_printf_v ("recording minsym: %-21s %18s %4d %.*s",
- mst_str (ms_type), hex_string (address), section,
- (int) name.size (), name.data ());
+ mst_str (ms_type),
+ hex_string (LONGEST (address)),
+ section, (int) name.size (), name.data ());
if (m_msym_bunch_index == BUNCH_SIZE)
{
else
msymbol->m_name = name.data ();
- msymbol->set_value_address (address);
+ msymbol->set_unrelocated_address (address);
msymbol->set_section_index (section);
msymbol->set_type (ms_type);
struct minimal_symbol *record_full (gdb::string_view name,
bool copy_name,
- CORE_ADDR address,
+ unrelocated_addr address,
enum minimal_symbol_type ms_type,
int section);
This variant does not return the new symbol. */
- void record (const char *name, CORE_ADDR address,
+ void record (const char *name, unrelocated_addr address,
enum minimal_symbol_type ms_type);
/* Like record_full, but:
This variant does not return the new symbol. */
- void record_with_info (const char *name, CORE_ADDR address,
+ void record_with_info (const char *name, unrelocated_addr address,
enum minimal_symbol_type ms_type,
int section)
{
if (ELF_ST_IS_MICROMIPS (st_other))
{
SET_MSYMBOL_TARGET_FLAG_MICROMIPS (msym);
- msym->set_value_address (msym->value_raw_address () | 1);
+ CORE_ADDR fixed = CORE_ADDR (msym->value_raw_address ()) | 1;
+ msym->set_unrelocated_address (unrelocated_addr (fixed));
}
else if (ELF_ST_IS_MIPS16 (st_other))
{
SET_MSYMBOL_TARGET_FLAG_MIPS16 (msym);
- msym->set_value_address (msym->value_raw_address () | 1);
+ CORE_ADDR fixed = CORE_ADDR (msym->value_raw_address ()) | 1;
+ msym->set_unrelocated_address (unrelocated_addr (fixed));
}
}
}
}
- reader.record (name, sym_value, ms_type);
+ reader.record (name, unrelocated_addr (sym_value), ms_type);
}
}
{
/* Addresses of TLS symbols are really offsets into a
per-objfile/per-thread storage block. */
- addr = bound_msym.minsym->value_raw_address ();
+ addr = CORE_ADDR (bound_msym.minsym->value_raw_address ());
}
else if (msymbol_is_function (objfile, msymbol, &addr))
{
if (section
&& (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
{
- load_addr = msym.minsym->value_raw_address ();
+ load_addr = CORE_ADDR (msym.minsym->value_raw_address ());
gdb_printf (_("a thread-local variable at offset %s "
"in the thread-local storage for `%s'"),
paddress (gdbarch, load_addr),
msym.set_value_address (symaddr);
gdbarch_elf_make_msymbol_special (gdbarch, sym, &msym);
- symaddr = msym.value_raw_address ();
+ symaddr = CORE_ADDR (msym.value_raw_address ());
}
/* BFD symbols are section relative. */
/* Use the relocated address as shown in the symbol here -- do
not try to respect copy relocations. */
- CORE_ADDR addr = (msymbol->value_raw_address ()
+ CORE_ADDR addr = (CORE_ADDR (msymbol->value_raw_address ())
+ objfile->section_offsets[msymbol->section_index ()]);
gdb_puts (paddress (gdbarch, addr), outfile);
gdb_printf (outfile, " %s", msymbol->linkage_name ());
if (this->maybe_copied)
return get_msymbol_address (objfile, this);
else
- return (this->value_raw_address ()
+ return (CORE_ADDR (this->value_raw_address ())
+ objfile->section_offsets[this->section_index ()]);
}
offsets from OBJFILE. */
CORE_ADDR value_address (objfile *objfile) const;
+ /* It does not make sense to call this for minimal symbols, as they
+ are stored unrelocated. */
+ CORE_ADDR value_address () const = delete;
+
/* The unrelocated address of the minimal symbol. */
- CORE_ADDR value_raw_address () const
+ unrelocated_addr value_raw_address () const
{
- return m_value.address;
+ return m_value.unrel_addr;
+ }
+
+ /* The unrelocated address just after the end of the the minimal
+ symbol. */
+ unrelocated_addr value_raw_end_address () const
+ {
+ return unrelocated_addr (CORE_ADDR (value_raw_address ()) + size ());
}
/* Return this minimal symbol's type. */
static void
record_minimal_symbol (minimal_symbol_reader &reader,
- const char *name, CORE_ADDR address,
+ const char *name, unrelocated_addr address,
enum minimal_symbol_type ms_type,
int n_scnum,
struct objfile *objfile)
unsigned int ssymnum;
const char *last_csect_name = NULL; /* Last seen csect's name and value. */
- CORE_ADDR last_csect_val = 0;
+ unrelocated_addr last_csect_val = unrelocated_addr (0);
int last_csect_sec = 0;
int misc_func_recorded = 0; /* true if any misc. function. */
int textlow_not_set = 1;
|| namestring[0] == '@'))
{
last_csect_name = namestring;
- last_csect_val = symbol.n_value;
+ last_csect_val = unrelocated_addr (symbol.n_value);
last_csect_sec = symbol.n_scnum;
}
if (pst != NULL)
table, except for section symbols. */
if (*namestring != '.')
record_minimal_symbol
- (reader, namestring, symbol.n_value,
+ (reader, namestring, unrelocated_addr (symbol.n_value),
sclass == C_HIDEXT ? mst_file_data : mst_data,
symbol.n_scnum, objfile);
break;
main_aux[0].x_sym.x_fcnary.x_fcn.x_lnnoptr;
record_minimal_symbol
- (reader, namestring, symbol.n_value,
+ (reader, namestring, unrelocated_addr (symbol.n_value),
sclass == C_HIDEXT ? mst_file_text : mst_text,
symbol.n_scnum, objfile);
misc_func_recorded = 1;
symbols, we will choose mst_text over
mst_solib_trampoline. */
record_minimal_symbol
- (reader, namestring, symbol.n_value,
+ (reader, namestring, unrelocated_addr (symbol.n_value),
mst_solib_trampoline, symbol.n_scnum, objfile);
misc_func_recorded = 1;
break;
XMC_BS might be possible too. */
if (*namestring != '.')
record_minimal_symbol
- (reader, namestring, symbol.n_value,
+ (reader, namestring, unrelocated_addr (symbol.n_value),
sclass == C_HIDEXT ? mst_file_data : mst_data,
symbol.n_scnum, objfile);
break;
table, except for section symbols. */
if (*namestring != '.')
record_minimal_symbol
- (reader, namestring, symbol.n_value,
+ (reader, namestring, unrelocated_addr (symbol.n_value),
sclass == C_HIDEXT ? mst_file_bss : mst_bss,
symbol.n_scnum, objfile);
break;