[lld] r252923 - ELF2: Print an error message for --relocatable.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 12 10:54:15 PST 2015


Author: ruiu
Date: Thu Nov 12 12:54:15 2015
New Revision: 252923

URL: http://llvm.org/viewvc/llvm-project?rev=252923&view=rev
Log:
ELF2: Print an error message for --relocatable.

Added:
    lld/trunk/test/elf2/relocatable.s
Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Options.td

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=252923&r1=252922&r2=252923&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Nov 12 12:54:15 2015
@@ -100,6 +100,12 @@ void LinkerDriver::main(ArrayRef<const c
   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);

Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=252923&r1=252922&r2=252923&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Thu Nov 12 12:54:15 2015
@@ -82,6 +82,8 @@ def o : Separate<["-"], "o">, MetaVarNam
 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<["-"], "ini
 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>;

Added: lld/trunk/test/elf2/relocatable.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocatable.s?rev=252923&view=auto
==============================================================================
--- lld/trunk/test/elf2/relocatable.s (added)
+++ lld/trunk/test/elf2/relocatable.s Thu Nov 12 12:54:15 2015
@@ -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:




More information about the llvm-commits mailing list