From: Alvin Wong Date: Wed, 28 Sep 2022 09:46:27 +0000 (+0300) Subject: [lldb][COFF] Map symbols without base+complex type as 'Data' type X-Git-Tag: upstream/17.0.6~32286 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a67a05e93349e341d1325f1a6428d1373f77177;p=platform%2Fupstream%2Fllvm.git [lldb][COFF] Map symbols without base+complex type as 'Data' type Both LLD and GNU ld write global/static variables to the COFF symbol table with `IMAGE_SYM_TYPE_NULL` and `IMAGE_SYM_DTYPE_NULL` type. Map these symbols as 'Data' type in the symtab to allow these symbols to be used in expressions and printable. Reviewed By: labath, DavidSpickett Differential Revision: https://reviews.llvm.org/D134585 --- diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 6b6177f..61c9b9f 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -379,6 +379,13 @@ lldb::SymbolType ObjectFilePECOFF::MapSymbolType(uint16_t coff_symbol_type) { if (complex_type == llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION) { return lldb::eSymbolTypeCode; } + const auto base_type = coff_symbol_type & 0xff; + if (base_type == llvm::COFF::IMAGE_SYM_TYPE_NULL && + complex_type == llvm::COFF::IMAGE_SYM_DTYPE_NULL) { + // Unknown type. LLD and GNU ld uses this for variables on MinGW, so + // consider these symbols to be data to enable printing. + return lldb::eSymbolTypeData; + } return lldb::eSymbolTypeInvalid; } diff --git a/lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml b/lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml index 4a663a8..d80a05e 100644 --- a/lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml +++ b/lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml @@ -6,7 +6,7 @@ # CHECK: Type File Address/Value {{.*}} Size Flags Name # CHECK: Code 0x0000000040001000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} entry -# CHECK: 0x0000000040002000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} variable +# CHECK: Data 0x0000000040002000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} variable # CHECK: Absolute 0x00000000deadbeef 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} absolute_symbol --- !COFF diff --git a/lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml b/lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml index dd21cad..4b1efd1 100644 --- a/lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml +++ b/lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml @@ -15,7 +15,7 @@ # CHECK-NEXT: 4294967295 Code 0x0000000180001020 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} aliasFunc # CHECK-NEXT: 4294967295 X Additional 0x0000000180003000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportInt # CHECK-NEXT: 4294967295 Data 0x0000000180003004 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} aliasInt -# CHECK-NEXT: 4294967295 Invalid 0x0000000180003008 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} internalInt +# CHECK-NEXT: 4294967295 Data 0x0000000180003008 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} internalInt # CHECK-EMPTY: # Test file generated with: