ti.h (78828) | ti.h (89857) |
---|---|
1/* COFF information for TI COFF support. Definitions in this file should be 2 customized in a target-specific file, and then this file included (see 3 tic54x.h for an example). 4 5 Copyright 2001 Free Software Foundation, Inc. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | 1/* COFF information for TI COFF support. Definitions in this file should be 2 customized in a target-specific file, and then this file included (see 3 tic54x.h for an example). 4 5 Copyright 2001 Free Software Foundation, Inc. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
20 | |
21#ifndef COFF_TI_H 22#define COFF_TI_H 23 | 20#ifndef COFF_TI_H 21#define COFF_TI_H 22 |
23/* Note "coff/external.h is not used because TI adds extra fields to the structures. */ 24 |
|
24/********************** FILE HEADER **********************/ 25 | 25/********************** FILE HEADER **********************/ 26 |
26struct external_filehdr { 27 char f_magic[2]; /* magic number */ 28 char f_nscns[2]; /* number of sections */ 29 char f_timdat[4]; /* time & date stamp */ 30 char f_symptr[4]; /* file pointer to symtab */ 31 char f_nsyms[4]; /* number of symtab entries */ 32 char f_opthdr[2]; /* sizeof(optional hdr) */ 33 char f_flags[2]; /* flags */ 34 char f_target_id[2]; /* magic no. (TI COFF-specific) */ 35}; | 27struct external_filehdr 28 { 29 char f_magic[2]; /* magic number */ 30 char f_nscns[2]; /* number of sections */ 31 char f_timdat[4]; /* time & date stamp */ 32 char f_symptr[4]; /* file pointer to symtab */ 33 char f_nsyms[4]; /* number of symtab entries */ 34 char f_opthdr[2]; /* sizeof(optional hdr) */ 35 char f_flags[2]; /* flags */ 36 char f_target_id[2]; /* magic no. (TI COFF-specific) */ 37 }; |
36 37/* COFF0 has magic number in f_magic, and omits f_target_id from the file 38 header; for later versions, f_magic is 0xC1 for COFF1 and 0xC2 for COFF2 39 and the target-specific magic number is found in f_target_id */ 40 41#define TICOFF0MAGIC TI_TARGET_ID 42#define TICOFF1MAGIC 0x00C1 43#define TICOFF2MAGIC 0x00C2 --- 40 unchanged lines hidden (view full) --- 84#define COFF2_P(ABFD) (bfd_coff_scnhsz(ABFD) != SCNHSZ_V01) 85 86#define COFF0_BADMAG(x) ((x).f_magic != TICOFF0MAGIC) 87#define COFF1_BADMAG(x) ((x).f_magic != TICOFF1MAGIC || (x).f_target_id != TI_TARGET_ID) 88#define COFF2_BADMAG(x) ((x).f_magic != TICOFF2MAGIC || (x).f_target_id != TI_TARGET_ID) 89 90/* we need to read/write an extra field in the coff file header */ 91#ifndef COFF_ADJUST_FILEHDR_IN_POST | 38 39/* COFF0 has magic number in f_magic, and omits f_target_id from the file 40 header; for later versions, f_magic is 0xC1 for COFF1 and 0xC2 for COFF2 41 and the target-specific magic number is found in f_target_id */ 42 43#define TICOFF0MAGIC TI_TARGET_ID 44#define TICOFF1MAGIC 0x00C1 45#define TICOFF2MAGIC 0x00C2 --- 40 unchanged lines hidden (view full) --- 86#define COFF2_P(ABFD) (bfd_coff_scnhsz(ABFD) != SCNHSZ_V01) 87 88#define COFF0_BADMAG(x) ((x).f_magic != TICOFF0MAGIC) 89#define COFF1_BADMAG(x) ((x).f_magic != TICOFF1MAGIC || (x).f_target_id != TI_TARGET_ID) 90#define COFF2_BADMAG(x) ((x).f_magic != TICOFF2MAGIC || (x).f_target_id != TI_TARGET_ID) 91 92/* we need to read/write an extra field in the coff file header */ 93#ifndef COFF_ADJUST_FILEHDR_IN_POST |
92#define COFF_ADJUST_FILEHDR_IN_POST(abfd,src,dst) \ 93do { ((struct internal_filehdr *)(dst))->f_target_id = \ 94bfd_h_get_16(abfd, (bfd_byte *)(((FILHDR *)(src))->f_target_id)); \ 95} while(0) | 94#define COFF_ADJUST_FILEHDR_IN_POST(abfd, src, dst) \ 95 do \ 96 { \ 97 ((struct internal_filehdr *)(dst))->f_target_id = \ 98 H_GET_16 (abfd, ((FILHDR *)(src))->f_target_id); \ 99 } \ 100 while (0) |
96#endif 97 98#ifndef COFF_ADJUST_FILEHDR_OUT_POST | 101#endif 102 103#ifndef COFF_ADJUST_FILEHDR_OUT_POST |
99#define COFF_ADJUST_FILEHDR_OUT_POST(abfd,src,dst) \ 100do { bfd_h_put_16(abfd, ((struct internal_filehdr *)(src))->f_target_id, \ 101 (bfd_byte *)(((FILHDR *)(dst))->f_target_id)); \ 102} while(0) | 104#define COFF_ADJUST_FILEHDR_OUT_POST(abfd, src, dst) \ 105 do \ 106 { \ 107 H_PUT_16 (abfd, ((struct internal_filehdr *)(src))->f_target_id, \ 108 ((FILHDR *)(dst))->f_target_id); \ 109 } \ 110 while (0) |
103#endif 104 105#define FILHDR struct external_filehdr 106#define FILHSZ 22 107#define FILHSZ_V0 20 /* COFF0 omits target_id field */ 108 109/* File header flags */ 110#define F_RELFLG (0x0001) --- 82 unchanged lines hidden (view full) --- 193#define SCNHDR struct external_scnhdr 194#define SCNHSZ_V01 40 /* for v0 and v1 */ 195#define SCNHSZ 48 196 197/* COFF2 changes the offsets and sizes of these fields 198 Assume we're dealing with the COFF2 scnhdr structure, and adjust 199 accordingly 200 */ | 111#endif 112 113#define FILHDR struct external_filehdr 114#define FILHSZ 22 115#define FILHSZ_V0 20 /* COFF0 omits target_id field */ 116 117/* File header flags */ 118#define F_RELFLG (0x0001) --- 82 unchanged lines hidden (view full) --- 201#define SCNHDR struct external_scnhdr 202#define SCNHSZ_V01 40 /* for v0 and v1 */ 203#define SCNHSZ 48 204 205/* COFF2 changes the offsets and sizes of these fields 206 Assume we're dealing with the COFF2 scnhdr structure, and adjust 207 accordingly 208 */ |
201#define GET_SCNHDR_NRELOC(ABFD,PTR) \ 202(COFF2_P(ABFD) ? bfd_h_get_32 (ABFD,PTR) : bfd_h_get_16 (ABFD, PTR)) 203#define PUT_SCNHDR_NRELOC(ABFD,VAL,PTR) \ 204(COFF2_P(ABFD) ? bfd_h_put_32 (ABFD,VAL,PTR) : bfd_h_put_16 (ABFD,VAL,PTR)) 205#define GET_SCNHDR_NLNNO(ABFD,PTR) \ 206(COFF2_P(ABFD) ? bfd_h_get_32 (ABFD,PTR) : bfd_h_get_16 (ABFD, (PTR)-2)) 207#define PUT_SCNHDR_NLNNO(ABFD,VAL,PTR) \ 208(COFF2_P(ABFD) ? bfd_h_put_32 (ABFD,VAL,PTR) : bfd_h_put_16 (ABFD,VAL,(PTR)-2)) 209#define GET_SCNHDR_FLAGS(ABFD,PTR) \ 210(COFF2_P(ABFD) ? bfd_h_get_32 (ABFD,PTR) : bfd_h_get_16 (ABFD, (PTR)-4)) 211#define PUT_SCNHDR_FLAGS(ABFD,VAL,PTR) \ 212(COFF2_P(ABFD) ? bfd_h_put_32 (ABFD,VAL,PTR) : bfd_h_put_16 (ABFD,VAL,(PTR)-4)) 213#define GET_SCNHDR_PAGE(ABFD,PTR) \ 214(COFF2_P(ABFD) ? bfd_h_get_16 (ABFD,PTR) : bfd_h_get_8 (ABFD, (PTR)-7)) | 209#define GET_SCNHDR_NRELOC(ABFD, PTR) \ 210 (COFF2_P (ABFD) ? H_GET_32 (ABFD, PTR) : H_GET_16 (ABFD, PTR)) 211#define PUT_SCNHDR_NRELOC(ABFD, VAL, PTR) \ 212 (COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, PTR) : H_PUT_16 (ABFD, VAL, PTR)) 213#define GET_SCNHDR_NLNNO(ABFD, PTR) \ 214 (COFF2_P (ABFD) ? H_GET_32 (ABFD, PTR) : H_GET_16 (ABFD, (PTR) -2)) 215#define PUT_SCNHDR_NLNNO(ABFD, VAL, PTR) \ 216 (COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, PTR) : H_PUT_16 (ABFD, VAL, (PTR) -2)) 217#define GET_SCNHDR_FLAGS(ABFD, PTR) \ 218 (COFF2_P (ABFD) ? H_GET_32 (ABFD, PTR) : H_GET_16 (ABFD, (PTR) -4)) 219#define PUT_SCNHDR_FLAGS(ABFD, VAL, PTR) \ 220 (COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, PTR) : H_PUT_16 (ABFD, VAL, (PTR) -4)) 221#define GET_SCNHDR_PAGE(ABFD, PTR) \ 222 (COFF2_P (ABFD) ? H_GET_16 (ABFD, PTR) : (unsigned) H_GET_8 (ABFD, (PTR) -7)) |
215/* on output, make sure that the "reserved" field is zero */ | 223/* on output, make sure that the "reserved" field is zero */ |
216#define PUT_SCNHDR_PAGE(ABFD,VAL,PTR) \ 217(COFF2_P(ABFD) ? bfd_h_put_16 (ABFD,VAL,PTR) : \ 218bfd_h_put_8 (ABFD,VAL,(PTR)-7), bfd_h_put_8 (ABFD, 0, (PTR)-8)) | 224#define PUT_SCNHDR_PAGE(ABFD, VAL, PTR) \ 225 (COFF2_P (ABFD) \ 226 ? H_PUT_16 (ABFD, VAL, PTR) \ 227 : H_PUT_8 (ABFD, VAL, (PTR) -7), H_PUT_8 (ABFD, 0, (PTR) -8)) |
219 220/* TI COFF stores section size as number of bytes (address units, not octets), 221 so adjust to be number of octets, which is what BFD expects */ | 228 229/* TI COFF stores section size as number of bytes (address units, not octets), 230 so adjust to be number of octets, which is what BFD expects */ |
222#define GET_SCNHDR_SIZE(ABFD,SZP) \ 223(bfd_h_get_32(ABFD,SZP)*bfd_octets_per_byte(ABFD)) 224#define PUT_SCNHDR_SIZE(ABFD,SZ,SZP) \ 225bfd_h_put_32(ABFD,(SZ)/bfd_octets_per_byte(ABFD),SZP) | 231#define GET_SCNHDR_SIZE(ABFD, SZP) \ 232 (H_GET_32 (ABFD, SZP) * bfd_octets_per_byte (ABFD)) 233#define PUT_SCNHDR_SIZE(ABFD, SZ, SZP) \ 234 H_PUT_32 (ABFD, (SZ) / bfd_octets_per_byte (ABFD), SZP) |
226 | 235 |
227#define COFF_ADJUST_SCNHDR_IN_POST(ABFD,EXT,INT) \ 228do { ((struct internal_scnhdr *)(INT))->s_page = \ 229GET_SCNHDR_PAGE(ABFD,(bfd_byte *)((SCNHDR *)(EXT))->s_page); \ 230} while(0) | 236#define COFF_ADJUST_SCNHDR_IN_POST(ABFD, EXT, INT) \ 237 do \ 238 { \ 239 ((struct internal_scnhdr *)(INT))->s_page = \ 240 GET_SCNHDR_PAGE (ABFD, ((SCNHDR *)(EXT))->s_page); \ 241 } \ 242 while (0) |
231 232/* The line number and reloc overflow checking in coff_swap_scnhdr_out in 233 coffswap.h doesn't use PUT_X for s_nlnno and s_nreloc. 234 Due to different sized v0/v1/v2 section headers, we have to re-write these 235 fields. 236 */ | 243 244/* The line number and reloc overflow checking in coff_swap_scnhdr_out in 245 coffswap.h doesn't use PUT_X for s_nlnno and s_nreloc. 246 Due to different sized v0/v1/v2 section headers, we have to re-write these 247 fields. 248 */ |
237#define COFF_ADJUST_SCNHDR_OUT_POST(ABFD,INT,EXT) \ 238do { \ 239PUT_SCNHDR_NLNNO(ABFD,((struct internal_scnhdr *)(INT))->s_nlnno,\ 240 (bfd_byte *)((SCNHDR *)(EXT))->s_nlnno); \ 241PUT_SCNHDR_NRELOC(ABFD,((struct internal_scnhdr *)(INT))->s_nreloc,\ 242 (bfd_byte *)((SCNHDR *)(EXT))->s_nreloc); \ 243PUT_SCNHDR_FLAGS(ABFD,((struct internal_scnhdr *)(INT))->s_flags, \ 244 (bfd_byte *)((SCNHDR *)(EXT))->s_flags); \ 245PUT_SCNHDR_PAGE(ABFD,((struct internal_scnhdr *)(INT))->s_page, \ 246 (bfd_byte *)((SCNHDR *)(EXT))->s_page); \ 247} while(0) | 249#define COFF_ADJUST_SCNHDR_OUT_POST(ABFD, INT, EXT) \ 250 do \ 251 { \ 252 PUT_SCNHDR_NLNNO (ABFD, ((struct internal_scnhdr *)(INT))->s_nlnno, \ 253 ((SCNHDR *)(EXT))->s_nlnno); \ 254 PUT_SCNHDR_NRELOC (ABFD, ((struct internal_scnhdr *)(INT))->s_nreloc,\ 255 ((SCNHDR *)(EXT))->s_nreloc); \ 256 PUT_SCNHDR_FLAGS (ABFD, ((struct internal_scnhdr *)(INT))->s_flags, \ 257 ((SCNHDR *)(EXT))->s_flags); \ 258 PUT_SCNHDR_PAGE (ABFD, ((struct internal_scnhdr *)(INT))->s_page, \ 259 ((SCNHDR *)(EXT))->s_page); \ 260 } \ 261 while (0) |
248 | 262 |
249/* Page macros 250 251 The first GDB port requires flags in its remote memory access commands to 252 distinguish between data/prog space. Hopefully we can make this go away 253 eventually. Stuff the page in the upper bits of a 32-bit address, since 254 the c5x family only uses 16 or 23 bits. 255 256 c2x, c5x and most c54x devices have 16-bit addresses, but the c548 has 257 23-bit program addresses. Make sure the page flags don't interfere. 258 These flags are used by GDB to identify the destination page for 259 addresses. 260*/ 261 262/* recognized load pages */ 263#define PG_PROG 0x0 /* PROG page */ 264#define PG_DATA 0x1 /* DATA page */ 265 266#define ADDR_MASK 0x00FFFFFF 267#define PG_TO_FLAG(p) (((unsigned long)(p) & 0xFF) << 24) 268#define FLAG_TO_PG(f) (((f) >> 24) & 0xFF) 269 | |
270/* 271 * names of "special" sections 272 */ 273#define _TEXT ".text" 274#define _DATA ".data" 275#define _BSS ".bss" 276#define _CINIT ".cinit" /* initialized C data */ 277#define _SCONST ".const" /* constants */ --- 101 unchanged lines hidden (view full) --- 379}; 380 381#define SYMENT struct external_syment 382#define SYMESZ 18 383#define AUXENT union external_auxent 384#define AUXESZ 18 385 386/* section lengths are in target bytes (not host bytes) */ | 263/* 264 * names of "special" sections 265 */ 266#define _TEXT ".text" 267#define _DATA ".data" 268#define _BSS ".bss" 269#define _CINIT ".cinit" /* initialized C data */ 270#define _SCONST ".const" /* constants */ --- 101 unchanged lines hidden (view full) --- 372}; 373 374#define SYMENT struct external_syment 375#define SYMESZ 18 376#define AUXENT union external_auxent 377#define AUXESZ 18 378 379/* section lengths are in target bytes (not host bytes) */ |
387#define GET_SCN_SCNLEN(ABFD,EXT) \ 388(bfd_h_get_32(ABFD,(bfd_byte *)(EXT)->x_scn.x_scnlen)*bfd_octets_per_byte(ABFD)) 389#define PUT_SCN_SCNLEN(ABFD,INT,EXT) \ 390bfd_h_put_32(ABFD,(INT)/bfd_octets_per_byte(ABFD),\ 391 (bfd_byte *)(EXT)->x_scn.x_scnlen) | 380#define GET_SCN_SCNLEN(ABFD, EXT) \ 381 (H_GET_32 (ABFD, (EXT)->x_scn.x_scnlen) * bfd_octets_per_byte (ABFD)) 382#define PUT_SCN_SCNLEN(ABFD, INT, EXT) \ 383 H_PUT_32 (ABFD, (INT) / bfd_octets_per_byte (ABFD), (EXT)->x_scn.x_scnlen) |
392 393/* lnsz size is in bits in COFF file, in bytes in BFD */ 394#define GET_LNSZ_SIZE(abfd, ext) \ | 384 385/* lnsz size is in bits in COFF file, in bytes in BFD */ 386#define GET_LNSZ_SIZE(abfd, ext) \ |
395(bfd_h_get_16(abfd, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_size) / \ 396 (class != C_FIELD ? 8 : 1)) | 387 (H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size) / (class != C_FIELD ? 8 : 1)) |
397 398#define PUT_LNSZ_SIZE(abfd, in, ext) \ | 388 389#define PUT_LNSZ_SIZE(abfd, in, ext) \ |
399 bfd_h_put_16(abfd, ((class != C_FIELD) ? (in)*8 : (in)), \ 400 (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size) | 390 H_PUT_16 (abfd, ((class != C_FIELD) ? (in) * 8 : (in)), \ 391 ext->x_sym.x_misc.x_lnsz.x_size) |
401 | 392 |
402/* TI COFF stores offsets for MOS and MOU in bits; BFD expects bytes */ 403#define COFF_ADJUST_SYM_IN_POST(ABFD,EXT,INT) \ 404do { struct internal_syment *dst = (struct internal_syment *)(INT); \ 405if (dst->n_sclass == C_MOS || dst->n_sclass == C_MOU) dst->n_value /= 8; \ 406} while (0) | 393/* TI COFF stores offsets for MOS and MOU in bits; BFD expects bytes 394 Also put the load page flag of the section into the symbol value if it's an 395 address. */ 396#ifndef NEEDS_PAGE 397#define NEEDS_PAGE(X) 0 398#define PAGE_MASK 0 399#endif 400#define COFF_ADJUST_SYM_IN_POST(ABFD, EXT, INT) \ 401 do \ 402 { \ 403 struct internal_syment *dst = (struct internal_syment *)(INT); \ 404 if (dst->n_sclass == C_MOS || dst->n_sclass == C_MOU) \ 405 dst->n_value /= 8; \ 406 else if (NEEDS_PAGE (dst->n_sclass)) { \ 407 asection *scn = coff_section_from_bfd_index (abfd, dst->n_scnum); \ 408 dst->n_value |= (scn->lma & PAGE_MASK); \ 409 } \ 410 } \ 411 while (0) |
407 | 412 |
408#define COFF_ADJUST_SYM_OUT_POST(ABFD,INT,EXT) \ 409do { struct internal_syment *src = (struct internal_syment *)(INT); \ 410SYMENT *dst = (SYMENT *)(EXT); \ 411if(src->n_sclass == C_MOU || src->n_sclass == C_MOS) \ 412bfd_h_put_32(abfd,src->n_value * 8,(bfd_byte *)dst->e_value); \ 413} while (0) | 413#define COFF_ADJUST_SYM_OUT_POST(ABFD, INT, EXT) \ 414 do \ 415 { \ 416 struct internal_syment *src = (struct internal_syment *)(INT); \ 417 SYMENT *dst = (SYMENT *)(EXT); \ 418 if (src->n_sclass == C_MOU || src->n_sclass == C_MOS) \ 419 H_PUT_32 (abfd, src->n_value * 8, dst->e_value); \ 420 else if (NEEDS_PAGE (src->n_sclass)) { \ 421 H_PUT_32 (abfd, src->n_value &= ~PAGE_MASK, dst->e_value); \ 422 } \ 423 } \ 424 while (0) |
414 415/* Detect section-relative absolute symbols so they get flagged with a sym 416 index of -1. 417*/ | 425 426/* Detect section-relative absolute symbols so they get flagged with a sym 427 index of -1. 428*/ |
418#define SECTION_RELATIVE_ABSOLUTE_SYMBOL_P(RELOC,SECT) \ 419((*(RELOC)->sym_ptr_ptr)->section->output_section == (SECT) \ 420 && (RELOC)->howto->name[0] == 'A') | 429#define SECTION_RELATIVE_ABSOLUTE_SYMBOL_P(RELOC, SECT) \ 430 ((*(RELOC)->sym_ptr_ptr)->section->output_section == (SECT) \ 431 && (RELOC)->howto->name[0] == 'A') |
421 422/********************** RELOCATION DIRECTIVES **********************/ 423 | 432 433/********************** RELOCATION DIRECTIVES **********************/ 434 |
424struct external_reloc_v0 { | 435struct external_reloc_v0 436{ |
425 char r_vaddr[4]; 426 char r_symndx[2]; 427 char r_reserved[2]; 428 char r_type[2]; 429}; 430 | 437 char r_vaddr[4]; 438 char r_symndx[2]; 439 char r_reserved[2]; 440 char r_type[2]; 441}; 442 |
431struct external_reloc { | 443struct external_reloc 444{ |
432 char r_vaddr[4]; 433 char r_symndx[4]; 434 char r_reserved[2]; /* extended pmad byte for COFF2 */ 435 char r_type[2]; 436}; 437 438#define RELOC struct external_reloc 439#define RELSZ_V0 10 /* FIXME -- coffcode.h needs fixing */ --- 12 unchanged lines hidden --- | 445 char r_vaddr[4]; 446 char r_symndx[4]; 447 char r_reserved[2]; /* extended pmad byte for COFF2 */ 448 char r_type[2]; 449}; 450 451#define RELOC struct external_reloc 452#define RELSZ_V0 10 /* FIXME -- coffcode.h needs fixing */ --- 12 unchanged lines hidden --- |