rs6k64.h revision 85815
1177633Sdfr/* IBM RS/6000 "XCOFF64" file definitions for BFD.
2177633Sdfr   Copyright (C) 2000 Free Software Foundation, Inc.
3261046Smav
4261046Smav   This program is free software; you can redistribute it and/or modify
5261046Smav   it under the terms of the GNU General Public License as published by
6261046Smav   the Free Software Foundation; either version 2 of the License, or
7261046Smav   (at your option) any later version.
8261046Smav
9261046Smav   This program is distributed in the hope that it will be useful,
10261046Smav   but WITHOUT ANY WARRANTY; without even the implied warranty of
11261046Smav   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12261046Smav   GNU General Public License for more details.
13261046Smav
14261046Smav   You should have received a copy of the GNU General Public License
15261046Smav   along with this program; if not, write to the Free Software
16261046Smav   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17177633Sdfr*/
18261046Smav
19261046Smav/********************** FILE HEADER **********************/
20261046Smav
21261046Smavstruct external_filehdr {
22261046Smav	char f_magic[2];	/* magic number			*/
23261046Smav	char f_nscns[2];	/* number of sections		*/
24261046Smav	char f_timdat[4];	/* time & date stamp		*/
25261046Smav	char f_symptr[8];/* file pointer to symtab 	*/
26261046Smav	char f_opthdr[2];	/* sizeof(optional hdr)		*/
27261046Smav	char f_flags[2];	/* flags			*/
28261046Smav	char f_nsyms[4];	/* number of symtab entries	*/
29177633Sdfr};
30177633Sdfr
31177633Sdfr        /* IBM RS/6000 */
32177633Sdfr#define U803XTOCMAGIC 0757	/* readonly text segments and TOC, XCOFF64 */
33177633Sdfr
34177633Sdfr#define BADMAG(x) ((x).f_magic != U803XTOCMAGIC)
35177633Sdfr
36177633Sdfr#define	FILHDR	struct external_filehdr
37177633Sdfr#define	FILHSZ	24
38177633Sdfr
39177633Sdfr/********************** AOUT "OPTIONAL HEADER" **********************/
40177633Sdfr
41177633Sdfr
42177633Sdfrtypedef struct
43177633Sdfr{
44177633Sdfr  unsigned char	magic[2];		/* type of file			*/
45177633Sdfr  unsigned char	vstamp[2];		/* version stamp		*/
46177633Sdfr  unsigned char	o_debugger[4];		/* reserved 			*/
47177633Sdfr  unsigned char	text_start[8];	/* base of text used for this file */
48177633Sdfr  unsigned char	data_start[8];	/* base of data used for this file */
49177633Sdfr  unsigned char	o_toc[8];	/* address of TOC */
50193650Srwatson  unsigned char	o_snentry[2];		/* section number of entry point */
51177633Sdfr  unsigned char	o_sntext[2];		/* section number of .text section */
52177633Sdfr  unsigned char	o_sndata[2];		/* section number of .data section */
53177633Sdfr  unsigned char	o_sntoc[2];		/* section number of TOC */
54177633Sdfr  unsigned char	o_snloader[2];		/* section number of .loader section */
55184588Sdfr  unsigned char	o_snbss[2];		/* section number of .bss section */
56184588Sdfr  unsigned char	o_algntext[2];		/* .text alignment */
57184588Sdfr  unsigned char	o_algndata[2];		/* .data alignment */
58184588Sdfr  unsigned char	o_modtype[2];		/* module type (??) */
59184588Sdfr  unsigned char o_cputype[2];		/* cpu type */
60184588Sdfr  unsigned char	o_resv2[4];		/* reserved 			*/
61184588Sdfr  unsigned char	tsize[8];		/* text size bytes, padded to FW bdry */
62177633Sdfr  unsigned char	dsize[8];		/* initialized data "  "	*/
63177633Sdfr  unsigned char	bsize[8];		/* uninitialized data "   "	*/
64177633Sdfr  unsigned char	entry[8];		/* entry pt.			*/
65177633Sdfr  unsigned char	o_maxstack[8];	/* max stack size (??) 		*/
66177633Sdfr  unsigned char o_maxdata[8];	/* max data size (??) 		*/
67177633Sdfr  unsigned char	o_resv3[16];		/* reserved 			*/
68177633Sdfr}
69177633SdfrAOUTHDR;
70177633Sdfr
71177633Sdfr#define AOUTSZ 120
72177633Sdfr#define SMALL_AOUTSZ (0)
73177633Sdfr#define AOUTHDRSZ 72
74177633Sdfr
75177633Sdfr#define	RS6K_AOUTHDR_OMAGIC	0x0107	/* old: text & data writeable */
76177633Sdfr#define	RS6K_AOUTHDR_NMAGIC	0x0108	/* new: text r/o, data r/w */
77177633Sdfr#define	RS6K_AOUTHDR_ZMAGIC	0x010B	/* paged: text r/o, both page-aligned */
78177633Sdfr
79177633Sdfr
80177633Sdfr/********************** SECTION HEADER **********************/
81177633Sdfr
82177633Sdfr
83177633Sdfrstruct external_scnhdr {
84177633Sdfr	char	s_name[8];		/* section name			*/
85177633Sdfr	char	s_paddr[8];	/* physical address, aliased s_nlib */
86177633Sdfr	char	s_vaddr[8];	/* virtual address		*/
87184588Sdfr	char	s_size[8];	/* section size			*/
88184588Sdfr	char	s_scnptr[8];	/* file ptr to raw data for section */
89177633Sdfr	char	s_relptr[8];	/* file ptr to relocation	*/
90177633Sdfr	char	s_lnnoptr[8];	/* file ptr to line numbers	*/
91177633Sdfr	char	s_nreloc[4];	/* number of relocation entries	*/
92177633Sdfr	char	s_nlnno[4];	/* number of line number entries*/
93177633Sdfr	char	s_flags[4];		/* flags			*/
94177633Sdfr	char    s_pad[4];		/* padding */
95177633Sdfr};
96177633Sdfr
97177633Sdfr/*
98177633Sdfr * names of "special" sections
99177633Sdfr */
100184588Sdfr#define _TEXT	".text"
101184588Sdfr#define _DATA	".data"
102184588Sdfr#define _BSS	".bss"
103184588Sdfr#define _PAD	".pad"
104184588Sdfr#define _LOADER	".loader"
105177633Sdfr
106177633Sdfr#define	SCNHDR	struct external_scnhdr
107177633Sdfr
108177633Sdfr#define	SCNHSZ	72
109177633Sdfr
110177633Sdfr/* XCOFF uses a special .loader section with type STYP_LOADER.  */
111177633Sdfr#define STYP_LOADER 0x1000
112184588Sdfr
113184588Sdfr/* XCOFF uses a special .debug section with type STYP_DEBUG.  */
114184588Sdfr#define STYP_DEBUG 0x2000
115184588Sdfr
116184588Sdfr/* XCOFF handles line number or relocation overflow by creating
117184588Sdfr   another section header with STYP_OVRFLO set.  */
118184588Sdfr#define STYP_OVRFLO 0x8000
119184588Sdfr
120184588Sdfr/********************** LINE NUMBERS **********************/
121184588Sdfr
122184588Sdfr/* 1 line number entry for every "breakpointable" source line in a section.
123184588Sdfr * Line numbers are grouped on a per function basis; first entry in a function
124184588Sdfr * grouping will have l_lnno = 0 and in place of physical address will be the
125184588Sdfr * symbol table index of the function name.
126184588Sdfr */
127184588Sdfrstruct external_lineno {
128184588Sdfr	union {
129184588Sdfr		char l_symndx[8];/* function name symbol index, iff l_lnno == 0*/
130184588Sdfr		char l_paddr[8];	/* (physical) address of line number	*/
131184588Sdfr	} l_addr;
132184588Sdfr	char l_lnno[4];		/* line number		*/
133184588Sdfr};
134184588Sdfr
135184588Sdfr
136184588Sdfr#define	LINENO	struct external_lineno
137184588Sdfr
138184588Sdfr#define	LINESZ	12
139184588Sdfr
140184588Sdfr
141184588Sdfr/********************** SYMBOLS **********************/
142177633Sdfr
143177633Sdfr#define E_SYMNMLEN	8	/* # characters in a symbol name	*/
144177633Sdfr#define E_FILNMLEN	14	/* # characters in a file name		*/
145177633Sdfr#define E_DIMNUM	4	/* # array dimensions in auxiliary entry */
146184588Sdfr
147184588Sdfrstruct external_syment
148177633Sdfr{
149177633Sdfr  union {
150177633Sdfr    char e_value[8];
151177633Sdfr  } e;
152184588Sdfr  char e_offset[4];
153184588Sdfr  char e_scnum[2];
154184588Sdfr  char e_type[2];
155177633Sdfr  char e_sclass[1];
156184588Sdfr  char e_numaux[1];
157184588Sdfr};
158184588Sdfr
159184588Sdfr
160184588Sdfr
161184588Sdfr#define N_BTMASK	(017)
162184588Sdfr#define N_TMASK		(060)
163184588Sdfr#define N_BTSHFT	(4)
164184588Sdfr#define N_TSHIFT	(2)
165184588Sdfr
166184588Sdfr
167184588Sdfrunion external_auxent {
168194498Sbrooks
169177633Sdfr    struct {
170177633Sdfr    	union {
171177633Sdfr	    struct {
172177633Sdfr		char x_lnno[4]; 	/* declaration line number */
173177633Sdfr		char x_size[2]; 	/* str/union/array size */
174177633Sdfr	    } x_lnsz;
175177633Sdfr	    struct {
176177633Sdfr		char x_lnnoptr[8];/* ptr to fcn line */
177177633Sdfr		char x_fsize[4];	 /* size of function */
178184588Sdfr		char x_endndx[4];	 /* entry ndx past block end */
179177633Sdfr	    } x_fcn;
180194498Sbrooks 	} x_fcnary;
181184588Sdfr    } x_sym;
182193650Srwatson
183193650Srwatson    union {
184184588Sdfr	char x_fname[E_FILNMLEN];
185177633Sdfr	struct {
186177633Sdfr	    char x_zeroes[4];
187184588Sdfr	    char x_offset[4];
188184588Sdfr	    char          x_pad[6];
189184588Sdfr	    unsigned char x_ftype[1];
190184588Sdfr	    unsigned char x_resv[2];
191184588Sdfr	} x_n;
192177633Sdfr    } x_file;
193177633Sdfr
194177633Sdfr    struct {
195177633Sdfr	char x_exptr[8];
196177633Sdfr	char x_fsize[4];
197	char x_endndx[4];
198	char x_pad[1];
199    } x_except;
200
201    struct {
202	    unsigned char x_scnlen_lo[4];
203	    unsigned char x_parmhash[4];
204	    unsigned char x_snhash[2];
205	    unsigned char x_smtyp[1];
206	    unsigned char x_smclas[1];
207	    unsigned char x_scnlen_hi[4];
208	    unsigned char x_pad[1];
209    } x_csect;
210
211    struct {
212	char x_pad[17];
213	char x_auxtype[1];
214    } x_auxtype;
215};
216
217#define	SYMENT	struct external_syment
218#define	SYMESZ	18
219#define	AUXENT	union external_auxent
220#define	AUXESZ	18
221#define DBXMASK 0x80		/* for dbx storage mask */
222#define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
223
224/* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h */
225#define _AUX_EXCEPT     255
226#define _AUX_FCN        254
227#define _AUX_SYM        253
228#define _AUX_FILE       252
229#define _AUX_CSECT      251
230
231
232
233/********************** RELOCATION DIRECTIVES **********************/
234
235
236struct external_reloc {
237  char r_vaddr[8];
238  char r_symndx[4];
239  char r_size[1];
240  char r_type[1];
241};
242
243
244#define RELOC struct external_reloc
245#define RELSZ 14
246
247#define DEFAULT_DATA_SECTION_ALIGNMENT 4
248#define DEFAULT_BSS_SECTION_ALIGNMENT 4
249#define DEFAULT_TEXT_SECTION_ALIGNMENT 4
250/* For new sections we havn't heard of before */
251#define DEFAULT_SECTION_ALIGNMENT 4
252