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
883883 }
884884 }
885885 last_text_section = cur_text_section;
886− if (tok1 == TOK_ASMDIR_section)
886+ if (tok1 == TOK_ASMDIR_section) {
887887 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+ }
888892 else
889893 push_section(s1, sname);
890894 /* 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
893897 if (old_nb_section != s1->nb_sections)
894898 cur_text_section->sh_addralign = 1;
895899 }
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;
899900 break;
900901 case TOK_ASMDIR_previous:
901902 {
tccpp.c+0−14
@@ -1506,20 +1506,6 @@ static int expr_preprocess(TCCState *s1) · 1505 unmodified lines
15061506 tokc.i = c;
15071507 } else {
15081508 /* 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− }
15231509 tok = TOK_CINT;
15241510 tokc.i = 0;
15251511 }
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 @@
1+AAAAAAAAA
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+
13 /* Previously in TinyCC, ELF sections defined in attributes would always have
24 the execute bit not set, so you would get segmentation faults when code in these
35 sections 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
911 }
1012
1113 int main () {
12− return wumbo(2);
14+ wumbo(2);
15+ puts("hi");
16+ return 0;
1317 }
tests/tests2/134_exec_section_in_c.expect+1−0
@@ -0,0 +1 @@
1+hi
tests/undef_func_macro.c+0−13
@@ -1,13 +0,0 @@
1−int 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