| 1 | /* emxbind.h -- Global header file for emxbind
|
|---|
| 2 | Copyright (c) 1991-1998 Eberhard Mattes
|
|---|
| 3 |
|
|---|
| 4 | This file is part of emxbind.
|
|---|
| 5 |
|
|---|
| 6 | emxbind is free software; you can redistribute it and/or modify it
|
|---|
| 7 | under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | emxbind is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with emxbind; see the file COPYING. If not, write to
|
|---|
| 18 | the Free Software Foundation, 59 Temple Place - Suite 330,
|
|---|
| 19 | Boston, MA 02111-1307, USA. */
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | #if defined (EXTERN)
|
|---|
| 23 | #define INIT(X) = X
|
|---|
| 24 | #define INIT_GROW = GROW_INIT
|
|---|
| 25 | #else
|
|---|
| 26 | #define INIT(X)
|
|---|
| 27 | #define INIT_GROW
|
|---|
| 28 | #define EXTERN extern
|
|---|
| 29 | #endif
|
|---|
| 30 |
|
|---|
| 31 | /* By default, don't implement the -L option (for listing the headers
|
|---|
| 32 | of an EXE file). */
|
|---|
| 33 |
|
|---|
| 34 | #if !defined (LIST_OPT)
|
|---|
| 35 | #define LIST_OPT FALSE
|
|---|
| 36 | #endif
|
|---|
| 37 |
|
|---|
| 38 | /* This is the version number. */
|
|---|
| 39 |
|
|---|
| 40 | #define VERSION "0.9d"
|
|---|
| 41 |
|
|---|
| 42 | /* Put this at the end of a function declaration to tell the compiler
|
|---|
| 43 | that the function never returns. */
|
|---|
| 44 |
|
|---|
| 45 | #define NORETURN2 __attribute__ ((noreturn))
|
|---|
| 46 |
|
|---|
| 47 | /* Number of characters in a file name. */
|
|---|
| 48 |
|
|---|
| 49 | #define FNAME_SIZE 512
|
|---|
| 50 |
|
|---|
| 51 | /* This is the default value for the -h option (heap size). */
|
|---|
| 52 |
|
|---|
| 53 | #define DEFAULT_HEAP_SIZE 0x02000000 /* 32 MB */
|
|---|
| 54 |
|
|---|
| 55 | /* This is the default value for the -k option (stack size). */
|
|---|
| 56 |
|
|---|
| 57 | #define DEFAULT_STACK_SIZE (8*1024*1024)
|
|---|
| 58 |
|
|---|
| 59 | /* A_OUT_OFFSET is the offset from the start of the a.out file to the
|
|---|
| 60 | text segment in the file. */
|
|---|
| 61 |
|
|---|
| 62 | #define A_OUT_OFFSET 0x0400
|
|---|
| 63 |
|
|---|
| 64 | /* This is the start address (in memory) of the text segment. */
|
|---|
| 65 |
|
|---|
| 66 | #define TEXT_BASE 0x00010000
|
|---|
| 67 |
|
|---|
| 68 | /* We use up to 4 memory objects in an LX executable file. */
|
|---|
| 69 |
|
|---|
| 70 | #define OBJECTS 4
|
|---|
| 71 |
|
|---|
| 72 | /* Source types for LX fixup records. */
|
|---|
| 73 |
|
|---|
| 74 | #define NRSTYP 0x0f /* Mask */
|
|---|
| 75 | #define NRSBYT 0x00 /* 8-bit byte (8-bits) */
|
|---|
| 76 | #define NRSSEG 0x02 /* 16-bit selector (16-bits) */
|
|---|
| 77 | #define NRSPTR 0x03 /* 16:16 pointer (32-bits) */
|
|---|
| 78 | #define NRSOFF 0x05 /* 16-bit offset (16-bits) */
|
|---|
| 79 | #define NRPTR48 0x06 /* 16:32 pointer (48-bits) */
|
|---|
| 80 | #define NROFF32 0x07 /* 32-bit offset (32-bits) */
|
|---|
| 81 | #define NRSOFF32 0x08 /* 32-bit self-relative offset (32-bits) */
|
|---|
| 82 |
|
|---|
| 83 | #define NRALIAS 0x10 /* Fixup to 16:16 alias */
|
|---|
| 84 | #define NRCHAIN 0x20 /* List of source offsets follows */
|
|---|
| 85 |
|
|---|
| 86 | /* Reference types for LX fixup records. */
|
|---|
| 87 |
|
|---|
| 88 | #define NRRTYP 0x03 /* Mask */
|
|---|
| 89 | #define NRRINT 0x00 /* Internal reference */
|
|---|
| 90 | #define NRRORD 0x01 /* Import by ordinal */
|
|---|
| 91 | #define NRRNAM 0x02 /* Import by name */
|
|---|
| 92 |
|
|---|
| 93 | /* Flags for LX fixup records. */
|
|---|
| 94 |
|
|---|
| 95 | #define NRADD 0x04 /* Additive fixup */
|
|---|
| 96 | #define NR32BITOFF 0x10 /* 32-bit target offset */
|
|---|
| 97 | #define NR32BITADD 0x20 /* 32-bit additive fixup */
|
|---|
| 98 | #define NR16OBJMOD 0x40 /* 16-bit object/module ordinal */
|
|---|
| 99 | #define NR8BITORD 0x80 /* 8-bit import ordinal */
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | /* How to open a file. This type is used for my_open(). */
|
|---|
| 103 |
|
|---|
| 104 | enum open_mode
|
|---|
| 105 | {
|
|---|
| 106 | open_read, create_write, open_read_write
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 | /* A file. OK is non-zero if the file is open. DEL is not yet used.
|
|---|
| 110 | F is the stream. NAME is the name of the file. */
|
|---|
| 111 |
|
|---|
| 112 | struct file
|
|---|
| 113 | {
|
|---|
| 114 | int ok, del;
|
|---|
| 115 | FILE *f;
|
|---|
| 116 | const char *name;
|
|---|
| 117 | };
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | /* Internal representation of fixups. */
|
|---|
| 121 |
|
|---|
| 122 | #define FIXUP_ABS 0
|
|---|
| 123 | #define FIXUP_REL 1
|
|---|
| 124 | #define FIXUP_FAR16 2
|
|---|
| 125 |
|
|---|
| 126 | #define TARGET_ORD 0
|
|---|
| 127 | #define TARGET_NAME 1
|
|---|
| 128 | #define TARGET_ADDR 2
|
|---|
| 129 |
|
|---|
| 130 | struct fixup
|
|---|
| 131 | {
|
|---|
| 132 | int type; /* fixup type, see constants above */
|
|---|
| 133 | int target; /* fixup target, see constants above */
|
|---|
| 134 | dword addr; /* address of patch */
|
|---|
| 135 | int obj; /* object number (where to patch) */
|
|---|
| 136 | int mod; /* module number or object (target) */
|
|---|
| 137 | dword dst; /* name or ordinal or address */
|
|---|
| 138 | dword add; /* additive fixup if non-zero */
|
|---|
| 139 | };
|
|---|
| 140 |
|
|---|
| 141 | /* Internal representation of an export definition. */
|
|---|
| 142 |
|
|---|
| 143 | struct export
|
|---|
| 144 | {
|
|---|
| 145 | char *entryname;
|
|---|
| 146 | char *internalname;
|
|---|
| 147 | long ord;
|
|---|
| 148 | int resident;
|
|---|
| 149 | dword offset;
|
|---|
| 150 | int object;
|
|---|
| 151 | };
|
|---|
| 152 |
|
|---|
| 153 | /* A growable buffer. */
|
|---|
| 154 |
|
|---|
| 155 | #define GROW_INIT {NULL, 0, 0}
|
|---|
| 156 |
|
|---|
| 157 | struct grow
|
|---|
| 158 | {
|
|---|
| 159 | byte *data;
|
|---|
| 160 | size_t size;
|
|---|
| 161 | size_t len;
|
|---|
| 162 | };
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 | /* This variable holds the command code. For instance, it is 'b' for
|
|---|
| 166 | binding. */
|
|---|
| 167 |
|
|---|
| 168 | EXTERN int mode INIT (0);
|
|---|
| 169 |
|
|---|
| 170 | /* Verbosity level. */
|
|---|
| 171 |
|
|---|
| 172 | EXTERN int verbosity INIT (1);
|
|---|
| 173 |
|
|---|
| 174 | /* The name of an emx.dll replacement (set by the -E option) or NULL
|
|---|
| 175 | (for emx.dll). */
|
|---|
| 176 |
|
|---|
| 177 | EXTERN char *emx_dll INIT (NULL);
|
|---|
| 178 |
|
|---|
| 179 | /* The OS/2 heap size, in bytes. The default value is 32 MB. The
|
|---|
| 180 | heap size can be changed with the -h option. */
|
|---|
| 181 |
|
|---|
| 182 | EXTERN long heap_size INIT (DEFAULT_HEAP_SIZE);
|
|---|
| 183 |
|
|---|
| 184 | /* The OS/2 stack size, in bytes. The default value is 8 MB. The
|
|---|
| 185 | stack size can be changed with the -k option and the STACKSIZE
|
|---|
| 186 | module statement. */
|
|---|
| 187 |
|
|---|
| 188 | EXTERN long stack_size INIT (DEFAULT_STACK_SIZE);
|
|---|
| 189 |
|
|---|
| 190 | /* The name of the core dump file (set by the -c option) or NULL (if
|
|---|
| 191 | there is no core dump file). */
|
|---|
| 192 |
|
|---|
| 193 | EXTERN char *opt_c INIT (NULL);
|
|---|
| 194 |
|
|---|
| 195 | /* Create a full-screen application. This flag is set by the -f
|
|---|
| 196 | option. */
|
|---|
| 197 |
|
|---|
| 198 | EXTERN int opt_f INIT (FALSE);
|
|---|
| 199 |
|
|---|
| 200 | /* Create a Presentation Manager application. This flag is set by the
|
|---|
| 201 | -p option. */
|
|---|
| 202 |
|
|---|
| 203 | EXTERN int opt_p INIT (FALSE);
|
|---|
| 204 |
|
|---|
| 205 | /* The name of the map file (set by the -m option) or NULL (if no .map
|
|---|
| 206 | file should be written). */
|
|---|
| 207 |
|
|---|
| 208 | EXTERN char *opt_m INIT (NULL);
|
|---|
| 209 |
|
|---|
| 210 | /* The name of the binary resource file (set by the -r option) or NULL
|
|---|
| 211 | (if there is no binary resource file). */
|
|---|
| 212 |
|
|---|
| 213 | EXTERN char *opt_r INIT (NULL);
|
|---|
| 214 |
|
|---|
| 215 | /* Strip symbols. This flag is set by the -s option. */
|
|---|
| 216 |
|
|---|
| 217 | EXTERN int opt_s INIT (FALSE);
|
|---|
| 218 |
|
|---|
| 219 | /* Create a windowed application. This flag is set by the -w
|
|---|
| 220 | option. */
|
|---|
| 221 |
|
|---|
| 222 | EXTERN int opt_w INIT (FALSE);
|
|---|
| 223 |
|
|---|
| 224 | /* If this flag is set, create an `empty' heap object and let emx.dll
|
|---|
| 225 | load the heap pages at run-time (that's what previous versions of
|
|---|
| 226 | emxbind did for historical reasons; now that's used only for
|
|---|
| 227 | creating EXE files for testing emx.dll or for saving memory if
|
|---|
| 228 | MEMMAN=COMMIT is in effect). Otherwise, create a heap object which
|
|---|
| 229 | contains the data pages of the core dump file. Of course, all this
|
|---|
| 230 | applies only if the -c option is given. This flag is set by the -C
|
|---|
| 231 | option. */
|
|---|
| 232 |
|
|---|
| 233 | EXTERN int old_heap INIT (FALSE);
|
|---|
| 234 |
|
|---|
| 235 | /* The module name. */
|
|---|
| 236 |
|
|---|
| 237 | EXTERN char *module_name INIT (NULL);
|
|---|
| 238 |
|
|---|
| 239 | /* The application type. */
|
|---|
| 240 |
|
|---|
| 241 | EXTERN int app_type INIT (_MDT_DEFAULT);
|
|---|
| 242 |
|
|---|
| 243 | /* INITINSTANCE, INITGLOBAL, TERMINSTANCE and TERMGLOBAL. */
|
|---|
| 244 |
|
|---|
| 245 | EXTERN int init_global INIT (TRUE);
|
|---|
| 246 | EXTERN int term_global INIT (TRUE);
|
|---|
| 247 |
|
|---|
| 248 | /* The description string. */
|
|---|
| 249 |
|
|---|
| 250 | EXTERN char *description INIT (NULL);
|
|---|
| 251 |
|
|---|
| 252 | /* The emx options for DOS and OS/2, respectively, are stored in these
|
|---|
| 253 | buffers, before being written to the emxbind headers. */
|
|---|
| 254 |
|
|---|
| 255 | EXTERN char options_for_dos[512];
|
|---|
| 256 | EXTERN char options_for_os2[512];
|
|---|
| 257 |
|
|---|
| 258 | /* The name of the output file. */
|
|---|
| 259 |
|
|---|
| 260 | EXTERN char out_fname[FNAME_SIZE];
|
|---|
| 261 |
|
|---|
| 262 | /* File structure for the input executable. Note that the `ok' field
|
|---|
| 263 | is initialized to FALSE to avoid closing an unopened file. */
|
|---|
| 264 |
|
|---|
| 265 | EXTERN struct file inp_file INIT ({FALSE});
|
|---|
| 266 |
|
|---|
| 267 | /* File structure for the binary resource file (-r option). Note that
|
|---|
| 268 | the `ok' field is initialized to FALSE to avoid closing an unopened
|
|---|
| 269 | file. */
|
|---|
| 270 |
|
|---|
| 271 | EXTERN struct file res_file INIT ({FALSE});
|
|---|
| 272 |
|
|---|
| 273 | /* File structure for the destination executable file. Note that the
|
|---|
| 274 | `ok' field is initialized to FALSE to avoid closing an unopened
|
|---|
| 275 | file. */
|
|---|
| 276 |
|
|---|
| 277 | EXTERN struct file out_file INIT ({FALSE});
|
|---|
| 278 |
|
|---|
| 279 | /* File structure for emxl.exe or emx.exe. Note that the `ok' field
|
|---|
| 280 | is initialized to FALSE to avoid closing an unopened file. */
|
|---|
| 281 |
|
|---|
| 282 | EXTERN struct file emx_file INIT ({FALSE});
|
|---|
| 283 |
|
|---|
| 284 | /* File structure for the core dump file (-c option). Note that the
|
|---|
| 285 | `ok' field is initialized to FALSE to avoid closing an unopened
|
|---|
| 286 | file. */
|
|---|
| 287 |
|
|---|
| 288 | EXTERN struct file core_file INIT ({FALSE});
|
|---|
| 289 |
|
|---|
| 290 | /* The DOS EXE headers read from the input executable. */
|
|---|
| 291 |
|
|---|
| 292 | EXTERN struct exe1_header inp_h1;
|
|---|
| 293 | EXTERN struct exe2_header inp_h2;
|
|---|
| 294 |
|
|---|
| 295 | /* The a.out header read from the source a.out (sub)file. */
|
|---|
| 296 |
|
|---|
| 297 | EXTERN struct a_out_header a_in_h;
|
|---|
| 298 |
|
|---|
| 299 | /* The DOS and OS/2 emxbind headers, respectively. */
|
|---|
| 300 |
|
|---|
| 301 | EXTERN struct dos_bind_header dos_bind_h;
|
|---|
| 302 | EXTERN struct os2_bind_header os2_bind_h;
|
|---|
| 303 |
|
|---|
| 304 | /* The fixed part of the LX header. */
|
|---|
| 305 |
|
|---|
| 306 | EXTERN struct os2_header os2_h;
|
|---|
| 307 |
|
|---|
| 308 | /* This flag is set by check_bound() to indicate whether the input
|
|---|
| 309 | file is a bound executable or not. Only the -L option (for listing
|
|---|
| 310 | the headers) can process executables which are not bound. */
|
|---|
| 311 |
|
|---|
| 312 | EXTERN int is_bound;
|
|---|
| 313 |
|
|---|
| 314 | /* The location of the a.out header in the source file. */
|
|---|
| 315 |
|
|---|
| 316 | EXTERN long a_in_pos;
|
|---|
| 317 |
|
|---|
| 318 | /* The size of the string table in the source a.out (sub)file. */
|
|---|
| 319 |
|
|---|
| 320 | EXTERN long a_in_str_size;
|
|---|
| 321 |
|
|---|
| 322 | /* The offsets of the data section and symbol table, respectively, of
|
|---|
| 323 | the source a.out (sub)file. */
|
|---|
| 324 |
|
|---|
| 325 | EXTERN long a_in_data;
|
|---|
| 326 | EXTERN long a_in_sym;
|
|---|
| 327 |
|
|---|
| 328 | /* This table contains all the fixups of the module, in an internal
|
|---|
| 329 | format. fixup_size is the number of entries allocated, fixup_len
|
|---|
| 330 | is the number of entries used. */
|
|---|
| 331 |
|
|---|
| 332 | EXTERN struct fixup *fixup_data INIT (NULL);
|
|---|
| 333 | EXTERN int fixup_size INIT (0);
|
|---|
| 334 | EXTERN int fixup_len INIT (0);
|
|---|
| 335 |
|
|---|
| 336 | /* procs holds the import procedure name table (table of import symbol
|
|---|
| 337 | names) of the executable, in LX EXE format, while it is being
|
|---|
| 338 | built. */
|
|---|
| 339 |
|
|---|
| 340 | EXTERN struct grow procs INIT_GROW;
|
|---|
| 341 |
|
|---|
| 342 | /* Create a relocatable executable if this flag is true. This flag is
|
|---|
| 343 | set when creating a DLL. */
|
|---|
| 344 |
|
|---|
| 345 | EXTERN int relocatable INIT (FALSE);
|
|---|
| 346 |
|
|---|
| 347 | /* The base address of the initialized data segment. */
|
|---|
| 348 |
|
|---|
| 349 | EXTERN dword data_base;
|
|---|
| 350 |
|
|---|
| 351 | /* Add one of these offsets to an text or data address, respectively,
|
|---|
| 352 | to get the location in the input executable. */
|
|---|
| 353 |
|
|---|
| 354 | EXTERN long text_off;
|
|---|
| 355 | EXTERN long data_off;
|
|---|
| 356 |
|
|---|
| 357 | /* These arrays contain the text and data sections, respectively, of
|
|---|
| 358 | the source a.out file. */
|
|---|
| 359 |
|
|---|
| 360 | EXTERN byte *text_image INIT (NULL);
|
|---|
| 361 | EXTERN byte *data_image INIT (NULL);
|
|---|
| 362 |
|
|---|
| 363 | /* These arrays contain the text and data relocation tables,
|
|---|
| 364 | respectively, as read from the source a.out file. */
|
|---|
| 365 |
|
|---|
| 366 | EXTERN struct reloc *tr_image INIT (NULL);
|
|---|
| 367 | EXTERN struct reloc *dr_image INIT (NULL);
|
|---|
| 368 |
|
|---|
| 369 | /* This array contains the symbol table, as read from the source a.out
|
|---|
| 370 | file. */
|
|---|
| 371 |
|
|---|
| 372 | EXTERN struct nlist *sym_image INIT (NULL);
|
|---|
| 373 |
|
|---|
| 374 | /* This array contains the string table, as read from the source a.out
|
|---|
| 375 | file. */
|
|---|
| 376 |
|
|---|
| 377 | EXTERN byte *str_image INIT (NULL);
|
|---|
| 378 |
|
|---|
| 379 | /* This is the number of symbols of the source a.out file. */
|
|---|
| 380 |
|
|---|
| 381 | EXTERN int sym_count INIT (-1);
|
|---|
| 382 |
|
|---|
| 383 | /* This array holds the object table entries. Usually, the entries
|
|---|
| 384 | are accessed via aliases, such as obj_text. */
|
|---|
| 385 |
|
|---|
| 386 | EXTERN struct object obj_h[OBJECTS];
|
|---|
| 387 |
|
|---|
| 388 | /* These are indices for the obj_h array. */
|
|---|
| 389 |
|
|---|
| 390 | #define OBJ_TEXT 0
|
|---|
| 391 | #define OBJ_DATA 1
|
|---|
| 392 | #define OBJ_HEAP 2
|
|---|
| 393 | #define OBJ_STK0 3
|
|---|
| 394 |
|
|---|
| 395 | /* Define shortcuts for the elements of the obj_h array. */
|
|---|
| 396 |
|
|---|
| 397 | #define obj_text obj_h[OBJ_TEXT]
|
|---|
| 398 | #define obj_data obj_h[OBJ_DATA]
|
|---|
| 399 | #define obj_heap obj_h[OBJ_HEAP]
|
|---|
| 400 | #define obj_stk0 obj_h[OBJ_STK0]
|
|---|
| 401 |
|
|---|
| 402 | /* This is the number of resource objects. */
|
|---|
| 403 |
|
|---|
| 404 | EXTERN int res_obj_count;
|
|---|
| 405 |
|
|---|
| 406 | /* This is the number of resources. */
|
|---|
| 407 |
|
|---|
| 408 | EXTERN int res_count;
|
|---|
| 409 |
|
|---|
| 410 | /* This is the number of resource pages. */
|
|---|
| 411 |
|
|---|
| 412 | EXTERN int res_pages;
|
|---|
| 413 |
|
|---|
| 414 | /* This is the number of preload resource pages. */
|
|---|
| 415 |
|
|---|
| 416 | EXTERN int res_preload_pages;
|
|---|
| 417 |
|
|---|
| 418 | /* entry_tab holds the entry table (table of exports) of the
|
|---|
| 419 | executable, in LX EXE format, while it is being built. */
|
|---|
| 420 |
|
|---|
| 421 | EXTERN struct grow entry_tab INIT_GROW;
|
|---|
| 422 |
|
|---|
| 423 | /* resnames holds the resident name table (table of export symbol
|
|---|
| 424 | names) of the executable, in LX EXE format, while it is being
|
|---|
| 425 | built. */
|
|---|
| 426 |
|
|---|
| 427 | EXTERN struct grow resnames INIT_GROW;
|
|---|
| 428 |
|
|---|
| 429 | /* nonresnames holds the non-resident name table (table of export
|
|---|
| 430 | symbol names) of the executable, in LX EXE format, while it is
|
|---|
| 431 | being built. */
|
|---|
| 432 |
|
|---|
| 433 | EXTERN struct grow nonresnames INIT_GROW;
|
|---|
| 434 |
|
|---|
| 435 | /* The DOS EXE headers to be written to the output executable. */
|
|---|
| 436 |
|
|---|
| 437 | EXTERN struct exe1_header out_h1;
|
|---|
| 438 | EXTERN struct exe2_header out_h2;
|
|---|
| 439 |
|
|---|
| 440 | /* The emxbind DOS header of emxl.exe or emx.exe. */
|
|---|
| 441 |
|
|---|
| 442 | EXTERN struct dos_bind_header emx_bind_h;
|
|---|
| 443 |
|
|---|
| 444 | /* The bytes address of the DOS patch area in the input executable. */
|
|---|
| 445 |
|
|---|
| 446 | EXTERN long patch_pos;
|
|---|
| 447 |
|
|---|
| 448 | /* The location of the LX header of the output executable. */
|
|---|
| 449 |
|
|---|
| 450 | EXTERN long os2_hdr_pos;
|
|---|
| 451 |
|
|---|
| 452 | /* The location of the LX header in the input executable. */
|
|---|
| 453 |
|
|---|
| 454 | EXTERN long inp_os2_pos;
|
|---|
| 455 |
|
|---|
| 456 | /* The location of the a.out header in the output executable. */
|
|---|
| 457 |
|
|---|
| 458 | EXTERN long a_out_pos;
|
|---|
| 459 |
|
|---|
| 460 | /* The number of zero bytes to insert between the emx.exe or emxl.exe
|
|---|
| 461 | image and the LX header. */
|
|---|
| 462 |
|
|---|
| 463 | EXTERN long fill2;
|
|---|
| 464 |
|
|---|
| 465 | /* This flag is set if a LIBRARY statement is seen in the module
|
|---|
| 466 | definition file. */
|
|---|
| 467 |
|
|---|
| 468 | EXTERN int dll_flag INIT (FALSE);
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 | /* Round up to the next multiple of 4. */
|
|---|
| 472 |
|
|---|
| 473 | #define round_4(X) ((((X)-1) & ~3) + 4)
|
|---|
| 474 |
|
|---|
| 475 | /* Round up to the next multiple of the page size (0x1000). */
|
|---|
| 476 |
|
|---|
| 477 | #define round_page(X) ((((X)-1) & ~0xfff) + 0x1000)
|
|---|
| 478 |
|
|---|
| 479 | /* Divide by the page size, rounding down. */
|
|---|
| 480 |
|
|---|
| 481 | #define div_page(X) ((X) >> 12)
|
|---|
| 482 |
|
|---|
| 483 | /* Compute the number of pages required for X bytes. */
|
|---|
| 484 |
|
|---|
| 485 | #define npages(X) div_page (round_page (X))
|
|---|
| 486 |
|
|---|
| 487 | /* Return the low 16-bit word of a 32-bit word. */
|
|---|
| 488 |
|
|---|
| 489 | #define LOWORD(X) ((X) & 0xffff)
|
|---|
| 490 |
|
|---|
| 491 | /* Return the high 16-bit word of a 32-bit word. */
|
|---|
| 492 |
|
|---|
| 493 | #define HIWORD(X) ((X) >> 16)
|
|---|
| 494 |
|
|---|
| 495 | /* Combine two 16-bit words (low word L and high word H) into a 32-bit
|
|---|
| 496 | word. */
|
|---|
| 497 |
|
|---|
| 498 | #define COMBINE(L,H) ((L) | (long)((H) << 16))
|
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 | /* exec.c */
|
|---|
| 502 |
|
|---|
| 503 | void check_bound (void);
|
|---|
| 504 | void read_emx (void);
|
|---|
| 505 | void read_a_out_header (void);
|
|---|
| 506 | void read_core (void);
|
|---|
| 507 | void read_segs (void);
|
|---|
| 508 | void read_reloc (void);
|
|---|
| 509 | void read_sym (void);
|
|---|
| 510 | void read_os2_header (void);
|
|---|
| 511 | void exe_flags (void);
|
|---|
| 512 | void set_dos_bind_header (void);
|
|---|
| 513 | void set_options (void);
|
|---|
| 514 | void set_exe_header (void);
|
|---|
| 515 | void put_header_byte (byte x);
|
|---|
| 516 | void put_header_word (word x);
|
|---|
| 517 | void put_header_dword (dword x);
|
|---|
| 518 | void put_header_bytes (const void *src, size_t size);
|
|---|
| 519 | void init_os2_header (void);
|
|---|
| 520 | void set_os2_header (void);
|
|---|
| 521 | void write_header (void);
|
|---|
| 522 | void write_nonres (void);
|
|---|
| 523 | void write_bind_header (void);
|
|---|
| 524 | void copy_a_out (void);
|
|---|
| 525 | void fill (long count);
|
|---|
| 526 | void copy (struct file *src, long size);
|
|---|
| 527 |
|
|---|
| 528 | /* fixup.c */
|
|---|
| 529 |
|
|---|
| 530 | void build_sym_hash_table (void);
|
|---|
| 531 | void sort_fixup (void);
|
|---|
| 532 | void create_fixup (const struct fixup *fp, int neg);
|
|---|
| 533 | void relocations (void);
|
|---|
| 534 | void os2_fixup (void);
|
|---|
| 535 | void put_impmod (void);
|
|---|
| 536 |
|
|---|
| 537 | /* export.c */
|
|---|
| 538 |
|
|---|
| 539 | void add_export (const struct export *exp);
|
|---|
| 540 | void entry_name (struct grow *table, const char *name, int ord);
|
|---|
| 541 | void exports (void);
|
|---|
| 542 | const struct export *get_export (int i);
|
|---|
| 543 |
|
|---|
| 544 | /* resource.c */
|
|---|
| 545 |
|
|---|
| 546 | void read_res (void);
|
|---|
| 547 | void put_rsctab (void);
|
|---|
| 548 | void put_res_obj (int map);
|
|---|
| 549 | void write_res (void);
|
|---|
| 550 |
|
|---|
| 551 | /* cmd.c */
|
|---|
| 552 |
|
|---|
| 553 | void cmd (int mode);
|
|---|
| 554 |
|
|---|
| 555 | /* list.c */
|
|---|
| 556 |
|
|---|
| 557 | #if LIST_OPT
|
|---|
| 558 | void list (void);
|
|---|
| 559 | #endif
|
|---|
| 560 |
|
|---|
| 561 | /* map.c */
|
|---|
| 562 |
|
|---|
| 563 | void write_map (const char *fname);
|
|---|
| 564 | void map_import (const char *sym_name, const char *mod, const char *name,
|
|---|
| 565 | int ord);
|
|---|
| 566 |
|
|---|
| 567 | /* utils.c */
|
|---|
| 568 |
|
|---|
| 569 | void error (const char *fmt, ...) NORETURN2;
|
|---|
| 570 | void my_read (void *dst, size_t size, struct file *f);
|
|---|
| 571 | void my_read_str (byte *dst, size_t size, struct file *f);
|
|---|
| 572 | void my_write (const void *src, size_t size, struct file *f);
|
|---|
| 573 | void my_seek (struct file *f, long pos);
|
|---|
| 574 | void my_skip (struct file *f, long pos);
|
|---|
| 575 | long my_size (struct file *f);
|
|---|
| 576 | long my_tell (struct file *f);
|
|---|
| 577 | void my_trunc (struct file *f);
|
|---|
| 578 | void my_change (struct file *dst, struct file *src);
|
|---|
| 579 | void my_open (struct file *f, const char *name, enum open_mode mode);
|
|---|
| 580 | void my_close (struct file *f);
|
|---|
| 581 | void my_remove (struct file *f);
|
|---|
| 582 | int my_readable (const char *name);
|
|---|
| 583 | void *xmalloc (size_t n);
|
|---|
| 584 | void *xrealloc (void *p, size_t n);
|
|---|
| 585 | char *xstrdup (const char *p);
|
|---|
| 586 | void put_grow (struct grow *dst, const void *src, size_t size);
|
|---|
| 587 | const char *plural_s (long n);
|
|---|