From 1e225241865271002bad000c0b834e1ba6d0e142 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 10 Jun 2006 16:54:45 +0000 Subject: [PATCH] yasm_object_optimize(): Fix error/warning handling by using the new method. effaddr.asm: Disable now-unsupported construct of [reg*(label2-label)]. x86_bc_insn_calc_len(): Don't destroy NULL intnum. svn path=/branches/new-optimizer/; revision=1562 --- frontends/yasm/yasm.c | 2 +- libyasm/section.c | 4 +++- libyasm/section.h | 8 +++++--- modules/arch/x86/tests/effaddr.asm | 2 +- modules/arch/x86/tests/effaddr.hex | 4 ---- modules/arch/x86/x86bc.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index e32f136d..59ebe342 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -624,7 +624,7 @@ main(int argc, char *argv[]) check_errors(errwarns, object); /* Optimize */ - yasm_object_optimize(object, cur_arch); + yasm_object_optimize(object, cur_arch, errwarns); check_errors(errwarns, object); /* generate any debugging information */ diff --git a/libyasm/section.c b/libyasm/section.c index 23d2a715..b7552857 100644 --- a/libyasm/section.c +++ b/libyasm/section.c @@ -777,7 +777,8 @@ update_all_bc_offsets(yasm_object *object) } void -yasm_object_optimize(yasm_object *object, yasm_arch *arch) +yasm_object_optimize(yasm_object *object, yasm_arch *arch, + yasm_errwarns *errwarns) { yasm_section *sect; unsigned long bc_index = 0; @@ -807,6 +808,7 @@ yasm_object_optimize(yasm_object *object, yasm_arch *arch) if (yasm_bc_calc_len(cur, optimize_add_span, &optd)) saw_error = 1; + yasm_errwarn_propagate(errwarns, cur->line); /* TODO: times */ if (cur->multiple) diff --git a/libyasm/section.h b/libyasm/section.h index 63d720e4..61b7acdf 100644 --- a/libyasm/section.h +++ b/libyasm/section.h @@ -161,10 +161,12 @@ const char *yasm_object_get_object_fn(const yasm_object *object); /** Optimize an object. Takes the unoptimized object and optimizes it. * If successful, the object is ready for output to an object file. * \param object object - * \note Optimization failures are indicated by this function calling - * yasm__error_at(); see errwarn.h for details. + * \param arch architecture + * \param errwarns error/warning set + * \note Optimization failures are stored into errwarns. */ -void yasm_object_optimize(yasm_object *object, yasm_arch *arch); +void yasm_object_optimize(yasm_object *object, yasm_arch *arch, + yasm_errwarns *errwarns); /** Determine if a section is absolute or general. * \param sect section diff --git a/modules/arch/x86/tests/effaddr.asm b/modules/arch/x86/tests/effaddr.asm index 7fa2f678..5a165c9a 100644 --- a/modules/arch/x86/tests/effaddr.asm +++ b/modules/arch/x86/tests/effaddr.asm @@ -14,4 +14,4 @@ mov eax,[dword eax] label dd 5 label2 -mov ax,[eax+ebx*(label2-label)] +;mov ax,[eax+ebx*(label2-label)] ; not supported diff --git a/modules/arch/x86/tests/effaddr.hex b/modules/arch/x86/tests/effaddr.hex index 75ad22b6..b3628f0d 100644 --- a/modules/arch/x86/tests/effaddr.hex +++ b/modules/arch/x86/tests/effaddr.hex @@ -57,7 +57,3 @@ f8 00 00 00 -66 -8b -04 -98 diff --git a/modules/arch/x86/x86bc.c b/modules/arch/x86/x86bc.c index 2aeca231..51bcbb4e 100644 --- a/modules/arch/x86/x86bc.c +++ b/modules/arch/x86/x86bc.c @@ -578,8 +578,8 @@ x86_bc_insn_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, insn->opcode.len = 1; } insn->postop = X86_POSTOP_NONE; + yasm_intnum_destroy(num); } - yasm_intnum_destroy(num); } bc->len += immlen/8; -- 2.40.0