source: vendor/emx/current/src/doc/emxdev.src

Last change on this file was 18, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 149.0 KB
Line 
1þtext
2===============================================================================
3emxdev.doc emx 0.9d APPLICATION DEVELOPER'S GUIDE 21-Dec-1998
4===============================================================================
5 Copyright (c) 1990-1998 by Eberhard Mattes
6þendtext
7
8þtitle emx 0.9d Application Developer's Guide
9
10þformat bold emx emxbind emxcat emximp emxomf emxomfar emxomfld 0.8f 9.9c 0.9d
11þformat bold emxload emxrev listomf emxexp emxaout emxtsf updt dmake
12þformat bold GCC GCOV GDB ld nm rc objdump GPPDEMID gprof TRCUST TRACE TRACEFMT
13
14þformat tty .a .bak .def .dll .exe .imp .lib .map .o .obj .res .s .tsf
15þformat tty build.doc
16þformat tty os2.h os2emx.h os2tk.h emx.h
17þformat tty cmd.exe command.com
18þformat tty emx.exe emxd.exe emxl.exe emxload.exe emxomf.exe emxomfld.exe
19þformat tty emx.dll emxio.dll emxlibcm.dll emxlibcs.dll
20þformat tty emxwrap.dll gppdemid.dll
21þformat tty strip.exe gcc.exe cpp.exe cc1.exe cc1plus.exe cc1obj.exe
22þformat tty crt0.s crt0.o gcrt0.o
23þformat tty c_import.a os2.a c_static.a c_static.lib
24þformat tty c.lib c_app.lib c_dllemx.lib c_dllsys.lib c_import.lib
25þformat tty os2.lib emx.lib emx2.lib sys.lib gcc.lib
26þformat tty emxio crt0 dll0
27þformat tty myprog.exe himem.sys config.sys
28þformat tty test.dll test.exe test.def test.res test1.obj test2.obj
29þformat tty /emx/bin/emxl.exe
30þformat tty stdio.c iodata.c gmon.out
31þformat tty <ctype.h> <dirent.h> <float.h> <io.h> <locale.h> <malloc.h>
32þformat tty <math.h> <process.h> <pwd.h> <signal.h> <stdio.h>
33þformat tty <stdlib.h> <string.h> <strings.h> <sys/emxload.h> <sys/fmutex.h>
34þformat tty <termios.h> <time.h> <umalloc.h> <unistd.h>
35
36þformat tty -mprobe -T -nostdlib -lwrap -lc -los2 -pg -pn
37þformat tty -Zmap[=<map_file>] -Zsysv-signals -Zbsd-signals -Zmt -Zso -Zcrtdll
38þformat tty -Zdll -Zomf -Zmtd -Zmts -Zsys -Zexe -Zstack -Zlinker
39
40þformat tty O_BINARY P_DEBUG P_NOSESSION SIGQUIT SIGILL SIGCLD SIGTRAP
41þformat tty SIGABRT SIGEMT SIGFPE SIGBUS SIGSEGV SIGSYS SIG_ACK
42þformat tty c_lflag VEOF VEOL VMIN VTIME IDEFAULT
43þformat tty __MT__ __.SYMDEF __.IMPORT
44
45þformat tty alarm() brk() fork() exec*() exit() fdopen() fopen() freopen()
46þformat tty fseek() main() malloc() open() popen() sbrk() select() abort()
47þformat tty sleep() spawn*() strcpy() system() wait() memcpy() ftell()
48þformat tty _abspath() _beginthread() _core() _emx_16to32() _emx_32to16()
49þformat tty _fseek_hdr() _fsetmode() _fullpath() _memaccess() _portaccess()
50þformat tty _read_kbd() _seek_hdr() _sleep2() _tmalloc() _inp8()
51þformat tty _CRT_init() _CRT_term() _DLL_InitTerm() _errno()
52þformat tty __open()
53þformat tty _tp __os2_bad __os2dll _16_ #define #include errno
54þformat tty argc argv "b" stdin stdout stderr
55þformat tty _pascal _cdecl
56þformat tty _THUNK_FUNCTION _THUNK_PROLOG _THUNK_CALL _THUNK_CALLI _THUNK
57þformat tty _THUNK_PASCAL_*** _THUNK_C_*** _THUNK_*** _THUNK_C_FUNCTION
58
59þformat tty DosSelectSession _DosSelectSession DosCreateThread DosSetMaxFH
60þformat tty DosLoadModule DosQueryProcAddr DosKillThread
61
62þformat tty -a -b -c -d -e -f -g -i -k -l -m -n -o -p -q -r -s -t -u -v -w -x
63þformat tty -D -E -F -I -K -L -O -P -R -S -X
64þformat tty -ac -am -aw -ai -aim -aciw -bs
65þformat tty -m1 -m2 -m3 -s8 -rd -s524288 -s8192 -S1 -S2 -qw -uw
66
67þformat syntax -a* -h# -m# -r* -p# -s# -C# -S# -V -Z
68þformat syntax <emxbind_options> -c[<core_file>] -d<def_file> -E<dll>
69þformat syntax -r<res_file> -h<heap_size> -k<stack_size> <def_file> <dll>
70þformat syntax <emx>[.exe] <input_file> <output_file>[.exe] <emx_options>
71þformat syntax -c[<core_file>] -d[<def_file>] <res_file> <file> <dir> <drive>
72þformat syntax <output_file> <program_file> <emx> <page_size> <options>
73þformat syntax <core_file> <symbol> <default_lib> <source_file> <target_file>
74þformat syntax <library_file> <command> <emx_options> <program> <arguments>
75þformat syntax <internalname> =<internalname> <entryname> <ordinal> @<ordinal>
76þformat syntax <libraryname> <number> <initialization> <termination>
77þformat syntax <appname> <apptype> <input_file>.imp <input_file>.lib
78þformat syntax <output_file>.lib <output_file>.a <input_file>.def
79þformat syntax <idmdll> <dataseg> -m<limit> -s<limit> <libdir> <directory>
80þformat syntax <address> <range> <value> <register> <condition> <list>
81þformat syntax <response_file> <option> <map_file> -m<map_file>
82þformat syntax <tss_file> <dll_name> <level>
83þformat syntax LIBRARY INITGLOBAL INITINSTANCE TERMGLOBAL TERMINSTANCE
84þformat syntax NEWFILES LONGNAMES EXPORTS RESIDENTNAME DESCRIPTION NONAME
85þformat syntax NOTWINDOWCOMPAT WINDOWAPI WINDOWCOMPAT NAME STUB STACKSIZE
86
87þformat abbrev etc.
88
89þif text
90þh= Table of Contents
91þtoc
92þendif
93
94þh1 Introduction to the emx Application Developer's Guide
95þlabel introduction
96þipf
97:font facename=Helv size=24x14.:hp2.emx 0.9d APPLICATION DEVELOPER'S GUIDE
98:ehp2.
99:p.
100:font facename=Helv size=16x10. Copyright (c) 1990-1998 by Eberhard Mattes
101:font facename=default size=0x0.
102:p.
103þendipf
104
105 This document describes how to use emx utilities to create programs
106 running under emx and how to create OS/2 programs with the emx
107 utilities. In this document, OS/2 stands for OS/2 2.x and later.
108
109 The GNU utilities are described in þtt{/emx/doc/emxgnu.doc} and
110 þtt{/emx/book/emxgnu.inf}.
111
112 There are three methods for creating executable files:
113
114þdescription
115þitem (E1)
116
117 using þhpt{ld} and þhpt{emxbind}
118
119þitem (E2)
120
121 using þhpt{emxomf}, þhpt{emxomfld} and LINK386, the program
122 will use the emx.dll dynamic link library for performing
123 system calls
124
125þitem (E3)
126
127 using emxomf, emxomfld and LINK386, the program will be linked
128 with a system call library (creating a stand-alone application
129 or DLL)
130
131þenddescription
132
133 The assembler creates a Unix-style a.out object file (.o file).
134 When using method (E1), .o files created by the assembler are linked
135 by a Unix-style linker with Unix-style libraries (.a files) to
136 create a Unix-style a.out file. Then, emxbind is used to turn this
137 file into an .exe file that can be executed under both OS/2 and
138 DOS. Using method (E1) enables core dumps and þhpt{fork()}.
139 Moreover, programs created with method (E1) can be debugged using
140 þhpt{GDB}, the GNU debugger. Programs created using method (E1) use
141 emx (emx.dll under OS/2, emx.exe under DOS) for system calls.
142
143 When using method (E2), the .o files created by the assembler are
144 converted to Object Module Format files (.obj files). These files
145 are linked with the OS/2 linker LINK386. The libraries are .lib
146 files. emxomfld is a front end to LINK386 which converts the ld
147 command line to a LINK386 command line. Programs created with
148 method (E2) cannot create core dumps, cannot call fork() and cannot
149 be debugged with GDB. Method (E2) works only under OS/2 and creates
150 programs that work only under OS/2. You can use IBM's IPMD and
151 SD386 debuggers to debug programs created with methods (E2) and
152 (E3). Files created with method (E2) are usually smaller. The
153 emx.dll dynamic link library is used for system calls. The
154 þhpt{-Zomf} option of þhpt{GCC} selects method (E2).
155
156 When using method (E3), the program won't call the emx.dll dynamic
157 link library. A system call library (emx emulator) is linked to the
158 program. The system call library maps system calls to OS/2 API
159 calls. Only a subset of the emx system calls is available with
160 method (E3). For instance, the þhpt{general terminal interface} is
161 not available. Functions which are not available or are limited
162 with method (E3) are marked [*] in the library reference. Use a
163 þhpt{module definition file} and the þhpt{STACKSIZE statement} to
164 set the stack size. Alternatively, you can use the þhpt{-Zstack}
165 option of GCC. The default stack size is 0x8000 bytes. Note that
166 the command line arguments and environment pointers are copied
167 to the stack on startup.
168
169 The following table summarizes the methods for creating executable
170 files.
171
172þverbatim
173 Method ³ (E1) ³ (E2) ³ (E3)
174 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
175 GCC options ³ ³ -Zomf ³ -Zomf -Zsys
176 Object file format ³ a.out ³ OMF ³ OMF
177 Object file name extension ³ .o ³ .obj ³ .obj
178 Library file name extension ³ .a ³ .lib ³ .lib
179 Executable file format ³ LX & a.out ³ LX ³ LX
180 Object files converted by ³ N/A ³ emxomf ³ emxomf
181 Executable files converted by ³ emxbind ³ N/A ³ N/A
182 Linker ³ ld ³ LINK386 ³ LINK386
183 Librarian ³ ar ³ emxomfar ³ emxomfar
184 Minimal set of libraries ³ c gcc ³ c gcc ³ c gcc
185 ³ ³ emx emx2 ³ sys os2
186 Methods for importing ³ (I1) (I2) ³ (I3) ³ (I3)
187 Can link with OMF libraries ³ NO (note 1) ³ NO (note 1) ³ YES
188 Debugger ³ GDB ³ IPMD, SD386 ³ IPMD, SD386
189 emx.dll required at run time ³ YES ³ YES ³ NO
190 Library support ³ +++ ³ ++ ³ +
191 Core dumps ³ YES ³ NO ³ NO
192 Size overhead ³ big ³ none ³ (note 2)
193 Programs run under DOS ³ YES ³ NO ³ NO
194 Can create DLLs ³ YES (note 3) ³ YES ³ YES
195 EMXOPT environment variable ³ YES ³ YES ³ NO
196 -Zmt supported ³ YES ³ YES ³ YES
197 -Zcrtdll supported ³ YES ³ YES ³ NO
198þendverbatim
199
200þdescription
201þitem Note 1:
202
203 import libraries can be used after conversion with þhpt{emximp}
204
205þitem Note 2:
206
207 depends on the set of syscalls used by the program
208
209þitem Note 3:
210
211 not recommended unless you want to debug the DLL with GDB
212
213þenddescription
214
215 See also section `þhpt{Startup modules and libraries}' of
216 þtt{emxgnu.doc}.
217
218 Programs created with method (E1) or (E2) can use emxlibcm.dll or
219 emxlibcs.dll, dynamic link libraries containing the C library. Use
220 the -Zcrtdll option to make a program that uses emxlibcm.dll
221 (multithread library) or emxlibcs.dll (single-thread library).
222 Programs which use emxlibcm.dll or emxlibcs.dll don't run under DOS.
223 For running the application, either emxlibcm.dll or emlibcs.dll
224 (depending on whether the application is a single-thread or
225 multithread program) and emx.dll are required. There are three
226 advantages of using emxlibcm.dll and emxlibcs.dll:
227
228þitemize
229þitem
230 reduced executable size
231þitem
232 reduced memory requirements
233þitem
234 programs don't have to be re-linked when the C library is changed.
235þenditemize
236
237 Use -Zomf -Zcrtdll -lwrap -s to minimize the size of the executable
238 file.
239
240 Please note that you should change the name of emxlibcm.dll or
241 emxlibcs.dll if you want to distribute your program with modified
242 versions of those dynamic link libraries.
243
244 For using floating point arithmetic, a coprocessor is required
245 (80387 or i486). All exceptions are masked, that is, computation
246 continues with +#INF, -#INF, +#NAN or -#NAN after an error.
247
248 A 387 coprocessor is not required for doing floating point
249 arithmetic under OS/2. Under DOS, a 387 coprocessor (or i486)
250 is required for doing floating point arithmetic.
251
252 A core dump file will be written if a program is terminated by
253 signal SIGSEGV (protection violation), SIGILL (illegal instruction),
254 SIGABRT (abort()), SIGFPE (floating point exception), SIGTRAP
255 (breakpoint), SIGBUS, SIGEMT, SIGQUIT, or SIGSYS. You can later
256 debug the program using the .exe file and the core dump file. The
257 name of the core dump file is þtt{core}, and it is put into the
258 current working directory. Use the -c emx option to suppress
259 writing a core dump file. When linking a program using method (E2)
260 or (E3), core dump files are not written by that program.
261
262 OS/2 and DOS support both the forward slash and the backslash for
263 separating directories. Unix utilities usually treat the backslash
264 character specially, therefore you should use the forward slash.
265 This document uses forward slash unless an OS/2 or DOS command is
266 shown (cmd.exe and command.com use backslashes).
267
268
269 File name extensions (the list is incomplete):
270
271þexample
272a Unix-style library (archive)
273bat DOS batch file
274c C source file
275cc C++ source file
276cmd OS/2 batch file
277cpp C++ source file
278cxx C++ source file
279def Module definition file
280doc Documentation file
281dll Dynamic link library
282dvi Device independent file, created by TeX
283exe Executable file
284h C include file (header file)
285i<digits> Split GNU info file
286imp emx import list file
287inf GNU info file (use `info' for reading) or
288 OS/2 on-line book (use `VIEW' for reading)
289lib OMF library
290m Objective C source file
291map Map file, created by LINK386 or emxbind
292o Object file (Unix style, a.out)
293obj Object file (OMF)
294rc Resource script file
295res Binary resource file
296s Assembler source file
297tex TeX (or texinfo) source file
298þendexample
299
300 Directories:
301
302þexample
303/emx Main directory, contains no files
304/emx/bin Executable files and batch files
305/emx/dll DLLs for OS/2
306/emx/doc Documentation
307/emx/include Header files (C language)
308/emx/lib Libraries
309/emx/lib/mt Multithread libraries
310/emx/lib/st Single-thread libraries
311/emx/new New .exe files created by the makebin batch file
312/emx/samples Sample programs
313/emx/src Source code
314/emx/test Test programs
315þendexample
316
317þh1 Managing bound .exe files with emxbind
318þlabel emxbind
319þi1 emxbind
320þkeyword emxbind
321
322 The emxbind utility is used to create and modify bound .exe files
323 using method (E1). The action to be performed is specified by a
324 command letter which looks like a command line option.
325
326þif ipf
327
328 The following emxbind commands are available:
329
330þdescription
331þitem -b
332
333 þhpt{Create an .exe file from an a.out file}
334
335þitem -s
336
337 þhpt{Change the type of an .exe file}
338
339þitem -x
340
341 þhpt{Extract the a.out file from a bound .exe file}
342
343þitem -a
344
345 þhpt{Change the emx options of a bound .exe file}
346
347þitem -i
348
349 þhpt{Display the emx options of a bound .exe file}
350
351þitem -u
352
353 þhpt{Update emx.exe in a bound .exe file}
354
355þitem -s
356
357 þhpt{Strip the symbol table from a bound .exe file}
358
359þenddescription
360þendif
361
362þh2 Creating an .exe file
363þlabel Create an .exe file from an a.out file
364þlabel -b command
365þi2 -b command
366
367 emxbind binds emx.exe and an emx executable file into one executable
368 file which runs both under OS/2 2.0 (or later) and DOS.
369
370þipfminitoc
371
372þh3 Important notes
373
374 The bound program does not run under DOS versions prior to 3.0. emx
375 options cannot be put onto the command line; use EMXOPT instead.
376
377 Do not compress the bound executable with a program like TINYPROG,
378 PKLITE, or LZEXE, which makes the program uncompress itself when
379 started.
380
381 emx can be used for running bound .exe files created using the same
382 version of emx. þhpt{spawn*()} and þhpt{exec*()} also work on bound
383 .exe files.
384
385 The GNU programs þhpt{GDB}, þbf{nm}, þbf{objdump} and þbf{size}
386 (but not þhpt{strip}) have been modified to work with bound .exe
387 files.
388
389 You can use the emx loader emxl.exe to save disk space. When the
390 bound executable is run, emxl.exe will load emx.exe to run the
391 program. There is a small speed penalty due to locating and loading
392 emx.exe.
393
394 If the EMX environment variable is set, emxl.exe first tries to load
395 the file specified by that variable. Use
396
397þexample
398SET EMX=c:\emx\bin\emx.exe
399þendexample
400
401 to speed up locating emx.exe. You can also use emxd.exe this way.
402
403 If the EMX environment variable is not set or the emx.exe file
404 specified by EMX could not be loaded, emxl.exe will try emx.exe in
405 the current working directory, then emx.exe in all directories
406 listed in the PATH environment variable.
407
408þh3 Invoking emxbind to create an .exe file
409
410 There are two ways to invoke emxbind to create an .exe file. The
411 first one is used if you want to use the default emxl.exe:
412
413þindent
414 þsy{emxbind [-b] [<emxbind_options>] [-o <output_file>[.exe]]} þbreak
415 þsy{ <input_file> [<emx_options>]}
416þendindent
417
418 The second one is used if you want to specifiy the path name of the
419 emx executable (emxl.exe, emx.exe, or emxd.exe) to use:
420
421þindent
422 þsy{emxbind [-b] [<emxbind_options>]} þbreak
423 þsy{ <emx>[.exe] <input_file> [<output_file>[.exe]] [<emx_options>]}
424þendindent
425
426 The command line consists of the following elements:
427
428þlist
429þitem <emxbind_options>
430
431 The following options can be given to emxbind. They must appear at
432 the beginning of the emxbind arguments.
433
434þdescription
435þitem -b (optional)
436
437 this emxbind command means `bind' and is the default. If you want
438 to use the -s option (strip symbol table), -b cannot be omitted,
439 that is, you should type -bs (otherwise, emxbind would perform the
440 þhpt{-s command} described below)
441
442þitem -c[<core_file>]
443
444 combine an a.out file and a core dump file created for that a.out
445 file into one program. This can be used to create a a program
446 with preloaded data. Note that the .exe file will waste a lot of
447 disk space. If you don't enter <core_file>, þtt{core} will be
448 used. The core dump file must not contain multiple heap objects
449
450þitem -d[<def_file>]
451
452 read the module definition file <def_file>. The default extension
453 is .def. If <def_file> is omitted, <input_file> with .def
454 extension is used instead. See section þref{module definition
455 files} for details on þhpt{module definition files}
456
457þitem -E<dll>
458
459 use <dll>þtt{.dll} instead of emx.dll. This option is used for
460 referencing an alternate, renamed emx.dll. If -E<dll> is not
461 used, emxbind takes the name of the DLL from the EMXBIND_DLL
462 environment variable. For instance, to use þtt{myx.dll} instead
463 of emx.dll, use the following command:
464þexample
465set emxbind_dll=myx
466þendexample
467 If both -E<dll> and EMXBIND_DLL are not set, emxbind uses emx.dll
468
469þitem -f
470
471 set application type to `full screen'. See also the þhpt{-e
472 command}
473
474þitem -h<heap_size>
475þlabel -h<heap_size> option of emxbind
476
477 set heap size for OS/2. This is the space available for
478 allocation by þhpt{malloc()} and þhpt{_tmalloc()}. For emx 0.9c
479 and later, the heap size specifies the size of the initial heap
480 object; malloc() may allocate additional heap objects so that the
481 total size of the heap is no longer limited by the size of the
482 initial heap object. The number is given in decimal, octal or
483 hexadecimal, using C notation. The heap size is specified in
484 megabytes (0 through 512). The default value is 32. For DOS, the
485 heap size is controlled by the þhpt{-s# emx option} (see section
486 þref{Using emx options})
487
488þitem -k<stack_size>
489þlabel -k<stack_size> option of emxbind
490
491 set the size of the stack object of the executable file. The
492 number is given in decimal, octal or hexadecimal, using C
493 notation. The stack size set by this option is used under OS/2.
494 The stack size is given in KByte, the default is 8192 (8 MByte).
495 The stack size must be between 20 and 524288 (512 MByte). The
496 stack size should not be less than 32 KByte. You should not use
497 -k without -b, as a -k command is planned for a future version of
498 emxbind
499
500þitem -m<map_file>
501
502 write the map file <map_file>. The format is simular to that of
503 map files written by LINK386. The default extension is
504 `þtt{map}'.
505
506þitem -p
507
508 set application type to `Presentation Manager'. See also the
509 þhpt{-e command}
510
511þitem -q
512
513 don't display emxbind banner line
514
515þitem -r<res_file>
516
517 put resources from binary resource file <res_file> (no default
518 extension) into the .exe file. Use þtt{rc -r} to create the
519 binary resource file. Do not use rc to put the resources into the
520 .exe file
521
522þitem -s
523
524 strip symbols (requires -b). You can also strip the symbol table
525 before creating the .exe file by calling
526þif ipf
527 þhpt{strip}
528þelse
529 strip.exe
530þendif
531 or after
532 creating the .exe file by using the þhpt{-s command} of emxbind
533
534þitem -v
535
536 display more information: list resources, display path name of
537 emxl.exe unless given on command line, display the statements in
538 the module definition file that are ignored
539
540þitem -w
541
542 set application type to `windowed' (default). See also the
543 þhpt{-e command}
544
545þenddescription
546
547 Only one of the options -f, -p and -w can be used. If none of
548 these options is used, the application type is taken from the NAME
549 statement of the module definition file (-d option). If no module
550 definition file is used, -w is the default.
551
552þitem þsy{[-o <output_file>[.exe]]}
553
554 path name of the bound executable file. The default extension is
555 .exe unless the LIBRARY statement is used in the module definition
556 file. If LIBRARY is used in the module definition file (that is,
557 when you are creating a dynamic link library), the default
558 extension is .dll. If the <output_file> parameter is omitted, the
559 <input_file> parameter will be used instead (do not specify an
560 extension for the input file to avoid overwriting the input
561 file!). Moreover, the output file name (or <input_file>, if
562 <output_file> is omitted) sans directory part and extension is
563 used as module name for the .exe file unless a module name is
564 defined with a NAME or LIBRARY statement in the module definition
565 file.
566
567 The -o option can be used only if there is exactly one file name
568 (which is not the argument of an option) given
569
570þitem <emx> (optional if no <output_file> is given)
571
572 path name of emx (default extension: .exe), that is emx.exe,
573 emxd.exe or emxl.exe. Using þtt{emxl.exe} is recommended. If
574 this argument is omitted (in this case the <output_file> argument
575 must be omitted as well), the filename from the STUB statement of
576 the module definition file is used. emxbind searches the
577 directories listed in the EMXPATH and PATH environment variables
578 for that file. If no module definition file is used or if the
579 STUB statement isn't used, the file /emx/bin/emxl.exe will be
580 used. If that file doesn't exist, emxbind searches the
581 directories listed in the EMXPATH and PATH environment variables
582 for emxl.exe. If that fails, emxl.exe is taken from the current
583 working directory. If the -v option is given, the path name of
584 emxl.exe will be displayed unless a STUB statement is present
585
586þitem <input_file>
587
588 path name of the a.out file to be read
589
590þitem <output_file> (optional)
591
592 path name of the bound executable file. The default extension is
593 .exe unless the LIBRARY statement is used in the module definition
594 file. If LIBRARY is used in the module definition file (that is,
595 when you are creating a dynamic link library), the default
596 extension is .dll. If the <output_file> parameter is omitted, the
597 <input_file> parameter will be used instead (do not specify an
598 extension for the input file to avoid overwriting the input
599 file!). Moreover, the output file name (or <input_file>, if
600 <output_file> is omitted) sans directory part and extension is
601 used as module name for the .exe file unless a module name is
602 defined with a NAME or LIBRARY statement in the module definition
603 file.
604
605 Use <output_file> instead of the -o option if you need to specify
606 <emx>
607
608þitem <emx_options> (optional)
609
610 emx options to be used when running the bound program. These
611 options will be examined before those given in EMXOPT. emxbind
612 does not completely check the validity of the options. See
613þif ipf
614 þhpt{Using emx options}
615þelse
616 section þref{Using emx options}
617þendif
618 for details.
619
620þdescription
621þitem -a*
622 [DOS] Enable dangerous features
623
624þitem -c
625 Disable core dumps caused by signals and exceptions
626
627þitem -d
628 [DOS] Don't use extended memory
629
630þitem -e
631 [DOS] Redirect standard error to standard output
632
633þitem -h#
634 Set file handle limit
635
636þitem -n
637 [OS/2] Suppress exception popups
638
639þitem -o
640 [DOS] Send the register dump of an exception to stdout instead of
641 the þtt{CON} device
642
643þitem -p
644 [DOS] Don't use low memory (lower Megabyte)
645
646þitem -q
647 Quote all arguments passed to child processes
648
649þitem -s#
650 [DOS] Set stack size (KByte)
651
652þitem -t
653 Truncate file names to 8.3 format
654
655þitem -x
656 [OS/2] Don't suppress wildcard expansion and response files if the
657 `MKS Korn shell' method of passing command line arguments is
658 used
659
660þitem -C#
661 [DOS] Commit memory
662
663þitem -E
664 Run debuggee in same session
665
666þitem -K
667 Avoid using DosKillThread
668
669þitem -L
670 [DOS] Disable preloading of pages from the executable file
671
672þitem -Z
673 [DOS] Don't zero-fill pages. This option is used for testing
674þenddescription
675þendlist
676
677þh3 Examples
678
679þexample
680emxbind \emx\bin\emxl myprog -s16384 -p
681þendexample
682
683 This example will bind þtt{myprog} and emxl.exe into myprog.exe.
684 The stack size will be set to 16384 KByte (under DOS) if this value
685 is not overridden by EMXOPT when myprog.exe is run. The program
686 will be able to run DOS programs. This example can be abbreviated
687 to
688
689þexample
690emxbind myprog -s16384 -p
691þendexample
692
693 To create an .exe file whose base name is different from the base
694 name of the a.out file, invoke emxbind this way:
695
696þexample
697emxbind \emx\bin\emxl myprog testprog -s16384 -p
698þendexample
699
700 This example will create þtt{testprog.exe}. This example can be
701 abbreviated t6o
702
703þexample
704emxbind -o testprog myprog -s16384 -p
705þendexample
706
707
708þh2 Changing the type of an .exe file
709þlabel -e command
710þlabel Change the type of an .exe file
711þi2 -e command
712
713 You can change the application type after creating an .exe file with
714 emxbind. For instance, this can be used after creating an .exe file
715 with GCC. Exactly one of the options -f, -p and -w must be given.
716 Note that you can set the application type while creating an .exe
717 file with the -b command.
718
719 þbf{Usage:}
720
721þindent
722 þsy{emxbind -e <emxbind_options> <program_file>[.exe]}
723þendindent
724
725þlist
726þitem <emxbind_options>
727
728 The following options can be given to emxbind. They must appear at
729 the beginning of the emxbind arguments.
730
731þdescription
732þitem -e
733
734 change the type of an .exe file
735
736þitem -f
737
738 set application type to `full screen'
739
740þitem -p
741
742 set application type to `Presentation Manager'
743
744þitem -q
745
746 don't display emxbind banner line
747
748þitem -w
749
750 set application type to `windowed'
751
752þenddescription
753
754 Exactly one of the options -f, -p and -w must be given.
755
756þitem <program_file>
757
758 path name of the bound .exe file to be changed. The default
759 extension is .exe
760
761þendlist
762
763 Example:
764
765þexample
766gcc -o myprog.exe myprog.c
767emxbind -ep myprog
768þendexample
769
770 Alternatively, you can create a file named myprog.def containing
771
772þexample
773NAME WINDOWAPI
774þendexample
775
776 and invoke GCC with the following command line:
777
778þexample
779gcc -o myprog.exe myprog.def
780þendexample
781
782þh2 Extracting the a.out file from a bound .exe file
783þlabel Extract the a.out file from a bound .exe file
784þi2 -x command
785
786 þbf{Usage:}
787
788þindent
789 þsy{emxbind -x [<emxbind_options>] <input_file>[.exe] <output_file>}
790þendindent
791
792þlist
793þitem <emxbind_options>
794
795 The following options can be given to emxbind. They must appear at
796 the beginning of the emxbind arguments.
797
798þdescription
799þitem -q
800
801 don't display emxbind banner line
802
803þitem -x
804
805 extract a.out file
806
807þenddescription
808
809þitem <input_file>
810
811 path name of a bound .exe file to be read. The default extension
812 is .exe
813
814þitem <output_file>
815
816 path name of the a.out file to be created
817
818þendlist
819
820 After extracting the a.out file from an .exe file which was created
821 using a core dump file, you should not use that file for creating an
822 .exe file. Use the -u command if you want to replace emx.exe,
823 emxl.exe or emxd.exe contained in a bound .exe file.
824
825 The relocation information is removed by emxbind while binding an
826 .exe file. Therefore, the a.out file extracted from a bound .exe
827 file does not include relocation information. This applies to
828 dynamic link libraries and a.out files linked with the -R option of
829 þhpt{ld}. Import information will be lost.
830
831þh2 Displaying and changing the emx options of a bound .exe file
832þlabel Change the emx options of a bound .exe file
833þlabel Display the emx options of a bound .exe file
834þi2 -a command
835þi2 -i command
836
837 emxbind also can display or change the emx options of a bound .exe
838 file. Note that the -i option was called -s in previous versions of
839 emxbind.
840
841 þbf{Usage (showing options):}
842
843þindent
844 þsy{emxbind -i [<emxbind_options>] <program_file>[.exe]}
845þendindent
846
847 þbf{Usage (altering options):}
848
849þindent
850 þsy{emxbind -a [<emxbind_options>] <program_file>[.exe] [<emx_options>]}
851þendindent
852
853þlist
854þitem <emxbind_options>
855
856 The following options can be given to emxbind. They must appear at
857 the beginning of the emxbind arguments.
858
859þdescription
860þitem -a
861
862 change emx options
863
864þitem -q
865
866 don't display emxbind banner line
867
868þenddescription
869
870þitem <program_file>
871
872 path name of a bound .exe file to be read or changed,
873 respectively. The default extension is .exe
874
875þitem <emx_options>
876
877 remove the options if empty, otherwise put these options into the
878 .exe file (see also the þhpt{-b command})
879þendlist
880
881
882þh2 Updating emx.exe in a bound .exe file
883þlabel Update emx.exe in a bound .exe file
884þi2 -u command
885
886 emxbind also can replace the DOS loader in an existing bound .exe
887 file. You should use this only if you can't rebuild the .exe file
888 because you don't have the a.out file. Note that you usually have
889 to re-link your program when using a new release of emx due to
890 differences in the system interface.
891
892 þbf{Usage:}
893
894þindent
895 þsy{emxbind -u [<emxbind_options>] <emx>[.exe] <program_file>[.exe]}
896þendindent
897
898þlist
899þitem <emxbind_options>
900
901 The following options can be given to emxbind. They must appear at
902 the beginning of the emxbind arguments.
903
904þdescription
905þitem -q
906
907 don't display emxbind banner line
908
909þitem -u
910
911 replace DOS loader
912
913þenddescription
914
915þitem <emx>
916
917 path name of emxd.exe, emx.exe or emxl.exe. This DOS loader is
918 copied to the <program_file>. The default extension is .exe.
919
920þitem <program_file>
921
922 path name of the bound .exe file to be changed. The default
923 extension is .exe. Better make a backup copy of the file before
924 using þtt{emxbind -u}.
925
926þendlist
927
928
929þh2 Stripping the symbol table from a bound .exe file
930þlabel Strip the symbol table from a bound .exe file
931þi2 -s command
932þlabel -s command
933
934 emxbind can also be used to remove the symbol table from a bound
935 .exe file
936þif ipf
937 (þhpt{strip}
938þelse
939 strip.exe
940þendif
941 cannot be used on .exe files). You can also
942 strip the symbol table while creating the .exe file by using the -s
943 option with the -b command.
944
945 þbf{Usage:}
946
947þindent
948 þsy{emxbind -s [<emxbind_options>] <program_file>[.exe]}
949þendindent
950
951þlist
952þitem <emxbind_options>
953
954 The following options can be given to emxbind. They must appear at
955 the beginning of the emxbind arguments.
956
957þdescription
958þitem -q
959
960 don't display emxbind banner line
961
962þitem -s
963
964 strip symbol table
965
966þenddescription
967
968þitem <program_file>
969
970 path name of the bound .exe file to be changed. The default
971 extension is .exe. If you cannot recreate the .exe file, make a
972 backup copy of the file before using þtt{emxbind -s}.
973þendlist
974
975þi1
976
977þh2 Module definition files
978þlabel module definition file
979þlabel module definition files
980
981 emxbind reads LINK386 compatible module definition files. In the
982 following list of available þhpt{module definition statements},
983 optional parts are enclosed in brackets. Case is ignored for
984 keywords (though IBM says you should use upper case for keywords).
985 See below a list of þhpt{reserved words}. You cannot use keywords
986 for function names, module names etcþ. In case of a conflict,
987 enclose the offending name in single or double quotes. Quotes are
988 also required if a name contains a special character such as blank,
989 tab, `@', `=', `.' or `;'. Lines starting with a semicolon are
990 treated as comment lines and are completely ignored. Numbers can be
991 given in decimal, octal or hexadecimal, using C syntax.
992
993þh3 Module definition statements
994þlabel module definition statements
995
996þlist
997þitem þsy{CODE ...}
998þkeyword CODE
999
1000 Define default attributes for code segments. Ignored by emxbind.
1001
1002þitem þsy{DATA ...}
1003þkeyword DATA
1004
1005 Define default attributes for data segments. Ignored by emxbind.
1006
1007þitem þsy{DESCRIPTION '<text>'}
1008þkeyword DESCRIPTION
1009
1010 Put a text into the .exe or .dll file. The text must be enclosed
1011 in single or double quotes. To include a single quote in single
1012 quotes or a double quote in double quotes, simply enter the quote
1013 twice. The text will be put at the start of the nonresident name
1014 table, which is put at the end of the .exe or .dll file.
1015 Typically, DESCRIPTION is used to insert a copyright message.
1016
1017 Example:
1018
1019þexample
1020DESCRIPTION 'HAL9000 -- Copyright (c) 2001 by Space Odyssey Inc.'
1021þendexample
1022
1023þitem þsy{EXETYPE ...}
1024þkeyword EXETYPE
1025
1026 Identifies the operating system. Ignored by emxbind (the
1027 operating system is always OS/2).
1028
1029þitem þsy{EXPORTS <entryname> [=<internalname>] [@<ordinal> [RESIDENTNAME|NONAME]]}
1030þkeyword EXPORTS
1031
1032 Make functions and variables visible outside the .exe or .dll
1033 file. All entry points of a dynamic link library must be exported
1034 using EXPORTS. Exporting entry points of .exe files is less
1035 common.
1036
1037 Following the EXPORTS keyword, you can enter any number of
1038
1039þindent
1040 þsy{<entryname> [=<internalname>] [@<ordinal> [RESIDENTNAME|NONAME]]}
1041þendindent
1042
1043 lines, one for each entrypoint. <entryname> is the name of the
1044 function as made visible outside of the .exe or .dll file.
1045 <entryname> is always converted to upper case. <internalname> is
1046 the name of the function as defined in your program. If
1047 =<internalname> is omitted, it is assumed to be identical to
1048 <entryname>. <internalname> is case sensitive. Exported
1049 functions not only have a name (<entryname>), they also have an
1050 ordinal number, the position within the name table. Using ordinal
1051 numbers when importing saves space and is supposed to be faster.
1052 You can assign a specific ordinal number to an exported function
1053 by entering @<ordinal>. <ordinal> is the ordinal number to be
1054 used (1 through 65535). If @<ordinal> is not given, emxbind chooses an
1055 unused ordinal number, but you won't know the ordinal number and
1056 therefore cannot use it for importing. If @<ordinal> is
1057 specified, <entryname> is by default put into the nonresident name
1058 table, which is not kept in memory while the .exe or .dll file is
1059 running or loaded, respectively. This saves space. To put
1060 <entryname> into the resident name table, enter RESIDENTNAME.
1061 Then, OS/2 will keep <entryname> in memory while the .exe or .dll
1062 file is running or loaded, respectively. This saves time.
1063 Example:
1064
1065þexample
1066EXPORTS my_qsort=qsort1 @1 RESIDENTNAME
1067 my_hsort
1068þendexample
1069
1070 Use NONAME to avoid putting <entryname> into the name tables.
1071 This may be required for dynamic link libraries which export many
1072 functions and variables.
1073
1074þitem þsy{HEAPSIZE <number>}
1075þkeyword HEAPSIZE
1076
1077 Set the size of the local heap. <number> can be þtt{MAXVAL} as
1078 well. Ignored by emxbind.
1079
1080þitem þsy{IMPORTS [<internalname>=]<modulename>.<entry>}
1081þkeyword IMPORTS
1082
1083 Define imported symbols. Ignored by emxbind. Use emximp
1084 instead.
1085
1086þitem þsy{LIBRARY [<libraryname>] [<initialization>] [<termination>]}
1087þkeyword LIBRARY INITGLOBAL INITINSTANCE TERMGLOBAL TERMINSTANCE
1088
1089 Create dynamic link library (.dll file). If LIBRARY is used, it
1090 must be the first statement of the module definition file.
1091 <libraryname> is the name of the module. The name is the first
1092 entry of the resident name table and must match the base name of
1093 the .dll file. If <libraryname> is not specified, the name of the
1094 output file sans directory and extension is used.
1095 <initialization> can be either INITGLOBAL or INITINSTANCE.
1096 INITGLOBAL causes the library initialization function to be called
1097 when the DLL is initially loaded into memory. INITINSTANCE causes
1098 the library initialization function to be called each time a
1099 process loads the DLL and each time a process referencing the DLL
1100 is started. <termination> can be either TERMGLOBAL or
1101 TERMINSTANCE. TERMGLOBAL causes the library termination function
1102 to be called when the DLL is no longer used by any process.
1103 TERMINSTANCE causes the library termination function to be called
1104 each time a process frees the DLL and each time a process
1105 referencing the DLL terminates.
1106
1107 Currently, TERMGLOBAL seems to cause the termination function not to
1108 be called at all.
1109
1110 See þhpt{_DLL_InitTerm()} for details about the library
1111 initialization function and the library termination function.
1112
1113 If <initialization> and <termination> are omitted, INITGLOBAL and
1114 TERMGLOBAL are used. If one of <initialization> and <termination>
1115 is specified, the other one defaults to an appropriate value, as
1116 shown by the following table:
1117
1118þexample
1119 ³ (no termination) ³ TERMGLOBAL ³ TERMINSTANCE
1120ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ
1121 (no initialization) ³ INITGLOBAL ³ INITGLOBAL ³ INITINSTANCE
1122 ³ TERMGLOBAL ³ TERMGLOBAL ³ TERMINSTANCE
1123ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ
1124 INITGLOBAL ³ INITGLOBAL ³ INITGLOBAL ³ INITGLOBAL
1125 ³ TERMGLOBAL ³ TERMGLOBAL ³ TERMINSTANCE
1126ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ
1127 INITINSTANCE ³ INITINSTANCE ³ INITINSTANCE ³ INITINSTANCE
1128 ³ TERMINSTANCE ³ TERMGLOBAL ³ TERMINSTANCE
1129þendexample
1130
1131 Examples:
1132
1133þexample
1134LIBRARY
1135LIBRARY INITINSTANCE
1136LIBRARY mylib
1137LIBRARY mylib INITINSTANCE TERMGLOBAL
1138þendexample
1139
1140þitem þsy{NAME [<appname>] [<apptype>] [NEWFILES]}
1141þkeyword NAME NOTWINDOWCOMPAT WINDOWAPI WINDOWCOMPAT NEWFILES LONGNAMES
1142
1143 Create an .exe file. If NAME is used, it must be the first
1144 statement. <appname> is the name of the module. The name is the
1145 first entry of the resident name table. If <appname> is not
1146 specified, the name of the output file sans directory and
1147 extension is used. <apptype> can be one of the following
1148 keywords:
1149
1150þdescription
1151þitem NOTWINDOWCOMPAT
1152
1153 the program will run full-screen
1154
1155þitem WINDOWAPI
1156
1157 the program is a Presentation Manager application
1158
1159þitem WINDOWCOMPAT
1160
1161 the program will run in a text window
1162
1163þenddescription
1164
1165 The default is WINDOWCOMPAT. <apptype> can be overridden on the
1166 emxbind command line with the -f, -p and -w options.
1167
1168 The NEWFILES keyword (LONGNAMES is an alias) is ignored, emx
1169 applications always use long file names. Examples:
1170
1171þexample
1172NAME WINDOWAPI
1173NAME myprog
1174NAME myprog NOTWINDOWCOMPAT
1175þendexample
1176
1177þitem þsy{OLD '<library>'}
1178þkeyword OLD
1179
1180 Preserve import information. Ignored by emxbind.
1181
1182þitem þsy{PROTMODE}
1183þkeyword PROTMODE
1184
1185 Executable runs only in protected mode. Ignored by emxbind.
1186
1187þitem þsy{SEGMENTS ...}
1188þkeyword SEGMENTS
1189
1190 Set segment attributes. Ignored by emxbind.
1191
1192þitem þsy{STACKSIZE <number>}
1193þlabel STACKSIZE statement
1194þkeyword STACKSIZE
1195
1196 Set the stack size for OS/2 programs. Always use this statement
1197 as the default is too small. The stack size should be 32768 or
1198 more. The stack size for DOS programs is controlled by the
1199 þhpt{-s# emx option}.
1200
1201þitem þsy{STUB '<program>'}
1202þkeyword STUB
1203
1204 Use <program> as DOS executable file. This program is run if the
1205 .exe or .dll file is started under DOS. <program> is sought in
1206 the directories listed in the EMXPATH and PATH environment
1207 variables unless the filename includes a directory. If the <emx>
1208 argument is given on the emxbind command line, the STUB statement
1209 is ignored. If <emx> is not given and the STUB statement is not
1210 present, þtt{\emx\bin\emxl.exe} is used. If that file does not
1211 exist, emxbind searches the directories listed in the EMXPATH and
1212 PATH environment variables and the current working directory for
1213 emxl.exe. Example:
1214
1215þexample
1216STUB 'emx.exe'
1217þendexample
1218þendlist
1219
1220
1221þh3 Reserved words
1222þlabel reserved words
1223
1224 The following words are reserved. You cannot use them as function
1225 names, module names, etc. unless enclosed in quotes.
1226
1227þexample
1228ALIAS INVALID PHYSICAL
1229BASE IOPL PRELOAD
1230CLASS LIBRARY PRIVATE
1231CODE LOADONCALL PRIVATELIB
1232CONFORMING LONGNAMES PROTECT
1233CONTIGUOUS MAXVAL PROTMODE
1234DATA MIXED1632 PURE
1235DESCRIPTION MOVABLE READONLY
1236DEV386 MOVEABLE READWRITE
1237DEVICE MULTIPLE REALMODE
1238DISCARDABLE NAME RESIDENT
1239DOS4 NEWFILES RESIDENTNAME
1240DYNAMIC NODATA SEGMENTS
1241EXECUTEONLY NOEXPANDDOWN SHARED
1242EXECUTE-ONLY NOIOPL SINGLE
1243EXECUTEREAD NONAME STACKSIZE
1244EXETYPE NONCONFORMING STUB
1245EXPANDDOWN NONDISCARDABLE SWAPPABLE
1246EXPORTS NONE TERMGLOBAL
1247FIXED NONPERMANENT TERMINSTANCE
1248HEAPSIZE NONSHARED UNKNOWN
1249HUGE NOTWINDOWCOMPAT VIRTUAL
1250IMPORTS OBJECTS WINDOWAPI
1251IMPURE OLD WINDOWCOMPAT
1252INCLUDE ORDER WINDOWS
1253INITGLOBAL OS2
1254INITINSTANCE PERMANENT
1255þendexample
1256
1257
1258þh1 Using emx options
1259þlabel Using emx options
1260
1261 Under DOS, emx options can be given on the emx command line:
1262
1263þindent
1264 þsy{emx [<options>] <program> [<arguments>]}
1265þendindent
1266
1267 where <program> is either a bound .exe file or an a.out file.
1268 Options marked [*] for DOS below affect only the emx program given on
1269 the command line. All other options are `sticky' and apply to all
1270 processes started by that instance of emx. Options of this type put
1271 by emxbind into the executable file are ignored when running an emx
1272 program by running emx. If you need one of these options, put them
1273 on the emx command line.
1274
1275 Under OS/2 and DOS, emx options can also be given in the EMXOPT
1276 environment variable. These options apply to all processes.
1277
1278 Moreover, you can use emxbind to put emx options into the executable
1279 file (see above for restrictions). In this case, options marked [*]
1280 below apply only to the program for which they have been set. All
1281 other options are `sticky' and apply to all processes started by the
1282 current instance of emx (unless you are running emx manually as shown
1283 above).
1284
1285 Options given on the emx command line override options given in
1286 EMXOPT. Options given in EMXOPT override options stored in the
1287 executable file.
1288
1289 The following emx options are available:
1290
1291þdescription
1292þitem -a*
1293
1294 [DOS*] Enable dangerous features: -ac makes data and the stack
1295 executable, -am enables þhpt{_memaccess()}, -aw enables write
1296 access to all memory areas, -ai enables þhpt{_portaccess()}. By
1297 default, only the .text section is executable, _memaccess() and
1298 _portaccess() are disabled. You can combine letters: for
1299 instance, -aim enables both _memaccess() and _portaccess(), -aciw
1300 enables all dangerous features. Note: -ac is automatically set
1301 in programs run with P_DEBUG mode of þhpt{spawn*()}. This is
1302 used to be able to call functions of the debuggee by putting code
1303 into the stack.
1304
1305þitem -c
1306
1307 [*] Disable core dumps caused by signals. Core dumps created by
1308 þhpt{_core()} are not disabled by -c.
1309
1310þitem -d
1311
1312 [DOS] Don't use extended memory. Only low memory (below 1 MByte)
1313 will be used. Use this if you suspect a bug in the extended
1314 memory management of emx or a bug in an extended memory manager.
1315
1316þitem -e
1317
1318 [DOS*] Redirect the standard error handle (2) to standard output
1319 (1)
1320
1321þitem -h#
1322þlabel -h# emx option
1323
1324 [DOS, OS/2*] Set file handle limit. Under DOS, the DOS file
1325 handle limit for the emx process is set to þsy{#}. The number
1326 þsy{#} must be between 10 and 255. This option is ignored for
1327 DOS versions earlier than 3.30. This option does not change the
1328 emx limit for the number of files per process -- that limit is
1329 always 40. Under OS/2, the file handle limit for the current
1330 process is set to þsy{#}. The number þsy{#} must be between 10
1331 and 65536.
1332
1333þitem -m#
1334
1335 [DOS] Select machine. -m1 selects Fujitsu FMR70 (not implemented
1336 yet), -m2 selects NEC PC-98 (not implemented yet), -m3 selects
1337 Inboard 386/PC.
1338
1339þitem -o
1340
1341 [DOS] Send the register dump of an exception to stdout. Without
1342 -o, the register dump is sent to the CON device. You need -o for
1343 redirecting the register dump to a file.
1344
1345þitem -p
1346
1347 [DOS] Don't use low memory (lower Megabyte); use this if the
1348 program runs a DOS program; not required for running emx programs
1349 (either a.out and bound .exe) unless command.com is called to run
1350 the programs (as done by the þhpt{system()} library function).
1351 If -p is not given, low memory will be used and there won't be
1352 enough low memory for running DOS programs.
1353
1354þitem -q
1355
1356 [*] All command line arguments passed to child processes will be
1357 quoted unconditionally, that is, wildcard expansion and response
1358 files won't work in child processes of processes for which the -q
1359 option is in effect.
1360
1361þitem -r*
1362
1363 [*] Prepend drive letter * to absolute path names. If a path
1364 name starts with þtt{/} but does not start with þtt{//},
1365 þtt{/dev/} or þtt{/pipe/}, * followed by a colon will be
1366 prepended. If -rd has been given, the filename þtt{\mydir\abc}
1367 will be translated to þtt{d:\mydir\abc}. Note: this option can
1368 cause unexpected effects.
1369
1370þitem -s#
1371þlabel -s# emx option
1372
1373 [DOS*] Set stack size (KByte), minimum: -s8, maximum: -s524288,
1374 default: -s8192. Note that under DOS, the heap and the stack
1375 share the same memory area. The pages not used by the stack are
1376 available for the heap. Therefore, you should use -s# if you
1377 need more than 8 MByte of heap and stack.
1378
1379þitem -t
1380
1381 [*] Truncate file names to 8.3 format. Each part of a pathname is
1382 truncated to 8.3 format by taking the first 8 characters before
1383 the dot and the first 3 characters after the dot. This is useful
1384 to compile programs on a FAT filesystem with minimal changes.
1385
1386 Without argument, -t enables truncation on all drives and for UNC
1387 pathnames.
1388
1389 The -t option takes an optional argument, listing the names of the
1390 drives on which file names should be truncated. The special drive
1391 name `þtt{/}' controls whether to truncate UNC pathnames. With
1392 `þtt{-tc/}', for instance, file names on drive C and UNC pathnames
1393 will be truncated.
1394
1395 If the argument of the -t option is `þtt{-}', truncation is
1396 disabled for all drives and for UNC pathnames. This is the
1397 default setting. If the argument starts with `þtt{-}', truncation
1398 is disabled on all drives listed. With `þtt{-t -t-d}', for instance,
1399 UNC pathnames and file names on all drives except
1400 drive D will be truncated.
1401
1402þitem -x
1403
1404 [OS/2] Don't suppress wildcard expansion and response files if
1405 the `MKS Korn shell' method of passing command line arguments is
1406 used.
1407
1408þitem -C#
1409þlabel -C# emx option
1410
1411 [DOS*] Commit memory. By default, memory is allocated as soon as
1412 a page is accessed. If there isn't enough memory (and swap
1413 space), the process is terminated. With -C#, memory is allocated
1414 when creating the process and when enlarging the data segment
1415 with þhpt{brk()} and þhpt{sbrk()}. If there isn't enough memory
1416 (and swap space), the process brk(), sbrk(), þhpt{malloc()}
1417 etc. return an error. The number þsy{#} specifies how many KByte
1418 should be allocated for the stack. If þsy{#} is omitted, 0 is
1419 used. The -C# option is not yet completely implemented -- if an
1420 allocation request succeeds partly, the allocated pages are not
1421 freed.
1422
1423þitem -E
1424
1425 [OS/2*] Run debuggee in same session. By default, a debugger for
1426 emx (such as GDB) runs the child process in a separate session.
1427 The P_NOSESSION flag of þhpt{spawn*()} has the same effect as
1428 -E.
1429
1430 [DOS] Don't check for 387 coprocessor. Assume no coprocessor is
1431 present. This option is used for testing.
1432
1433þitem -F
1434
1435 [DOS] Use fast A20 switching. By default, the standard method
1436 for switching A20 is used. A faster method is available on some
1437 machines. That method will be used if the -F option is present.
1438
1439þitem -K
1440
1441 [OS/2*] Don't use DosKillThread. Due to bugs in OS/2,
1442 DosKillThread may cause problems. emx.dll automatically avoids
1443 using DosKillThread for OS/2 2.1 and older. For OS/2 2.11 and
1444 later, you can use the -K option to disable usage of
1445 DosKillThread. Currently, DosKillThread is not used by emx.dll
1446 and this option does not have any effect.
1447
1448þitem -L
1449
1450 [DOS*] Disable preloading of pages from the executable file. By
1451 default, the complete code and data areas are read into memory
1452 before a program is started. If there is not enough memory, no
1453 pages are preloaded. With -L (or if not enough memory is
1454 available), pages are loaded as soon as they are accessed.
1455
1456þitem -O
1457
1458 [DOS] Override XMS version check. By default, emx checks for XMS
1459 version number 2.00 or later and for XMS driver revision 2.06 or
1460 later, as older himem.sys drivers don't work correctly. You can
1461 override this check by giving the -O option (for drivers using a
1462 different revision numbering scheme), but emx may not work with
1463 your XMS driver, anyway. Actually, emx has not been tested with
1464 himem.sys 2.05; 2.04 fails, 2.06 works.
1465
1466þitem -P
1467
1468 [DOS] Use patched code for A20 switching. There is a patch area
1469 in emx.exe where you can put alternate code for switching A20.
1470 The -P option enables the code in the patch area.
1471
1472þitem -S#
1473
1474 [DOS] Enable the þhpt{emx kernel debugger}. Use the -S option to
1475 operate the debugger through the keyboard and display. If you
1476 want to debug using a terminal, enter -S1 to use COM1, -S2 to use
1477 COM2.
1478
1479þitem -V
1480
1481 Display emx version. On program start, the emx version will be
1482 displayed.
1483
1484þitem -Z
1485
1486 [DOS*] Don't zero-fill pages. This option is used for testing.
1487
1488þenddescription
1489
1490þh1 More emx utilities
1491
1492þif ipf
1493
1494þdescription
1495þitem þhpt{emxaout}
1496
1497 Convert .obj files to .o files
1498
1499þitem þhpt{emxcat}
1500
1501 Concatenate source files
1502
1503þitem þhpt{emxexp}
1504
1505 Create export list from object files and libraries
1506
1507þitem þhpt{emximp}
1508
1509 Create import libraries
1510
1511þitem þhpt{emxload}
1512
1513 Preload executables to speed up compilation
1514
1515þitem þhpt{emxomf}
1516
1517 Convert .o files to .obj files
1518
1519þitem þhpt{emxomfar}
1520
1521 Manage .lib files
1522
1523þitem þhpt{emxomfld}
1524
1525 Call LINK386 like ld
1526
1527þitem þhpt{emxrev}
1528
1529 Display emx revision index
1530
1531þitem þhpt{emxtsf}
1532
1533 Create .tsf files for TRCUST
1534
1535þitem þhpt{listomf}
1536
1537 List an .obj or .lib file
1538
1539þitem þhpt{updt}
1540
1541 Update files
1542
1543þenddescription
1544þendif
1545
1546þh2 emxaout
1547þlabel emxaout
1548þindex emxaout
1549þkeyword emxaout
1550
1551 The emxaout tool converts OMF object files (.obj files) to a.out
1552 object files (.o files). The converted files can be used with the
1553 Unix-style linker þhpt{ld}. By using emxaout, you can create .o
1554 files with MASM 6.0.
1555
1556þindent
1557 þsy{emxaout [-u] [-o <output_file>] <input_file>}
1558þendindent
1559
1560 Convert the OMF file <input_file> to a.out format. The default
1561 extension for <input_file> is .obj. If the -o option is used, the
1562 a.out file is written to <output_file>. Otherwise, the name of the
1563 output file is constructed by replacing the extension of
1564 <input_file> with .o.
1565
1566 The following option is available:
1567
1568þlist
1569þitem -u
1570
1571 Don't add leading underscores to symbol names. By default,
1572 emxaout prepends an underscore to every symbol name.
1573
1574 When using the þtt{PROC C}, þtt{PROTO C} and þtt{EXTERNDEF C}
1575 directives of MASM 6.0, you should use the -u option of emxaout
1576 because MASM prepends an underscore to symbols defined with those
1577 directives.
1578
1579þendlist
1580
1581 The OMF file must have 32-bit OS/2 format, that is, you should use
1582 the following MASM directives:
1583
1584þexample
1585.386
1586.MODEL FLAT
1587þendexample
1588
1589 emxaout discards debugging information.
1590
1591
1592þh2 emxcat
1593þlabel emxcat
1594þindex emxcat
1595þkeyword emxcat
1596
1597 The emxcat tool concatenates assembler or C source files. This is
1598 used for building emxwrap.dll.
1599
1600þindent
1601 þsy{emxcat [-D<symbol>]... -o <output_file> <input_file>...}
1602þendindent
1603
1604 All the þsy{<input_file>}s are concatenated and written to
1605 <output_file>. If the output file is included in the input files,
1606 it is not copied; emxcat simply compares the filenames, therefore
1607 it's possible to fool emxcat and make it copying until the disk is
1608 full.
1609
1610 Your code should not depend on the order in which the files are
1611 copied to the output file. A different version of emxcat may copy
1612 the files files in a different order.
1613
1614 At the very beginning of the output file, the symbols given on the
1615 command line are defined. Note that there must not be a space
1616 between -D and the name of the symbol.
1617
1618 #include statements are collected at the start of the output file.
1619 The (partial) order of the include files is maintained. If there is
1620 an inconsistency in the order of include files in different input
1621 files, emxomf prints a warning message. For instance, this happens
1622 for the following three input files:
1623
1624þexample
1625/* file1.c */
1626#include "a.h"
1627#include "b.h"
1628
1629/* file2.c */
1630#include "b.h"
1631#include "c.h"
1632
1633/* file3.c */
1634#include "c.h"
1635#include "a.h"
1636þendexample
1637
1638 The statement
1639
1640þexample
1641#include <sys/emx.h>
1642þendexample
1643
1644 is treated specially: it always precedes all other #include
1645 statements if present in one of the input files. (The
1646 þtt{<sys/emx.h>} header no longer exists; it had to be included
1647 before any other headers.)
1648
1649 When concatenating .s files, lines starting with þtt{CONST_} are
1650 omitted if already copied to the output file -- only the first
1651 instance is retained.
1652
1653 All macros þtt{#define}d by an input file are #undefined after
1654 copying the input file. Constants starting with þtt{INCL_} are an
1655 exception and are collected at the start of the output file, before
1656 the #include statements.
1657
1658 emxcat leaves alone #define and #include statements which do not
1659 start at the first column of the line. If you put blanks before
1660 #define and #include, emxcat copies these statements to the output
1661 file without treating them specially.
1662
1663
1664þh2 emxexp
1665þlabel emxexp
1666þindex emxexp
1667þkeyword emxexp
1668
1669 The emxexp tool creates an export list for a module definition file
1670 from object files and libraries. This is used for building dynamic
1671 link libraries written in C++.
1672
1673þindent
1674 þsy{emxexp [-n] [-u] [-o[<ordinal>]] <input_file>...}
1675þendindent
1676
1677 For each public symbol (except for uninitialized variables unless
1678 the -u option is given) of the
1679 input files (which can be .o, .a, .obj or .lib files), emxexp prints
1680 to the standard output an export definition for the EXPORTS
1681 statement of a module definition file. For mangled names, a comment
1682 is generated which shows the demangled name. The following options
1683 are available:
1684
1685þlist
1686þitem þsy{-n}
1687
1688 Add the NONAME keyword to each export definition to keep LINK386
1689 from putting the name into the name tables. This is required for
1690 dynamic link libraries which export too many names.
1691
1692þitem þsy{-o[<ordinal>]}
1693
1694 Add ordinal numbers to the export definitions. If <ordinal> is
1695 given, ordinal numbers will start with that number. Otherwise,
1696 ordinal numbers will start with 1.
1697
1698þitem þsy{-u}
1699
1700 Also export unitialized variables. Each uninitialized variable
1701 encountered in the input files is exported only once. If you
1702 concatenate export lists created by multiple runs of emxexp, you
1703 have to remove duplicate exports of uninitialized variables
1704 yourself. Therefore, it is recommended to give all the input files
1705 on the command line of a single emxexp invocation. By default,
1706 uninitialized variables are not exported.
1707
1708þendlist
1709
1710
1711þh2 emximp
1712þlabel emximp
1713þlabel (I1)
1714þlabel (I2)
1715þindex emximp
1716þkeyword emximp
1717
1718 emximp manages files required for importing functions from dynamic
1719 link libraries.
1720
1721 Three different methods for importing are used for the two methods
1722 of creating executable files. When using ld and emxbind, there are
1723 two methods for importing:
1724
1725þdescription
1726þitem (I1)
1727
1728 The import library contains a small piece of code for each
1729 function which loads the AL register with the number of argument
1730 words and jumps to the imported function. Information on
1731 imported functions is stored in tables in the text segment of
1732 the program. þhpt{emxbind} reads these tables to create
1733 appropriate fixups in the .exe file. When an imported function
1734 is called while running the resulting program under DOS, an
1735 error message will be displayed and the program will be
1736 terminated. Data cannot be imported with method (I1). You have
1737 to use the -R option of þhpt{ld}.
1738
1739þitem (I2)
1740
1741 The import library does not contain code for import definitions.
1742 Instead, it contains special symbol table entries, which are
1743 copied to the a.out file. One of these entries makes ld create
1744 a relocatable output file. emxbind reads the symbol table and
1745 creates appropriate fixups in the .exe file. The AL register
1746 isn't loaded with the number of argument words. The program
1747 will be aborted (protection violation) when an imported function
1748 is called under DOS. The -R option of ld is automatically
1749 turned on when referencing an import definition of type (I2).
1750
1751þenddescription
1752
1753 When using emxomf and LINK386, the standard OS/2 method is used:
1754
1755þdescription
1756þitem (I3)
1757
1758 LINK386 reads a .lib import library or a module definition file
1759 to create appropriate fixups. The AL register isn't loaded with
1760 the number of argument words. The program won't run under DOS.
1761
1762þenddescription
1763
1764 Methods (I2) and (I3) are recommended unless the dynamic link
1765 library requires the AL register to be loaded with the number of
1766 argument words. os2.a uses method (I2).
1767
1768 emximp is used to create appropriate files for all these methods.
1769 Information on functions exported by dynamic link libraries is
1770 provided in emx import list files.
1771
1772 The following table summarizes the features of the three methods:
1773
1774þexample
1775Method ³ (I1) ³ (I2) ³ (I3)
1776ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ
1777Linker ³ ld ³ ld ³ LINK386
1778Import by name ³ YES ³ NO ³ YES
1779Load AL register ³ YES ³ NO ³ NO
1780Code overhead ³ YES ³ NO ³ NO
1781Catch call under DOS ³ YES ³ NO ³ NO
1782Import library type ³ .o .a ³ .a ³ .lib .def
1783Can import functions ³ YES ³ YES ³ YES
1784Can import data ³ NO ³ YES ³ YES
1785Additive fixups ³ NO ³ YES ³ YES
1786Linker options ³ -R ³ ³
1787þendexample
1788
1789þipfminitoc
1790
1791þh3 What is an emx import list file?
1792
1793 An emx import list file defines how functions can be imported from
1794 dynamic link libraries. For each function, the import list file
1795 defines the name of the function, the module name (that's the name
1796 of the dynamic link library exporting the function), either the
1797 ordinal number or the name of the function as exported by the
1798 dynamic link library, and the number of argument 32-bit words
1799 expected by the function (this is the number of arguments unless
1800 structures are passed by value).
1801
1802 For method (I1), emximp is used to turn an import list file into an
1803 .a import library which can be linked to a program using the
1804 þhpt{ld} linker. emximp either creates assembler source files (.s)
1805 or automatically calls the assembler to create object files (.o).
1806 The object files can be packed into a library with the þbf{ar}
1807 program.
1808
1809 For method (I2), emximp is used to turn an import list file (.imp
1810 file), an OMF import library (.lib file), or a module definition
1811 file (.def file) directly into an .a import library which can be
1812 linked to a program using the ld linker.
1813
1814 For method (I3), emximp can convert an import list file into a
1815 module definition file or an OMF import library. emximp can also
1816 convert a module definition file (.def file) into an OMF import
1817 library.
1818
1819 Comments in an import list file are started with a semicolon. Empty
1820 lines are ignored.
1821
1822 For each function you have to put one line into the import list
1823 file. Here's an example of an import list file:
1824
1825þexample
1826; myimport.imp
1827DosStartTimer doscalls 351 3
1828DosStopTimer doscalls 290 1
1829þendexample
1830
1831 Such a line consists of four components which are separated by one
1832 or more blanks. The first word is the name of the function, as used
1833 in C programs. The second word is the name of the DLL. The third
1834 word is either the ordinal number of the DLL entry or the name of
1835 the DLL entry. You have to use ordinal numbers for OS/2 API
1836 functions. The fourth word is the number of 32-bit words of
1837 arguments expected by the function. This is the number of arguments
1838 unless structures are passed by value.
1839
1840 A question mark used as forth word is equivalent to using the number
1841 0. A question mark should be used if the number of arguments is
1842 unknown or if the entry point is not a function (data can also be
1843 exported). Using a question mark causes a warning when creating
1844 files for method (I1).
1845
1846 An þtt{R} used as forth word causes the AL register not to be loaded
1847 with method (I1) -- this is used for functions which expect an
1848 argument in the EAX register.
1849
1850 An þtt{F} used as forth word specifies a 16-bit function. emximp
1851 adds _16_ in front of the function name to notify þhpt{emxbind} and
1852 þhpt{emxomf} of the 16-bitness of the function. References to
1853 symbols starting with _16_ are fixed up by 16:16 far pointers.
1854
1855
1856þh3 Creating an emx import list file from an OMF import library
1857
1858 To create an emx import list file from an OMF import library, type
1859
1860þindent
1861 þsy{emximp -o <output_file>.imp <input_file>.lib ...}
1862þendindent
1863
1864 <output_file> is the name of the emx import list file to be
1865 created. The name must end with .imp. <input_file> is the name of
1866 an existing import library file. The name must end with .lib. You
1867 can give one or more input filenames on the command line.
1868
1869 As the number of argument words of the functions cannot be derived
1870 from the import library, a question mark instead of a number for the
1871 number of argument words is written to the import list file.
1872
1873 When encountering a module with static code or data, emximp displays
1874 a warning message.
1875
1876þh3 Creating an emx import list file from a module definition file
1877
1878 To create an emx import list file from a module definition file, type
1879
1880þindent
1881 þsy{emximp -o <output_file>.imp <input_file>.def ...}
1882þendindent
1883
1884 <output_file> is the name of the emx import list file to be created.
1885 The name must end with .imp. <input_file> is the name of an
1886 existing module definition file. The name must end with .def. You
1887 can give one or more input filenames on the command line.
1888
1889 As the number of argument words of the functions cannot be derived
1890 from the module definition file, a question mark instead of a number
1891 for the number of argument words is written to the import list
1892 file.
1893
1894
1895þh3 Creating an emx import library for method (I1)
1896
1897 To create an emx import library for method (I1), type
1898
1899þindent
1900 þsy{emximp [-a<assembler>] [-b<base_name>|<prefix_length>] [-p<module>]...} þbreak
1901 þsy{ [-s] <input_file>.imp ...}
1902þendindent
1903
1904 <input_file> is the name of the import list file. The name must end
1905 with .imp. You can give one or more input filenames on the command
1906 line.
1907
1908 The names of the output files are either taken from the import list
1909 file or automatically generated by emximp. A line in starting with
1910 `+' starts a new assembly language file or object file (module).
1911 The name of the output file is given after the `+':
1912
1913þexample
1914+os2mem1.s ; start a new output file
1915þendexample
1916
1917 This feature is used only for method (I1). All the functions
1918 defined in one module are linked if at least one of the functions is
1919 referenced.
1920
1921 It's possible to let emximp automatically write one file per
1922 function. The output filenames are constructed by appending the
1923 ordinal number or a sequential number to a fixed prefix or to a
1924 prefix of the DLL name. To let emximp automatically choose output
1925 filenames, use the -b command line option. If -b is given, the
1926 import list file must not contain lines starting with `+'. The
1927 argument of the -b option is either a number or a string. If the
1928 argument is a string, that string is used as base name of the output
1929 files. If the argument is a number, that many characters are taken
1930 from the start of each DLL name to create the base name of the
1931 output file. A number is appended to the base name. If -s is
1932 given, a sequential number is appended, starting with the number 1.
1933 The number is incremented for each output file. If -s is not given,
1934 the ordinal number of the function is appended; giving entry names
1935 instead of ordinal numbers in the import list file is not allowed
1936 for that reason. Note that appending ordinal numbers to the names
1937 may cause problems (output for different functions written to the
1938 same file) if multiple DLLs are used in the import list file and the
1939 argument of the -b option is a string (or too small a number to make
1940 the prefixes unique). These problems also occur if the import list
1941 file defines multiple functions to refer to the same entry point.
1942 The extension of the output files is .o if the -a option is used, .s
1943 otherwise.
1944
1945 By default, emximp creates assembler source files. emximp can
1946 automatically call an assembler to assemble the output files. This
1947 feature is turned on by the -a command line option. The argument of
1948 the -a option is the name of the assembler (there must be no blanks
1949 between -a and the argument). If the argument is omitted,
1950 þtt{as.exe} is used. The default extension is .exe, the program
1951 will be sought in the directories listed in the PATH environment
1952 variable.
1953
1954 The object files will have the same name as the assembler source
1955 files, with the .s extension replaced by .o.
1956
1957 Under OS/2, the assembly language files are not actually written, a
1958 pipe is used instead. Under DOS, the assembly language files
1959 created by emximp will be deleted automatically after running the
1960 assembler.
1961
1962 To save space in the executable file, DLL names which are often used
1963 should be put into separate files, see above for an example. Use
1964 the -p option of emximp to use separate files for the DLL names.
1965 The argument of the -p option is the name of the DLL. emximp
1966 prepends þtt{__os2_} to the DLL name for making the label used for
1967 referencing the DLL name. You can use multiple -p options. Here's
1968 how to write a separate file which defines a DLL name:
1969
1970þexample
1971 .globl __os2_pmgpi
1972 .text
1973__os2_pmgpi:
1974 .asciz "PMGPI"
1975þendexample
1976
1977 This file declares the DLL name PMGPI. Use the þtt{-p pmgpi} option
1978 of emximp to tell emximp to create code that references this file.
1979
1980
1981 þbf{Technical details:}
1982
1983 Let's examine the .s file created by emximp for the DosSelectSession
1984 function.
1985
1986þexample
19871) .globl _DosSelectSession
19882) .align 2, 144
19893) _DosSelectSession:
19904) movb $1, %al
19915) 1: jmp __os2_bad
19926) 2: .long 1, 1b+1, L1, 38
19937) L1: .asciz "sesmgr"
19948) .stabs "__os2dll", 23, 0, 0, 2b
1995þendexample
1996
1997 Line 1 is obvious: it exports _DosSelectSession from os2.a so
1998 that þhpt{ld} will link this module when _DosSelectSession is
1999 referenced.
2000
2001 Line 2 is a speed hack: the 386 performs much better when jumping to
2002 an address which is an integral multiple of 4.
2003
2004 Line 3 declares _DosSelectSession. Your program calls this code
2005 when calling DosSelectSession.
2006
2007 Line 4 stores the number of arguments in the AL register (or rather,
2008 the number of argument 32-bit words).
2009
2010 Line 5 jumps to __os2_bad which displays an error message and stops
2011 execution. This is what happens if you run the program on DOS.
2012
2013 Line 6 creates a small table which is read by þhpt{emxbind}: It
2014 consists of four words:
2015
2016þitemize
2017þitem
2018
2019 a word of flag bits. Currently, only bit 0 is defined: it's 0 for
2020 import by name, 1 for import by ordinal.
2021
2022þitem
2023
2024 the address of the word to be fixed up for referencing the DLL.
2025 `þtt{1b+1}' means `local label 1, looking backwards, add one to
2026 address'. Therefore, the address used by the þtt{JMP} instruction
2027 is used.
2028
2029þitem
2030
2031 a pointer to the name of the module (null-terminated ASCII string).
2032 For often used names the pointer should point to a string in a
2033 separate, common module to save space, see the -p option.
2034
2035þitem
2036
2037 the ordinal number or a pointer to the name of the entry point
2038 (null-terminated ASCII string), respectively, depending on bit 0 of
2039 the flags word.
2040
2041þenditemize
2042
2043 Line 7 defines the module name pointed to by the table.
2044
2045 Line 8 is the tricky part: it contains a special symbol table entry
2046 to make ld build a table named __os2dll which contains pointers to
2047 all the small tables (þtt{2b} is the address of the small table).
2048 See also crt0.s, where the table is initialized. crt0 contains a
2049 pointer to the table in a fixed location so that emxbind can find
2050 the table of pointers, read all the small tables (as described
2051 above) and create the necessary OS/2 fixups.
2052
2053
2054þh3 Creating an a.out import library for method (I2)
2055
2056 To create an a.out import library for method (I2), type
2057
2058þindent
2059 þsy{emximp [-m] -o <output_file>.a <input_file>.def ...} þbreak
2060 þsy{emximp [-m] -o <output_file>.a <input_file>.imp ...} þbreak
2061 þsy{emximp [-m] -o <output_file>.a <input_file>.lib ...} þbreak
2062þendindent
2063
2064 <output_file>.a is the name of the archive file to be created. The
2065 name must end with .a.
2066
2067 <input_file>.def is the name of a module definition file containing
2068 one or more EXPORTS statements.
2069
2070 <input_file>.imp is the name of an emx import list file. The name
2071 must end with .imp.
2072
2073 <input_file>.lib is the name of an import library (OMF). The name
2074 must end with .lib. Modules in the input files which are not import
2075 definitions are ignored.
2076
2077 You can give one or more input filenames on the command line; all
2078 input file must be of the same type, either .imp or .lib.
2079
2080 All import records of the input files are converted to import
2081 modules for method (I2). After creating the output file, you should
2082 run þtt{ar s} on the output file to increase linking efficiency.
2083
2084 When encountering a module with static code or data in a .lib file,
2085 emximp displays a warning message. You may have to extract those
2086 modules from the library, convert them with þhpt{emxaout}, and add
2087 them to the target library with þhpt{emxomfar}.
2088
2089 The -m option directs emximp to add code which calls the
2090 þtt{_mcount} function. This is used for profiling; þtt{os2_p.a} is
2091 created with the -m option of emximp.
2092
2093 þbf{Technical details:}
2094
2095 A member named __.IMPORT is added to the archive. GNU þhpt{ld} (the
2096 one ported to emx) has been patched to turn on relocatable output if
2097 it finds a member named __.IMPORT in a library. As only the
2098 __.SYMDEF member is scanned if present, __.IMPORT defines the
2099 special symbol þtt{__IMPORT!}. When patched GNU ld finds the
2100 definition of a symbol named þtt{__IMPORT!} in the __.SYMDEF member,
2101 relocatable output is turned on. (Relocatable output can also be
2102 turned on by using the -R option of þbf{ld}.)
2103
2104 For each function in the input files, emximp adds an a.out-type
2105 module to the output file. Such a module defines two symbols
2106 (unless the -m option is used). One symbol defines the entry point,
2107 the other symbol gives information on the DLL name and the ordinal
2108 number or procedure name. For instance, for
2109
2110þexample
2111LIBRARY doscalls
2112EXPORTS DosBeep @286
2113þendexample
2114
2115 the two symbols `þtt{_DosBeep}' and `þtt{_DosBeep=doscalls.286}' are
2116 defined. The symbol types 0x69 and 0x6b are used, respectively.
2117 GNU ld has been patched to keep references to symbols of type 0x69
2118 in the relocation table.
2119
2120 þhpt{emxbind} scans the relocation table for references to symbols
2121 of type 0x69 and scans the symbol table for a matching symbol of
2122 type 0x6b which defines the entry point.
2123
2124þh3 Creating an OMF import library for method (I3)
2125
2126 To create an OMF import library for method (I3), use one of the
2127 following invokations of emximp, depending on the input format:
2128
2129þindent
2130 þsy{emximp [-p#] -o <output_file>.lib <input_file>.def ...} þbreak
2131 þsy{emximp [-p#] -o <output_file>.lib <input_file>.imp ...}
2132þendindent
2133
2134 <output_file>.lib is the name of the import library file to be
2135 created. The name must end with .lib.
2136
2137 <input_file>.def is the name of a module definition file containing
2138 one or more EXPORTS statements.
2139
2140 <input_file>.imp is the name of an emx import list file.
2141
2142 You can give one or more input filenames on the command line.
2143
2144 All the import list files must define functions that are in the same
2145 dynamic link library. Lines start with `+' are ignored.
2146
2147 The number of argument words is lost after that conversion, that is,
2148 you cannot recreated the import list file using emximp.
2149
2150 The -p# option sets the page size to # bytes (16, 32, 64, ...,
2151 32768). If -p is not given, a page size of 16 bytes will be used.
2152 Increase the page size if emximp complains about too big a library.
2153 If emximp doesn't complain, you shouldn't increase the page size to
2154 save disk space.
2155
2156þh3 Creating a module definition file for method (I3)
2157
2158 To create a þhpt{module definition file} for method (I3), type
2159
2160þindent
2161 þsy{emximp -o <output_file>.def <input_file>.imp ...}
2162þendindent
2163
2164 <output_file> is the name of the module definition file to be
2165 created. The name must end with .def.
2166
2167 <input_file> is the name of an emx import list file. The name must
2168 end with .imp. You can give one or more input filenames on the
2169 command line.
2170
2171 All the import list files must define functions that are in the same
2172 dynamic link library. Lines start with `+' are ignored.
2173
2174 The number of argument words is lost after that conversion, that is,
2175 you cannot recreated the import list file using emximp.
2176
2177
2178þh3 emximp options
2179
2180 The -q option suppresses warnings about `impure' import libraries,
2181 that is, import libraries which also contain code.
2182
2183
2184þh2 emxload
2185þlabel emxload
2186þindex emxload
2187þkeyword emxload
2188
2189 The emxload tool preloads OS/2 programs. Preloading programs speeds
2190 up loading these programs if you have enough memory. If you have
2191 too little memory, preloading may degrade performance. Preloading
2192 is especially useful with a compiler such as GCC which runs many
2193 processes to complete its task.
2194
2195 emxload starts the emxload server process (emxload.exe contains both
2196 the client program described here and the server program). The
2197 server process runs until stopped with the -q option of emxload.
2198
2199 When using emxload to load a program which is already preloaded by
2200 emxload, the expiry time of that program will be reset to the new
2201 value.
2202
2203 There are library functions for using the emxload server in your
2204 programs. See þhpt{_emxload_prog()} etc. for details.
2205
2206 The GNU C compiler keeps itself in memory for þpa{N} minutes if the
2207 environment variable GCCLOAD is set to þpa{N}. For example, to keep
2208 the passes of GCC in memory for 5 minutes, type
2209
2210þexample
2211SET GCCLOAD=5
2212þendexample
2213
2214 The following programs use GCCLOAD: gcc.exe, cpp.exe, cc1.exe,
2215 cc1plus.exe, cc1obj.exe, as.exe, and emxomf.exe.
2216
2217
2218þindent
2219 þsy{emxload [-m<limit>] [-s<limit>] [-e] [-u[w]]} þbreak
2220 þsy{ [-gcc] [-g++] [-gobjc] [-gnat] [-omf] <program>...}
2221þendindent
2222
2223 All the þsy{<program>}s are preloaded. The default extension is
2224 .exe. There are shortcuts for preloading the GNU C compiler:
2225
2226þlist
2227þitem þsy{-gcc}
2228
2229 This option preloads the complete GNU C compiler for compiling C
2230 programs and generating a.out-style output. The following programs
2231 will be preloaded: þtt{gcc.exe}, þtt{cpp.exe}, þtt{cc1.exe},
2232 þtt{as.exe}, þtt{ld.exe}, and þtt{emxbind.exe}.
2233
2234þitem þsy{-g++}
2235
2236 This option preloads the complete GNU C compiler for compiling C++
2237 programs and generating a.out-style output. The following programs
2238 will be preloaded: þtt{gcc.exe}, þtt{cpp.exe}, þtt{cc1plus.exe},
2239 þtt{as.exe}, þtt{ld.exe}, and þtt{emxbind.exe}.
2240
2241þitem þsy{-gobjc}
2242
2243 This option preloads the complete GNU C compiler for compiling
2244 programs written in the Objective C programming language and
2245 generating a.out-style output. The following programs
2246 will be preloaded: þtt{gcc.exe}, þtt{cpp.exe}, þtt{cc1obj.exe},
2247 þtt{as.exe}, þtt{ld.exe}, and þtt{emxbind.exe}.
2248
2249þitem þsy{-gnat}
2250
2251 This option preloads the complete GNU Ada translator (GNAT) for
2252 generating a.out-style output. The following programs
2253 will be preloaded: þtt{gcc.exe}, þtt{gnat1.exe},
2254 þtt{as.exe}, þtt{ld.exe}, þtt{gnatbind.exe}, and þtt{emxbind.exe}.
2255
2256þitem þsy{-omf}
2257
2258 Use this option in addition to one of the options for preloading GCC
2259 to preload the programs used for generating OMF-style output. The
2260 following programs will be preloaded: emxomf.exe, emxomfld.exe,
2261 and þtt{link386.exe}.
2262
2263þendlist
2264
2265 You can use one or more of the above options. For instance, if you
2266 want to compile C and C++ programs, use
2267
2268þexample
2269emxload -gcc -g++
2270þendexample
2271
2272 This will preload þtt{gcc.exe}, þtt{cpp.exe}, þtt{cc1.exe},
2273 þtt{cc1plus.exe}, þtt{as.exe}, þtt{ld.exe}, and þtt{emxbind.exe}.
2274
2275 There are additional options for controlling the operation of emxload:
2276
2277þlist
2278þitem -m<limit>
2279
2280 Automatically unload the specified programs after þsy{<limit>}
2281 minutes. This option overrides the -s<limit> option. By default,
2282 programs are unloaded after 10 minutes.
2283
2284þitem -s<limit>
2285
2286 Automatically unload the specified programs after þsy{<limit>}
2287 seconds. This option overrides the -m<limit> option. By default,
2288 programs are unloaded after 600 seconds.
2289
2290þitem -e
2291
2292 Don't unload the specified programs automatically. This option
2293 overrides the -m<limit> and -s<limit> options. By default, emxload
2294 unloads a program after 10 minutes.
2295
2296þitem -u
2297
2298 Unload the specified programs. By default, emxload preloads the
2299 specified programs. With the -u option, all specified programs will
2300 be unloaded. Don't wait until the server has unloaded the programs.
2301
2302þitem -uw
2303
2304 Like -u, but wait until the server has unloaded the programs.
2305
2306þendlist
2307
2308 Two special calling sequences are available:
2309
2310þindent
2311 þsy{emxload -l}
2312þendindent
2313
2314 List the preloaded programs with the number of minutes and seconds
2315 left until automatic unloading.
2316
2317þindent
2318 þsy{emxload -q[w]}
2319þendindent
2320
2321 Stop the emxload server process. All preloaded programs will be
2322 unloaded. Use -qw to wait until the server is stopped. -q doesn't
2323 wait.
2324
2325
2326þh2 emxomf
2327þlabel emxomf
2328þindex emxomf
2329þkeyword emxomf
2330
2331 The emxomf tool converts a.out object files (.o files) to Object
2332 Module Formats (.obj files). The converted files can be used with
2333 the OS/2 linker link386.exe.
2334
2335 emxomf keeps itself in memory for þpa{N} minutes if the environment
2336 variable GCCLOAD is set to þpa{N}.
2337
2338þindent
2339 þsy{emxomf [-d] [-l[<symbol>]] [-g] [-q] [-s] [-u] [-p <page_size>]} þbreak
2340 þsy{ [-m <symbol>] [-i <default_lib>] [-I <idmdll>] [-D <dataseg>]} þbreak
2341 þsy{ -o <output_file> <input_file>}
2342þendindent
2343
2344 Convert a single .o or .a file (<input_file>) to an .obj or .lib
2345 file (<output_file>). There are no default extensions. If the -d
2346 option is given, the input file is deleted after successful
2347 conversion. If the input file is an archive, it is not deleted.
2348
2349þindent
2350 þsy{emxomf [-d] [-l[<symbol>]] [-g] [-q] [-s] [-u] [-x] [-p <page_size>]} þbreak
2351 þsy{ [-m <symbol>] [-O <directory>] [-r|R<response_file>]} þbreak
2352 þsy{ [-i <default_lib>] [-I <idmdll>] [-D <dataseg>] <input_file>...}
2353þendindent
2354
2355 Convert multiple .o and .a files to .obj and .lib files (more than
2356 one <input_file> can be given on the command line). The names of
2357 the output files are constructed by replacing the extension of the
2358 þsy{<input_file>}s with .obj or .lib, respectively. If the -x
2359 option is given, all members (which must be a.out modules) of
2360 archives (.a files) are converted to .obj files. The names of the
2361 output files are constructed by replacing the extension of the
2362 member names with .obj. If the -x option is not given, archives (.a
2363 files) are converted to libraries (.lib files). If the -O option is
2364 given, the output files are written to the directory <directory>. A
2365 þbf{LIB} response file <response_file> is created if you use the -r
2366 or -R option. When using -r, the response file will contain
2367 commands to add the modules to a library file, when using -R, it
2368 will contain commands to replace the modules in a library file. If
2369 the -d option is given, all the input files except for archives are
2370 deleted after successful conversion. If the -s option is given,
2371 debugging information is omitted.
2372
2373 You can put emxomf options into the environment variable EMXOMFOPT.
2374 These options will be read before the options given on the command
2375 line.
2376
2377 Options common to both calling sequences:
2378
2379þlist
2380þitem -D <dataseg>
2381
2382 Change the name of the data segment. By default, all initialized
2383 variables are put into the DATA32 segment which is a member of the
2384 DGROUP group. By using the -D option, the segment used for
2385 initialized variables can be changed. That segment won't be a
2386 member of the DGROUP. This can be used for creating dynamic link
2387 libraries with both instance data and shared data. Define all
2388 variables which should be private to the instances of the DLL in a
2389 separate source file, initialize all the variables, use the -D
2390 option of emxomf to put these variables into a separate segment
2391 and set the attributes of that segment in the module definition
2392 file to NONSHARED. All other variables will go into the default
2393 data segment, which is shared by all instances of the DLL.
2394 Alternatively, you can make variables private by default and put
2395 the shared variables into a separate segment. You have to list
2396 all the segments of class DATA in the module definition file.
2397 Example:
2398
2399þexample
2400SEGMENTS
2401 PRIV CLASS 'DATA' NONSHARED
2402 DATA32 CLASS 'DATA' SHARED
2403 BSS32 CLASS 'BSS' SHARED
2404þendexample
2405
2406 In this example, variables are shared by default. The segment
2407 PRIV contains private variables.
2408
2409þitem -g
2410
2411 Create groups for sets, as did previous versions of emxomf. This
2412 causes an extra object to be created for each set (such as
2413 þtt{__CTOR__LIST__}). By default, all sets are merged into the
2414 text object.
2415
2416þitem -i <default_lib>
2417
2418 Add default library request. LINK386 is informed that the .obj
2419 file should be linked with the library <default_lib>. If
2420 <default_lib> doesn't include a file name extension, LINK386
2421 uses the default extension .lib. You can specify multiple
2422 libraries by using multiple -i options.
2423
2424þitem -I <idmdll>
2425
2426 Change the name of the identifier manipulation DLL. That DLL is
2427 used by LINK386 to demangle C++ symbol names in error messages. A
2428 special record (IDMDLL) is inserted into the .obj file by emxomf
2429 to tell LINK386 about the name of the DLL. emxomf inserts that
2430 record only if it recognizes the input file as being compiled by
2431 G++. The default for the identifier manipulation DLL is
2432 þtt{gppdemid}. Use þtt{-I-} to suppress the insertion of the
2433 IDMDLL record.
2434
2435þitem þsy{-l[<symbol>]}
2436
2437 The module (all the modules of an archive when converting an
2438 archive) is supposed to be a library modules. A library module
2439 doesn't define a stack segment and doesn't request libraries. If
2440 <symbol> is given (following directly -l, without space), it is
2441 used as name of the entry point, that is, the function that should
2442 be called when the DLL is started. If <symbol> is not specified,
2443 no entry point will be defined. If -l and -m are missing, the
2444 module is supposed to be part of a program but not the main
2445 module. Such a module doesn't define a stack segment and doesn't
2446 have an entry point.
2447
2448þitem -m <symbol>
2449
2450 The module is supposed to be the main module of a program. A main
2451 module defines a default stack segment (0x8000 bytes) and has an
2452 entry point. <symbol> is the name of the entry point, that is,
2453 the function that should be called when the program is started.
2454 -m is used for the startup code module crt0 and should not be used
2455 for user modules. If -l and -m are missing, the module is
2456 supposed to be part of a program but not the main module. Such a
2457 module doesn't define a stack segment and doesn't have an entry
2458 point.
2459
2460þitem -p <page_size>
2461
2462 Set the page size of .lib files to <page_size> bytes (16, 32, 64,
2463 ..., 32768). If -p is not given, a page size of 16 bytes will be
2464 used. Increase the page size if emxomf complains about too big
2465 a library. If emxomf doesn't complain, you shouldn't increase
2466 the page size to save disk space.
2467
2468þitem -q
2469
2470 Suppress certain warning messages. Currently, this option
2471 suppresses the warning message for internal PC-relative
2472 relocations being ignored.
2473
2474þitem -s
2475
2476 If the -s option is given, debugging information is omitted. By
2477 default, debugging information is converted from a.out
2478 þbf{DBX}-style (with GNU extensions) to HLL version 3 format (as
2479 used by IBM's IPMD debugger of the C/C++ Tools 2.0 package and by
2480 SD386). If emxomf cannot translate debugging information, a
2481 warning message is displayed. Types not recognized by emxomf are
2482 treated as `þtt{int}' to be able to continue conversion.
2483 Restrictions:
2484
2485þitemize
2486þitem
2487
2488 The Objective C language is not supported yet.
2489
2490þitem
2491
2492 Structures (or unions) without declarator within another
2493 structure (or union) are ignored as GCC doesn't emit suitable
2494 debugging information.
2495
2496þitem
2497
2498 Variable-length automatic arrays are not supported.
2499
2500þitem
2501
2502 `þtt{long long}' and `þtt{unsigned long long}' types are
2503 translated to the following structure, as HLL version 3
2504 debugging information doesn't support 64-bit integers:
2505
2506þexample
2507struct _long_long
2508{
2509 unsigned long lo;
2510 unsigned long hi;
2511}
2512þendexample
2513
2514þitem
2515
2516 Pointer to member (C++) is not yet supported.
2517
2518þenditemize
2519
2520þitem -u
2521
2522 List all symbol table entries (stabs code and symbol name) unknown
2523 to emxomf. This option is used for debugging emxomf.
2524
2525þendlist
2526
2527
2528þh2 emxomfar
2529þlabel emxomfar
2530þindex emxomfar
2531þkeyword emxomfar
2532
2533 emxomfar is a librarian for OMF .lib files with a command line
2534 interface similar to þbf{ar} to simplify makefiles.
2535
2536þindent
2537 þsy{emxomfar [-p#] <command> <library_file> [<module>]...}
2538þendindent
2539
2540 The default extension for <library_file> is .lib. When modifying a
2541 library file, a backup file with .bak extension is created.
2542
2543 Here's a description of emxomfar commands:
2544
2545þdescription
2546þitem d
2547
2548 Delete modules from library. The module name __.SYMDEF is
2549 ignored.
2550
2551þitem m
2552
2553 Move members to the end of the archive. Not implemented in
2554 emxomfar.
2555
2556þitem p
2557
2558 Copy members to standard output. Not implemented in emxomfar.
2559
2560þitem q
2561
2562 Quick append. This command is equivalent to the r command in
2563 emxomfar.
2564
2565þitem r
2566
2567 Replace modules in library. Modules which are not in the library
2568 are added to the library. The default extension for modules is
2569 .obj.
2570
2571þitem s
2572
2573 Build the __.SYMDEF symbol table member. This command is ignored
2574 by emxomfar.
2575
2576þitem t
2577
2578 List table of contents. Use the v option to also list public
2579 symbols.
2580
2581þitem x
2582
2583 Extract modules from library. The default extension for modules
2584 is .obj.
2585
2586þenddescription
2587
2588 You can additionally use the following modifiers in the <command>
2589 argument:
2590
2591þdescription
2592
2593þitem a
2594
2595 Position after specified member. Not implemented in emxomfar
2596
2597þitem b
2598
2599 Position before specified member. Not implemented in emxomfar
2600
2601þitem c
2602
2603 Don't display warning when creating new library.
2604
2605þitem i
2606
2607 Position before specified member. Not implemented in emomfar
2608
2609þitem l
2610
2611 Create temporary file in current directory. Ignored by emxomfar
2612
2613þitem o
2614
2615 Preserve dates. Ignored by emxomfar
2616
2617þitem u
2618
2619 Don't replace members with older files (update). Ignored by
2620 emxomfar
2621
2622þitem v
2623
2624 Verbose output.
2625
2626þenddescription
2627
2628 The following option must precede <command> if used:
2629
2630þdescription
2631þitem -p#
2632
2633 Set page size to # bytes (16, 32, 64, ..., 32768). If -p is not
2634 given, a page size of 16 bytes will be used. Increase the page
2635 size if emxomfar complains about too big a library. If emxomfar
2636 doesn't complain, you shouldn't increase the page size to save
2637 disk space.
2638
2639þenddescription
2640
2641 Example:
2642
2643þexample
2644emxomfar -p32 rc newlib *.obj
2645þendexample
2646
2647
2648þh2 emxomfld
2649þlabel emxomfld
2650þindex emxomfld
2651þkeyword emxomfld
2652
2653 emxomfld is a front end to LINK386, providing an þhpt{ld}-like
2654 command line syntax for LINK386. After parsing the command line,
2655 LINK386 is called with equivalent command line arguments.
2656
2657þindent
2658 þsy{emxomfld -o <file> [-l <lib>] [-L <libdir>] [-T <base>] [-sS]} þbreak
2659 þsy{ [-Zexe] [-Zdll] [-Zstack <stack_size>] [-Zmap[=<map_file>]]} þbreak
2660 þsy{ [-O <option>] <file>...}
2661þendindent
2662
2663 The files given on the emxomfld command line are assumed to be .obj
2664 files to be linked unless the extension is .def, .lib or
2665 .res. A file having a .def extension is used as module definition
2666 file. There may be at most one module definition file. A file
2667 having a .lib extension is used as library file. A file
2668 having a .res extension is used as binary resource file; þbf{rc} is
2669 called to attach the resources to the output file.
2670
2671 Example:
2672
2673þexample
2674emxomfld -o test -lc -Lc:/mylibs test1 test2 test.def test.res
2675þendexample
2676
2677 Create file test.exe (or test.dll, depending on the contents of
2678 test.def), by linking test1.obj and þtt{obj2.obj} with c.lib. c.lib
2679 is sought in þtt{c:/mylibs}. Use the module definition file
2680 test.def. Call þbf{rc} to copy the resources from test.res to
2681 test.exe (or test.dll).
2682
2683 The following options are available:
2684
2685þlist
2686þitem þsy{-i}
2687
2688 Pass the þtt{/INFORMATION} option to LINK386, causing filenames
2689 to be displayed while linking. This is used for debugging
2690 emxomfld.
2691
2692þitem þsy{-l <lib>}
2693
2694 Link with the library þsy{<lib>}þtt{.lib}. For instance, -lc
2695 causes c.lib to be used.
2696
2697þitem þsy{-L <libdir>}
2698
2699 Add the directory <libdir> to the library search path. Libraries
2700 are sought in the directories given by -L options. emxomfld
2701 prepends the directories to the LIB environment variable.
2702
2703þitem þsy{-o <file>}
2704
2705 <file> is the output file. The default extension (.exe or .dll)
2706 is provided by LINK386. If -o is omitted, þtt{$$$} will be used.
2707
2708þitem þsy{-O <option>}
2709
2710 Pass the option <option> to LINK386. For each option to be passed
2711 to LINK386, one -O has to be used. <option> should start with a
2712 slash. Example:
2713
2714þexample
2715-O/runfromvdm
2716þendexample
2717
2718 See also the -Zlinker option of GCC.
2719
2720þitem þsy{-s}
2721
2722 Strip all symbols, including debugging information. If -s and -S
2723 are not used, emxomfld passes the þtt{/DEBUG} option to LINK386.
2724
2725þitem þsy{-S}
2726
2727 Strip debugging symbols (emxomfld strips all symbols, including
2728 debugging information, if -S is used). If -s and -S are not used,
2729 emxomfld passes the þtt{/DEBUG} option to LINK386.
2730
2731þitem þsy{-T <base>}
2732
2733 Set the base address of the text segment. This option is
2734 translated to the þtt{/BASE} option of LINK386. emxomfld
2735 automatically passes þtt{/BASE:0x10000} to LINK386 unless -T is
2736 used or a DLL is built. If neither -T nor -Zdll is used, the
2737 module definition file is read to learn whether a DLL is being
2738 built or not.
2739
2740þitem þsy{-x}
2741
2742 Discard all local symbols (this option is ignored by emxomfld).
2743
2744þitem þsy{-X}
2745
2746 Discard local symbols starting with þtt{L} (this option is ignored
2747 by emxomfld).
2748
2749þitem þsy{-Zdll}
2750
2751 Build a DLL. If the -Zdll option is present, emxomfld does not
2752 automatically pass þtt{/BASE:0x10000} to LINK386. The -Zdll
2753 option isn't necesary as a module definition file is required when
2754 building a DLL and emxomfld and emxbind read the module definition
2755 file to learn whether a DLL is to be built or not.
2756
2757þitem þsy{-Zexe}
2758
2759 If the -Zexe option is present, emxomfld deletes the output file
2760 (whose name is given on the command line) and adds .exe to the
2761 output filename. After calling LINK386, emxomfld creates an
2762 empty output file (without .exe). This feature is used for
2763 minimizing changes to Unixoid makefiles. See also the -Zexe
2764 option of GCC and ld.
2765
2766þitem þsy{-Zmap[=<map_file>]}
2767
2768 Let LINK386 write the map file <map_file>. LINK386 adds the
2769 default extension `þtt{map}'. If þsy{=<map_file>} is not
2770 specified, the name of the map file will be derived from the
2771 output file name.
2772
2773þitem þsy{-Zstack <stack_size>}
2774
2775 Set the stack size of the executable, in Kbyte. The argument of
2776 the -Zstack option is multiplied by 1024 and turned into a
2777 þtt{/STACK} LINK386 option. The number can be given in decimal,
2778 octal or hexadecimal, using C notation.
2779
2780þendlist
2781
2782
2783þh2 emxrev
2784þlabel emxrev
2785þindex emxrev
2786þkeyword emxrev
2787
2788 emxrev displays the revision number of emx DLLs (emx.dll, emxio.dll,
2789 emxlibc.dll, emxlibcm.dll, emxlibcs.dll, and emxwrap.dll). The
2790 revision number is incremented every time a changed version of a DLL
2791 is released. By looking at the revision numbers of the DLLs, you
2792 can tell which one is the newest one.
2793
2794 To display the revision number of the default emx DLLs, type
2795
2796þindent
2797 þsy{emxrev}
2798þendindent
2799
2800 The default DLLs are those used by the operating system when
2801 starting a program.
2802
2803 To display the revision number of a specific file, type
2804
2805þindent
2806 þsy{emxrev -f <file>}
2807þendindent
2808
2809 If a directory is included in <file>, append .dll to the name. If
2810 no directory is included in <file>, don't append .dll to the name.
2811
2812 To display the revision numbers of the emx DLLs in directory <dir>,
2813 type
2814
2815þindent
2816 þsy{emxrev -d <dir>}
2817þendindent
2818
2819 To display the revision numbers of the emx DLLs in all directories
2820 of drive <drive> (þtt{c:}, for instance), type
2821
2822þindent
2823 þsy{emxrev -c <drive>}
2824þendindent
2825
2826 To display the revision numbers of the emx DLLs in all directories
2827 of all hard disks, type
2828
2829þindent
2830 þsy{emxrev -a}
2831þendindent
2832
2833 To display the revision numbers of the emx DLLs in the directories
2834 listed in the LIBPATH statement of a config.sys file, type
2835
2836þindent
2837 þsy{emxrev -p <file>}
2838þendindent
2839
2840 where <file> is the name of the config.sys file.
2841
2842
2843þh2 emxtsf
2844þlabel emxtsf
2845þindex emxtsf
2846þkeyword emxtsf
2847
2848 emxtsf assists in creating .tsf files for TRCUST. TRCUST (which can
2849 be downloaded as part of the þtt{os2pdp.zip} package from the usual
2850 OS/2 archives) generates þtt{.tdf} and þtt{.tff} files from .tsf
2851 files; þtt{.tdf} files are used by OS/2's TRACE command,
2852 þtt{.tff} files are used by OS/2's TRACEFMT command.
2853
2854þindent
2855 þsy{emxtsf [-d <dll_name>] [-w <level>] <tss_file> <map_file> <def_file> <dll_name>}
2856þendindent
2857
2858 <tss_file> declares what functions are to be traced and how to
2859 format their arguments; the format of that file is described below.
2860
2861 <map_file> is the .map file created by the linker for the DLL. It's
2862 used to find out which symbols are available. This avoids errors
2863 when TRCUST is run.
2864
2865 <def_file> is the DLL's module definition file (.def file); the
2866 ordinal numbers of the EXPORTS statement will be used as minor trace
2867 codes. Functions which are not exported will be assigned minor
2868 trace codes starting at 0x7fff, counting down.
2869
2870 <dll_name> is the name of the DLL. If the -d option is not used,
2871 TRACEFMT will print the function name as is. If the -d option is
2872 used, <dll_name> followed by a colon and a space will be prefixed to
2873 the function name.
2874
2875 The -w option sets the warning level. Warning level 0 is the
2876 default setting. Warning level 1 prints the names of functions
2877 exported by the DLL but not defined in the <tss_file> to standard
2878 error. Warning level 2 additionally prints the names of functions
2879 for which no epilogue has been found.
2880
2881 emxtsf writes the output to standard output; the output should be
2882 appended to a manually created .tsf file header.
2883
2884 In <tss_file>, empty lines and lines starting with a semicolon are
2885 ignored. All remaining lines start with a letter which is followed
2886 by a space character and additional data.
2887
2888 A line starting with `þtt{G}' defines a group; all following
2889 function definitions belong to that group until another group is
2890 defined. A line starting with `þtt{T}' defines a list of event
2891 types; these event types will be used for all following function
2892 definitions until another list of event types is defined.
2893
2894Example:
2895
2896þexample
2897G IO
2898T APP,CPP
2899þendexample
2900
2901 Note that in the header of the .tsf file, each group must be defined
2902 in a þtt{GROUP} statement and each event types must be defined in a
2903 þtt{TYPELIST} statement. Both a group and a list of event types
2904 must be defined before functions can be defined.
2905
2906 A line defining a function starts with a letter which defines the
2907 return type of the function. The following return types are
2908 supported:
2909
2910þdescription
2911þitem þtt{i}
291232-bit integer
2913þitem þtt{p}
2914pointer
2915þitem þtt{v}
2916no return value (void)
2917þitem þtt{I}
2918ignore this symbol
2919þenddescription
2920
2921 Note that floating-point return values cannot be traced. `þtt{I}'
2922 pretends that a symbol has been used; this is used to avoid the
2923 warnings for exported symbols (such as variables) that are not
2924 traced.
2925
2926 The letter is followed by a space and the function name. The
2927 function name is followed by parenthesis in which the arguments are
2928 declared. For each argument, the argument type and the argument
2929 name is provided (separated by a space), arguments are separated by
2930 commas. The argument type is a single letter:
2931
2932þdescription
2933þitem þtt{i}
293432-bit integer
2935þitem þtt{p}
2936pointer
2937þitem þtt{s}
2938string (consisting entirely of printable characters)
2939þenddescription
2940
2941 The following example defines tracepoints for some standard library
2942 functions:
2943
2944þexample
2945v clearerr (p stream)
2946p fgets (p buffer, i size, p stream)
2947v abort ()
2948I errno ; suppress warning about errno not being traced
2949þendexample
2950
2951 If a function has more arguments than declared in the <tss_file>,
2952 remaining arguments of the function won't be traced.
2953
2954 For each function, emxtsf creates a Pre-Invocation tracepoint. If
2955 the function has been compiled with the þhpt{-mepilogue} option of
2956 GCC, a Post-Invocation tracepoint will be created as well.
2957
2958
2959þh2 listomf
2960þlabel listomf
2961þindex listomf
2962þkeyword listomf
2963
2964 listomf lists an .obj or .lib file in (more or less) human-readable form.
2965
2966þindent
2967 þsy{listomf [-d] <input_file>}
2968þendindent
2969
2970 Give the name of the object file or library file on the command
2971 line. There is no default extension. If the -d option is given,
2972 listomf won't interpret debugging information.
2973
2974 Warning: listomf is a quick and dirty program which was used for
2975 developing þhpt{emxomf}.
2976
2977
2978þh2 updt
2979þlabel updt
2980þindex updt
2981þkeyword updt
2982
2983þitemize
2984þitem
2985 Copy file if contents have changed:
2986
2987þindent
2988 þsy{updt [-v] <source_file> <target_file>}
2989þendindent
2990
2991 updt copies the source file to the target file if the target file
2992 does not exist or if the source and target files differ in contents.
2993 This is used by the makefile for GCC.
2994
2995þitem
2996 Copy file if source file is newer:
2997
2998þindent
2999 þsy{updt [-v] -t <source_file> <target_file>}
3000þendindent
3001
3002 updt copies the source file to the target file if the target file
3003 does not exist or if the source file is newer than the target file.
3004 This is used for configuring GCC.
3005þenditemize
3006
3007 The -v option turns on information messages.
3008
3009
3010þh1 Hints for porting Unix programs to emx
3011
3012þitemize
3013þitem
3014
3015 If you want Unix-like wildcard expansion built into the program, use
3016
3017þexample
3018int main (int argc, char *argv[])
3019{
3020 _wildcard (&argc, &argv);
3021 /* ... the program ... */
3022}
3023þendexample
3024
3025 This should be done at the very beginning of þhpt{main()}, before
3026 þpa{ARGC} and þpa{ARGV} are used. See þhpt{_wildcard()} and
3027 þhpt{_response()}.
3028
3029þitem
3030
3031 Change all þhpt{open()}, þhpt{fopen()}, þhpt{fdopen()} and
3032 þhpt{freopen()} calls to use O_BINARY or "b", respectively, for
3033 binary files. If a file contains both binary and textual data, read
3034 the file in binary mode and do the conversion yourself.
3035
3036þitem
3037
3038 Though fseek() and ftell() now work on text files, the offsets are
3039 different from what Unix programs expect. You may have to open the
3040 files in binary mode and ignore carriage returns (this has been done
3041 in GDB).
3042
3043þitem
3044
3045 Replace þhpt{fork()} and þhpt{exec*()} with þhpt{spawn*()}. Under
3046 OS/2, fork() is inefficient. Under DOS, fork() is not implemented.
3047
3048þitem
3049
3050 Replace þhpt{exec*()} with þhpt{spawn*()} and þhpt{exit()} if the
3051 parent process waits for the termination of the new process (by
3052 calling þhpt{wait()} or by waiting for SIGCLD). This is required to
3053 keep the process ID of the child process. In a forked process,
3054 however, you don't have to do this because emx.dll does it for you.
3055
3056þitem
3057
3058 Programs reading a.out files should be changed to call
3059 þhpt{_seek_hdr()} or þhpt{_fseek_hdr()} before reading the header to
3060 support .exe files. More changes are usually required.
3061
3062þitem
3063
3064 Watch out for Unix file system hacks: Unix allows deleting and
3065 renaming an open file (the file will be deleted after being closed).
3066
3067þitem
3068
3069 Watch out for Unix file names (Unix is case sensitive, long file
3070 names and multiple dots are allowed). On OS/2's HPFS multiple dots
3071 are also allowed; however, trailing dots are not significant (except
3072 for the special file names `þtt{.}' and `þtt{..}').
3073
3074þitem
3075
3076 The null device is called þtt{/dev/null} under Unix. The __open()
3077 system call translates the filenames þtt{"/dev/null"} and
3078 þtt{"/dev/tty"} (lower case, with slashes) to þtt{"nul"} and
3079 þtt{"con"}, respectively. However,
3080
3081þexample
3082system ("whatever >/dev/null");
3083þendexample
3084
3085 won't work as the standard OS/2 and DOS command interpreters don't
3086 recognize þtt{/dev/null}.
3087
3088þitem
3089
3090 Programs using stdin, stdout or stderr for binary data should call
3091 þhpt{_fsetmode()} to switch the stream to binary mode.
3092
3093þitem
3094
3095 If you want to use þtt{\} for separating directories, changes may be
3096 necessary. These changes are optional because þtt{/} also works.
3097
3098þitem
3099
3100 Implement support for drive names. This can be done by using
3101
3102þexample
3103#define getcwd _getcwd2
3104#define chdir _chdir2
3105þendexample
3106
3107 In addition, some changes will be necessary. For instance, you have
3108 to change code which checks whether a filename is an absolute path
3109 name. þhpt{_fullpath()} and þhpt{_abspath()} can also be useful.
3110
3111þitem
3112
3113 Note that þtt{///abc} is a valid Unix filename. It's equivalent to
3114 þtt{/abc}.
3115
3116þitem
3117
3118 Note that þtt{chdir ("..")} is a no-op under Unix if the current working
3119 directory is the root directory. Under emx, þtt{chdir ("..")} fails in
3120 the root directory.
3121
3122þitem
3123
3124 Use termio or termios or read the keyboard with þhpt{_read_kbd()} if
3125 you don't want to get input line by line.
3126
3127þitem
3128
3129 Under Unix, directories in environment variables (PATH, for
3130 instance) are separated by colons; use semicolons instead.
3131
3132þitem
3133
3134 Do not use the þtt{PTRACE_TRACEME} request of þhpt{ptrace()}: use
3135 P_DEBUG instead when starting the process with þhpt{spawn*()}.
3136
3137þitem
3138
3139 By default, signal processing is different when using signal():
3140 SIG_ACK should be used instead of the signal handler address to
3141 re-enable a signal by calling þhpt{signal()} when the signal handler
3142 has been called. This behavior can be changed with the
3143 -Zbsd-signals and -Zsysv-signals options of GCC. If you use POSIX.1
3144 functions for signal handling, SIG_ACK is not required.
3145
3146þitem
3147
3148 The shell isn't called þtt{/bin/sh}. Use þhpt{system()}. system()
3149 and þhpt{popen()} don't expand wildcards (unless COMSPEC points to a
3150 shell which expands wildcards).
3151
3152þitem
3153
3154 Printing single characters is inefficient. A solution is to use
3155
3156þexample
3157setvbuf (stdout, NULL, _IOLBF, BUFSIZ)
3158þendexample
3159
3160 and to use þtt{fflush (stdout)} if you need the output immediately
3161 (flushing is required only after displaying prompting texts before
3162 reading input or displaying progress reports that don't end with a
3163 newline character). GDB output has been made much faster by using
3164 line buffering.
3165
3166þitem
3167
3168 Note that þtt{VEOF != VMIN} and þtt{VEOL != VTIME}. Programs which
3169 use VEOF and VEOL to access VMIN and VTIME, respectively, should be
3170 changed to use VMIN and VTIME. emx uses separate fields for VEOF,
3171 VEOL, VMIN and VTIME.
3172
3173þitem
3174
3175 To use termio, you have to reset the IDEFAULT bit of c_lflag. This
3176 does not apply to termios.
3177
3178þenditemize
3179
3180
3181þh1 Creating OS/2 programs
3182
3183 This section describes additional features available when devoloping
3184 OS/2 programs.
3185
3186þipfminitoc
3187
3188þh2 Calling OS/2 API functions
3189þlabel Calling OS/2 API functions
3190
3191 Use
3192
3193þexample
3194#include <os2.h>
3195þendexample
3196
3197 in your C files to call OS/2 API functions. GCC automatically links
3198 your program with os2.a (or os2.lib) by passing the -los2 option to
3199 the linker. If you call the linker manually, you have to tell the
3200 linker to link with library os2. Note that your program will crash
3201 if it calls an OS/2 API function when run under DOS.
3202
3203 You can use either the header file that comes with emx (os2emx.h) or
3204 the header files that come with the Developer's Toolkit for OS/2
3205 (an IBM product). By default, os2emx.h is used when doing
3206 þtt{#include <os2.h>}. To use the header files of the Developer's
3207 Toolkit for OS/2, edit þtt{/emx/include/os2.h} to #include
3208 os2tk.h instead of os2emx.h, and add the toolkit include file
3209 directory to the C_INCLUDE_PATH, CPLUS_INCLUDE_PATH and
3210 OBJC_INCLUDE_PATH environment variables. Instead of editing
3211 þtt{os2.h}, you can #define þtt{USE_OS2_TOOLKIT_HEADERS} before
3212 doing þtt{#include <os2.h>}.
3213
3214 Note that you should define þtt{INCL_}þsl{WHATEVER} constants when
3215 using os2emx.h as you would with the IBM Developer's Toolkit for
3216 OS/2 -- though not all constants are tested by the current
3217 version of os2emx.h.
3218
3219 When compiling C++ programs, you may have to define the preprocessor
3220 symbol þtt{OS2EMX_PLAIN_CHAR}.
3221
3222 When passing a pointer to a structure to a 16-bit function, the
3223 structure must not cross a 64 KByte boundary. This (currently)
3224 cannot be automatically assured for structures allocated in the
3225 stack (auto variables and function arguments).
3226
3227 To pass the address of an þtt{auto} variable to a 16-bit function,
3228 you should define the variable twice and use þtt{_THUNK_PTR_STRUCT_OK}
3229 or þtt{_THUNK_PTR_SIZE_OK} to check which one is properly aligned.
3230
3231 To ensure that all structures passed to 16-bit functions are
3232 properly aligned, define all those variables in a module of their
3233 own which must be the first module linked. This doesn't work if the
3234 combined size of all those variables exceeds 64 KByte. Use
3235 þhpt{_tmalloc()} to allocate memory for structures passed to 16-bit
3236 functions.
3237
3238 The 32-bit wrappers for 16-bit OS/2 API functions are provided for
3239 both static linking (library os2) and dynamic linking (library
3240 þtt{wrap}, emxwrap.dll).
3241
3242
3243þh2 Importing from OS/2 DLLs
3244þlabel Importing from OS/2 DLLs
3245
3246 All functions in the list above are defined in os2.a and os2.lib.
3247 Moreover, the 32-bit wrappers for the 16-bit OS/2 API functions are
3248 available in the dynamic link library emxwrap.dll to reduce the size
3249 of the executables. The import library for emxwrap.dll is
3250 þtt{wrap}. To import functions not defined in os2.a and os2.lib,
3251 you have to create an import list file for these functions.
3252
3253 See the þhpt{emximp} documentation for details.
3254
3255 Please note that you cannot directly call 16-bit functions not
3256 listed above. See below for details.
3257
3258
3259þh2 Creating Presentation Manager applications using ld and emxbind
3260þlabel Creating Presentation Manager applications using ld and emxbind
3261
3262 To create a Presentation Manager application using ld and emxbind,
3263
3264þitemize
3265þitem
3266
3267 þtt{#include <os2.h>}
3268
3269þitem
3270
3271 link with os2.a (done automatically when using GCC to link)
3272
3273þitem
3274
3275 use þtt{rc -r} to compile the resource-definition file into a binary
3276 resource file (.res file)
3277
3278þitem
3279
3280 use þtt{emxbind -ep} or a module definition file to set the
3281 application type
3282
3283þitem
3284
3285 use the -r option of emxbind to put the resources from the binary
3286 resource file into the .exe file. If there is a .res file on the GCC
3287 or ld command line, it is automatically passed to emxbind
3288
3289þenditemize
3290
3291 Do not use rc to put the resources into the .exe file!
3292
3293 Example:
3294
3295þexample
3296cd \emx\test
3297rc -r pm1.rc
3298gcc -o pm1 pm1.c
3299emxbind -bp -rpm1.res /emx/bin/emxl pm1
3300þendexample
3301
3302 Ditto, using a module definition file:
3303
3304þexample
3305cd \emx\test
3306rc -r pm1.rc
3307gcc -o pm1.exe pm1.c pm1.def pm1.res
3308þendexample
3309
3310 Example (compiling the `template' toolkit sample program):
3311
3312þexample
3313cd \toolkt20\c\samples\template
3314copy ..\prodinfo.bmp
3315rc -r main.rc
3316gcc -s -o template.exe *.c template.def main.res
3317þendexample
3318
3319
3320þh2 Creating Presentation Manager applications using emxomf and LINK386
3321þlabel Creating Presentation Manager applications using emxomf and LINK386
3322
3323 To create a Presentation Manager application using emxomf and LINK386,
3324
3325þitemize
3326þitem
3327
3328 þtt{#include <os2.h>}
3329
3330þitem
3331
3332 link with os2.lib (done automatically when using GCC to link)
3333
3334þitem
3335
3336 use a module definition file which uses the WINDOWAPI keyword of the
3337 NAME statement
3338
3339þitem
3340
3341 use þtt{rc -r} to compile the resource-definition file into a binary
3342 resource file (.res file)
3343
3344þitem
3345
3346 use rc or emxomfld to add the binary resource file to the .exe
3347 file. Optionally, you can compile the resource-definition file and
3348 add it to the .exe file using rc in one step. Using two steps is
3349 recommended in makefiles.
3350
3351þenditemize
3352
3353 Example:
3354
3355þexample
3356cd \emx\test
3357rc -r pm1.rc
3358gcc -o pm1.exe pm1.c pm1.def pm1.res -Zomf
3359þendexample
3360
3361 Example (compiling the `template' toolkit sample program):
3362
3363þexample
3364cd \toolkt20\c\samples\template
3365copy ..\prodinfo.bmp
3366rc -r main.rc
3367gcc -Zomf -o template.exe *.c template.def main.res
3368þendexample
3369
3370 If you want to use the þhpt{-Zsys} option, you should increase the
3371 stack size by editing the STACKSIZE statement in the .def file.
3372 Note that the command line arguments and the complete environment
3373 are copied to the stack! The stack size should be at least 32768.
3374
3375
3376þh2 Creating Workplace Shell applications
3377þlabel Creating Workplace Shell applications
3378
3379 Dynamic link libraries for Workplace Shell objects should be either
3380 DLLs without C runtime environment or stand-alone DLLs (see below).
3381
3382 For creating Workplace Shell applications, you need the SOM headers
3383 and the SOM compiler from the Developer's Toolkit for OS/2 (an IBM
3384 product).
3385
3386 See the `flag' example in þtt{/emx/samples}.
3387
3388þh2 Creating dynamic link libraries
3389þlabel Creating dynamic link libraries
3390
3391 There are six types of dynamic link libraries:
3392
3393þenumerate
3394þitem
3395
3396 DLLs which use emxlibcm.dll or emxlibcs.dll or a custom C runtime
3397 DLL. These DLLs don't contain C library functions. Calls to C
3398 library functions are resolved by emxlibcm.dll or emxlibcs.dll or a
3399 custom C runtime DLL (and, in all three cases, emx.dll). The main
3400 program and all DLLs must use the same C runtime DLL.
3401
3402þitem
3403
3404 Custom C runtime DLLs. These DLLs contain the C library or parts
3405 thereof and export the C library functions to other DLLs and to the
3406 main program. An application (main program and DLLs) should use
3407 only one custom C runtime DLL; emxlibcm.dll and emxlibcs.dll should
3408 not be used. Either the system call library sys.lib or emx.dll can
3409 be used. This type of DLL is recommended if you want to ship your
3410 application with your own DLLs, but without any emx DLLs. This type
3411 of DLL can also be used when replacing library functions such as
3412 malloc() which are referenced by other library functions.
3413
3414þitem
3415
3416 C runtime forwarder DLLs. These DLLs forward all C runtime
3417 functions to emxlibcm.dll or emxlibcs.dll, and add some functions of
3418 their own. However, they cannot safely replace functions of
3419 emxlibcm.dll or emxlibcs.dll as the latter ones won't call the
3420 replacement functions.
3421
3422þitem
3423
3424 Stand-alone DLLs. These DLLs contain the C library or parts
3425 thereof, which is used privately by the DLL. The main program and
3426 the other DLLs use a different C runtime environment. You should
3427 use only `simple' C library functions such as memcpy() which don't
3428 require global variables.
3429
3430 Keep in mind that the DLL and the program using the DLL don't share
3431 global variables such as þhpt{errno}, þhpt{timezone}, and -- very
3432 important -- the variables used for I/O.
3433
3434þitem
3435
3436 DLLs without C runtime environment. These DLLs don't call any C
3437 library functions which require a runtime environment. Only OS/2
3438 API functions and simple C library functions such as þtt{strcpy()}
3439 can be called.
3440
3441þitem
3442
3443 Resource DLLs. These DLLs contain only resources. Some bits of
3444 code are required for library initialization.
3445
3446þendenumerate
3447
3448 Write a þhpt{module definition file} (.def file) that contains a
3449 LIBRARY statement and an EXPORTS statement. The EXPORTS statement
3450 has to list all functions to be exported by your DLL. The .def file
3451 should have the same name as the .dll file to be created.
3452
3453 Compile and link your program using the þhpt{-Zdll} option of GCC.
3454 This option causes the dll0 startup to be used instead of crt0 and
3455 selects appropriate libraries. As DLLs are usually multithread
3456 libraries, you should also use the þhpt{-Zmt} option. Specify the
3457 name of the .def file on the GCC or ld command line, respectively.
3458
3459 Using the þhpt{-mprobe} GCC option is recommended for creating DLLs
3460 as the DLL might be called from a thread with uncommitted stack.
3461
3462 Linking with LINK386 (using GCC -Zomf) is recommended for dynamic
3463 link libraries. Use ld and emxbind only if you want to debug the
3464 dynamic link library.
3465
3466þh3 Creating dynamic link libraries that use a C library DLL
3467
3468 Dynamic link libraries that use emxlibcm.dll or emxlibcs.dll (or a
3469 custom C runtime DLL) are allowed to call all library functions,
3470 including stream I/O, as long as they are used together with
3471 programs and other dynamic link libraries that use the same
3472 emxlibcm.dll or emxlibcs.dll (or the same custom C runtime DLL used
3473 by the DLL). That is, all I/O done by C library functions must be
3474 done in a single place, emxlibcm.dll, emxlibcs.dll, or the custom C
3475 runtime DLL. The following GCC options are used for building
3476 a DLL which uses a C library DLL: þhpt{-Zdll} þhpt{-Zcrtdll}.
3477
3478 The default _DLL_InitTerm() function calls _CRT_init(),
3479 constructors, and destructors, but does not call _CRT_term().
3480 _CRT_init() is called to ensure that the C library has been
3481 initialized for use by the constructors, even if OS/2 happens to
3482 initialize the DLLs in a wrong sequence. _CRT_term() is not called
3483 because other libraries may still use the C library.
3484
3485 See þtt{/emx/test/testdll3.cc} for an example.
3486
3487þh3 Creating custom C runtime DLLs
3488
3489 Creating a custom C runtime DLL means creating a DLL which contains
3490 your own code and some or all code of emxlibcm.dll or emxlibcs.dll.
3491 Write a module definition file which exports your functions and all
3492 C library functions and variables referenced by the main program and
3493 other DLLs using the custom C runtime DLL.
3494
3495 You can use þtt{/emx/lib/cdll.def} as template. Note that some
3496 symbols must always be exported, see þtt{/emx/lib/cdll.def} for
3497 details.
3498
3499 To create a multithread DLL, delete all lines of
3500 þtt{/emx/lib/cdll.def} which contain the string þtt[{ST}]. To
3501 create a single-thread DLL, delete all lines containing þtt[{MT}].
3502 To create a DLL which uses emx.dll, delete all lines containing
3503 þtt[{SYS}]. To create a DLL which does not use emx.dll (-Zsys),
3504 delete all lines containing þtt[{EMX}]. This can be automatically
3505 done, for instance with the þtt{sed} tool; see target
3506 þtt{testdll7.def} in þtt{/emx/test/makefile}.
3507
3508 Don't forget to use the following statement:
3509
3510þexample
3511DATA
3512 MULTIPLE NONSHARED
3513þendexample
3514
3515 Use the following GCC option for building a custom C runtime DLL:
3516 þhpt{-Zdll}. The options þhpt{-Zomf} and þhpt{-Zsys} are optional.
3517
3518 If clients of your DLL call the hardware port I/O functions such as
3519 þhpt{_inp8()}, either link the clients with þtt{-lemxio} or use
3520 þtt{/emx/src/lib/cdll/emxio.def} in addition to your module
3521 definition file for creating the import library (it is essential to
3522 import the functions from þtt{emxio.dll}, therefore appending
3523 þtt{emxio.def} to your module definition file won't work).
3524
3525 To use your custom C runtime DLL, use the þhpt{-Zcrtdll} option of
3526 GCC: If your import library is named þtt{myclib.lib}, use
3527 þtt{-Zcrtdll=myclib} in GCC's command line.
3528
3529 The default _DLL_InitTerm() function calls _CRT_init(),
3530 constructors, destructors, and _CRT_term().
3531
3532 See þtt{/emx/test/testdll4.c} and þtt{/emx/test/testdll7.c} for
3533 examples.
3534
3535þh3 Creating C runtime forwarder DLLs
3536
3537 Creating a C runtime forwarder DLL is similar to creating a custom C
3538 runtime DLL (see above). However, instead of statically linking the
3539 C runtime library, it is linked dynamically. That is, the exports
3540 of the forwarder DLL are resolved by imports from emxlibcm.dll or
3541 emxlibcs.dll.
3542
3543 Use the following GCC option for building a forwarder DLL:
3544 þhpt{-Zdll} þhpt{-Zomf} þhpt{-Zcrtdll}. As emxbind does not
3545 support forwarders, you have to use -Zomf.
3546
3547þh3 Creating stand-alone dynamic link libraries
3548
3549 A stand-alone dynamic link library has its own runtime environment
3550 which is not shared with the client application or other DLLs. Use
3551 the following GCC options for creating a stand-alone DLL:
3552 þhpt{-Zdll} þhpt{-Zso} þhpt{-Zsys} þhpt{-Zomf}.
3553
3554 The default _DLL_InitTerm() function calls _CRT_init(),
3555 constructors, destructors, and _CRT_term().
3556
3557 See þtt{/emx/test/testdll5.c} for an example.
3558
3559þh3 Creating dynamic link libraries without C runtime environment
3560
3561 To create a dynamic link library without C runtime, do not reference
3562 any C library function which requires a runtime environment. As the
3563 þtt{new} operator of C++ calls malloc(), you cannot use C++ to
3564 create a DLL of this type unless you provide your own memory
3565 management. Do not use þhpt{-Zmt} even if the DLL is used by
3566 multithread programs; you have to use Mutex semaphores when using
3567 functions such as þtt{strtok()} which are not thread-safe. Use the
3568 following GCC options to build a DLL without C runtime environment:
3569 þhpt{-Zdll} þhpt{-Zno-rte} þhpt{-Zomf}.
3570
3571 The default _DLL_InitTerm() function calls constructors and
3572 destructors, but does not call _CRT_init() and _CRT_term() as there
3573 is no runtime environment to initialize.
3574
3575 See þtt{/emx/test/testdll1.c} for an example.
3576
3577þh3 Creating resource DLLs
3578
3579 To create a resource DLL, build a DLL from þtt{/emx/lib/res0.obj}
3580 and add the resources with rc:
3581
3582þexample
3583link386 \emx\lib\res0,myres.dll,nul,,myres.def
3584rc myres.res myres.dll
3585þendexample
3586
3587 The module definition file should start with a LIBRARY statement.
3588
3589þh3 Creating dynamic link libraries using C++
3590
3591 You should not use the GNU C++ libraries (þhpt{libg++} and
3592 þhpt{libstdc++}) if you create a DLL (unless you are building a
3593 stand-alone DLL or a private C runtime DLL) as there is not yet a
3594 DLL version of these libraries.
3595
3596 As creating the module definition file for the DLL by hand is quite
3597 boring, you should let your computer do it: see the description of
3598 the þhpt{emxexp} tool for details. The þtt{sign} sample of
3599 þtt{emxample.zip} uses emxexp to create the module definition file.
3600
3601 To call the constructors and destructors for static objects in the
3602 DLL, make sure that the þhpt{_DLL_InitTerm()} function of the DLL
3603 calls þhpt{__ctordtorInit()} and þhpt{__ctordtorTerm()}. You should
3604 call _CRT_init() before __ctordtorInit() to ensure that the C
3605 library has been initialized for use by the constructors, even if
3606 OS/2 happens to initialize the DLLs in a wrong sequence.
3607
3608þh2 Using the DLL version of the C library
3609þlabel Using the DLL version of the C library
3610
3611 To use emxlibcm.dll or emxlibcs.dll, simply type þhpt{-Zcrtdll} on
3612 the GCC command line. This links your program with the import
3613 libraries c_import.a or c_import.lib instead of the static C library
3614 (þtt{c}, þtt{c_app}, þtt{gcc}, þtt{emx}). Additionally, code which
3615 must be statically linked is taken from c_static.a or c_static.lib.
3616 -Zcrtdll can be used with methods (E1) and (E2). See the
3617 þhpt{introduction} for further information.
3618
3619 Note that emxlibcm.dll and emxlibcs.dll use emx.dll. Thus, the
3620 restrictions of -Zsys do not apply.
3621
3622 Do not redefine functions in your program which are contained in
3623 emxlibcm.dll or emxlibcs.dll. Other functions in emxlibcm.dll or
3624 emxlibcs.dll will continue to use the original versions in that DLL
3625 which will cause problems. If you have to replace library functions
3626 and want to use a C library DLL, create a new DLL (which must not be
3627 called emxlibc.dll, emxlibcm.dll, or emxlibcs.dll), add your
3628 replacement functions and all the functions of emxlibcm.dll or
3629 emxlibcs.dll except for the functions you are replacing.
3630
3631
3632þh2 Creating multithread programs
3633þlabel Creating multithread programs
3634
3635 Multithread programs have to use either the multithread static
3636 libraries or the dynamic link library emxlibcm.dll. You have to say
3637 þhpt{-Zmt} on the GCC command line.
3638
3639 Use þhpt{_beginthread()} to start a new thread. Do not use
3640 DosCreateThread unless the new thread doesn't call C library
3641 functions.
3642
3643 The C library functions in þtt{mt/c.a}, þtt{mt/c.lib}, and
3644 emxlibcm.dll are not yet completely thread-safe. The -Zmt, -Zmts,
3645 and -Zmtd options define the __MT__ preprocessor macro. The C
3646 library header files check for __MT__ to use alternate definitions
3647 suitable for multithread programs when -Zmt, -Zmts, or -Zmtd is
3648 used.
3649
3650 Each thread has its own þhpt{errno} value. To create a library
3651 which can be used for both single-thread and multithread programs,
3652 use the þhpt{_errno()} function instead of the errno variable. If
3653 the preprocessor symbol þtt{__ST_MT_ERRNO__} is defined, errno will
3654 be redefined to call _errno(). Just use the þtt{-D__ST_MT_ERRNO__}
3655 option in the GCC command line.
3656
3657 If you are very careful, you can write multithread programs that
3658 use the single-thread libraries. Only the main thread is allowed
3659 to call library functions that have side effects, including
3660 functions that set errno. All other threads should use OS/2 API
3661 functions instead.
3662
3663 For performance reasons, single-thread programs should be linked
3664 with the single-thread libraries (that is, without the -Zmt option).
3665
3666
3667þh2 Calling 16-bit functions
3668þlabel Calling 16-bit functions
3669
3670 Limited support for calling 16-bit functions is available. You can
3671 call 16-bit OS/2 API functions and other 16-bit functions that use
3672 the pascal (_pascal) or C (_cdecl) calling convention and are
3673 exported by a dynamic link library. As no changes have been made to
3674 GCC to support direct calls to 16-bit functions (this would require
3675 big changes to GCC), you have to call 16-bit functions by applying
3676 the (awkward) C preprocessor macros and functions described below.
3677 There are two sets of macros, one for the pascal calling convention
3678 (_THUNK_PASCAL_***) and one for the C calling convention
3679 (_THUNK_C_***). For convenience and compatibility with emx 0.8f,
3680 there are also macros _THUNK_*** which are aliases for the
3681 _THUNK_PASCAL_*** macros. For brevity, only the _THUNK_*** macros
3682 are explained below. To call a _cdecl function, use
3683 _THUNK_C_FUNCTION etc. instead of _THUNK_FUNCTION etc.
3684
3685þlist
3686þitem þtt{_THUNK_FUNCTION(}þpa{FUNCTION}þtt{)}
3687
3688 This macro is used for declaring the 16-bit function. The
3689 function is declared as usual, using a prototype, but
3690 _THUNK_FUNCTION is applied to the function name. The 16-bit
3691 function must not be called directly.
3692
3693þitem þtt{_THUNK_PROLOG(}þpa{SIZE}þtt{)}
3694
3695 For each call to the 16-bit function, this macro must be
3696 called first. þpa{SIZE} is the number of bytes in the
3697 argument list of the 16-bit function. After calling
3698 _THUNK_PROLOG, the following macros are used to build the
3699 argument list. The macros are to be applied left-to-right,
3700 that is, the first argument is handled first both for the
3701 pascal and the C calling convention.
3702
3703þitem þtt{_THUNK_CHAR(}þpa{ARG}þtt{)}
3704
3705 Pass an 8-bit argument to the function.
3706
3707þitem þtt{_THUNK_SHORT(}þpa{ARG}þtt{)}
3708
3709 Pass a 16-bit argument to the function.
3710
3711þitem þtt{_THUNK_LONG(}þpa{ARG}þtt{)}
3712
3713 Pass a 32-bit argument to the function.
3714
3715þitem þtt{_THUNK_FLAT(}þpa{ARG}þtt{)}
3716
3717 Pass a 32-bit (flat) pointer to the function.
3718
3719þitem þtt{_THUNK_FAR16(}þpa{ARG}þtt{)}
3720
3721 Pass a 16:16-bit far pointer to the function. After
3722 building the argument list, the 16-bit function is called by
3723 invoking the following macro.
3724
3725þitem þtt{_THUNK_CALL(}þpa{FUNCTION}þtt{)}
3726
3727 Call the 16-bit function þpa{FUNCTION}. Do not apply
3728 _THUNK_FUNCTION to the function name.
3729
3730þitem þtt{_THUNK_CALLI(}þpa{FUNCTION}þtt{)}
3731
3732 Call the 16-bit function pointed to by the 16:16-bit far
3733 pointer þpa{FUNCTION}. Use this macro instead of _THUNK_CALL
3734 when employing DosLoadModule and DosQueryProcAddr. The
3735 pointer returned by DosQueryProcAddr must be turned into a
3736 16:16-bit far pointer by calling _emx_32to16().
3737
3738þendlist
3739
3740 There should be no statements other than calls to the _THUNK macros
3741 between _THUNK_PROLOG and _THUNK_CALL. _THUNK_PROLOG starts an
3742 expression which is terminated by _THUNK_CALL. Therefore, the
3743 return value of the 16-bit function is returned by _THUNK_CALL and
3744 by the entire sequences of statements from _THUNK_PROLOG to
3745 _THUNK_CALL. The return value is the value returned by the 16-bit
3746 function in the DX and AX registers. If the function returns a
3747 16-bit value, you have to typecast the return value to þtt{SHORT} or
3748 þtt{USHORT} to discard the upper 16 bits.
3749
3750 See the description of þhpt{_emx_16to32()} and _emx_32to16() for
3751 converting 16-bit far pointers to 32-bit flat pointers and vice
3752 versa. This conversion is not done automatically.
3753
3754 You will get a warning about the variable _tp being unused if the
3755 16-bit function doesn't take arguments. This warning is harmless.
3756
3757 When passing a pointer to a structure to a 16-bit function, the
3758 structure must not cross a 64 KByte boundary. This (currently)
3759 cannot be assured for structures allocated in the stack (þtt{auto}
3760 variables and function arguments). To ensure that all structures
3761 passed to 16-bit functions are properly aligned, define all those
3762 variables in a module of their own which must be the first module
3763 linked. This doesn't work if the combined size of all those
3764 variables exceeds 64 KByte. Alternatively, you can define the
3765 variable twice and use þtt{_THUNK_PTR_STRUCT_OK} or
3766 þtt{_THUNK_PTR_SIZE_OK} to check which one is properly aligned. Use
3767 þhpt{_tmalloc()} to allocate memory for structures passed to 16-bit
3768 functions. Example:
3769
3770þexample
3771#include <os2.h> /* define _THUNK_*** macros */
3772
3773/* Declare 16-bit function */
3774USHORT _THUNK_FUNCTION (Dos16Beep) (USHORT usFrequency, USHORT usDuration);
3775
3776void beep (int frequency, int duration)
3777{
3778 _THUNK_PROLOG (2+2);
3779 _THUNK_SHORT (frequency);
3780 _THUNK_SHORT (duration);
3781 _THUNK_CALL (Dos16Beep);
3782}
3783þendexample
3784
3785 See þtt{/emx/test/c16test1.c}, þtt{/emx/test/c16test2.c},
3786 þtt{/emx/src/lib/sys/scrsize.c}, and þtt{/emx/src/lib/os2/*.c} for
3787 more examples.
3788
3789
3790þh1 Customizing
3791
3792 Default values are provided for the heap size, the stack size and
3793 the number of files that can be open simultaneously. The following
3794 sections describe how to increase the limits.
3795
3796þipfminitoc
3797
3798þh2 Increasing the heap size
3799þlabel Increasing the heap size
3800
3801 The malloc() implementation of emx 0.9c and later can use multiple
3802 heap objects under OS/2; in consequence, the heap size is no longer
3803 limited under OS/2. However, if you use another malloc()
3804 implementation which does not support non-contiguous memory
3805 allocation or if the application is run under DOS, the maximum size
3806 of the heap available for þhpt{malloc()} is fixed. The default for
3807 the combined size of the heap and stack is 8 MByte under DOS. Use
3808 the þhpt{-s# emx option} (see section þref{Using emx options}) to
3809 increase the heap and stack size.
3810
3811 The default heap size is 32 MByte under OS/2. For the emx
3812 implementation of malloc(), this is the size of the initial heap
3813 object and the minimum size of additional heap objects. If ld and
3814 emxbind are used for linking, you can change the heap size with the
3815 þhpt{-h<heap_size> option of emxbind}.
3816
3817 If emxomf and LINK386 without -Zsys are used for linking, the heap
3818 size cannot be changed. If -Zsys is used, initialize the variable
3819 þtt{_sys_heap_size} to the desired heap size:
3820þexample
3821unsigned _sys_heap_size = 0x4000000; /* 64 MByte */
3822þendexample
3823 This can be done in any module explicitely linked to your
3824 application.
3825
3826
3827þh2 Increasing the stack size
3828þlabel Increasing the stack size
3829
3830 The default for the combined size of the heap and stack is 8 MByte
3831 under DOS. When using emxbind, the default stack size is 8 MB under
3832 OS/2. When using emxomf and LINK386, the default stack size is 0x8000
3833 bytes under OS/2.
3834
3835 The stack size for DOS can be changed with the þhpt{-s# emx option}.
3836 emxbind can put this option into the executable file.
3837
3838 The stack size for OS/2 can be changed with the þhpt{-k<stack_size>
3839 option of emxbind} when using emxbind. When using LINK386, use the
3840 þhpt{STACKSIZE statement} in a þhpt{module definition file}. The
3841 stack size should be at least 32768 bytes. You can also use the
3842 þhpt{-Zstack} option of GCC.
3843
3844 If you are using certain beta versions of LINK386, bits 16 through 23
3845 of the stack size should not equal 0x20000 or 0x40000 bits set.
3846 Otherwise, your program will crash under OS/2 2.0 due to a bug in
3847 OS/2 2.0. Use only stack sizes where both the 0x20000 and 0x40000
3848 bits are zero or the 0x10000 or 0x80000 bits are one.
3849
3850þh2 Increasing the number of files
3851þlabel Increasing the number of files
3852
3853 Under DOS and when using emx.dll under OS/2, you can set the number
3854 of file handles supported by the emx runtime by setting the EMXOPT
3855 environment variable or by using emxbind to put emx options into the
3856 .exe file. See section þref{Using emx options} for the þhpt{-h# emx
3857 option}.
3858
3859 Note that you might have to change the FILES settings in the
3860 config.sys file under DOS. (Under OS/2, the FILES setting of
3861 config.sys applies only to DOS programs.)
3862
3863 When using the system call library (-Zsys, sys.lib) you have to call
3864 DosSetMaxFH to increase the number of file handles.
3865
3866 The number of file handles and streams supported by the C library is
3867 not limited. However, a process inherits only the first 40 file
3868 handles (0 through 39) of its parent process.
3869
3870þh1 Profiling
3871
3872 Profiling is used to find out where a program spends most of its
3873 time, to be able to improve performance of the program by paying
3874 special attention to those hot spots.
3875
3876 See also the GCOV chapter in the GCC manual. Note that GCOV
3877 currently requires support for long file names, that is, it won't
3878 work on FAT drives.
3879
3880þipfminitoc
3881
3882þh2 Limitations
3883
3884 Currently, profiling is supported only for programs built with
3885 emxbind; that is, you cannot use the -Zomf and -Zsys options of GCC.
3886 Moreover, profiling is restricted to the main thread (thread 1), all
3887 other threads are ignored.
3888
3889 Under OS/2, DosProfile, an unsupported and undocumented API is used.
3890 That API may disappear in future versions of OS/2 or behave
3891 differently in older versions of OS/2: Profiling has been tested
3892 only under OS/2 Warp 3.0.
3893
3894 Under DOS, the periodic interrupt of the real-time clock is used.
3895 If emx thinks another programs uses that interrupt, it silently
3896 refuses to profile your program (all sampling counters will remain
3897 zero). Profiling also doesn't work if there is no real-time clock
3898 or if it is not IBM-compatible.
3899
3900þh2 Preparing your program for profiling
3901
3902 You have to recompile your program for profiling, using the -pg or
3903 -pn option of GCC. The -pg option adds specials hooks to functions,
3904 uses gcrt0.o instead of crt0.o (to start profiling when the program
3905 is run), and uses library þtt{c_p.a} instead of þtt{c.a} (which has
3906 been compiled with -pg and therefore contains profiling hooks). The
3907 profiling hooks added by -pg enable gprof to print a call graph
3908 which shows which functions called which others, and how much time
3909 each function used when its function calls are included. The -pn
3910 option does not add profiling hooks; it uses gcrt0.o instead of
3911 crt0.o (to start profiling when the program is run). Profiling with
3912 -pn avoids the overhead caused by the profiling hooks; gprof won't
3913 be able to print a call graph and won't know how many times the
3914 functions have been called. Do not use the -s option as gprof needs
3915 the symbol table.
3916
3917 Note that þtt{gcrt0.o} is built from þtt{gmon.c} which is covered by
3918 the BSD license (see þtt{\emx\doc\COPYING.BSD}). þtt{gcrt0.o} is
3919 distributed in þtt{bsddev.zip}, therefore you have to install
3920 þtt{bsddev.zip} for profiling.
3921
3922þh2 Creating execution profiles
3923
3924 To collect profiling data for a program compiled with the -pg or -pn
3925 option of GCC, just run it. On termination of the program, a file
3926 named gmon.out will be written in the (then) current working
3927 directory.
3928
3929 A program compiled with the -pg option of GCC will run a bit
3930 slower than if compiled without the -pg option.
3931
3932þh2 Viewing execution profiles
3933
3934 Change to the directory containing the gmon.out file and run gprof
3935 on the executable file:
3936
3937þexample
3938[C:\TEST]myprog args
3939[C:\TEST]gprof myprog.exe
3940þendexample
3941
3942 See the gprof manual for details (shipped in þtt{gnudoc.zip}).
3943 gprof is distributed in þtt{bsddev.zip}, therefore you have to
3944 install þtt{bsddev.zip} for profiling.
3945
3946 Note that the sampling frequency is 1024Hz under DOS, and 1000Hz
3947 under OS/2. gprof assumes a sampling frequency of 1024Hz under DOS,
3948 and 1000Hz under OS/2. When running gprof under OS/2 on a gmon.out
3949 file created under DOS, or vice versa, the absolute timings will be
3950 slightly incorrect, though the relative timings will still be valid.
3951
3952
3953þh1 Tracing
3954
3955 All functions of emxlibcs.dll and emxlibcm.dll can be traced with
3956 the OS/2 TRACE command. If you want to trace the library calls of
3957 an application, you have to link it dynamically (þhpt{-Zcrtdll}).
3958
3959þipfminitoc
3960
3961þh2 Preparing for tracing
3962
3963 The following changes should be made to your config.sys file:
3964
3965þitemize
3966þitem
3967 Add the þtt{c:\emx\etc} directory to the DPATH environment variable,
3968 using the correct drive letter.
3969þitem
3970 Add the line
3971þexample
3972TRACEBUF=63
3973þendexample
3974 to enable tracing.
3975þenditemize
3976
3977 Reboot the machine after changing config.sys.
3978
3979þh2 Groups and event types
3980
3981 All the functions of emxlibcs.dll and emxlibcm.dll are divided into
3982 groups, to simplify tracing and to reduce the amount of trace data
3983 being produced. Each function belongs to exactly one group. You
3984 can enable and disable tracing for entire groups of tracepoints.
3985 The following groups are defined:
3986
3987þdescription
3988þitem þtt{CONV}
3989 Converting strings to numbers and vice versa (<stdlib.h> etc.)
3990þitem þtt{CTYPE}
3991 Functions of <ctype.h>
3992þitem þtt{DIR}
3993 Reading and managing directories (<unistd.h>, <dirent.h>, etc.)
3994þitem þtt{EA}
3995 Extended attributes (<io.h>)
3996þitem þtt{EMXLOAD}
3997 emxload support (<sys/emxload.h>)
3998þitem þtt{ENV}
3999 environment (<stdlib.h>)
4000þitem þtt{FNAME}
4001 File names (<stdlib.h> etc.), e.g., þtt{_defext()}
4002þitem þtt{GCC}
4003 Compiler helper functions and other functions of þtt{libgcc} (þtt{gcc.a})
4004þitem þtt{INIT}
4005 Initialization and termination
4006þitem þtt{LOCALE}
4007 Locale support (<locale.h>)
4008þitem þtt{LOWIO}
4009 Low-level I/O (<io.h>, <unistd.h> etc.)
4010þitem þtt{MALLOC}
4011 Memory allocation (<stdlib.h>, <malloc.h>, and <umalloc.h>)
4012þitem þtt{MATH}
4013 Floating-point math (<math.h> and <float.h>)
4014þitem þtt{NLS}
4015 National language support (<sys/nls.h>)
4016þitem þtt{OTHER}
4017 All remaining functions
4018þitem þtt{PROCESS}
4019 Process management and thread management (<unistd.h>, <process.h> etc.)
4020þitem þtt{PWD}
4021 Password database (<pwd.h>), user IDs, group IDs, etc.
4022þitem þtt{RTTI}
4023 C++ Run Time Type Identification
4024þitem þtt{SEM}
4025 Semaphores (<sys/fmutex.h> etc.)
4026þitem þtt{SIGNAL}
4027 Signal processing (<signal.h>)
4028þitem þtt{STDIO}
4029 C stream I/O (<stdio.h>)
4030þitem þtt{STRING}
4031 String and buffer processing (<string.h>, <strings.h>, etc.)
4032þitem þtt{SYSCALL}
4033 emx system calls
4034þitem þtt{TERMIOS}
4035 POSIX.1 general terminal interface (<termios.h>)
4036þitem þtt{TIME}
4037 Time and date (<time.h> etc.)
4038þenddescription
4039
4040 Each tracepoint has two event types: þtt{PRE} or þtt{POST} for the
4041 Pre-Invocation tracepoint and Post-Invocation tracepoint,
4042 respectively, and þtt{API} or þtt{INT} for API functions and
4043 internal functions, respectively. You can enable or disable tracing
4044 by event type.
4045
4046þh2 Minor trace codes
4047
4048 Each function has a unique minor trace code. You can enable tracing
4049 of a function by specifying its minor trace code. For functions
4050 which are exported by the DLL, the minor trace code for
4051 Pre-Invocation is identical to the ordinal number. See
4052 þtt{\emx\src\lib\cdll\emxlib.def} for the ordinal numbers.
4053 Additionally, the following minor trace codes are defined:
4054
4055þdescription
4056þitem 32767
4057 þtt{_DLL_InitTerm()}
4058þenddescription
4059
4060 To get the minor trace code for Post-Invocation, add 32768 to the
4061 minor trace code for Pre-Invocation.
4062
4063þh2 Using the TRACE command
4064
4065 The following command enables tracing for all trace points of
4066 emxlibcs.dll:
4067
4068þexample
4069trace on emxlibcs
4070þendexample
4071
4072 Usually, this generates too much data and causes the trace buffer to
4073 wrap around. The following command disables tracing for all trace
4074 points of all DLLs:
4075
4076þexample
4077trace on emxlibcs
4078þendexample
4079
4080 The following command enables tracing of all functions of group
4081 STDIO and all API functions of LOWIO:
4082
4083þexample
4084trace on emxlibcs (stdio,lowio=api)
4085þendexample
4086
4087 The following command enables tracing for all þtt{exec*()} and
4088 þtt{spawn*()} functions:
4089
4090þexample
4091trace on emxlibcs (100-107, 112-119)
4092þendexample
4093
4094 See the OS/2 command reference (þtt{help trace}) for details.
4095 Use the TRACEFMT command to view the contents of the trace buffer.
4096
4097
4098þh1 Debugger (DOS)
4099þlabel emx kernel debugger
4100
4101 emxd.exe contains a debugger (that's the difference between emx.exe
4102 and emxd.exe). Use the -S option to enable the debugger. If you
4103 want to debug using a terminal, enter -S1 to use COM1, -S2 to use
4104 COM2. To debug an emx program, type
4105
4106þindent
4107 þsy{emxd -S [<options>] <program> [<arguments>]}
4108þendindent
4109
4110 (which works with all emx programs) or
4111
4112þtypewriter
4113 set emx=c:\emx\bin\emxd.exe þbreak
4114 set emxopt=-S þbreak
4115 þsy{<program>}
4116þendtypewriter
4117
4118 (which doesn't work if emx.exe is bound to the program). When
4119 starting an emx program by running emx.exe or emxd.exe, the emx
4120 options -d, -h#, -m#, -o, -p, -E, -F, -O, -P and -V set by emxbind
4121 are ignored. Pass these options on the command line instead.
4122
4123 þbf{Command keys:}
4124
4125þdescription
4126þitem .
4127
4128 display registers and next instruction
4129
4130þitem :
4131
4132 show CS:EIP and next instruction (toggle)
4133
4134þitem BLANK
4135
4136 1 step
4137
4138þitem 0
4139
4140 10 steps
4141
4142þitem 1-9
4143
4144 1 through 9 steps
4145
4146þitem C
4147
4148 set breakpoint after next instruction and start program. This
4149 command should only be used on þtt{CALL} instructions
4150
4151þitem F
4152
4153 display floating point (387) status
4154
4155þitem N
4156
4157 step without stopping
4158
4159þitem F2
4160
4161 display registers and next instruction
4162
4163þitem F5
4164
4165 start program without setting breakpoint
4166
4167þitem F8
4168
4169 1 step
4170
4171þitem F10
4172
4173 set breakpoint after next instruction and start program
4174
4175þenddescription
4176
4177 þbf{Commands:}
4178
4179þlist
4180þitem þsy{A <address>}
4181
4182 display inforomation about <address> (virtual, physical and
4183 external addresses)
4184
4185þitem þsy{A <range>}
4186
4187 ditto, loop through <range> in steps of 1000H bytes
4188
4189þitem þsy{B}
4190
4191 display breakpoints and watchpoints
4192
4193þitem þsy{B <address>}
4194
4195 set breakpoint (default segment: CS). Up to 3 breakpoints and
4196 watchpoints can be set
4197
4198þitem þsy{D}
4199
4200 continue last þsy{D} command
4201
4202þitem þsy{D <address>}
4203
4204 display hex dump: 16 lines (default segment: DS)
4205
4206þitem þsy{D <range>}
4207
4208 display hex dump (default segment: DS)
4209
4210þitem þsy{G}
4211
4212 start program
4213
4214þitem þsy{G <address>}
4215
4216 set temporary breakpoint at <address> (default segment: CS)
4217 and start program
4218
4219þitem þsy{I}
4220
4221 display process table: process index, process id, parent
4222 process id, and file handle mapping
4223
4224þitem þsy{K}
4225
4226 display breakpoints and watchpoints
4227
4228þitem þsy{K <value>}
4229
4230 delete breakpoint or watchpoint (by number)
4231
4232þitem þsy{L <value>}
4233
4234 display info about selector <value>
4235
4236þitem þsy{L <value> <value>}
4237
4238 ditto, loop through range in steps of 8 (not 4!)
4239
4240þitem þsy{Q}
4241
4242 quit, return value 0
4243
4244þitem þsy{Q <value>}
4245
4246 quit and set the return value to <value>
4247
4248þitem þsy{R}
4249
4250 display registers and next instruction
4251
4252þitem þsy{R <register> <value>}
4253
4254 set register to <value>
4255
4256þitem þsy{R <condition>}
4257
4258 set/reset processor flag
4259
4260þitem þsy{S <range> <list>}
4261
4262 search memory
4263
4264þitem þsy{U}
4265
4266 continue last þsy{U} command
4267
4268þitem þsy{U <address>}
4269
4270 unassemble (default segment: CS)
4271
4272þitem þsy{V <value>}
4273
4274 display info about virtual address
4275
4276þitem þsy{V <value> <value>}
4277
4278 ditto, loop through range in steps of 1000H bytes
4279
4280þitem þsy{VP}
4281
4282 display info about pages that have physical memory assigned
4283
4284þitem þsy{VP <value>}
4285
4286 display info by physical address
4287
4288þitem þsy{VP <value> <value>}
4289
4290 ditto, loop through range in steps of 1000H bytes
4291
4292þitem þsy{VX}
4293
4294 display info about pages that have an external address
4295
4296þitem þsy{VX <value>}
4297
4298 display info by external address
4299
4300þitem þsy{VX <value> <value>}
4301
4302 ditto, loop through range in steps of 1000H bytes
4303
4304þitem þsy{W}
4305
4306 display breakpoints and watchpoints
4307
4308þitem þsy{W<l><a> <address>}
4309
4310 set watchpoint at given address (default segment: DS).
4311 þsy{<l>} is þtt{B} (byte), þtt{W} (word, <address> must be
4312 even) or þtt{D} (dword, the 2 low bits of <address> must be
4313 zero). þsy{<a>} is þtt{R} (trap read and write accesses),
4314 þtt{W} (trap write accesses) or þtt{X} (trap modifying write
4315 accesses).
4316
4317þitem þsy{X <value>}
4318
4319 find symbol at address <value> or below
4320
4321þendlist
4322
4323 The following arguments are used by the commands listed above:
4324
4325þlist
4326þitem <address>
4327
4328þlist
4329þitem þsy{[<value>:]<value>}
4330
4331 selector and offset. If using the SS register for the selector
4332 fails, type the value of SS as hexadecimal number
4333
4334þitem <symbol>
4335
4336 use address of variable or function <symbol>. If <symbol> looks
4337 like a hexadecimal number you lose
4338
4339þendlist
4340
4341þitem <condition>
4342
4343 Each processor flag has two states:
4344
4345þverbatim
4346NC, CY, PE, PO, NA, AC, NZ, ZR, PL, NG, DI, EI, UP, DN, NV, OV
4347þendverbatim
4348
4349þitem <register>
4350
4351 The following registers can be used:
4352
4353þverbatim
4354EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIP, EFLAGS,
4355AX, BX, CX, DX, SI, DI, BP, SP, IP,
4356AL, AH, BL, BH, CL, CH, DL, DH,
4357CS, DS, ES, FS, GS, SS
4358þendverbatim
4359
4360þitem <range>
4361
4362 A <range> includes all addresses between the start address and the
4363 end address:
4364
4365þlist
4366þitem þsy{<address> <address>}
4367
4368 The selectors of both addresses must be identical (the selector of
4369 the second address should be omitted, it defaults to the selector
4370 of the first address). The second offset must be greater than or
4371 equal to the first offset
4372
4373þendlist
4374
4375þitem <list>
4376
4377 A <list> is made of one or more values or multi-letter strings:
4378
4379 þsy{<value>|'<text>' ...}
4380
4381þitem <value>
4382
4383 A <value> is the basic element of an expression.
4384
4385þlist
4386þitem þsy{0} through þsy{ffffffff}
4387
4388 Hexadecimal number
4389
4390þitem <register>
4391
4392 Current value of the register <register>
4393
4394þitem þsy{'<C>'}
4395
4396 Character code (ASCII) of the character þsy{<C>}
4397
4398þendlist
4399þendlist
4400
4401 If the -S option is used, emx will display swapper statistics when
4402 returning to DOS. It displays
4403
4404þindent
4405 þsy{Swapper statistics: F=<f> R=<r> W=<w> N=<n> S=<s>}
4406þendindent
4407
4408 where þsy{<f>} is the number of page faults, þsy{<r>} is the number
4409 of swapper file reads, þsy{<w>} is the number of swapper file
4410 writes, þsy{<n>} is the number of times the swap space of present
4411 pages has been recycled, and þsy{<s>} is the size of the swapper
4412 file. All numbers are decimal numbers.
4413
4414
4415þh1 Executable file format
4416
4417þdescription
4418þitem a.out
4419
4420 see þtt{/emx/include/a_out.h}
4421
4422þitem exe
4423
4424 OS/2 LX format with additional sections, see diagram below
4425
4426þenddescription
4427
4428þexample
4429ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
4430³ ³
4431³ DOS .exe header: ³
4432³ ³
4433³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ
4434³ ³ ³ÄÄÄÄÄÄÄÄ¿
4435³ ³ Control information ³ÄÄÄÄ¿ ³
4436³ ³ ³ÄÄ¿ ³ ³
4437³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ<ÄÙ ³ ³
4438³ ³ ³ ³ ³
4439³ ³ Relocation table ³ ³ ³
4440³ ³ ³ ³ ³
4441ÀÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ³
4442 ³ ³
4443ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿<ÄÄÄÙ ³
4444³ ³ ³
4445³ DOS (emx or emxl) image: ³ ³
4446³ ³ ³
4447³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ ³
4448³ ³ ³ ³
4449³ ³ emxbind header (options) ³ÄÄÄÄÄÄ¿ ³
4450³ ³ ³ ³ ³
4451³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ ³ ³
4452³ ³ ³ ³ ³
4453³ ³ Code & data ³ ³ ³
4454³ ³ ³ ³ ³
4455ÀÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ³
4456 ³ ³
4457ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿<ÄÄÄÄÄÄÄÙ
4458³ ³ ³
4459³ OS/2 linear executable header: ³ ³
4460³ ³ ³
4461³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ ³
4462³ ³ ³ ³
4463³ ³ Fixed-size header ³ÄÄÄÄ¿ ³
4464³ ³ ³ÄÄ¿ ³ ³
4465³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ<ÄÙ ³ ³
4466³ ³ ³ ³ ³
4467³ ³ Loader section ³ÄÄ¿ ³ ³
4468³ ³ ³ ³ ³ ³
4469³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ<ÄÄÄÙ ³
4470³ ³ ³ ³ ³
4471³ ³ Fixup section ³ ³ ³
4472³ ³ ³ ³ ³
4473ÀÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ³
4474ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿<ÄŽ ³
4475³ ³ ³ ³
4476³ Resources ³ ³ ³
4477³ ³ ³ ³
4478ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ³
4479ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿<ijÄÄÄÙ
4480³ ³ ³
4481³ a.out executable: ³ ³
4482³ ³ ³
4483³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ ³
4484³ ³ ³ÄijÄÄ¿
4485³ ³ a.out header ³ ³ ³
4486³ ³ ³ ³ ³
4487³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ<ÄŽ ³
4488³ ³ ³ ³ ³
4489³ ³ Text segment ³ ³ ³
4490³ ³ ³ ³ ³
4491³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ<ÄÙ<ÄŽ
4492³ ³ ³ ³
4493³ ³ Data segment ³ ³
4494³ ³ ³ ³
4495³ ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ ³
4496³ ³ ³ ³ ³
4497³ ³ ³ OS/2 emxbind header ³ ³
4498³ ³ ³ ³ ³
4499³ ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ ³
4500³ ³ ³ ³ ³
4501³ ³ ³ Other data ³ ³
4502³ ³ ³ ³ ³
4503³ ÃÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŽ<ÄÄÄÄÙ
4504³ ³ ³
4505³ ³ Symbol table ³
4506³ ³ ³
4507ÀÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
4508þendexample
4509
4510þh1 Known problems
4511
4512þitemize
4513þitem
4514
4515 þhpt{sleep()} and þhpt{_sleep2()} hold signals under
4516 DOS, that is, if the þhpt{alarm()} timer elapses, the signal handler
4517 for SIGALRM isn't called until the completion of those functions
4518
4519þitem
4520
4521 when using the þhpt{-C# emx option}, memory allocated by an
4522 unsuccessful þhpt{brk()} or þhpt{sbrk()} call isn't freed. That is,
4523 as soon as a þhpt{malloc()} call fails, further calls will also
4524 fail. Actually, this isn't a bug -- it's a lacking feature
4525
4526þitem
4527
4528 emx doesn't work under DOS if more than 64 MByte of memory is
4529 installed
4530
4531þitem
4532
4533 running emx programs by a DOS program started by an emx program
4534 seems not to work under certain circumstances [Is this still true?]
4535
4536þitem
4537
4538 breakpoints are shared by all instances of a program under OS/2 2.1
4539 and earlier -- this is an OS/2 bug which seems to be fixed OS/2 2.11
4540 (ServicePak XR06200 for OS/2 2.1)
4541
4542þitem
4543
4544 þhpt{fork()} doesn't work correctly in multithread programs.
4545
4546þenditemize
4547
4548þtext
4549
4550--------------------------- END OF EMXDEV.DOC ------------------------------
4551þendtext
Note: See TracBrowser for help on using the repository browser.