summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Driver.cpp6
-rw-r--r--lld/ELF/Options.td3
-rw-r--r--lld/test/elf2/relocatable.s9
3 files changed, 18 insertions, 0 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 0d78830bf43..79ffd3039e4 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -100,6 +100,12 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
opt::InputArgList Args = parseArgs(&Alloc, ArgsArr);
createFiles(Args);
+ // Traditional linkers can generate re-linkable object files instead
+ // of executables or DSOs. We don't support that since the feature
+ // does not seem to provide more value than the static archiver.
+ if (Args.hasArg(OPT_relocatable))
+ error("-r option is not supported. Use 'ar' command instead.");
+
switch (Config->EKind) {
case ELF32LEKind:
link<ELF32LE>(Args);
diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 655c932241b..8dbf4634a68 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -82,6 +82,8 @@ def o : Separate<["-"], "o">, MetaVarName<"<path>">,
def rpath : Separate<["-"], "rpath">,
HelpText<"Add a DT_RUNPATH to the output">;
+def relocatable : Flag<["--"], "relocatable">;
+
def script : Separate<["--"], "script">, HelpText<"Read linker script">;
def shared : Flag<["-"], "shared">,
@@ -123,6 +125,7 @@ def alias_init_init : Joined<["-"], "init=">, Alias<init>;
def alias_l__library : Joined<["--"], "library=">, Alias<l>;
def alias_o_output : Joined<["--"], "output=">, Alias<o>;
def alias_rpath_rpath : Joined<["-"], "rpath=">, Alias<rpath>;
+def alias_relocatable_r : Flag<["-"], "r">, Alias<relocatable>;
def alias_shared_Bshareable : Flag<["-"], "Bshareable">, Alias<shared>;
def alias_soname_h : Separate<["-"], "h">, Alias<soname>;
def alias_soname_soname : Separate<["-"], "soname">, Alias<soname>;
diff --git a/lld/test/elf2/relocatable.s b/lld/test/elf2/relocatable.s
new file mode 100644
index 00000000000..1a2f8939433
--- /dev/null
+++ b/lld/test/elf2/relocatable.s
@@ -0,0 +1,9 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: not ld.lld2 -r %t -o %t2 2>&1 | FileCheck %s
+
+# CHECK: -r option is not supported. Use 'ar' command instead.
+
+.globl _start;
+_start:
OpenPOWER on IntegriCloud