[lld] [LLD][COFF] Add support for custom section layout (PR #152779)

Alexandre Ganea via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 08:58:43 PDT 2025


================
@@ -214,6 +214,48 @@ void LinkerDriver::parseSection(StringRef s) {
   ctx.config.section[name] = parseSectionAttributes(ctx, attrs);
 }
 
+// Parses /sectionlayout:@ option argument.
+void LinkerDriver::parseSectionLayout(StringRef path) {
+  if (path.starts_with("@"))
+    path = path.substr(1);
+  std::unique_ptr<MemoryBuffer> layoutFile =
+      CHECK(MemoryBuffer::getFile(path), "could not open " + path);
+  StringRef content = layoutFile->getBuffer();
+  int index = 0;
+  std::set<std::string> seenSections;
----------------
aganea wrote:

Can you not check directly for existence in `ctx.config.sectionOrder` and omit this `seenSections`?

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


More information about the llvm-commits mailing list