dataval *dv;
size_t slen;
size_t i;
+ unsigned char *bufp_orig = *bufp;
STAILQ_FOREACH(dv, &bc_data->datahead, link) {
switch (dv->type) {
case DV_EMPTY:
break;
case DV_EXPR:
- if (output_expr(&dv->data.expn, bufp, bc_data->size, sect, bc,
- 0, d))
+ if (output_expr(&dv->data.expn, bufp, bc_data->size,
+ *bufp-bufp_orig, sect, bc, 0, d))
return 1;
break;
case DV_STRING:
* ep - (double) pointer to the expression to output
* bufp - (double) pointer to buffer to contain byte representation
* valsize - the size (in bytes) to be used for the byte rep
+ * offset - the offset (in bytes) of the expr contents from the bc start
* sect - current section (usually passed into higher-level calling fct)
- * bc - current bytecode (usually passed into higher-level callign fct)
+ * bc - current bytecode (usually passed into higher-level calling fct)
* rel - should the expr be treated as PC/IP-relative? (nonzero=yes)
* d - objfmt-specific data (passed into higher-level calling fct)
* Returns nonzero if an error occurred, 0 otherwise
*/
typedef int (*output_expr_func) (expr **ep, unsigned char **bufp,
- unsigned long valsize,
+ unsigned long valsize, unsigned long offset,
/*@observer@*/ const section *sect,
/*@observer@*/ const bytecode *bc, int rel,
/*@null@*/ void *d)
/*@null@*/ effaddr *ea = &x86_ea->ea;
immval *imm = insn->imm;
unsigned int i;
+ unsigned char *bufp_orig = *bufp;
/* Prefixes */
if (insn->lockrep_pre != 0)
InternalError(_("checkea failed"));
if (ea->disp) {
- if (output_expr(&ea->disp, bufp, ea->len, sect, bc, 0, d))
+ if (output_expr(&ea->disp, bufp, ea->len, *bufp-bufp_orig,
+ sect, bc, 0, d))
return 1;
} else {
/* 0 displacement, but we didn't know it before, so we have to
/* Immediate (if required) */
if (imm && imm->val) {
/* TODO: check imm->len vs. sized len from expr? */
- if (output_expr(&imm->val, bufp, imm->len, sect, bc, 0, d))
+ if (output_expr(&imm->val, bufp, imm->len, *bufp-bufp_orig, sect, bc,
+ 0, d))
return 1;
}
{
unsigned char opersize;
unsigned int i;
+ unsigned char *bufp_orig = *bufp;
/* Prefixes */
if (jmprel->lockrep_pre != 0)
WRITE_8(*bufp, jmprel->shortop.opcode[i]);
/* Relative displacement */
- if (output_expr(&jmprel->target, bufp, 1, sect, bc, 1, d))
+ if (output_expr(&jmprel->target, bufp, 1, *bufp-bufp_orig, sect,
+ bc, 1, d))
return 1;
break;
case JR_NEAR_FORCED:
/* Relative displacement */
if (output_expr(&jmprel->target, bufp,
- (opersize == 32) ? 4UL : 2UL, sect, bc, 1, d))
+ (opersize == 32) ? 4UL : 2UL, *bufp-bufp_orig,
+ sect, bc, 1, d))
return 1;
break;
default:
static int
bin_objfmt_output_expr(expr **ep, unsigned char **bufp, unsigned long valsize,
+ /*@unused@*/ unsigned long offset,
/*@observer@*/ const section *sect,
/*@observer@*/ const bytecode *bc, int rel,
/*@unused@*/ /*@null@*/ void *d)
/*@null@*/ effaddr *ea = &x86_ea->ea;
immval *imm = insn->imm;
unsigned int i;
+ unsigned char *bufp_orig = *bufp;
/* Prefixes */
if (insn->lockrep_pre != 0)
InternalError(_("checkea failed"));
if (ea->disp) {
- if (output_expr(&ea->disp, bufp, ea->len, sect, bc, 0, d))
+ if (output_expr(&ea->disp, bufp, ea->len, *bufp-bufp_orig,
+ sect, bc, 0, d))
return 1;
} else {
/* 0 displacement, but we didn't know it before, so we have to
/* Immediate (if required) */
if (imm && imm->val) {
/* TODO: check imm->len vs. sized len from expr? */
- if (output_expr(&imm->val, bufp, imm->len, sect, bc, 0, d))
+ if (output_expr(&imm->val, bufp, imm->len, *bufp-bufp_orig, sect, bc,
+ 0, d))
return 1;
}
{
unsigned char opersize;
unsigned int i;
+ unsigned char *bufp_orig = *bufp;
/* Prefixes */
if (jmprel->lockrep_pre != 0)
WRITE_8(*bufp, jmprel->shortop.opcode[i]);
/* Relative displacement */
- if (output_expr(&jmprel->target, bufp, 1, sect, bc, 1, d))
+ if (output_expr(&jmprel->target, bufp, 1, *bufp-bufp_orig, sect,
+ bc, 1, d))
return 1;
break;
case JR_NEAR_FORCED:
/* Relative displacement */
if (output_expr(&jmprel->target, bufp,
- (opersize == 32) ? 4UL : 2UL, sect, bc, 1, d))
+ (opersize == 32) ? 4UL : 2UL, *bufp-bufp_orig,
+ sect, bc, 1, d))
return 1;
break;
default:
dataval *dv;
size_t slen;
size_t i;
+ unsigned char *bufp_orig = *bufp;
STAILQ_FOREACH(dv, &bc_data->datahead, link) {
switch (dv->type) {
case DV_EMPTY:
break;
case DV_EXPR:
- if (output_expr(&dv->data.expn, bufp, bc_data->size, sect, bc,
- 0, d))
+ if (output_expr(&dv->data.expn, bufp, bc_data->size,
+ *bufp-bufp_orig, sect, bc, 0, d))
return 1;
break;
case DV_STRING:
* ep - (double) pointer to the expression to output
* bufp - (double) pointer to buffer to contain byte representation
* valsize - the size (in bytes) to be used for the byte rep
+ * offset - the offset (in bytes) of the expr contents from the bc start
* sect - current section (usually passed into higher-level calling fct)
- * bc - current bytecode (usually passed into higher-level callign fct)
+ * bc - current bytecode (usually passed into higher-level calling fct)
* rel - should the expr be treated as PC/IP-relative? (nonzero=yes)
* d - objfmt-specific data (passed into higher-level calling fct)
* Returns nonzero if an error occurred, 0 otherwise
*/
typedef int (*output_expr_func) (expr **ep, unsigned char **bufp,
- unsigned long valsize,
+ unsigned long valsize, unsigned long offset,
/*@observer@*/ const section *sect,
/*@observer@*/ const bytecode *bc, int rel,
/*@null@*/ void *d)
static int
bin_objfmt_output_expr(expr **ep, unsigned char **bufp, unsigned long valsize,
+ /*@unused@*/ unsigned long offset,
/*@observer@*/ const section *sect,
/*@observer@*/ const bytecode *bc, int rel,
/*@unused@*/ /*@null@*/ void *d)