コード例 #1
0
const elf_machine_handler *
elf_set_arch(yasm_arch *arch, yasm_symtab *symtab, int bits_pref)
{
    const char *machine = yasm_arch_get_machine(arch);
    int i;

    for (i=0, elf_march = elf_machine_handlers[0];
         elf_march != NULL;
         elf_march = elf_machine_handlers[++i])
    {
        if (yasm__strcasecmp(yasm_arch_keyword(arch), elf_march->arch)==0)
            if (yasm__strcasecmp(machine, elf_march->machine)==0)
                if (bits_pref == 0 || bits_pref == elf_march->bits)
                    break;
    }

    if (elf_march && elf_march->num_ssyms > 0)
    {
        /* Allocate "special" syms */
        elf_ssyms =
            yasm_xmalloc(elf_march->num_ssyms * sizeof(yasm_symrec *));
        for (i=0; (unsigned int)i<elf_march->num_ssyms; i++)
        {
            /* FIXME: misuse of NULL bytecode */
            elf_ssyms[i] = yasm_symtab_define_label(symtab,
                                                    elf_march->ssyms[i].name,
                                                    NULL, 0, 0);
            yasm_symrec_add_data(elf_ssyms[i], &elf_ssym_symrec_data,
                                 (void*)&elf_march->ssyms[i]);
        }
    }

    return elf_march;
}
コード例 #2
0
static elf_symtab_entry *
elf_objfmt_symtab_append(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym,
                         elf_section_index sectidx, elf_symbol_binding bind,
                         elf_symbol_type type, elf_symbol_vis vis,
                         yasm_expr *size, elf_address *value,
                         yasm_object *object)
{
    elf_symtab_entry *entry = yasm_symrec_get_data(sym, &elf_symrec_data);

    if (!entry) {
        /*@only@*/ char *symname = yasm_symrec_get_global_name(sym, object);
        elf_strtab_entry *name =
            elf_strtab_append_str(objfmt_elf->strtab, symname);
        yasm_xfree(symname);
        entry = elf_symtab_entry_create(name, sym);
        yasm_symrec_add_data(sym, &elf_symrec_data, entry);
    }

    /* Only append to table if not already appended */
    if (!elf_sym_in_table(entry))
        elf_symtab_append_entry(objfmt_elf->elf_symtab, entry);

    elf_symtab_set_nonzero(entry, NULL, sectidx, bind, type, size, value);
    elf_sym_set_visibility(entry, vis);

    return entry;
}
コード例 #3
0
ファイル: xdf-objfmt.c プロジェクト: venkatarajasekhar/Qt
static int
xdf_objfmt_count_sym(yasm_symrec *sym, /*@null@*/ void *d)
{
    /*@null@*/ xdf_objfmt_output_info *info = (xdf_objfmt_output_info *)d;
    yasm_sym_vis vis = yasm_symrec_get_visibility(sym);
    assert(info != NULL);
    if (vis & YASM_SYM_COMMON) {
        yasm_error_set(YASM_ERROR_GENERAL,
            N_("XDF object format does not support common variables"));
        yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym));
        return 0;
    }
    if (info->all_syms ||
        (vis != YASM_SYM_LOCAL && !(vis & YASM_SYM_DLOCAL))) {
        /* Save index in symrec data */
        xdf_symrec_data *sym_data = yasm_xmalloc(sizeof(xdf_symrec_data));
        sym_data->index = info->indx;
        yasm_symrec_add_data(sym, &xdf_symrec_data_cb, sym_data);

        info->indx++;
    }
    return 0;
}