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