diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -2833,8 +2833,7 @@ // 2. the ENTRY(symbol) command in a linker control script; // 3. the value of the symbol _start, if present; // 4. the number represented by the entry symbol, if it is a number; -// 5. the address of the first byte of the .text section, if present; -// 6. the address 0. +// 5. the address 0. static uint64_t getEntryAddr() { // Case 1, 2 or 3 if (Symbol *b = symtab->find(config->entry)) @@ -2846,14 +2845,6 @@ return addr; // Case 5 - if (OutputSection *sec = findSection(".text")) { - if (config->warnMissingEntry) - warn("cannot find entry symbol " + config->entry + "; defaulting to 0x" + - utohexstr(sec->addr)); - return sec->addr; - } - - // Case 6 if (config->warnMissingEntry) warn("cannot find entry symbol " + config->entry + "; not setting start address"); diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst --- a/lld/docs/ReleaseNotes.rst +++ b/lld/docs/ReleaseNotes.rst @@ -26,6 +26,9 @@ * ``--export-dynamic-symbol-list`` has been added. (`D107317 `_) +* ``e_entry`` no longer falls back to the address of ``.text`` if the entry symbol does not exist. + Instead, a value of 0 will be written. + (`D110014 `_) Breaking changes ---------------- diff --git a/lld/test/ELF/basic-ppc.s b/lld/test/ELF/basic-ppc.s --- a/lld/test/ELF/basic-ppc.s +++ b/lld/test/ELF/basic-ppc.s @@ -26,7 +26,7 @@ // CHECK-NEXT: Type: Executable (0x2) // CHECK-NEXT: Machine: EM_PPC (0x14) // CHECK-NEXT: Version: 1 -// CHECK-NEXT: Entry: 0x100100B4 +// CHECK-NEXT: Entry: 0x0 // CHECK-NEXT: ProgramHeaderOffset: 0x34 // CHECK-NEXT: SectionHeaderOffset: 0x104 // CHECK-NEXT: Flags [ (0x0) diff --git a/lld/test/ELF/basic-ppc64.s b/lld/test/ELF/basic-ppc64.s --- a/lld/test/ELF/basic-ppc64.s +++ b/lld/test/ELF/basic-ppc64.s @@ -33,7 +33,7 @@ // CHECK-NEXT: Type: SharedObject (0x3) // CHECK-NEXT: Machine: EM_PPC64 (0x15) // CHECK-NEXT: Version: 1 -// CHECK-NEXT: Entry: 0x1022C +// CHECK-NEXT: Entry: 0x0 // CHECK-NEXT: ProgramHeaderOffset: 0x40 // CHECK-NEXT: SectionHeaderOffset: 0x330 // CHECK-NEXT: Flags [ (0x2) diff --git a/lld/test/ELF/entry.s b/lld/test/ELF/entry.s --- a/lld/test/ELF/entry.s +++ b/lld/test/ELF/entry.s @@ -2,16 +2,17 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1 # RUN: ld.lld -e foobar %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN1 %s -# RUN: llvm-readobj --file-headers %t2 | FileCheck -check-prefix=TEXT %s +# RUN: llvm-readobj --file-headers %t2 | FileCheck -check-prefix=NOENTRY %s -# WARN1: warning: cannot find entry symbol foobar; defaulting to 0x201120 -# TEXT: Entry: 0x201120 +# WARN1: warning: cannot find entry symbol foobar; not setting start address # RUN: ld.lld %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN2 %s -# WARN2: warning: cannot find entry symbol _start; defaulting to 0x201120 +# RUN: llvm-readobj --file-headers %t2 | FileCheck -check-prefix=NOENTRY %s +# WARN2: warning: cannot find entry symbol _start; not setting start address # RUN: ld.lld -shared -e foobar %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN3 %s -# WARN3: warning: cannot find entry symbol foobar; defaulting to 0x1238 +# RUN: llvm-readobj --file-headers %t2 | FileCheck -check-prefix=NOENTRY %s +# WARN3: warning: cannot find entry symbol foobar; not setting start address # RUN: ld.lld -shared --fatal-warnings -e entry %t1 -o %t2 # RUN: ld.lld -shared --fatal-warnings %t1 -o %t2