From 2acb04f7f2077a4cff103421d79ceee48441918a Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 10 Jul 2017 22:29:28 +0200 Subject: tccasm: Fix local statics referenced from asms The assembler uses the ->sym_scope member to walk up the symbols until finding a non-automatic symbol. Since reordering the members of Sym the sym_scope member contains a scope even for local statics. Formerly the use of asm_label for statics was implicitely clearing sym_scope, now we have to do that explicitely. Add a testcase for that, and one I encountered when moving the clearing of sym_scope too deep into the call chain (into put_extern_sym). --- tccgen.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index f733598..19909f9 100644 --- a/tccgen.c +++ b/tccgen.c @@ -6861,6 +6861,9 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, sym = sym_push(v, type, r | VT_SYM, 0); patch_storage(sym, ad, NULL); } + /* Local statics have a scope until now (for + warnings), remove it here. */ + sym->sym_scope = 0; /* update symbol definition */ put_extern_sym(sym, sec, addr, size); } else { @@ -7257,6 +7260,9 @@ found: tcc_error("unsupported forward __alias__ attribute"); esym = &((ElfW(Sym) *)symtab_section->data)[alias_target->c]; tsec.sh_num = esym->st_shndx; + /* Local statics have a scope until now (for + warnings), remove it here. */ + sym->sym_scope = 0; put_extern_sym2(sym, &tsec, esym->st_value, esym->st_size, 0); } } else { -- cgit v1.3.1