[lld] r319473 - Error on -no-define-common if the output is not relocatable.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 12:46:33 PST 2017
Author: rafael
Date: Thu Nov 30 12:46:33 2017
New Revision: 319473
URL: http://llvm.org/viewvc/llvm-project?rev=319473&view=rev
Log:
Error on -no-define-common if the output is not relocatable.
The ELF spec says
Symbols with section index SHN_COMMON may appear only in relocatable
objects.
Currently lld can produce file that break that requirement.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/relocatable-common.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=319473&r1=319472&r2=319473&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Nov 30 12:46:33 2017
@@ -278,6 +278,9 @@ static void checkOptions(opt::InputArgLi
if (!Config->Shared && !Config->AuxiliaryList.empty())
error("-f may not be used without -shared");
+ if (!Config->Relocatable && !Config->DefineCommon)
+ error("-no-define-common not supported in non relocatable output");
+
if (Config->Relocatable) {
if (Config->Shared)
error("-r and -shared may not be used together");
Modified: lld/trunk/test/ELF/relocatable-common.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocatable-common.s?rev=319473&r1=319472&r2=319473&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocatable-common.s (original)
+++ lld/trunk/test/ELF/relocatable-common.s Thu Nov 30 12:46:33 2017
@@ -33,4 +33,7 @@
# DEFCOMM-NEXT: Section: COMMON
# DEFCOMM-NEXT: }
+# RUN: not ld.lld -shared --no-define-common %t1.o -o %t 2>&1 | FileCheck --check-prefix=ERROR %s
+# ERROR: error: -no-define-common not supported in non relocatable output
+
.comm common,4,4
More information about the llvm-commits
mailing list