[llvm] [llvm-readobj][COFF] Dump .modmeta section (PR #201695)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 01:00:43 PDT 2026
================
@@ -2558,3 +2561,74 @@ void COFFDumper::printCOFFTLSDirectory(
ArrayRef(ImageSectionCharacteristics),
COFF::SectionCharacteristics(COFF::IMAGE_SCN_ALIGN_MASK));
}
+
+void COFFDumper::printCOFFCxxModuleMetadata() {
+ SectionRef Sect;
+ for (const SectionRef &S : Obj->sections()) {
+ StringRef SectionName = unwrapOrError(Obj->getFileName(), S.getName());
+ if (SectionName == ".modmeta") {
+ Sect = S;
+ break;
+ }
+ }
+ if (Sect == SectionRef())
+ return;
+
+ StringRef Contents = unwrapOrError(Obj->getFileName(), Sect.getContents());
+ COFFCxxModuleMetadata ModMap =
+ unwrapOrError(Obj->getFileName(), parseCOFFCxxModuleMetadata(Contents));
+
+ DictScope D(W, "CxxModuleMetadata");
+ W.printNumber("Version", ModMap.Version);
+ W.printNumber("Reserved", ModMap.Reserved);
+ W.printNumber("ModuleIndexWidth", ModMap.ModuleIndexWidth);
+ W.printNumber("SymbolIndexWidth", ModMap.SymbolIndexWidth);
+
+ COFFCxxModuleMetadataReader Reader(ModMap);
+
+ SmallSet<uint32_t, 8> HeaderUnits;
+ Error Err = Reader.readModuleList(makeVisitor([&](auto A) {
+ for (auto V : A)
+ HeaderUnits.insert(V);
+ }));
+ if (Err)
+ reportError(std::move(Err), Obj->getFileName());
----------------
jh7370 wrote:
Similar to `unwrapOrError`, we should generally avoid `reportError` in newer code, in favour of using `reportWarning`, since it otherwise prevents other requested llvm-readobj operations.
https://github.com/llvm/llvm-project/pull/201695
More information about the llvm-commits
mailing list