Beispiel #1
0
static void
x86_dir_cpu(yasm_object *object, yasm_valparamhead *valparams,
            yasm_valparamhead *objext_valparams, unsigned long line)
{
    yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch;

    yasm_valparam *vp;
    yasm_vps_foreach(vp, valparams) {
        /*@null@*/ /*@dependent@*/ const char *s = yasm_vp_string(vp);
        if (s)
            yasm_x86__parse_cpu(arch_x86, s, strlen(s));
        else if (vp->type == YASM_PARAM_EXPR) {
            const yasm_intnum *intcpu;
            intcpu = yasm_expr_get_intnum(&vp->param.e, 0);
            if (!intcpu)
                yasm_error_set(YASM_ERROR_SYNTAX,
                               N_("invalid argument to [%s]"), "CPU");
            else {
                char strcpu[16];
                sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu));
                yasm_x86__parse_cpu(arch_x86, strcpu, strlen(strcpu));
            }
        } else
            yasm_error_set(YASM_ERROR_SYNTAX, N_("invalid argument to [%s]"),
                           "CPU");
    }
}
static elf_symtab_entry *
build_extern(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, yasm_object *object)
{
    yasm_valparamhead *objext_valparams =
        yasm_symrec_get_objext_valparams(sym);

    if (objext_valparams) {
        yasm_valparam *vp = yasm_vps_first(objext_valparams);
        for (; vp; vp = yasm_vps_next(vp)) {
            if (yasm_vp_string(vp))
                yasm_error_set(YASM_ERROR_TYPE,
                               N_("unrecognized symbol type `%s'"),
                               yasm_vp_string(vp));
        }
    }

    return elf_objfmt_symtab_append(objfmt_elf, sym, SHN_UNDEF, STB_GLOBAL, 0,
                                    STV_DEFAULT, NULL, NULL, object);
}
Beispiel #3
0
int
yasm_dir_helper_string(void *obj, yasm_valparam *vp, unsigned long line,
                       void *data, uintptr_t arg)
{
    /*@dependent@*/ /*@null@*/ const char *local;
    char **s = (char **)data;

    if (*s)
        yasm_xfree(*s);
    if (!(local = yasm_vp_string(vp))) {
        yasm_error_set(YASM_ERROR_VALUE,
                       N_("argument to `%s' is not a string or identifier"),
                       vp->val);
        return -1;
    }
    *s = yasm__xstrdup(local);
    return 0;
}
Beispiel #4
0
          offsetof(struct xdf_section_switch_data, flags), XDF_SECT_FLAT },
        { "absolute", 1, yasm_dir_helper_intn,
          offsetof(struct xdf_section_switch_data, absaddr), 0 },
        { "virtual", 1, yasm_dir_helper_intn,
          offsetof(struct xdf_section_switch_data, vaddr), 0 },
        { "align", 1, yasm_dir_helper_intn,
          offsetof(struct xdf_section_switch_data, align_intn), 0 }
    };

    data.absaddr = NULL;
    data.vaddr = NULL;
    data.align_intn = NULL;
    data.flags = 0;

    vp = yasm_vps_first(valparams);
    sectname = yasm_vp_string(vp);
    if (!sectname)
        return NULL;
    vp = yasm_vps_next(vp);

    flags_override = yasm_dir_helper(object, vp, line, help, NELEMS(help),
                                     &data, yasm_dir_helper_valparam_warn);
    if (flags_override < 0)
        return NULL;    /* error occurred */

    if (data.absaddr)
        data.flags |= XDF_SECT_ABSOLUTE;
    if (data.align_intn) {
        align = yasm_intnum_get_uint(data.align_intn);
        yasm_intnum_destroy(data.align_intn);