[Nasm-bugs] [Bug 3392808] New: [Support request] absolute with label/dollar sign to change from progbits section to a nobits section

noreply-nasm at dev.nasm.us noreply-nasm at dev.nasm.us
Sun Sep 11 09:46:32 PDT 2022


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

            Bug ID: 3392808
           Summary: [Support request] absolute with label/dollar sign to
                    change from progbits section to a nobits section
           Product: NASM
           Version: 2.16 (development)
          Hardware: All
                OS: All
            Status: OPEN
          Severity: enhancement
          Priority: Medium
         Component: Assembler
          Assignee: nobody at nasm.us
          Reporter: pushbx at ulukai.org
                CC: chang.seok.bae at intel.com, gorcunov at gmail.com,
                    hpa at zytor.com, nasm-bugs at nasm.us
     Obtained from: Built from git using configure

I wanted to note this down here just in case it isn't known yet. Perhaps the
developers could add a test case for this to the repo?

I discovered this use in the Insight debugger application, at
https://hg.pushbx.org/ecm/insight/file/73e1b07abd73/src/insight.asm#l103 to
quote:

udata_start:

absolute        udata_start

                resb    WINDOW_BUF_SIZE - SHARED_DATA_SIZE
code_mark_buff  resw    10 * 4


What they do is to feed the "absolute" directive a label (equivalently, could
use the dollar sign '$' here-position-indicator) so that they can then continue
with nobits space reservation directives (resb and friends) at the exact
address that the progbits section ended at. This is the easiest way I've seen
of doing that.

The second-easiest, equally-or-more powerful way is to utilise NASM's bin
format multi-section support, to make an explicit nobits section that follows
the progbits section(s). However, this is more complex for users to understand
and prepare. (My own debugger application, lDebug, employs this. However, its
sectioning is very complex all in all anyway, featuring 9 different sections in
the same assembly source.)

The remaining ways would involve labels and equates after the end of the
progbits data, which becomes unwieldy very quickly if there's more than two or
three variables (so to say).

Here's a small test case. The construct appears to work on at least two
different NASM versions:

$ cat test2.asm
        org 256
        mov ax, buffer
        retn

absolute $
buffer: resb 100
$ nasm -v
NASM version 2.16rc0 compiled on Sep  6 2022
$ nasm test2.asm -l /dev/stderr -o /dev/null
     1                                          org 256
     2 00000000 B8[0400]                        mov ax, buffer
     3 00000003 C3                              retn
     4
     5                                  absolute $
     6 00000004 <res 64h>               buffer: resb 100
$ oldnasm -v
NASM version 2.14.03rc2 compiled on Aug 31 2019
$ oldnasm test2.asm -l /dev/stderr -o /dev/null
     1                                          org 256
     2 00000000 B8[0400]                        mov ax, buffer
     3 00000003 C3                              retn
     4
     5                                  absolute $
     6 00000004 <res 00000064>          buffer: resb 100
$


Additionally, here is a use case in the wild that reminded me of how this
feature is used in Insight:

https://stackoverflow.com/questions/73618421/replace-one-character-with-string-in-assembly-language-8086#comment130109622_73679742

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


More information about the Nasm-bugs mailing list