[lld] r248806 - [ELF2] Implemented --entry flag.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 09:40:14 PDT 2015
Author: ruiu
Date: Tue Sep 29 11:40:13 2015
New Revision: 248806
URL: http://llvm.org/viewvc/llvm-project?rev=248806&view=rev
Log:
[ELF2] Implemented --entry flag.
Patch from George Rimar!
Added:
lld/trunk/test/elf2/entry.s
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
lld/trunk/ELF/SymbolTable.cpp
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=248806&r1=248805&r2=248806&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Tue Sep 29 11:40:13 2015
@@ -30,6 +30,7 @@ struct Configuration {
bool ExportDynamic = false;
bool NoInhibitExec = false;
bool AllowMultipleDefinition = false;
+ llvm::StringRef Entry;
};
extern Configuration *Config;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=248806&r1=248805&r2=248806&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Sep 29 11:40:13 2015
@@ -142,6 +142,9 @@ void LinkerDriver::link(ArrayRef<const c
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;
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=248806&r1=248805&r2=248806&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Tue Sep 29 11:40:13 2015
@@ -55,3 +55,9 @@ def alias_l : Joined<["--"], "library=">
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>;
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=248806&r1=248805&r2=248806&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Sep 29 11:40:13 2015
@@ -74,8 +74,9 @@ template <class ELFT> void SymbolTable::
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
Added: lld/trunk/test/elf2/entry.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/entry.s?rev=248806&view=auto
==============================================================================
--- lld/trunk/test/elf2/entry.s (added)
+++ lld/trunk/test/elf2/entry.s Tue Sep 29 11:40:13 2015
@@ -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:
More information about the llvm-commits
mailing list