Add test for interaction of --gc-sections and undefined references

It is possible for a link to fail with an undefined reference, unless
--gc-sections is specified, removing the reference in the process. This
doesn't look to be tested anywhere explicitly, so I thought it useful
to add a test for it to ensure the behaviour is maintained.

Reviewers: ruiu

Differential Revision: https://reviews.llvm.org/D42299

llvm-svn: 323099
This commit is contained in:
James Henderson 2018-01-22 10:58:06 +00:00
parent 245e0e67f3
commit 0018ca8462
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# Sanity check that the link will fail with the undefined error without
# gc-sections.
# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
# CHECK: error: undefined symbol: undefined
# RUN: ld.lld %t.o --gc-sections -o %t
.section .text.unused,"ax",@progbits
unused:
callq undefined
.text
.global _start
_start:
nop