rs6k64.h revision 85815
1139804Simp/* IBM RS/6000 "XCOFF64" file definitions for BFD.
21541Srgrimes   Copyright (C) 2000 Free Software Foundation, Inc.
31541Srgrimes
41541Srgrimes   This program is free software; you can redistribute it and/or modify
51541Srgrimes   it under the terms of the GNU General Public License as published by
61541Srgrimes   the Free Software Foundation; either version 2 of the License, or
71541Srgrimes   (at your option) any later version.
81541Srgrimes
91541Srgrimes   This program is distributed in the hope that it will be useful,
101541Srgrimes   but WITHOUT ANY WARRANTY; without even the implied warranty of
111541Srgrimes   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
121541Srgrimes   GNU General Public License for more details.
131541Srgrimes
141541Srgrimes   You should have received a copy of the GNU General Public License
151541Srgrimes   along with this program; if not, write to the Free Software
161541Srgrimes   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
171541Srgrimes*/
181541Srgrimes
191541Srgrimes/********************** FILE HEADER **********************/
201541Srgrimes
211541Srgrimesstruct external_filehdr {
221541Srgrimes	char f_magic[2];	/* magic number			*/
231541Srgrimes	char f_nscns[2];	/* number of sections		*/
241541Srgrimes	char f_timdat[4];	/* time & date stamp		*/
251541Srgrimes	char f_symptr[8];/* file pointer to symtab 	*/
261541Srgrimes	char f_opthdr[2];	/* sizeof(optional hdr)		*/
271541Srgrimes	char f_flags[2];	/* flags			*/
281541Srgrimes	char f_nsyms[4];	/* number of symtab entries	*/
291541Srgrimes};
301541Srgrimes
311541Srgrimes        /* IBM RS/6000 */
32116182Sobrien#define U803XTOCMAGIC 0757	/* readonly text segments and TOC, XCOFF64 */
33116182Sobrien
34116182Sobrien#define BADMAG(x) ((x).f_magic != U803XTOCMAGIC)
351541Srgrimes
361541Srgrimes#define	FILHDR	struct external_filehdr
371541Srgrimes#define	FILHSZ	24
38108524Salfred
39143417Srwatson/********************** AOUT "OPTIONAL HEADER" **********************/
401541Srgrimes
41108524Salfred
42143417Srwatsontypedef struct
43143417Srwatson{
441541Srgrimes  unsigned char	magic[2];		/* type of file			*/
451541Srgrimes  unsigned char	vstamp[2];		/* version stamp		*/
4624206Sbde  unsigned char	o_debugger[4];		/* reserved 			*/
4724206Sbde  unsigned char	text_start[8];	/* base of text used for this file */
481541Srgrimes  unsigned char	data_start[8];	/* base of data used for this file */
4934924Sbde  unsigned char	o_toc[8];	/* address of TOC */
5060405Schris  unsigned char	o_snentry[2];		/* section number of entry point */
511541Srgrimes  unsigned char	o_sntext[2];		/* section number of .text section */
521541Srgrimes  unsigned char	o_sndata[2];		/* section number of .data section */
531541Srgrimes  unsigned char	o_sntoc[2];		/* section number of TOC */
54196019Srwatson  unsigned char	o_snloader[2];		/* section number of .loader section */
551541Srgrimes  unsigned char	o_snbss[2];		/* section number of .bss section */
56163606Srwatson  unsigned char	o_algntext[2];		/* .text alignment */
57163606Srwatson  unsigned char	o_algndata[2];		/* .data alignment */
58167206Srwatson  unsigned char	o_modtype[2];		/* module type (??) */
59116546Sphk  unsigned char o_cputype[2];		/* cpu type */
60116546Sphk  unsigned char	o_resv2[4];		/* reserved 			*/
61175140Sjhb  unsigned char	tsize[8];		/* text size bytes, padded to FW bdry */
62116546Sphk  unsigned char	dsize[8];		/* initialized data "  "	*/
63116546Sphk  unsigned char	bsize[8];		/* uninitialized data "   "	*/
64116546Sphk  unsigned char	entry[8];		/* entry pt.			*/
65116546Sphk  unsigned char	o_maxstack[8];	/* max stack size (??) 		*/
66116546Sphk  unsigned char o_maxdata[8];	/* max data size (??) 		*/
67224914Skib  unsigned char	o_resv3[16];		/* reserved 			*/
68224914Skib}
69116546SphkAOUTHDR;
7072521Sjlemon
711541Srgrimes#define AOUTSZ 120
721541Srgrimes#define SMALL_AOUTSZ (0)
7343408Snewton#define AOUTHDRSZ 72
74167206Srwatson
75167206Srwatson#define	RS6K_AOUTHDR_OMAGIC	0x0107	/* old: text & data writeable */
761541Srgrimes#define	RS6K_AOUTHDR_NMAGIC	0x0108	/* new: text r/o, data r/w */
77109153Sdillon#define	RS6K_AOUTHDR_ZMAGIC	0x010B	/* paged: text r/o, both page-aligned */
7892310Salfred
7992310Salfred
80191816Szec/********************** SECTION HEADER **********************/
81172930Srwatson
82171744Srwatson
83104571Srwatsonstruct external_scnhdr {
84104571Srwatson	char	s_name[8];		/* section name			*/
85191816Szec	char	s_paddr[8];	/* physical address, aliased s_nlib */
86191816Szec	char	s_vaddr[8];	/* virtual address		*/
871541Srgrimes	char	s_size[8];	/* section size			*/
881541Srgrimes	char	s_scnptr[8];	/* file ptr to raw data for section */
891541Srgrimes	char	s_relptr[8];	/* file ptr to relocation	*/
9043408Snewton	char	s_lnnoptr[8];	/* file ptr to line numbers	*/
91167206Srwatson	char	s_nreloc[4];	/* number of relocation entries	*/
92167206Srwatson	char	s_nlnno[4];	/* number of line number entries*/
931541Srgrimes	char	s_flags[4];		/* flags			*/
94109153Sdillon	char    s_pad[4];		/* padding */
9592310Salfred};
9692310Salfred
97104571Srwatson/*
98172930Srwatson * names of "special" sections
99171744Srwatson */
100104571Srwatson#define _TEXT	".text"
101104571Srwatson#define _DATA	".data"
102160619Srwatson#define _BSS	".bss"
103143417Srwatson#define _PAD	".pad"
104143417Srwatson#define _LOADER	".loader"
105209595Sjhb
106143417Srwatson#define	SCNHDR	struct external_scnhdr
107143417Srwatson
10892310Salfred#define	SCNHSZ	72
1091541Srgrimes
1101541Srgrimes/* XCOFF uses a special .loader section with type STYP_LOADER.  */
1111549Srgrimes#define STYP_LOADER 0x1000
112175140Sjhb
113175140Sjhb/* XCOFF uses a special .debug section with type STYP_DEBUG.  */
114175140Sjhb#define STYP_DEBUG 0x2000
115175140Sjhb
116175140Sjhb/* XCOFF handles line number or relocation overflow by creating
117175140Sjhb   another section header with STYP_OVRFLO set.  */
118175140Sjhb#define STYP_OVRFLO 0x8000
119175140Sjhb
120167206Srwatson/********************** LINE NUMBERS **********************/
121167206Srwatson
1221541Srgrimes/* 1 line number entry for every "breakpointable" source line in a section.
123137671Sphk * Line numbers are grouped on a per function basis; first entry in a function
124137671Sphk * grouping will have l_lnno = 0 and in place of physical address will be the
1251541Srgrimes * symbol table index of the function name.
1261541Srgrimes */
1271541Srgrimesstruct external_lineno {
128130653Srwatson	union {
1291541Srgrimes		char l_symndx[8];/* function name symbol index, iff l_lnno == 0*/
1301541Srgrimes		char l_paddr[8];	/* (physical) address of line number	*/
1311541Srgrimes	} l_addr;
1321541Srgrimes	char l_lnno[4];		/* line number		*/
133130653Srwatson};
134137671Sphk
1351541Srgrimes
1361541Srgrimes#define	LINENO	struct external_lineno
137130653Srwatson
138167206Srwatson#define	LINESZ	12
139167206Srwatson
140167206Srwatson
141167206Srwatson/********************** SYMBOLS **********************/
142130653Srwatson
1431541Srgrimes#define E_SYMNMLEN	8	/* # characters in a symbol name	*/
144130653Srwatson#define E_FILNMLEN	14	/* # characters in a file name		*/
1451541Srgrimes#define E_DIMNUM	4	/* # array dimensions in auxiliary entry */
146130653Srwatson
147130653Srwatsonstruct external_syment
1481541Srgrimes{
149130653Srwatson  union {
150130653Srwatson    char e_value[8];
1511541Srgrimes  } e;
152130653Srwatson  char e_offset[4];
1531541Srgrimes  char e_scnum[2];
154130653Srwatson  char e_type[2];
1551541Srgrimes  char e_sclass[1];
156130653Srwatson  char e_numaux[1];
157130653Srwatson};
1581541Srgrimes
159130653Srwatson
160130653Srwatson
1611541Srgrimes#define N_BTMASK	(017)
162130653Srwatson#define N_TMASK		(060)
1631541Srgrimes#define N_BTSHFT	(4)
164137671Sphk#define N_TSHIFT	(2)
1651541Srgrimes
1661541Srgrimes
167130796Srwatsonunion external_auxent {
1681541Srgrimes
169137671Sphk    struct {
1701541Srgrimes    	union {
171195134Sphk	    struct {
172195134Sphk		char x_lnno[4]; 	/* declaration line number */
173195134Sphk		char x_size[2]; 	/* str/union/array size */
174195134Sphk	    } x_lnsz;
175195134Sphk	    struct {
176195191Semaste		char x_lnnoptr[8];/* ptr to fcn line */
177195191Semaste		char x_fsize[4];	 /* size of function */
178195191Semaste		char x_endndx[4];	 /* entry ndx past block end */
179195191Semaste	    } x_fcn;
180195191Semaste 	} x_fcnary;
181195191Semaste    } x_sym;
182195191Semaste
183195191Semaste    union {
18441086Struckman	char x_fname[E_FILNMLEN];
185137671Sphk	struct {
186137671Sphk	    char x_zeroes[4];
18741086Struckman	    char x_offset[4];
18841086Struckman	    char          x_pad[6];
189104393Struckman	    unsigned char x_ftype[1];
190137671Sphk	    unsigned char x_resv[2];
1911541Srgrimes	} x_n;
19241086Struckman    } x_file;
193137671Sphk
194137671Sphk    struct {
19541086Struckman	char x_exptr[8];
1961541Srgrimes	char x_fsize[4];
197104393Struckman	char x_endndx[4];
198137671Sphk	char x_pad[1];
1991541Srgrimes    } x_except;
2001541Srgrimes
201130796Srwatson    struct {
202130480Srwatson	    unsigned char x_scnlen_lo[4];
203137671Sphk	    unsigned char x_parmhash[4];
204137671Sphk	    unsigned char x_snhash[2];
205137671Sphk	    unsigned char x_smtyp[1];
206167206Srwatson	    unsigned char x_smclas[1];
207167206Srwatson	    unsigned char x_scnlen_hi[4];
208167206Srwatson	    unsigned char x_pad[1];
209137671Sphk    } x_csect;
210137671Sphk
211137671Sphk    struct {
212218757Sbz	char x_pad[17];
213218757Sbz	char x_auxtype[1];
214178888Sjulian    } x_auxtype;
215218757Sbz};
216218757Sbz
217218757Sbz#define	SYMENT	struct external_syment
218137671Sphk#define	SYMESZ	18
219137671Sphk#define	AUXENT	union external_auxent
220218757Sbz#define	AUXESZ	18
221218757Sbz#define DBXMASK 0x80		/* for dbx storage mask */
222137671Sphk#define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
2231541Srgrimes
224171744Srwatson/* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h */
2251541Srgrimes#define _AUX_EXCEPT     255
2261541Srgrimes#define _AUX_FCN        254
2271549Srgrimes#define _AUX_SYM        253
228167206Srwatson#define _AUX_FILE       252
229167206Srwatson#define _AUX_CSECT      251
2301541Srgrimes
231109153Sdillon
232171744Srwatson
233137671Sphk/********************** RELOCATION DIRECTIVES **********************/
234137671Sphk
235172930Srwatson
236171744Srwatsonstruct external_reloc {
237145167Srwatson  char r_vaddr[8];
238145167Srwatson  char r_symndx[4];
239171744Srwatson  char r_size[1];
2401541Srgrimes  char r_type[1];
2411541Srgrimes};
2421549Srgrimes
243167206Srwatson
244167206Srwatson#define RELOC struct external_reloc
2451541Srgrimes#define RELSZ 14
246109153Sdillon
247171744Srwatson#define DEFAULT_DATA_SECTION_ALIGNMENT 4
248132554Srwatson#define DEFAULT_BSS_SECTION_ALIGNMENT 4
249171744Srwatson#define DEFAULT_TEXT_SECTION_ALIGNMENT 4
2501541Srgrimes/* For new sections we havn't heard of before */
2511541Srgrimes#define DEFAULT_SECTION_ALIGNMENT 4
25262425Schris