1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-09 16:05:58 +03:00

Do not set the .text address as an entry adddress if -e is missing

lld does not do that too.
This commit is contained in:
Rui Ueyama 2024-04-28 11:41:31 +09:00
parent 6b70e02bf5
commit 020b1a78d9

View File

@ -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;
}