[lld] 6cf1ea9 - [ELF,test] Improve unclosed tests
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 16:51:47 PDT 2024
Author: Fangrui Song
Date: 2024-07-26T16:51:42-07:00
New Revision: 6cf1ea99c6c022bf2ca59362775ba36aaa688d79
URL: https://github.com/llvm/llvm-project/commit/6cf1ea99c6c022bf2ca59362775ba36aaa688d79
DIFF: https://github.com/llvm/llvm-project/commit/6cf1ea99c6c022bf2ca59362775ba36aaa688d79.diff
LOG: [ELF,test] Improve unclosed tests
Added:
Modified:
lld/test/ELF/linkerscript/memory-err.s
lld/test/ELF/linkerscript/overlay.test
lld/test/ELF/linkerscript/phdrs.s
lld/test/ELF/linkerscript/sections.s
Removed:
################################################################################
diff --git a/lld/test/ELF/linkerscript/memory-err.s b/lld/test/ELF/linkerscript/memory-err.s
index 5ec190a415b29..5500b840ac830 100644
--- a/lld/test/ELF/linkerscript/memory-err.s
+++ b/lld/test/ELF/linkerscript/memory-err.s
@@ -71,6 +71,10 @@
# RUN: not ld.lld -T %t.script %t.o -o /dev/null 2>&1 | FileCheck --check-prefix=NOT_CONVERGE %s
# NOT_CONVERGE: error: address (0x14) of section '.text' does not converge
+# RUN: echo 'MEMORY { ram : ORIGIN = symbol, LENGTH = 4094 ' > %t.script
+# RUN: not ld.lld -T %t.script %t.o -o /dev/null 2>&1 | FileCheck --check-prefix=UNCLOSED %s
+# UNCLOSED: error: {{.*}}:1: unexpected EOF
+
nop
.data
diff --git a/lld/test/ELF/linkerscript/overlay.test b/lld/test/ELF/linkerscript/overlay.test
index b939ee4c4095b..59b5b6c62aad3 100644
--- a/lld/test/ELF/linkerscript/overlay.test
+++ b/lld/test/ELF/linkerscript/overlay.test
@@ -92,3 +92,11 @@ SECTIONS {
.out.aaa { *(.aaa) } > AX AT>FLASH
}
}
+
+#--- unclosed.lds
+SECTIONS {
+ OVERLAY 0x1000 : AT ( 0x2000 ) {
+
+# RUN: not ld.lld a.o -T unclosed.lds 2>&1 | FileCheck %s --check-prefix=UNCLOSED
+# UNCLOSED: error: unclosed.lds:1: unexpected EOF
+# UNCLOSED-NOT: {{.}}
diff --git a/lld/test/ELF/linkerscript/phdrs.s b/lld/test/ELF/linkerscript/phdrs.s
index 4ddb2bdb25c47..18307bcf36675 100644
--- a/lld/test/ELF/linkerscript/phdrs.s
+++ b/lld/test/ELF/linkerscript/phdrs.s
@@ -97,6 +97,12 @@ PHDRS { text PT_FOO FOOHDR; }
# PTFOO-NEXT:>>> PHDRS { text PT_FOO FOOHDR; }
# PTFOO-NEXT:>>> ^
+#--- unclosed.lds
+PHDRS { text PT_LOAD ;
+
+# RUN: not ld.lld -T unclosed.lds a.o 2>&1 | FileCheck --check-prefix=UNCLOSED %s
+# UNCLOSED:error: unclosed.lds:1: invalid program header type:
+
#--- a.s
.global _start
_start:
diff --git a/lld/test/ELF/linkerscript/sections.s b/lld/test/ELF/linkerscript/sections.s
index fc03af8402dfe..0453a12ceb147 100644
--- a/lld/test/ELF/linkerscript/sections.s
+++ b/lld/test/ELF/linkerscript/sections.s
@@ -1,18 +1,22 @@
# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
-# Empty SECTIONS command.
-# RUN: echo "SECTIONS {}" > %t.script
-# RUN: ld.lld -o %t1 --script %t.script %t
-# RUN: llvm-objdump --section-headers %t1 | \
+#--- empty.lds
+SECTIONS {}
+
+# RUN: ld.lld -o empty -T empty.lds a.o
+# RUN: llvm-objdump --section-headers empty | \
# RUN: FileCheck -check-prefix=SEC-DEFAULT %s
+#--- 1.lds
# SECTIONS command with the same order as default.
-# RUN: echo "SECTIONS { \
-# RUN: .text : { *(.text) } \
-# RUN: .data : { *(.data) } }" > %t.script
-# RUN: ld.lld -o %t2 --script %t.script %t
-# RUN: llvm-objdump --section-headers %t2 | \
+SECTIONS {
+ .text : { *(.text) }
+ .data : { *(.data) } }
+
+# RUN: ld.lld -o 1 -T 1.lds a.o
+# RUN: llvm-objdump --section-headers 1 | \
# RUN: FileCheck -check-prefix=SEC-DEFAULT %s
# Idx Name Size
@@ -28,8 +32,8 @@
# .text and .data have swapped names but proper sizes and types.
# RUN: echo "SECTIONS { \
# RUN: .data : { *(.text) } \
-# RUN: .text : { *(.data) } }" > %t.script
-# RUN: ld.lld -o %t4 --script %t.script %t
+# RUN: .text : { *(.data) } }" > t.lds
+# RUN: ld.lld -o %t4 --script t.lds a.o
# RUN: llvm-objdump --section-headers %t4 | \
# RUN: FileCheck -check-prefix=SEC-SWAP-NAMES %s
@@ -50,8 +54,8 @@
# RUN: .text : { *(.text) } \
# RUN: .data : { *(.data) } } \
# RUN: SECTIONS { \
-# RUN: .data : { *(other) } }" > %t.script
-# RUN: ld.lld -o %t6 --script %t.script %t
+# RUN: .data : { *(other) } }" > t.lds
+# RUN: ld.lld -o %t6 --script t.lds a.o
# RUN: llvm-objdump --section-headers %t6 | \
# RUN: FileCheck -check-prefix=SEC-MULTI %s
@@ -72,7 +76,7 @@
# RUN: .data : { *(.data) } \
# RUN: .comment : { *(.comment) } \
# RUN: other : { *(other) } }' > %t5.lds
-# RUN: ld.lld -o %t5 -T %t5.lds %t
+# RUN: ld.lld -o %t5 -T %t5.lds a.o
# RUN: llvm-readelf -S -l %t5 | FileCheck --check-prefix=SEP-BY-NONALLOC %s
# SEP-BY-NONALLOC: [Nr] Name Type Address Off Size ES Flg
@@ -87,11 +91,25 @@
# SEP-BY-NONALLOC-NEXT: LOAD 0x00100e 0x000000000000000e 0x000000000000000e 0x000023 0x000025 RW 0x1000
# SEP-BY-NONALLOC-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0
+#--- semi.lds
# Input section pattern contains additional semicolon.
# Case found in linux kernel script. Check we are able to parse it.
-# RUN: echo "SECTIONS { .text : { ;;*(.text);;S = 0;; } }" > %t.script
-# RUN: ld.lld -o /dev/null --script %t.script %t
+SECTIONS { .text : { ;;*(.text);;S = 0;; } }
+
+# RUN: ld.lld -T semi.lds a.o
+
+#--- unclosed.lds
+SECTIONS {
+ .text : { *(.text) }
+
+# RUN: not ld.lld -T unclosed.lds a.o 2>&1 | FileCheck --check-prefix=UNCLOSED %s
+# UNCLOSED: error: unclosed.lds:1: malformed number:
+
+#--- unclosed-out.lds
+SECTIONS {
+ .text : { *(.text)
+#--- a.s
.globl _start
_start:
mov $60, %rax
More information about the llvm-commits
mailing list