[lld] r262377 - [ELF] - handle of command line options incompatible with -r
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 11:38:52 PST 2016
Author: grimar
Date: Tue Mar 1 13:38:51 2016
New Revision: 262377
URL: http://llvm.org/viewvc/llvm-project?rev=262377&view=rev
Log:
[ELF] - handle of command line options incompatible with -r
Patch handles the command line options
incompatible with relocatable output.
Differential revision: http://reviews.llvm.org/D17758
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/driver.test
lld/trunk/test/ELF/relocatable.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=262377&r1=262376&r2=262377&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Mar 1 13:38:51 2016
@@ -141,8 +141,15 @@ static void checkOptions(opt::InputArgLi
if (Config->EMachine == EM_AMDGPU && !Config->Entry.empty())
error("-e option is not valid for AMDGPU.");
- if (Config->Relocatable && Config->Shared)
+ if (!Config->Relocatable)
+ return;
+
+ if (Config->Shared)
error("-r and -shared may not be used together");
+ if (Config->GcSections)
+ error("-r and --gc-sections may not be used together");
+ if (Config->ICF)
+ error("-r and --icf may not be used together");
}
static StringRef
Modified: lld/trunk/test/ELF/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/driver.test?rev=262377&r1=262376&r2=262377&view=diff
==============================================================================
--- lld/trunk/test/ELF/driver.test (original)
+++ lld/trunk/test/ELF/driver.test Tue Mar 1 13:38:51 2016
@@ -20,6 +20,23 @@
# RUN: ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s
# VERSION: LLD
+## Attempt to link DSO with -r
+# RUN: ld.lld -shared %t -o %t.so
+# RUN: not ld.lld -r %t.so %t -o %tfail 2>&1 | FileCheck -check-prefix=ERR %s
+# ERR: Attempted static link of dynamic object
+
+## Attempt to use -r and -shared together
+# RUN: not ld.lld -r -shared %t -o %tfail 2>&1 | FileCheck -check-prefix=ERR2 %s
+# ERR2: -r and -shared may not be used together
+
+## Attempt to use -r and --gc-sections together
+# RUN: not ld.lld -r --gc-sections %t -o %tfail 2>&1 | FileCheck -check-prefix=ERR3 %s
+# ERR3: -r and --gc-sections may not be used together
+
+## Attempt to use -r and --icf together
+# RUN: not ld.lld -r --icf=all %t -o %tfail 2>&1 | FileCheck -check-prefix=ERR4 %s
+# ERR4: -r and --icf may not be used together
+
.globl _start
_start:
nop
Modified: lld/trunk/test/ELF/relocatable.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocatable.s?rev=262377&r1=262376&r2=262377&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocatable.s (original)
+++ lld/trunk/test/ELF/relocatable.s Tue Mar 1 13:38:51 2016
@@ -15,15 +15,6 @@
# RUN: ld.lld -e main %t -o %texec
# RUN: llvm-readobj -file-headers %texec | FileCheck -check-prefix=CHECKEXE %s
-## Attempt to link DSO with -r
-# RUN: ld.lld -shared %t1.o -o %t.so
-# RUN: not ld.lld -r %t.so %t2.o -o %tfail 2>&1 | FileCheck -check-prefix=ERR %s
-# ERR: Attempted static link of dynamic object
-
-## Attempt to use -r and shared together
-# RUN: not ld.lld -r -shared %t2.o -o %tfail 2>&1 | FileCheck -check-prefix=ERR2 %s
-# ERR2: -r and -shared may not be used together
-
# CHECK: ElfHeader {
# CHECK-NEXT: Ident {
# CHECK-NEXT: Magic: (7F 45 4C 46)
More information about the llvm-commits
mailing list