[PATCH] D13212: [ELF2] - Implemented -e flag

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 07:59:09 PDT 2015


grimar updated this revision to Diff 35978.
grimar added a comment.

Review comments addressed.


http://reviews.llvm.org/D13212

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Options.td
  ELF/SymbolTable.cpp
  test/elf2/entry.s

Index: test/elf2/entry.s
===================================================================
--- test/elf2/entry.s
+++ test/elf2/entry.s
@@ -0,0 +1,6 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
+# RUN: not lld -flavor gnu2 %t1 -o %t2
+# RUN: lld -flavor gnu2 %t1 -o %t2 -e _end
+
+.globl _end;
+_end: 
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -72,7 +72,7 @@
   Target.reset(createTarget(EMachine));
   if (Config->Shared)
     return;
-  EntrySym = new (Alloc) Undefined<ELFT>("_start", Undefined<ELFT>::Synthetic);
+  EntrySym = new (Alloc) Undefined<ELFT>(Config->Entry, Undefined<ELFT>::Synthetic);
   resolve<ELFT>(EntrySym);
 
   // In the assembly for 32 bit x86 the _GLOBAL_OFFSET_TABLE_ symbol is magical
Index: ELF/Options.td
===================================================================
--- ELF/Options.td
+++ ELF/Options.td
@@ -37,3 +37,9 @@
 
 def export_dynamic : Flag<["--"], "export-dynamic">,
      HelpText<"Put symbols in the dynamic symbol table">;
+
+def entry : Separate<["--", "-"], "entry">, MetaVarName<"<entry>">,
+     HelpText<"Name of entry point symbol">;
+
+def alias_entry : Separate<["-"], "e">,
+     Alias<entry>;
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -97,6 +97,9 @@
   if (Args.hasArg(OPT_noinhibit_exec))
     Config->NoInhibitExec = true;
 
+  if (auto *Arg = Args.getLastArg(OPT_entry))
+    Config->Entry = Arg->getValue();
+
   // Create a list of input files.
   std::vector<MemoryBufferRef> Inputs;
 
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -25,6 +25,7 @@
   bool DiscardNone = false;
   bool ExportDynamic = false;
   bool NoInhibitExec = false;
+  llvm::StringRef Entry = "_start";
 };
 
 extern Configuration *Config;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13212.35978.patch
Type: text/x-patch
Size: 1980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150929/1e154ed5/attachment.bin>


More information about the llvm-commits mailing list