blob: fe4912d664034cd618e4550e4a2fc57d824cdfad [file] [log] [blame]
Clinton Popetz7f6d05e2000-04-26 15:09:44 +00001/* IBM RS/6000 "XCOFF64" file definitions for BFD.
Alan Modrad87bef32023-01-01 16:38:42 +10302 Copyright (C) 2000-2023 Free Software Foundation, Inc.
Clinton Popetz7f6d05e2000-04-26 15:09:44 +00003
Nick Clifton4f1d9bd2001-03-14 02:27:44 +00004 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
Nick Cliftone4e42b42010-04-15 10:26:09 +00006 the Free Software Foundation; either version 3 of the License, or
Nick Clifton4f1d9bd2001-03-14 02:27:44 +00007 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
Nick Cliftone4e42b42010-04-15 10:26:09 +000016 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
17 MA 02110-1301, USA. */
Nick Clifton4f1d9bd2001-03-14 02:27:44 +000018
Tom Rix3dd657b2001-05-24 20:32:58 +000019/********************** FILE HEADER **********************/
20
Nick Cliftoneb1e0e82002-03-18 12:46:27 +000021struct external_filehdr
22{
23 char f_magic[2]; /* magic number */
24 char f_nscns[2]; /* number of sections */
25 char f_timdat[4]; /* time & date stamp */
26 char f_symptr[8]; /* file pointer to symtab */
27 char f_opthdr[2]; /* sizeof(optional hdr) */
28 char f_flags[2]; /* flags */
29 char f_nsyms[4]; /* number of symtab entries */
Tom Rix3dd657b2001-05-24 20:32:58 +000030};
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000031
Nick Cliftoneb1e0e82002-03-18 12:46:27 +000032/* IBM RS/6000. */
33#define U803XTOCMAGIC 0757 /* Aix 4.3 64-bit XCOFF */
34#define U64_TOCMAGIC 0767 /* AIX 5+ 64-bit XCOFF */
35#define BADMAG(x) ((x).f_magic != U803XTOCMAGIC && (x).f_magic != U64_TOCMAGIC)
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000036
Tom Rix3dd657b2001-05-24 20:32:58 +000037#define FILHDR struct external_filehdr
38#define FILHSZ 24
39
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000040/********************** AOUT "OPTIONAL HEADER" **********************/
41
Clément Chigot1b2cb8e2021-03-11 11:08:19 +010042typedef struct
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000043{
Clément Chigot1b2cb8e2021-03-11 11:08:19 +010044 unsigned char magic[2]; /* type of file */
45 unsigned char vstamp[2]; /* version stamp */
46 unsigned char o_debugger[4]; /* reserved */
47 unsigned char text_start[8]; /* base of text used for this file */
48 unsigned char data_start[8]; /* base of data used for this file */
49 unsigned char o_toc[8]; /* address of TOC */
50 unsigned char o_snentry[2]; /* section number of entry point */
51 unsigned char o_sntext[2]; /* section number of .text section */
52 unsigned char o_sndata[2]; /* section number of .data section */
53 unsigned char o_sntoc[2]; /* section number of TOC */
54 unsigned char o_snloader[2]; /* section number of .loader section */
55 unsigned char o_snbss[2]; /* section number of .bss section */
56 unsigned char o_algntext[2]; /* .text alignment */
57 unsigned char o_algndata[2]; /* .data alignment */
58 unsigned char o_modtype[2]; /* module type (??) */
Tom Rix3dd657b2001-05-24 20:32:58 +000059 unsigned char o_cputype[2]; /* cpu type */
Clément Chigot1b2cb8e2021-03-11 11:08:19 +010060 unsigned char o_textpsize[1]; /* text page size */
61 unsigned char o_datapsize[1]; /* data page size */
62 unsigned char o_stackpsize[1]; /* stack page size */
63 unsigned char o_flags[1]; /* Flags and TLS alignment */
64 unsigned char tsize[8]; /* text size bytes, padded to FW bdry */
65 unsigned char dsize[8]; /* initialized data " " */
66 unsigned char bsize[8]; /* uninitialized data " " */
67 unsigned char entry[8]; /* entry pt. */
68 unsigned char o_maxstack[8]; /* max stack size (??) */
69 unsigned char o_maxdata[8]; /* max data size (??) */
70 unsigned char o_sntdata[2]; /* section number of .tdata section */
71 unsigned char o_sntbss[2]; /* section number of .tbss section */
72 unsigned char o_x64flags[2]; /* XCOFF64 flags */
73 unsigned char o_resv3[10]; /* reserved */
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000074}
75AOUTHDR;
76
Clinton Popetzc6664df2000-05-06 01:41:50 +000077#define AOUTSZ 120
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000078#define SMALL_AOUTSZ (0)
79#define AOUTHDRSZ 72
80
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000081/********************** SECTION HEADER **********************/
Tom Rix3dd657b2001-05-24 20:32:58 +000082
Nick Cliftoneb1e0e82002-03-18 12:46:27 +000083struct external_scnhdr
84{
85 char s_name[8]; /* section name */
86 char s_paddr[8]; /* physical address, aliased s_nlib */
87 char s_vaddr[8]; /* virtual address */
88 char s_size[8]; /* section size */
89 char s_scnptr[8]; /* file ptr to raw data for section */
90 char s_relptr[8]; /* file ptr to relocation */
91 char s_lnnoptr[8]; /* file ptr to line numbers */
92 char s_nreloc[4]; /* number of relocation entries */
93 char s_nlnno[4]; /* number of line number entries*/
94 char s_flags[4]; /* flags */
95 char s_pad[4]; /* padding */
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000096};
97
Clinton Popetz7f6d05e2000-04-26 15:09:44 +000098#define SCNHDR struct external_scnhdr
99
100#define SCNHSZ 72
101
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000102/********************** LINE NUMBERS **********************/
103
104/* 1 line number entry for every "breakpointable" source line in a section.
Nick Cliftoneb1e0e82002-03-18 12:46:27 +0000105 Line numbers are grouped on a per function basis; first entry in a function
106 grouping will have l_lnno = 0 and in place of physical address will be the
107 symbol table index of the function name. */
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000108
Nick Cliftoneb1e0e82002-03-18 12:46:27 +0000109struct external_lineno
110{
111 union
112 {
113 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
114 char l_paddr[8]; /* (physical) address of line number */
115 } l_addr;
116
117 char l_lnno[4]; /* line number */
118};
Tom Rix3dd657b2001-05-24 20:32:58 +0000119
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000120#define LINENO struct external_lineno
Tom Rix3dd657b2001-05-24 20:32:58 +0000121
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000122#define LINESZ 12
123
Tom Rix3dd657b2001-05-24 20:32:58 +0000124/********************** SYMBOLS **********************/
125
126#define E_SYMNMLEN 8 /* # characters in a symbol name */
127#define E_FILNMLEN 14 /* # characters in a file name */
128#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
129
130struct external_syment
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000131{
Tom Rix3dd657b2001-05-24 20:32:58 +0000132 char e_value[8];
133 char e_offset[4];
134 char e_scnum[2];
135 char e_type[2];
136 char e_sclass[1];
137 char e_numaux[1];
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000138};
139
Tom Rix3dd657b2001-05-24 20:32:58 +0000140#define N_BTMASK (017)
141#define N_TMASK (060)
142#define N_BTSHFT (4)
143#define N_TSHIFT (2)
Tom Rix3dd657b2001-05-24 20:32:58 +0000144
Nick Cliftoneb1e0e82002-03-18 12:46:27 +0000145union external_auxent
146{
Cl?ment Chigotb11b2962021-04-22 12:28:50 +0100147 struct {
148 char x_lnno[4]; /* declaration line number */
149 char x_pad[13];
150 char x_auxtype[1];
151 } x_sym;
Tom Rix3dd657b2001-05-24 20:32:58 +0000152
Cl?ment Chigotb11b2962021-04-22 12:28:50 +0100153 struct {
154 char x_lnnoptr[8];/* ptr to fcn line */
155 char x_fsize[4]; /* size of function */
156 char x_endndx[4]; /* entry ndx past block end */
157 char x_pad[1];
158 char x_auxtype[1];
159 } x_fcn;
Tom Rix3dd657b2001-05-24 20:32:58 +0000160
Cl?ment Chigotb11b2962021-04-22 12:28:50 +0100161 struct {
162 union {
163 char x_fname[E_FILNMLEN];
164 struct {
165 char x_zeroes[4];
166 char x_offset[4];
167 char x_pad[6];
168 } x_n;
169 } x_n;
170 unsigned char x_ftype[1];
171 unsigned char x_resv[2];
172 char x_auxtype[1];
173 } x_file;
Tom Rix3dd657b2001-05-24 20:32:58 +0000174
Cl?ment Chigotb11b2962021-04-22 12:28:50 +0100175 struct {
176 char x_exptr[8];
177 char x_fsize[4];
178 char x_endndx[4];
179 char x_pad[1];
180 char x_auxtype[1];
181 } x_except;
182
183 struct {
184 char x_scnlen_lo[4];
185 char x_parmhash[4];
186 char x_snhash[2];
187 char x_smtyp[1];
188 char x_smclas[1];
189 char x_scnlen_hi[4];
190 char x_pad[1];
191 char x_auxtype[1];
192 } x_csect;
193
194 struct {
195 char x_scnlen[8];
196 char x_nreloc[8];
197 char x_pad[1];
198 char x_auxtype[1];
199 } x_sect;
Tom Rix3dd657b2001-05-24 20:32:58 +0000200};
201
202#define SYMENT struct external_syment
203#define SYMESZ 18
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000204#define AUXENT union external_auxent
205#define AUXESZ 18
206#define DBXMASK 0x80 /* for dbx storage mask */
207#define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
208
Nick Cliftoneb1e0e82002-03-18 12:46:27 +0000209/* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h. */
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000210#define _AUX_EXCEPT 255
211#define _AUX_FCN 254
212#define _AUX_SYM 253
213#define _AUX_FILE 252
214#define _AUX_CSECT 251
Cl?ment Chigotb11b2962021-04-22 12:28:50 +0100215#define _AUX_SECT 250
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000216
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000217/********************** RELOCATION DIRECTIVES **********************/
218
Nick Cliftoneb1e0e82002-03-18 12:46:27 +0000219struct external_reloc
220{
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000221 char r_vaddr[8];
222 char r_symndx[4];
223 char r_size[1];
224 char r_type[1];
225};
226
Clinton Popetz7f6d05e2000-04-26 15:09:44 +0000227#define RELOC struct external_reloc
228#define RELSZ 14
229
230#define DEFAULT_DATA_SECTION_ALIGNMENT 4
231#define DEFAULT_BSS_SECTION_ALIGNMENT 4
232#define DEFAULT_TEXT_SECTION_ALIGNMENT 4
233/* For new sections we havn't heard of before */
234#define DEFAULT_SECTION_ALIGNMENT 4
Tom Rix3dd657b2001-05-24 20:32:58 +0000235
236/* The ldhdr structure. This appears at the start of the .loader
237 section. */
238
239struct external_ldhdr
240{
241 bfd_byte l_version[4];
242 bfd_byte l_nsyms[4];
243 bfd_byte l_nreloc[4];
244 bfd_byte l_istlen[4];
245 bfd_byte l_nimpid[4];
246 bfd_byte l_stlen[4];
247 bfd_byte l_impoff[8];
248 bfd_byte l_stoff[8];
249 bfd_byte l_symoff[8];
250 bfd_byte l_rldoff[8];
251};
252#define LDHDRSZ (56)
253
254struct external_ldsym
255{
256 bfd_byte l_value[8];
257 bfd_byte l_offset[4];
258 bfd_byte l_scnum[2];
259 bfd_byte l_smtype[1];
260 bfd_byte l_smclas[1];
261 bfd_byte l_ifile[4];
262 bfd_byte l_parm[4];
263};
264
265#define LDSYMSZ (24)
266
267struct external_ldrel
268{
269 bfd_byte l_vaddr[8];
270 bfd_byte l_rtype[2];
271 bfd_byte l_rsecnm[2];
272 bfd_byte l_symndx[4];
273};
274
275#define LDRELSZ (16)
Tristan Gingold8cfbb632011-05-04 06:53:38 +0000276
277struct external_exceptab
278{
279 union {
280 bfd_byte e_symndx[4];
281 bfd_byte e_paddr[8];
282 } e_addr;
283 bfd_byte e_lang[1];
284 bfd_byte e_reason[1];
285};
286
287#define EXCEPTSZ (10)