📄 coff-c55x.h
字号:
/* This file is derived from the GAS 2.1.4 assembler control file. The GAS product is under the GNU General Public License, version 2 or later. As such, this file is also under that license. If the file format changes in the COFF object, this file should be subsequently updated to reflect the changes. The actual loader module only uses a few of these structures. The full set is documented here because I received the full set. If you wish more information about COFF, then O'Reilly has a very excellent book.*//* * coff-c55x.h * * Modified from linux/inlcude/coff.h, for TI TSM320c55x * by Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com> * * 2004/07/22: DSP Gateway version 3.2 */#ifndef __COFF_C55X_H#define __COFF_C55X_H#define E_SYMNMLEN 8 /* Number of characters in a symbol name */#define E_FILNMLEN 14 /* Number of characters in a file name */#define E_DIMNUM 4 /* Number of array dimensions in auxiliary entry *//* * These defines are byte order independent. There is no alignment of fields * permitted in the structures. Therefore they are declared as characters * and the values loaded from the character positions. It also makes it * nice to have it "endian" independent. */ /* Load a short int from the following tables with little-endian formats */#define COFF_SHORT_L(ps) ((short)(((unsigned short)((unsigned char)ps[1])<<8)|\ ((unsigned short)((unsigned char)ps[0]))))/* Load a 24-bit from the following tables with little-endian formats *//* T.Koba */#define COFF_24BIT_L(ps) (((long)(((unsigned long)((unsigned char)ps[2])<<16) |\ ((unsigned long)((unsigned char)ps[1])<<8) |\ ((unsigned long)((unsigned char)ps[0]))))) /* Load a long int from the following tables with little-endian formats */#define COFF_LONG_L(ps) (((long)(((unsigned long)((unsigned char)ps[3])<<24) |\ ((unsigned long)((unsigned char)ps[2])<<16) |\ ((unsigned long)((unsigned char)ps[1])<<8) |\ ((unsigned long)((unsigned char)ps[0]))))) /* Load a short int from the following tables with big-endian formats */#define COFF_SHORT_H(ps) ((short)(((unsigned short)((unsigned char)ps[0])<<8)|\ ((unsigned short)((unsigned char)ps[1]))))/* Load a long int from the following tables with big-endian formats *//* T.Koba */#define COFF_24BIT_H(ps) (((long)(((unsigned long)((unsigned char)ps[0])<<16) |\ ((unsigned long)((unsigned char)ps[1])<<8) |\ ((unsigned long)((unsigned char)ps[2])))))/* Load a long int from the following tables with big-endian formats */#define COFF_LONG_H(ps) (((long)(((unsigned long)((unsigned char)ps[0])<<24) |\ ((unsigned long)((unsigned char)ps[1])<<16) |\ ((unsigned long)((unsigned char)ps[2])<<8) |\ ((unsigned long)((unsigned char)ps[3])))))/* T.Koba */#define COFF_PUT_SHORT_L(val,ps) {\ ps[0]= val &0xff;\ ps[1]=(val>>8)&0xff;\ }#define COFF_PUT_24BIT_L(val,ps) {\ ps[0]= val &0xff;\ ps[1]=(val>> 8)&0xff;\ ps[2]=(val>>16)&0xff;\ }#define COFF_PUT_LONG_L(val,ps) {\ ps[0]= val &0xff;\ ps[1]=(val>> 8)&0xff;\ ps[2]=(val>>16)&0xff;\ ps[3]=(val>>24)&0xff;\ }#define COFF_PUT_SHORT_H(val,ps) {\ ps[0]=(val>>8)&0xff;\ ps[1]= val &0xff;\ }#define COFF_PUT_24BIT_H(val,ps) {\ ps[0]=(val>>16)&0xff;\ ps[1]=(val>> 8)&0xff;\ ps[2]= val &0xff;\ }#define COFF_PUT_LONG_H(val,ps) {\ ps[0]=(val>>24)&0xff;\ ps[1]=(val>>16)&0xff;\ ps[2]=(val>> 8)&0xff;\ ps[3]= val &0xff;\ }/* These may be overridden later by brain dead implementations which generate a big-endian header with little-endian data. In that case, generate a replacement macro which tests a flag and uses either of the two above as appropriate. */#define COFF_LONG(v) COFF_LONG_L(v)#define COFF_24BIT(v) COFF_24BIT_L(v)#define COFF_SHORT(v) COFF_SHORT_L(v)#define COFF_PUT_LONG(v,p) COFF_PUT_LONG_L(v,p)#define COFF_PUT_24BIT(v,p) COFF_PUT_24BIT_L(v,p)#define COFF_PUT_SHORT(v,p) COFF_PUT_SHORT_L(v,p)/*** coff information for TI TMS320C55x. *//********************** FILE HEADER **********************/struct COFF_filehdr { char f_verid[2]; /* version id */ char f_nscns[2]; /* number of sections */ char f_timdat[4]; /* time & date stamp */ char f_symptr[4]; /* file pointer to symtab */ char f_nsyms[4]; /* number of symtab entries */ char f_opthdr[2]; /* sizeof(optional hdr) */ char f_flags[2]; /* flags */ char f_tgtid[2]; /* target id */};/* * Bits for f_flags: * * F_RELFLG relocation info stripped from file * F_EXEC file is executable (i.e. no unresolved external * references) * F_LNNO line numbers stripped from file * F_LSYMS local symbols stripped from file * F_MINMAL this is a minimal object file (".m") output of fextract * F_UPDATE this is a fully bound update file, output of ogen * F_SWABD this file has had its bytes swabbed (in names) * F_AR16WR this file has the byte ordering of an AR16WR * (e.g. 11/70) machine * F_AR32WR this file has the byte ordering of an AR32WR machine * (e.g. vax and iNTEL 386) * F_AR32W this file has the byte ordering of an AR32W machine * (e.g. 3b,maxi) * F_PATCH file contains "patch" list in optional header * F_NODF (minimal file only) no decision functions for * replaced functions * F_SYMMERGE (T.Koba) duplicate symbols were removed. */#define COFF_F_RELFLG 0000001#define COFF_F_EXEC 0000002#define COFF_F_LNNO 0000004#define COFF_F_LSYMS 0000010#define COFF_F_MINMAL 0000020#define COFF_F_UPDATE 0000040#define COFF_F_SWABD 0000100#define COFF_F_AR16WR 0000200#define COFF_F_AR32WR 0000400#define COFF_F_AR32W 0001000#define COFF_F_PATCH 0002000#define COFF_F_NODF 0002000/* T.Koba */#define COFF_F_SYMMERGE 0010000/* T.Koba */#define COFF_TGTID_C55X 0x009c#if 0 /* Perhaps, someday, these formats may be used. */#define COFF_I386PTXMAGIC 0x154#define COFF_I386AIXMAGIC 0x175 /* IBM's AIX system */#define COFF_I386BADMAG(x) ((COFF_SHORT((x).f_magic) != COFF_I386MAGIC) \ && COFF_SHORT((x).f_magic) != COFF_I386PTXMAGIC \ && COFF_SHORT((x).f_magic) != COFF_I386AIXMAGIC)#else#define COFF_I386BADMAG(x) (COFF_SHORT((x).f_magic) != COFF_I386MAGIC)#endif#define COFF_FILHDR struct COFF_filehdr/* * T.Koba: * arm-linux-gcc is confused with the struct size of not multiple of 4. * It doesn't recognize #pragma pack(1). *///#define COFF_FILHSZ sizeof(COFF_FILHDR)#define COFF_FILHSZ 22/********************** AOUT "OPTIONAL HEADER" **********************//* Linux COFF must have this "optional" header. Standard COFF has no entry location for the "entry" point. They normally would start with the first location of the .text section. This is not a good idea for linux. So, the use of this "optional" header is not optional. It is required. Do not be tempted to assume that the size of the optional header is a constant and simply index the next byte by the size of this structure. Use the 'f_opthdr' field in the main coff header for the size of the structure actually written to the file!!*/typedef struct { char magic[2]; /* type of file */ char vstamp[2]; /* version stamp */ char tsize[4]; /* text size in bytes, padded to FW bdry */ char dsize[4]; /* initialized data " " */ char bsize[4]; /* uninitialized data " " */ char entry[4]; /* entry pt. */ char text_start[4]; /* base of text used for this file */ char data_start[4]; /* base of data used for this file */}COFF_AOUTHDR;#define COFF_AOUTSZ (sizeof(COFF_AOUTHDR))#define COFF_STMAGIC 0401#define COFF_OMAGIC 0404#define COFF_JMAGIC 0407 /* dirty text and data image, can't share */#define COFF_DMAGIC 0410 /* dirty text segment, data aligned */#define COFF_ZMAGIC 0413 /* The proper magic number for executables */#define COFF_SHMAGIC 0443 /* shared library header *//********************** SECTION HEADER **********************/struct COFF_scnhdr { char s_name[8]; /* section name */ char s_paddr[4]; /* physical address, aliased s_nlib */ char s_vaddr[4]; /* virtual address */ char s_size[4]; /* section size */ char s_scnptr[4]; /* file ptr to raw data for section */ char s_relptr[4]; /* file ptr to relocation */ char s_lnnoptr[4]; /* file ptr to line numbers */ char s_nreloc[4]; /* number of relocation entries */ char s_nlnno[4]; /* number of line number entries */ char s_flags[4]; /* flags */ char s_rsvd[2]; /* reserved */ char s_mempg[2]; /* memory page number */};#define COFF_SCNHDR struct COFF_scnhdr#define COFF_SCNHSZ sizeof(COFF_SCNHDR)/* * names of "special" sections */#define COFF_TEXT ".text"#define COFF_DATA ".data"#define COFF_BSS ".bss"#define COFF_COMMENT ".comment"#define COFF_LIB ".lib"#define COFF_SECT_TEXT 0 /* Section for instruction code */#define COFF_SECT_DATA 1 /* Section for initialized globals */#define COFF_SECT_BSS 2 /* Section for un-initialized globals */#define COFF_SECT_REQD 3 /* Minimum number of sections for good file */#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_RDATA 0x100 /* read-only (T.Koba) */#define COFF_STYP_INFO 0x200 /* .comment section */#define COFF_STYP_OVER 0x400 /* overlay section */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -