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

noreply-nasm at gorcunov.org noreply-nasm at gorcunov.org
Sat Aug 10 04:20:38 PDT 2019


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

--- Comment #7 from C. Masloch <pushbx at 38.de> ---
What I'm doing is that I have sections defined like this:
https://bitbucket.org/ecm/ldebug/src/adab3da5025ff00b63381aec2d50bcee150989a8/source/debug.asm#lines-110

        cpu 8086
        org 100h
        addsection lDEBUG_DATA_ENTRY, align=16 start=100h
data_entry_start:
        addsection ASMTABLE1, align=16 follows=lDEBUG_DATA_ENTRY
        addsection ASMTABLE2, align=16 follows=ASMTABLE1
        addsection lDEBUG_CODE, align=16 follows=ASMTABLE2 vstart=0
code_start:
        addsection DATASTACK, align=16 follows=ASMTABLE2 nobits
        addsection INIT, align=16 follows=lDEBUG_CODE vstart=0

(addsection is a macro defined in lmacros3.mac)


Now, when I have eg the function d4message in the lDEBUG_CODE section, I may
accidentally "d4 call d4message" in the lDEBUG_DATA_ENTRY section:

source$ hg d
diff --git a/source/debug.asm b/source/debug.asm
--- a/source/debug.asm
+++ b/source/debug.asm
@@ -805,6 +805,9 @@
        call entry_to_code_sel, installdpmi_code

 .fataldpmierr:
+d4     call d4message
+d4     asciz "Test",13,10
+
        mov ax, 4CFFh
        int 21h

source$ build_name=debugx build_options=-D_PM ./mak.sh -D_BOOTLDR -D_DEBUG1
-D_DEBUG4


NASM silently accepts this, generating eg E8 91 A9 at offset 5A91h, that is,
"call 0425h", where 0425h is the offset of d4message in the lDEBUG_CODE
section. However, this is not valid code, because lDEBUG_CODE is not loaded to
the same segment as lDEBUG_DATA_ENTRY, so a near call from one to the other is
invalid.

What I meant about groups is that NASM may have difficulties telling which
sections are loaded where, and whether the call from one to another section is
valid. By specifying different "groups" we could tell NASM that a near call
from lDEBUG_DATA_ENTRY to lDEBUG_CODE is not valid.

This would be useful because we could have several sections (with appropriate
vstart/vfollows) loaded to be addressed by the same segment, where near or
short branches would be valid. These could be specified with the same "group",
so that  NASM knows to act as it always does as yet (ie, allow the near call).

-- 
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