static int bc_align_expand(yasm_bytecode *bc, int span, long old_val,
long new_val, /*@out@*/ long *neg_thres,
/*@out@*/ long *pos_thres);
-static int bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+static int bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
static int bc_data_item_size(yasm_bytecode *bc);
static int bc_data_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
void *add_span_data);
-static int bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+static int bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
bytecode_data *bc_data = (bytecode_data *)bc->contents;
yasm_dataval *dv;
- unsigned char *bufp_orig = *bufp;
yasm_intnum *intn;
unsigned int val_len;
unsigned long multiple, i;
val_len = dv->data.val.size/8;
for (i=0; i<multiple; i++) {
if (output_value(&dv->data.val, *bufp, val_len,
- (unsigned long)(*bufp-bufp_orig), bc, 1,
+ (unsigned long)(*bufp-bufstart), bc, 1,
d))
return 1;
*bufp += val_len;
static void bc_incbin_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc);
static int bc_incbin_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
void *add_span_data);
-static int bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+static int bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
static int bc_org_expand(yasm_bytecode *bc, int span, long old_val,
long new_val, /*@out@*/ long *neg_thres,
/*@out@*/ long *pos_thres);
-static int bc_org_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+static int bc_org_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-bc_org_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+bc_org_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
static int bc_reserve_calc_len(yasm_bytecode *bc,
yasm_bc_add_span_func add_span,
void *add_span_data);
-static int bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+static int bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
}
int
-yasm_bc_tobytes_common(yasm_bytecode *bc, unsigned char **bufp, void *d,
+yasm_bc_tobytes_common(yasm_bytecode *bc, unsigned char **buf,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc)
{
/*@sets *buf@*/
{
/*@only@*/ /*@null@*/ unsigned char *mybuf = NULL;
+ unsigned char *bufstart;
unsigned char *origbuf, *destbuf;
long i;
int error = 0;
destbuf = mybuf;
} else
destbuf = buf;
+ bufstart = destbuf;
*bufsize = bc->len*bc->mult_int;
yasm_internal_error(N_("got empty bytecode in bc_tobytes"));
else for (i=0; i<bc->mult_int; i++) {
origbuf = destbuf;
- error = bc->callback->tobytes(bc, &destbuf, d, output_value,
+ error = bc->callback->tobytes(bc, &destbuf, bufstart, d, output_value,
output_reloc);
if (!error && ((unsigned long)(destbuf - origbuf) != bc->len))
* passed-in buf matches the bytecode length
* (it's okay not to do this if an error
* indication is returned)
+ * \param bufstart For calculating the correct offset parameter for
+ * the \a output_value calls: *bufp - bufstart.
* \param d data to pass to each call to
* output_value/output_reloc
* \param output_value function to call to convert values into their byte
* preferable if calling this function twice would result in the
* same output.
*/
- int (*tobytes) (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ int (*tobytes) (yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
*/
YASM_LIB_DECL
int yasm_bc_tobytes_common
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
long new_val, /*@out@*/ long *neg_thres,
/*@out@*/ long *pos_thres);
static int lc3b_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart,
void *d, yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-lc3b_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+lc3b_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
lc3b_insn *insn = (lc3b_insn *)bc->contents;
/*@only@*/ yasm_intnum *delta;
+ unsigned long buf_off = (unsigned long)(*bufp - bufstart);
/* Output opcode */
YASM_SAVE_16_L(*bufp, insn->opcode);
break;
case LC3B_IMM_4:
insn->imm.size = 4;
- if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d))
+ if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d))
return 1;
break;
case LC3B_IMM_5:
insn->imm.size = 5;
insn->imm.sign = 1;
- if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d))
+ if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d))
return 1;
break;
case LC3B_IMM_6_WORD:
insn->imm.size = 6;
- if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d))
+ if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d))
return 1;
break;
case LC3B_IMM_6_BYTE:
insn->imm.size = 6;
insn->imm.sign = 1;
- if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d))
+ if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d))
return 1;
break;
case LC3B_IMM_8:
insn->imm.size = 8;
- if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d))
+ if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d))
return 1;
break;
case LC3B_IMM_9_PC:
insn->imm.size = 9;
insn->imm.sign = 1;
- if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d))
+ if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d))
return 1;
break;
case LC3B_IMM_9:
insn->imm.size = 9;
- if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d))
+ if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d))
return 1;
break;
default:
long new_val, /*@out@*/ long *neg_thres,
/*@out@*/ long *pos_thres);
static int x86_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart,
void *d, yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
long new_val, /*@out@*/ long *neg_thres,
/*@out@*/ long *pos_thres);
static int x86_bc_jmp_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart,
void *d, yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
yasm_bc_add_span_func add_span,
void *add_span_data);
static int x86_bc_jmpfar_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-x86_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+x86_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
x86_insn *insn = (x86_insn *)bc->contents;
/*@null@*/ x86_effaddr *x86_ea = (x86_effaddr *)insn->x86_ea;
yasm_value *imm = insn->imm;
- unsigned char *bufp_orig = *bufp;
/* Prefixes */
x86_common_tobytes(&insn->common, bufp,
yasm_expr_int(delta), bc->line);
}
if (output_value(&x86_ea->ea.disp, *bufp, disp_len,
- (unsigned long)(*bufp-bufp_orig), bc, 1, d))
+ (unsigned long)(*bufp-bufstart), bc, 1, d))
return 1;
*bufp += disp_len;
}
imm_len = 1;
} else
imm_len = imm->size/8;
- if (output_value(imm, *bufp, imm_len, (unsigned long)(*bufp-bufp_orig),
+ if (output_value(imm, *bufp, imm_len, (unsigned long)(*bufp-bufstart),
bc, 1, d))
return 1;
*bufp += imm_len;
}
static int
-x86_bc_jmp_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+x86_bc_jmp_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
x86_jmp *jmp = (x86_jmp *)bc->contents;
unsigned char opersize;
unsigned int i;
- unsigned char *bufp_orig = *bufp;
/*@only@*/ yasm_intnum *delta;
/* Prefixes */
jmp->target.size = 8;
jmp->target.sign = 1;
if (output_value(&jmp->target, *bufp, 1,
- (unsigned long)(*bufp-bufp_orig), bc, 1, d))
+ (unsigned long)(*bufp-bufstart), bc, 1, d))
return 1;
*bufp += 1;
break;
jmp->target.size = i*8;
jmp->target.sign = 1;
if (output_value(&jmp->target, *bufp, i,
- (unsigned long)(*bufp-bufp_orig), bc, 1, d))
+ (unsigned long)(*bufp-bufstart), bc, 1, d))
return 1;
*bufp += i;
break;
}
static int
-x86_bc_jmpfar_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+x86_bc_jmpfar_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@unused@*/ yasm_output_reloc_func output_reloc)
{
x86_jmpfar *jmpfar = (x86_jmpfar *)bc->contents;
unsigned int i;
- unsigned char *bufp_orig = *bufp;
unsigned char opersize;
x86_common_tobytes(&jmpfar->common, bufp, 0);
i = (opersize == 16) ? 2 : 4;
jmpfar->offset.size = i*8;
if (output_value(&jmpfar->offset, *bufp, i,
- (unsigned long)(*bufp-bufp_orig), bc, 1, d))
+ (unsigned long)(*bufp-bufstart), bc, 1, d))
return 1;
*bufp += i;
jmpfar->segment.size = 16;
if (output_value(&jmpfar->segment, *bufp, 2,
- (unsigned long)(*bufp-bufp_orig), bc, 1, d))
+ (unsigned long)(*bufp-bufstart), bc, 1, d))
return 1;
*bufp += 2;
static int cv8_symhead_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int cv8_symhead_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
static int cv8_fileinfo_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int cv8_fileinfo_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
static int cv8_lineinfo_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int cv8_lineinfo_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
static int cv_sym_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int cv_sym_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-cv8_symhead_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+cv8_symhead_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
}
static int
-cv8_fileinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+cv8_fileinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
}
static int
-cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
cv8_lineset *ls;
/* start offset and section */
- cv_out_sym(li->sectsym, 0, bc, &buf, d, output_value);
+ cv_out_sym(li->sectsym, (unsigned long)(buf - bufstart), bc, &buf,
+ d, output_value);
/* Two bytes of pad/alignment */
YASM_WRITE_8(buf, 0);
}
static int
-cv_sym_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+cv_sym_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
break;
case 'Y':
cv_out_sym((yasm_symrec *)cvs->args[arg++].p,
- (unsigned long)(buf-(*bufp)), bc, &buf, d,
+ (unsigned long)(buf-bufstart), bc, &buf, d,
output_value);
break;
case 'T':
static int cv_type_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int cv_type_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-cv_type_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+cv_type_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
static int dwarf2_head_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int dwarf2_head_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
yasm_section_bcs_first(head->debug_ptr)),
dbgfmt_dwarf2->sizeof_offset*8);
output_value(&value, buf, dbgfmt_dwarf2->sizeof_offset,
- (unsigned long)(buf-*bufp), bc, 0, d);
+ (unsigned long)(buf-bufstart), bc, 0, d);
buf += dbgfmt_dwarf2->sizeof_offset;
}
static int dwarf2_abbrev_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int dwarf2_abbrev_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-dwarf2_abbrev_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+dwarf2_abbrev_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
static int dwarf2_spp_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int dwarf2_spp_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
static int dwarf2_line_op_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int dwarf2_line_op_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-dwarf2_spp_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+dwarf2_spp_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
}
static int
-dwarf2_line_op_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+dwarf2_line_op_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
yasm_value_init_sym(&value, line_op->ext_operand,
line_op->ext_operandsize*8);
output_value(&value, buf, line_op->ext_operandsize,
- (unsigned long)(buf-*bufp), bc, 0, d);
+ (unsigned long)(buf-bufstart), bc, 0, d);
buf += line_op->ext_operandsize;
}
if (line_op->ext_operand_int) {
static int stabs_bc_str_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int stabs_bc_str_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
static int stabs_bc_stab_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int stabs_bc_stab_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-stabs_bc_stab_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+stabs_bc_stab_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
}
static int
-stabs_bc_str_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+stabs_bc_str_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
static int win32_sxdata_bc_calc_len
(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
static int win32_sxdata_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-win32_sxdata_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+win32_sxdata_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
long new_val, /*@out@*/ long *neg_thres,
/*@out@*/ long *pos_thres);
static int win64_uwinfo_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
long new_val, /*@out@*/ long *neg_thres,
/*@out@*/ long *pos_thres);
static int win64_uwcode_bc_tobytes
- (yasm_bytecode *bc, unsigned char **bufp, void *d,
+ (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
/*@null@*/ yasm_output_reloc_func output_reloc);
}
static int
-win64_uwinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+win64_uwinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
YASM_WRITE_8(buf, 1);
/* Size of prolog */
- output_value(&info->prolog_size, buf, 1, (unsigned long)(buf-*bufp),
+ output_value(&info->prolog_size, buf, 1, (unsigned long)(buf-*bufstart),
bc, 1, d);
buf += 1;
/* Count of codes */
- output_value(&info->codes_count, buf, 1, (unsigned long)(buf-*bufp),
+ output_value(&info->codes_count, buf, 1, (unsigned long)(buf-bufstart),
bc, 1, d);
buf += 1;
}
static int
-win64_uwcode_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
+win64_uwcode_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
+ unsigned char *bufstart, void *d,
yasm_output_value_func output_value,
yasm_output_reloc_func output_reloc)
{
yasm_expr_create(YASM_EXPR_SUB, yasm_expr_sym(code->loc),
yasm_expr_sym(code->proc), bc->line),
8);
- output_value(&val, buf, 1, (unsigned long)(buf-*bufp), bc, 1, d);
+ output_value(&val, buf, 1, (unsigned long)(buf-bufstart), bc, 1, d);
buf += 1;
yasm_value_delete(&val);
EXTRA_DIST += modules/objfmts/elf/tests/amd64/elfso64.hex
EXTRA_DIST += modules/objfmts/elf/tests/amd64/gotpcrel.asm
EXTRA_DIST += modules/objfmts/elf/tests/amd64/gotpcrel.hex
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/multiplefixup.asm
+EXTRA_DIST += modules/objfmts/elf/tests/amd64/multiplefixup.hex
--- /dev/null
+[section .data]
+foobar:
+ dq 42
+[section .text]
+foo:
+ times 4 mov rax, [rel foobar]
+ times 4 mov rax, [foobar]
+ times 4 jmp foo
--- /dev/null
+7f
+45
+4c
+46
+02
+01
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+3e
+00
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+20
+02
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+40
+00
+07
+00
+01
+00
+48
+8b
+05
+00
+00
+00
+00
+48
+8b
+05
+00
+00
+00
+00
+48
+8b
+05
+00
+00
+00
+00
+48
+8b
+05
+00
+00
+00
+00
+48
+8b
+04
+25
+00
+00
+00
+00
+48
+8b
+04
+25
+00
+00
+00
+00
+48
+8b
+04
+25
+00
+00
+00
+00
+48
+8b
+04
+25
+00
+00
+00
+00
+eb
+c2
+eb
+c0
+eb
+be
+eb
+bc
+03
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+04
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+0a
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+04
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+11
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+04
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+18
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+04
+00
+00
+00
+fc
+ff
+ff
+ff
+ff
+ff
+ff
+ff
+20
+00
+00
+00
+00
+00
+00
+00
+0a
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+28
+00
+00
+00
+00
+00
+00
+00
+0a
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+30
+00
+00
+00
+00
+00
+00
+00
+0a
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+38
+00
+00
+00
+00
+00
+00
+00
+0a
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+2a
+00
+00
+00
+00
+00
+00
+00
+00
+2e
+74
+65
+78
+74
+00
+2e
+64
+61
+74
+61
+00
+2e
+72
+65
+6c
+61
+2e
+74
+65
+78
+74
+00
+2e
+73
+74
+72
+74
+61
+62
+00
+2e
+73
+79
+6d
+74
+61
+62
+00
+2e
+73
+68
+73
+74
+72
+74
+61
+62
+00
+00
+00
+00
+2d
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+04
+00
+f1
+ff
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+28
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+4c
+01
+00
+00
+00
+00
+00
+00
+32
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+80
+01
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+20
+00
+00
+00
+02
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+84
+01
+00
+00
+00
+00
+00
+00
+90
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+06
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+01
+00
+00
+00
+06
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+00
+00
+44
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+10
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+0d
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+84
+00
+00
+00
+00
+00
+00
+00
+c0
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+04
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+18
+00
+00
+00
+00
+00
+00
+00
+07
+00
+00
+00
+01
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+44
+01
+00
+00
+00
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00