diff options
author | Greg Clayton <gclayton@fb.com> | 2022-08-10 21:08:04 -0700 |
---|---|---|
committer | Greg Clayton <gclayton@fb.com> | 2022-08-22 14:46:27 -0700 |
commit | f0697d7c3fb5296cfec1718206aceb77b7ca9ab8 (patch) | |
tree | aa57483530ca69f77b83ebd75a4cd1555ec7a065 /lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | |
parent | 2880d7b9e4c9a0a266ef73aa7719f6f4f867573d (diff) | |
download | llvm-f0697d7c3fb5296cfec1718206aceb77b7ca9ab8.zip llvm-f0697d7c3fb5296cfec1718206aceb77b7ca9ab8.tar.gz llvm-f0697d7c3fb5296cfec1718206aceb77b7ca9ab8.tar.bz2 |
Don't create sections for SHN_ABS symbols in ELF files.
Symbols that have the section index of SHN_ABS were previously creating extra top level sections that contained the value of the symbol as if the symbol's value was an address. As far as I can tell, these symbol's values are not addresses, even if they do have a size. To make matters worse, adding these extra sections can stop address lookups from succeeding if the symbol's value + size overlaps with an existing section as these sections get mapped into memory when the image is loaded by the dynamic loader. This can cause stack frames to appear empty as the address lookup fails completely.
This patch:
- doesn't create a section for any SHN_ABS symbols
- makes symbols that are absolute have values that are not addresses
- add accessors to SBSymbol to get the value and size of a symbol as raw integers. Prevoiusly there was no way to access a symbol's value from a SBSymbol because the only accessors were:
SBAddress SBSymbol::GetStartAddress();
SBAddress SBSymbol::GetEndAddress();
and these accessors would return an invalid SBAddress if the symbol's value wasn't an address
- Adds a test to ensure no ".absolute.<symbol-name>" sections are created
- Adds a test to test the new SBSymbol APIs
Differential Revision: https://reviews.llvm.org/D131705
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 122298d..bc488a7 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2223,23 +2223,6 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // symbols. See above for more details. uint64_t symbol_value = symbol.st_value + symbol_value_offset; - if (symbol_section_sp == nullptr && shndx == SHN_ABS && - symbol.st_size != 0) { - // We don't have a section for a symbol with non-zero size. Create a new - // section for it so the address range covered by the symbol is also - // covered by the module (represented through the section list). It is - // needed so module lookup for the addresses covered by this symbol will - // be successfull. This case happens for absolute symbols. - ConstString fake_section_name(std::string(".absolute.") + symbol_name); - symbol_section_sp = - std::make_shared<Section>(module_sp, this, SHN_ABS, fake_section_name, - eSectionTypeAbsoluteAddress, symbol_value, - symbol.st_size, 0, 0, 0, SHF_ALLOC); - - module_section_list->AddSection(symbol_section_sp); - section_list->AddSection(symbol_section_sp); - } - if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile) symbol_value -= symbol_section_sp->GetFileAddress(); |