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

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


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

Updated patch to match latest revision.


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
@@ -74,8 +74,9 @@
   Target.reset(createTarget(EMachine));
   if (Config->Shared)
     return;
-  EntrySym = new (Alloc)
-      Undefined<ELFT>(Target->getDefaultEntry(), Undefined<ELFT>::Synthetic);
+  EntrySym = new (Alloc) Undefined<ELFT>(
+      Config->Entry.empty() ? Target->getDefaultEntry() : 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
@@ -55,3 +55,9 @@
 
 def sysroot : Joined<["--"], "sysroot=">,
      HelpText<"Set the system root">;
+
+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
@@ -142,6 +142,9 @@
   if (Args.hasArg(OPT_allow_multiple_definition))
     Config->AllowMultipleDefinition = 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
@@ -30,6 +30,7 @@
   bool ExportDynamic = false;
   bool NoInhibitExec = false;
   bool AllowMultipleDefinition = false;
+  llvm::StringRef Entry;
 };
 
 extern Configuration *Config;


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


More information about the llvm-commits mailing list