NASM OMF output contains wrong segment addresses
I also mailed the following to H.P. Anvin, the maintainer of NASM:
I have found a bug in at least NASM 2.16.1 and later, probably in the OMF output routines.
Far jumps and far calls contain a wrong segment address when outputting OMF files. The segment address seems to be the same as the offset address. I included a minimal example. NASM 2.15.5 produces correct code.
The code is assembled with nasm -f obj and the OMF file is disassembled with Open Watcom 1.9 wdis.
section _TEXT class=CODE
nop
nop
jmp far $
Segment: _TEXT BYTE USE16 00000007 bytes
0000 90 nop
0001 90 nop
0002 L$1:
0002 EA 02 00 02 00 jmp L$1
One nop more to show the segment equals the offset:
section _TEXT class=CODE
nop
nop
nop
jmp far $
Segment: _TEXT BYTE USE16 00000008 bytes
0000 90 nop
0001 90 nop
0002 90 nop
0003 L$1:
0003 EA 03 00 03 00 jmp L$1
Correct output of NASM 2.15.5:
Segment: _TEXT BYTE USE16 00000007 bytes
0000 90 nop
0001 90 nop
0002 L$1:
0002 EA 02 00 00 00 jmp L$1