From c883d43ae52124410c801e226361c02561e8173d Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sun, 21 Jun 2020 01:45:35 +0200 Subject: [PATCH] fixes for deadlocks and dollars in asm * tccelf code doesn't use USING_GLOBALS, hence must be called from outside the semaphore * dollars aren't part of identifiers in asm mode --- libtcc.c | 4 ++-- tccasm.c | 2 ++ tccpp.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libtcc.c b/libtcc.c index 7c485b9b..78e2c93b 100644 --- a/libtcc.c +++ b/libtcc.c @@ -740,9 +740,9 @@ static int tcc_compile(TCCState *s1, int filetype, const char *str, int fd) s1->error_set_jmp_enabled = 0; tccgen_finish(s1); preprocess_end(s1); - tccelf_end_file(s1); - tcc_exit_state(); + + tccelf_end_file(s1); return s1->nb_errors != 0 ? -1 : 0; } diff --git a/tccasm.c b/tccasm.c index 93ae95b3..ec665937 100644 --- a/tccasm.c +++ b/tccasm.c @@ -1020,6 +1020,7 @@ static void tcc_assemble_inline(TCCState *s1, char *str, int len, int global) { const int *saved_macro_ptr = macro_ptr; int dotid = set_idnum('.', IS_ID); + int dolid = set_idnum('$', 0); tcc_open_bf(s1, ":asm:", len); memcpy(file->buffer, str, len); @@ -1027,6 +1028,7 @@ static void tcc_assemble_inline(TCCState *s1, char *str, int len, int global) tcc_assemble_internal(s1, 0, global); tcc_close(); + set_idnum('$', dolid); set_idnum('.', dotid); macro_ptr = saved_macro_ptr; } diff --git a/tccpp.c b/tccpp.c index f8b060bf..bc031c43 100644 --- a/tccpp.c +++ b/tccpp.c @@ -3691,7 +3691,7 @@ ST_FUNC void preprocess_start(TCCState *s1, int is_asm) s1->pack_stack[0] = 0; s1->pack_stack_ptr = s1->pack_stack; - set_idnum('$', s1->dollars_in_identifiers ? IS_ID : 0); + set_idnum('$', !is_asm && s1->dollars_in_identifiers ? IS_ID : 0); set_idnum('.', is_asm ? IS_ID : 0); cstr_new(&cstr);