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

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 10:02:16 PDT 2025


================
@@ -0,0 +1,122 @@
+RUN: yaml2obj %p/Inputs/sectionlayout.yaml -o %t.obj
+
+## Error on non-exist input layout file
+RUN: not lld-link /entry:main /sectionlayout:doesnotexist.txt %t.obj
+
+## Order in 1 -> 3 -> 2
+RUN: echo ".text1" > %t.layout.txt
+RUN: echo ".text3" >> %t.layout.txt
+RUN: echo ".text2" >> %t.layout.txt
+RUN: lld-link /out:%t.exe /entry:main /sectionlayout:%t.layout.txt %t.obj
+RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=CHECK1 %s
+
+## While /sectionlayout:abc is valid, /sectionlayout:@abc is also accepted (to align with MS link.exe)
----------------
kkent030315 wrote:

Yeah it's a bit odd. The `/sectionlayout:` had a breaking change (syntax change) couple times. For instance, `/SECTIONLAYOUT:.text,.data,ALIGN=1,.rsrc` is no longer accepted in recent version of MS linker (they now only accept a file with `@path/to/file`). I am pretty sure it is somewhat relevant to the odd.

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


More information about the llvm-commits mailing list