summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
diff options
context:
space:
mode:
authorAdrian McCarthy <amccarth@google.com>2016-01-26 00:58:09 +0000
committerAdrian McCarthy <amccarth@google.com>2016-01-26 00:58:09 +0000
commitc35b91cee23079e32f421dbea5e2697ae492ef6b (patch)
tree77d3717f5d965f8742cb4ac16ae70eedf84b0d61 /lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
parent86ff2689a5e6050e24a9bc11aea1364169d7299f (diff)
downloadbcm5719-llvm-c35b91cee23079e32f421dbea5e2697ae492ef6b.tar.gz
bcm5719-llvm-c35b91cee23079e32f421dbea5e2697ae492ef6b.zip
Set symbol types for function symbols loaded from PE/COFF
This fixes the regression of several tests on Windows after rL258621. The root problem is that ObjectFilePECOFF was not setting type information for the symbols, and the new CL rejects symbols without type information, breaking functionality like thread step-over. The fix sets the type information for functions (and creates a TODO for other types). Along the way, I fixed some typos and formatting that made the code I was debugging harder to understand. In the long run, we should consider replacing most of ObjectFilePECOFF with the COFF parsing code from LLVM. Differential Revision: http://reviews.llvm.org/D16563 llvm-svn: 258758
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp')
-rw-r--r--lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index ab2be36f415..52c6ac8fb65 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -169,6 +169,18 @@ ObjectFilePECOFF::MagicBytesMatch (DataBufferSP& data_sp)
return magic == IMAGE_DOS_SIGNATURE;
}
+lldb::SymbolType
+ObjectFilePECOFF::MapSymbolType(uint16_t coff_symbol_type)
+{
+ // TODO: We need to complete this mapping of COFF symbol types to LLDB ones.
+ // For now, here's a hack to make sure our function have types.
+ const auto complex_type = coff_symbol_type >> llvm::COFF::SCT_COMPLEX_TYPE_SHIFT;
+ if (complex_type == llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION)
+ {
+ return lldb::eSymbolTypeCode;
+ }
+ return lldb::eSymbolTypeInvalid;
+}
ObjectFilePECOFF::ObjectFilePECOFF (const lldb::ModuleSP &module_sp,
DataBufferSP& data_sp,
@@ -534,8 +546,8 @@ ObjectFilePECOFF::GetSymtab()
{
const uint32_t symbol_size = 18;
const uint32_t addr_byte_size = GetAddressByteSize ();
- const size_t symbol_data_size = num_syms * symbol_size;
- // Include the 4 bytes string table size at the end of the symbols
+ const size_t symbol_data_size = num_syms * symbol_size;
+ // Include the 4-byte string table size at the end of the symbols
DataBufferSP symtab_data_sp(m_file.ReadFileContents (m_coff_header.symoff, symbol_data_size + 4));
DataExtractor symtab_data (symtab_data_sp, GetByteOrder(), addr_byte_size);
lldb::offset_t offset = symbol_data_size;
@@ -556,8 +568,8 @@ ObjectFilePECOFF::GetSymtab()
coff_symbol_t symbol;
const uint32_t symbol_offset = offset;
const char *symbol_name_cstr = NULL;
- // If the first 4 bytes of the symbol string are zero, then we
- // it is followed by a 4 byte string table offset. Else these
+ // If the first 4 bytes of the symbol string are zero, then they
+ // are followed by a 4-byte string table offset. Else these
// 8 bytes contain the symbol name
if (symtab_data.GetU32 (&offset) == 0)
{
@@ -586,6 +598,7 @@ ObjectFilePECOFF::GetSymtab()
{
Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value);
symbols[i].GetAddressRef() = symbol_addr;
+ symbols[i].SetType(MapSymbolType(symbol.type));
}
if (symbol.naux > 0)
OpenPOWER on IntegriCloud