We never set ofmt and errfunc to anything but the global values.
Dropping them from the label definition function command line
simplifies the code.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
}
void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
- bool is_norm, bool isextrn, struct ofmt *ofmt,
- efunc error)
+ bool is_norm, bool isextrn)
{
union label *lptr;
int exi;
(void)special; /* Don't warn that this parameter is unused */
(void)is_norm; /* Don't warn that this parameter is unused */
(void)isextrn; /* Don't warn that this parameter is unused */
- (void)ofmt; /* Don't warn that this parameter is unused */
#ifdef DEBUG
#if DEBUG<3
if (!strncmp(label, "debugdump", 9))
#endif
- error(ERR_DEBUG, "redefine_label (%s, %ld, %08lx, %s, %d, %d)",
+ nasm_error(ERR_DEBUG, "redefine_label (%s, %ld, %08lx, %s, %d, %d)",
label, segment, offset, special, is_norm, isextrn);
#endif
lptr = find_label(label, 1);
if (!lptr)
- error(ERR_PANIC, "can't find label `%s' on pass two", label);
+ nasm_error(ERR_PANIC, "can't find label `%s' on pass two", label);
if (!islocal(label)) {
if (!islocalchar(*label) && lptr->defn.is_norm)
}
void define_label(char *label, int32_t segment, int64_t offset, char *special,
- bool is_norm, bool isextrn, struct ofmt *ofmt, efunc error)
+ bool is_norm, bool isextrn)
{
union label *lptr;
int exi;
#if DEBUG<3
if (!strncmp(label, "debugdump", 9))
#endif
- error(ERR_DEBUG, "define_label (%s, %ld, %08lx, %s, %d, %d)",
+ nasm_error(ERR_DEBUG, "define_label (%s, %ld, %08lx, %s, %d, %d)",
label, segment, offset, special, is_norm, isextrn);
#endif
lptr = find_label(label, 1);
if (lptr->defn.is_global & DEFINED_BIT) {
- error(ERR_NONFATAL, "symbol `%s' redefined", label);
+ nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label);
return;
}
lptr->defn.is_global |= DEFINED_BIT;
/* not local, but not special either */
prevlabel = lptr->defn.label;
} else if (islocal(label) && !*prevlabel) {
- error(ERR_NONFATAL, "attempt to define a local label before any"
+ nasm_error(ERR_NONFATAL, "attempt to define a local label before any"
" non-local labels");
}
} /* if (pass0 == 1) */
}
-void define_common(char *label, int32_t segment, int32_t size, char *special,
- struct ofmt *ofmt, efunc error)
+void define_common(char *label, int32_t segment, int32_t size, char *special)
{
union label *lptr;
lptr = find_label(label, 1);
if ((lptr->defn.is_global & DEFINED_BIT) &&
(passn == 1 || !(lptr->defn.is_global & COMMON_BIT))) {
- error(ERR_NONFATAL, "symbol `%s' redefined", label);
+ nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label);
return;
}
lptr->defn.is_global |= DEFINED_BIT|COMMON_BIT;
if (!islocalchar(label[0])) {
prevlabel = lptr->defn.label;
} else {
- error(ERR_NONFATAL, "attempt to define a local label as a "
+ nasm_error(ERR_NONFATAL, "attempt to define a local label as a "
"common variable");
return;
}
special);
}
-void declare_as_global(char *label, char *special, efunc error)
+void declare_as_global(char *label, char *special)
{
union label *lptr;
if (islocal(label)) {
- error(ERR_NONFATAL, "attempt to declare local symbol `%s' as"
+ nasm_error(ERR_NONFATAL, "attempt to declare local symbol `%s' as"
" global", label);
return;
}
break;
case LOCAL_SYMBOL:
if (!(lptr->defn.is_global & EXTERN_BIT)) {
- error(ERR_WARNING, "symbol `%s': GLOBAL directive "
+ nasm_error(ERR_WARNING, "symbol `%s': GLOBAL directive "
"after symbol definition is an experimental feature", label);
lptr->defn.is_global = GLOBAL_SYMBOL;
}
bool lookup_label(char *label, int32_t *segment, int64_t *offset);
bool is_extern(char *label);
void define_label(char *label, int32_t segment, int64_t offset, char *special,
- bool is_norm, bool isextrn, struct ofmt *ofmt,
- efunc error);
+ bool is_norm, bool isextrn);
void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
- bool is_norm, bool isextrn, struct ofmt *ofmt,
- efunc error);
-void define_common(char *label, int32_t segment, int32_t size, char *special,
- struct ofmt *ofmt, efunc error);
-void declare_as_global(char *label, char *special, efunc error);
+ bool is_norm, bool isextrn);
+void define_common(char *label, int32_t segment, int32_t size, char *special);
+void declare_as_global(char *label, char *special);
int init_labels(void);
void cleanup_labels(void);
char *local_scope(char *label);
if (ofmt->stdmac)
pp_extra_stdmac(ofmt->stdmac);
- parser_global_info(ofmt, &location);
+ parser_global_info(&location);
eval_global_info(ofmt, lookup_label, &location);
/* define some macros dependent of command-line */
if (!is_extern(value)) { /* allow re-EXTERN to be ignored */
int temp = pass0;
pass0 = 1; /* fake pass 1 in labels.c */
- declare_as_global(value, special,
- nasm_error);
+ declare_as_global(value, special);
define_label(value, seg_alloc(), 0L, NULL,
- false, true, ofmt, nasm_error);
+ false, true);
pass0 = temp;
}
} /* else pass0 == 1 */
special = q;
} else
special = NULL;
- declare_as_global(value, special, nasm_error);
+ declare_as_global(value, special);
} /* pass == 1 */
break;
case D_COMMON: /* [COMMON symbol size:special] */
}
if (pass0 < 2) {
- define_common(value, seg_alloc(), size,
- special, ofmt, nasm_error);
+ define_common(value, seg_alloc(), size, special);
} else if (pass0 == 2) {
if (special)
ofmt->symdef(value, 0L, 0L, 3, special);
def_label(output_ins.label,
output_ins.oprs[0].segment,
output_ins.oprs[0].offset, NULL,
- false, isext, ofmt,
- nasm_error);
+ false, isext);
} else if (output_ins.operands == 2
&& (output_ins.oprs[0].type & IMMEDIATE)
&& (output_ins.oprs[0].type & COLON)
def_label(output_ins.label,
output_ins.oprs[0].offset | SEG_ABS,
output_ins.oprs[1].offset,
- NULL, false, false, ofmt,
- nasm_error);
+ NULL, false, false);
} else
nasm_error(ERR_NONFATAL,
"bad syntax for EQU");
define_label(output_ins.label,
output_ins.oprs[0].segment,
output_ins.oprs[0].offset,
- NULL, false, false, ofmt,
- nasm_error);
+ NULL, false, false);
} else if (output_ins.operands == 2
&& (output_ins.oprs[0].
type & IMMEDIATE)
output_ins.oprs[0].
offset | SEG_ABS,
output_ins.oprs[1].offset,
- NULL, false, false, ofmt,
- nasm_error);
+ NULL, false, false);
} else
nasm_error(ERR_NONFATAL,
"bad syntax for EQU");
* an EQU or a segment-base symbol, which shouldn't.
*/
typedef void (*ldfunc)(char *label, int32_t segment, int64_t offset,
- char *special, bool is_norm, bool isextrn,
- struct ofmt * ofmt, efunc error);
+ char *special, bool is_norm, bool isextrn);
void define_label(char *label, int32_t segment, int64_t offset,
- char *special, bool is_norm, bool isextrn,
- struct ofmt * ofmt, efunc error);
+ char *special, bool is_norm, bool isextrn);
/*
* List-file generators should look like this:
is_pic = 0x00; /* may become 0x40 */
aout_gotpc_sect = seg_alloc();
- define_label("..gotpc", aout_gotpc_sect + 1, 0L, NULL, false, false, &of_aoutb,
- nasm_error);
+ define_label("..gotpc", aout_gotpc_sect + 1, 0L, NULL, false, false);
aout_gotoff_sect = seg_alloc();
- define_label("..gotoff", aout_gotoff_sect + 1, 0L, NULL, false, false,
- &of_aoutb, nasm_error);
+ define_label("..gotoff", aout_gotoff_sect + 1, 0L, NULL, false, false);
aout_got_sect = seg_alloc();
- define_label("..got", aout_got_sect + 1, 0L, NULL, false, false, &of_aoutb,
- nasm_error);
+ define_label("..got", aout_got_sect + 1, 0L, NULL, false, false);
aout_plt_sect = seg_alloc();
- define_label("..plt", aout_plt_sect + 1, 0L, NULL, false, false, &of_aoutb,
- nasm_error);
+ define_label("..plt", aout_plt_sect + 1, 0L, NULL, false, false);
aout_sym_sect = seg_alloc();
- define_label("..sym", aout_sym_sect + 1, 0L, NULL, false, false, &of_aoutb,
- nasm_error);
+ define_label("..sym", aout_sym_sect + 1, 0L, NULL, false, false);
}
#endif
/* section.<name>.start */
strcpy(label_name + base_len, ".start");
- define_label(label_name, sec->start_index, 0L,
- NULL, 0, 0, ofmt, nasm_error);
+ define_label(label_name, sec->start_index, 0L, NULL, 0, 0);
/* section.<name>.vstart */
strcpy(label_name + base_len, ".vstart");
- define_label(label_name, sec->vstart_index, 0L,
- NULL, 0, 0, ofmt, nasm_error);
+ define_label(label_name, sec->vstart_index, 0L, NULL, 0, 0);
nasm_free(label_name);
}
win64 = true;
coff_gen_init();
imagebase_sect = seg_alloc()+1;
- define_label(WRT_IMAGEBASE, imagebase_sect, 0, NULL, false, false,
- ofmt, nasm_error);
+ define_label(WRT_IMAGEBASE, imagebase_sect, 0, NULL, false, false);
}
static void coff_std_init(void)
fwds = NULL;
elf_gotpc_sect = seg_alloc();
- define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false, &of_elf32,
- nasm_error);
+ define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false);
elf_gotoff_sect = seg_alloc();
- define_label("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false, &of_elf32,
- nasm_error);
+ define_label("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false);
elf_got_sect = seg_alloc();
- define_label("..got", elf_got_sect + 1, 0L, NULL, false, false, &of_elf32,
- nasm_error);
+ define_label("..got", elf_got_sect + 1, 0L, NULL, false, false);
elf_plt_sect = seg_alloc();
- define_label("..plt", elf_plt_sect + 1, 0L, NULL, false, false, &of_elf32,
- nasm_error);
+ define_label("..plt", elf_plt_sect + 1, 0L, NULL, false, false);
elf_sym_sect = seg_alloc();
- define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false, &of_elf32,
- nasm_error);
+ define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false);
elf_tlsie_sect = seg_alloc();
- define_label("..tlsie", elf_tlsie_sect + 1, 0L, NULL, false, false, &of_elf32,
- nasm_error);
+ define_label("..tlsie", elf_tlsie_sect + 1, 0L, NULL, false, false);
def_seg = seg_alloc();
}
fwds = NULL;
elf_gotpc_sect = seg_alloc();
- define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false, &of_elf64,
- nasm_error);
+ define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false);
elf_gotoff_sect = seg_alloc();
- define_label("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false, &of_elf64,
- nasm_error);
+ define_label("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false);
elf_got_sect = seg_alloc();
- define_label("..got", elf_got_sect + 1, 0L, NULL, false, false, &of_elf64,
- nasm_error);
+ define_label("..got", elf_got_sect + 1, 0L, NULL, false, false);
elf_plt_sect = seg_alloc();
- define_label("..plt", elf_plt_sect + 1, 0L, NULL, false, false, &of_elf64,
- nasm_error);
+ define_label("..plt", elf_plt_sect + 1, 0L, NULL, false, false);
elf_sym_sect = seg_alloc();
- define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false, &of_elf64,
- nasm_error);
+ define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false);
elf_gottpoff_sect = seg_alloc();
- define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false, &of_elf64,
- nasm_error);
+ define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false);
def_seg = seg_alloc();
ieee_seg_needs_update = seg;
if (seg->align >= SEG_ABS)
define_label(name, NO_SEG, seg->align - SEG_ABS,
- NULL, false, false, &of_ieee, nasm_error);
+ NULL, false, false);
else
- define_label(name, seg->index + 1, 0L,
- NULL, false, false, &of_ieee, nasm_error);
+ define_label(name, seg->index + 1, 0L, NULL, false, false);
ieee_seg_needs_update = NULL;
if (seg->use32)
/* string table starts with a zero byte - don't ask why */
saa_wbytes(strs, &zero, sizeof(char));
strslen = 1;
-
- /* add special symbol for ..gotpcrel */
- macho_gotpcrel_sect = seg_alloc();
- macho_gotpcrel_sect ++;
- define_label("..gotpcrel", macho_gotpcrel_sect, 0L, NULL, false, false, &of_macho64, nasm_error);
+
+ /* add special symbol for ..gotpcrel */
+ macho_gotpcrel_sect = seg_alloc();
+ macho_gotpcrel_sect++;
+ define_label("..gotpcrel", macho_gotpcrel_sect, 0L, NULL, false, false);
}
static void sect_write(struct section *sect,
int pcrel, int bytes, int64_t reloff)
{
struct reloc *r;
- struct symbol *sym;
+ struct symbol *sym;
int32_t fi;
- int32_t adjustment = 0;
+ int32_t adjustment = 0;
/* NeXT as puts relocs in reversed order (address-wise) into the
** files, so we do the same, doesn't seem to make much of a
obj_seg_needs_update = seg;
if (seg->align >= SEG_ABS)
define_label(name, NO_SEG, seg->align - SEG_ABS,
- NULL, false, false, &of_obj, nasm_error);
+ NULL, false, false);
else
define_label(name, seg->index + 1, 0L,
- NULL, false, false, &of_obj, nasm_error);
+ NULL, false, false);
obj_seg_needs_update = NULL;
/*
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);
+ "segment `%s' is already part of"
+ " a group: first one takes precedence",
+ seg->name);
else
seg->grp = grp;
}
grp->name = NULL;
obj_grp_needs_update = grp;
- define_label(v, grp->index + 1, 0L,
- NULL, false, false, &of_obj, nasm_error);
+ define_label(v, grp->index + 1, 0L, NULL, false, false);
obj_grp_needs_update = NULL;
while (*q) {
static int i;
static struct tokenval tokval;
static efunc error;
-static struct ofmt *outfmt; /* Structure of addresses of output routines */
static struct location *location; /* Pointer to current line's segment,offset */
-void parser_global_info(struct ofmt *output, struct location * locp)
+void parser_global_info(struct location * locp)
{
- outfmt = output;
location = locp;
}
* am still not certain.
*/
ldef(result->label, in_abs_seg ? abs_seg : location->segment,
- location->offset, NULL, true, false, outfmt, errfunc);
+ location->offset, NULL, true, false);
}
}
#ifndef NASM_PARSER_H
#define NASM_PARSER_H
-void parser_global_info(struct ofmt *output, struct location * locp);
+void parser_global_info(struct location * locp);
insn *parse_line(int pass, char *buffer, insn * result,
efunc error, evalfunc evaluate, ldfunc ldef);
void cleanup_insn(insn * instruction);