Skip to content

Commit

Permalink
Do not set the .text address as an entry adddress if -e is missing
Browse files Browse the repository at this point in the history
lld does not do that too.
  • Loading branch information
rui314 committed Apr 28, 2024
1 parent 6b70e02 commit 020b1a7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions elf/output-chunks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ static u64 get_entry_addr(Context<E> &ctx) {
if (ctx.arg.relocatable)
return 0;

if (Symbol<E> &sym = *ctx.arg.entry;
sym.file && !sym.file->is_dso)
return sym.get_addr(ctx);
if (Symbol<E> *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<E> *osec = find_section(ctx, ".text"))
return osec->shdr.sh_addr;
if (!ctx.arg.shared)
Warn(ctx) << "entry symbol was not specified";
return 0;
}

Expand Down

0 comments on commit 020b1a7

Please sign in to comment.