[Lldb-commits] [PATCH] D134265: [lldb][COFF] Improve info of symbols from export table
Martin Storsjö via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 28 02:58:31 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0870afc68e1a: [lldb][COFF] Improve info of symbols from export table (authored by alvinhochun, committed by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134265/new/
https://reviews.llvm.org/D134265
Files:
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml
Index: lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml
===================================================================
--- lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml
+++ lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml
@@ -6,10 +6,10 @@
# CHECK: UserID DSX Type File Address/Value {{.*}} Size Flags Name
# CHECK-NEXT: ------
-# CHECK-NEXT: 4294967295 D Code 0x0000000180001020 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportFnAlias
-# CHECK-NEXT: 4294967295 D Code 0x0000000180001010 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportFunc
-# CHECK-NEXT: 4294967295 D Code 0x0000000180003000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportInt
-# CHECK-NEXT: 4294967295 D Code 0x0000000180003004 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportIntAlias
+# CHECK-NEXT: 1 X Code 0x0000000180001020 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportFnAlias
+# CHECK-NEXT: 2 X Code 0x0000000180001010 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportFunc
+# CHECK-NEXT: 3 X Data 0x0000000180003000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportInt
+# CHECK-NEXT: 4 X Data 0x0000000180003004 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportIntAlias
# CHECK-NEXT: 4294967295 Code 0x0000000180001000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} entry
# CHECK-NEXT: 4294967295 Code 0x0000000180001010 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} exportFunc
# CHECK-NEXT: 4294967295 Code 0x0000000180001020 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} aliasFunc
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -826,6 +826,10 @@
// Note: symbol name may be empty if it is only exported by ordinal.
symbol.GetMangled().SetValue(ConstString(sym_name));
+ uint32_t ordinal;
+ llvm::cantFail(entry.getOrdinal(ordinal));
+ symbol.SetID(ordinal);
+
uint32_t function_rva;
if (auto err = entry.getExportRVA(function_rva)) {
LLDB_LOG(log,
@@ -834,10 +838,19 @@
sym_name, llvm::fmt_consume(std::move(err)));
continue;
}
+ // Skip the symbol if it doesn't look valid.
+ if (function_rva == 0 && sym_name.empty())
+ continue;
symbol.GetAddressRef() =
Address(m_coff_header_opt.image_base + function_rva, sect_list);
- symbol.SetType(lldb::eSymbolTypeCode);
- symbol.SetDebug(true);
+
+ // An exported symbol may be either code or data. Guess by checking whether
+ // the section containing the symbol is executable.
+ symbol.SetType(lldb::eSymbolTypeData);
+ if (auto section_sp = symbol.GetAddressRef().GetSection())
+ if (section_sp->GetPermissions() & ePermissionsExecutable)
+ symbol.SetType(lldb::eSymbolTypeCode);
+ symbol.SetExternal(true);
symtab.AddSymbol(symbol);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134265.463475.patch
Type: text/x-patch
Size: 3045 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220928/8740479c/attachment.bin>
More information about the lldb-commits
mailing list