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