⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elf.h

📁 浙江大学的悟空嵌入式系统模拟器
💻 H
📖 第 1 页 / 共 2 页
字号:
	#define R_SPARC_11		       31
	#define R_SPARC_WDISP16		   40
	#define R_SPARC_WDISP19		   41
	#define R_SPARC_7		       43
	#define R_SPARC_5		       44
	#define R_SPARC_6		       45

	//! Bits present in AT_HWCAP, primarily for Sparc32.  

	#define HWCAP_SPARC_FLUSH      1    // CPU supports flush instruction
	#define HWCAP_SPARC_STBAR      2
	#define HWCAP_SPARC_SWAP       4
	#define HWCAP_SPARC_MULDIV     8
	#define HWCAP_SPARC_V9		   16
	#define HWCAP_SPARC_ULTRA3	   32

	//! 68k ELF relocation types
	#define R_68K_NONE	           0
	#define R_68K_32	           1
	#define R_68K_16	           2
	#define R_68K_8		           3
	#define R_68K_PC32	           4
	#define R_68K_PC16	           5
	#define R_68K_PC8	           6
	#define R_68K_GOT32	           7
	#define R_68K_GOT16	           8
	#define R_68K_GOT8	           9
	#define R_68K_GOT32O	       10
	#define R_68K_GOT16O	       11
	#define R_68K_GOT8O	           12
	#define R_68K_PLT32	           13
	#define R_68K_PLT16	           14
	#define R_68K_PLT8	           15
	#define R_68K_PLT32O	       16
	#define R_68K_PLT16O	       17
	#define R_68K_PLT8O	           18
	#define R_68K_COPY	           19
	#define R_68K_GLOB_DAT	       20
	#define R_68K_JMP_SLOT	       21
	#define R_68K_RELATIVE	       22

	//! Alpha ELF relocation types
	#define R_ALPHA_NONE           0       // No reloc 
	#define R_ALPHA_REFLONG        1       // Direct 32 bit 
	#define R_ALPHA_REFQUAD		   2       // Direct 64 bit 
	#define R_ALPHA_GPREL32        3       // GP relative 32 bit 
	#define R_ALPHA_LITERAL        4       // GP relative 16 bit w/optimization 
	#define R_ALPHA_LITUSE         5       // Optimization hint for	LITERAL 
	#define R_ALPHA_GPDISP         6       // Add displacement to GP 
	#define R_ALPHA_BRADDR         7       // PC+4 relative 23 bit shifted 
	#define R_ALPHA_HINT           8       // PC+4 relative 16 bit shifted 
	#define R_ALPHA_SREL16         9       // PC relative 16 bit 
	#define R_ALPHA_SREL32         10      // PC relative 32 bit 
	#define R_ALPHA_SREL64         11      // PC relative 64 bit 
	#define R_ALPHA_OP_PUSH        12      // OP stack push 
	#define R_ALPHA_OP_STORE       13      // OP stack pop and store 
	#define R_ALPHA_OP_PSUB        14      // OP stack subtract 
	#define R_ALPHA_OP_PRSHIFT     15      // OP stack right shift 
	#define R_ALPHA_GPVALUE        16
	#define R_ALPHA_GPRELHIGH      17
	#define R_ALPHA_GPRELLOW       18
	#define R_ALPHA_IMMED_GP_16    19
	#define R_ALPHA_IMMED_GP_HI32  20
	#define R_ALPHA_IMMED_SCN_HI32 21
	                         
	#define R_ALPHA_IMMED_BR_HI32  22
	                         
	#define R_ALPHA_IMMED_LO32     23
	#define R_ALPHA_COPY           24    // Copy symbol at runtime 
	#define R_ALPHA_GLOB_DAT       25    // Create GOT entry 
	#define R_ALPHA_JMP_SLOT       26    // Create PLT entry 
	#define R_ALPHA_RELATIVE       27    // Adjust by program base 

	//! Legal values for e_flags field of Elf64_Ehdr.  
	#define EF_ALPHA_32BIT		   1	// All addresses are below 2GB 

	typedef struct elf32_rel {
		Elf32_Addr	r_offset;
		Elf32_Word	r_info;
	} Elf32_Rel;

	typedef struct elf64_rel {
		Elf64_Addr r_offset;	// Location at which to apply the action 
		Elf64_Xword r_info;	// index and type of relocation 
	} Elf64_Rel;

	typedef struct elf32_rela{
		Elf32_Addr	r_offset;
		Elf32_Word	r_info;
		Elf32_Sword	r_addend;
	}Elf32_Rela;

	typedef struct elf64_rela {
		Elf64_Addr r_offset;	  // Location at which to apply the action 
		Elf64_Xword r_info;	  // index and type of relocation 
		Elf64_Sxword r_addend;  // Constant addend used to compute value 
	} Elf64_Rela;

	typedef struct elf32_sym{
		Elf32_Word	st_name;
		Elf32_Addr	st_value;
		Elf32_Word	st_size;
		unsigned char	st_info;
		unsigned char	st_other;
		Elf32_Half	st_shndx;
	} Elf32_Sym;

	typedef struct elf64_sym {
		Elf64_Word st_name;		// Symbol name, index in string tbl 
		unsigned char	st_info;	// Type and binding attributes 
		unsigned char	st_other;	// No defined meaning, 0 
		Elf64_Half st_shndx;		// Associated section index 
		Elf64_Addr st_value;		// Value of the symbol 
		Elf64_Xword st_size;		// Associated symbol size 
	} Elf64_Sym;


	#define EI_NIDENT	16

	typedef struct elf32_hdr{
		unsigned char	e_ident[EI_NIDENT];
		Elf32_Half	e_type;
		Elf32_Half	e_machine;
		Elf32_Word	e_version;
		Elf32_Addr	e_entry;    // Entry point
		Elf32_Off	e_phoff;
		Elf32_Off	e_shoff;
		Elf32_Word	e_flags;
		Elf32_Half	e_ehsize;
		Elf32_Half	e_phentsize;
		Elf32_Half	e_phnum;
		Elf32_Half	e_shentsize;
		Elf32_Half	e_shnum;
		Elf32_Half	e_shstrndx;
	} Elf32_Ehdr;

	typedef struct elf64_hdr {
		unsigned char	e_ident[16];		// ELF "magic number" 
		Elf64_Half e_type;
		Elf64_Half e_machine;
		Elf64_Word e_version;
		Elf64_Addr e_entry;		// Entry point virtual address 
		Elf64_Off e_phoff;		// Program header table file offset 
		Elf64_Off e_shoff;		// Section header table file offset 
		Elf64_Word e_flags;
		Elf64_Half e_ehsize;
		Elf64_Half e_phentsize;
		Elf64_Half e_phnum;
		Elf64_Half e_shentsize;
		Elf64_Half e_shnum;
		Elf64_Half e_shstrndx;
	} Elf64_Ehdr;

	//! These constants define the permissions on sections in the program
	//! header, p_flags. 

	#define PF_R		0x4
	#define PF_W		0x2
	#define PF_X		0x1

	typedef struct elf32_phdr{
		Elf32_Word	p_type;
		Elf32_Off	p_offset;
		Elf32_Addr	p_vaddr;
		Elf32_Addr	p_paddr;
		Elf32_Word	p_filesz;
		Elf32_Word	p_memsz;
		Elf32_Word	p_flags;
		Elf32_Word	p_align;
	} Elf32_Phdr;

	typedef struct elf64_phdr {
		Elf64_Word p_type;
		Elf64_Word p_flags;
		Elf64_Off p_offset;		// Segment file offset 
		Elf64_Addr p_vaddr;		// Segment virtual address 
		Elf64_Addr p_paddr;		// Segment physical address 
		Elf64_Xword p_filesz;		// Segment size in file 
		Elf64_Xword p_memsz;		// Segment size in memory 
		Elf64_Xword p_align;		// Segment alignment, file & memory 
	} Elf64_Phdr;

	//! sh_type

	#define SHT_NULL			0
	#define SHT_PROGBITS		1
	#define SHT_SYMTAB			2
	#define SHT_STRTAB			3
	#define SHT_RELA			4
	#define SHT_HASH			5
	#define SHT_DYNAMIC			6
	#define SHT_NOTE			7
	#define SHT_NOBITS			8
	#define SHT_REL				9
	#define SHT_SHLIB			10
	#define SHT_DYNSYM			11
	#define SHT_NUM				12
	#define SHT_LOPROC			0x70000000
	#define SHT_HIPROC			0x7fffffff
	#define SHT_LOUSER			0x80000000
	#define SHT_HIUSER			0xffffffff
	#define SHT_MIPS_LIST		0x70000000
	#define SHT_MIPS_CONFLICT	0x70000002
	#define SHT_MIPS_GPTAB		0x70000003
	#define SHT_MIPS_UCODE		0x70000004

	//! sh_flags 

	#define SHF_WRITE	        0x1
	#define SHF_ALLOC	        0x2
	#define SHF_EXECINSTR	    0x4
	#define SHF_MASKPROC	    0xf0000000
	#define SHF_MIPS_GPREL	    0x10000000

	//! special section indexes 

	#define SHN_UNDEF	        0
	#define SHN_LORESERVE	    0xff00
	#define SHN_LOPROC	        0xff00
	#define SHN_HIPROC	        0xff1f
	#define SHN_ABS		        0xfff1
	#define SHN_COMMON	        0xfff2
	#define SHN_HIRESERVE	    0xffff
	#define SHN_MIPS_ACCOMON	0xff00
 
	typedef struct {
		Elf32_Word	sh_name;
		Elf32_Word	sh_type;
		Elf32_Word	sh_flags;
		Elf32_Addr	sh_addr;
		Elf32_Off	sh_offset;
		Elf32_Word	sh_size;
		Elf32_Word	sh_link;
		Elf32_Word	sh_info;
		Elf32_Word	sh_addralign;
		Elf32_Word	sh_entsize;
	} Elf32_Shdr;

	typedef struct elf64_shdr {
		Elf64_Word sh_name;		    // Section name, index in string tbl 
		Elf64_Word sh_type;		    // Type of section 
		Elf64_Xword sh_flags;		// Miscellaneous section attributes 
		Elf64_Addr sh_addr;		    // Section virtual addr at execution 
		Elf64_Off sh_offset;		// Section file offset 
		Elf64_Xword sh_size;		// Size of section in bytes 
		Elf64_Word sh_link;		    // Index of another section 
		Elf64_Word sh_info;		    // Additional section information 
		Elf64_Xword sh_addralign;	// Section alignment 
		Elf64_Xword sh_entsize;	    // Entry size if section holds table 
	} Elf64_Shdr;

	#define	EI_MAG0		0		    // e_ident[] indexes 
	#define	EI_MAG1		1
	#define	EI_MAG2		2
	#define	EI_MAG3		3
	#define	EI_CLASS	4
	#define	EI_DATA		5
	#define	EI_VERSION	6
	#define	EI_PAD		7

	#define	ELFMAG0		0x7f	 // EI_MAG 
	#define	ELFMAG1		'E'
	#define	ELFMAG2		'L'
	#define	ELFMAG3		'F'
	#define	ELFMAG		"\177ELF"
	#define	SELFMAG		4

	#define	ELFCLASSNONE	0		// EI_CLASS 
	#define	ELFCLASS32	    1
	#define	ELFCLASS64		2
	#define	ELFCLASSNUM		3

	#define ELFDATANONE		0		// e_ident[EI_DATA] 
	#define ELFDATA2LSB		1
	#define ELFDATA2MSB		2

	#define EV_NONE			0		// e_version, EI_VERSION 
	#define EV_CURRENT		1
	#define EV_NUM			2

	//! Notes used in ET_CORE 

	#define NT_PRSTATUS		1
	#define NT_PRFPREG		2
	#define NT_PRPSINFO		3
	#define NT_TASKSTRUCT	4
	#define NT_PRFPXREG		20

	//! Note header in a PT_NOTE section 

	typedef struct elf32_note {
		Elf32_Word	n_namesz;	// Name size 
		Elf32_Word	n_descsz;	// Content size 
		Elf32_Word	n_type;		// Content type 
	} Elf32_Nhdr;

	//! Note header in a PT_NOTE section 

	typedef struct elf64_note {
		Elf64_Word n_namesz;	    // Name size 
		Elf64_Word n_descsz;	    // Content size 
		Elf64_Word n_type;	    // Content type 
	} Elf64_Nhdr;

	#if ELF_CLASS == ELFCLASS32

	extern Elf32_Dyn _DYNAMIC [];
	#define elfhdr		elf32_hdr
	#define elf_phdr	elf32_phdr
	#define elf_note	elf32_note

	#else

	extern Elf64_Dyn _DYNAMIC [];
	#define elfhdr		elf64_hdr
	#define elf_phdr	elf64_phdr
	#define elf_note	elf64_note

	#endif
	}
#endif // ELF_H 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -