History

tccasm.c: Make .init and .fini sections executable

GAS selects default attributes for a section based on its name and makes the sections .text, .init, .fini executable. The crti.s and crtn.s files of musl rely on these defaults and don't set the "x" flag for the .init and .fini sections. Unfortunately TCC does not care for .init and .fini section defaults in assembler or C code. Fix this for assembler code.

Stefan committed 1 year ago

Commit ba0899d1 parent 2f887641 file · +4 −0Browse files

Unified · Split

tccasm.c+4−0
@@ -907,6 +907,10 @@ static void asm_parse_directive(TCCState *s1, int global) · 906 unmodified lines
907 sets alignment to PTR_SIZE. The assembler behaves different. */907 sets alignment to PTR_SIZE. The assembler behaves different. */
908 if (old_nb_section != s1->nb_sections) {908 if (old_nb_section != s1->nb_sections) {
909 cur_text_section->sh_addralign = 1;909 cur_text_section->sh_addralign = 1;
910 /* Make .init and .fini sections executable by default.
911 GAS does so, too, and musl relies on it. */
912 if (!strcmp(sname, ".init") || !strcmp(sname, ".fini"))
913 flags |= SHF_EXECINSTR;
910 cur_text_section->sh_flags = flags;914 cur_text_section->sh_flags = flags;
911 }915 }
912 }916 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t