From 5bd8aeb917ed326f50b1ed45669a1cf40aca75a3 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Fri, 26 Aug 2016 18:11:19 +0200 Subject: tccasm: Support refs to anon symbols from asm This happens when e.g. string constants (or other static data) are passed as operands to inline asm as immediates. The produced symbol ref wouldn't be found. So tighten the connection between C and asm-local symbol table even more. --- i386-asm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'i386-asm.c') diff --git a/i386-asm.c b/i386-asm.c index 473088b..336ef1b 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -1437,10 +1437,19 @@ ST_FUNC void subst_asm_operand(CString *add_str, modifier != 'P') cstr_ccat(add_str, '$'); if (r & VT_SYM) { - cstr_cat(add_str, get_tok_str(sv->sym->v, NULL), -1); + const char *name = get_tok_str(sv->sym->v, NULL); + if (sv->sym->v >= SYM_FIRST_ANOM) { + /* In case of anonymuous symbols ("L.42", used + for static data labels) we can't find them + in the C symbol table when later looking up + this name. So enter them now into the asm label + list when we still know the symbol. */ + get_asm_sym(tok_alloc(name, strlen(name))->tok, sv->sym); + } + cstr_cat(add_str, name, -1); if ((uint32_t)sv->c.i == 0) goto no_offset; - cstr_ccat(add_str, '+'); + cstr_ccat(add_str, '+'); } val = sv->c.i; if (modifier == 'n') -- cgit v1.3.1