mirror of
https://github.com/frida/tinycc
synced 2024-12-24 22:16:49 +03:00
__asm__() outside function
gcc/pcc allow __asm__() outside a function body: extern void vide(void); __asm__("vide: ret"); There is many such code in the Linux kernels.
This commit is contained in:
parent
09a78412f0
commit
6afe668ec7
10
tccasm.c
10
tccasm.c
@ -824,6 +824,16 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess)
|
||||
opcode = tok;
|
||||
next();
|
||||
if (tok == ':') {
|
||||
/* handle "extern void vide(void); __asm__("vide: ret");" as
|
||||
"__asm__("globl vide\nvide: ret");" */
|
||||
Sym *sym = sym_find(opcode);
|
||||
if (sym && (sym->type.t & VT_EXTERN) && nocode_wanted) {
|
||||
sym = label_find(opcode);
|
||||
if (!sym) {
|
||||
sym = label_push(&s1->asm_labels, opcode, 0);
|
||||
sym->type.t = VT_VOID;
|
||||
}
|
||||
}
|
||||
/* new label */
|
||||
asm_new_label(s1, opcode, 0);
|
||||
next();
|
||||
|
7
tests/tests2/85-asm-outside-function.c
Normal file
7
tests/tests2/85-asm-outside-function.c
Normal file
@ -0,0 +1,7 @@
|
||||
extern void vide(void);
|
||||
__asm__("vide: ret");
|
||||
|
||||
int main() {
|
||||
vide();
|
||||
return 0;
|
||||
}
|
0
tests/tests2/85-asm-outside-function.expect
Normal file
0
tests/tests2/85-asm-outside-function.expect
Normal file
Loading…
Reference in New Issue
Block a user