]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/som.h
[PATCH] fix windmc typedef bug
[thirdparty/binutils-gdb.git] / bfd / som.h
CommitLineData
252b5132 1/* HP PA-RISC SOM object file format: definitions internal to BFD.
b3adc24a 2 Copyright (C) 1990-2020 Free Software Foundation, Inc.
252b5132
RH
3
4 Contributed by the Center for Software Science at the
5 University of Utah (pa-gdb-bugs@cs.utah.edu).
6
7 This file is part of BFD, the Binary File Descriptor library.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
cd123cb7 11 the Free Software Foundation; either version 3 of the License, or
252b5132
RH
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
3e110533 21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
53e09e0a 22 02110-1301, USA. */
252b5132
RH
23
24#ifndef _SOM_H
25#define _SOM_H
26
27#include "libhppa.h"
28
351e2b5a 29/* We want reloc.h to provide PA 2.0 defines. */
759ebd76
DA
30#define PA_2_0
31
e1f000f6
TG
32#include "som/aout.h"
33#include "som/lst.h"
34#include "som/internal.h"
252b5132
RH
35
36/* The SOM BFD backend doesn't currently use anything from these
37 two include files, but it's likely to need them in the future. */
38#ifdef R_DLT_REL
39#include <shl.h>
40#include <dl.h>
41#endif
42
55172d69
PA
43#ifdef __cplusplus
44extern "C" {
45#endif
46
e1f000f6 47#if defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
252b5132
RH
48/* BSD uses a completely different scheme for object file identification.
49 so for now, define _PA_RISC_ID to accept any random value for a model
50 number. */
51#undef _PA_RISC_ID
52#define _PA_RISC_ID(__m_num) 1
53#endif /* HOST_HPPABSD */
54
252b5132 55typedef struct som_symbol
116c20d2
NC
56{
57 asymbol symbol;
58 unsigned int som_type;
59
60 /* Structured like the ELF tc_data union. Allows more code sharing
61 in GAS this way. */
62 union
252b5132 63 {
116c20d2
NC
64 struct
65 {
66 unsigned int hppa_arg_reloc;
67 unsigned int hppa_priv_level;
68 } ap;
2c3fc389 69 void * any;
252b5132 70 }
116c20d2
NC
71 tc_data;
72
73 /* Index of this symbol in the symbol table. Only used when
74 building relocation streams for incomplete objects. */
75 int index;
76
77 /* How many times this symbol is used in a relocation. By sorting
78 the symbols from most used to least used we can significantly
79 reduce the size of the relocation stream for incomplete objects. */
80 int reloc_count;
81
82 /* During object file writing, the offset of the name of this symbol
83 in the SOM string table. */
84 int stringtab_offset;
85}
252b5132
RH
86som_symbol_type;
87
88/* A structure containing all the magic information stored in a BFD's
89 private data which needs to be copied during an objcopy/strip run. */
90struct som_exec_data
116c20d2
NC
91{
92 /* Sort-of a magic number. BSD uses it to distinguish between
93 native executables and hpux executables. */
94 short system_id;
252b5132 95
116c20d2
NC
96 /* Magic exec flags. These control things like whether or not
97 null pointer dereferencing is allowed and the like. */
98 long exec_flags;
252b5132 99
116c20d2
NC
100 /* We must preserve the version identifier too. Some versions
101 of the HP linker do not grok NEW_VERSION_ID for reasons unknown. */
102 unsigned int version_id;
17617495 103
116c20d2
NC
104 /* Add more stuff here as needed. Good examples of information
105 we might want to pass would be presumed_dp, entry_* and maybe
106 others from the file header. */
107};
252b5132
RH
108
109struct somdata
116c20d2
NC
110{
111 /* All the magic information about an executable which lives
112 in the private BFD structure and needs to be copied from
113 the input bfd to the output bfd during an objcopy/strip. */
114 struct som_exec_data *exec_data;
115
116 /* These three fields are only used when writing files and are
117 generated from scratch. They need not be copied for objcopy
118 or strip to work. */
e1f000f6
TG
119 struct som_header *file_hdr;
120 struct som_string_auxhdr *copyright_aux_hdr;
121 struct som_string_auxhdr *version_aux_hdr;
116c20d2 122 struct som_exec_auxhdr *exec_hdr;
e1f000f6 123 struct som_compilation_unit *comp_unit;
116c20d2
NC
124
125 /* Pointers to a saved copy of the symbol and string tables. These
126 need not be copied for objcopy or strip to work. */
127 som_symbol_type *symtab;
128 char *stringtab;
129 asymbol **sorted_syms;
130
131 /* We remember these offsets so that after check_file_format, we have
132 no dependencies on the particular format of the exec_hdr.
133 These offsets need not be copied for objcopy or strip to work. */
134
135 file_ptr sym_filepos;
136 file_ptr str_filepos;
137 file_ptr reloc_filepos;
138 unsigned stringtab_size;
6119d252 139 void * line_info;
116c20d2 140};
252b5132
RH
141
142struct som_data_struct
116c20d2
NC
143{
144 struct somdata a;
145};
252b5132
RH
146
147/* Substructure of som_section_data_struct used to hold information
148 which can't be represented by the generic BFD section structure,
149 but which must be copied during objcopy or strip. */
150struct som_copyable_section_data_struct
116c20d2
NC
151{
152 /* Various fields in space and subspace headers that we need
153 to pass around. */
154 unsigned int sort_key : 8;
155 unsigned int access_control_bits : 7;
156 unsigned int is_defined : 1;
157 unsigned int is_private : 1;
158 unsigned int quadrant : 2;
159 unsigned int is_comdat : 1;
160 unsigned int is_common : 1;
161 unsigned int dup_common : 1;
162
163 /* For subspaces, this points to the section which represents the
164 space in which the subspace is contained. For spaces it points
165 back to the section for this space. */
166 asection *container;
167
168 /* The user-specified space number. It is wrong to use this as
169 an index since duplicates and holes are allowed. */
170 int space_number;
171
172 /* Add more stuff here as needed. Good examples of information
173 we might want to pass would be initialization pointers,
174 and the many subspace flags we do not represent yet. */
175};
252b5132
RH
176
177/* Used to keep extra SOM specific information for a given section.
178
179 reloc_size holds the size of the relocation stream, note this
180 is very different from the number of relocations as SOM relocations
6fa957a9 181 are variable length.
252b5132
RH
182
183 reloc_stream is the actual stream of relocation entries. */
184
185struct som_section_data_struct
116c20d2
NC
186{
187 struct som_copyable_section_data_struct *copy_data;
188 unsigned int reloc_size;
a96afa0f 189 unsigned char *reloc_stream;
e1f000f6 190 struct som_space_dictionary_record *space_dict;
116c20d2
NC
191 struct som_subspace_dictionary_record *subspace_dict;
192};
252b5132
RH
193
194#define somdata(bfd) ((bfd)->tdata.som_data->a)
116c20d2
NC
195#define obj_som_exec_data(bfd) (somdata (bfd).exec_data)
196#define obj_som_file_hdr(bfd) (somdata (bfd).file_hdr)
197#define obj_som_exec_hdr(bfd) (somdata (bfd).exec_hdr)
198#define obj_som_copyright_hdr(bfd) (somdata (bfd).copyright_aux_hdr)
199#define obj_som_version_hdr(bfd) (somdata (bfd).version_aux_hdr)
200#define obj_som_compilation_unit(bfd) (somdata (bfd).comp_unit)
201#define obj_som_symtab(bfd) (somdata (bfd).symtab)
202#define obj_som_stringtab(bfd) (somdata (bfd).stringtab)
203#define obj_som_sym_filepos(bfd) (somdata (bfd).sym_filepos)
204#define obj_som_str_filepos(bfd) (somdata (bfd).str_filepos)
205#define obj_som_stringtab_size(bfd) (somdata (bfd).stringtab_size)
206#define obj_som_reloc_filepos(bfd) (somdata (bfd).reloc_filepos)
207#define obj_som_sorted_syms(bfd) (somdata (bfd).sorted_syms)
07d6d2b8 208#define som_section_data(sec) ((struct som_section_data_struct *) sec->used_by_bfd)
252b5132
RH
209#define som_symbol_data(symbol) ((som_symbol_type *) symbol)
210
252b5132
RH
211/* Defines groups of basic relocations. FIXME: These should
212 be the only basic relocations created by GAS. The rest
213 should be internal to the BFD backend.
214
215 The idea is both SOM and ELF define these basic relocation
7dee875e 216 types so they map into a SOM or ELF specific relocation as
6fa957a9 217 appropriate. This allows GAS to share much more code
252b5132
RH
218 between the two object formats. */
219
220#define R_HPPA_NONE R_NO_RELOCATION
221#define R_HPPA R_CODE_ONE_SYMBOL
222#define R_HPPA_PCREL_CALL R_PCREL_CALL
223#define R_HPPA_ABS_CALL R_ABS_CALL
224#define R_HPPA_GOTOFF R_DP_RELATIVE
225#define R_HPPA_ENTRY R_ENTRY
226#define R_HPPA_EXIT R_EXIT
227#define R_HPPA_COMPLEX R_COMP1
228#define R_HPPA_BEGIN_BRTAB R_BEGIN_BRTAB
229#define R_HPPA_END_BRTAB R_END_BRTAB
230#define R_HPPA_BEGIN_TRY R_BEGIN_TRY
231#define R_HPPA_END_TRY R_END_TRY
232
233/* Exported functions, mostly for use by GAS. */
116c20d2
NC
234bfd_boolean bfd_som_set_section_attributes (asection *, int, int, unsigned int, int);
235bfd_boolean bfd_som_set_subsection_attributes (asection *, asection *, int, unsigned int, int, int, int, int);
07d6d2b8
AM
236void bfd_som_set_symbol_type (asymbol *, unsigned int);
237bfd_boolean bfd_som_attach_aux_hdr (bfd *, int, char *);
238int ** hppa_som_gen_reloc_type (bfd *, int, int, enum hppa_reloc_field_selector_type_alt, int, asymbol *);
116c20d2 239bfd_boolean bfd_som_attach_compilation_unit (bfd *, const char *, const char *, const char *, const char *);
36192a8d 240asection * bfd_section_from_som_symbol (bfd *abfd, struct som_external_symbol_dictionary_record *symbol);
252b5132 241
55172d69
PA
242#ifdef __cplusplus
243}
244#endif
252b5132 245#endif /* _SOM_H */