17c478bd9Sstevel@tonic-gate #ifndef I386_BITS_ELF_H 27c478bd9Sstevel@tonic-gate #define I386_BITS_ELF_H 37c478bd9Sstevel@tonic-gate 47c478bd9Sstevel@tonic-gate #include "cpu.h" 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate #ifdef CONFIG_X86_64 77c478bd9Sstevel@tonic-gate /* ELF Defines for the 64bit version of the current architecture */ 87c478bd9Sstevel@tonic-gate #define EM_CURRENT_64 EM_X86_64 97c478bd9Sstevel@tonic-gate #define EM_CURRENT_64_PRESENT ( \ 107c478bd9Sstevel@tonic-gate CPU_FEATURE_P(cpu_info.x86_capability, LM) && \ 117c478bd9Sstevel@tonic-gate CPU_FEATURE_P(cpu_info.x86_capability, PAE) && \ 127c478bd9Sstevel@tonic-gate CPU_FEATURE_P(cpu_info.x86_capability, PSE)) 137c478bd9Sstevel@tonic-gate 147c478bd9Sstevel@tonic-gate #define ELF_CHECK_X86_64_ARCH(x) \ 157c478bd9Sstevel@tonic-gate (EM_CURRENT_64_PRESENT && ((x).e_machine == EM_X86_64)) 167c478bd9Sstevel@tonic-gate #define __unused_i386 177c478bd9Sstevel@tonic-gate #else 187c478bd9Sstevel@tonic-gate #define ELF_CHECK_X86_64_ARCH(x) 0 197c478bd9Sstevel@tonic-gate #define __unused_i386 __unused 207c478bd9Sstevel@tonic-gate #endif 217c478bd9Sstevel@tonic-gate 227c478bd9Sstevel@tonic-gate 237c478bd9Sstevel@tonic-gate /* ELF Defines for the current architecture */ 247c478bd9Sstevel@tonic-gate #define EM_CURRENT EM_386 257c478bd9Sstevel@tonic-gate #define ELFDATA_CURRENT ELFDATA2LSB 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #define ELF_CHECK_I386_ARCH(x) \ 287c478bd9Sstevel@tonic-gate (((x).e_machine == EM_386) || ((x).e_machine == EM_486)) 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #define ELF_CHECK_ARCH(x) \ 317c478bd9Sstevel@tonic-gate ((ELF_CHECK_I386_ARCH(x) || ELF_CHECK_X86_64_ARCH(x)) && \ 327c478bd9Sstevel@tonic-gate ((x).e_entry <= 0xffffffffUL)) 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef IMAGE_FREEBSD 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * FreeBSD has this rather strange "feature" of its design. 377c478bd9Sstevel@tonic-gate * At some point in its evolution, FreeBSD started to rely 387c478bd9Sstevel@tonic-gate * externally on private/static/debug internal symbol information. 397c478bd9Sstevel@tonic-gate * That is, some of the interfaces that software uses to access 407c478bd9Sstevel@tonic-gate * and work with the FreeBSD kernel are made available not 417c478bd9Sstevel@tonic-gate * via the shared library symbol information (the .DYNAMIC section) 427c478bd9Sstevel@tonic-gate * but rather the debug symbols. This means that any symbol, not 437c478bd9Sstevel@tonic-gate * just publicly defined symbols can be (and are) used by system 447c478bd9Sstevel@tonic-gate * tools to make the system work. (such as top, swapinfo, swapon, 457c478bd9Sstevel@tonic-gate * etc) 467c478bd9Sstevel@tonic-gate * 477c478bd9Sstevel@tonic-gate * Even worse, however, is the fact that standard ELF loaders do 487c478bd9Sstevel@tonic-gate * not know how to load the symbols since they are not within 497c478bd9Sstevel@tonic-gate * an ELF PT_LOAD section. The kernel needs these symbols to 507c478bd9Sstevel@tonic-gate * operate so the following changes/additions to the boot 517c478bd9Sstevel@tonic-gate * loading of EtherBoot have been made to get the kernel to load. 527c478bd9Sstevel@tonic-gate * All of the changes are within IMAGE_FREEBSD such that the 537c478bd9Sstevel@tonic-gate * extra/changed code only compiles when FREEBSD support is 547c478bd9Sstevel@tonic-gate * enabled. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 587c478bd9Sstevel@tonic-gate * Section header for FreeBSD (debug symbol kludge!) support 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate typedef struct { 617c478bd9Sstevel@tonic-gate Elf32_Word sh_name; /* Section name (index into the 627c478bd9Sstevel@tonic-gate section header string table). */ 637c478bd9Sstevel@tonic-gate Elf32_Word sh_type; /* Section type. */ 647c478bd9Sstevel@tonic-gate Elf32_Word sh_flags; /* Section flags. */ 657c478bd9Sstevel@tonic-gate Elf32_Addr sh_addr; /* Address in memory image. */ 667c478bd9Sstevel@tonic-gate Elf32_Off sh_offset; /* Offset in file. */ 677c478bd9Sstevel@tonic-gate Elf32_Size sh_size; /* Size in bytes. */ 687c478bd9Sstevel@tonic-gate Elf32_Word sh_link; /* Index of a related section. */ 697c478bd9Sstevel@tonic-gate Elf32_Word sh_info; /* Depends on section type. */ 707c478bd9Sstevel@tonic-gate Elf32_Size sh_addralign; /* Alignment in bytes. */ 717c478bd9Sstevel@tonic-gate Elf32_Size sh_entsize; /* Size of each entry in section. */ 727c478bd9Sstevel@tonic-gate } Elf32_Shdr; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* sh_type */ 757c478bd9Sstevel@tonic-gate #define SHT_SYMTAB 2 /* symbol table section */ 767c478bd9Sstevel@tonic-gate #define SHT_STRTAB 3 /* string table section */ 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * Module information subtypes (for the metadata that we need to build) 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate #define MODINFO_END 0x0000 /* End of list */ 827c478bd9Sstevel@tonic-gate #define MODINFO_NAME 0x0001 /* Name of module (string) */ 837c478bd9Sstevel@tonic-gate #define MODINFO_TYPE 0x0002 /* Type of module (string) */ 847c478bd9Sstevel@tonic-gate #define MODINFO_METADATA 0x8000 /* Module-specfic */ 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #define MODINFOMD_SSYM 0x0003 /* start of symbols */ 877c478bd9Sstevel@tonic-gate #define MODINFOMD_ESYM 0x0004 /* end of symbols */ 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #endif /* IMAGE_FREEBSD */ 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #endif /* I386_BITS_ELF_H */ 92