[PATCH] D17758: [ELF] - handle of command line options incompatible with -r
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 02:01:27 PST 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
I would like to prepare a serie of patches to improve -r support.
This one handles the all incompatible command line options.
http://reviews.llvm.org/D17758
Files:
ELF/Driver.cpp
test/ELF/relocatable-errors.s
test/ELF/relocatable.s
Index: test/ELF/relocatable.s
===================================================================
--- test/ELF/relocatable.s
+++ test/ELF/relocatable.s
@@ -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)
Index: test/ELF/relocatable-errors.s
===================================================================
--- test/ELF/relocatable-errors.s
+++ test/ELF/relocatable-errors.s
@@ -0,0 +1,25 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+
+## Attempt to link DSO with -r
+# RUN: ld.lld -shared %t1.o -o %t.so
+# RUN: not ld.lld -r %t.so %t1.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 %t1.o -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 %t1.o -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 %t1.o -o %tfail 2>&1 | FileCheck -check-prefix=ERR4 %s
+# ERR4: -r and --icf may not be used together
+
+.text
+.globl main
+.type main, at function
+main:
+
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -141,8 +141,14 @@
if (Config->EMachine == EM_AMDGPU && !Config->Entry.empty())
error("-e option is not valid for AMDGPU.");
- if (Config->Relocatable && Config->Shared)
- error("-r and -shared may not be used together");
+ if (Config->Relocatable) {
+ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17758.49465.patch
Type: text/x-patch
Size: 2521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160301/44fbc2be/attachment.bin>
More information about the llvm-commits
mailing list