* ld-arm/arm-elf.exp: Add arm-static-app test.
[binutils.git] / bfd / libnlm.h
blob0a7b4d962c914420aacecb53be18a18437809587
1 /* BFD back-end data structures for NLM (NetWare Loadable Modules) files.
2 Copyright 1993, 1994, 2001, 2002, 2003 Free Software Foundation, Inc.
3 Written by Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #ifndef _LIBNLM_H_
22 #define _LIBNLM_H_ 1
24 #ifdef ARCH_SIZE
25 # define NLM_ARCH_SIZE ARCH_SIZE
26 #endif
27 #include "nlm/common.h"
28 #include "nlm/internal.h"
29 #include "nlm/external.h"
31 /* A reloc for an imported NLM symbol. Normal relocs are associated
32 with sections, and include a symbol. These relocs are associated
33 with (undefined) symbols, and include a section. */
35 struct nlm_relent
37 /* Section of reloc. */
38 asection *section;
39 /* Reloc info (sym_ptr_ptr field set only when canonicalized). */
40 arelent reloc;
43 /* Information we keep for an NLM symbol. */
45 typedef struct
47 /* BFD symbol. */
48 asymbol symbol;
49 /* Number of reloc entries for imported symbol. */
50 bfd_size_type rcnt;
51 /* Array of reloc information for imported symbol. */
52 struct nlm_relent *relocs;
53 } nlmNAME(symbol_type);
55 extern bfd_boolean nlm_mkobject
56 PARAMS ((bfd *));
57 extern bfd_boolean nlm_set_arch_mach
58 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
60 extern void nlmNAME(get_symbol_info)
61 PARAMS ((bfd *, asymbol *, symbol_info *));
62 extern long nlmNAME(get_symtab_upper_bound)
63 PARAMS ((bfd *));
64 extern long nlmNAME(canonicalize_symtab)
65 PARAMS ((bfd *, asymbol **));
66 extern asymbol *nlmNAME(make_empty_symbol)
67 PARAMS ((bfd *));
68 extern void nlmNAME(print_symbol)
69 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
70 extern long nlmNAME(get_reloc_upper_bound)
71 PARAMS ((bfd *, asection *));
72 extern long nlmNAME(canonicalize_reloc)
73 PARAMS ((bfd *, asection *, arelent **, asymbol **));
74 extern const bfd_target *nlmNAME(object_p)
75 PARAMS ((bfd *));
76 extern bfd_boolean nlmNAME(set_arch_mach)
77 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
78 extern bfd_boolean nlmNAME(set_section_contents)
79 PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
80 extern bfd_boolean nlmNAME(write_object_contents)
81 PARAMS ((bfd *));
83 /* Some private data is stashed away for future use using the tdata pointer
84 in the bfd structure. */
86 struct nlm_obj_tdata
88 /* Actual data, but ref like ptr */
89 Nlm_Internal_Fixed_Header nlm_fixed_hdr[1];
90 Nlm_Internal_Variable_Header nlm_variable_hdr[1];
91 Nlm_Internal_Version_Header nlm_version_hdr[1];
92 Nlm_Internal_Copyright_Header nlm_copyright_hdr[1];
93 Nlm_Internal_Extended_Header nlm_extended_hdr[1];
94 Nlm_Internal_Custom_Header nlm_custom_hdr[1];
95 Nlm_Internal_Cygnus_Ext_Header nlm_cygnus_ext_hdr[1];
96 /* BFD NLM symbols. */
97 nlmNAME(symbol_type) *nlm_symbols;
98 /* Lowest text and data VMA values. */
99 bfd_vma nlm_text_low;
100 bfd_vma nlm_data_low;
101 /* Caches for data read from object file. */
102 arelent * nlm_reloc_fixups;
103 asection ** nlm_reloc_fixup_secs;
104 /* Backend specific information. This should probably be a pointer,
105 but that would require yet another entry point to initialize the
106 structure. */
107 union
109 struct /* Alpha backend information. */
111 bfd_vma gp; /* GP value. */
112 bfd_vma lita_address; /* .lita section address. */
113 bfd_size_type lita_size; /* .lita section size. */
115 alpha_backend_data;
117 backend_data;
120 #define nlm_tdata(bfd) ((bfd) -> tdata.nlm_obj_data)
121 #define nlm_fixed_header(bfd) (nlm_tdata(bfd) -> nlm_fixed_hdr)
122 #define nlm_variable_header(bfd) (nlm_tdata(bfd) -> nlm_variable_hdr)
123 #define nlm_version_header(bfd) (nlm_tdata(bfd) -> nlm_version_hdr)
124 #define nlm_copyright_header(bfd) (nlm_tdata(bfd) -> nlm_copyright_hdr)
125 #define nlm_extended_header(bfd) (nlm_tdata(bfd) -> nlm_extended_hdr)
126 #define nlm_custom_header(bfd) (nlm_tdata(bfd) -> nlm_custom_hdr)
127 #define nlm_cygnus_ext_header(bfd) (nlm_tdata(bfd) -> nlm_cygnus_ext_hdr)
128 #define nlm_get_symbols(bfd) (nlm_tdata(bfd) -> nlm_symbols)
129 #define nlm_set_symbols(bfd, p) (nlm_tdata(bfd) -> nlm_symbols = (p))
130 #define nlm_set_text_low(bfd, i) (nlm_tdata(bfd) -> nlm_text_low = (i))
131 #define nlm_get_text_low(bfd) (nlm_tdata(bfd) -> nlm_text_low)
132 #define nlm_set_data_low(bfd, i) (nlm_tdata(bfd) -> nlm_data_low = (i))
133 #define nlm_get_data_low(bfd) (nlm_tdata(bfd) -> nlm_data_low)
134 #define nlm_relocation_fixups(bfd) (nlm_tdata(bfd) -> nlm_reloc_fixups)
135 #define nlm_relocation_fixup_secs(bfd) (nlm_tdata(bfd)->nlm_reloc_fixup_secs)
137 #define nlm_alpha_backend_data(bfd) \
138 (&nlm_tdata (bfd)->backend_data.alpha_backend_data)
140 /* This is used when writing out the external relocs. */
142 struct reloc_and_sec
144 arelent *rel;
145 asection *sec;
148 /* We store some function pointer in the backend structure. This lets
149 different NLM targets share most of the same code, while providing
150 slightly different code where necessary. */
152 struct nlm_backend_data
154 /* Signature for this backend. */
155 char signature[NLM_SIGNATURE_SIZE];
156 /* Size of the fixed header. */
157 bfd_size_type fixed_header_size;
158 /* Size of optional prefix for this backend. Some backend may
159 require this to be a function, but so far a constant is OK. This
160 is for a prefix which precedes the standard NLM fixed header. */
161 bfd_size_type optional_prefix_size;
162 /* Architecture. */
163 enum bfd_architecture arch;
164 /* Machine. */
165 unsigned int mach;
166 /* Some NLM formats do not use the uninitialized data section, so
167 all uninitialized data must be put into the regular data section
168 instead. */
169 bfd_boolean no_uninitialized_data;
170 /* Some NLM formats have a prefix on the file. If this function is
171 not NULL, it will be called by nlm_object_p. It should return
172 TRUE if this file could match this format, and it should leave
173 the BFD such that a bfd_bread will pick up the fixed header. */
174 bfd_boolean (*nlm_backend_object_p) PARAMS ((bfd *));
175 /* Write out the prefix. This function may be NULL. This must
176 write out the same number of bytes as is in the field
177 optional_prefix_size. */
178 bfd_boolean (*nlm_write_prefix) PARAMS ((bfd *));
179 /* Read a relocation fixup from abfd. The reloc information is
180 machine specific. The second argument is the symbol if this is
181 an import, or NULL if this is a reloc fixup. This function
182 should set the third argument to the section which the reloc
183 belongs in, and the fourth argument to the reloc itself; it does
184 not need to fill in the sym_ptr_ptr field for a reloc against an
185 import symbol. */
186 bfd_boolean (*nlm_read_reloc)
187 PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
188 /* To make objcopy to an i386 NLM work, the i386 backend needs a
189 chance to work over the relocs. This is a bit icky. */
190 bfd_boolean (*nlm_mangle_relocs)
191 PARAMS ((bfd *, asection *, const PTR data, bfd_vma offset,
192 bfd_size_type count));
193 /* Read an import record from abfd. It would be nice if this
194 were in a machine-dependent format, but it doesn't seem to be. */
195 bfd_boolean (*nlm_read_import) PARAMS ((bfd *, nlmNAME(symbol_type) *));
196 /* Write an import record to abfd. */
197 bfd_boolean (*nlm_write_import) PARAMS ((bfd *, asection *, arelent *));
198 /* Set the section for a public symbol. This may be NULL, in which
199 case a default method will be used. */
200 bfd_boolean (*nlm_set_public_section)
201 PARAMS ((bfd *, nlmNAME(symbol_type) *));
202 /* Get the offset to write out for a public symbol. This may be
203 NULL, in which case a default method will be used. */
204 bfd_vma (*nlm_get_public_offset) PARAMS ((bfd *, asymbol *));
205 /* Swap the fixed header in and out */
206 void (*nlm_swap_fhdr_in)
207 PARAMS ((bfd *, PTR, Nlm_Internal_Fixed_Header *));
208 void (*nlm_swap_fhdr_out)
209 PARAMS ((bfd *, struct nlm_internal_fixed_header *, PTR));
210 /* Write out an external reference. */
211 bfd_boolean (*nlm_write_external)
212 PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
213 bfd_boolean (*nlm_write_export) PARAMS ((bfd *, asymbol *, bfd_vma));
216 #define nlm_backend(bfd) \
217 ((struct nlm_backend_data *)((bfd) -> xvec -> backend_data))
218 #define nlm_signature(bfd) \
219 (nlm_backend(bfd) -> signature)
220 #define nlm_fixed_header_size(bfd) \
221 (nlm_backend(bfd) -> fixed_header_size)
222 #define nlm_optional_prefix_size(bfd) \
223 (nlm_backend(bfd) -> optional_prefix_size)
224 #define nlm_architecture(bfd) \
225 (nlm_backend(bfd) -> arch)
226 #define nlm_machine(bfd) \
227 (nlm_backend(bfd) -> mach)
228 #define nlm_no_uninitialized_data(bfd) \
229 (nlm_backend(bfd) -> no_uninitialized_data)
230 #define nlm_backend_object_p_func(bfd) \
231 (nlm_backend(bfd) -> nlm_backend_object_p)
232 #define nlm_write_prefix_func(bfd) \
233 (nlm_backend(bfd) -> nlm_write_prefix)
234 #define nlm_read_reloc_func(bfd) \
235 (nlm_backend(bfd) -> nlm_read_reloc)
236 #define nlm_mangle_relocs_func(bfd) \
237 (nlm_backend(bfd) -> nlm_mangle_relocs)
238 #define nlm_read_import_func(bfd) \
239 (nlm_backend(bfd) -> nlm_read_import)
240 #define nlm_write_import_func(bfd) \
241 (nlm_backend(bfd) -> nlm_write_import)
242 #define nlm_set_public_section_func(bfd) \
243 (nlm_backend(bfd) -> nlm_set_public_section)
244 #define nlm_get_public_offset_func(bfd) \
245 (nlm_backend(bfd) -> nlm_get_public_offset)
246 #define nlm_swap_fixed_header_in_func(bfd) \
247 (nlm_backend(bfd) -> nlm_swap_fhdr_in)
248 #define nlm_swap_fixed_header_out_func(bfd) \
249 (nlm_backend(bfd) -> nlm_swap_fhdr_out)
250 #define nlm_write_external_func(bfd) \
251 (nlm_backend(bfd) -> nlm_write_external)
252 #define nlm_write_export_func(bfd) \
253 (nlm_backend(bfd) -> nlm_write_export)
255 /* The NLM code, data, and uninitialized sections have no names defined
256 in the NLM, but bfd wants to give them names, so use the traditional
257 UNIX names. */
259 #define NLM_CODE_NAME ".text"
260 #define NLM_INITIALIZED_DATA_NAME ".data"
261 #define NLM_UNINITIALIZED_DATA_NAME ".bss"
263 #endif /* _LIBNLM_H_ */