[llvm] [llvm-readobj][COFF] Implement --coff-pseudoreloc in llvm-readobj to dump runtime pseudo-relocation records (PR #151816)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 10 20:08:07 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- llvm/tools/llvm-readobj/COFFDumper.cpp llvm/tools/llvm-readobj/ObjDumper.h llvm/tools/llvm-readobj/llvm-readobj.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 102cc64aa..2aa087394 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -2171,12 +2171,14 @@ void COFFDumper::printCOFFPseudoReloc() {
           ImportDirectories, EntryRVA,
           [](uint32_t RVA, const auto &D) { return RVA < D.StartRVA; });
       if (Ite == ImportDirectories.begin())
-        return createStringError("the reference of the symbol points out of the import table");
+        return createStringError(
+            "the reference of the symbol points out of the import table");
 
       --Ite;
       uint32_t RVA = Ite->StartRVA;
       if (Ite->EndRVA != 0 && Ite->EndRVA <= RVA)
-        return createStringError("the reference of the symbol points out of the import table");
+        return createStringError(
+            "the reference of the symbol points out of the import table");
       // Search with linear iteration to care if padding or garbage exist
       // between ImportDirectoryEntry
       for (auto S : Ite->EntryRef.imported_symbols()) {
@@ -2190,11 +2192,13 @@ void COFFDumper::printCOFFPseudoReloc() {
         }
         RVA += Obj->is64() ? 8 : 4;
         if (EntryRVA < RVA)
-          return createStringError("the reference of the symbol doesn't point imported symbol properly");
+          return createStringError("the reference of the symbol doesn't point "
+                                   "imported symbol properly");
       }
       Ite->EndRVA = RVA;
 
-      return createStringError("the reference of the symbol points out of the import table");
+      return createStringError(
+          "the reference of the symbol points out of the import table");
     }
 
   private:
@@ -2203,14 +2207,12 @@ void COFFDumper::printCOFFPseudoReloc() {
     DenseMap<uint32_t, StringRef> ImportedSymbols;
   };
   CachingImportedSymbolLookup ImportedSymbols(Obj);
-  llvm::stable_sort(RVASymbolMap, [](const auto &x, const auto &y) {
-    return x.RVA < y.RVA;
-  });
-  RVASymbolMap.erase(llvm::unique(RVASymbolMap,
-                                  [](const auto &x, const auto &y) {
-                                    return x.RVA == y.RVA;
-                                  }),
-                     RVASymbolMap.end());
+  llvm::stable_sort(RVASymbolMap,
+                    [](const auto &x, const auto &y) { return x.RVA < y.RVA; });
+  RVASymbolMap.erase(
+      llvm::unique(RVASymbolMap,
+                   [](const auto &x, const auto &y) { return x.RVA == y.RVA; }),
+      RVASymbolMap.end());
 
   for (const auto &Reloc : RelocRecords) {
     DictScope Entry(W, "Entry");

``````````

</details>


https://github.com/llvm/llvm-project/pull/151816


More information about the llvm-commits mailing list