[lld] 36aef4b - [ELF, test] Combine merge section out-of-bounds tests into merge-piece-oob.s (#188688)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 25 23:06:39 PDT 2026


Author: Fangrui Song
Date: 2026-03-25T23:06:34-07:00
New Revision: 36aef4ba811a2ef24abb0050f4b23b7c6d4f6c87

URL: https://github.com/llvm/llvm-project/commit/36aef4ba811a2ef24abb0050f4b23b7c6d4f6c87
DIFF: https://github.com/llvm/llvm-project/commit/36aef4ba811a2ef24abb0050f4b23b7c6d4f6c87.diff

LOG: [ELF,test] Combine merge section out-of-bounds tests into merge-piece-oob.s (#188688)

Added: 
    lld/test/ELF/merge-piece-oob.s

Modified: 
    

Removed: 
    lld/test/ELF/relocation-before-merge-start.s
    lld/test/ELF/relocation-past-merge-end.s


################################################################################
diff  --git a/lld/test/ELF/merge-piece-oob.s b/lld/test/ELF/merge-piece-oob.s
new file mode 100644
index 0000000000000..ac552cc1498af
--- /dev/null
+++ b/lld/test/ELF/merge-piece-oob.s
@@ -0,0 +1,39 @@
+# REQUIRES: x86
+## Test out-of-bounds section symbol offsets in SHF_MERGE sections.
+
+# RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64
+# RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s -DPREFIX=error --implicit-check-not=error:
+# RUN: ld.lld %t.o -o /dev/null -shared --noinhibit-exec 2>&1 | FileCheck %s -DPREFIX=warning --implicit-check-not=warning:
+
+# CHECK:      [[PREFIX]]: {{.*}}:(.foo): offset is outside the section
+# CHECK-NEXT: [[PREFIX]]: {{.*}}:(.foo): offset is outside the section
+# CHECK-NEXT: [[PREFIX]]: {{.*}}:(.foo): offset is outside the section
+# CHECK-NEXT: [[PREFIX]]: {{.*}}:(.foo): offset is outside the section
+## .rodata.str1.1 is "abc\0" (4 bytes).
+# CHECK-NEXT: [[PREFIX]]: {{.*}}:(.rodata.str1.1): offset is outside the section
+## .data.retain references .foo-1 as well.
+# CHECK-NEXT: [[PREFIX]]: {{.*}}:(.foo): offset is outside the section
+
+.globl _start
+_start:
+
+.data
+.quad .foo + 8
+.quad .foo + 9
+.quad .foo + 0x100000000
+.quad .foo - 1
+.quad .rodata.str1.1 + 3
+.quad .rodata.str1.1 + 4
+
+.quad a0 - 1
+.quad a0 + 9
+
+.section .data.retain,"awR"
+.quad .foo - 1
+
+.section	.foo,"aM", at progbits,8
+a0:
+.quad 0
+
+.section	.rodata.str1.1,"aMS", at progbits,1
+.asciz	"abc"

diff  --git a/lld/test/ELF/relocation-before-merge-start.s b/lld/test/ELF/relocation-before-merge-start.s
deleted file mode 100644
index b5f7406f3a685..0000000000000
--- a/lld/test/ELF/relocation-before-merge-start.s
+++ /dev/null
@@ -1,9 +0,0 @@
-// REQUIRES: x86
-// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
-// RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s --implicit-check-not=error:
-// CHECK: error: {{.*}}:(.foo): offset is outside the section
-
-.data
-.quad .foo - 1
-.section	.foo,"aM", at progbits,4
-.quad 0

diff  --git a/lld/test/ELF/relocation-past-merge-end.s b/lld/test/ELF/relocation-past-merge-end.s
deleted file mode 100644
index 0aa201c31138f..0000000000000
--- a/lld/test/ELF/relocation-past-merge-end.s
+++ /dev/null
@@ -1,17 +0,0 @@
-// REQUIRES: x86
-// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64
-// RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s -DPREFIX=error --implicit-check-not=error:
-// RUN: ld.lld %t.o -o /dev/null -shared --noinhibit-exec 2>&1 | FileCheck %s -DPREFIX=warning --implicit-check-not=warning:
-
-// CHECK:      [[PREFIX]]: {{.*}}:(.foo): offset is outside the section
-// CHECK-NEXT: [[PREFIX]]: {{.*}}:(.rodata.str1.1): offset is outside the section
-
-.data
-.quad .foo + 10
-.quad .rodata.str1.1 + 4
-
-.section	.foo,"aM", at progbits,4
-.quad 0
-
-.section	.rodata.str1.1,"aMS", at progbits,1
-.asciz	"abc"


        


More information about the llvm-commits mailing list