[Nasm-bugs] [Bug 3392571] inter-section call doesn't cause error or warning

noreply-nasm at dev.nasm.us noreply-nasm at dev.nasm.us
Wed Oct 11 04:39:49 PDT 2023


https://bugzilla.nasm.us/show_bug.cgi?id=3392571

C. Masloch <pushbx at ulukai.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
    Breaks existing|---                         |No
               code|                            |
       Bug category|                            |Unexpected or confusing
                   |                            |behavior
       Generated by|---                         |Human

--- Comment #12 from C. Masloch <pushbx at ulukai.org> ---
>From a bug during development of my debugger I found that recent nasm sometimes
emits round parens into a listing file:
https://hg.pushbx.org/ecm/ldebug/rev/2b14b7f9ed90

This is emitted in listing.c when it receives a OUT_RELADDR (as opposed to
square brackets for OUT_ADDRESS or OUT_SEGMENT):
https://github.com/netwide-assembler/nasm/blob/a916e4127b2eaa3bf40bddf3de9b0ceefc0d98a4/asm/listing.c#L259

Here's a small test case. It turns out that inter-section near calls and short
jumps use the round parens while intra-section near calls and short jumps do
not use any parens or brackets. In this example, I would usually consider the
branches to quuux to be invalid due to the differing vstart while the branches
to qux are more likely to be valid.

However, in current lDebug there are no round parens emitted in the listing
file at all. So to find invalid inter-section branches it would already help a
lot if the assembler could warn about every reference which emits an
OUT_RELADDR to the listing file.

$ cat test.asm

        section foo
        call bar
        call qux
        call quuux
        jmp short bar
        jmp short qux
        jmp short quuux

bar:
        section baz align=1
        times 8 db 0
qux:

        section xyzzy align=16 vstart=0
quuux:
$ nasm test.asm -l test.lst
$ cat test.lst
     1
     2                                          section foo
     3 00000000 E80C00                          call bar
     4 00000003 E8(0800)                        call qux
     5 00000006 E8(0000)                        call quuux
     6 00000009 EB04                            jmp short bar
     7 0000000B EB(08)                          jmp short qux
     8 0000000D EB(00)                          jmp short quuux
     9
    10                                  bar:
    11                                          section baz align=1
    12 00000000 00<rep 8h>                      times 8 db 0
    13                                  qux:
    14
    15                                          section xyzzy align=16 vstart=0
    16                                  quuux:
$ podhex test
000000 E8 0C 00 E8 11 00 E8 F7-FF EB 04 EB 0A EB F1 00  >................<
000010 00 00 00 00 00 00 00                             >.......<
000017
$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.


More information about the Nasm-bugs mailing list