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
This commit is contained in:
Michael Matz 2020-06-21 01:45:35 +02:00
parent 18db8da7df
commit c883d43ae5
3 changed files with 5 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);