Skip to content

Commit 8a67a05

Browse files
alvinhochunmstorsjo
authored andcommitted
[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
1 parent acf7d08 commit 8a67a05

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ lldb::SymbolType ObjectFilePECOFF::MapSymbolType(uint16_t coff_symbol_type) {
379379
if (complex_type == llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION) {
380380
return lldb::eSymbolTypeCode;
381381
}
382+
const auto base_type = coff_symbol_type & 0xff;
383+
if (base_type == llvm::COFF::IMAGE_SYM_TYPE_NULL &&
384+
complex_type == llvm::COFF::IMAGE_SYM_DTYPE_NULL) {
385+
// Unknown type. LLD and GNU ld uses this for variables on MinGW, so
386+
// consider these symbols to be data to enable printing.
387+
return lldb::eSymbolTypeData;
388+
}
382389
return lldb::eSymbolTypeInvalid;
383390
}
384391

lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# CHECK: Type File Address/Value {{.*}} Size Flags Name
88
# CHECK: Code 0x0000000040001000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} entry
9-
# CHECK: 0x0000000040002000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} variable
9+
# CHECK: Data 0x0000000040002000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} variable
1010
# CHECK: Absolute 0x00000000deadbeef 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} absolute_symbol
1111

1212
--- !COFF

lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# CHECK-NEXT: 4294967295 Code 0x0000000180001020 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} aliasFunc
1616
# CHECK-NEXT: 4294967295 X Additional 0x0000000180003000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportInt
1717
# CHECK-NEXT: 4294967295 Data 0x0000000180003004 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} aliasInt
18-
# CHECK-NEXT: 4294967295 Invalid 0x0000000180003008 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} internalInt
18+
# CHECK-NEXT: 4294967295 Data 0x0000000180003008 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} internalInt
1919
# CHECK-EMPTY:
2020

2121
# Test file generated with:

0 commit comments

Comments
 (0)