diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-09-25 19:24:57 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-09-25 19:24:57 +0000 |
| commit | 551dfd8818ed9dfe737df82e98c5fd1f1af54e76 (patch) | |
| tree | c5aa45f7e3ffe7aa046efacf64e649c6d296f167 | |
| parent | 0e604f913ada479925e4f6106867b3c5d3646e32 (diff) | |
| download | bcm5719-llvm-551dfd8818ed9dfe737df82e98c5fd1f1af54e76.tar.gz bcm5719-llvm-551dfd8818ed9dfe737df82e98c5fd1f1af54e76.zip | |
Implement --noinhibit-exec.
Patch by George Rimar!
llvm-svn: 248605
| -rw-r--r-- | lld/ELF/Config.h | 1 | ||||
| -rw-r--r-- | lld/ELF/Driver.cpp | 3 | ||||
| -rw-r--r-- | lld/ELF/InputSection.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/Options.td | 4 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 9 | ||||
| -rw-r--r-- | lld/test/elf2/no-inhibit-exec.s | 15 |
6 files changed, 30 insertions, 3 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 5108a65fc82..b77a2f08671 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -24,6 +24,7 @@ struct Configuration { bool DiscardLocals = false; bool DiscardNone = false; bool ExportDynamic = false; + bool NoInhibitExec = false; }; extern Configuration *Config; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index deafb6a1b96..307bb08cb68 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -94,6 +94,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { if (Args.hasArg(OPT_export_dynamic)) Config->ExportDynamic = true; + if (Args.hasArg(OPT_noinhibit_exec)) + Config->NoInhibitExec = true; + // Create a list of input files. std::vector<MemoryBufferRef> Inputs; diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 237ca59dd82..4ad9bfc3865 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "InputSection.h" +#include "Config.h" #include "Error.h" #include "InputFiles.h" #include "OutputSections.h" diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td index 897fc157502..5baa58771ec 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -28,6 +28,10 @@ def discard_locals : Flag<["-"], "discard-locals">, def alias_discard_locals: Flag<["-"], "X">, Alias<discard_locals>; +def noinhibit_exec : Flag<["--"], "noinhibit-exec">, + HelpText<"Retain the executable output file whenever" + " it is still usable">; + def discard_none : Flag<["-"], "discard-none">, HelpText<"Keep all symbols in the symbol table">; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 61d72b2734b..464125b9b97 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -281,11 +281,14 @@ static void undefError(const SymbolTable &S, const SymbolBody &Sym) { if (&SymE > Syms.begin() && &SymE < Syms.end()) SymFile = F.get(); } + + std::string Message = "undefined symbol: " + Sym.getName().str(); if (SymFile) - error(Twine("undefined symbol: ") + Sym.getName() + " in " + - SymFile->getName()); + Message += " in " + SymFile->getName().str(); + if (Config->NoInhibitExec) + warning(Message); else - error(Twine("undefined symbol: ") + Sym.getName()); + error(Message); } // Create output section objects and add them to OutputSections. diff --git a/lld/test/elf2/no-inhibit-exec.s b/lld/test/elf2/no-inhibit-exec.s new file mode 100644 index 00000000000..272a8d8e3e5 --- /dev/null +++ b/lld/test/elf2/no-inhibit-exec.s @@ -0,0 +1,15 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: not lld -flavor gnu2 %t -o %t2 +# RUN: lld -flavor gnu2 %t --noinhibit-exec -o %t2 +# RUN: llvm-objdump -d %t2 | FileCheck %s +# REQUIRES: x86 + +# CHECK: Disassembly of section .text: +# CHECK-NEXT: _start +# CHECK-NEXT: 11000: e8 fb ef fe ff callq -69637 + +# next code will not link without noinhibit-exec flag +# because of undefined symbol _bar +.globl _start; +_start: + call _bar |

