assemblyx86nasmsymbolsredefinition

Common symbol reported as 'redefined' in ancient NASM versions (0.98.39)


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.


Solution

  • 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

    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.