Handle copy relocations
In ELF, if a data symbol is defined in a shared library and used by the main program, it will be subject to a "copy relocation". In this scenario, the main program has a copy of the symbol in question, and a relocation that tells ld.so to copy the data from the shared library. Then the symbol in the main program is used to satisfy all references. This patch changes gdb to handle this scenario. Data symbols coming from ELF shared libraries get a special flag that indicates that the symbol's address may be subject to copy relocation. I looked briefly into handling copy relocations by looking at the actual relocations in the main program, but this seemed difficult to do with BFD. Note that no caching is done here. Perhaps this could be changed if need be; I wanted to avoid possible problems with either objfile lifetimes and changes, or conflicts with the long-term (vapor-ware) objfile splitting project. gdb/ChangeLog 2019-10-02 Tom Tromey <tromey@adacore.com> * symmisc.c (dump_msymbols): Don't use MSYMBOL_VALUE_ADDRESS. * ada-lang.c (lesseq_defined_than): Handle LOC_STATIC. * dwarf2read.c (dwarf2_per_objfile): Add can_copy parameter. (dwarf2_has_info): Likewise. (new_symbol): Set maybe_copied on symbol when appropriate. * dwarf2read.h (dwarf2_per_objfile): Add can_copy parameter. <can_copy>: New member. * elfread.c (record_minimal_symbol): Set maybe_copied on symbol when appropriate. (elf_symfile_read): Update call to dwarf2_has_info. * minsyms.c (lookup_minimal_symbol_linkage): New function. * minsyms.h (lookup_minimal_symbol_linkage): Declare. * symtab.c (get_symbol_address, get_msymbol_address): New functions. * symtab.h (get_symbol_address, get_msymbol_address): Declare. (SYMBOL_VALUE_ADDRESS, MSYMBOL_VALUE_ADDRESS): Handle maybe_copied. (struct symbol, struct minimal_symbol) <maybe_copied>: New member.
This commit is contained in:
parent
1dd5885077
commit
4b610737f0
11 changed files with 208 additions and 32 deletions
|
@ -4724,6 +4724,15 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1)
|
|||
case LOC_CONST:
|
||||
return SYMBOL_VALUE (sym0) == SYMBOL_VALUE (sym1)
|
||||
&& equiv_types (SYMBOL_TYPE (sym0), SYMBOL_TYPE (sym1));
|
||||
|
||||
case LOC_STATIC:
|
||||
{
|
||||
const char *name0 = SYMBOL_LINKAGE_NAME (sym0);
|
||||
const char *name1 = SYMBOL_LINKAGE_NAME (sym1);
|
||||
return (strcmp (name0, name1) == 0
|
||||
&& SYMBOL_VALUE_ADDRESS (sym0) == SYMBOL_VALUE_ADDRESS (sym1));
|
||||
}
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue