[PATCH] D23925: [ELF] Default to entry address 0x0 in case start symbol is not defined and entry point is not specified in command line

Rafael Ávila de Espíndola via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 30 09:18:46 PDT 2016

rafael added a subscriber: rafael.

Comment at: ELF/Driver.cpp:552-557
@@ -551,6 +551,8 @@
   // Add entry symbol. Note that AMDGPU binaries have no entry points.
   if (Config->Entry.empty() && !Config->Shared && !Config->Relocatable &&
-      Config->EMachine != EM_AMDGPU)
+      Config->EMachine != EM_AMDGPU) {
     Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
+    Config->ForcedEntry = true;
+  }
evgeny777 wrote:
> ruiu wrote:
> > Can you move this after the code adding files to the symbol table? Once you add all files to the symbol table, you know whether _start is resolvable or not, so you can add an undefined symbol _start only when available. In that way, I think you can remove ForcedEntry variable.
> Unfortunately, I can't. The main problem is that in general _start symbol should exist in symtab, before adding files, otherwise LTO can optimize out everything. 
We don't check IsUsedInRegularObj for LTO until every file is read, so what causes it to decide that everything can be gced?



More information about the llvm-commits mailing list