• link order

    From mutazilah@gmail.com@21:1/5 to All on Fri Jun 23 00:59:52 2023
    I am using Visual C++ 1.52 to create a 16-bit DOS executable
    and my link command starts:

    link /cp:1 /noi /nod /map /nologo /dosseg ploadst.obj+pload.obj+int13x.obj+

    The map shows:

    Start Stop Length Name Class
    00000H 00788H 00789H PLOADST_TEXT CODE
    0078AH 0078AH 00000H PLOAD_TEXT CODE
    0078AH 007F9H 00070H INT13X_TEXT CODE
    00C66H 00C66H 00000H DOSSUPC_TEXT CODE
    00C66H 00C66H 00000H BOS_TEXT CODE
    00C66H 00F45H 002E0H SUPPORT_TEXT CODE
    00F46H 00F46H 00000H MINIFAT_TEXT CODE
    00F46H 00F46H 00000H STRING_TEXT CODE
    00F46H 00F46H 00000H PDOSLOAD_TEXT CODE
    00F46H 01091H 0014CH LLDOS_TEXT CODE
    01092H 01214H 00183H PROTINTA_TEXT CODE
    01218H 012BDH 000A6H _TEXT32 CODE
    012BEH 012BEH 00000H FILE_TEXT CODE
    012BEH 012BEH 00000H CTYPE_TEXT CODE
    012C0H 09455H 08196H COMDAT_SEG1 CODE
    09456H 09B1FH 006CAH _DATA DATA
    09B20H 09B20H 00000H CONST CONST
    09B20H 0A39BH 0087CH _BSS BSS
    0A3A0H 0A94BH 005ACH c_common BSS
    0A950H 0B94FH 01000H STACK STACK

    which is the correct order, with pload coming second.

    But this:

    Address Publics by Value

    0000:0700 __startup
    0000:0758 _clrbss
    0000:0775 _displayc
    0000:0784 __exita
    0078:000A _int13x
    007F:000A ___open
    007F:0031 ___creat
    007F:0058 ___read
    007F:0084 ___write
    007F:00B0 ___seek
    0121:0008 _rtop_stage2
    0121:008A _runreal
    012C:0000 _main
    012C:0546 _dstart
    012C:0BD4 _readAbs
    012C:0DDA _dumpbuf
    012C:0E20 _dumplong
    012C:0EC8 ___divide
    012C:0FBE ___modulo
    012C:10BE ___subhphp
    012C:1128 _BosSetCursorPosition
    012C:1156 _BosScrollWindowUp
    012C:1198 _BosWriteText

    shows that other things ended up being earlier than
    the stuff in pload:

    C:\devel\pdos\src>grep main pload.c
    pload.c: /* Released to the Public Domain */
    pload.c: int main(void)
    pload.c: /* we need to enter here to avoid Watcom name mangling of main() */ pload.c: main();

    C:\devel\pdos\src>grep dstart pload.c
    pload.c: void dstart(int drive, char *edata)

    C:\devel\pdos\src>grep dumplong pload.c
    pload.c: void dumplong(unsigned long x);
    pload.c: /* now you can do debugging with dumplong/dumpbuf, without pload.c: void dumplong(unsigned long x)


    Almost everything appears to have been moved to here:

    012C0H 09455H 08196H COMDAT_SEG1 CODE

    and then rearranged in an order that I don't actually want.

    Any idea what is happening?

    I have no idea what "COMDAT_SEG1" means.

    I looked at all the link options and didn't see anything
    that might keep things in the right order.

    Thanks. Paul.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mutazilah@gmail.com@21:1/5 to All on Fri Jun 23 02:59:37 2023
    Switching from -O2 to -Ox solved the problem.

    I think because -O2 must have -Gy which separates
    functions into separate segments (or something like
    that) so that the linker can eliminate dead code.

    So now I have a bigger executable, but at least it is
    in the right order so that I can minimize the number
    of sectors that the boot sector needs to load.

    BFN. Paul.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)