[lld] [LLD][ELF] Support OVERLAY symbol assignments (PR #159895)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 20 10:41:33 PDT 2025


================
@@ -0,0 +1,32 @@
+# REQUIRES: x86
+# RUN: echo 'nop; .section .small, "a"; .long 0; .section .big1, "a"; .quad 1; .section .big2, "a"; .quad 2;' \
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o
+# RUN: ld.lld %t.o --script %s -o %t
+
+SECTIONS {
+  OVERLAY 0x1000 : AT ( 0x4000 ) {
+    .out.big { 
+      *(.big1)
+      . = ALIGN(0x100);
+      *(.big2)
+    }
+    .out.small { *(.small) }
+  }
+}
+
+## A variant of overlay.test with explicit program header assingment.
+## Check that we generate two program headers consistent with the overlay
+
+# RUN: llvm-readelf -S -l %t | FileCheck %s
+
+# CHECK: Section Headers:
+# CHECK:      Name       Type     Address          Off    Size
+# CHECK:      .out.big   PROGBITS 0000000000001000 001000 000108
+# CHECK-NEXT: .out.small PROGBITS 0000000000001000 002000 000004
+
----------------
MaskRay wrote:

just one blank line 

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


More information about the llvm-commits mailing list