I'm trying to compile this source (already stripped down to minimum) with NASM 0.98.39:
common foo 2:near
mov word [bx], foo
dummy:
Unexpectedly, I get the error message:
$ nasm-0.98.39 -O9 -f obj -o tt.obj tt.nasm tt.nasm:1: error: symbol `foo' redefined
Newer versions of NASM (e.g. 2.13.02) succeed.
Is there a way to make it work with NASM 0.98.39?
Please note that for the production project upgrading NASM is not an option, because newer versions generate different machine code in some corner cases.
Please note that changing the optimization flag from -O9
to -O0
makes it succeed, but it's not an option for the production project.
CodePudding user response:
Is there a way to make it work with NASM 0.98.39?
No, there is not.
You could, of course and certainly a rather quick’n’dirty solution, upgrade nasm
and
- try addressing the undesired deviations in optimization (insert
strict
), or - simply dump the desired machine code in
db
notation.
Yes, I'd be happy with a workaround.
OMF is a fairly easy data format.
You can read up on all the necessary docs in less than an hour and program a patch program within one day.
You’ll then use an extern
in your nasm
source code in lieu of common
, your patch program will fix this.
CodePudding user response:
This is another workaround: split the source file, and link both .obj files:
Source file 1 (extern
s all code and data):
extern foo
mov word [bx], foo
dummy:
Source file 2 (only common
s):
common foo 2:near