#include "gdbsupport/enum-flags.h"
#include "gdbsupport/function-view.h"
#include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/gdb_string_view.h"
#include "gdbsupport/next-iterator.h"
#include "completer.h"
extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
+/* Return the address of SYM. The MAYBE_COPIED flag must be set on
+ SYM. If SYM appears in the main program's minimal symbols, then
+ that minsym's address is returned; otherwise, SYM's address is
+ returned. This should generally only be used via the
+ SYMBOL_VALUE_ADDRESS macro. */
+
+extern CORE_ADDR get_symbol_address (const struct symbol *sym);
+
/* Note that all the following SYMBOL_* macros are used with the
SYMBOL argument being either a partial symbol or
a full symbol. Both types have a ginfo field. In particular
field only, instead of the SYMBOL parameter. */
#define SYMBOL_VALUE(symbol) (symbol)->ginfo.value.ivalue
-#define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->ginfo.value.address
+#define SYMBOL_VALUE_ADDRESS(symbol) \
+ (((symbol)->maybe_copied) ? get_symbol_address (symbol) \
+ : ((symbol)->ginfo.value.address))
+#define SET_SYMBOL_VALUE_ADDRESS(symbol, new_value) \
+ ((symbol)->ginfo.value.address = (new_value))
#define SYMBOL_VALUE_BYTES(symbol) (symbol)->ginfo.value.bytes
#define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->ginfo.value.common_block
#define SYMBOL_BLOCK_VALUE(symbol) (symbol)->ginfo.value.block
(symbol)->ginfo.name = (linkage_name)
/* Set the linkage and natural names of a symbol, by demangling
- the linkage name. */
-#define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile) \
- symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, \
+ the linkage name. If linkage_name may not be nullterminated,
+ copy_name must be set to true. */
+#define SYMBOL_SET_NAMES(symbol,linkage_name,copy_name,objfile) \
+ symbol_set_names (&(symbol)->ginfo, linkage_name, copy_name, \
(objfile)->per_bfd)
extern void symbol_set_names (struct general_symbol_info *symbol,
- const char *linkage_name, int len, bool copy_name,
+ gdb::string_view linkage_name, bool copy_name,
struct objfile_per_bfd_storage *per_bfd);
/* Now come lots of name accessor macros. Short version as to when to
the object file format may not carry that piece of information. */
unsigned int has_size : 1;
+ /* For data symbols only, if this is set, then the symbol might be
+ subject to copy relocation. In this case, a minimal symbol
+ matching the symbol's linkage name is first looked for in the
+ main objfile. If found, then that address is used; otherwise the
+ address in this symbol is used. */
+
+ unsigned maybe_copied : 1;
+
/* Minimal symbols with the same hash key are kept on a linked
list. This is the link. */
bool text_p () const;
};
+/* Return the address of MINSYM, which comes from OBJF. The
+ MAYBE_COPIED flag must be set on MINSYM. If MINSYM appears in the
+ main program's minimal symbols, then that minsym's address is
+ returned; otherwise, MINSYM's address is returned. This should
+ generally only be used via the MSYMBOL_VALUE_ADDRESS macro. */
+
+extern CORE_ADDR get_msymbol_address (struct objfile *objf,
+ const struct minimal_symbol *minsym);
+
#define MSYMBOL_TARGET_FLAG_1(msymbol) (msymbol)->target_flag_1
#define MSYMBOL_TARGET_FLAG_2(msymbol) (msymbol)->target_flag_2
#define MSYMBOL_SIZE(msymbol) ((msymbol)->size + 0)
/* The relocated address of the minimal symbol, using the section
offsets from OBJFILE. */
#define MSYMBOL_VALUE_ADDRESS(objfile, symbol) \
- ((symbol)->value.address \
- + ANOFFSET ((objfile)->section_offsets, ((symbol)->section)))
+ (((symbol)->maybe_copied) ? get_msymbol_address (objfile, symbol) \
+ : ((symbol)->value.address \
+ + ANOFFSET ((objfile)->section_offsets, ((symbol)->section))))
/* For a bound minsym, we can easily compute the address directly. */
#define BMSYMBOL_VALUE_ADDRESS(symbol) \
MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym)
/* All defined types */
TYPES_DOMAIN = 2,
+ /* All modules. */
+ MODULES_DOMAIN = 3,
+
/* Any type. */
- ALL_DOMAIN = 3
+ ALL_DOMAIN = 4
};
extern const char *search_domain_name (enum search_domain);
register, the CFA as defined by DWARF unwinding information, ...
So this specific method is supposed to compute the frame base address such
- as for nested fuctions, the static link computes the same address. For
+ as for nested functions, the static link computes the same address. For
instance, considering DWARF debugging information, the static link is
computed with DW_AT_static_link and this method must be used to compute
the corresponding DW_AT_frame_base attribute. */
/* Whether this is an inlined function (class LOC_BLOCK only). */
unsigned is_inlined : 1;
+ /* For LOC_STATIC only, if this is set, then the symbol might be
+ subject to copy relocation. In this case, a minimal symbol
+ matching the symbol's linkage name is first looked for in the
+ main objfile. If found, then that address is used; otherwise the
+ address in this symbol is used. */
+
+ unsigned maybe_copied : 1;
+
/* The concrete type of this symbol. */
ENUM_BITFIELD (symbol_subclass_kind) subclass : 2;