ELF2: Print an error message for --relocatable.

llvm-svn: 252923
This commit is contained in:
Rui Ueyama 2015-11-12 18:54:15 +00:00
parent b8da794ca1
commit f5bcf2a72f
3 changed files with 18 additions and 0 deletions

View File

@ -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);

View File

@ -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>;

View File

@ -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: