1 /* HP PA-RISC SOM object file format: definitions internal to BFD.
2 Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
4 Contributed by the Center for Software Science at the
5 University of Utah (pa-gdb-bugs@cs.utah.edu).
7 This file is part of BFD, the Binary File Descriptor library.
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
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
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.
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
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "../bfd/sysdep.h"
34 #if defined(HOST_HPPABSD) || defined (HOST_HPPAOSF)
35 /* BSD uses a completely different scheme for object file identification.
36 so for now, define _PA_RISC_ID to accept any random value for a model
39 #define _PA_RISC_ID(__m_num) 1
40 #endif /* HOST_HPPABSD */
42 #define FILE_HDR_SIZE sizeof(struct header)
43 #define AUX_HDR_SIZE sizeof(struct som_exec_auxhdr)
45 typedef struct som_symbol
48 unsigned int som_type
;
50 /* Structured like the ELF tc_data union. Allows more code sharing
54 unsigned int hppa_arg_reloc
;
59 /* Index of this symbol in the symbol table. Only used when
60 building relocation streams for incomplete objects. */
63 /* How many times this symbol is used in a relocation. By sorting
64 the symbols from most used to least used we can significantly
65 reduce the size of the relocation stream for incomplete objects. */
70 /* A structure containing all the magic information stored in a BFD's
71 private data which needs to be copied during an objcopy/strip run. */
74 /* Sort-of a magic number. BSD uses it to distinguish between
75 native executables and hpux executables. */
78 /* Magic exec flags. These control things like whether or not
79 null pointer dereferencing is allowed and the like. */
82 /* Add more stuff here as needed. Good examples of information
83 we might want to pass would be presumed_dp, entry_* and maybe
84 others from the file header. */
89 /* All the magic information about an executable which lives
90 in the private BFD structure and needs to be copied from
91 the input bfd to the output bfd during a objcopy/strip. */
92 struct som_exec_data
*exec_data
;
94 /* These three fields are only used when writing files and are
95 generated from scratch. They need not be copied for objcopy
97 struct header
*file_hdr
;
98 struct copyright_aux_hdr
*copyright_aux_hdr
;
99 struct user_string_aux_hdr
*version_aux_hdr
;
100 struct som_exec_auxhdr
*exec_hdr
;
102 /* Pointers to a saved copy of the symbol and string tables. These
103 need not be copied for objcopy or strip to work. */
104 som_symbol_type
*symtab
;
107 /* We remember these offsets so that after check_file_format, we have
108 no dependencies on the particular format of the exec_hdr.
109 These offsets need not be copied for objcopy or strip to work. */
111 file_ptr sym_filepos
;
112 file_ptr str_filepos
;
113 file_ptr reloc_filepos
;
114 unsigned stringtab_size
;
117 struct som_data_struct
122 /* Substructure of som_section_data_struct used to hold information
123 which can't be represented by the generic BFD section structure,
124 but which must be copied during objcopy or strip. */
125 struct som_copyable_section_data_struct
127 /* Various fields in space and subspace headers that we need
129 unsigned int sort_key
: 8;
130 unsigned int access_control_bits
: 7;
131 unsigned int is_defined
: 1;
132 unsigned int is_private
: 1;
133 unsigned int quadrant
: 2;
135 /* For subspaces, this points to the section which represents the
136 space in which the subspace is contained. For spaces it points
137 back to the section for this space. */
140 /* The user-specified space number. It is wrong to use this as
141 an index since duplicates and holes are allowed. */
144 /* Add more stuff here as needed. Good examples of information
145 we might want to pass would be initialization pointers,
146 and the many subspace flags we do not represent yet. */
149 /* Used to keep extra SOM specific information for a given section.
151 reloc_size holds the size of the relocation stream, note this
152 is very different from the number of relocations as SOM relocations
155 reloc_stream is the actual stream of relocation entries. */
157 struct som_section_data_struct
159 struct som_copyable_section_data_struct
*copy_data
;
160 unsigned int reloc_size
;
162 struct space_dictionary_record
*space_dict
;
163 struct subspace_dictionary_record
*subspace_dict
;
166 #define somdata(bfd) ((bfd)->tdata.som_data->a)
167 #define obj_som_exec_data(bfd) (somdata(bfd).exec_data)
168 #define obj_som_file_hdr(bfd) (somdata(bfd).file_hdr)
169 #define obj_som_exec_hdr(bfd) (somdata(bfd).exec_hdr)
170 #define obj_som_copyright_hdr(bfd) (somdata(bfd).copyright_aux_hdr)
171 #define obj_som_version_hdr(bfd) (somdata(bfd).version_aux_hdr)
172 #define obj_som_symtab(bfd) (somdata(bfd).symtab)
173 #define obj_som_stringtab(bfd) (somdata(bfd).stringtab)
174 #define obj_som_sym_filepos(bfd) (somdata(bfd).sym_filepos)
175 #define obj_som_str_filepos(bfd) (somdata(bfd).str_filepos)
176 #define obj_som_stringtab_size(bfd) (somdata(bfd).stringtab_size)
177 #define obj_som_reloc_filepos(bfd) (somdata(bfd).reloc_filepos)
178 #define som_section_data(sec) \
179 ((struct som_section_data_struct *)sec->used_by_bfd)
180 #define som_symbol_data(symbol) ((som_symbol_type *) symbol)
183 /* Defines groups of basic relocations. FIXME: These should
184 be the only basic relocations created by GAS. The rest
185 should be internal to the BFD backend.
187 The idea is both SOM and ELF define these basic relocation
188 types so they map into a SOM or ELF specific reloation as
189 appropriate. This allows GAS to share much more code
190 between the two object formats. */
192 #define R_HPPA_NONE R_NO_RELOCATION
193 #define R_HPPA R_CODE_ONE_SYMBOL
194 #define R_HPPA_PCREL_CALL R_PCREL_CALL
195 #define R_HPPA_ABS_CALL R_ABS_CALL
196 #define R_HPPA_GOTOFF R_DP_RELATIVE
197 #define R_HPPA_ENTRY R_ENTRY
198 #define R_HPPA_EXIT R_EXIT
199 #define R_HPPA_COMPLEX R_COMP1
201 /* Exported functions, mostly for use by GAS. */
202 boolean bfd_som_set_section_attributes
PARAMS ((asection
*, int, int,
204 boolean bfd_som_set_subsection_attributes
PARAMS ((asection
*, asection
*,
205 int, unsigned int, int));
206 void bfd_som_set_symbol_type
PARAMS ((asymbol
*, unsigned int));
207 boolean bfd_som_attach_aux_hdr
PARAMS ((bfd
*, int, char *));
208 int ** hppa_som_gen_reloc_type
209 PARAMS ((bfd
*, int, int, enum hppa_reloc_field_selector_type_alt
));