1*1b8adde7SWilliam Kucharski #ifndef I386_BITS_ELF_H 2*1b8adde7SWilliam Kucharski #define I386_BITS_ELF_H 3*1b8adde7SWilliam Kucharski 4*1b8adde7SWilliam Kucharski #include "cpu.h" 5*1b8adde7SWilliam Kucharski 6*1b8adde7SWilliam Kucharski #ifdef CONFIG_X86_64 7*1b8adde7SWilliam Kucharski /* ELF Defines for the 64bit version of the current architecture */ 8*1b8adde7SWilliam Kucharski #define EM_CURRENT_64 EM_X86_64 9*1b8adde7SWilliam Kucharski #define EM_CURRENT_64_PRESENT ( \ 10*1b8adde7SWilliam Kucharski CPU_FEATURE_P(cpu_info.x86_capability, LM) && \ 11*1b8adde7SWilliam Kucharski CPU_FEATURE_P(cpu_info.x86_capability, PAE) && \ 12*1b8adde7SWilliam Kucharski CPU_FEATURE_P(cpu_info.x86_capability, PSE)) 13*1b8adde7SWilliam Kucharski 14*1b8adde7SWilliam Kucharski #define ELF_CHECK_X86_64_ARCH(x) \ 15*1b8adde7SWilliam Kucharski (EM_CURRENT_64_PRESENT && ((x).e_machine == EM_X86_64)) 16*1b8adde7SWilliam Kucharski #define __unused_i386 17*1b8adde7SWilliam Kucharski #else 18*1b8adde7SWilliam Kucharski #define ELF_CHECK_X86_64_ARCH(x) 0 19*1b8adde7SWilliam Kucharski #define __unused_i386 __unused 20*1b8adde7SWilliam Kucharski #endif 21*1b8adde7SWilliam Kucharski 22*1b8adde7SWilliam Kucharski 23*1b8adde7SWilliam Kucharski /* ELF Defines for the current architecture */ 24*1b8adde7SWilliam Kucharski #define EM_CURRENT EM_386 25*1b8adde7SWilliam Kucharski #define ELFDATA_CURRENT ELFDATA2LSB 26*1b8adde7SWilliam Kucharski 27*1b8adde7SWilliam Kucharski #define ELF_CHECK_I386_ARCH(x) \ 28*1b8adde7SWilliam Kucharski (((x).e_machine == EM_386) || ((x).e_machine == EM_486)) 29*1b8adde7SWilliam Kucharski 30*1b8adde7SWilliam Kucharski #define ELF_CHECK_ARCH(x) \ 31*1b8adde7SWilliam Kucharski ((ELF_CHECK_I386_ARCH(x) || ELF_CHECK_X86_64_ARCH(x)) && \ 32*1b8adde7SWilliam Kucharski ((x).e_entry <= 0xffffffffUL)) 33*1b8adde7SWilliam Kucharski 34*1b8adde7SWilliam Kucharski #ifdef IMAGE_FREEBSD 35*1b8adde7SWilliam Kucharski /* 36*1b8adde7SWilliam Kucharski * FreeBSD has this rather strange "feature" of its design. 37*1b8adde7SWilliam Kucharski * At some point in its evolution, FreeBSD started to rely 38*1b8adde7SWilliam Kucharski * externally on private/static/debug internal symbol information. 39*1b8adde7SWilliam Kucharski * That is, some of the interfaces that software uses to access 40*1b8adde7SWilliam Kucharski * and work with the FreeBSD kernel are made available not 41*1b8adde7SWilliam Kucharski * via the shared library symbol information (the .DYNAMIC section) 42*1b8adde7SWilliam Kucharski * but rather the debug symbols. This means that any symbol, not 43*1b8adde7SWilliam Kucharski * just publicly defined symbols can be (and are) used by system 44*1b8adde7SWilliam Kucharski * tools to make the system work. (such as top, swapinfo, swapon, 45*1b8adde7SWilliam Kucharski * etc) 46*1b8adde7SWilliam Kucharski * 47*1b8adde7SWilliam Kucharski * Even worse, however, is the fact that standard ELF loaders do 48*1b8adde7SWilliam Kucharski * not know how to load the symbols since they are not within 49*1b8adde7SWilliam Kucharski * an ELF PT_LOAD section. The kernel needs these symbols to 50*1b8adde7SWilliam Kucharski * operate so the following changes/additions to the boot 51*1b8adde7SWilliam Kucharski * loading of EtherBoot have been made to get the kernel to load. 52*1b8adde7SWilliam Kucharski * All of the changes are within IMAGE_FREEBSD such that the 53*1b8adde7SWilliam Kucharski * extra/changed code only compiles when FREEBSD support is 54*1b8adde7SWilliam Kucharski * enabled. 55*1b8adde7SWilliam Kucharski */ 56*1b8adde7SWilliam Kucharski 57*1b8adde7SWilliam Kucharski /* 58*1b8adde7SWilliam Kucharski * Section header for FreeBSD (debug symbol kludge!) support 59*1b8adde7SWilliam Kucharski */ 60*1b8adde7SWilliam Kucharski typedef struct { 61*1b8adde7SWilliam Kucharski Elf32_Word sh_name; /* Section name (index into the 62*1b8adde7SWilliam Kucharski section header string table). */ 63*1b8adde7SWilliam Kucharski Elf32_Word sh_type; /* Section type. */ 64*1b8adde7SWilliam Kucharski Elf32_Word sh_flags; /* Section flags. */ 65*1b8adde7SWilliam Kucharski Elf32_Addr sh_addr; /* Address in memory image. */ 66*1b8adde7SWilliam Kucharski Elf32_Off sh_offset; /* Offset in file. */ 67*1b8adde7SWilliam Kucharski Elf32_Size sh_size; /* Size in bytes. */ 68*1b8adde7SWilliam Kucharski Elf32_Word sh_link; /* Index of a related section. */ 69*1b8adde7SWilliam Kucharski Elf32_Word sh_info; /* Depends on section type. */ 70*1b8adde7SWilliam Kucharski Elf32_Size sh_addralign; /* Alignment in bytes. */ 71*1b8adde7SWilliam Kucharski Elf32_Size sh_entsize; /* Size of each entry in section. */ 72*1b8adde7SWilliam Kucharski } Elf32_Shdr; 73*1b8adde7SWilliam Kucharski 74*1b8adde7SWilliam Kucharski /* sh_type */ 75*1b8adde7SWilliam Kucharski #define SHT_SYMTAB 2 /* symbol table section */ 76*1b8adde7SWilliam Kucharski #define SHT_STRTAB 3 /* string table section */ 77*1b8adde7SWilliam Kucharski 78*1b8adde7SWilliam Kucharski /* 79*1b8adde7SWilliam Kucharski * Module information subtypes (for the metadata that we need to build) 80*1b8adde7SWilliam Kucharski */ 81*1b8adde7SWilliam Kucharski #define MODINFO_END 0x0000 /* End of list */ 82*1b8adde7SWilliam Kucharski #define MODINFO_NAME 0x0001 /* Name of module (string) */ 83*1b8adde7SWilliam Kucharski #define MODINFO_TYPE 0x0002 /* Type of module (string) */ 84*1b8adde7SWilliam Kucharski #define MODINFO_METADATA 0x8000 /* Module-specfic */ 85*1b8adde7SWilliam Kucharski 86*1b8adde7SWilliam Kucharski #define MODINFOMD_SSYM 0x0003 /* start of symbols */ 87*1b8adde7SWilliam Kucharski #define MODINFOMD_ESYM 0x0004 /* end of symbols */ 88*1b8adde7SWilliam Kucharski 89*1b8adde7SWilliam Kucharski #endif /* IMAGE_FREEBSD */ 90*1b8adde7SWilliam Kucharski 91*1b8adde7SWilliam Kucharski #endif /* I386_BITS_ELF_H */ 92