[ELF][test] Rename SHF_LINK_ORDER related "metadata" to "linkorder"
authorFangrui Song <maskray@google.com>
Thu, 27 Feb 2020 00:24:58 +0000 (16:24 -0800)
committerFangrui Song <maskray@google.com>
Thu, 27 Feb 2020 01:36:59 +0000 (17:36 -0800)
Test cleanups.

lld/test/ELF/gc-sections-linkorder-err.s [moved from lld/test/ELF/gc-sections-metadata-err.s with 100% similarity]
lld/test/ELF/gc-sections-linkorder.s [new file with mode: 0644]
lld/test/ELF/gc-sections-linkorder2.s [moved from lld/test/ELF/gc-sections-metadata2.s with 60% similarity]
lld/test/ELF/gc-sections-metadata.s [deleted file]
lld/test/ELF/linkerscript/discard-linkorder.s [moved from lld/test/ELF/linkerscript/discard-section-metadata.s with 100% similarity]
lld/test/ELF/linkerscript/linkorder.s [moved from lld/test/ELF/linkerscript/section-metadata.s with 100% similarity]
lld/test/ELF/linkerscript/linkorder2.s [moved from lld/test/ELF/linkerscript/section-metadata2.s with 100% similarity]
lld/test/ELF/linkorder-err.s [new file with mode: 0644]
lld/test/ELF/linkorder-err2.s [moved from lld/test/ELF/section-metadata-err2.s with 55% similarity]
lld/test/ELF/linkorder-err3.s [moved from lld/test/ELF/section-metadata-err3.s with 85% similarity]
lld/test/ELF/section-metadata-err.s [deleted file]

diff --git a/lld/test/ELF/gc-sections-linkorder.s b/lld/test/ELF/gc-sections-linkorder.s
new file mode 100644 (file)
index 0000000..54a29ab
--- /dev/null
@@ -0,0 +1,32 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: ld.lld --gc-sections --print-gc-sections %t.o -o /dev/null | FileCheck %s --implicit-check-not=removing
+
+# CHECK: removing unused section {{.*}}.o:(.foo2)
+# CHECK: removing unused section {{.*}}.o:(bar2)
+# CHECK: removing unused section {{.*}}.o:(.zed2)
+
+.global _start
+_start:
+.quad .foo1
+
+.section .foo1,"a"
+.quad 0
+
+.section .foo2,"a"
+.quad 0
+
+.section bar1,"ao",@progbits,.foo1
+.quad .zed1
+.quad .foo1
+
+.section bar2,"ao",@progbits,.foo2
+.quad .zed2
+.quad .foo2
+
+.section .zed1,"a"
+.quad 0
+
+.section .zed2,"a"
+.quad 0
similarity index 60%
rename from lld/test/ELF/gc-sections-metadata2.s
rename to lld/test/ELF/gc-sections-linkorder2.s
index 3a3b640..b22bc58 100644 (file)
@@ -1,16 +1,13 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: ld.lld --gc-sections %t.o -o %t
-# RUN: llvm-objdump -section-headers %t | FileCheck %s
 
-# CHECK: .foo
-# CHECK: .bar
-# CHECK: .zed
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --gc-sections --print-gc-sections %t.o -o /dev/null | count 0
 
 .globl _start
 _start:
 .quad .foo
 
+## .foo is retained, so sections linking to it are retained as well.
 .section .foo,"a"
 .quad 0
 .section .bar,"ao",@progbits,.foo
diff --git a/lld/test/ELF/gc-sections-metadata.s b/lld/test/ELF/gc-sections-metadata.s
deleted file mode 100644 (file)
index 2e696f8..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-# REQUIRES: x86
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: ld.lld --gc-sections %t.o -o %t
-# RUN: llvm-objdump -section-headers %t | FileCheck  %s
-
-# CHECK:      1 .foo1
-# CHECK-NEXT:   bar1
-# CHECK-NEXT:   .zed1
-# CHECK-NEXT:   .text
-# CHECK-NEXT:   .comment
-# CHECK-NEXT:   .symtab
-# CHECK-NEXT:   .shstrtab
-# CHECK-NEXT:   .strtab
-
-.global _start
-_start:
-.quad .foo1
-
-.section .foo1,"a"
-.quad 0
-
-.section .foo2,"a"
-.quad 0
-
-.section bar1,"ao",@progbits,.foo1
-.quad .zed1
-.quad .foo1
-
-.section bar2,"ao",@progbits,.foo2
-.quad .zed2
-.quad .foo2
-
-.section .zed1,"a"
-.quad 0
-
-.section .zed2,"a"
-.quad 0
diff --git a/lld/test/ELF/linkorder-err.s b/lld/test/ELF/linkorder-err.s
new file mode 100644 (file)
index 0000000..85409ec
--- /dev/null
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
+
+# CHECK: error: a section .foo with SHF_LINK_ORDER should not refer a non-regular section: {{.*}}.o:(.merge)
+
+.section .merge,"aM",@progbits,8
+.quad 0
+.section .foo,"ao",@progbits,.merge
+.quad 0
similarity index 55%
rename from lld/test/ELF/section-metadata-err2.s
rename to lld/test/ELF/linkorder-err2.s
index 3191c1f..ccacd00 100644 (file)
@@ -4,8 +4,8 @@
 # RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
 
 ## Check we do not crash and report proper errors.
-# CHECK: error: a section .bar with SHF_LINK_ORDER should not refer a non-regular section: {{.*}}section-metadata-err2.s.tmp.o:(.foo)
-# CHECK: error: a section .bar with SHF_LINK_ORDER should not refer a non-regular section: {{.*}}section-metadata-err2.s.tmp.o:(.foo)
+# CHECK:      error: a section .bar with SHF_LINK_ORDER should not refer a non-regular section: {{.*}}.o:(.foo)
+# CHECK-NEXT: error: a section .bar with SHF_LINK_ORDER should not refer a non-regular section: {{.*}}.o:(.foo)
 
 .section .foo,"aM",@progbits,8
 .quad 0
similarity index 85%
rename from lld/test/ELF/section-metadata-err3.s
rename to lld/test/ELF/linkorder-err3.s
index 5c4875b..2e36ab4 100644 (file)
@@ -4,7 +4,7 @@
 # RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
 
 # CHECK:      error: incompatible section flags for .bar
-# CHECK-NEXT: >>> {{.*}}section-metadata-err3.s.tmp.o:(.bar): 0x2
+# CHECK-NEXT: >>> {{.*}}.o:(.bar): 0x2
 # CHECK-NEXT: >>> output section .bar: 0x82
 
 .section .foo,"a",@progbits
diff --git a/lld/test/ELF/section-metadata-err.s b/lld/test/ELF/section-metadata-err.s
deleted file mode 100644 (file)
index c910430..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-# REQUIRES: x86
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
-
-# CHECK: error: a section .bar with SHF_LINK_ORDER should not refer a non-regular section: {{.*}}section-metadata-err.s.tmp.o:(.foo)
-
-.global _start
-_start:
-.quad .foo
-
-.section .foo,"aM",@progbits,8
-.quad 0
-
-.section .bar,"ao",@progbits,.foo