[PATCH] D24899: [ELF] Don't warn about missing start symbol in relocatable and shared files

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 24 19:34:05 PDT 2016


phosek created this revision.
phosek added a reviewer: ruiu.
phosek added subscribers: llvm-commits, phosek.
phosek added a project: lld.

Previously LLD would print a warning for missing entry symbol in relocatable and shared output files, which is incorrect as these normally don't have an entry symbol.

https://reviews.llvm.org/D24899

Files:
  ELF/Driver.cpp
  test/ELF/driver.test

Index: test/ELF/driver.test
===================================================================
--- test/ELF/driver.test
+++ test/ELF/driver.test
@@ -52,6 +52,10 @@
 # RUN: not ld.lld %t -output=/no/such/file 2>&1 | FileCheck -check-prefix=ERR8 %s
 # ERR8: failed to open utput=/no/such/file
 
+## Do not report warning about missing entry symbol for -r
+# RUN: ld.lld -r %t -o %tsuccess 2>&1 | FileCheck -allow-empty -check-prefix=ERR9 %s
+# ERR9-NOT: entry symbol not found, assuming 0
+
 .globl _start
 _start:
   nop
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -665,20 +665,21 @@
   // Add the start symbol.
   // It initializes either Config->Entry or Config->EntryAddr.
   // Note that AMDGPU binaries have no entries.
+  const bool HasEntry =
+    !Config->Shared && !Config->Relocatable && Config->EMachine != EM_AMDGPU;
   bool HasEntryAddr = false;
   if (!Config->Entry.empty()) {
     // It is either "-e <addr>" or "-e <symbol>".
     HasEntryAddr = !Config->Entry.getAsInteger(0, Config->EntryAddr);
-  } else if (!Config->Shared && !Config->Relocatable &&
-             Config->EMachine != EM_AMDGPU) {
+  } else if (HasEntry) {
     // -e was not specified. Use the default start symbol name
     // if it is resolvable.
     Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
   }
   if (!HasEntryAddr) {
     if (Symtab.find(Config->Entry))
       Config->EntrySym = Symtab.addUndefined(Config->Entry);
-    else
+    else if (HasEntry)
       warning("entry symbol " + Config->Entry + " not found, assuming 0");
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24899.72408.patch
Type: text/x-patch
Size: 1644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160925/38d98bf4/attachment.bin>


More information about the llvm-commits mailing list