[PATCH] D23867: [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
Thu Aug 25 05:37:31 PDT 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added a subscriber: llvm-commits.
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 also others conflicting options, so fix is "partial".
https://reviews.llvm.org/D23867
Files:
ELF/Driver.cpp
test/ELF/arm-target1.s
test/ELF/conflict.s
Index: test/ELF/conflict.s
===================================================================
--- test/ELF/conflict.s
+++ test/ELF/conflict.s
@@ -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
Index: test/ELF/arm-target1.s
===================================================================
--- test/ELF/arm-target1.s
+++ test/ELF/arm-target1.s
@@ -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
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -344,6 +344,18 @@
return false;
}
+static bool shouldDemangle(opt::InputArgList &Args) {
+ if (auto *Arg = Args.getLastArg(OPT_demangle, OPT_no_demangle))
+ return Arg->getOption().getID() == OPT_demangle;
+ return true;
+}
+
+static bool shouldUseTarget1Rel(opt::InputArgList &Args) {
+ if (auto *Arg = Args.getLastArg(OPT_target1_abs, OPT_target1_rel))
+ return Arg->getOption().getID() == OPT_target1_rel;
+ return false;
+}
+
// Initializes Config members by the command line options.
void LinkerDriver::readConfigs(opt::InputArgList &Args) {
for (auto *Arg : Args.filtered(OPT_L))
@@ -365,7 +377,7 @@
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 = shouldDemangle(Args);
Config->DisableVerify = Args.hasArg(OPT_disable_verify);
Config->DiscardAll = Args.hasArg(OPT_discard_all);
Config->DiscardLocals = Args.hasArg(OPT_discard_locals);
@@ -385,7 +397,7 @@
Config->Shared = Args.hasArg(OPT_shared);
Config->StripAll = Args.hasArg(OPT_strip_all);
Config->StripDebug = Args.hasArg(OPT_strip_debug);
- Config->Target1Rel = Args.hasArg(OPT_target1_rel);
+ Config->Target1Rel = shouldUseTarget1Rel(Args);
Config->Threads = Args.hasArg(OPT_threads);
Config->Trace = Args.hasArg(OPT_trace);
Config->Verbose = Args.hasArg(OPT_verbose);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23867.69226.patch
Type: text/x-patch
Size: 3040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160825/106a31e1/attachment.bin>
More information about the llvm-commits
mailing list