[lld] r280211 - [ELF] - Fix (partial) for bug 28843 - Make sure we handle options with opposing meanings.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 01:53:21 PDT 2016
Author: grimar
Date: Wed Aug 31 03:53:21 2016
New Revision: 280211
URL: http://llvm.org/viewvc/llvm-project?rev=280211&view=rev
Log:
[ELF] - Fix (partial) for bug 28843 - Make sure we handle options with opposing meanings.
As stated in PR28843:
we should handle command lines with
-target1-rel -target1-abs
--demangle --no-demangle
Patch implements this for specified options.
There are probably other conflicting options can exist,
so fix is called "partial".
Differential revision: https://reviews.llvm.org/D23867
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/arm-target1.s
lld/trunk/test/ELF/conflict.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=280211&r1=280210&r2=280211&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Aug 31 03:53:21 2016
@@ -344,6 +344,13 @@ static bool isOutputFormatBinary(opt::In
return false;
}
+static bool getArg(opt::InputArgList &Args, unsigned K1, unsigned K2,
+ bool Default) {
+ if (auto *Arg = Args.getLastArg(K1, K2))
+ return Arg->getOption().getID() == K1;
+ return Default;
+}
+
static DiscardPolicy getDiscardOption(opt::InputArgList &Args) {
auto *Arg =
Args.getLastArg(OPT_discard_all, OPT_discard_locals, OPT_discard_none);
@@ -362,7 +369,6 @@ static DiscardPolicy getDiscardOption(op
}
}
-
static StripPolicy getStripOption(opt::InputArgList &Args) {
if (auto *Arg = Args.getLastArg(OPT_strip_all, OPT_strip_debug)) {
if (Arg->getOption().getID() == OPT_strip_all)
@@ -393,7 +399,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->AllowMultipleDefinition = Args.hasArg(OPT_allow_multiple_definition);
Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic);
Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions);
- Config->Demangle = !Args.hasArg(OPT_no_demangle);
+ Config->Demangle = getArg(Args, OPT_demangle, OPT_no_demangle, true);
Config->DisableVerify = Args.hasArg(OPT_disable_verify);
Config->Discard = getDiscardOption(Args);
Config->EhFrameHdr = Args.hasArg(OPT_eh_frame_hdr);
@@ -409,7 +415,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->Relocatable = Args.hasArg(OPT_relocatable);
Config->SaveTemps = Args.hasArg(OPT_save_temps);
Config->Shared = Args.hasArg(OPT_shared);
- Config->Target1Rel = Args.hasArg(OPT_target1_rel);
+ Config->Target1Rel = getArg(Args, OPT_target1_rel, OPT_target1_abs, false);
Config->Threads = Args.hasArg(OPT_threads);
Config->Trace = Args.hasArg(OPT_trace);
Config->Verbose = Args.hasArg(OPT_verbose);
Modified: lld/trunk/test/ELF/arm-target1.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-target1.s?rev=280211&r1=280210&r2=280211&view=diff
==============================================================================
--- lld/trunk/test/ELF/arm-target1.s (original)
+++ lld/trunk/test/ELF/arm-target1.s Wed Aug 31 03:53:21 2016
@@ -7,6 +7,12 @@
// RUN: not ld.lld -shared %t.o -o %t3.so 2>&1 | FileCheck %s \
// RUN: --check-prefix=ABS
+// RUN: ld.lld -shared %t.o -o %t2.so --target1-abs --target1-rel
+// RUN: llvm-objdump -t -d %t2.so | FileCheck %s \
+// RUN: --check-prefix=RELATIVE
+// RUN: not ld.lld -shared %t.o -o %t3.so --target1-rel --target1-abs 2>&1 \
+// RUN: | FileCheck %s --check-prefix=ABS
+
// RELOC: Relocations [
// RELOC: .rel.text {
// RELOC: 0x0 R_ARM_TARGET1 patatino 0x0
Modified: lld/trunk/test/ELF/conflict.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/conflict.s?rev=280211&r1=280210&r2=280211&view=diff
==============================================================================
--- lld/trunk/test/ELF/conflict.s (original)
+++ lld/trunk/test/ELF/conflict.s Wed Aug 31 03:53:21 2016
@@ -12,6 +12,11 @@
# NO_DEMANGLE: duplicate symbol: _Z3muldd in
# NO_DEMANGLE: duplicate symbol: foo in
+# RUN: not ld.lld %t1.o %t1.o -o %t2 --demangle --no-demangle 2>&1 | \
+# RUN: FileCheck -check-prefix=NO_DEMANGLE %s
+# RUN: not ld.lld %t1.o %t1.o -o %t2 --no-demangle --demangle 2>&1 | \
+# RUN: FileCheck -check-prefix=DEMANGLE %s
+
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/conflict.s -o %t2.o
# RUN: llvm-ar rcs %t3.a %t2.o
# RUN: not ld.lld %t1.o %t3.a -u baz -o %t2 2>&1 | FileCheck -check-prefix=ARCHIVE %s
More information about the llvm-commits
mailing list