[lld] r323099 - Add test for interaction of --gc-sections and undefined references

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 02:58:06 PST 2018


Author: jhenderson
Date: Mon Jan 22 02:58:06 2018
New Revision: 323099

URL: http://llvm.org/viewvc/llvm-project?rev=323099&view=rev
Log:
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

Added:
    lld/trunk/test/ELF/gc-sections-no-undef-error.s

Added: lld/trunk/test/ELF/gc-sections-no-undef-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gc-sections-no-undef-error.s?rev=323099&view=auto
==============================================================================
--- lld/trunk/test/ELF/gc-sections-no-undef-error.s (added)
+++ lld/trunk/test/ELF/gc-sections-no-undef-error.s Mon Jan 22 02:58:06 2018
@@ -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", at progbits
+unused:
+  callq undefined
+
+.text
+.global _start
+_start:
+  nop




More information about the llvm-commits mailing list