Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -649,7 +649,8 @@ if (ScriptConfig->HasSections) return; - ElfSym::EhdrStart = Symtab::X->addIgnored("__ehdr_start"); + if (!Config->Relocatable) + ElfSym::EhdrStart = Symtab::X->addIgnored("__ehdr_start"); auto Define = [this](StringRef S, DefinedRegular *&Sym1, DefinedRegular *&Sym2) { Index: test/ELF/ehdr_start.s =================================================================== --- test/ELF/ehdr_start.s +++ test/ELF/ehdr_start.s @@ -9,3 +9,8 @@ .global _start, __ehdr_start _start: .quad __ehdr_start + +# RUN: ld.lld -r %t.o -o %t.r +# RUN: llvm-objdump -t %t.r | FileCheck %s --check-prefix=RELOCATABLE + +# RELOCATABLE: 0000000000000000 *UND* 00000000 __ehdr_start