* aix386-core.c (aix386_bfd_is_local_label): Correct cast from
[binutils-gdb.git] / bfd / som.h
1 /* HP PA-RISC SOM object file format: definitions internal to BFD.
2 Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
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
11 the Free Software Foundation; either version 2 of the License, or
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
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22
23 #ifndef _SOM_H
24 #define _SOM_H
25
26 #include "../bfd/sysdep.h"
27 #include "libhppa.h"
28
29 #include <a.out.h>
30 #include <lst.h>
31 #include <ar.h>
32
33
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
37 number. */
38 #undef _PA_RISC_ID
39 #define _PA_RISC_ID(__m_num) 1
40 #endif /* HOST_HPPABSD */
41
42 #define FILE_HDR_SIZE sizeof(struct header)
43 #define AUX_HDR_SIZE sizeof(struct som_exec_auxhdr)
44
45 typedef struct som_symbol
46 {
47 asymbol symbol;
48 short desc;
49 char other;
50 unsigned char type;
51 unsigned int som_type;
52
53 /* Structured like the ELF tc_data union. Allows more code sharing
54 in GAS this way. */
55 union
56 {
57 unsigned int hppa_arg_reloc;
58 PTR any;
59 }
60 tc_data;
61
62 /* Index of this symbol in the symbol table. Only used when
63 building relocation streams for incomplete objects. */
64 int index;
65
66 /* How many times this symbol is used in a relocation. By sorting
67 the symbols from most used to least used we can significantly
68 reduce the size of the relocation stream for incomplete objects. */
69 int reloc_count;
70
71 /* The unwind descriptor bits associated with R_ENTRY relocations
72 for functions (not enough room in a BFD reloc to store all the
73 information, so we tack it onto the symbol associated with the
74 function. */
75 char *unwind;
76 }
77 som_symbol_type;
78
79 /* A structure containing all the magic information stored in a BFD's
80 private data which needs to be copied during an objcopy/strip run. */
81 struct som_exec_data
82 {
83 /* Sort-of a magic number. BSD uses it to distinguish between
84 native executables and hpux executables. */
85 short system_id;
86
87 /* Magic exec flags. These control things like whether or not
88 null pointer dereferencing is allowed and the like. */
89 long exec_flags;
90
91 /* Add more stuff here as needed. Good examples of information
92 we might want to pass would be presumed_dp, entry_* and maybe
93 others from the file header. */
94 };
95
96 struct somdata
97 {
98 /* All the magic information about an executable which lives
99 in the private BFD structure and needs to be copied from
100 the input bfd to the output bfd during a objcopy/strip. */
101 struct som_exec_data *exec_data;
102
103 /* These three fields are only used when writing files and are
104 generated from scratch. They need not be copied for objcopy
105 or strip to work. */
106 struct header *file_hdr;
107 struct copyright_aux_hdr *copyright_aux_hdr;
108 struct user_string_aux_hdr *version_aux_hdr;
109
110 /* Pointers to a saved copy of the symbol and string tables. These
111 need not be copied for objcopy or strip to work. */
112 som_symbol_type *symtab;
113 char *stringtab;
114
115 /* We remember these offsets so that after check_file_format, we have
116 no dependencies on the particular format of the exec_hdr.
117 These offsets need not be copied for objcopy or strip to work. */
118
119 file_ptr sym_filepos;
120 file_ptr str_filepos;
121 file_ptr reloc_filepos;
122 unsigned stringtab_size;
123 };
124
125 struct som_data_struct
126 {
127 struct somdata a;
128 };
129
130 /* Used to keep extra SOM specific information for a given section.
131
132 reloc_size holds the size of the relocation stream, note this
133 is very different from the number of relocations as SOM relocations
134 are variable length.
135
136 reloc_stream is the actual stream of relocation entries.
137
138 The BFD section index may not exactly match a SOM subspace index,
139 for this reason we keep track of the original SOM subspace index
140 when a subspace is turned into a BFD section. */
141
142 struct som_section_data_struct
143 {
144 unsigned int is_space : 1;
145 unsigned int is_subspace : 1;
146 unsigned int reloc_size;
147 char *reloc_stream;
148 asection *containing_space;
149 struct space_dictionary_record space_dict;
150 struct subspace_dictionary_record subspace_dict;
151 };
152
153 #define somdata(bfd) ((bfd)->tdata.som_data->a)
154 #define obj_som_exec_data(bfd) (somdata(bfd).exec_data)
155 #define obj_som_file_hdr(bfd) (somdata(bfd).file_hdr)
156 #define obj_som_copyright_hdr(bfd) (somdata(bfd).copyright_aux_hdr)
157 #define obj_som_version_hdr(bfd) (somdata(bfd).version_aux_hdr)
158 #define obj_som_symtab(bfd) (somdata(bfd).symtab)
159 #define obj_som_stringtab(bfd) (somdata(bfd).stringtab)
160 #define obj_som_sym_filepos(bfd) (somdata(bfd).sym_filepos)
161 #define obj_som_str_filepos(bfd) (somdata(bfd).str_filepos)
162 #define obj_som_stringtab_size(bfd) (somdata(bfd).stringtab_size)
163 #define obj_som_reloc_filepos(bfd) (somdata(bfd).reloc_filepos)
164 #define som_section_data(sec) \
165 ((struct som_section_data_struct *)sec->used_by_bfd)
166 #define som_symbol_data(symbol) \
167 ((som_symbol_type *) symbol)
168
169
170 /* Defines groups of basic relocations. FIXME: These should
171 be the only basic relocations created by GAS. The rest
172 should be internal to the BFD backend.
173
174 The idea is both SOM and ELF define these basic relocation
175 types so they map into a SOM or ELF specific reloation as
176 appropriate. This allows GAS to share much more code
177 between the two object formats. */
178
179 #define R_HPPA_NONE R_NO_RELOCATION
180 #define R_HPPA R_CODE_ONE_SYMBOL
181 #define R_HPPA_ABS_CALL R_ABS_CALL
182 #define R_HPPA_PCREL_CALL R_PCREL_CALL
183 #define R_HPPA_GOTOFF R_DP_RELATIVE
184 #define R_HPPA_COMPLEX R_COMP1
185 #define R_HPPA_COMPLEX_PCREL_CALL R_COMP2
186 #define R_HPPA_COMPLEX_ABS_CALL R_COMP3
187 #define R_HPPA_ENTRY R_ENTRY
188 #define R_HPPA_EXIT R_EXIT
189
190 /* Exported functions, mostly for use by GAS. */
191 void bfd_som_set_section_attributes PARAMS ((asection *, int, int,
192 unsigned int, int));
193 void bfd_som_set_subsection_attributes PARAMS ((asection *, asection *,
194 int, unsigned int, int));
195 void bfd_som_set_symbol_type PARAMS ((asymbol *, unsigned int));
196 void bfd_som_attach_unwind_info PARAMS ((asymbol *, char *));
197 boolean bfd_som_attach_aux_hdr PARAMS ((bfd *, int, char *));
198 int ** hppa_som_gen_reloc_type
199 PARAMS ((bfd *, int, int, enum hppa_reloc_field_selector_type_alt));
200 #endif /* _SOM_H */