From: nicolai@lysator.liu.se (Nicolai Wadstr|m)
Subject: Device Drivers in C, how to order segments?
Organization: Lysator Academic Computer Society, Linkoping University, Sweden
Date: Sat, 10 Oct 1992 13:39:41 GMT

I'm trying to write a OS/2 2.0 Device driver in C (Microsoft C 6.0, because
it provides the right memory model..), but how do I tell the linker to order
the segments in the right order?

Any help would be appreciated!


--- My .MAP file ----

 Start     Length     Name                   Class
 0001:0000 000C8H     MAINSEG                CODE
 0001:00C8 0151CH     _TEXT                  CODE
 0001:15E4 00000H     END_TEXT               CODE
 0002:0000 00A26H     KEEPSEG                CODE
 0003:0000 0028EH     INITSEG                CODE
 0004:0000 00000H     C_ETEXT                ENDCODE
 0004:0000 00200H     FAR_BSS                FAR_BSS
 0005:0000 000FFH     c_common               BSS
 0006:0000 00000H     BUFFERS                LAST_DATA
 0006:0000 00850H     LOCKS                  LOCKSEG
 0007:0000 00100H     THREADDATA             THREADDATASEG
 0008:0000 00062H     NULL                   BEGDATA
 0008:0062 0074AH     _DATA                  DATA
 0008:07AC 0000EH     CDATA                  DATA
 0008:07BA 00000H     XIFB                   DATA
 0008:07BA 00000H     XIF                    DATA
 0008:07BA 00000H     XIFE                   DATA
 0008:07BA 00000H     XIB                    DATA
 0008:07BA 00000H     XI                     DATA
 0008:07BA 00000H     XIE                    DATA
 0008:07BA 00000H     XPB                    DATA
 0008:07BA 00004H     XP                     DATA
 0008:07BE 00000H     XPE                    DATA
 0008:07BE 00000H     XCB                    DATA
 0008:07BE 00000H     XC                     DATA
 0008:07BE 00000H     XCE                    DATA
 0008:07BE 00000H     XCFB                   DATA
 0008:07BE 00000H     XCF                    DATA
 0008:07BE 00000H     XCFE                   DATA
 0008:07BE 00000H     CONST                  CONST
 0008:07BE 00000H     FAR_BSS                FAR_BSS
 0008:07BE 00000H     LAST_D                 LAST_DATA
 0008:07BE 00008H     HDR                    MSG
 0008:07C6 0013AH     MSG                    MSG
 0008:0900 00002H     PAD                    MSG
 0008:0902 00001H     EPAD                   MSG
 0008:0904 0000AH     _BSS                   BSS
 0008:090E 00000H     XOB                    BSS
 0008:090E 00000H     XO                     BSS
 0008:090E 00000H     XOE                    BSS
 0008:0910 00000H     STACK                  STACK

.
.
.

( The NULL segment (class BEGDATA) should be the first segment in the
the binary...)


--- My .DEF file ------

LIBRARY demo
PROTMODE
SEGMENTS NULL           CLASS'BEGDATA'   PRELOAD
         _DATA          CLASS'DATA'      PRELOAD
         CONST          CLASS'CONST'     PRELOAD
         FAR_BSS        CLASS'FAR_BSS'   PRELOAD
         _BSS           CLASS'BSS'       PRELOAD
         c_common       CLASS'BSS'       PRELOAD
         BUFFERS        CLASS'LAST_DATA' PRELOAD
         LAST_D         CLASS'LAST_DATA' PRELOAD
         MAINSEG        CLASS'CODE'      PRELOAD
         _TEXT          CLASS'CODE'      PRELOAD
         END_TEXT       CLASS'CODE'      PRELOAD
         KEEPSEG        CLASS'CODE'      PRELOAD IOPL
         INITSEG        CLASS'CODE'      PRELOAD




------------------------------------------


Regards,
          nicolai




nicolai@lysator.liu.se


-- 
Nicolai Wadstr|m                   # Internet:      nicolai@lysator.liu.se
                                   #
                                   # BBS:           +46-40-124554 (down)
                                   # Voice:         +46-40-975535