aboutsummaryrefslogtreecommitdiff
path: root/test/ELF/emit-relocs-gc.s
diff options
context:
space:
mode:
Diffstat (limited to 'test/ELF/emit-relocs-gc.s')
-rw-r--r--test/ELF/emit-relocs-gc.s30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ELF/emit-relocs-gc.s b/test/ELF/emit-relocs-gc.s
new file mode 100644
index 000000000000..0741e78ab955
--- /dev/null
+++ b/test/ELF/emit-relocs-gc.s
@@ -0,0 +1,30 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+
+## Show that we emit .rela.bar and .rela.text when GC is disabled.
+# RUN: ld.lld --emit-relocs %t.o -o %t
+# RUN: llvm-objdump %t -section-headers | FileCheck %s --check-prefix=NOGC
+# NOGC: .rela.text
+# NOGC: .rela.bar
+
+## GC collects .bar section and we exclude .rela.bar from output. We keep
+## .rela.text because we keep .text.
+# RUN: ld.lld --gc-sections --emit-relocs --print-gc-sections %t.o -o %t \
+# RUN: | FileCheck --check-prefix=MSG %s
+# MSG: removing unused section from '.bar' in file
+# MSG: removing unused section from '.rela.bar' in file
+# RUN: llvm-objdump %t -section-headers | FileCheck %s --check-prefix=GC
+# GC-NOT: rela.bar
+# GC: rela.text
+# GC-NOT: rela.bar
+
+.section .bar,"a"
+.quad .bar
+
+.text
+relocs:
+.quad _start
+
+.global _start
+_start:
+ nop