175fd0b74Schristos /* coff information for Intel 386/486. 275fd0b74Schristos 3*e992f068Schristos Copyright (C) 2001-2022 Free Software Foundation, Inc. 475fd0b74Schristos 575fd0b74Schristos This program is free software; you can redistribute it and/or modify 675fd0b74Schristos it under the terms of the GNU General Public License as published by 775fd0b74Schristos the Free Software Foundation; either version 3 of the License, or 875fd0b74Schristos (at your option) any later version. 975fd0b74Schristos 1075fd0b74Schristos This program is distributed in the hope that it will be useful, 1175fd0b74Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1275fd0b74Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1375fd0b74Schristos GNU General Public License for more details. 1475fd0b74Schristos 1575fd0b74Schristos You should have received a copy of the GNU General Public License 1675fd0b74Schristos along with this program; if not, write to the Free Software 1775fd0b74Schristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 1875fd0b74Schristos MA 02110-1301, USA. */ 1975fd0b74Schristos 2075fd0b74Schristos #define L_LNNO_SIZE 2 2175fd0b74Schristos #define INCLUDE_COMDAT_FIELDS_IN_AUXENT 2275fd0b74Schristos #include "coff/external.h" 2375fd0b74Schristos 2475fd0b74Schristos #define COFF_PAGE_SIZE 0x1000 2575fd0b74Schristos 2675fd0b74Schristos /* Bits for f_flags: 2775fd0b74Schristos F_RELFLG Relocation info stripped from file 2875fd0b74Schristos F_EXEC File is executable (no unresolved external references) 2975fd0b74Schristos F_LNNO Line numbers stripped from file 3075fd0b74Schristos F_LSYMS Local symbols stripped from file 3175fd0b74Schristos F_AR32WR File has byte ordering of an AR32WR machine (e.g. vax). */ 3275fd0b74Schristos 3375fd0b74Schristos #define F_RELFLG (0x0001) 3475fd0b74Schristos #define F_EXEC (0x0002) 3575fd0b74Schristos #define F_LNNO (0x0004) 3675fd0b74Schristos #define F_LSYMS (0x0008) 3775fd0b74Schristos 3875fd0b74Schristos #define I386MAGIC 0x14c 3975fd0b74Schristos #define I386PTXMAGIC 0x154 4075fd0b74Schristos #define I386AIXMAGIC 0x175 4175fd0b74Schristos 4275fd0b74Schristos /* This is Lynx's all-platform magic number for executables. */ 4375fd0b74Schristos 4475fd0b74Schristos #define LYNXCOFFMAGIC 0415 4575fd0b74Schristos 46012573ebSchristos /* .NET DLLs XOR the Machine number (above) with an override to 47012573ebSchristos indicate that the DLL contains OS-specific machine code rather 48012573ebSchristos than just IL or bytecode. See 49012573ebSchristos https://github.com/dotnet/coreclr/blob/6f7aa7967c607b8c667518314ab937c0d7547025/src/inc/pedecoder.h#L94-L107. */ 50012573ebSchristos #define IMAGE_FILE_MACHINE_NATIVE_APPLE_OVERRIDE 0x4644 51012573ebSchristos #define IMAGE_FILE_MACHINE_NATIVE_FREEBSD_OVERRIDE 0xadc4 52012573ebSchristos #define IMAGE_FILE_MACHINE_NATIVE_LINUX_OVERRIDE 0x7b79 53012573ebSchristos #define IMAGE_FILE_MACHINE_NATIVE_NETBSD_OVERRIDE 0x1993 54012573ebSchristos 55012573ebSchristos /* Used in some .NET DLLs that target a specific OS. */ 56012573ebSchristos #define I386_APPLE_MAGIC (I386MAGIC ^ IMAGE_FILE_MACHINE_NATIVE_APPLE_OVERRIDE) 57012573ebSchristos #define I386_FREEBSD_MAGIC (I386MAGIC ^ IMAGE_FILE_MACHINE_NATIVE_FREEBSD_OVERRIDE) 58012573ebSchristos #define I386_LINUX_MAGIC (I386MAGIC ^ IMAGE_FILE_MACHINE_NATIVE_LINUX_OVERRIDE) 59012573ebSchristos #define I386_NETBSD_MAGIC (I386MAGIC ^ IMAGE_FILE_MACHINE_NATIVE_NETBSD_OVERRIDE) 60012573ebSchristos 6175fd0b74Schristos #define I386BADMAG(x) ( ((x).f_magic != I386MAGIC) \ 62012573ebSchristos && (x).f_magic != I386_APPLE_MAGIC \ 63012573ebSchristos && (x).f_magic != I386_FREEBSD_MAGIC \ 64012573ebSchristos && (x).f_magic != I386_LINUX_MAGIC \ 65012573ebSchristos && (x).f_magic != I386_NETBSD_MAGIC \ 6675fd0b74Schristos && (x).f_magic != I386AIXMAGIC \ 6775fd0b74Schristos && (x).f_magic != I386PTXMAGIC \ 6875fd0b74Schristos && (x).f_magic != LYNXCOFFMAGIC) 6975fd0b74Schristos 7075fd0b74Schristos #define OMAGIC 0404 /* Object files, eg as output. */ 7175fd0b74Schristos #define ZMAGIC 0413 /* Demand load format, eg normal ld output. */ 7275fd0b74Schristos #define STMAGIC 0401 /* Target shlib. */ 7375fd0b74Schristos #define SHMAGIC 0443 /* Host shlib. */ 7475fd0b74Schristos 7575fd0b74Schristos /* Define some NT default values. */ 7675fd0b74Schristos /* #define NT_IMAGE_BASE 0x400000 moved to internal.h */ 7775fd0b74Schristos #define NT_SECTION_ALIGNMENT 0x1000 7875fd0b74Schristos #define NT_FILE_ALIGNMENT 0x200 7975fd0b74Schristos #define NT_DEF_RESERVE 0x100000 8075fd0b74Schristos #define NT_DEF_COMMIT 0x1000 8175fd0b74Schristos 8275fd0b74Schristos /* Relocation directives. */ 8375fd0b74Schristos 8475fd0b74Schristos struct external_reloc 8575fd0b74Schristos { 8675fd0b74Schristos char r_vaddr[4]; 8775fd0b74Schristos char r_symndx[4]; 8875fd0b74Schristos char r_type[2]; 8975fd0b74Schristos }; 9075fd0b74Schristos 9175fd0b74Schristos #define RELOC struct external_reloc 9275fd0b74Schristos #define RELSZ 10 9375fd0b74Schristos 94*e992f068Schristos /* i386 Relocations. */ 95*e992f068Schristos 96*e992f068Schristos #define R_DIR32 6 97*e992f068Schristos #define R_IMAGEBASE 7 98*e992f068Schristos #define R_SECTION 10 99*e992f068Schristos #define R_SECREL32 11 100*e992f068Schristos #define R_RELBYTE 15 101*e992f068Schristos #define R_RELWORD 16 102*e992f068Schristos #define R_RELLONG 17 103*e992f068Schristos #define R_PCRBYTE 18 104*e992f068Schristos #define R_PCRWORD 19 105*e992f068Schristos #define R_PCRLONG 20 106