[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
Thu Aug 7 01:54:03 PDT 2025
================
@@ -2002,51 +2002,94 @@ void COFFDumper::printCOFFBaseReloc() {
}
void COFFDumper::printCOFFPseudoReloc() {
+ if (!Obj->getDOSHeader()) {
+ W.startLine()
+ << "pseudo-relocation is only meaningful for a PE image file\n";
+ return;
+ }
+
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";
+ W.startLine() << "the symbol table has been stripped\n";
return;
}
- for (auto i = 0u;
- i < Count && (!RelocBegin.getRawPtr() || !RelocEnd.getRawPtr()); ++i) {
+
+ struct SymbolEntry {
+ COFFSymbolRef Symbol;
+ const coff_section *Section;
+ StringRef SymbolName;
+ };
+ std::map<uint32_t, SymbolEntry> RVASymbolMap;
+ COFFSymbolRef RelocBegin, RelocEnd;
+ for (auto i = 0u; i < Count; ++i) {
auto Sym = Obj->getSymbol(i);
- if (Sym.takeError())
+ if (!Sym) {
+ consumeError(Sym.takeError());
----------------
jh7370 wrote:
It's generally poor form to simply throw away errors. We should be reporting them with `reportWarning`, as I already said in a previous comment. Same applies throughout.
https://github.com/llvm/llvm-project/pull/151816
More information about the llvm-commits
mailing list