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

Tomohiro Kashiwada via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 05:29:34 PDT 2025


================
@@ -2000,6 +2001,122 @@ void COFFDumper::printCOFFBaseReloc() {
   }
 }
 
+void COFFDumper::printCOFFPseudoReloc() {
+  const StringRef RelocBeginName = Obj->getArch() == Triple::x86
+                                       ? "___RUNTIME_PSEUDO_RELOC_LIST__"
+                                       : "__RUNTIME_PSEUDO_RELOC_LIST__";
+  const StringRef RelocEndName = Obj->getArch() == Triple::x86
+                                     ? "___RUNTIME_PSEUDO_RELOC_LIST_END__"
+                                     : "__RUNTIME_PSEUDO_RELOC_LIST_END__";
+
+  COFFSymbolRef RelocBegin, RelocEnd;
+  auto Count = Obj->getNumberOfSymbols();
+  if (Count == 0) {
+    W.startLine() << "The symbol table has been stripped\n";
+    return;
+  }
+  for (auto i = 0u;
+       i < Count && (!RelocBegin.getRawPtr() || !RelocEnd.getRawPtr()); ++i) {
+    auto Sym = Obj->getSymbol(i);
+    if (Sym.takeError())
+      continue;
----------------
kikairoya wrote:

With `Expected<COFFSymbolRef> SymOrErr = Obj->getSymbol(i + 100)` to enforce to emit warnings, I got 6 completely same warning messages while dumping `pseudoreloc.test.tmp.exe-x86_64` as following:
```
$ bin/llvm-readobj test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64 --coff-pseudoreloc

File: test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64
Format: COFF-x86-64
Arch: x86_64
AddressSize: 64bit
PseudoReloc [
bin/llvm-readobj: warning: 'test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64': Invalid data was encountered while parsing the file
bin/llvm-readobj: warning: 'test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64': Invalid data was encountered while parsing the file
bin/llvm-readobj: warning: 'test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64': Invalid data was encountered while parsing the file
bin/llvm-readobj: warning: 'test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64': Invalid data was encountered while parsing the file
bin/llvm-readobj: warning: 'test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64': Invalid data was encountered while parsing the file
bin/llvm-readobj: warning: 'test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64': Invalid data was encountered while parsing the file
bin/llvm-readobj: warning: 'test/tools/llvm-readobj/COFF/Output/pseudoreloc.test.tmp.exe-x86_64': the marker symbols for runtime pseudo-relocation were not found
]
```

What does "each identical warning" mean?

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


More information about the llvm-commits mailing list