]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* Internal format of COFF object file data structures, for GNU BFD. |
4f1d9bd8 | 2 | This file is part of BFD, the Binary File Descriptor library. |
61e2488c | 3 | |
d87bef3a | 4 | Copyright (C) 1999-2023 Free Software Foundation, Inc. |
4f1d9bd8 NC |
5 | |
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
e4e42b45 | 8 | the Free Software Foundation; either version 3 of the License, or |
4f1d9bd8 | 9 | (at your option) any later version. |
61e2488c | 10 | |
4f1d9bd8 NC |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
61e2488c | 15 | |
4f1d9bd8 NC |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | |
e4e42b45 NC |
18 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
19 | MA 02110-1301, USA. */ | |
252b5132 RH |
20 | |
21 | #ifndef GNU_COFF_INTERNAL_H | |
22 | #define GNU_COFF_INTERNAL_H 1 | |
23 | ||
24 | /* First, make "signed char" work, even on old compilers. */ | |
25 | #ifndef signed | |
26 | #ifndef __STDC__ | |
27 | #define signed /**/ | |
28 | #endif | |
29 | #endif | |
30 | ||
31 | /********************** FILE HEADER **********************/ | |
32 | ||
33 | /* extra stuff in a PE header. */ | |
34 | ||
35 | struct internal_extra_pe_filehdr | |
36 | { | |
37 | /* DOS header data follows for PE stuff */ | |
38 | unsigned short e_magic; /* Magic number, 0x5a4d */ | |
39 | unsigned short e_cblp; /* Bytes on last page of file, 0x90 */ | |
40 | unsigned short e_cp; /* Pages in file, 0x3 */ | |
41 | unsigned short e_crlc; /* Relocations, 0x0 */ | |
42 | unsigned short e_cparhdr; /* Size of header in paragraphs, 0x4 */ | |
43 | unsigned short e_minalloc; /* Minimum extra paragraphs needed, 0x0 */ | |
44 | unsigned short e_maxalloc; /* Maximum extra paragraphs needed, 0xFFFF */ | |
45 | unsigned short e_ss; /* Initial (relative) SS value, 0x0 */ | |
46 | unsigned short e_sp; /* Initial SP value, 0xb8 */ | |
47 | unsigned short e_csum; /* Checksum, 0x0 */ | |
48 | unsigned short e_ip; /* Initial IP value, 0x0 */ | |
49 | unsigned short e_cs; /* Initial (relative) CS value, 0x0 */ | |
50 | unsigned short e_lfarlc; /* File address of relocation table, 0x40 */ | |
51 | unsigned short e_ovno; /* Overlay number, 0x0 */ | |
52 | unsigned short e_res[4]; /* Reserved words, all 0x0 */ | |
53 | unsigned short e_oemid; /* OEM identifier (for e_oeminfo), 0x0 */ | |
54 | unsigned short e_oeminfo; /* OEM information; e_oemid specific, 0x0 */ | |
55 | unsigned short e_res2[10]; /* Reserved words, all 0x0 */ | |
56 | bfd_vma e_lfanew; /* File address of new exe header, 0x80 */ | |
2f1575ea | 57 | unsigned int dos_message[16]; /* Text which always follows DOS header. */ |
61e2488c | 58 | bfd_vma nt_signature; /* required NT signature, 0x4550 */ |
252b5132 RH |
59 | }; |
60 | ||
61 | struct internal_filehdr | |
62 | { | |
63 | struct internal_extra_pe_filehdr pe; | |
64 | ||
4f1d9bd8 | 65 | /* Standard coff internal info. */ |
252b5132 | 66 | unsigned short f_magic; /* magic number */ |
167ad85b | 67 | unsigned int f_nscns; /* number of sections */ |
252b5132 RH |
68 | long f_timdat; /* time & date stamp */ |
69 | bfd_vma f_symptr; /* file pointer to symtab */ | |
70 | long f_nsyms; /* number of symtab entries */ | |
71 | unsigned short f_opthdr; /* sizeof(optional hdr) */ | |
72 | unsigned short f_flags; /* flags */ | |
81635ce4 | 73 | unsigned short f_target_id; /* (TI COFF specific) */ |
252b5132 RH |
74 | }; |
75 | ||
76 | ||
77 | /* Bits for f_flags: | |
4f1d9bd8 NC |
78 | F_RELFLG relocation info stripped from file |
79 | F_EXEC file is executable (no unresolved external references) | |
80 | F_LNNO line numbers stripped from file | |
81 | F_LSYMS local symbols stripped from file | |
82 | F_AR16WR file is 16-bit little-endian | |
83 | F_AR32WR file is 32-bit little-endian | |
84 | F_AR32W file is 32-bit big-endian | |
85 | F_DYNLOAD rs/6000 aix: dynamically loadable w/imports & exports | |
86 | F_SHROBJ rs/6000 aix: file is a shared object | |
4d095f5b | 87 | F_DLL PE format DLL */ |
252b5132 RH |
88 | |
89 | #define F_RELFLG (0x0001) | |
90 | #define F_EXEC (0x0002) | |
91 | #define F_LNNO (0x0004) | |
92 | #define F_LSYMS (0x0008) | |
93 | #define F_AR16WR (0x0080) | |
94 | #define F_AR32WR (0x0100) | |
95 | #define F_AR32W (0x0200) | |
96 | #define F_DYNLOAD (0x1000) | |
97 | #define F_SHROBJ (0x2000) | |
98 | #define F_DLL (0x2000) | |
99 | ||
4f1d9bd8 | 100 | /* Extra structure which is used in the optional header. */ |
61e2488c | 101 | typedef struct _IMAGE_DATA_DIRECTORY |
252b5132 RH |
102 | { |
103 | bfd_vma VirtualAddress; | |
104 | long Size; | |
105 | } IMAGE_DATA_DIRECTORY; | |
6c73cbb1 NC |
106 | #define PE_EXPORT_TABLE 0 |
107 | #define PE_IMPORT_TABLE 1 | |
108 | #define PE_RESOURCE_TABLE 2 | |
109 | #define PE_EXCEPTION_TABLE 3 | |
110 | #define PE_CERTIFICATE_TABLE 4 | |
111 | #define PE_BASE_RELOCATION_TABLE 5 | |
112 | #define PE_DEBUG_DATA 6 | |
113 | #define PE_ARCHITECTURE 7 | |
114 | #define PE_GLOBAL_PTR 8 | |
115 | #define PE_TLS_TABLE 9 | |
116 | #define PE_LOAD_CONFIG_TABLE 10 | |
117 | #define PE_BOUND_IMPORT_TABLE 11 | |
118 | #define PE_IMPORT_ADDRESS_TABLE 12 | |
119 | #define PE_DELAY_IMPORT_DESCRIPTOR 13 | |
120 | #define PE_CLR_RUNTIME_HEADER 14 | |
121 | /* DataDirectory[15] is currently reserved, so no define. */ | |
252b5132 RH |
122 | #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 |
123 | ||
61e2488c JT |
124 | /* Extra structure used in debug directory. */ |
125 | struct internal_IMAGE_DEBUG_DIRECTORY | |
126 | { | |
127 | unsigned long Characteristics; | |
128 | unsigned long TimeDateStamp; | |
129 | unsigned short MajorVersion; | |
130 | unsigned short MinorVersion; | |
131 | unsigned long Type; | |
132 | unsigned long SizeOfData; | |
133 | unsigned long AddressOfRawData; | |
134 | unsigned long PointerToRawData; | |
135 | }; | |
136 | ||
137 | #define PE_IMAGE_DEBUG_TYPE_UNKNOWN 0 | |
138 | #define PE_IMAGE_DEBUG_TYPE_COFF 1 | |
139 | #define PE_IMAGE_DEBUG_TYPE_CODEVIEW 2 | |
140 | #define PE_IMAGE_DEBUG_TYPE_FPO 3 | |
141 | #define PE_IMAGE_DEBUG_TYPE_MISC 4 | |
142 | #define PE_IMAGE_DEBUG_TYPE_EXCEPTION 5 | |
143 | #define PE_IMAGE_DEBUG_TYPE_FIXUP 6 | |
144 | #define PE_IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7 | |
145 | #define PE_IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8 | |
146 | #define PE_IMAGE_DEBUG_TYPE_BORLAND 9 | |
147 | #define PE_IMAGE_DEBUG_TYPE_RESERVED10 10 | |
148 | #define PE_IMAGE_DEBUG_TYPE_CLSID 11 | |
1957ab10 JT |
149 | #define PE_IMAGE_DEBUG_TYPE_VC_FEATURE 12 |
150 | #define PE_IMAGE_DEBUG_TYPE_POGO 13 | |
151 | #define PE_IMAGE_DEBUG_TYPE_ILTCG 14 | |
152 | #define PE_IMAGE_DEBUG_TYPE_MPX 15 | |
153 | #define PE_IMAGE_DEBUG_TYPE_REPRO 16 | |
61e2488c JT |
154 | |
155 | /* Extra structure for a codeview debug record */ | |
156 | #define CV_INFO_SIGNATURE_LENGTH 16 | |
157 | ||
158 | typedef struct _CODEVIEW_INFO | |
159 | { | |
160 | unsigned long CVSignature; | |
161 | char Signature[CV_INFO_SIGNATURE_LENGTH]; | |
162 | unsigned int SignatureLength; | |
163 | unsigned long Age; | |
279edac5 | 164 | /* char PdbFileName[]; */ |
61e2488c JT |
165 | } CODEVIEW_INFO; |
166 | ||
c6e94b27 | 167 | /* Default image base for NT. */ |
252b5132 RH |
168 | #define NT_EXE_IMAGE_BASE 0x400000 |
169 | #define NT_DLL_IMAGE_BASE 0x10000000 | |
170 | ||
c6e94b27 RH |
171 | /* Default image base for BeOS. */ |
172 | #define BEOS_EXE_IMAGE_BASE 0x80000000 | |
173 | #define BEOS_DLL_IMAGE_BASE 0x10000000 | |
174 | ||
252b5132 RH |
175 | /* Extra stuff in a PE aouthdr */ |
176 | ||
177 | #define PE_DEF_SECTION_ALIGNMENT 0x1000 | |
63fa1674 JW |
178 | #ifndef PE_DEF_FILE_ALIGNMENT |
179 | # define PE_DEF_FILE_ALIGNMENT 0x200 | |
180 | #endif | |
252b5132 | 181 | |
61e2488c | 182 | struct internal_extra_pe_aouthdr |
252b5132 | 183 | { |
d13c9dc6 L |
184 | /* FIXME: The following entries are in AOUTHDR. But they aren't |
185 | available internally in bfd. We add them here so that objdump | |
186 | can dump them. */ | |
61e2488c | 187 | /* The state of the image file. */ |
d13c9dc6 | 188 | short Magic; |
61e2488c | 189 | /* Linker major version number. */ |
d13c9dc6 | 190 | char MajorLinkerVersion; |
61e2488c | 191 | /* Linker minor version number. */ |
d13c9dc6 | 192 | char MinorLinkerVersion; |
61e2488c | 193 | /* Total size of all code sections. */ |
b24cc414 | 194 | bfd_vma SizeOfCode; |
61e2488c | 195 | /* Total size of all initialized data sections. */ |
b24cc414 | 196 | bfd_vma SizeOfInitializedData; |
61e2488c | 197 | /* Total size of all uninitialized data sections. */ |
b24cc414 | 198 | bfd_vma SizeOfUninitializedData; |
d13c9dc6 L |
199 | /* Address of entry point relative to image base. */ |
200 | bfd_vma AddressOfEntryPoint; | |
201 | /* Address of the first code section relative to image base. */ | |
202 | bfd_vma BaseOfCode; | |
203 | /* Address of the first data section relative to image base. */ | |
204 | bfd_vma BaseOfData; | |
61e2488c | 205 | |
252b5132 | 206 | /* PE stuff */ |
61e2488c | 207 | bfd_vma ImageBase; /* Address of specific location in memory that |
b24cc414 AM |
208 | file is located, NT default 0x10000. */ |
209 | ||
210 | uint32_t SectionAlignment; /* Section alignment default 0x1000. */ | |
211 | uint32_t FileAlignment; /* File alignment default 0x200. */ | |
212 | short MajorOperatingSystemVersion; /* Minimum version of the operating. */ | |
213 | short MinorOperatingSystemVersion; /* System req'd for exe, default 1. */ | |
214 | short MajorImageVersion; /* User defineable field to store version of */ | |
215 | short MinorImageVersion; /* exe or dll being created, default to 0. */ | |
216 | short MajorSubsystemVersion; /* Minimum subsystem version required to */ | |
217 | short MinorSubsystemVersion; /* run exe; default to 3.1. */ | |
218 | uint32_t Reserved1; /* Seems to be 0. */ | |
219 | uint32_t SizeOfImage; /* Size of memory to allocate for prog. */ | |
220 | uint32_t SizeOfHeaders; /* Size of PE header and section table. */ | |
221 | uint32_t CheckSum; /* Set to 0. */ | |
222 | short Subsystem; | |
252b5132 | 223 | |
61e2488c | 224 | /* Type of subsystem exe uses for user interface, |
252b5132 RH |
225 | possible values: |
226 | 1 - NATIVE Doesn't require a subsystem | |
227 | 2 - WINDOWS_GUI runs in Windows GUI subsystem | |
228 | 3 - WINDOWS_CUI runs in Windows char sub. (console app) | |
229 | 5 - OS2_CUI runs in OS/2 character subsystem | |
61e2488c JT |
230 | 7 - POSIX_CUI runs in Posix character subsystem. */ |
231 | unsigned short DllCharacteristics; /* flags for DLL init. */ | |
232 | bfd_vma SizeOfStackReserve; /* Amount of memory to reserve. */ | |
233 | bfd_vma SizeOfStackCommit; /* Amount of memory initially committed for | |
b24cc414 | 234 | initial thread's stack, default 0x1000. */ |
61e2488c JT |
235 | bfd_vma SizeOfHeapReserve; /* Amount of virtual memory to reserve and */ |
236 | bfd_vma SizeOfHeapCommit; /* commit, don't know what to defaut it to. */ | |
b24cc414 AM |
237 | uint32_t LoaderFlags; /* Can probably set to 0. */ |
238 | uint32_t NumberOfRvaAndSizes; /* Number of entries in next entry, 16. */ | |
252b5132 RH |
239 | IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; |
240 | }; | |
241 | ||
242 | /********************** AOUT "OPTIONAL HEADER" **********************/ | |
243 | struct internal_aouthdr | |
244 | { | |
245 | short magic; /* type of file */ | |
246 | short vstamp; /* version stamp */ | |
247 | bfd_vma tsize; /* text size in bytes, padded to FW bdry*/ | |
248 | bfd_vma dsize; /* initialized data " " */ | |
249 | bfd_vma bsize; /* uninitialized data " " */ | |
250 | bfd_vma entry; /* entry pt. */ | |
251 | bfd_vma text_start; /* base of text used for this file */ | |
252 | bfd_vma data_start; /* base of data used for this file */ | |
253 | ||
252b5132 | 254 | /* RS/6000 stuff */ |
3dd657b1 | 255 | bfd_vma o_toc; /* address of TOC */ |
252b5132 RH |
256 | short o_snentry; /* section number for entry point */ |
257 | short o_sntext; /* section number for text */ | |
258 | short o_sndata; /* section number for data */ | |
259 | short o_sntoc; /* section number for toc */ | |
260 | short o_snloader; /* section number for loader section */ | |
261 | short o_snbss; /* section number for bss */ | |
262 | short o_algntext; /* max alignment for text */ | |
263 | short o_algndata; /* max alignment for data */ | |
264 | short o_modtype; /* Module type field, 1R,RE,RO */ | |
265 | short o_cputype; /* Encoded CPU type */ | |
1b2cb8e2 CC |
266 | bfd_vma o_maxstack; /* max stack size allowed. */ |
267 | bfd_vma o_maxdata; /* max data size allowed. */ | |
268 | char o_flags; /* Flags and TLS alignment */ | |
269 | short o_sntdata; /* section number for tdata */ | |
270 | short o_sntbss; /* section number for tbss */ | |
271 | short o_x64flags; /* XCOFF64 flags */ | |
272 | ||
252b5132 RH |
273 | |
274 | /* ECOFF stuff */ | |
275 | bfd_vma bss_start; /* Base of bss section. */ | |
276 | bfd_vma gp_value; /* GP register value. */ | |
277 | unsigned long gprmask; /* General registers used. */ | |
278 | unsigned long cprmask[4]; /* Coprocessor registers used. */ | |
279 | unsigned long fprmask; /* Floating pointer registers used. */ | |
280 | ||
281 | /* Apollo stuff */ | |
282 | long o_inlib; /* inlib data */ | |
283 | long o_sri; /* Static Resource Information */ | |
284 | long vid[2]; /* Version id */ | |
285 | ||
252b5132 | 286 | struct internal_extra_pe_aouthdr pe; |
252b5132 RH |
287 | }; |
288 | ||
289 | /********************** STORAGE CLASSES **********************/ | |
290 | ||
291 | /* This used to be defined as -1, but now n_sclass is unsigned. */ | |
292 | #define C_EFCN 0xff /* physical end of function */ | |
293 | #define C_NULL 0 | |
294 | #define C_AUTO 1 /* automatic variable */ | |
295 | #define C_EXT 2 /* external symbol */ | |
296 | #define C_STAT 3 /* static */ | |
297 | #define C_REG 4 /* register variable */ | |
298 | #define C_EXTDEF 5 /* external definition */ | |
299 | #define C_LABEL 6 /* label */ | |
300 | #define C_ULABEL 7 /* undefined label */ | |
301 | #define C_MOS 8 /* member of structure */ | |
302 | #define C_ARG 9 /* function argument */ | |
303 | #define C_STRTAG 10 /* structure tag */ | |
304 | #define C_MOU 11 /* member of union */ | |
305 | #define C_UNTAG 12 /* union tag */ | |
306 | #define C_TPDEF 13 /* type definition */ | |
307 | #define C_USTATIC 14 /* undefined static */ | |
308 | #define C_ENTAG 15 /* enumeration tag */ | |
309 | #define C_MOE 16 /* member of enumeration */ | |
310 | #define C_REGPARM 17 /* register parameter */ | |
311 | #define C_FIELD 18 /* bit field */ | |
312 | #define C_AUTOARG 19 /* auto argument */ | |
313 | #define C_LASTENT 20 /* dummy entry (end of block) */ | |
314 | #define C_BLOCK 100 /* ".bb" or ".eb" */ | |
315 | #define C_FCN 101 /* ".bf" or ".ef" */ | |
316 | #define C_EOS 102 /* end of structure */ | |
317 | #define C_FILE 103 /* file name */ | |
318 | #define C_LINE 104 /* line # reformatted as symbol table entry */ | |
319 | #define C_ALIAS 105 /* duplicate tag */ | |
320 | #define C_HIDDEN 106 /* ext symbol in dmert public lib */ | |
5f190081 | 321 | #define C_WEAKEXT 127 /* weak symbol -- GNU extension. */ |
252b5132 | 322 | |
81635ce4 | 323 | /* New storage classes for TI COFF */ |
252b5132 RH |
324 | #define C_UEXT 19 /* Tentative external definition */ |
325 | #define C_STATLAB 20 /* Static load time label */ | |
326 | #define C_EXTLAB 21 /* External load time label */ | |
327 | #define C_SYSTEM 23 /* System Wide variable */ | |
328 | ||
329 | /* New storage classes for WINDOWS_NT */ | |
330 | #define C_SECTION 104 /* section name */ | |
331 | #define C_NT_WEAK 105 /* weak external */ | |
332 | ||
333 | /* New storage classes for 80960 */ | |
334 | ||
335 | /* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */ | |
336 | #define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */ | |
337 | ||
338 | #define C_SCALL 107 /* Procedure reachable via system call */ | |
339 | #define C_LEAFEXT 108 /* External leaf */ | |
340 | #define C_LEAFSTAT 113 /* Static leaf */ | |
341 | #define C_OPTVAR 109 /* Optimized variable */ | |
342 | #define C_DEFINE 110 /* Preprocessor #define */ | |
343 | #define C_PRAGMA 111 /* Advice to compiler or linker */ | |
344 | #define C_SEGMENT 112 /* 80960 segment name */ | |
345 | ||
252b5132 RH |
346 | /* New storage classes for RS/6000 */ |
347 | #define C_HIDEXT 107 /* Un-named external symbol */ | |
348 | #define C_BINCL 108 /* Marks beginning of include file */ | |
349 | #define C_EINCL 109 /* Marks ending of include file */ | |
8602d4fe | 350 | #define C_AIX_WEAKEXT 111 /* AIX definition of C_WEAKEXT. */ |
97834047 | 351 | #define C_DWARF 112 /* DWARF symbol */ |
8602d4fe | 352 | |
53dd76d3 TG |
353 | #define C_NULL_VALUE 0x00de1e00 /* Value for a C_NULL deleted entry. */ |
354 | ||
8602d4fe RS |
355 | #if defined _AIX52 || defined AIX_WEAK_SUPPORT |
356 | #undef C_WEAKEXT | |
357 | #define C_WEAKEXT C_AIX_WEAKEXT | |
358 | #endif | |
252b5132 RH |
359 | |
360 | /* storage classes for stab symbols for RS/6000 */ | |
361 | #define C_GSYM (0x80) | |
362 | #define C_LSYM (0x81) | |
363 | #define C_PSYM (0x82) | |
364 | #define C_RSYM (0x83) | |
365 | #define C_RPSYM (0x84) | |
366 | #define C_STSYM (0x85) | |
367 | #define C_TCSYM (0x86) | |
368 | #define C_BCOMM (0x87) | |
369 | #define C_ECOML (0x88) | |
370 | #define C_ECOMM (0x89) | |
371 | #define C_DECL (0x8c) | |
372 | #define C_ENTRY (0x8d) | |
373 | #define C_FUN (0x8e) | |
374 | #define C_BSTAT (0x8f) | |
375 | #define C_ESTAT (0x90) | |
9d3056cd TG |
376 | #define C_GTLS (0x97) |
377 | #define C_STTLS (0x98) | |
252b5132 RH |
378 | |
379 | /* Storage classes for Thumb symbols */ | |
380 | #define C_THUMBEXT (128 + C_EXT) /* 130 */ | |
381 | #define C_THUMBSTAT (128 + C_STAT) /* 131 */ | |
382 | #define C_THUMBLABEL (128 + C_LABEL) /* 134 */ | |
383 | #define C_THUMBEXTFUNC (C_THUMBEXT + 20) /* 150 */ | |
384 | #define C_THUMBSTATFUNC (C_THUMBSTAT + 20) /* 151 */ | |
385 | ||
f9a6a8f0 | 386 | /* True if XCOFF symbols of class CLASS have auxiliary csect information. */ |
8602d4fe RS |
387 | #define CSECT_SYM_P(CLASS) \ |
388 | ((CLASS) == C_EXT || (CLASS) == C_AIX_WEAKEXT || (CLASS) == C_HIDEXT) | |
389 | ||
252b5132 RH |
390 | /********************** SECTION HEADER **********************/ |
391 | ||
392 | #define SCNNMLEN (8) | |
393 | ||
394 | struct internal_scnhdr | |
395 | { | |
602f1657 | 396 | char s_name[SCNNMLEN] ATTRIBUTE_NONSTRING; /* section name */ |
252b5132 RH |
397 | |
398 | /* Physical address, aliased s_nlib. | |
399 | In the pei format, this field is the virtual section size | |
400 | (the size of the section after being loaded int memory), | |
401 | NOT the physical address. */ | |
402 | bfd_vma s_paddr; | |
403 | ||
404 | bfd_vma s_vaddr; /* virtual address */ | |
405 | bfd_vma s_size; /* section size */ | |
406 | bfd_vma s_scnptr; /* file ptr to raw data for section */ | |
407 | bfd_vma s_relptr; /* file ptr to relocation */ | |
408 | bfd_vma s_lnnoptr; /* file ptr to line numbers */ | |
409 | unsigned long s_nreloc; /* number of relocation entries */ | |
410 | unsigned long s_nlnno; /* number of line number entries*/ | |
6f8f6017 | 411 | unsigned long s_flags; /* flags */ |
b9af77f5 | 412 | unsigned char s_page; /* TI COFF load page */ |
252b5132 RH |
413 | }; |
414 | ||
4f1d9bd8 | 415 | /* s_flags "type". */ |
252b5132 RH |
416 | #define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */ |
417 | #define STYP_DSECT (0x0001) /* "dummy": relocated only*/ | |
418 | #define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */ | |
419 | #define STYP_GROUP (0x0004) /* "grouped": formed of input sections */ | |
420 | #define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */ | |
421 | #define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated, | |
422 | loaded; reloc & lineno entries processed normally */ | |
423 | #define STYP_TEXT (0x0020) /* section contains text only */ | |
424 | #define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile | |
425 | will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will | |
426 | update all process invocations. */ | |
427 | #define STYP_DATA (0x0040) /* section contains data only */ | |
428 | #define STYP_BSS (0x0080) /* section contains bss only */ | |
429 | #define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */ | |
430 | #define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */ | |
431 | #define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */ | |
432 | #define STYP_LIB (0x0800) /* for .lib: same as INFO */ | |
433 | #define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */ | |
4f1d9bd8 NC |
434 | #define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions |
435 | wherever padding is necessary and there is a | |
436 | word of contiguous bytes beginning on a word | |
437 | boundary. */ | |
252b5132 RH |
438 | |
439 | #define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */ | |
440 | ||
441 | ||
252b5132 RH |
442 | /********************** LINE NUMBERS **********************/ |
443 | ||
444 | /* 1 line number entry for every "breakpointable" source line in a section. | |
4f1d9bd8 NC |
445 | Line numbers are grouped on a per function basis; first entry in a function |
446 | grouping will have l_lnno = 0 and in place of physical address will be the | |
447 | symbol table index of the function name. */ | |
252b5132 RH |
448 | |
449 | struct internal_lineno | |
450 | { | |
451 | union | |
452 | { | |
3dd657b1 TR |
453 | bfd_signed_vma l_symndx; /* function name symbol index, iff l_lnno == 0*/ |
454 | bfd_signed_vma l_paddr; /* (physical) address of line number */ | |
252b5132 RH |
455 | } l_addr; |
456 | unsigned long l_lnno; /* line number */ | |
457 | }; | |
458 | ||
459 | /********************** SYMBOLS **********************/ | |
460 | ||
461 | #define SYMNMLEN 8 /* # characters in a symbol name */ | |
462 | #define FILNMLEN 14 /* # characters in a file name */ | |
463 | #define DIMNUM 4 /* # array dimensions in auxiliary entry */ | |
464 | ||
465 | struct internal_syment | |
466 | { | |
467 | union | |
468 | { | |
602f1657 | 469 | char _n_name[SYMNMLEN] ATTRIBUTE_NONSTRING; /* old COFF version */ |
252b5132 RH |
470 | struct |
471 | { | |
60159858 AM |
472 | uintptr_t _n_zeroes; /* new == 0 */ |
473 | uintptr_t _n_offset; /* offset into string table */ | |
252b5132 RH |
474 | } _n_n; |
475 | char *_n_nptr[2]; /* allows for overlaying */ | |
476 | } _n; | |
d2df793a | 477 | bfd_vma n_value; /* value of symbol */ |
9ae678af | 478 | int n_scnum; /* section number */ |
252b5132 RH |
479 | unsigned short n_flags; /* copy of flags from filhdr */ |
480 | unsigned short n_type; /* type and derived type */ | |
481 | unsigned char n_sclass; /* storage class */ | |
482 | unsigned char n_numaux; /* number of aux. entries */ | |
483 | }; | |
484 | ||
485 | #define n_name _n._n_name | |
486 | #define n_zeroes _n._n_n._n_zeroes | |
487 | #define n_offset _n._n_n._n_offset | |
488 | ||
252b5132 | 489 | /* Relocatable symbols have number of the section in which they are defined, |
4f1d9bd8 | 490 | or one of the following: */ |
252b5132 | 491 | |
9ae678af NC |
492 | #define N_UNDEF ((int)0) /* undefined symbol */ |
493 | #define N_ABS ((int)-1) /* value of symbol is absolute */ | |
494 | #define N_DEBUG ((int)-2) /* debugging symbol -- value is meaningless */ | |
495 | #define N_TV ((int)-3) /* indicates symbol needs preload transfer vector */ | |
496 | #define P_TV ((int)-4) /* indicates symbol needs postload transfer vector*/ | |
252b5132 | 497 | |
4f1d9bd8 NC |
498 | /* Type of a symbol, in low N bits of the word. */ |
499 | ||
252b5132 RH |
500 | #define T_NULL 0 |
501 | #define T_VOID 1 /* function argument (only used by compiler) */ | |
502 | #define T_CHAR 2 /* character */ | |
503 | #define T_SHORT 3 /* short integer */ | |
504 | #define T_INT 4 /* integer */ | |
505 | #define T_LONG 5 /* long integer */ | |
506 | #define T_FLOAT 6 /* floating point */ | |
507 | #define T_DOUBLE 7 /* double word */ | |
508 | #define T_STRUCT 8 /* structure */ | |
509 | #define T_UNION 9 /* union */ | |
510 | #define T_ENUM 10 /* enumeration */ | |
511 | #define T_MOE 11 /* member of enumeration*/ | |
512 | #define T_UCHAR 12 /* unsigned character */ | |
513 | #define T_USHORT 13 /* unsigned short */ | |
514 | #define T_UINT 14 /* unsigned integer */ | |
515 | #define T_ULONG 15 /* unsigned long */ | |
516 | #define T_LNGDBL 16 /* long double */ | |
517 | ||
4f1d9bd8 NC |
518 | /* Derived types, in n_type. */ |
519 | ||
252b5132 RH |
520 | #define DT_NON (0) /* no derived type */ |
521 | #define DT_PTR (1) /* pointer */ | |
522 | #define DT_FCN (2) /* function */ | |
523 | #define DT_ARY (3) /* array */ | |
524 | ||
525 | #define BTYPE(x) ((x) & N_BTMASK) | |
25bcc51d | 526 | #define DTYPE(x) (((x) & N_TMASK) >> N_BTSHFT) |
252b5132 RH |
527 | |
528 | #define ISPTR(x) \ | |
529 | (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_PTR << N_BTSHFT)) | |
530 | #define ISFCN(x) \ | |
531 | (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_FCN << N_BTSHFT)) | |
532 | #define ISARY(x) \ | |
533 | (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_ARY << N_BTSHFT)) | |
534 | #define ISTAG(x) \ | |
535 | ((x) == C_STRTAG || (x) == C_UNTAG || (x) == C_ENTAG) | |
536 | #define DECREF(x) \ | |
537 | ((((x) >> N_TSHIFT) & ~ N_BTMASK) | ((x) & N_BTMASK)) | |
538 | ||
add588a8 CC |
539 | /* Visibility flag, in XCOFF n_type. */ |
540 | #define SYM_V_INTERNAL 0x1000 | |
541 | #define SYM_V_HIDDEN 0x2000 | |
542 | #define SYM_V_PROTECTED 0x3000 | |
543 | #define SYM_V_EXPORTED 0x4000 | |
544 | #define SYM_V_MASK 0xF000 | |
545 | ||
252b5132 RH |
546 | union internal_auxent |
547 | { | |
548 | struct | |
549 | { | |
252b5132 RH |
550 | union |
551 | { | |
552 | long l; /* str, un, or enum tag indx */ | |
553 | struct coff_ptr_struct *p; | |
554 | } x_tagndx; | |
555 | ||
556 | union | |
557 | { | |
558 | struct | |
559 | { | |
560 | unsigned short x_lnno; /* declaration line number */ | |
561 | unsigned short x_size; /* str/union/array size */ | |
562 | } x_lnsz; | |
563 | long x_fsize; /* size of function */ | |
564 | } x_misc; | |
565 | ||
566 | union | |
567 | { | |
568 | struct | |
569 | { /* if ISFCN, tag, or .bb */ | |
3dd657b1 | 570 | bfd_signed_vma x_lnnoptr; /* ptr to fcn line # */ |
252b5132 RH |
571 | union |
572 | { /* entry ndx past block end */ | |
573 | long l; | |
574 | struct coff_ptr_struct *p; | |
575 | } x_endndx; | |
576 | } x_fcn; | |
577 | ||
578 | struct | |
579 | { /* if ISARY, up to 4 dimen. */ | |
580 | unsigned short x_dimen[DIMNUM]; | |
581 | } x_ary; | |
582 | } x_fcnary; | |
583 | ||
584 | unsigned short x_tvndx; /* tv index */ | |
585 | } x_sym; | |
586 | ||
e86fc4a5 | 587 | struct |
252b5132 | 588 | { |
92fc129e NC |
589 | union |
590 | { | |
591 | /* PR 17754: We used to use FILNMLEN for the size of the x_fname | |
e86fc4a5 CC |
592 | array, but that causes problems as PE targets use a larger |
593 | value. We cannot use their definition of E_FILNMLEN as this | |
594 | header can be used without including any PE headers. */ | |
595 | char x_fname[20]; | |
596 | struct | |
597 | { | |
60159858 | 598 | /* PR 28630: We use uintptr_t because these fields may be |
92fc129e | 599 | used to hold pointers. We assume that this type is at least |
60159858 AM |
600 | 32 bits. */ |
601 | uintptr_t x_zeroes; | |
602 | uintptr_t x_offset; | |
e86fc4a5 CC |
603 | } x_n; |
604 | } x_n; | |
92fc129e | 605 | |
e86fc4a5 | 606 | unsigned char x_ftype; |
252b5132 RH |
607 | } x_file; |
608 | ||
609 | struct | |
610 | { | |
611 | long x_scnlen; /* section length */ | |
612 | unsigned short x_nreloc; /* # relocation entries */ | |
613 | unsigned short x_nlinno; /* # line numbers */ | |
614 | unsigned long x_checksum; /* section COMDAT checksum for PE */ | |
615 | unsigned short x_associated; /* COMDAT associated section index for PE */ | |
616 | unsigned char x_comdat; /* COMDAT selection number for PE */ | |
617 | } x_scn; | |
618 | ||
619 | struct | |
620 | { | |
621 | long x_tvfill; /* tv fill value */ | |
622 | unsigned short x_tvlen; /* length of .tv */ | |
623 | unsigned short x_tvran[2]; /* tv range */ | |
624 | } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ | |
625 | ||
626 | /****************************************** | |
627 | * RS/6000-specific auxent - last auxent for every external symbol | |
628 | ******************************************/ | |
629 | struct | |
630 | { | |
631 | union | |
632 | { /* csect length or enclosing csect */ | |
3dd657b1 | 633 | bfd_signed_vma l; |
252b5132 RH |
634 | struct coff_ptr_struct *p; |
635 | } x_scnlen; | |
636 | long x_parmhash; /* parm type hash index */ | |
637 | unsigned short x_snhash; /* sect num with parm hash */ | |
638 | unsigned char x_smtyp; /* symbol align and type */ | |
639 | /* 0-4 - Log 2 of alignment */ | |
640 | /* 5-7 - symbol type */ | |
641 | unsigned char x_smclas; /* storage mapping class */ | |
642 | long x_stab; /* dbx stab info index */ | |
643 | unsigned short x_snstab; /* sect num with dbx stab */ | |
644 | } x_csect; /* csect definition information */ | |
645 | ||
646 | /* x_smtyp values: */ | |
647 | ||
648 | #define SMTYP_ALIGN(x) ((x) >> 3) /* log2 of alignment */ | |
649 | #define SMTYP_SMTYP(x) ((x) & 0x7) /* symbol type */ | |
650 | /* Symbol type values: */ | |
651 | #define XTY_ER 0 /* External reference */ | |
652 | #define XTY_SD 1 /* Csect definition */ | |
653 | #define XTY_LD 2 /* Label definition */ | |
654 | #define XTY_CM 3 /* .BSS */ | |
655 | #define XTY_EM 4 /* Error message */ | |
656 | #define XTY_US 5 /* "Reserved for internal use" */ | |
657 | ||
658 | /* x_smclas values: */ | |
659 | ||
660 | #define XMC_PR 0 /* Read-only program code */ | |
661 | #define XMC_RO 1 /* Read-only constant */ | |
662 | #define XMC_DB 2 /* Read-only debug dictionary table */ | |
663 | #define XMC_TC 3 /* Read-write general TOC entry */ | |
664 | #define XMC_UA 4 /* Read-write unclassified */ | |
665 | #define XMC_RW 5 /* Read-write data */ | |
666 | #define XMC_GL 6 /* Read-only global linkage */ | |
667 | #define XMC_XO 7 /* Read-only extended operation */ | |
668 | #define XMC_SV 8 /* Read-only supervisor call */ | |
669 | #define XMC_BS 9 /* Read-write BSS */ | |
670 | #define XMC_DS 10 /* Read-write descriptor csect */ | |
671 | #define XMC_UC 11 /* Read-write unnamed Fortran common */ | |
672 | #define XMC_TI 12 /* Read-only traceback index csect */ | |
673 | #define XMC_TB 13 /* Read-only traceback table csect */ | |
674 | /* 14 ??? */ | |
675 | #define XMC_TC0 15 /* Read-write TOC anchor */ | |
676 | #define XMC_TD 16 /* Read-write data in TOC */ | |
b11b2969 CC |
677 | |
678 | struct | |
679 | { | |
680 | long x_scnlen; /* Section length */ | |
681 | long x_nreloc; /* Number of relocation entries */ | |
682 | } x_sect; | |
252b5132 RH |
683 | }; |
684 | ||
685 | /********************** RELOCATION DIRECTIVES **********************/ | |
686 | ||
687 | struct internal_reloc | |
688 | { | |
689 | bfd_vma r_vaddr; /* Virtual address of reference */ | |
690 | long r_symndx; /* Index into symbol table */ | |
691 | unsigned short r_type; /* Relocation type */ | |
692 | unsigned char r_size; /* Used by RS/6000 and ECOFF */ | |
693 | unsigned char r_extern; /* Used by ECOFF */ | |
694 | unsigned long r_offset; /* Used by Alpha ECOFF, SPARC, others */ | |
695 | }; | |
696 | ||
27049a38 MH |
697 | #define IMAGE_REL_BASED_ABSOLUTE 0 |
698 | #define IMAGE_REL_BASED_HIGH 1 | |
699 | #define IMAGE_REL_BASED_LOW 2 | |
700 | #define IMAGE_REL_BASED_HIGHLOW 3 | |
701 | #define IMAGE_REL_BASED_HIGHADJ 4 | |
702 | #define IMAGE_REL_BASED_MIPS_JMPADDR 5 | |
703 | #define IMAGE_REL_BASED_ARM_MOV32 5 | |
704 | #define IMAGE_REL_BASED_RISCV_HIGH20 5 | |
705 | #define IMAGE_REL_BASED_THUMB_MOV32 7 | |
706 | #define IMAGE_REL_BASED_RISCV_LOW12I 7 | |
707 | #define IMAGE_REL_BASED_RISCV_LOW12S 8 | |
708 | #define IMAGE_REL_BASED_LOONGARCH32_MARK_LA 8 | |
709 | #define IMAGE_REL_BASED_LOONGARCH64_MARK_LA 8 | |
710 | #define IMAGE_REL_BASED_MIPS_JMPADDR16 9 | |
711 | #define IMAGE_REL_BASED_DIR64 10 | |
712 | ||
252b5132 | 713 | #endif /* GNU_COFF_INTERNAL_H */ |