?? ti.h
字號:
/* COFF information for TI COFF support. Definitions in this file should be customized in a target-specific file, and then this file included (see tic54x.h for an example). Copyright 2001, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#ifndef COFF_TI_H#define COFF_TI_H/* Note "coff/external.h is not used because TI adds extra fields to the structures. *//********************** FILE HEADER **********************/struct external_filehdr { char f_magic[2]; /* magic number */ 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_target_id[2]; /* magic no. (TI COFF-specific) */ };/* COFF0 has magic number in f_magic, and omits f_target_id from the file header; for later versions, f_magic is 0xC1 for COFF1 and 0xC2 for COFF2 and the target-specific magic number is found in f_target_id */ #define TICOFF0MAGIC TI_TARGET_ID#define TICOFF1MAGIC 0x00C1#define TICOFF2MAGIC 0x00C2#define TICOFF_AOUT_MAGIC 0x0108 /* magic number in optional header */#define TICOFF 1 /* customize coffcode.h *//* The target_id field changes depending on the particular CPU target *//* for COFF0, the target id appeared in f_magic, where COFFX magic is now */#ifndef TI_TARGET_ID#error "TI_TARGET_ID needs to be defined for your CPU"#endif/* Which bfd_arch to use... */#ifndef TICOFF_TARGET_ARCH#error "TICOFF_TARGET_ARCH needs to be defined for your CPU"#endif#ifndef TICOFF_TARGET_MACHINE_GET#define TICOFF_TARGET_MACHINE_GET(FLAGS) 0#endif#ifndef TICOFF_TARGET_MACHINE_SET#define TICOFF_TARGET_MACHINE_SET(FLAGSP, MACHINE)#endif/* Default to COFF2 for file output */#ifndef TICOFF_DEFAULT_MAGIC#define TICOFF_DEFAULT_MAGIC TICOFF2MAGIC#endif/* This value is made available in the rare case where a bfd is unavailable */#ifndef OCTETS_PER_BYTE_POWER#error "OCTETS_PER_BYTE_POWER not defined for this CPU"#else#define OCTETS_PER_BYTE (1<<OCTETS_PER_BYTE_POWER)#endif/* default alignment is on a byte (not octet!) boundary */#ifndef COFF_DEFAULT_SECTION_ALIGNMENT_POWER#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 0#endif/* TI COFF encodes the section alignment in the section header flags */#define COFF_ALIGN_IN_SECTION_HEADER 1#define COFF_ALIGN_IN_S_FLAGS 1/* requires a power-of-two argument */#define COFF_ENCODE_ALIGNMENT(S,X) ((S).s_flags |= (((unsigned)(X)&0xF)<<8))/* result is a power of two */#define COFF_DECODE_ALIGNMENT(X) (((X)>>8)&0xF)#define COFF0_P(ABFD) (bfd_coff_filhsz(ABFD) == FILHSZ_V0)#define COFF2_P(ABFD) (bfd_coff_scnhsz(ABFD) != SCNHSZ_V01)#define COFF0_BADMAG(x) ((x).f_magic != TICOFF0MAGIC)#define COFF1_BADMAG(x) ((x).f_magic != TICOFF1MAGIC || (x).f_target_id != TI_TARGET_ID)#define COFF2_BADMAG(x) ((x).f_magic != TICOFF2MAGIC || (x).f_target_id != TI_TARGET_ID)/* we need to read/write an extra field in the coff file header */#ifndef COFF_ADJUST_FILEHDR_IN_POST#define COFF_ADJUST_FILEHDR_IN_POST(abfd, src, dst) \ do \ { \ ((struct internal_filehdr *)(dst))->f_target_id = \ H_GET_16 (abfd, ((FILHDR *)(src))->f_target_id); \ } \ while (0)#endif#ifndef COFF_ADJUST_FILEHDR_OUT_POST#define COFF_ADJUST_FILEHDR_OUT_POST(abfd, src, dst) \ do \ { \ H_PUT_16 (abfd, ((struct internal_filehdr *)(src))->f_target_id, \ ((FILHDR *)(dst))->f_target_id); \ } \ while (0)#endif#define FILHDR struct external_filehdr#define FILHSZ 22#define FILHSZ_V0 20 /* COFF0 omits target_id field *//* File header flags */#define F_RELFLG (0x0001)#define F_EXEC (0x0002)#define F_LNNO (0x0004)#define F_VERS (0x0010) /* TMS320C4x code *//* F_LSYMS needs to be redefined in your source file */#define F_LSYMS_TICOFF (0x0010) /* normal COFF is 0x8 */#define F_10 0x00 /* file built for TMS320C1x devices */#define F_20 0x10 /* file built for TMS320C2x devices */#define F_25 0x20 /* file built for TMS320C2x/C5x devices */#define F_LENDIAN 0x0100 /* 16 bits/word, LSB first */#define F_SYMMERGE 0x1000 /* duplicate symbols were removed *//********************** OPTIONAL HEADER **********************/typedef struct { char magic[2]; /* type of file (0x108) */ 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 */}AOUTHDR;#define AOUTHDRSZ 28#define AOUTSZ 28/********************** SECTION HEADER **********************//* COFF0, COFF1 */struct external_scnhdr_v01 { 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 (in WORDS) */ 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[2]; /* number of relocation entries */ char s_nlnno[2]; /* number of line number entries*/ char s_flags[2]; /* flags */ char s_reserved[1]; /* reserved */ char s_page[1]; /* section page number (LOAD) */};/* COFF2 */struct external_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 (in WORDS) */ 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_reserved[2]; /* reserved */ char s_page[2]; /* section page number (LOAD) */};/* * Special section flags *//* TI COFF defines these flags; STYP_CLINK: the section should be excluded from the final linker output if there are no references found to any symbol in the section STYP_BLOCK: the section should be blocked, i.e. if the section would cross a page boundary, it is started at a page boundary instead. TI COFF puts the section alignment power of two in the section flags e.g. 2**N is alignment, flags |= (N & 0xF) << 8*/ #define STYP_CLINK (0x4000)#define STYP_BLOCK (0x1000)#define STYP_ALIGN (0x0F00) /* TI COFF stores section alignment here */#define SCNHDR_V01 struct external_scnhdr_v01#define SCNHDR struct external_scnhdr#define SCNHSZ_V01 40 /* for v0 and v1 */#define SCNHSZ 48/* COFF2 changes the offsets and sizes of these fields Assume we're dealing with the COFF2 scnhdr structure, and adjust accordingly */#define GET_SCNHDR_NRELOC(ABFD, LOC) \ (COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, LOC))#define PUT_SCNHDR_NRELOC(ABFD, VAL, LOC) \ (COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, LOC))#define GET_SCNHDR_NLNNO(ABFD, LOC) \ (COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, (LOC) - 2))#define PUT_SCNHDR_NLNNO(ABFD, VAL, LOC) \ (COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, (LOC) - 2))#define GET_SCNHDR_FLAGS(ABFD, LOC) \ (COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, (LOC) - 4))#define PUT_SCNHDR_FLAGS(ABFD, VAL, LOC) \ (COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, (LOC) - 4))#define GET_SCNHDR_PAGE(ABFD, LOC) \ (COFF2_P (ABFD) ? H_GET_16 (ABFD, LOC) : (unsigned) H_GET_8 (ABFD, (LOC) - 7))/* on output, make sure that the "reserved" field is zero */#define PUT_SCNHDR_PAGE(ABFD, VAL, LOC) \ (COFF2_P (ABFD) \ ? H_PUT_16 (ABFD, VAL, LOC) \ : H_PUT_8 (ABFD, VAL, (LOC) - 7), H_PUT_8 (ABFD, 0, (LOC) - 8))
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -