00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _LIBNLM_H_
00022 #define _LIBNLM_H_ 1
00023
00024 #ifdef ARCH_SIZE
00025 # define NLM_ARCH_SIZE ARCH_SIZE
00026 #endif
00027 #include "nlm/common.h"
00028 #include "nlm/internal.h"
00029 #include "nlm/external.h"
00030
00031
00032
00033
00034
00035 struct nlm_relent
00036 {
00037
00038 asection *section;
00039
00040 arelent reloc;
00041 };
00042
00043
00044
00045 typedef struct
00046 {
00047
00048 asymbol symbol;
00049
00050 bfd_size_type rcnt;
00051
00052 struct nlm_relent *relocs;
00053 } nlmNAME(symbol_type);
00054
00055 extern bfd_boolean nlm_mkobject
00056 PARAMS ((bfd *));
00057 extern bfd_boolean nlm_set_arch_mach
00058 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
00059
00060 extern void nlmNAME(get_symbol_info)
00061 PARAMS ((bfd *, asymbol *, symbol_info *));
00062 extern long nlmNAME(get_symtab_upper_bound)
00063 PARAMS ((bfd *));
00064 extern long nlmNAME(canonicalize_symtab)
00065 PARAMS ((bfd *, asymbol **));
00066 extern asymbol *nlmNAME(make_empty_symbol)
00067 PARAMS ((bfd *));
00068 extern void nlmNAME(print_symbol)
00069 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
00070 extern long nlmNAME(get_reloc_upper_bound)
00071 PARAMS ((bfd *, asection *));
00072 extern long nlmNAME(canonicalize_reloc)
00073 PARAMS ((bfd *, asection *, arelent **, asymbol **));
00074 extern const bfd_target *nlmNAME(object_p)
00075 PARAMS ((bfd *));
00076 extern bfd_boolean nlmNAME(set_arch_mach)
00077 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
00078 extern bfd_boolean nlmNAME(set_section_contents)
00079 PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
00080 extern bfd_boolean nlmNAME(write_object_contents)
00081 PARAMS ((bfd *));
00082
00083
00084
00085
00086 struct nlm_obj_tdata
00087 {
00088
00089 Nlm_Internal_Fixed_Header nlm_fixed_hdr[1];
00090 Nlm_Internal_Variable_Header nlm_variable_hdr[1];
00091 Nlm_Internal_Version_Header nlm_version_hdr[1];
00092 Nlm_Internal_Copyright_Header nlm_copyright_hdr[1];
00093 Nlm_Internal_Extended_Header nlm_extended_hdr[1];
00094 Nlm_Internal_Custom_Header nlm_custom_hdr[1];
00095 Nlm_Internal_Cygnus_Ext_Header nlm_cygnus_ext_hdr[1];
00096
00097 nlmNAME(symbol_type) *nlm_symbols;
00098
00099 bfd_vma nlm_text_low;
00100 bfd_vma nlm_data_low;
00101
00102 arelent * nlm_reloc_fixups;
00103 asection ** nlm_reloc_fixup_secs;
00104
00105
00106
00107 union
00108 {
00109 struct
00110 {
00111 bfd_vma gp;
00112 bfd_vma lita_address;
00113 bfd_size_type lita_size;
00114 }
00115 alpha_backend_data;
00116 }
00117 backend_data;
00118 };
00119
00120 #define nlm_tdata(bfd) ((bfd) -> tdata.nlm_obj_data)
00121 #define nlm_fixed_header(bfd) (nlm_tdata(bfd) -> nlm_fixed_hdr)
00122 #define nlm_variable_header(bfd) (nlm_tdata(bfd) -> nlm_variable_hdr)
00123 #define nlm_version_header(bfd) (nlm_tdata(bfd) -> nlm_version_hdr)
00124 #define nlm_copyright_header(bfd) (nlm_tdata(bfd) -> nlm_copyright_hdr)
00125 #define nlm_extended_header(bfd) (nlm_tdata(bfd) -> nlm_extended_hdr)
00126 #define nlm_custom_header(bfd) (nlm_tdata(bfd) -> nlm_custom_hdr)
00127 #define nlm_cygnus_ext_header(bfd) (nlm_tdata(bfd) -> nlm_cygnus_ext_hdr)
00128 #define nlm_get_symbols(bfd) (nlm_tdata(bfd) -> nlm_symbols)
00129 #define nlm_set_symbols(bfd, p) (nlm_tdata(bfd) -> nlm_symbols = (p))
00130 #define nlm_set_text_low(bfd, i) (nlm_tdata(bfd) -> nlm_text_low = (i))
00131 #define nlm_get_text_low(bfd) (nlm_tdata(bfd) -> nlm_text_low)
00132 #define nlm_set_data_low(bfd, i) (nlm_tdata(bfd) -> nlm_data_low = (i))
00133 #define nlm_get_data_low(bfd) (nlm_tdata(bfd) -> nlm_data_low)
00134 #define nlm_relocation_fixups(bfd) (nlm_tdata(bfd) -> nlm_reloc_fixups)
00135 #define nlm_relocation_fixup_secs(bfd) (nlm_tdata(bfd)->nlm_reloc_fixup_secs)
00136
00137 #define nlm_alpha_backend_data(bfd) \
00138 (&nlm_tdata (bfd)->backend_data.alpha_backend_data)
00139
00140
00141
00142 struct reloc_and_sec
00143 {
00144 arelent *rel;
00145 asection *sec;
00146 };
00147
00148
00149
00150
00151
00152 struct nlm_backend_data
00153 {
00154
00155 char signature[NLM_SIGNATURE_SIZE];
00156
00157 bfd_size_type fixed_header_size;
00158
00159
00160
00161 bfd_size_type optional_prefix_size;
00162
00163 enum bfd_architecture arch;
00164
00165 unsigned int mach;
00166
00167
00168
00169 bfd_boolean no_uninitialized_data;
00170
00171
00172
00173
00174 bfd_boolean (*nlm_backend_object_p) PARAMS ((bfd *));
00175
00176
00177
00178 bfd_boolean (*nlm_write_prefix) PARAMS ((bfd *));
00179
00180
00181
00182
00183
00184
00185
00186 bfd_boolean (*nlm_read_reloc)
00187 PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
00188
00189
00190 bfd_boolean (*nlm_mangle_relocs)
00191 PARAMS ((bfd *, asection *, const PTR data, bfd_vma offset,
00192 bfd_size_type count));
00193
00194
00195 bfd_boolean (*nlm_read_import) PARAMS ((bfd *, nlmNAME(symbol_type) *));
00196
00197 bfd_boolean (*nlm_write_import) PARAMS ((bfd *, asection *, arelent *));
00198
00199
00200 bfd_boolean (*nlm_set_public_section)
00201 PARAMS ((bfd *, nlmNAME(symbol_type) *));
00202
00203
00204 bfd_vma (*nlm_get_public_offset) PARAMS ((bfd *, asymbol *));
00205
00206 void (*nlm_swap_fhdr_in)
00207 PARAMS ((bfd *, PTR, Nlm_Internal_Fixed_Header *));
00208 void (*nlm_swap_fhdr_out)
00209 PARAMS ((bfd *, struct nlm_internal_fixed_header *, PTR));
00210
00211 bfd_boolean (*nlm_write_external)
00212 PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
00213 bfd_boolean (*nlm_write_export) PARAMS ((bfd *, asymbol *, bfd_vma));
00214 };
00215
00216 #define nlm_backend(bfd) \
00217 ((struct nlm_backend_data *)((bfd) -> xvec -> backend_data))
00218 #define nlm_signature(bfd) \
00219 (nlm_backend(bfd) -> signature)
00220 #define nlm_fixed_header_size(bfd) \
00221 (nlm_backend(bfd) -> fixed_header_size)
00222 #define nlm_optional_prefix_size(bfd) \
00223 (nlm_backend(bfd) -> optional_prefix_size)
00224 #define nlm_architecture(bfd) \
00225 (nlm_backend(bfd) -> arch)
00226 #define nlm_machine(bfd) \
00227 (nlm_backend(bfd) -> mach)
00228 #define nlm_no_uninitialized_data(bfd) \
00229 (nlm_backend(bfd) -> no_uninitialized_data)
00230 #define nlm_backend_object_p_func(bfd) \
00231 (nlm_backend(bfd) -> nlm_backend_object_p)
00232 #define nlm_write_prefix_func(bfd) \
00233 (nlm_backend(bfd) -> nlm_write_prefix)
00234 #define nlm_read_reloc_func(bfd) \
00235 (nlm_backend(bfd) -> nlm_read_reloc)
00236 #define nlm_mangle_relocs_func(bfd) \
00237 (nlm_backend(bfd) -> nlm_mangle_relocs)
00238 #define nlm_read_import_func(bfd) \
00239 (nlm_backend(bfd) -> nlm_read_import)
00240 #define nlm_write_import_func(bfd) \
00241 (nlm_backend(bfd) -> nlm_write_import)
00242 #define nlm_set_public_section_func(bfd) \
00243 (nlm_backend(bfd) -> nlm_set_public_section)
00244 #define nlm_get_public_offset_func(bfd) \
00245 (nlm_backend(bfd) -> nlm_get_public_offset)
00246 #define nlm_swap_fixed_header_in_func(bfd) \
00247 (nlm_backend(bfd) -> nlm_swap_fhdr_in)
00248 #define nlm_swap_fixed_header_out_func(bfd) \
00249 (nlm_backend(bfd) -> nlm_swap_fhdr_out)
00250 #define nlm_write_external_func(bfd) \
00251 (nlm_backend(bfd) -> nlm_write_external)
00252 #define nlm_write_export_func(bfd) \
00253 (nlm_backend(bfd) -> nlm_write_export)
00254
00255
00256
00257
00258
00259 #define NLM_CODE_NAME ".text"
00260 #define NLM_INITIALIZED_DATA_NAME ".data"
00261 #define NLM_UNINITIALIZED_DATA_NAME ".bss"
00262
00263 #endif