Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -665,12 +665,13 @@ // 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 " or "-e ". 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"; @@ -678,7 +679,7 @@ 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"); } 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