arm.h revision 78828
192108Sphk/* ARM COFF support for BFD. 292108Sphk Copyright 1998, 1999, 2000 Free Software Foundation, Inc. 392108Sphk 492108Sphk This file is part of BFD, the Binary File Descriptor library. 592108Sphk 692108Sphk This program is free software; you can redistribute it and/or modify 792108Sphk it under the terms of the GNU General Public License as published by 892108Sphk the Free Software Foundation; either version 2 of the License, or 992108Sphk (at your option) any later version. 1092108Sphk 1192108Sphk This program is distributed in the hope that it will be useful, 1292108Sphk but WITHOUT ANY WARRANTY; without even the implied warranty of 1392108Sphk MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1492108Sphk GNU General Public License for more details. 1592108Sphk 1692108Sphk You should have received a copy of the GNU General Public License 1792108Sphk along with this program; if not, write to the Free Software Foundation, 1892108Sphk Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 1992108Sphk 2092108Sphk#define COFFARM 1 2192108Sphk 2292108Sphk/********************** FILE HEADER **********************/ 2392108Sphk 2492108Sphkstruct external_filehdr 2592108Sphk{ 2692108Sphk char f_magic[2]; /* magic number */ 2792108Sphk char f_nscns[2]; /* number of sections */ 2892108Sphk char f_timdat[4]; /* time & date stamp */ 2992108Sphk char f_symptr[4]; /* file pointer to symtab */ 3092108Sphk char f_nsyms[4]; /* number of symtab entries */ 3192108Sphk char f_opthdr[2]; /* sizeof(optional hdr) */ 3292108Sphk char f_flags[2]; /* flags */ 3392108Sphk}; 3492108Sphk 3592108Sphk/* Bits for f_flags: 36116196Sobrien * F_RELFLG relocation info stripped from file 37116196Sobrien * F_EXEC file is executable (no unresolved external references) 38116196Sobrien * F_LNNO line numbers stripped from file 3992108Sphk * F_LSYMS local symbols stripped from file 4092108Sphk * F_INTERWORK file supports switching between ARM and Thumb instruction sets 4192108Sphk * F_INTERWORK_SET the F_INTERWORK bit is valid 42113926Sphk * F_APCS_FLOAT code passes float arguments in float registers 4392108Sphk * F_PIC code is reentrant/position-independent 4492108Sphk * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) 4592108Sphk * F_APCS_26 file uses 26 bit ARM Procedure Calling Standard 4692108Sphk * F_APCS_SET the F_APCS_26, F_APCS_FLOAT and F_PIC bits have been initialised 4792108Sphk * F_SOFT_FLOAT code does not use floating point instructions 4892108Sphk */ 4992108Sphk 5092108Sphk#define F_RELFLG (0x0001) 5192108Sphk#define F_EXEC (0x0002) 5292108Sphk#define F_LNNO (0x0004) 5393250Sphk#define F_LSYMS (0x0008) 5492108Sphk#define F_INTERWORK (0x0010) 5592108Sphk#define F_INTERWORK_SET (0x0020) 5692108Sphk#define F_APCS_FLOAT (0x0040) 5792108Sphk#undef F_AR16WR 5892108Sphk#define F_PIC (0x0080) 5992108Sphk#define F_AR32WR (0x0100) 6092108Sphk#define F_APCS_26 (0x0400) 6192108Sphk#define F_APCS_SET (0x0800) 62110592Sphk#define F_SOFT_FLOAT (0x2000) 63113926Sphk 6492108Sphk/* Bits stored in flags field of the internal_f structure */ 65104063Sphk 66104063Sphk#define F_INTERWORK (0x0010) 67104063Sphk#define F_APCS_FLOAT (0x0040) 68104063Sphk#define F_PIC (0x0080) 69104063Sphk#define F_APCS26 (0x1000) 70104063Sphk#define F_ARM_ARCHITECTURE_MASK (0x4000+0x0800+0x0400) 71104063Sphk#define F_ARM_2 (0x0400) 72104063Sphk#define F_ARM_2a (0x0800) 73104063Sphk#define F_ARM_3 (0x0c00) 74104063Sphk#define F_ARM_3M (0x4000) 75104063Sphk#define F_ARM_4 (0x4400) 76104063Sphk#define F_ARM_4T (0x4800) 77104063Sphk#define F_ARM_5 (0x4c00) 78104063Sphk 79104063Sphk/* 80104063Sphk * ARMMAGIC ought to encoded the procesor type, 81104063Sphk * but it is too late to change it now, instead 82104063Sphk * the flags field of the internal_f structure 8392108Sphk * is used as shown above. 8492108Sphk * 8592108Sphk * XXX - NC 5/6/97 8692108Sphk */ 8799028Sjulian 8892108Sphk#define ARMMAGIC 0xa00 /* I just made this up */ 89108296Sphk 90104087Sphk#define ARMBADMAG(x) (((x).f_magic != ARMMAGIC)) 9192108Sphk 9292108Sphk#define ARMPEMAGIC 0x1c0 9392108Sphk#define THUMBPEMAGIC 0x1c2 9492108Sphk 9592108Sphk#undef ARMBADMAG 9692108Sphk#define ARMBADMAG(x) (((x).f_magic != ARMMAGIC) && ((x).f_magic != ARMPEMAGIC) && ((x).f_magic != THUMBPEMAGIC)) 9792108Sphk 9892108Sphk#define FILHDR struct external_filehdr 9992108Sphk#define FILHSZ 20 10092108Sphk 10192108Sphk 10292108Sphk/********************** AOUT "OPTIONAL HEADER" **********************/ 10392108Sphk 10492108Sphk 10592108Sphktypedef struct 10692108Sphk{ 10792108Sphk char magic[2]; /* type of file */ 10899028Sjulian char vstamp[2]; /* version stamp */ 10992108Sphk char tsize[4]; /* text size in bytes, padded to FW bdry*/ 110108296Sphk char dsize[4]; /* initialized data " " */ 111104087Sphk char bsize[4]; /* uninitialized data " " */ 11292108Sphk char entry[4]; /* entry pt. */ 11392108Sphk char text_start[4]; /* base of text used for this file */ 11492108Sphk char data_start[4]; /* base of data used for this file */ 11592108Sphk} 11692108SphkAOUTHDR; 11792108Sphk 11892108Sphk 11992108Sphk#define AOUTSZ 28 12092108Sphk#define AOUTHDRSZ 28 12192108Sphk 12292108Sphk#define OMAGIC 0404 /* object files, eg as output */ 12392108Sphk#define ZMAGIC 0413 /* demand load format, eg normal ld output */ 12492108Sphk#define STMAGIC 0401 /* target shlib */ 12592108Sphk#define SHMAGIC 0443 /* host shlib */ 12692108Sphk 12792108Sphk 128107452Sphk/* define some NT default values */ 129104087Sphk/* #define NT_IMAGE_BASE 0x400000 moved to internal.h */ 13092108Sphk#define NT_SECTION_ALIGNMENT 0x1000 131108296Sphk#define NT_FILE_ALIGNMENT 0x200 132104087Sphk#define NT_DEF_RESERVE 0x100000 13392108Sphk#define NT_DEF_COMMIT 0x1000 13493250Sphk 135116522Sphk/********************** SECTION HEADER **********************/ 13692108Sphkstruct external_scnhdr 13792108Sphk{ 13892108Sphk char s_name[8]; /* section name */ 139114293Smarkm char s_paddr[4]; /* physical address, aliased s_nlib */ 14092108Sphk char s_vaddr[4]; /* virtual address */ 14192108Sphk char s_size[4]; /* section size */ 14292108Sphk char s_scnptr[4]; /* file ptr to raw data for section */ 14392108Sphk char s_relptr[4]; /* file ptr to relocation */ 14492108Sphk char s_lnnoptr[4]; /* file ptr to line numbers */ 145113926Sphk char s_nreloc[2]; /* number of relocation entries */ 146113926Sphk char s_nlnno[2]; /* number of line number entries*/ 147113926Sphk char s_flags[4]; /* flags */ 148113926Sphk}; 149113926Sphk 150113926Sphk#define SCNHDR struct external_scnhdr 151113926Sphk#define SCNHSZ 40 15292108Sphk 15392108Sphk/* 15492108Sphk * names of "special" sections 155116522Sphk */ 156116522Sphk#define _TEXT ".text" 15792108Sphk#define _DATA ".data" 15892108Sphk#define _BSS ".bss" 15992108Sphk#define _COMMENT ".comment" 160112534Sphk#define _LIB ".lib" 16192108Sphk 16292108Sphk/* We use the .rdata section to hold read only data. */ 16392108Sphk#define _LIT ".rdata" 16492108Sphk 16592108Sphk/********************** LINE NUMBERS **********************/ 166113926Sphk 167113926Sphk/* 1 line number entry for every "breakpointable" source line in a section. 16892108Sphk * Line numbers are grouped on a per function basis; first entry in a function 16992108Sphk * grouping will have l_lnno = 0 and in place of physical address will be the 17092108Sphk * symbol table index of the function name. 171106101Sphk */ 172106101Sphkstruct external_lineno 173106101Sphk{ 174106101Sphk union 175106101Sphk { 176106101Sphk char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ 177106101Sphk char l_paddr[4]; /* (physical) address of line number */ 178113940Sphk } l_addr; 179106101Sphk char l_lnno[2]; /* line number */ 180106101Sphk}; 181106101Sphk 182106101Sphk 183106101Sphk#define LINENO struct external_lineno 184106101Sphk#define LINESZ 6 185104452Sphk 18692108Sphk 187104452Sphk/********************** SYMBOLS **********************/ 18892108Sphk 18992108Sphk#define E_SYMNMLEN 8 /* # characters in a symbol name */ 190104452Sphk#define E_FILNMLEN 14 /* # characters in a file name */ 191104452Sphk#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ 192113940Sphk 193105358Sphkstruct external_syment 19492108Sphk{ 195104452Sphk union 19692108Sphk { 197104452Sphk char e_name[E_SYMNMLEN]; 19892108Sphk struct 199104452Sphk { 20092108Sphk char e_zeroes[4]; 201104452Sphk char e_offset[4]; 20292108Sphk } e; 20392108Sphk } e; 204104452Sphk char e_value[4]; 205104452Sphk char e_scnum[2]; 206113940Sphk char e_type[2]; 207105358Sphk char e_sclass[1]; 20892108Sphk char e_numaux[1]; 209104452Sphk}; 21092108Sphk 21192108Sphk#define N_BTMASK (0xf) 212104359Sphk#define N_TMASK (0x30) 213104359Sphk#define N_BTSHFT (4) 214104452Sphk#define N_TSHIFT (2) 215108308Sphk 216106101Sphkunion external_auxent 21792108Sphk{ 218104452Sphk struct 219108308Sphk { 220106101Sphk char x_tagndx[4]; /* str, un, or enum tag indx */ 221104359Sphk union 222106101Sphk { 223108308Sphk struct 224106101Sphk { 225106101Sphk char x_lnno[2]; /* declaration line number */ 226105581Sphk char x_size[2]; /* str/union/array size */ 22792108Sphk } x_lnsz; 22892108Sphk char x_fsize[4]; /* size of function */ 229110523Sphk } x_misc; 230110523Sphk union 231110523Sphk { 232105581Sphk struct /* if ISFCN, tag, or .bb */ 23393248Sphk { 234105581Sphk char x_lnnoptr[4]; /* ptr to fcn line # */ 23592108Sphk char x_endndx[4]; /* entry ndx past block end */ 236105581Sphk } x_fcn; 23792108Sphk struct /* if ISARY, up to 4 dimen. */ 238105581Sphk { 23992108Sphk char x_dimen[E_DIMNUM][2]; 240105581Sphk } x_ary; 24192108Sphk } x_fcnary; 242 char x_tvndx[2]; /* tv index */ 243 } x_sym; 244 245 union 246 { 247 char x_fname[E_FILNMLEN]; 248 struct 249 { 250 char x_zeroes[4]; 251 char x_offset[4]; 252 } x_n; 253 } x_file; 254 255 struct 256 { 257 char x_scnlen[4]; /* section length */ 258 char x_nreloc[2]; /* # relocation entries */ 259 char x_nlinno[2]; /* # line numbers */ 260 char x_checksum[4]; /* section COMDAT checksum */ 261 char x_associated[2]; /* COMDAT associated section index */ 262 char x_comdat[1]; /* COMDAT selection number */ 263 } x_scn; 264 265 struct 266 { 267 char x_tvfill[4]; /* tv fill value */ 268 char x_tvlen[2]; /* length of .tv */ 269 char x_tvran[2][2]; /* tv range */ 270 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ 271}; 272 273#define SYMENT struct external_syment 274#define SYMESZ 18 275#define AUXENT union external_auxent 276#define AUXESZ 18 277 278#define _ETEXT "etext" 279 280/********************** RELOCATION DIRECTIVES **********************/ 281#ifdef ARM_WINCE 282struct external_reloc 283{ 284 char r_vaddr[4]; 285 char r_symndx[4]; 286 char r_type[2]; 287}; 288 289#define RELOC struct external_reloc 290#define RELSZ 10 291 292#else 293struct external_reloc 294{ 295 char r_vaddr[4]; 296 char r_symndx[4]; 297 char r_type[2]; 298 char r_offset[4]; 299}; 300 301#define RELOC struct external_reloc 302#define RELSZ 14 303#endif 304