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

📄 binimg.h

📁 OXCC is a multipass, interpreting C compiler with several language extensions. It generates an Archi
💻 H
📖 第 1 页 / 共 4 页
字号:
  unsigned int r_symbolnum:24;
  unsigned int r_pcrel:1;
  unsigned int r_length:2;
  unsigned int r_extern:1;
  unsigned int r_pad:4;
} RELOCATION_INFO, *PRELOCATION_INFO;

#define RELOC_ADDRESS(r)		((r)->r_address)
#define RELOC_EXTERN_P(r)		((r)->r_extern)
#define RELOC_SYMBOL(r)			((r)->r_symbolnum)
#define RELOC_PCREL_P(r)		((r)->r_pcrel)
#define RELOC_TARGET_SIZE(r)	((r)->r_length)

/* ****************** ARCHIVE FORMAT *********************** */

#define ARMAG "!<arch>\n"           /* archive start */
#define SARMAG 8
#define ARFMAG "`\n"                /* archive end */
#define ARPAD  "\n"                 /* null entry */
#define ARLNKR "/               "   /* NT linker member */
#define ARLONG "//              "   /* NT longnames member */

typedef struct ar_hdr {
  char ar_name[16];	/* member name, `/' terminated */
  char ar_date[12]; /* member date, decimal */
  char ar_uid[6];	/* member user id, decimal */
  char ar_gid[6];	/* member group id, decimal */
  char ar_mode[8];  /* member mode, octal */
  char ar_size[10]; /* member size, decimal */
  char ar_fmag[2];
} AR_HDR, *PAR_HDR;
/* 
   Format of __.SYMDEF:
   First, a longword containing the size of the 'symdef' data that follows.
   Second, zero or more 'symdef' structures.
   Third, a word containing the length of symbol name strings.
   Fourth, zero or more symbol name strings (each followed by a zero).
*/

struct symdef {
  long symbol_name_string_index;
  long library_member_offset;
};

/********************** COFF BASIC "OPTIONAL HEADER" **********************/
/* USED WITH PE format of WINNT also */

typedef struct 
{
  unsigned short 	magic;		/* type of file				*/
  unsigned short	vstamp;		/* version stamp			*/
  unsigned long		tsize;		/* text size in bytes, padded to FW bdry*/
  unsigned long		dsize;		/* initialized data "  "		*/
  unsigned long		bsize;		/* uninitialized data "   "		*/
  unsigned long		entry;		/* entry pt.				*/
  unsigned long 	text_start;	/* base of text used for this file */
  unsigned long 	data_start;	/* base of data used for this file */
} OPT_HDR, *POPT_HDR;

typedef struct {
	COFF_HDR c __attribute__((packed));
	OPT_HDR o __attribute__((packed));
} XCOFF_HDR, *PXCOFF_HDR;
/*************** NT SPECIFIC ADDITIONS TO OPTIONAL HDR **********/

#define PE_DIRS 16

typedef struct {
    unsigned long  RVA;
    unsigned long  size;
} PE_DATA_DIR, *PPE_DATA_DIR;

/*
// Directory Entries
*/

#define DIR_ENTRY_EXPORT         0   /* Export Directory */
#define DIR_ENTRY_IMPORT         1   /* Import Directory */
#define DIR_ENTRY_RESOURCE       2   /* Resource Directory */
#define DIR_ENTRY_EXCEPTION      3   /* Exception Directory */
#define DIR_ENTRY_SECURITY       4   /* Security Directory */
#define DIR_ENTRY_BASERELOC      5   /* Base Relocation Table */
#define DIR_ENTRY_DEBUG          6   /* Debug Directory */
#define DIR_ENTRY_COPYRIGHT      7   /* Description String */
#define DIR_ENTRY_GLOBALPTR      8   /* Machine Value (MIPS GP) size == 0 */
#define DIR_ENTRY_TLS            9   /* TLS Directory */
#define DIR_ENTRY_LOAD_CONFIG   10   /* Load Configuration Directory */
#define DIR_ENTRY_BOUND_IMPORT  11   /* Bound Import Directory in headers */
#define DIR_ENTRY_IAT           12   /* Import Address Table */

typedef struct {
    unsigned long   ImageBase;
    unsigned long   SectionAlignment;
    unsigned long   FileAlignment;
    unsigned short  MajorOperatingSystemVersion;
    unsigned short  MinorOperatingSystemVersion;
    unsigned short  MajorImageVersion;
    unsigned short  MinorImageVersion;
    unsigned short  MajorSubsystemVersion;
    unsigned short  MinorSubsystemVersion;
    unsigned long   Reserved1 __attribute__((packed));
    unsigned long   SizeOfImage;
    unsigned long   SizeOfHeaders;
    unsigned long   CheckSum;
    unsigned short  Subsystem;
    unsigned short  DllCharacteristics;
    unsigned long   SizeOfStackReserve __attribute__((packed));
    unsigned long   SizeOfStackCommit;
    unsigned long   SizeOfHeapReserve;
    unsigned long   SizeOfHeapCommit;
    unsigned long   LoaderFlags;
    unsigned long   NumberOfDataDirs;
    PE_DATA_DIR DataDirectory[PE_DIRS];
} PE_OPT_HDR, *PPE_OPT_HDR;

typedef struct {
    unsigned long  BaseOfBss;
    unsigned long  GprMask;
    unsigned long  CprMask[4];
    unsigned long  GpValue;
} PE_ROM_OPT_HDR, *PPE_ROM_OPT_HDR;

typedef struct {
	unsigned short magic;	/* PE */
	unsigned short pad;
	COFF_HDR c __attribute__((packed));
	OPT_HDR o __attribute__((packed));
	PE_OPT_HDR p __attribute__((packed));
} PE_HDR, *PPE_HDR;

/*
// Subsystem Values NT
*/
#define SUBSYS_UNKNOWN       0   /* Unknown subsystem. */
#define SUBSYS_NATIVE        1   /* doesn't require a subsystem. */
#define SUBSYS_WINDOWS_GUI   2   /* runs in the Windows GUI subsystem. */
#define SUBSYS_WINDOWS_CUI   3   /* runs in the Windows character subsystem. */
#define SUBSYS_OS2_CUI       5   /* runs in the OS/2 character subsystem. */
#define SUBSYS_POSIX_CUI     7   /* runs in the Posix character subsystem. */


	
/********************** SECTION HEADER **********************/

typedef struct scnhdr {
	char				s_name[8];	/* section name			*/
	unsigned long		s_vsize;	/* virtual size when loaded (image) */
	unsigned long		s_vaddr;	/* virtual address		*/
	unsigned long		s_size;		/* raw data size			*/
	unsigned long		s_scnptr;	/* file ptr to raw data for section */
	unsigned long		s_relptr;	/* file ptr to relocation	*/
	unsigned long		s_lnnoptr;	/* file ptr to line numbers	*/
	unsigned short		s_nreloc;	/* number of relocation entries	*/
	unsigned short		s_nlnno;	/* number of line number entries*/
	unsigned long		s_flags;	/* characteristics			*/
} SCNHDR, *PSCNHDR;
/*
 * names of "special" sections
 */
#define _TEXT	".text"
#define _DATA	".data"
#define _BSS	".bss"
#define _COMMENT ".comment"
#define _LIB 	".lib"
#define _EDATA	".edata"	/* export info */
#define _IDATA	".idata"	/* import info */
#define _RDATA  ".rdata"	/* read only data + debug directory info */
#define _RELOC  ".reloc"	/* PE image fixups */
#define _RSRC   ".rsrc"		/* windows resources */
#define _PDATA  ".pdata"
#define _DEBUG  ".debug"
/*
 * s_flags "type"
 */
#define STYP_TEXT	      (0x00000020) /* section contains text only */
#define STYP_DATA	      (0x00000040) /* section contains data only */
#define STYP_BSS	      (0x00000080) /* section contains bss only */
#define STYP_INFO	      (0x00000100) /* section contains comments or something */
#define STYP_REMOVE	      (0x00000800) /* don't include section in loaded image */
#define STYP_COMDAT	      (0x00001000) /* section contents comdat */
#define STYP_FARDATA      (0x00008000)
#define STYP_PURGABLE     (0x00020000)
#define STYP_16BIT	      (0x00020000)
#define STYP_MEMLOCK      (0x00040000)
#define STYP_PRELOAD      (0x00080000)
#define STYP_ALIGNMENT	  (0x00700000)
#define STYP_ALGN1	      (0x00100000)
#define STYP_ALGN2	      (0x00200000)
#define STYP_ALGN4	      (0x00300000) /* default for emx,djgpp */
#define STYP_ALGN8	      (0x00400000)
#define STYP_ALGN16	      (0x00500000) /* default for NT */
#define STYP_ALGN32	      (0x00600000)
#define STYP_ALGN64	      (0x00700000)
#define STYP_NRELOC_OVFL  (0x01000000) /* section contains extended relocations */
#define STYP_DISCARDABLE  (0x02000000) /* section can be discarded */
#define STYP_NOT_CACHED   (0x04000000) /* section is not cachable */
#define STYP_NOT_PAGED    (0x08000000) /* section is not pageable */
#define STYP_SHARED       (0x10000000) /* section is shareable */
#define STYP_EXECUTE      (0x20000000) /* section is executable */
#define STYP_READ         (0x40000000) /* section is readable */
#define STYP_WRITE        (0x80000000) /* section is writeable */

/* linux style */
#define COFF_STYP_REG     0x00 /* regular segment                          */
#define COFF_STYP_DSECT   0x01 /* dummy segment                            */
#define COFF_STYP_NOLOAD  0x02 /* no-load segment                          */
#define COFF_STYP_GROUP   0x04 /* group segment                            */
#define COFF_STYP_PAD     0x08 /* .pad segment                             */
#define COFF_STYP_COPY    0x10 /* copy section                             */
#define COFF_STYP_TEXT    0x20 /* .text segment                            */
#define COFF_STYP_DATA    0x40 /* .data segment                            */
#define COFF_STYP_BSS     0x80 /* .bss segment                             */
#define COFF_STYP_INFO   0x200 /* .comment section                         */
#define COFF_STYP_OVER   0x400 /* overlay section                          */
#define COFF_STYP_LIB    0x800 /* library section                          */

/*
 * Shared libraries have the following section header in the data field for
 * each library.
 */

struct COFF_slib {
  char		sl_entsz[4];	/* Size of this entry               */
  char		sl_pathndx[4];	/* size of the header field         */
};

#define	COFF_SLIBHD	struct COFF_slib
#define	COFF_SLIBSZ	sizeof(COFF_SLIBHD)

/********************** LINE NUMBERS **********************/

/* 1 line number entry for every "breakpointable" source line in a section.
 * Line numbers are grouped on a per function basis; first entry in a function
 * grouping will have l_lnno = 0 and in place of physical address will be the
 * symbol table index of the function name.
 */
typedef struct coff_lineno{
	union {
		unsigned long l_symndx __attribute__((packed));	/* function name symbol index, iff l_lnno == 0 */
		unsigned long l_vaddr __attribute__((packed));	/* RVA of line number */
	} l_addr;
	unsigned short l_lnno;						/* line number */
} LINENO, *PLINENO;
#define COFF_LINENO_SIZE (6)

/********************** SYMBOLS **********************/

#define E_SYMNMLEN	8	/* # characters in a symbol name	*/
#define E_FILNMLEN	14	/* # characters in a file name		*/
#define E_DIMNUM	4	/* # array dimensions in auxiliary entry */
#define COFF_E_SYMNMLEN	 8
#define COFF_E_FILNMLEN	14
#define COFF_E_DIMNUM	 4

struct COFF_symbol
{
  union {
    char e_name[E_SYMNMLEN];
    struct {
      unsigned long e_zeroes __attribute__((packed)); /* if 0 use string tbl */
      unsigned long e_offset __attribute__((packed)); /* offset into string tbl */
    } e;
  } e;
  unsigned long e_value __attribute__((packed));
  short e_scnum;				/* section number */
  unsigned short e_type;		/* type */
  unsigned char e_sclass;		/* storage class */
  unsigned char e_numaux;		/* number of aux symbols */
};
typedef struct COFF_symbol COFF_SYMBOL, *PCOFF_SYMBOL;
#define COFF_SYMBOL_SIZE (18)

union COFF_auxent {
	struct {
		unsigned long x_tagndx __attribute__((packed));/* str, un, or enum tag indx */
		union {
			struct {
			    unsigned short  x_lnno;	/* declaration line number */
			    unsigned short  x_size; /* str/union/array size */
			} x_lnsz;
			unsigned long x_fsize __attribute__((packed));/* size of function */
		} x_misc;
		union {
			struct { /* if ISFCN, tag, or .bb */
			    unsigned long x_lnnoptr __attribute__((packed));/* ptr to fcn line # */
			    unsigned long x_next __attribute__((packed));	/* ptr to next fcn */
			} x_fcn;
			struct { /* if ISARY, up to 4 dimen. */
			    unsigned short x_dimen[E_DIMNUM];
			} x_ary;
		} x_fcnary;
		unsigned short x_tvndx;	/* tv index */
	} x_sym;

	union {
		char x_fname[E_FILNMLEN];
		struct {
			unsigned long x_zeroes __attribute__((packed));
			unsigned long x_offset __attribute__((packed));
		} x_n;
	} x_file;

	struct {
		unsigned long x_scnlen __attribute__((packed));		/* section length */
		unsigned short x_nreloc;					/* # relocation entries */
		unsigned short x_nlinno;					/* # line numbers */
		unsigned long cksum __attribute__((packed)); /* cksum for communal NT */
		short x_scnum;   /* section number to associate with */
		char x_sel;		/* communal selection type NT */
	} x_scn;

        struct {
		unsigned long x_tvfill __attribute__((packed));		/* tv fill value */
		unsigned short x_tvlen;						/* length of .tv */
		unsigned short x_tvran[2];					/* tv range */
	} x_tv;		/* info about .tv section (in auxent of symbol .tv)) */
};
typedef union COFF_auxent AUXENT, *PAUXENT;

#define COFF_AUXENT_SIZE COFF_SYMBOL_SIZE

#define _ETEXT	"etext"


/* Relocatable symbols have number of the section in which they are defined,
   or one of the following: */

#define SYM_UNDEF ((short)0)	/* undefined symbol */
#define SYM_ABS	  ((short)-1)	/* value of symbol is absolute */
#define SYM_DEBUG ((short)-2)	/* debugging symbol -- value is meaningless */
#define SYM_NTV	  ((short)-3)	/* indicates symbol needs preload transfer vector */
#define SYM_PTV	  ((short)-4)	/* indicates symbol needs postload transfer vector*/

/*
 * Type of a symbol, in e_type
 */
#define T_NULL		0x0000
#define T_VOID		0x0001	/* function argument (only used by compiler) */
#define T_CHAR		0x0002	/* character		*/
#define T_SHORT		0x0003	/* short integer	*/
#define T_INT		0x0004	/* integer		*/
#define T_LONG		0x0005	/* long integer		*/
#define T_FLOAT		0x0006	/* floating point	*/
#define T_DOUBLE	0x0007	/* double word		*/
#define T_STRUCT	0x0008	/* structure 		*/
#define T_UNION		0x0009	/* union 		*/
#define T_ENUM		0x000A	/* enumeration 		*/
#define T_MOE		0x000B	/* member of enumeration*/
#define T_UCHAR		0x000C	/* unsigned character	*/
#define T_USHORT	0x000D	/* unsigned short	*/
#define T_UINT		0x000E	/* unsigned integer	*/
#define T_ULONG		0x000F	/* unsigned long	*/
#define T_LNGDBL	0x0010	/* long double		*/
#define T_PCODE		0x8000	/* pcode */

/*
 * derived types, in e_type
*/
#define DT_NON		(0)	/* no derived type */
#define DT_PTR		(1)	/* pointer */
#define DT_FCN		(2)	/* function */
#define DT_ARY		(3)	/* array */

/* type packing constants */
#define N_BTMASK	(0x000F)
#define N_TMASK		(0x0030)
#define N_TMASK1    (0x00C0)
#define N_TMASK2    (0x00F0)
#define N_BTSHFT	(4)
#define N_TSHIFT	(2)
  
#define BTYPE(x)	((x) & N_BTMASK)	/* basic type */

/* this stuff is bugged [NDC] */
#define ISPTR(x)	(((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
#define ISFCN(x)	(((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
#define ISARY(x)	(((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
#define ISTAG(x)	((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG)
#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))

/********************** STORAGE CLASSES **********************/

#define C_EFCN		0xff	/* physical end of function	*/
#define C_NULL		0x0000
#define C_AUTO		0x0001	/* automatic variable		*/
#define C_EXT		0x0002	/* external symbol		*/
#define C_STAT		0x0003	/* static			*/
#define C_REG		0x0004	/* register variable		*/
#define C_EXTDEF	0x0005	/* external definition		*/
#define C_LABEL		0x0006	/* label			*/

⌨️ 快捷键说明

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