aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/elfread.c12
-rw-r--r--gdb/objfiles.h11
-rw-r--r--gdb/symtab.c14
-rw-r--r--gdb/symtab.h17
4 files changed, 37 insertions, 17 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 862beb9..55e3e47 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -219,13 +219,7 @@ record_minimal_symbol (minimal_symbol_reader &reader,
|| bfd_section == bfd_abs_section_ptr)
section_index = gdb_bfd_section_index (objfile->obfd.get (), bfd_section);
- struct minimal_symbol *result
- = reader.record_full (name, copy_name, address, ms_type, section_index);
- if ((objfile->flags & OBJF_MAINLINE) == 0
- && (ms_type == mst_data || ms_type == mst_bss))
- result->maybe_copied = 1;
-
- return result;
+ return reader.record_full (name, copy_name, address, ms_type, section_index);
}
/* Read the symbol table of an ELF file.
@@ -1372,6 +1366,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
elfctf_build_psymtabs (objfile);
}
+
+ /* Copy relocations are used by some ABIs using the ELF format, so
+ set the objfile flag indicating this fact. */
+ objfile->object_format_has_copy_relocs = true;
}
/* Initialize anything that needs initializing when a completely new symbol
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 91dda1c..b3b216f 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -871,6 +871,17 @@ public:
next time. If an objfile does not have the symbols, it will
never have them. */
bool skip_jit_symbol_lookup = false;
+
+ /* Flag which indicates, when true, that the object format
+ potentially supports copy relocations. ABIs for some
+ architectures that use ELF have a copy relocation in which the
+ initialization for a global variable defined in a shared object
+ will be copied to memory allocated to the main program during
+ dynamic linking. Therefore this flag will be set for ELF
+ objfiles. Other object formats that use the same copy relocation
+ mechanism as ELF should set this flag too. This flag is used in
+ conjunction with the minimal_symbol::maybe_copied method. */
+ bool object_format_has_copy_relocs = false;
};
/* A deleter for objfile. */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 0117a2a..838d711 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -435,7 +435,7 @@ compunit_symtab::language () const
CORE_ADDR
minimal_symbol::value_address (objfile *objfile) const
{
- if (this->maybe_copied)
+ if (this->maybe_copied (objfile))
return get_msymbol_address (objfile, this);
else
return (CORE_ADDR (this->unrelocated_address ())
@@ -467,6 +467,16 @@ minimal_symbol::text_p () const
|| m_type == mst_file_text;
}
+/* See symtab.h. */
+
+bool
+minimal_symbol::maybe_copied (objfile *objfile) const
+{
+ return (objfile->object_format_has_copy_relocs
+ && (objfile->flags & OBJF_MAINLINE) == 0
+ && (m_type == mst_data || m_type == mst_bss));
+}
+
/* See whether FILENAME matches SEARCH_NAME using the rule that we
advertise to the user. (The manual's description of linespecs
describes what we advertise). Returns true if they match, false
@@ -6515,7 +6525,7 @@ get_symbol_address (const struct symbol *sym)
CORE_ADDR
get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym)
{
- gdb_assert (minsym->maybe_copied);
+ gdb_assert (minsym->maybe_copied (objf));
gdb_assert ((objf->flags & OBJF_MAINLINE) == 0);
const char *linkage_name = minsym->linkage_name ();
diff --git a/gdb/symtab.h b/gdb/symtab.h
index ee4729b..fa77fc1 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -855,14 +855,6 @@ struct minimal_symbol : public general_symbol_info
the object file format may not carry that piece of information. */
unsigned int m_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;
-
/* Non-zero if this symbol ever had its demangled name set (even if
it was set to NULL). */
unsigned int name_set : 1;
@@ -884,6 +876,15 @@ struct minimal_symbol : public general_symbol_info
/* True if MSYMBOL is of some text type. */
bool text_p () const;
+
+ /* For data symbols only, given an objfile, if 'maybe_copied'
+ evaluates to 'true' for that objfile, 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. */
+
+ bool maybe_copied (objfile *objfile) const;
};
#include "minsyms.h"