diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2018-12-02 11:44:38 +0300 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2018-12-02 11:44:38 +0300 |
commit | 0623e7dcf578032b6f6e49f41d26d7b80f3c28ea (patch) | |
tree | d6d7f3e4984e5b8dfbeab7508dcaa2d55bfca0e6 /output | |
parent | f8d9bf9d833d6ee64349259e9261cbfffbb3de53 (diff) | |
download | nasm-0623e7dcf578032b6f6e49f41d26d7b80f3c28ea.tar.gz |
output: obj -- Use nasm_error helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'output')
-rw-r--r-- | output/outobj.c | 140 |
1 files changed, 63 insertions, 77 deletions
diff --git a/output/outobj.c b/output/outobj.c index f649cad7..252ce881 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -774,8 +774,7 @@ static void obj_deflabel(char *name, int32_t segment, bool used_special = false; /* have we used the special text? */ #if defined(DEBUG) && DEBUG>2 - nasm_error(ERR_DEBUG, - " obj_deflabel: %s, seg=%"PRIx32", off=%"PRIx64", is_global=%d, %s\n", + nasm_debug(" obj_deflabel: %s, seg=%"PRIx32", off=%"PRIx64", is_global=%d, %s\n", name, segment, offset, is_global, special); #endif @@ -795,7 +794,7 @@ static void obj_deflabel(char *name, int32_t segment, obj_entry_ofs = offset; return; } - nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name); + nasm_nonfatal("unrecognised special symbol `%s'", name); } /* @@ -826,8 +825,8 @@ static void obj_deflabel(char *name, int32_t segment, pub->segment = (segment == NO_SEG ? 0 : segment & ~SEG_ABS); } if (special) - nasm_error(ERR_NONFATAL, "OBJ supports no special symbol features" - " for this symbol type"); + nasm_nonfatal("OBJ supports no special symbol features" + " for this symbol type"); return; } @@ -855,9 +854,8 @@ static void obj_deflabel(char *name, int32_t segment, loc->offset = offset; if (special) - nasm_error(ERR_NONFATAL, - "OBJ supports no special symbol features" - " for this symbol type"); + nasm_nonfatal("OBJ supports no special symbol features" + " for this symbol type"); return; } @@ -922,8 +920,8 @@ static void obj_deflabel(char *name, int32_t segment, obj_ext_set_defwrt(ext, p); special += len; if (*special && *special != ':') - nasm_error(ERR_NONFATAL, "`:' expected in special symbol" - " text for `%s'", ext->name); + nasm_nonfatal("`:' expected in special symbol" + " text for `%s'", ext->name); else if (*special == ':') special++; } @@ -936,18 +934,16 @@ static void obj_deflabel(char *name, int32_t segment, if (ext->commonsize) ext->commonelem = 1; else - nasm_error(ERR_NONFATAL, - "`%s': `far' keyword may only be applied" - " to common variables\n", ext->name); + nasm_nonfatal("`%s': `far' keyword may only be applied" + " to common variables\n", ext->name); special += 3; special += strspn(special, " \t"); } else if (!nasm_strnicmp(special, "near", 4)) { if (ext->commonsize) ext->commonelem = 0; else - nasm_error(ERR_NONFATAL, - "`%s': `far' keyword may only be applied" - " to common variables\n", ext->name); + nasm_nonfatal("`%s': `far' keyword may only be applied" + " to common variables\n", ext->name); special += 4; special += strspn(special, " \t"); } @@ -971,16 +967,15 @@ static void obj_deflabel(char *name, int32_t segment, e = evaluate(stdscan, NULL, &tokval, NULL, 1, NULL); if (e) { if (!is_simple(e)) - nasm_error(ERR_NONFATAL, "cannot use relocatable" - " expression as common-variable element size"); + nasm_nonfatal("cannot use relocatable" + " expression as common-variable element size"); else ext->commonelem = reloc_value(e); } special = stdscan_get(); } else { - nasm_error(ERR_NONFATAL, - "`%s': element-size specifications only" - " apply to common variables", ext->name); + nasm_nonfatal("`%s': element-size specifications only" + " apply to common variables", ext->name); while (*special && *special != ':') special++; if (*special == ':') @@ -1010,8 +1005,8 @@ static void obj_deflabel(char *name, int32_t segment, ext->index = ++externals; if (special && !used_special) - nasm_error(ERR_NONFATAL, "OBJ supports no special symbol features" - " for this symbol type"); + nasm_nonfatal("OBJ supports no special symbol features" + " for this symbol type"); } /* forward declaration */ @@ -1079,11 +1074,11 @@ static void obj_out(int32_t segto, const void *data, size = abs((int)size); if (segment == NO_SEG && type != OUT_ADDRESS) - nasm_error(ERR_NONFATAL, "relative call to absolute address not" - " supported by OBJ format"); + nasm_nonfatal("relative call to absolute address not" + " supported by OBJ format"); if (segment >= SEG_ABS) - nasm_error(ERR_NONFATAL, "far-absolute relocations not supported" - " by OBJ format"); + nasm_nonfatal("far-absolute relocations not supported" + " by OBJ format"); ldata = *(int64_t *)data; if (type != OUT_ADDRESS) { @@ -1128,8 +1123,8 @@ static void obj_out(int32_t segto, const void *data, switch (size) { default: - nasm_error(ERR_NONFATAL, "OBJ format can only handle 16- or " - "32-byte relocations"); + nasm_nonfatal("OBJ format can only handle 16- or " + "32-byte relocations"); segment = NO_SEG; /* Don't actually generate a relocation */ break; case 2: @@ -1152,8 +1147,8 @@ static void obj_out(int32_t segto, const void *data, */ rsize = 2; if (ldata & 0xFFFF) - nasm_error(ERR_NONFATAL, "OBJ format cannot handle complex" - " dword-size segment base references"); + nasm_nonfatal("OBJ format cannot handle complex" + " dword-size segment base references"); } if (segment != NO_SEG) obj_write_fixup(orp, rsize, @@ -1164,8 +1159,7 @@ static void obj_out(int32_t segto, const void *data, } default: - nasm_error(ERR_NONFATAL, - "Relocation type not supported by output format"); + nasm_nonfatal("Relocation type not supported by output format"); /* fall through */ case OUT_RESERVE: @@ -1191,8 +1185,8 @@ static void obj_write_fixup(ObjRecord * orp, int bytes, ObjRecord *forp; if (bytes != 2 && bytes != 4) { - nasm_error(ERR_NONFATAL, "`obj' output driver does not support" - " %d-bit relocations", bytes << 3); + nasm_nonfatal("`obj' output driver does not support" + " %d-bit relocations", bytes << 3); return; } @@ -1282,8 +1276,8 @@ static void obj_write_fixup(ObjRecord * orp, int bytes, else if (e->defwrt_type == DEFWRT_GROUP) method |= 0x10, fidx = e->defwrt_ptr.grp->obj_index; else { - nasm_error(ERR_NONFATAL, "default WRT specification for" - " external `%s' unresolved", e->name); + nasm_nonfatal("default WRT specification for" + " external `%s' unresolved", e->name); method |= 0x50, fidx = -1; /* got to do _something_ */ } } else @@ -1339,8 +1333,8 @@ static int32_t obj_segment(char *name, int pass, int *bits) * by sponging off the label manager. */ #if defined(DEBUG) && DEBUG>=3 - nasm_error(ERR_DEBUG, " obj_segment: < %s >, pass=%d, *bits=%d\n", - name, pass, *bits); + nasm_debug(" obj_segment: < %s >, pass=%d, *bits=%d\n", + name, pass, *bits); #endif if (!name) { *bits = 16; @@ -1386,8 +1380,8 @@ static int32_t obj_segment(char *name, int pass, int *bits) if (!strcmp(seg->name, name)) { if (attrs > 0 && pass == 1) - nasm_error(ERR_WARNING, "segment attributes specified on" - " redeclaration of segment: ignoring"); + nasm_warn("segment attributes specified on" + " redeclaration of segment: ignoring"); if (seg->use32) *bits = 32; else @@ -1477,8 +1471,7 @@ static int32_t obj_segment(char *name, int pass, int *bits) seg->align = readnum(p + 6, &rn_error); if (rn_error) { seg->align = 1; - nasm_error(ERR_NONFATAL, "segment alignment should be" - " numeric"); + nasm_nonfatal("segment alignment should be numeric"); } switch (seg->align) { case 1: /* BYTE */ @@ -1489,38 +1482,35 @@ static int32_t obj_segment(char *name, int pass, int *bits) case 4096: /* PharLap extension */ break; case 8: - nasm_error(ERR_WARNING, - "OBJ format does not support alignment" - " of 8: rounding up to 16"); + nasm_warn("OBJ format does not support alignment" + " of 8: rounding up to 16"); seg->align = 16; break; case 32: case 64: case 128: - nasm_error(ERR_WARNING, - "OBJ format does not support alignment" - " of %d: rounding up to 256", seg->align); + nasm_warn("OBJ format does not support alignment" + " of %d: rounding up to 256", seg->align); seg->align = 256; break; case 512: case 1024: case 2048: - nasm_error(ERR_WARNING, - "OBJ format does not support alignment" - " of %d: rounding up to 4096", seg->align); + nasm_warn("OBJ format does not support alignment" + " of %d: rounding up to 4096", seg->align); seg->align = 4096; break; default: - nasm_error(ERR_NONFATAL, "invalid alignment value %d", - seg->align); + nasm_nonfatal("invalid alignment value %d", + seg->align); seg->align = 1; break; } } else if (!nasm_strnicmp(p, "absolute=", 9)) { seg->align = SEG_ABS + readnum(p + 9, &rn_error); if (rn_error) - nasm_error(ERR_NONFATAL, "argument to `absolute' segment" - " attribute should be numeric"); + nasm_nonfatal("argument to `absolute' segment" + " attribute should be numeric"); } } @@ -1544,10 +1534,9 @@ static int32_t obj_segment(char *name, int pass, int *bits) grp->segs[i] = grp->segs[grp->nindices]; grp->segs[grp->nindices++].index = seg->obj_index; if (seg->grp) - nasm_error(ERR_WARNING, - "segment `%s' is already part of" - " a group: first one takes precedence", - seg->name); + nasm_warn("segment `%s' is already part of" + " a group: first one takes precedence", + seg->name); else seg->grp = grp; } @@ -1620,7 +1609,7 @@ obj_directive(enum directive directive, char *value, int pass) for (grp = grphead; grp; grp = grp->next) { obj_idx++; if (!strcmp(grp->name, v)) { - nasm_error(ERR_NONFATAL, "group `%s' defined twice", v); + nasm_nonfatal("group `%s' defined twice", v); return DIRR_ERROR; } } @@ -1660,10 +1649,9 @@ obj_directive(enum directive directive, char *value, int pass) grp->segs[grp->nentries++] = grp->segs[grp->nindices]; grp->segs[grp->nindices++].index = seg->obj_index; if (seg->grp) - nasm_error(ERR_WARNING, - "segment `%s' is already part of" - " a group: first one takes precedence", - seg->name); + nasm_warn("segment `%s' is already part of" + " a group: first one takes precedence", + seg->name); else seg->grp = grp; } else { @@ -1725,8 +1713,8 @@ obj_directive(enum directive directive, char *value, int pass) impname = q; if (!*extname || !*libname) - nasm_error(ERR_NONFATAL, "`import' directive requires symbol name" - " and library name"); + nasm_nonfatal("`import' directive requires symbol name" + " and library name"); else { struct ImpDef *imp; bool err = false; @@ -1773,7 +1761,7 @@ obj_directive(enum directive directive, char *value, int pass) } if (!*intname) { - nasm_error(ERR_NONFATAL, "`export' directive requires export name"); + nasm_nonfatal("`export' directive requires export name"); return DIRR_OK; } if (!*extname) { @@ -1797,16 +1785,14 @@ obj_directive(enum directive directive, char *value, int pass) bool err = false; flags |= EXPDEF_MASK_PARMCNT & readnum(v + 5, &err); if (err) { - nasm_error(ERR_NONFATAL, - "value `%s' for `parm' is non-numeric", v + 5); + nasm_nonfatal("value `%s' for `parm' is non-numeric", v + 5); return DIRR_ERROR; } } else { bool err = false; ordinal = readnum(v, &err); if (err) { - nasm_error(ERR_NONFATAL, - "unrecognised export qualifier `%s'", v); + nasm_nonfatal("unrecognised export qualifier `%s'", v); return DIRR_ERROR; } flags |= EXPDEF_FLAG_ORDINAL; @@ -2092,8 +2078,8 @@ static void obj_write_file(void) /* acbp |= 0x00 */ ; else if (seg->align >= 4096) { if (seg->align > 4096) - nasm_error(ERR_NONFATAL, "segment `%s' requires more alignment" - " than OBJ format supports", seg->name); + nasm_nonfatal("segment `%s' requires more alignment" + " than OBJ format supports", seg->name); acbp |= 0xC0; /* PharLap extension */ } else if (seg->align >= 256) { acbp |= 0x80; @@ -2127,8 +2113,8 @@ static void obj_write_file(void) if (grp->nindices != grp->nentries) { for (i = grp->nindices; i < grp->nentries; i++) { - nasm_error(ERR_NONFATAL, "group `%s' contains undefined segment" - " `%s'", grp->name, grp->segs[i].name); + nasm_nonfatal("group `%s' contains undefined segment" + " `%s'", grp->name, grp->segs[i].name); nasm_free(grp->segs[i].name); grp->segs[i].name = NULL; } @@ -2350,7 +2336,7 @@ static void obj_write_file(void) } } if (!seg) - nasm_error(ERR_NONFATAL, "entry point is not in this module"); + nasm_nonfatal("entry point is not in this module"); } /* |