Alien-TinyCC
view release on metacpan or search on metacpan
src/tccgen.c view on Meta::CPAN
else
ps = &ts->sym_identifier;
*ps = s->prev_tok;
}
sym_free(s);
s = ss;
}
*ptop = b;
}
static void weaken_symbol(Sym *sym)
{
sym->type.t |= VT_WEAK;
if (sym->c > 0) {
int esym_type;
ElfW(Sym) *esym;
esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
esym_type = ELFW(ST_TYPE)(esym->st_info);
esym->st_info = ELFW(ST_INFO)(STB_WEAK, esym_type);
}
src/tccgen.c view on Meta::CPAN
CValue cval;
/* push global reference */
sym = get_sym_ref(type, sec, addr, size);
cval.ul = 0;
vsetc(type, VT_CONST | VT_SYM, &cval);
vtop->sym = sym;
}
/* patch symbol weakness */
if (type->t & VT_WEAK)
weaken_symbol(sym);
#ifdef CONFIG_TCC_BCHECK
/* handles bounds now because the symbol must be defined
before for the relocation */
if (tcc_state->do_bounds_check) {
unsigned long *bounds_ptr;
greloc(bounds_section, sym, bounds_section->data_offset, R_DATA_PTR);
/* then add global bound info */
bounds_ptr = section_ptr_add(bounds_section, 2 * sizeof(long));
bounds_ptr[0] = 0; /* relocated */
src/tccgen.c view on Meta::CPAN
label_pop(&global_label_stack, NULL);
/* reset local stack */
scope_stack_bottom = NULL;
sym_pop(&local_stack, NULL);
/* end of function */
/* patch symbol size */
((ElfW(Sym) *)symtab_section->data)[sym->c].st_size =
ind - func_ind;
/* patch symbol weakness (this definition overrules any prototype) */
if (sym->type.t & VT_WEAK)
weaken_symbol(sym);
if (tcc_state->do_debug) {
put_stabn(N_FUN, 0, 0, ind - func_ind);
}
/* It's better to crash than to generate wrong code */
cur_text_section = NULL;
funcname = ""; /* for safety */
func_vt.t = VT_VOID; /* for safety */
ind = 0; /* for safety */
nocode_wanted = saved_nocode_wanted;
}
src/tccgen.c view on Meta::CPAN
if ((btype.t & VT_EXTERN) || ((type.t & VT_BTYPE) == VT_FUNC) ||
((type.t & VT_ARRAY) && (type.t & VT_STATIC) &&
!has_init && l == VT_CONST && type.ref->c < 0)) {
/* external variable or function */
/* NOTE: as GCC, uninitialized global static
arrays of null size are considered as
extern */
sym = external_sym(v, &type, r, asm_label);
if (type.t & VT_WEAK)
weaken_symbol(sym);
if (ad.alias_target) {
Section tsec;
Elf32_Sym *esym;
Sym *alias_target;
alias_target = sym_find(ad.alias_target);
if (!alias_target || !alias_target->c)
tcc_error("unsupported forward __alias__ attribute");
esym = &((Elf32_Sym *)symtab_section->data)[alias_target->c];
( run in 0.303 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )