From 020b1a78d9704ad8deca5cd5d63b0fe37f3e4162 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 28 Apr 2024 11:41:31 +0900 Subject: [PATCH] Do not set the .text address as an entry adddress if -e is missing lld does not do that too. --- elf/output-chunks.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/elf/output-chunks.cc b/elf/output-chunks.cc index ca41632a..552642f3 100644 --- a/elf/output-chunks.cc +++ b/elf/output-chunks.cc @@ -40,12 +40,15 @@ static u64 get_entry_addr(Context &ctx) { if (ctx.arg.relocatable) return 0; - if (Symbol &sym = *ctx.arg.entry; - sym.file && !sym.file->is_dso) - return sym.get_addr(ctx); + if (Symbol *sym = ctx.arg.entry) { + if (sym->file && !sym->file->is_dso) + return sym->get_addr(ctx); + Warn(ctx) << "entry symbol is not defined: " << *sym; + return 0; + } - if (OutputSection *osec = find_section(ctx, ".text")) - return osec->shdr.sh_addr; + if (!ctx.arg.shared) + Warn(ctx) << "entry symbol was not specified"; return 0; }