Test cleanups.
--- /dev/null
+# 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
# 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
+++ /dev/null
-# 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
--- /dev/null
+# 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
# 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
# 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
+++ /dev/null
-# 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