History

fix: previous two commits

Jonathan M. Wilbur committed 2 years ago

Commit f15008d1 parent e4d874d7 files · +12 −32Browse files

Unified · Split

7 files
  1. tccasm.c +5 −4
  2. tccpp.c +0 −14
  3. tests/tests2/133_exec_section_in_asm.c +0 −0
  4. tests/tests2/133_exec_section_in_asm.expect +1 −0
  5. tests/tests2/134_exec_section_in_c.c +5 −1
  6. tests/tests2/134_exec_section_in_c.expect +1 −0
  7. tests/undef_func_macro.c +0 −13
tccasm.c+5−4
@@ -883,8 +883,12 @@ static void asm_parse_directive(TCCState *s1, int global) · 882 unmodified lines
883 }883 }
884 }884 }
885 last_text_section = cur_text_section;885 last_text_section = cur_text_section;
886 if (tok1 == TOK_ASMDIR_section)886 if (tok1 == TOK_ASMDIR_section) {
887 use_section(s1, sname);887 use_section(s1, sname);
888 /* The section directive supports flags, but they are unsupported.
889 For now, just assume any section contains code. */
890 cur_text_section->sh_flags |= SHF_EXECINSTR;
891 }
888 else892 else
889 push_section(s1, sname);893 push_section(s1, sname);
890 /* If we just allocated a new section reset its alignment to894 /* If we just allocated a new section reset its alignment to
@@ -893,9 +897,6 @@ static void asm_parse_directive(TCCState *s1, int global) · 2 unmodified lines
893 if (old_nb_section != s1->nb_sections)897 if (old_nb_section != s1->nb_sections)
894 cur_text_section->sh_addralign = 1;898 cur_text_section->sh_addralign = 1;
895 }899 }
896 /* The section directive supports flags, but they are unsupported.
897 For now, just assume any section contains code. */
898 cur_text_section->sh_flags |= SHF_EXECINSTR;
899 break;900 break;
900 case TOK_ASMDIR_previous:901 case TOK_ASMDIR_previous:
901 { 902 {
tccpp.c+0−14
@@ -1506,20 +1506,6 @@ static int expr_preprocess(TCCState *s1) · 1505 unmodified lines
1506 tokc.i = c;1506 tokc.i = c;
1507 } else {1507 } else {
1508 /* if undefined macro, replace with zero */1508 /* if undefined macro, replace with zero */
1509 next_nomacro();
1510 // If the undefined macro is followed by parens, just skip them.
1511 if (tok == '(') {
1512 int bracket_depth = 1;
1513 while (bracket_depth > 0) {
1514 next();
1515 if (tok == '(')
1516 bracket_depth++;
1517 else if (tok == ')')
1518 bracket_depth--;
1519 }
1520 } else {
1521 unget_tok(tok); // Is this actually the function I want?
1522 }
1523 tok = TOK_CINT;1509 tok = TOK_CINT;
1524 tokc.i = 0;1510 tokc.i = 0;
1525 }1511 }
tests/tests2/133_exec_section_in_asm.crenamed from tests/exec_section_in_asm.c+0−0

File renamed without changes.

tests/tests2/133_exec_section_in_asm.expect+1−0
@@ -0,0 +1 @@
1AAAAAAAAA
tests/tests2/134_exec_section_in_c.crenamed from tests/exec_section_in_c.c+5−1
@@ -1,3 +1,5 @@
1#include <stdio.h>
2
1/* Previously in TinyCC, ELF sections defined in attributes would always have3/* Previously in TinyCC, ELF sections defined in attributes would always have
2the execute bit not set, so you would get segmentation faults when code in these4the execute bit not set, so you would get segmentation faults when code in these
3sections was exectuted. This file is a minimal example of a file that will put5sections was exectuted. This file is a minimal example of a file that will put
@@ -9,5 +11,7 @@ int wumbo (int arg) { · 5 unmodified lines
9}11}
10 12
11int main () {13int main () {
12 return wumbo(2);14 wumbo(2);
15 puts("hi");
16 return 0;
13}17}
tests/tests2/134_exec_section_in_c.expect+1−0
@@ -0,0 +1 @@
1hi
tests/undef_func_macro.c+0−13
@@ -1,13 +0,0 @@
1int main () {
2// This used to evaluate to 0 (0), which is invalid.
3// Now it should evaluate to 0.
4#if WUMBOED(WUMBO)
5#endif
6
7// Just trying a more complicated test case.
8#if WUMBO && defined(WUMBOLOGY) || WUMBOED(WUMBO) && !WUMBOLOGY
9 return 0;
10#elif WUMBO && defined(WUMBOLOGY) || WUMBOED(WUMBO) && !WUMBOLOGY
11 return 1;
12#endif
13}

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