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

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 01:15:03 PDT 2025


================
@@ -2140,38 +2162,43 @@ void COFFDumper::printCOFFPseudoReloc() {
       });
     }
 
-    const StringRef *find(uint32_t EntryRVA) {
+    Expected<StringRef> find(uint32_t EntryRVA) {
       if (auto Ite = ImportedSymbols.find(EntryRVA);
           Ite != ImportedSymbols.end())
-        return &Ite->second;
+        return Ite->second;
 
       auto Ite = llvm::upper_bound(
           ImportDirectories, EntryRVA,
           [](uint32_t RVA, const auto &D) { return RVA < D.StartRVA; });
       if (Ite == ImportDirectories.begin())
-        return nullptr;
+        return createStringError(
+            "the reference of the symbol points out of the import table");
----------------
jh7370 wrote:

I'm not a massive fan of the warnings in this function. I expect some of them could do with the address values as context. Also, grammatically, some improvements are needed, but I'm not sure on the best wording, because of my lack of specific PE/COFF knowledge.

@mstorsjo, could you provide suggestions for improvements to these warnings in this function, please?

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


More information about the llvm-commits mailing list