aboutsummaryrefslogtreecommitdiff
path: root/i386-asm.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-08-26 18:11:19 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:11 +0100
commit5bd8aeb917ed326f50b1ed45669a1cf40aca75a3 (patch)
treeeeaf074e00e4944e42a9cc80e8fd5a875e821237 /i386-asm.c
parentdd57a348664d0fac46a0f4c822f70c80bbf97774 (diff)
downloadtinycc-5bd8aeb917ed326f50b1ed45669a1cf40aca75a3.tar.gz
tinycc-5bd8aeb917ed326f50b1ed45669a1cf40aca75a3.tar.bz2
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.
Diffstat (limited to 'i386-asm.c')
-rw-r--r--i386-asm.c13
1 files changed, 11 insertions, 2 deletions
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')