mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-24 03:40:09 +08:00
fix: previous two commits
This commit is contained in:
parent
e4d874d88a
commit
f15008da05
9
tccasm.c
9
tccasm.c
@ -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
|
||||
@ -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:
|
||||
{
|
||||
|
14
tccpp.c
14
tccpp.c
@ -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;
|
||||
}
|
||||
|
1
tests/tests2/133_exec_section_in_asm.expect
Normal file
1
tests/tests2/133_exec_section_in_asm.expect
Normal file
@ -0,0 +1 @@
|
||||
AAAAAAAAA
|
@ -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
|
||||
@ -9,5 +11,7 @@ int wumbo (int arg) {
|
||||
}
|
||||
|
||||
int main () {
|
||||
return wumbo(2);
|
||||
wumbo(2);
|
||||
puts("hi");
|
||||
return 0;
|
||||
}
|
1
tests/tests2/134_exec_section_in_c.expect
Normal file
1
tests/tests2/134_exec_section_in_c.expect
Normal file
@ -0,0 +1 @@
|
||||
hi
|
@ -1,13 +0,0 @@
|
||||
int main () {
|
||||
// This used to evaluate to 0 (0), which is invalid.
|
||||
// Now it should evaluate to 0.
|
||||
#if WUMBOED(WUMBO)
|
||||
#endif
|
||||
|
||||
// Just trying a more complicated test case.
|
||||
#if WUMBO && defined(WUMBOLOGY) || WUMBOED(WUMBO) && !WUMBOLOGY
|
||||
return 0;
|
||||
#elif WUMBO && defined(WUMBOLOGY) || WUMBOED(WUMBO) && !WUMBOLOGY
|
||||
return 1;
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user