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