OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [bfd/] [libnlm.h] - Blame information for rev 635

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.