[PATCH] D126787: [llvm-objdump][COFF] Remove duplicate data dir loading
Alvin Wong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 1 09:33:21 PDT 2022
alvinhochun created this revision.
Herald added a subscriber: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: All.
alvinhochun updated this revision to Diff 433418.
alvinhochun retitled this revision from "[llvm-objdump][COFF] Remove duplicate data dir loading code" to "[llvm-objdump][COFF] Remove duplicate data dir loading".
alvinhochun edited the summary of this revision.
alvinhochun added a comment.
Herald added a subscriber: StephenFan.
alvinhochun published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Update commit message
COFFObjectFile already initialized the pointers and checked their
ranges, so COFFDump should just reuse these pointers.
Depends on D126786 <https://reviews.llvm.org/D126786>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126787
Files:
llvm/tools/llvm-objdump/COFFDump.cpp
Index: llvm/tools/llvm-objdump/COFFDump.cpp
===================================================================
--- llvm/tools/llvm-objdump/COFFDump.cpp
+++ llvm/tools/llvm-objdump/COFFDump.cpp
@@ -430,21 +430,12 @@
if (!PE32Header && !PE32PlusHeader)
return;
- const data_directory *DataDir = Obj->getDataDirectory(COFF::TLS_TABLE);
- if (!DataDir || DataDir->RelativeVirtualAddress == 0)
- return;
-
- uintptr_t IntPtr = 0;
- if (Error E =
- Obj->getRvaPtr(DataDir->RelativeVirtualAddress, IntPtr))
- reportError(std::move(E), Obj->getFileName());
-
if (PE32Header) {
- auto *TLSDir = reinterpret_cast<const coff_tls_directory32 *>(IntPtr);
- printTLSDirectoryT(TLSDir);
+ if (auto *TLSDir = Obj->getTLSDirectory32())
+ printTLSDirectoryT(TLSDir);
} else {
- auto *TLSDir = reinterpret_cast<const coff_tls_directory64 *>(IntPtr);
- printTLSDirectoryT(TLSDir);
+ if (auto *TLSDir = Obj->getTLSDirectory64())
+ printTLSDirectoryT(TLSDir);
}
outs() << "\n";
@@ -459,19 +450,10 @@
if (Obj->getMachine() != COFF::IMAGE_FILE_MACHINE_I386)
return;
- const data_directory *DataDir = Obj->getDataDirectory(COFF::LOAD_CONFIG_TABLE);
- if (!DataDir)
- reportError("no load config data dir", Obj->getFileName());
-
- uintptr_t IntPtr = 0;
- if (DataDir->RelativeVirtualAddress == 0)
+ auto *LoadConf = Obj->getLoadConfig32();
+ if (!LoadConf)
return;
- if (Error E =
- Obj->getRvaPtr(DataDir->RelativeVirtualAddress, IntPtr))
- reportError(std::move(E), Obj->getFileName());
-
- auto *LoadConf = reinterpret_cast<const coff_load_configuration32 *>(IntPtr);
outs() << "Load configuration:"
<< "\n Timestamp: " << LoadConf->TimeDateStamp
<< "\n Major Version: " << LoadConf->MajorVersion
@@ -544,11 +526,11 @@
// Prints export tables. The export table is a table containing the list of
// exported symbol from the DLL.
static void printExportTable(const COFFObjectFile *Obj) {
- outs() << "Export Table:\n";
export_directory_iterator I = Obj->export_directory_begin();
export_directory_iterator E = Obj->export_directory_end();
if (I == E)
return;
+ outs() << "Export Table:\n";
StringRef DllName;
uint32_t OrdinalBase;
if (I->getDllName(DllName))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126787.433418.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220601/77ecf589/attachment.bin>
More information about the llvm-commits
mailing list