[lld] r248605 - Implement --noinhibit-exec.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 12:24:57 PDT 2015


Author: rafael
Date: Fri Sep 25 14:24:57 2015
New Revision: 248605

URL: http://llvm.org/viewvc/llvm-project?rev=248605&view=rev
Log:
Implement --noinhibit-exec.

Patch by George Rimar!

Added:
    lld/trunk/test/elf2/no-inhibit-exec.s
Modified:
    lld/trunk/ELF/Config.h
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/Options.td
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=248605&r1=248604&r2=248605&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Sep 25 14:24:57 2015
@@ -24,6 +24,7 @@ struct Configuration {
   bool DiscardLocals = false;
   bool DiscardNone = false;
   bool ExportDynamic = false;
+  bool NoInhibitExec = false;
 };
 
 extern Configuration *Config;

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=248605&r1=248604&r2=248605&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Sep 25 14:24:57 2015
@@ -94,6 +94,9 @@ void LinkerDriver::link(ArrayRef<const c
   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;
 

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=248605&r1=248604&r2=248605&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Fri Sep 25 14:24:57 2015
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "InputSection.h"
+#include "Config.h"
 #include "Error.h"
 #include "InputFiles.h"
 #include "OutputSections.h"

Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=248605&r1=248604&r2=248605&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Fri Sep 25 14:24:57 2015
@@ -28,6 +28,10 @@ def discard_locals : Flag<["-"], "discar
 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">;
 

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=248605&r1=248604&r2=248605&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Sep 25 14:24:57 2015
@@ -281,11 +281,14 @@ static void undefError(const SymbolTable
     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.

Added: lld/trunk/test/elf2/no-inhibit-exec.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/no-inhibit-exec.s?rev=248605&view=auto
==============================================================================
--- lld/trunk/test/elf2/no-inhibit-exec.s (added)
+++ lld/trunk/test/elf2/no-inhibit-exec.s Fri Sep 25 14:24:57 2015
@@ -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




More information about the llvm-commits mailing list