[PATCH] D40661: Error on -no-define-common if the output is not relocatable
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 10:28:37 PST 2017
rafael created this revision.
Herald added a subscriber: emaste.
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.
https://reviews.llvm.org/D40661
Files:
ELF/Driver.cpp
test/ELF/relocatable-common.s
Index: test/ELF/relocatable-common.s
===================================================================
--- test/ELF/relocatable-common.s
+++ test/ELF/relocatable-common.s
@@ -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
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -667,6 +667,9 @@
Config->ZText = !hasZOption(Args, "notext");
Config->ZWxneeded = hasZOption(Args, "wxneeded");
+ if (!Config->Relocatable && !Config->DefineCommon)
+ error("-no-define-common not supported in non relocatable output");
+
// Parse LTO plugin-related options for compatibility with gold.
for (auto *Arg : Args.filtered(OPT_plugin_opt, OPT_plugin_opt_eq)) {
StringRef S = Arg->getValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40661.124964.patch
Type: text/x-patch
Size: 997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/87f54eef/attachment.bin>
More information about the llvm-commits
mailing list