Beispiel #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);
        }
    }

    return elf_march;
}
Beispiel #2
0
static yasm_objfmt *
xdf_objfmt_create(yasm_object *object)
{
    yasm_objfmt_xdf *objfmt_xdf = yasm_xmalloc(sizeof(yasm_objfmt_xdf));

    /* Only support x86 arch */
    if (yasm__strcasecmp(yasm_arch_keyword(object->arch), "x86") != 0) {
        yasm_xfree(objfmt_xdf);
        return NULL;
    }

    /* Support x86 and amd64 machines of x86 arch */
    if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), "x86") &&
        yasm__strcasecmp(yasm_arch_get_machine(object->arch), "amd64")) {
        yasm_xfree(objfmt_xdf);
        return NULL;
    }

    objfmt_xdf->parse_scnum = 0;    /* section numbering starts at 0 */

    objfmt_xdf->objfmt.module = &yasm_xdf_LTX_objfmt;

    return (yasm_objfmt *)objfmt_xdf;
}