Skip to content

Commit

Permalink
fix: previous two commits
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWilbur committed Jul 31, 2024
1 parent e4d874d commit f15008d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 32 deletions.
9 changes: 5 additions & 4 deletions tccasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,12 @@ static void asm_parse_directive(TCCState *s1, int global)
}
}
last_text_section = cur_text_section;
if (tok1 == TOK_ASMDIR_section)
if (tok1 == TOK_ASMDIR_section) {
use_section(s1, sname);
/* The section directive supports flags, but they are unsupported.
For now, just assume any section contains code. */
cur_text_section->sh_flags |= SHF_EXECINSTR;
}
else
push_section(s1, sname);
/* If we just allocated a new section reset its alignment to
Expand All @@ -893,9 +897,6 @@ static void asm_parse_directive(TCCState *s1, int global)
if (old_nb_section != s1->nb_sections)
cur_text_section->sh_addralign = 1;
}
/* The section directive supports flags, but they are unsupported.
For now, just assume any section contains code. */
cur_text_section->sh_flags |= SHF_EXECINSTR;
break;
case TOK_ASMDIR_previous:
{
Expand Down
14 changes: 0 additions & 14 deletions tccpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,20 +1506,6 @@ static int expr_preprocess(TCCState *s1)
tokc.i = c;
} else {
/* if undefined macro, replace with zero */
next_nomacro();
// If the undefined macro is followed by parens, just skip them.
if (tok == '(') {
int bracket_depth = 1;
while (bracket_depth > 0) {
next();
if (tok == '(')
bracket_depth++;
else if (tok == ')')
bracket_depth--;
}
} else {
unget_tok(tok); // Is this actually the function I want?
}
tok = TOK_CINT;
tokc.i = 0;
}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions tests/tests2/133_exec_section_in_asm.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AAAAAAAAA
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <stdio.h>

/* Previously in TinyCC, ELF sections defined in attributes would always have
the execute bit not set, so you would get segmentation faults when code in these
sections was exectuted. This file is a minimal example of a file that will put
Expand All @@ -9,5 +11,7 @@ int wumbo (int arg) {
}

int main () {
return wumbo(2);
wumbo(2);
puts("hi");
return 0;
}
1 change: 1 addition & 0 deletions tests/tests2/134_exec_section_in_c.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hi
13 changes: 0 additions & 13 deletions tests/undef_func_macro.c

This file was deleted.

0 comments on commit f15008d

Please sign in to comment.