~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to binutils/bfd/mach-o.h

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Mach-O support for BFD.
 
2
   Copyright 1999, 2000, 2001, 2002
 
3
   Free Software Foundation, Inc.
 
4
 
 
5
   This file is part of BFD, the Binary File Descriptor library.
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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.  */
 
20
 
 
21
#ifndef _BFD_MACH_O_H_
 
22
#define _BFD_MACH_O_H_
 
23
 
 
24
#include "bfd.h"
 
25
 
 
26
#define BFD_MACH_O_N_STAB  0xe0 /* If any of these bits set, a symbolic debugging entry.  */
 
27
#define BFD_MACH_O_N_PEXT  0x10 /* Private external symbol bit.  */
 
28
#define BFD_MACH_O_N_TYPE  0x0e /* Mask for the type bits.  */
 
29
#define BFD_MACH_O_N_EXT   0x01 /* External symbol bit, set for external symbols.  */
 
30
#define BFD_MACH_O_N_UNDF  0x00 /* Undefined, n_sect == NO_SECT.  */
 
31
#define BFD_MACH_O_N_ABS   0x02 /* Absolute, n_sect == NO_SECT.  */
 
32
#define BFD_MACH_O_N_SECT  0x0e /* Defined in section number n_sect.  */
 
33
#define BFD_MACH_O_N_PBUD  0x0c /* Prebound undefined (defined in a dylib).  */
 
34
#define BFD_MACH_O_N_INDR  0x0a /* Indirect.  */
 
35
 
 
36
typedef enum bfd_mach_o_ppc_thread_flavour
 
37
  {
 
38
    BFD_MACH_O_PPC_THREAD_STATE = 1,
 
39
    BFD_MACH_O_PPC_FLOAT_STATE = 2,
 
40
    BFD_MACH_O_PPC_EXCEPTION_STATE = 3,
 
41
    BFD_MACH_O_PPC_VECTOR_STATE = 4
 
42
  }
 
43
bfd_mach_o_ppc_thread_flavour;
 
44
 
 
45
typedef enum bfd_mach_o_i386_thread_flavour
 
46
  {
 
47
    BFD_MACH_O_i386_NEW_THREAD_STATE = 1,
 
48
    BFD_MACH_O_i386_FLOAT_STATE = 2,
 
49
    BFD_MACH_O_i386_ISA_PORT_MAP_STATE = 3,
 
50
    BFD_MACH_O_i386_V86_ASSIST_STATE = 4,
 
51
    BFD_MACH_O_i386_REGS_SEGS_STATE = 5,
 
52
    BFD_MACH_O_i386_THREAD_SYSCALL_STATE = 6,
 
53
    BFD_MACH_O_i386_THREAD_STATE_NONE = 7,
 
54
    BFD_MACH_O_i386_SAVED_STATE = 8,
 
55
    BFD_MACH_O_i386_THREAD_STATE = -1,
 
56
    BFD_MACH_O_i386_THREAD_FPSTATE = -2,
 
57
    BFD_MACH_O_i386_THREAD_EXCEPTSTATE = -3,
 
58
    BFD_MACH_O_i386_THREAD_CTHREADSTATE = -4,
 
59
  }
 
60
bfd_mach_o_i386_thread_flavour;
 
61
 
 
62
#define BFD_MACH_O_LC_REQ_DYLD 0x80000000
 
63
 
 
64
typedef enum bfd_mach_o_load_command_type
 
65
  {
 
66
    BFD_MACH_O_LC_SEGMENT = 0x1,        /* File segment to be mapped.  */
 
67
    BFD_MACH_O_LC_SYMTAB = 0x2,         /* Link-edit stab symbol table info (obsolete).  */
 
68
    BFD_MACH_O_LC_SYMSEG = 0x3,         /* Link-edit gdb symbol table info.  */
 
69
    BFD_MACH_O_LC_THREAD = 0x4,         /* Thread.  */
 
70
    BFD_MACH_O_LC_UNIXTHREAD = 0x5,     /* UNIX thread (includes a stack).  */
 
71
    BFD_MACH_O_LC_LOADFVMLIB = 0x6,     /* Load a fixed VM shared library.  */
 
72
    BFD_MACH_O_LC_IDFVMLIB = 0x7,       /* Fixed VM shared library id.  */
 
73
    BFD_MACH_O_LC_IDENT = 0x8,          /* Object identification information (obsolete).  */
 
74
    BFD_MACH_O_LC_FVMFILE = 0x9,        /* Fixed VM file inclusion.  */
 
75
    BFD_MACH_O_LC_PREPAGE = 0xa,        /* Prepage command (internal use).  */
 
76
    BFD_MACH_O_LC_DYSYMTAB = 0xb,       /* Dynamic link-edit symbol table info.  */
 
77
    BFD_MACH_O_LC_LOAD_DYLIB = 0xc,     /* Load a dynamicly linked shared library.  */
 
78
    BFD_MACH_O_LC_ID_DYLIB = 0xd,       /* Dynamicly linked shared lib identification.  */
 
79
    BFD_MACH_O_LC_LOAD_DYLINKER = 0xe,  /* Load a dynamic linker.  */
 
80
    BFD_MACH_O_LC_ID_DYLINKER = 0xf,    /* Dynamic linker identification.  */
 
81
    BFD_MACH_O_LC_PREBOUND_DYLIB = 0x10,/* Modules prebound for a dynamicly.  */
 
82
    BFD_MACH_O_LC_ROUTINES = 0x11,      /* Image routines.  */
 
83
    BFD_MACH_O_LC_SUB_FRAMEWORK = 0x12, /* Sub framework.  */
 
84
    BFD_MACH_O_LC_SUB_UMBRELLA = 0x13,  /* Sub umbrella.  */
 
85
    BFD_MACH_O_LC_SUB_CLIENT = 0x14,    /* Sub client.  */
 
86
    BFD_MACH_O_LC_SUB_LIBRARY = 0x15,   /* Sub library.  */
 
87
    BFD_MACH_O_LC_TWOLEVEL_HINTS = 0x16,/* Two-level namespace lookup hints.  */
 
88
    BFD_MACH_O_LC_PREBIND_CKSUM = 0x17, /* Prebind checksum.  */
 
89
    /* Load a dynamicly linked shared library that is allowed to be
 
90
       missing (weak).  */
 
91
    BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18
 
92
  }
 
93
bfd_mach_o_load_command_type;
 
94
 
 
95
typedef enum bfd_mach_o_cpu_type
 
96
  {
 
97
    BFD_MACH_O_CPU_TYPE_VAX = 1,
 
98
    BFD_MACH_O_CPU_TYPE_MC680x0 = 6,
 
99
    BFD_MACH_O_CPU_TYPE_I386 = 7,
 
100
    BFD_MACH_O_CPU_TYPE_MIPS = 8,
 
101
    BFD_MACH_O_CPU_TYPE_MC98000 = 10,
 
102
    BFD_MACH_O_CPU_TYPE_HPPA = 11,
 
103
    BFD_MACH_O_CPU_TYPE_ARM = 12,
 
104
    BFD_MACH_O_CPU_TYPE_MC88000 = 13,
 
105
    BFD_MACH_O_CPU_TYPE_SPARC = 14,
 
106
    BFD_MACH_O_CPU_TYPE_I860 = 15,
 
107
    BFD_MACH_O_CPU_TYPE_ALPHA = 16,
 
108
    BFD_MACH_O_CPU_TYPE_POWERPC = 18
 
109
  }
 
110
bfd_mach_o_cpu_type;
 
111
 
 
112
typedef enum bfd_mach_o_filetype
 
113
  {
 
114
    BFD_MACH_O_MH_OBJECT = 1,
 
115
    BFD_MACH_O_MH_EXECUTE = 2,
 
116
    BFD_MACH_O_MH_FVMLIB = 3,
 
117
    BFD_MACH_O_MH_CORE = 4,
 
118
    BFD_MACH_O_MH_PRELOAD = 5,
 
119
    BFD_MACH_O_MH_DYLIB = 6,
 
120
    BFD_MACH_O_MH_DYLINKER = 7,
 
121
    BFD_MACH_O_MH_BUNDLE = 8,
 
122
    BFD_MACH_O_MH_DYLIB_STUB = 9
 
123
  }
 
124
bfd_mach_o_filetype;
 
125
 
 
126
/* Constants for the type of a section.  */
 
127
 
 
128
typedef enum bfd_mach_o_section_type
 
129
  {
 
130
    /* Regular section.  */
 
131
    BFD_MACH_O_S_REGULAR = 0x0,
 
132
 
 
133
    /* Zero fill on demand section.  */
 
134
    BFD_MACH_O_S_ZEROFILL = 0x1,
 
135
 
 
136
    /* Section with only literal C strings.  */
 
137
    BFD_MACH_O_S_CSTRING_LITERALS = 0x2,
 
138
 
 
139
    /* Section with only 4 byte literals.  */
 
140
    BFD_MACH_O_S_4BYTE_LITERALS = 0x3,
 
141
 
 
142
    /* Section with only 8 byte literals.  */
 
143
    BFD_MACH_O_S_8BYTE_LITERALS = 0x4,
 
144
 
 
145
    /* Section with only pointers to literals.  */
 
146
    BFD_MACH_O_S_LITERAL_POINTERS = 0x5,
 
147
 
 
148
    /* For the two types of symbol pointers sections and the symbol stubs
 
149
       section they have indirect symbol table entries.  For each of the
 
150
       entries in the section the indirect symbol table entries, in
 
151
       corresponding order in the indirect symbol table, start at the index
 
152
       stored in the reserved1 field of the section structure.  Since the
 
153
       indirect symbol table entries correspond to the entries in the
 
154
       section the number of indirect symbol table entries is inferred from
 
155
       the size of the section divided by the size of the entries in the
 
156
       section.  For symbol pointers sections the size of the entries in
 
157
       the section is 4 bytes and for symbol stubs sections the byte size
 
158
       of the stubs is stored in the reserved2 field of the section
 
159
       structure.  */
 
160
 
 
161
    /* Section with only non-lazy symbol pointers.  */
 
162
    BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6,
 
163
    BFD_MACH_O_S_NL_SYMBOL_POINTERS = 0x6,
 
164
    
 
165
    /* Section with only lazy symbol pointers.  */
 
166
    BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,
 
167
    BFD_MACH_O_S_LA_SYMBOL_POINTERS = 0x7,
 
168
    
 
169
    /* Section with only symbol stubs, byte size of stub in the reserved2 field.  */
 
170
    BFD_MACH_O_S_SYMBOL_STUBS = 0x8,
 
171
 
 
172
    /* Section with only function pointers for initialization.  */
 
173
    BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS = 0x9
 
174
  }
 
175
bfd_mach_o_section_type;
 
176
 
 
177
/* mask */
 
178
#define BFD_MACH_O_REFERENCE_TYPE 0xf
 
179
 
 
180
typedef enum bfd_mach_o_n_desc
 
181
  {
 
182
 
 
183
    /* This symbol is a reference to an external non-lazy symbol (data).  */
 
184
    BFD_MACH_O_REFERENCE_FLAG_UNDEFINED_NON_LAZY = 0x0,
 
185
    
 
186
    /* This symbol is a reference to an external lazy symbol pointer (function call).  */
 
187
    BFD_MACH_O_REFERENCE_FLAG_UNDEFINED_LAZY = 0x1,
 
188
 
 
189
    /* This symbol is defined in this module.  */
 
190
    BFD_MACH_O_REFERENCE_FLAG_DEFINED = 0x2
 
191
 
 
192
  }
 
193
bfd_mach_o_n_desc;
 
194
 
 
195
typedef unsigned long bfd_mach_o_cpu_subtype;
 
196
 
 
197
typedef struct bfd_mach_o_header
 
198
{
 
199
  unsigned long magic;
 
200
  unsigned long cputype;
 
201
  unsigned long cpusubtype;
 
202
  unsigned long filetype;
 
203
  unsigned long ncmds;
 
204
  unsigned long sizeofcmds;
 
205
  unsigned long flags;
 
206
  enum bfd_endian byteorder;
 
207
}
 
208
bfd_mach_o_header;
 
209
 
 
210
typedef struct bfd_mach_o_section
 
211
{
 
212
  asection *bfdsection;
 
213
  char sectname[16 + 1];
 
214
  char segname[16 + 1];
 
215
  bfd_vma addr;
 
216
  bfd_vma size;
 
217
  bfd_vma offset;
 
218
  unsigned long align;
 
219
  bfd_vma reloff;
 
220
  unsigned long nreloc;
 
221
  unsigned long flags;
 
222
  unsigned long reserved1;
 
223
  unsigned long reserved2;
 
224
}
 
225
bfd_mach_o_section;
 
226
 
 
227
typedef struct bfd_mach_o_segment_command
 
228
{
 
229
  char segname[16];
 
230
  bfd_vma vmaddr;
 
231
  bfd_vma vmsize;
 
232
  bfd_vma fileoff;
 
233
  unsigned long filesize;
 
234
  unsigned long nsects;
 
235
  unsigned long flags;
 
236
  bfd_mach_o_section *sections;
 
237
  asection *segment;
 
238
}
 
239
bfd_mach_o_segment_command;
 
240
 
 
241
typedef struct bfd_mach_o_nlist
 
242
{
 
243
  /* BFD internal representation.  */
 
244
  asymbol root;
 
245
  
 
246
  /* Mach-O representation.  */
 
247
  struct {
 
248
    union {
 
249
      char *n_name;
 
250
      long  n_strx;
 
251
    } n_un;
 
252
    unsigned char n_type;
 
253
    unsigned char n_sect;
 
254
    short n_desc;
 
255
    unsigned long n_value;
 
256
  } nlist;
 
257
 
 
258
  /* Index in input symbol table.  */
 
259
  unsigned long input_index;
 
260
  
 
261
  /* Index in output symbol table.  */
 
262
  unsigned long output_index;
 
263
}
 
264
bfd_mach_o_nlist;
 
265
 
 
266
typedef struct bfd_mach_o_symtab_command
 
267
{
 
268
  unsigned long symoff;
 
269
  unsigned long nsyms;
 
270
  unsigned long stroff;
 
271
  unsigned long strsize;
 
272
  /*asymbol *symbols;*/
 
273
  bfd_mach_o_nlist *nlists;
 
274
  char *strtab;
 
275
  asection *stabs_segment;
 
276
  asection *stabstr_segment;
 
277
}
 
278
bfd_mach_o_symtab_command;
 
279
 
 
280
/* This is the second set of the symbolic information which is used to support
 
281
   the data structures for the dynamicly link editor.
 
282
 
 
283
   The original set of symbolic information in the symtab_command which contains
 
284
   the symbol and string tables must also be present when this load command is
 
285
   present.  When this load command is present the symbol table is organized
 
286
   into three groups of symbols:
 
287
       local symbols (static and debugging symbols) - grouped by module
 
288
       defined external symbols - grouped by module (sorted by name if not lib)
 
289
       undefined external symbols (sorted by name)
 
290
   In this load command there are offsets and counts to each of the three groups
 
291
   of symbols.
 
292
 
 
293
   This load command contains a the offsets and sizes of the following new
 
294
   symbolic information tables:
 
295
       table of contents
 
296
       module table
 
297
       reference symbol table
 
298
       indirect symbol table
 
299
   The first three tables above (the table of contents, module table and
 
300
   reference symbol table) are only present if the file is a dynamicly linked
 
301
   shared library.  For executable and object modules, which are files
 
302
   containing only one module, the information that would be in these three
 
303
   tables is determined as follows:
 
304
       table of contents - the defined external symbols are sorted by name
 
305
       module table - the file contains only one module so everything in the
 
306
                      file is part of the module.
 
307
       reference symbol table - is the defined and undefined external symbols
 
308
 
 
309
   For dynamicly linked shared library files this load command also contains
 
310
   offsets and sizes to the pool of relocation entries for all sections
 
311
   separated into two groups:
 
312
       external relocation entries
 
313
       local relocation entries
 
314
   For executable and object modules the relocation entries continue to hang
 
315
   off the section structures.  */
 
316
 
 
317
typedef struct bfd_mach_o_dysymtab_command
 
318
{
 
319
  /* The symbols indicated by symoff and nsyms of the LC_SYMTAB load command
 
320
     are grouped into the following three groups:
 
321
       local symbols (further grouped by the module they are from)
 
322
       defined external symbols (further grouped by the module they are from)
 
323
       undefined symbols
 
324
 
 
325
     The local symbols are used only for debugging.  The dynamic binding
 
326
     process may have to use them to indicate to the debugger the local
 
327
     symbols for a module that is being bound.
 
328
 
 
329
     The last two groups are used by the dynamic binding process to do the
 
330
     binding (indirectly through the module table and the reference symbol
 
331
     table when this is a dynamicly linked shared library file).  */
 
332
 
 
333
  unsigned long ilocalsym;    /* Index to local symbols.  */
 
334
  unsigned long nlocalsym;    /* Number of local symbols.  */
 
335
  unsigned long iextdefsym;   /* Index to externally defined symbols.  */
 
336
  unsigned long nextdefsym;   /* Number of externally defined symbols.  */
 
337
  unsigned long iundefsym;    /* Index to undefined symbols.  */
 
338
  unsigned long nundefsym;    /* Number of undefined symbols.  */
 
339
 
 
340
  /* For the for the dynamic binding process to find which module a symbol
 
341
     is defined in the table of contents is used (analogous to the ranlib
 
342
     structure in an archive) which maps defined external symbols to modules
 
343
     they are defined in.  This exists only in a dynamicly linked shared
 
344
     library file.  For executable and object modules the defined external
 
345
     symbols are sorted by name and is use as the table of contents.  */
 
346
 
 
347
  unsigned long tocoff;       /* File offset to table of contents.  */
 
348
  unsigned long ntoc;         /* Number of entries in table of contents.  */
 
349
 
 
350
  /* To support dynamic binding of "modules" (whole object files) the symbol
 
351
     table must reflect the modules that the file was created from.  This is
 
352
     done by having a module table that has indexes and counts into the merged
 
353
     tables for each module.  The module structure that these two entries
 
354
     refer to is described below.  This exists only in a dynamicly linked
 
355
     shared library file.  For executable and object modules the file only
 
356
     contains one module so everything in the file belongs to the module.  */
 
357
 
 
358
  unsigned long modtaboff;    /* File offset to module table.  */
 
359
  unsigned long nmodtab;      /* Number of module table entries.  */
 
360
 
 
361
  /* To support dynamic module binding the module structure for each module
 
362
     indicates the external references (defined and undefined) each module
 
363
     makes.  For each module there is an offset and a count into the
 
364
     reference symbol table for the symbols that the module references.
 
365
     This exists only in a dynamicly linked shared library file.  For
 
366
     executable and object modules the defined external symbols and the
 
367
     undefined external symbols indicates the external references.  */
 
368
 
 
369
  unsigned long extrefsymoff;  /* Offset to referenced symbol table.  */
 
370
  unsigned long nextrefsyms;   /* Number of referenced symbol table entries.  */
 
371
 
 
372
  /* The sections that contain "symbol pointers" and "routine stubs" have
 
373
     indexes and (implied counts based on the size of the section and fixed
 
374
     size of the entry) into the "indirect symbol" table for each pointer
 
375
     and stub.  For every section of these two types the index into the
 
376
     indirect symbol table is stored in the section header in the field
 
377
     reserved1.  An indirect symbol table entry is simply a 32bit index into
 
378
     the symbol table to the symbol that the pointer or stub is referring to.
 
379
     The indirect symbol table is ordered to match the entries in the section.  */
 
380
 
 
381
  unsigned long indirectsymoff; /* File offset to the indirect symbol table.  */
 
382
  unsigned long nindirectsyms;  /* Number of indirect symbol table entries.  */
 
383
 
 
384
  /* To support relocating an individual module in a library file quickly the
 
385
     external relocation entries for each module in the library need to be
 
386
     accessed efficiently.  Since the relocation entries can't be accessed
 
387
     through the section headers for a library file they are separated into
 
388
     groups of local and external entries further grouped by module.  In this
 
389
     case the presents of this load command who's extreloff, nextrel,
 
390
     locreloff and nlocrel fields are non-zero indicates that the relocation
 
391
     entries of non-merged sections are not referenced through the section
 
392
     structures (and the reloff and nreloc fields in the section headers are
 
393
     set to zero).
 
394
 
 
395
     Since the relocation entries are not accessed through the section headers
 
396
     this requires the r_address field to be something other than a section
 
397
     offset to identify the item to be relocated.  In this case r_address is
 
398
     set to the offset from the vmaddr of the first LC_SEGMENT command.
 
399
 
 
400
     The relocation entries are grouped by module and the module table
 
401
     entries have indexes and counts into them for the group of external
 
402
     relocation entries for that the module.
 
403
 
 
404
     For sections that are merged across modules there must not be any
 
405
     remaining external relocation entries for them (for merged sections
 
406
     remaining relocation entries must be local).  */
 
407
 
 
408
  unsigned long extreloff;    /* Offset to external relocation entries.  */
 
409
  unsigned long nextrel;      /* Number of external relocation entries.  */
 
410
 
 
411
  /* All the local relocation entries are grouped together (they are not
 
412
     grouped by their module since they are only used if the object is moved
 
413
     from it staticly link edited address).  */
 
414
 
 
415
  unsigned long locreloff;    /* Offset to local relocation entries.  */
 
416
  unsigned long nlocrel;      /* Number of local relocation entries.  */
 
417
}
 
418
bfd_mach_o_dysymtab_command;
 
419
 
 
420
/* An indirect symbol table entry is simply a 32bit index into the symbol table
 
421
   to the symbol that the pointer or stub is refering to.  Unless it is for a
 
422
   non-lazy symbol pointer section for a defined symbol which strip(1) as
 
423
   removed.  In which case it has the value INDIRECT_SYMBOL_LOCAL.  If the
 
424
   symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that.  */
 
425
 
 
426
#define INDIRECT_SYMBOL_LOCAL 0x80000000
 
427
#define INDIRECT_SYMBOL_ABS   0x40000000
 
428
 
 
429
typedef struct bfd_mach_o_thread_flavour
 
430
{
 
431
  unsigned long flavour;
 
432
  bfd_vma offset;
 
433
  unsigned long size;
 
434
}
 
435
bfd_mach_o_thread_flavour;
 
436
 
 
437
typedef struct bfd_mach_o_thread_command
 
438
{
 
439
  unsigned long nflavours;
 
440
  bfd_mach_o_thread_flavour *flavours;
 
441
  asection *section;
 
442
}
 
443
bfd_mach_o_thread_command;
 
444
 
 
445
typedef struct bfd_mach_o_dylinker_command
 
446
{
 
447
  unsigned long cmd;                   /* LC_ID_DYLIB or LC_LOAD_DYLIB.  */
 
448
  unsigned long cmdsize;               /* Includes pathname string.  */
 
449
  unsigned long name_offset;           /* Offset to library's path name.  */
 
450
  unsigned long name_len;              /* Offset to library's path name.  */
 
451
  asection *section;
 
452
}
 
453
bfd_mach_o_dylinker_command;
 
454
 
 
455
typedef struct bfd_mach_o_dylib_command
 
456
{
 
457
  unsigned long cmd;                   /* LC_ID_DYLIB or LC_LOAD_DYLIB.  */
 
458
  unsigned long cmdsize;               /* Includes pathname string.  */
 
459
  unsigned long name_offset;           /* Offset to library's path name.  */
 
460
  unsigned long name_len;              /* Offset to library's path name.  */
 
461
  unsigned long timestamp;             /* Library's build time stamp.  */
 
462
  unsigned long current_version;       /* Library's current version number.  */
 
463
  unsigned long compatibility_version; /* Library's compatibility vers number.  */
 
464
  asection *section;
 
465
}
 
466
bfd_mach_o_dylib_command;
 
467
 
 
468
typedef struct bfd_mach_o_prebound_dylib_command
 
469
{
 
470
  unsigned long cmd;                 /* LC_PREBOUND_DYLIB.  */
 
471
  unsigned long cmdsize;             /* Includes strings.  */
 
472
  unsigned long name;                /* Library's path name.  */
 
473
  unsigned long nmodules;            /* Number of modules in library.  */
 
474
  unsigned long linked_modules;      /* Bit vector of linked modules.  */
 
475
  asection *section;
 
476
}
 
477
bfd_mach_o_prebound_dylib_command;
 
478
 
 
479
typedef struct bfd_mach_o_load_command
 
480
{
 
481
  bfd_mach_o_load_command_type type;
 
482
  unsigned int type_required;
 
483
  bfd_vma offset;
 
484
  bfd_vma len;
 
485
  union
 
486
  {
 
487
    bfd_mach_o_segment_command segment;
 
488
    bfd_mach_o_symtab_command symtab;
 
489
    bfd_mach_o_dysymtab_command dysymtab;
 
490
    bfd_mach_o_thread_command thread;
 
491
    bfd_mach_o_dylib_command dylib;
 
492
    bfd_mach_o_dylinker_command dylinker;
 
493
    bfd_mach_o_prebound_dylib_command prebound_dylib;
 
494
  }
 
495
  command;
 
496
}
 
497
bfd_mach_o_load_command;
 
498
 
 
499
/* Map an indirect symbol table entry to a symbol table entry and vice-versa.  */
 
500
typedef struct {
 
501
 
 
502
  /* Reference to the indirect symbol table entry.  */
 
503
  unsigned long ist_idx;
 
504
 
 
505
  /* Reference to the symbol table entry.  */
 
506
  unsigned long st_idx;
 
507
}
 
508
bfd_mach_o_ist_entry;
 
509
 
 
510
/* Describe the indirect symbol table.  */
 
511
typedef struct {
 
512
 
 
513
  /* Associated LC_DYSYMTAB load command.  */
 
514
  bfd_mach_o_dysymtab_command *command;
 
515
 
 
516
  /* Number of entries in this indirect symbol table.  */
 
517
  unsigned long nmemb;
 
518
 
 
519
  /* Number of BFD_MACH_O_S_SYMBOL_STUB sections in the following array.  */
 
520
  unsigned long nstubs;
 
521
  
 
522
  /* Array of stub sections.  */
 
523
  bfd_mach_o_section **stubs;
 
524
  
 
525
  /* Number of BFD_MACH_O_S_NL_SYMBOL_POINTERS sections in the following array.  */
 
526
  unsigned long nnlptrs;
 
527
 
 
528
  /* Array of non-lazy symbol pointer sections.  */
 
529
  bfd_mach_o_section **nlptrs;
 
530
 
 
531
  /* Number of BFD_MACH_O_S_LA_SYMBOL_POINTERS sections in the following array.  */
 
532
  unsigned long nlaptrs;
 
533
 
 
534
  /* Array of lazy symbol pointer sections.  */
 
535
  bfd_mach_o_section **laptrs;
 
536
 
 
537
  /* Raw indirect symbol table entry, as slurped from the input file.  */
 
538
  bfd_mach_o_ist_entry *raw_ist;
 
539
 
 
540
  /* Indirect symbol table that was sorted by chunks, depending on st_idx.  */
 
541
  bfd_mach_o_ist_entry *sorted_ist;  
 
542
}
 
543
bfd_mach_o_ist;
 
544
 
 
545
typedef struct
 
546
{
 
547
  /* General link information.  */
 
548
  struct bfd_link_info *info;
 
549
 
 
550
  /* Output BFD.  */
 
551
  bfd *output_bfd;
 
552
 
 
553
  /* Buffer large enough to hold contents of any section.  */
 
554
  bfd_byte *contents;
 
555
}
 
556
bfd_mach_o_final_link_info;
 
557
 
 
558
/* This struct is used to pass information to and from bfd_mach_o_link_output_extsym.  */
 
559
typedef struct
 
560
{
 
561
  boolean failed;
 
562
  bfd_mach_o_final_link_info *finfo;
 
563
}
 
564
bfd_mach_o_outext_info;
 
565
 
 
566
/* Mach-O back-end global hash table entries.  */
 
567
// typedef struct {
 
568
//
 
569
//   struct bfd_link_hash_entry root;
 
570
//  
 
571
// }
 
572
// bfd_mach_o_link_hash_entry;
 
573
 
 
574
#define mach_o_tdata(abfd)    ((abfd)->tdata.mach_o_data)
 
575
#define mach_o_symtab(abfd)   (mach_o_tdata(abfd)->st)
 
576
#define mach_o_dysymtab(abfd) (mach_o_tdata(abfd)->dyst)
 
577
 
 
578
#define mach_o_n_type(udata)  (((udata) >> 24) & 0xff)
 
579
#define mach_o_n_sect(udata)  (((udata) >> 16) & 0xff)
 
580
#define mach_o_n_desc(udata)  ((udata) & 0xffff)
 
581
 
 
582
typedef struct mach_o_data_struct
 
583
{
 
584
  bfd_mach_o_header header;
 
585
  bfd_mach_o_load_command *commands;
 
586
  bfd_mach_o_ist *ist;
 
587
  bfd_mach_o_symtab_command *st;
 
588
  bfd_mach_o_dysymtab_command *dyst;
 
589
  unsigned long nsymbols;
 
590
  asymbol *symbols;
 
591
  unsigned long nsects;
 
592
  bfd_mach_o_section **sections;
 
593
  bfd *ibfd;
 
594
}
 
595
mach_o_data_struct;
 
596
 
 
597
typedef struct mach_o_data_struct bfd_mach_o_data_struct;
 
598
 
 
599
boolean bfd_mach_o_valid
 
600
  PARAMS ((bfd *));
 
601
int bfd_mach_o_scan_read_symtab_symbol
 
602
/*PARAMS ((bfd *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));*/
 
603
  PARAMS ((bfd *, bfd_mach_o_symtab_command *,
 
604
           bfd_mach_o_nlist *, unsigned long));
 
605
int bfd_mach_o_scan_read_symtab_strtab
 
606
  PARAMS ((bfd *, bfd_mach_o_symtab_command *));
 
607
int bfd_mach_o_scan_read_symtab_symbols
 
608
  PARAMS ((bfd *, bfd_mach_o_symtab_command *));
 
609
int bfd_mach_o_scan_read_dysymtab_symbol
 
610
  PARAMS ((bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *,
 
611
           bfd_mach_o_nlist */*asymbol **/, unsigned long));
 
612
int bfd_mach_o_scan_start_address
 
613
  PARAMS ((bfd *));
 
614
int bfd_mach_o_scan
 
615
  PARAMS ((bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *));
 
616
boolean bfd_mach_o_mkobject
 
617
  PARAMS ((bfd *));
 
618
const bfd_target * bfd_mach_o_object_p
 
619
  PARAMS ((bfd *));
 
620
const bfd_target * bfd_mach_o_core_p
 
621
  PARAMS ((bfd *));
 
622
const bfd_target * bfd_mach_o_archive_p
 
623
  PARAMS ((bfd *));
 
624
bfd * bfd_mach_o_openr_next_archived_file
 
625
  PARAMS ((bfd *, bfd *));
 
626
int bfd_mach_o_lookup_section
 
627
  PARAMS ((bfd *, asection *, bfd_mach_o_load_command **,
 
628
           bfd_mach_o_section **));
 
629
int bfd_mach_o_lookup_command
 
630
  PARAMS ((bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **));
 
631
unsigned long bfd_mach_o_stack_addr
 
632
  PARAMS ((enum bfd_mach_o_cpu_type));
 
633
int bfd_mach_o_core_fetch_environment
 
634
  PARAMS ((bfd *, unsigned char **, unsigned int *));
 
635
char * bfd_mach_o_core_file_failing_command
 
636
  PARAMS ((bfd *));
 
637
int bfd_mach_o_core_file_failing_signal
 
638
  PARAMS ((bfd *));
 
639
boolean bfd_mach_o_core_file_matches_executable_p
 
640
  PARAMS ((bfd *, bfd *));
 
641
 
 
642
extern const bfd_target mach_o_be_vec;
 
643
extern const bfd_target mach_o_le_vec;
 
644
extern const bfd_target mach_o_fat_vec;
 
645
 
 
646
struct bfd_preserve
 
647
{
 
648
  PTR marker;
 
649
  PTR tdata;
 
650
  flagword flags;
 
651
  const struct bfd_arch_info *arch_info;
 
652
  struct sec *sections;
 
653
  struct sec **section_tail;
 
654
  unsigned int section_count;
 
655
  struct bfd_hash_table section_htab;
 
656
};
 
657
 
 
658
boolean
 
659
bfd_preserve_save PARAMS ((bfd *, struct bfd_preserve *));
 
660
 
 
661
void
 
662
bfd_preserve_restore PARAMS ((bfd *, struct bfd_preserve *));
 
663
 
 
664
void
 
665
bfd_preserve_finish PARAMS ((bfd *, struct bfd_preserve *));
 
666
 
 
667
#endif /* _BFD_MACH_O_H_ */