diff --git a/tccasm.c b/tccasm.c index f31eab5a..b6fc34e5 100644 --- a/tccasm.c +++ b/tccasm.c @@ -907,6 +907,10 @@ static void asm_parse_directive(TCCState *s1, int global) sets alignment to PTR_SIZE. The assembler behaves different. */ if (old_nb_section != s1->nb_sections) { cur_text_section->sh_addralign = 1; + /* Make .init and .fini sections executable by default. + GAS does so, too, and musl relies on it. */ + if (!strcmp(sname, ".init") || !strcmp(sname, ".fini")) + flags |= SHF_EXECINSTR; cur_text_section->sh_flags = flags; } }