[PATCH] D42299: [ELF] Add test for interaction of --gc-sections and undefined references
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 06:56:37 PST 2018
jhenderson created this revision.
jhenderson added reviewers: rafael, ruiu.
Herald added subscribers: llvm-commits, emaste.
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.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D42299
Files:
test/ELF/gc-sections-no-undef-error.s
Index: test/ELF/gc-sections-no-undef-error.s
===================================================================
--- test/ELF/gc-sections-no-undef-error.s
+++ test/ELF/gc-sections-no-undef-error.s
@@ -0,0 +1,20 @@
+# 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> %t.err
+# RUN: FileCheck %s --input-file %t.err
+# 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42299.130613.patch
Type: text/x-patch
Size: 666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180119/9a50265e/attachment.bin>
More information about the llvm-commits
mailing list