[llvm] [llvm-pdbutil] Create DBI section headers in yaml2pdb (PR #166566)

Alexandre Ganea via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 08:28:46 PST 2025


================
@@ -865,6 +869,18 @@ static void yamlToPdb(StringRef Path) {
     }
   }
 
+  std::vector<object::coff_section> Sections;
+  if (!Dbi.SectionHeaders.empty()) {
+    for (const auto &Hdr : Dbi.SectionHeaders)
+      Sections.emplace_back(Hdr.toCoffSection());
+
+    DbiBuilder.createSectionMap(Sections);
+    ExitOnErr(DbiBuilder.addDbgStream(
+        pdb::DbgHeaderType::SectionHdr,
+        ArrayRef<uint8_t>{(const uint8_t *)Sections.data(),
----------------
aganea wrote:

Ah yes the downcasting from `object::coff_section *` to `uint_8_t *` must be explicit. The reason I mentionned that is that I think boilerplate like this doesn't belong in high level code. We should probably have something like `arrayRefFromStringRef`, but for downcasting any `ArrayRef<T>` to a `ArrayRef<uint8_t>`. We can probably do that in a follow-up PR, since this should be a separate discussion.

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


More information about the llvm-commits mailing list