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

📄 elf.h

📁 支持AMD64的汇编编译器源码
💻 H
📖 第 1 页 / 共 2 页
字号:
 * P = Location of location being relocated (r_offset) * S = Value of symbol */typedef enum {    R_386_NONE = 0,		/* none */    R_386_32 = 1,		/* word32, S + A */    R_386_PC32 = 2,		/* word32, S + A - P */    R_386_GOT32 = 3,		/* word32, G + A - P */    R_386_PLT32 = 4,		/* word32, L + A - P */    R_386_COPY = 5,		/* none */    R_386_GLOB_DAT = 6,		/* word32, S */    R_386_JMP_SLOT = 7,		/* word32, S */    R_386_RELATIVE = 8,		/* word32, B + A */    R_386_GOTOFF = 9,		/* word32, S + A - GOT */    R_386_GOTPC = 10,		/* word32, GOT + A - P */    R_386_TLS_TPOFF = 14,	/* Negative offset in static TLS block (GNU				   version) */    R_386_TLS_IE = 15,		/* Absolute address of GOT entry for negative				   static TLS block offset */    R_386_TLS_GOTIE = 16,	/* GOT entry for negative static TLS block				   offset */    R_386_TLS_LE = 17,		/* Negative offset relative to static TLS				   (GNU version) */    R_386_TLS_GD = 18,		/* Direct 32 bit for GNU version of GD TLS */    R_386_TLS_LDM = 19,		/* Direct 32 bit for GNU version of LD TLS				   in LE code */    R_386_16 = 20,		/* word16, S + A (GNU extension) */    R_386_PC16 = 21,		/* word16, S + A - P (GNU extension) */    R_386_8 = 22,		/* word8, S + A (GNU extension) */    R_386_PC8 = 23,		/* word8, S + A - P (GNU extension) */    R_386_TLS_GD_32 = 24,	/* Direct 32 bit for GD TLS */    R_386_TLS_GD_PUSH = 25,	/* Tag for pushl in GD TLS code */    R_386_TLS_GD_CALL = 26,	/* Relocation for call to */    R_386_TLS_GD_POP = 27,	/* Tag for popl in GD TLS code */    R_386_TLS_LDM_32 = 28,	/* Direct 32 bit for local dynamic code */    R_386_TLS_LDM_PUSH = 29,	/* Tag for pushl in LDM TLS code */    R_386_TLS_LDM_CALL = 30,	/* Relocation for call to */    R_386_TLS_LDM_POP = 31,	/* Tag for popl in LDM TLS code */    R_386_TLS_LDO_32 = 32,	/* Offset relative to TLS block */    R_386_TLS_IE_32 = 33,	/* GOT entry for static TLS block */    R_386_TLS_LE_32 = 34,	/* Offset relative to static TLS block */    R_386_TLS_DTPMOD32 = 35,	/* ID of module containing symbol */    R_386_TLS_DTPOFF32 = 36,	/* Offset in TLS block */    R_386_TLS_TPOFF32 = 37	/* Offset in static TLS block */} elf_386_relocation_type;typedef enum {    R_X86_64_NONE = 0,		/* none */    R_X86_64_64 = 1,		/* word64, S + A */    R_X86_64_PC32 = 2,		/* word32, S + A - P */    R_X86_64_GOT32 = 3,		/* word32, G + A */    R_X86_64_PLT32 = 4,		/* word32, L + A - P */    R_X86_64_COPY = 5,		/* none */    R_X86_64_GLOB_DAT = 6,	/* word64, S, set GOT entry to data address */    R_X86_64_JMP_SLOT = 7,	/* word64, S, set GOT entry to code address */    R_X86_64_RELATIVE = 8,	/* word64, B + A */    R_X86_64_GOTPCREL = 9,	/* word32, G + GOT + A - P */    R_X86_64_32 = 10,		/* word32 (zero extend), S + A */    R_X86_64_32S = 11,		/* word32 (sign extend), S + A */    R_X86_64_16 = 12,		/* word16, S + A */    R_X86_64_PC16 = 13,		/* word16, S + A - P */    R_X86_64_8 = 14,		/* word8, S + A */    R_X86_64_PC8 = 15,		/* word8, S + A - P */    R_X86_64_DPTMOD64 = 16,	/* word64, ID of module containing symbol */    R_X86_64_DTPOFF64 = 17,	/* word64, offset in TLS block */    R_X86_64_TPOFF64 = 18,	/* word64, offset in initial TLS block */    R_X86_64_TLSGD = 19,	/* word32, PC-rel offset to GD GOT block */    R_X86_64_TLSLD = 20,	/* word32, PC-rel offset to LD GOT block */    R_X86_64_DTPOFF32 = 21,	/* word32, offset to TLS block */    R_X86_64_GOTTPOFF = 22,	/* word32, PC-rel offset to IE GOT entry */    R_X86_64_TPOFF32 = 23	/* word32, offset in initial TLS block */} elf_x86_64_relocation_type;struct elf_secthead {    elf_section_type	 type;    elf_section_flags	 flags;    elf_address		 offset;    yasm_intnum		*size;    elf_section_index	 link;    elf_section_info	 info;	    /* see note ESD1 */    yasm_intnum 	*align;    elf_size		 entsize;    yasm_symrec		*sym;    elf_strtab_entry	*name;    elf_section_index	 index;    elf_strtab_entry	*rel_name;    elf_section_index	 rel_index;    elf_address		 rel_offset;    unsigned long	 nreloc;};/* Note ESD1: *   for section types SHT_REL, SHT_RELA: *     link -> index of associated symbol table *     info -> index of relocated section *   for section types SHT_SYMTAB, SHT_DYNSYM: *     link -> index of associated string table *     info -> 1+index of last "local symbol" (bind == STB_LOCAL) *  (for section type SHT_DNAMIC: *     link -> index of string table *     info -> 0 ) *  (for section type SHT_HASH: *     link -> index of symbol table to which hash applies *     info -> 0 ) *   for all others: *     link -> SHN_UNDEF *     info -> 0 */struct elf_reloc_entry {    yasm_reloc		 reloc;    int			 rtype_rel;    size_t		 valsize;    yasm_intnum         *addend;    /*@null@*/ yasm_symrec *wrt;};STAILQ_HEAD(elf_strtab_head, elf_strtab_entry);struct elf_strtab_entry {    STAILQ_ENTRY(elf_strtab_entry) qlink;    unsigned long	 index;    char		*str;};STAILQ_HEAD(elf_symtab_head, elf_symtab_entry);struct elf_symtab_entry {    STAILQ_ENTRY(elf_symtab_entry) qlink;    yasm_symrec		*sym;    yasm_section	*sect;    elf_strtab_entry	*name;    elf_address		 value;    yasm_expr		*xsize;    elf_size		 size;    elf_section_index	 index;    elf_symbol_binding	 bind;    elf_symbol_type	 type;    elf_symbol_index	 symindex;};#endif /* defined(YASM_OBJFMT_ELF_INTERNAL) */extern const yasm_assoc_data_callback elf_section_data;extern const yasm_assoc_data_callback elf_symrec_data;int elf_set_arch(struct yasm_arch *arch, yasm_symtab *symtab);/* reloc functions */int elf_is_wrt_sym_relative(yasm_symrec *wrt);elf_reloc_entry *elf_reloc_entry_create(yasm_symrec *sym,					/*@null@*/ yasm_symrec *wrt,					yasm_intnum *addr,					int rel,					size_t valsize);void elf_reloc_entry_destroy(void *entry);/* strtab functions */elf_strtab_entry *elf_strtab_entry_create(const char *str);elf_strtab_head *elf_strtab_create(void);elf_strtab_entry *elf_strtab_append_str(elf_strtab_head *head, const char *str);void elf_strtab_destroy(elf_strtab_head *head);unsigned long elf_strtab_output_to_file(FILE *f, elf_strtab_head *head);/* symtab functions */elf_symtab_entry *elf_symtab_entry_create(elf_strtab_entry *name,					  struct yasm_symrec *sym);elf_symtab_head *elf_symtab_create(void);elf_symtab_entry *elf_symtab_append_entry(elf_symtab_head *symtab,					  elf_symtab_entry *entry);elf_symtab_entry *elf_symtab_insert_local_sym(elf_symtab_head *symtab,					      elf_strtab_head *strtab,					      struct yasm_symrec *sym);void elf_symtab_destroy(elf_symtab_head *head);unsigned long elf_symtab_assign_indices(elf_symtab_head *symtab);unsigned long elf_symtab_write_to_file(FILE *f, elf_symtab_head *symtab);void elf_symtab_set_nonzero(elf_symtab_entry	*entry,			    struct yasm_section *sect,			    elf_section_index	 sectidx,			    elf_symbol_binding	 bind,			    elf_symbol_type	 type,			    struct yasm_expr	*size,			    elf_address		 value);/* section header functions */elf_secthead *elf_secthead_create(elf_strtab_entry	*name,				  elf_section_type	type,				  elf_section_flags	flags,				  elf_section_index	idx,				  elf_address		offset,				  elf_size		size);void elf_secthead_destroy(elf_secthead *esd);unsigned long elf_secthead_write_to_file(FILE *f, elf_secthead *esd,					 elf_section_index sindex);int elf_secthead_append_reloc(yasm_section *sect, elf_secthead *shead,			      elf_reloc_entry *reloc);elf_section_type elf_secthead_get_type(elf_secthead *shead);int elf_secthead_is_empty(elf_secthead *shead);struct yasm_symrec *elf_secthead_get_sym(elf_secthead *shead);const struct yasm_intnum *elf_secthead_set_align(elf_secthead *shead,						 struct yasm_intnum *align);elf_section_index elf_secthead_get_index(elf_secthead *shead);elf_section_info elf_secthead_set_info(elf_secthead *shead,				       elf_section_info info);elf_section_index elf_secthead_set_index(elf_secthead *shead,					 elf_section_index sectidx);elf_section_index elf_secthead_set_link(elf_secthead *shead,					elf_section_index link);elf_section_index elf_secthead_set_rel_index(elf_secthead *shead,					     elf_section_index sectidx);elf_strtab_entry *elf_secthead_set_rel_name(elf_secthead *shead,					    elf_strtab_entry *entry);elf_size elf_secthead_set_entsize(elf_secthead *shead, elf_size size);struct yasm_symrec *elf_secthead_set_sym(elf_secthead *shead,					 struct yasm_symrec *sym);void elf_secthead_add_size(elf_secthead *shead, yasm_intnum *size);char *elf_secthead_name_reloc_section(const char *basesect);void elf_handle_reloc_addend(yasm_intnum *intn, elf_reloc_entry *reloc);unsigned long elf_secthead_write_rel_to_file(FILE *f, elf_section_index symtab,					     yasm_section *sect,					     elf_secthead *esd,					     elf_section_index sindex);unsigned long elf_secthead_write_relocs_to_file(FILE *f, yasm_section *sect,						elf_secthead *shead);long elf_secthead_set_file_offset(elf_secthead *shead, long pos);/* program header function */unsigned longelf_proghead_get_size(void);unsigned longelf_proghead_write_to_file(FILE *f,			   elf_offset secthead_addr,			   unsigned long secthead_count,			   elf_section_index shstrtab_index);#endif /* ELF_H_INCLUDED */

⌨️ 快捷键说明

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