Back to index

cell-binutils  2.17cvs20070401
libcoff.h
Go to the documentation of this file.
00001 /* DO NOT EDIT!  -*- buffer-read-only: t -*-  This file is automatically 
00002    generated from "libcoff-in.h" and "coffcode.h".
00003    Run "make headers" in your build bfd/ to regenerate.  */
00004 
00005 /* BFD COFF object file private structure.
00006    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
00007    2000, 2001, 2002, 2003, 2004, 2005, 2006
00008    Free Software Foundation, Inc.
00009    Written by Cygnus Support.
00010 
00011    This file is part of BFD, the Binary File Descriptor library.
00012 
00013    This program is free software; you can redistribute it and/or modify
00014    it under the terms of the GNU General Public License as published by
00015    the Free Software Foundation; either version 2 of the License, or
00016    (at your option) any later version.
00017 
00018    This program is distributed in the hope that it will be useful,
00019    but WITHOUT ANY WARRANTY; without even the implied warranty of
00020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021    GNU General Public License for more details.
00022 
00023    You should have received a copy of the GNU General Public License
00024    along with this program; if not, write to the Free Software
00025    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00026 
00027 #include "bfdlink.h"
00028 
00029 /* Object file tdata; access macros.  */
00030 
00031 #define coff_data(bfd)                   ((bfd)->tdata.coff_obj_data)
00032 #define exec_hdr(bfd)                    (coff_data (bfd)->hdr)
00033 #define obj_pe(bfd)                   (coff_data (bfd)->pe)
00034 #define obj_symbols(bfd)          (coff_data (bfd)->symbols)
00035 #define       obj_sym_filepos(bfd)       (coff_data (bfd)->sym_filepos)
00036 #define obj_relocbase(bfd)        (coff_data (bfd)->relocbase)
00037 #define obj_raw_syments(bfd)             (coff_data (bfd)->raw_syments)
00038 #define obj_raw_syment_count(bfd)     (coff_data (bfd)->raw_syment_count)
00039 #define obj_convert(bfd)          (coff_data (bfd)->conversion_table)
00040 #define obj_conv_table_size(bfd)      (coff_data (bfd)->conv_table_size)
00041 #define obj_coff_external_syms(bfd)   (coff_data (bfd)->external_syms)
00042 #define obj_coff_keep_syms(bfd)          (coff_data (bfd)->keep_syms)
00043 #define obj_coff_strings(bfd)            (coff_data (bfd)->strings)
00044 #define obj_coff_keep_strings(bfd)    (coff_data (bfd)->keep_strings)
00045 #define obj_coff_sym_hashes(bfd)      (coff_data (bfd)->sym_hashes)
00046 #define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written)
00047 #define obj_coff_local_toc_table(bfd) (coff_data (bfd)->local_toc_sym_map)
00048 
00049 /* `Tdata' information kept for COFF files.  */
00050 
00051 typedef struct coff_tdata
00052 {
00053   struct coff_symbol_struct *symbols;     /* Symtab for input bfd.  */
00054   unsigned int *conversion_table;
00055   int conv_table_size;
00056   file_ptr sym_filepos;
00057 
00058   struct coff_ptr_struct *raw_syments;
00059   unsigned long raw_syment_count;
00060 
00061   /* These are only valid once writing has begun.  */
00062   long int relocbase;
00063 
00064   /* These members communicate important constants about the symbol table
00065      to GDB's symbol-reading code.  These `constants' unfortunately vary
00066      from coff implementation to implementation...  */
00067   unsigned local_n_btmask;
00068   unsigned local_n_btshft;
00069   unsigned local_n_tmask;
00070   unsigned local_n_tshift;
00071   unsigned local_symesz;
00072   unsigned local_auxesz;
00073   unsigned local_linesz;
00074 
00075   /* The unswapped external symbols.  May be NULL.  Read by
00076      _bfd_coff_get_external_symbols.  */
00077   void * external_syms;
00078   /* If this is TRUE, the external_syms may not be freed.  */
00079   bfd_boolean keep_syms;
00080 
00081   /* The string table.  May be NULL.  Read by
00082      _bfd_coff_read_string_table.  */
00083   char *strings;
00084   /* If this is TRUE, the strings may not be freed.  */
00085   bfd_boolean keep_strings;
00086   /* If this is TRUE, the strings have been written out already.  */
00087   bfd_boolean strings_written;
00088 
00089   /* Is this a PE format coff file?  */
00090   int pe;
00091   /* Used by the COFF backend linker.  */
00092   struct coff_link_hash_entry **sym_hashes;
00093 
00094   /* Used by the pe linker for PowerPC.  */
00095   int *local_toc_sym_map;
00096 
00097   struct bfd_link_info *link_info;
00098 
00099   /* Used by coff_find_nearest_line.  */
00100   void * line_info;
00101 
00102   /* A place to stash dwarf2 info for this bfd.  */
00103   void * dwarf2_find_line_info;
00104 
00105   /* The timestamp from the COFF file header.  */
00106   long timestamp;
00107 
00108   /* Copy of some of the f_flags bits in the COFF filehdr structure,
00109      used by ARM code.  */
00110   flagword flags;
00111 
00112 } coff_data_type;
00113 
00114 /* Tdata for pe image files.  */
00115 typedef struct pe_tdata
00116 {
00117   coff_data_type coff;
00118   struct internal_extra_pe_aouthdr pe_opthdr;
00119   int dll;
00120   int has_reloc_section;
00121   bfd_boolean (*in_reloc_p) (bfd *, reloc_howto_type *);
00122   flagword real_flags;
00123   int target_subsystem;
00124   bfd_boolean force_minimum_alignment;
00125 } pe_data_type;
00126 
00127 #define pe_data(bfd)        ((bfd)->tdata.pe_obj_data)
00128 
00129 /* Tdata for XCOFF files.  */
00130 
00131 struct xcoff_tdata
00132 {
00133   /* Basic COFF information.  */
00134   coff_data_type coff;
00135 
00136   /* TRUE if this is an XCOFF64 file. */
00137   bfd_boolean xcoff64;
00138 
00139   /* TRUE if a large a.out header should be generated.  */
00140   bfd_boolean full_aouthdr;
00141 
00142   /* TOC value.  */
00143   bfd_vma toc;
00144 
00145   /* Index of section holding TOC.  */
00146   int sntoc;
00147 
00148   /* Index of section holding entry point.  */
00149   int snentry;
00150 
00151   /* .text alignment from optional header.  */
00152   int text_align_power;
00153 
00154   /* .data alignment from optional header.  */
00155   int data_align_power;
00156 
00157   /* modtype from optional header.  */
00158   short modtype;
00159 
00160   /* cputype from optional header.  */
00161   short cputype;
00162 
00163   /* maxdata from optional header.  */
00164   bfd_vma maxdata;
00165 
00166   /* maxstack from optional header.  */
00167   bfd_vma maxstack;
00168 
00169   /* Used by the XCOFF backend linker.  */
00170   asection **csects;
00171   unsigned long *debug_indices;
00172   unsigned int import_file_id;
00173 };
00174 
00175 #define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
00176 
00177 /* We take the address of the first element of an asymbol to ensure that the
00178    macro is only ever applied to an asymbol.  */
00179 #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
00180 
00181 /* The used_by_bfd field of a section may be set to a pointer to this
00182    structure.  */
00183 
00184 struct coff_section_tdata
00185 {
00186   /* The relocs, swapped into COFF internal form.  This may be NULL.  */
00187   struct internal_reloc *relocs;
00188   /* If this is TRUE, the relocs entry may not be freed.  */
00189   bfd_boolean keep_relocs;
00190   /* The section contents.  This may be NULL.  */
00191   bfd_byte *contents;
00192   /* If this is TRUE, the contents entry may not be freed.  */
00193   bfd_boolean keep_contents;
00194   /* Information cached by coff_find_nearest_line.  */
00195   bfd_vma offset;
00196   unsigned int i;
00197   const char *function;
00198   /* Optional information about a COMDAT entry; NULL if not COMDAT. */
00199   struct coff_comdat_info *comdat;
00200   int line_base;
00201   /* A pointer used for .stab linking optimizations.  */
00202   void * stab_info;
00203   /* Available for individual backends.  */
00204   void * tdata;
00205 };
00206 
00207 /* An accessor macro for the coff_section_tdata structure.  */
00208 #define coff_section_data(abfd, sec) \
00209   ((struct coff_section_tdata *) (sec)->used_by_bfd)
00210 
00211 /* Tdata for sections in XCOFF files.  This is used by the linker.  */
00212 
00213 struct xcoff_section_tdata
00214 {
00215   /* Used for XCOFF csects created by the linker; points to the real
00216      XCOFF section which contains this csect.  */
00217   asection *enclosing;
00218   /* The lineno_count field for the enclosing section, because we are
00219      going to clobber it there.  */
00220   unsigned int lineno_count;
00221   /* The first and one past the last symbol indices for symbols used
00222      by this csect.  */
00223   unsigned long first_symndx;
00224   unsigned long last_symndx;
00225 };
00226 
00227 /* An accessor macro the xcoff_section_tdata structure.  */
00228 #define xcoff_section_data(abfd, sec) \
00229   ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
00230 
00231 /* Tdata for sections in PE files.  */
00232 
00233 struct pei_section_tdata
00234 {
00235   /* The virtual size of the section.  */
00236   bfd_size_type virt_size;
00237   /* The PE section flags.  */
00238   long pe_flags;
00239 };
00240 
00241 /* An accessor macro for the pei_section_tdata structure.  */
00242 #define pei_section_data(abfd, sec) \
00243   ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
00244 
00245 /* COFF linker hash table entries.  */
00246 
00247 struct coff_link_hash_entry
00248 {
00249   struct bfd_link_hash_entry root;
00250 
00251   /* Symbol index in output file.  Set to -1 initially.  Set to -2 if
00252      there is a reloc against this symbol.  */
00253   long indx;
00254 
00255   /* Symbol type.  */
00256   unsigned short type;
00257 
00258   /* Symbol class.  */
00259   unsigned char class;
00260 
00261   /* Number of auxiliary entries.  */
00262   char numaux;
00263 
00264   /* BFD to take auxiliary entries from.  */
00265   bfd *auxbfd;
00266 
00267   /* Pointer to array of auxiliary entries, if any.  */
00268   union internal_auxent *aux;
00269 
00270   /* Flag word; legal values follow.  */
00271   unsigned short coff_link_hash_flags;
00272   /* Symbol is a PE section symbol.  */
00273 #define COFF_LINK_HASH_PE_SECTION_SYMBOL (01)
00274 };
00275 
00276 /* COFF linker hash table.  */
00277 
00278 struct coff_link_hash_table
00279 {
00280   struct bfd_link_hash_table root;
00281   /* A pointer to information used to link stabs in sections.  */
00282   struct stab_info stab_info;
00283 };
00284 
00285 /* Look up an entry in a COFF linker hash table.  */
00286 
00287 #define coff_link_hash_lookup(table, string, create, copy, follow)    \
00288   ((struct coff_link_hash_entry *)                             \
00289    bfd_link_hash_lookup (&(table)->root, (string), (create),          \
00290                       (copy), (follow)))
00291 
00292 /* Traverse a COFF linker hash table.  */
00293 
00294 #define coff_link_hash_traverse(table, func, info)                    \
00295   (bfd_link_hash_traverse                                      \
00296    (&(table)->root,                                            \
00297     (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func), \
00298     (info)))
00299 
00300 /* Get the COFF linker hash table from a link_info structure.  */
00301 
00302 #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
00303 
00304 /* Functions in coffgen.c.  */
00305 extern const bfd_target *coff_object_p
00306   (bfd *);
00307 extern struct bfd_section *coff_section_from_bfd_index
00308   (bfd *, int);
00309 extern long coff_get_symtab_upper_bound
00310   (bfd *);
00311 extern long coff_canonicalize_symtab
00312   (bfd *, asymbol **);
00313 extern int coff_count_linenumbers
00314   (bfd *);
00315 extern struct coff_symbol_struct *coff_symbol_from
00316   (bfd *, asymbol *);
00317 extern bfd_boolean coff_renumber_symbols
00318   (bfd *, int *);
00319 extern void coff_mangle_symbols
00320   (bfd *);
00321 extern bfd_boolean coff_write_symbols
00322   (bfd *);
00323 extern bfd_boolean coff_write_linenumbers
00324   (bfd *);
00325 extern alent *coff_get_lineno
00326   (bfd *, asymbol *);
00327 extern asymbol *coff_section_symbol
00328   (bfd *, char *);
00329 extern bfd_boolean _bfd_coff_get_external_symbols
00330   (bfd *);
00331 extern const char *_bfd_coff_read_string_table
00332   (bfd *);
00333 extern bfd_boolean _bfd_coff_free_symbols
00334   (bfd *);
00335 extern struct coff_ptr_struct *coff_get_normalized_symtab
00336   (bfd *);
00337 extern long coff_get_reloc_upper_bound
00338   (bfd *, sec_ptr);
00339 extern asymbol *coff_make_empty_symbol
00340   (bfd *);
00341 extern void coff_print_symbol
00342   (bfd *, void * filep, asymbol *, bfd_print_symbol_type);
00343 extern void coff_get_symbol_info
00344   (bfd *, asymbol *, symbol_info *ret);
00345 extern bfd_boolean _bfd_coff_is_local_label_name
00346   (bfd *, const char *);
00347 extern asymbol *coff_bfd_make_debug_symbol
00348   (bfd *, void *, unsigned long);
00349 extern bfd_boolean coff_find_nearest_line
00350   (bfd *, asection *, asymbol **, bfd_vma, const char **,
00351    const char **, unsigned int *);
00352 extern bfd_boolean coff_find_inliner_info
00353   (bfd *, const char **, const char **, unsigned int *);
00354 extern int coff_sizeof_headers
00355   (bfd *, struct bfd_link_info *);
00356 extern bfd_boolean bfd_coff_reloc16_relax_section
00357   (bfd *, asection *, struct bfd_link_info *, bfd_boolean *);
00358 extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
00359   (bfd *, struct bfd_link_info *, struct bfd_link_order *,
00360    bfd_byte *, bfd_boolean, asymbol **);
00361 extern bfd_vma bfd_coff_reloc16_get_value
00362   (arelent *, struct bfd_link_info *, asection *);
00363 extern void bfd_perform_slip
00364   (bfd *, unsigned int, asection *, bfd_vma);
00365 
00366 /* Functions and types in cofflink.c.  */
00367 
00368 #define STRING_SIZE_SIZE 4
00369 
00370 /* We use a hash table to merge identical enum, struct, and union
00371    definitions in the linker.  */
00372 
00373 /* Information we keep for a single element (an enum value, a
00374    structure or union field) in the debug merge hash table.  */
00375 
00376 struct coff_debug_merge_element
00377 {
00378   /* Next element.  */
00379   struct coff_debug_merge_element *next;
00380 
00381   /* Name.  */
00382   const char *name;
00383 
00384   /* Type.  */
00385   unsigned int type;
00386 
00387   /* Symbol index for complex type.  */
00388   long tagndx;
00389 };
00390 
00391 /* A linked list of debug merge entries for a given name.  */
00392 
00393 struct coff_debug_merge_type
00394 {
00395   /* Next type with the same name.  */
00396   struct coff_debug_merge_type *next;
00397 
00398   /* Class of type.  */
00399   int class;
00400 
00401   /* Symbol index where this type is defined.  */
00402   long indx;
00403 
00404   /* List of elements.  */
00405   struct coff_debug_merge_element *elements;
00406 };
00407 
00408 /* Information we store in the debug merge hash table.  */
00409 
00410 struct coff_debug_merge_hash_entry
00411 {
00412   struct bfd_hash_entry root;
00413 
00414   /* A list of types with this name.  */
00415   struct coff_debug_merge_type *types;
00416 };
00417 
00418 /* The debug merge hash table.  */
00419 
00420 struct coff_debug_merge_hash_table
00421 {
00422   struct bfd_hash_table root;
00423 };
00424 
00425 /* Initialize a COFF debug merge hash table.  */
00426 
00427 #define coff_debug_merge_hash_table_init(table) \
00428   (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \
00429                      sizeof (struct coff_debug_merge_hash_entry)))
00430 
00431 /* Free a COFF debug merge hash table.  */
00432 
00433 #define coff_debug_merge_hash_table_free(table) \
00434   (bfd_hash_table_free (&(table)->root))
00435 
00436 /* Look up an entry in a COFF debug merge hash table.  */
00437 
00438 #define coff_debug_merge_hash_lookup(table, string, create, copy) \
00439   ((struct coff_debug_merge_hash_entry *) \
00440    bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
00441 
00442 /* Information we keep for each section in the output file when doing
00443    a relocatable link.  */
00444 
00445 struct coff_link_section_info
00446 {
00447   /* The relocs to be output.  */
00448   struct internal_reloc *relocs;
00449   /* For each reloc against a global symbol whose index was not known
00450      when the reloc was handled, the global hash table entry.  */
00451   struct coff_link_hash_entry **rel_hashes;
00452 };
00453 
00454 /* Information that we pass around while doing the final link step.  */
00455 
00456 struct coff_final_link_info
00457 {
00458   /* General link information.  */
00459   struct bfd_link_info *info;
00460   /* Output BFD.  */
00461   bfd *output_bfd;
00462   /* Used to indicate failure in traversal routine.  */
00463   bfd_boolean failed;
00464   /* If doing "task linking" set only during the time when we want the
00465      global symbol writer to convert the storage class of defined global
00466      symbols from global to static. */
00467   bfd_boolean global_to_static;
00468   /* Hash table for long symbol names.  */
00469   struct bfd_strtab_hash *strtab;
00470   /* When doing a relocatable link, an array of information kept for
00471      each output section, indexed by the target_index field.  */
00472   struct coff_link_section_info *section_info;
00473   /* Symbol index of last C_FILE symbol (-1 if none).  */
00474   long last_file_index;
00475   /* Contents of last C_FILE symbol.  */
00476   struct internal_syment last_file;
00477   /* Symbol index of first aux entry of last .bf symbol with an empty
00478      endndx field (-1 if none).  */
00479   long last_bf_index;
00480   /* Contents of last_bf_index aux entry.  */
00481   union internal_auxent last_bf;
00482   /* Hash table used to merge debug information.  */
00483   struct coff_debug_merge_hash_table debug_merge;
00484   /* Buffer large enough to hold swapped symbols of any input file.  */
00485   struct internal_syment *internal_syms;
00486   /* Buffer large enough to hold sections of symbols of any input file.  */
00487   asection **sec_ptrs;
00488   /* Buffer large enough to hold output indices of symbols of any
00489      input file.  */
00490   long *sym_indices;
00491   /* Buffer large enough to hold output symbols for any input file.  */
00492   bfd_byte *outsyms;
00493   /* Buffer large enough to hold external line numbers for any input
00494      section.  */
00495   bfd_byte *linenos;
00496   /* Buffer large enough to hold any input section.  */
00497   bfd_byte *contents;
00498   /* Buffer large enough to hold external relocs of any input section.  */
00499   bfd_byte *external_relocs;
00500   /* Buffer large enough to hold swapped relocs of any input section.  */
00501   struct internal_reloc *internal_relocs;
00502 };
00503 
00504 /* Most COFF variants have no way to record the alignment of a
00505    section.  This struct is used to set a specific alignment based on
00506    the name of the section.  */
00507 
00508 struct coff_section_alignment_entry
00509 {
00510   /* The section name.  */
00511   const char *name;
00512 
00513   /* This is either (unsigned int) -1, indicating that the section
00514      name must match exactly, or it is the number of letters which
00515      must match at the start of the name.  */
00516   unsigned int comparison_length;
00517 
00518   /* These macros may be used to fill in the first two fields in a
00519      structure initialization.  */
00520 #define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1)
00521 #define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1)
00522 
00523   /* Only use this entry if the default section alignment for this
00524      target is at least that much (as a power of two).  If this field
00525      is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored.  */
00526   unsigned int default_alignment_min;
00527 
00528   /* Only use this entry if the default section alignment for this
00529      target is no greater than this (as a power of two).  If this
00530      field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored.  */
00531   unsigned int default_alignment_max;
00532 
00533 #define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1)
00534 
00535   /* The desired alignment for this section (as a power of two).  */
00536   unsigned int alignment_power;
00537 };
00538 
00539 extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
00540   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
00541 extern bfd_boolean _bfd_coff_link_hash_table_init
00542   (struct coff_link_hash_table *, bfd *,
00543    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
00544                             struct bfd_hash_table *,
00545                             const char *),
00546    unsigned int);
00547 extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
00548   (bfd *);
00549 extern const char *_bfd_coff_internal_syment_name
00550   (bfd *, const struct internal_syment *, char *);
00551 extern bfd_boolean _bfd_coff_link_add_symbols
00552   (bfd *, struct bfd_link_info *);
00553 extern bfd_boolean _bfd_coff_final_link
00554   (bfd *, struct bfd_link_info *);
00555 extern struct internal_reloc *_bfd_coff_read_internal_relocs
00556   (bfd *, asection *, bfd_boolean, bfd_byte *, bfd_boolean,
00557    struct internal_reloc *);
00558 extern bfd_boolean _bfd_coff_generic_relocate_section
00559   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
00560    struct internal_reloc *, struct internal_syment *, asection **);
00561 extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
00562   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
00563 extern bfd_boolean _bfd_coff_write_global_sym
00564   (struct coff_link_hash_entry *, void *);
00565 extern bfd_boolean _bfd_coff_write_task_globals
00566   (struct coff_link_hash_entry *, void *);
00567 extern bfd_boolean _bfd_coff_link_input_bfd
00568   (struct coff_final_link_info *, bfd *);
00569 extern bfd_boolean _bfd_coff_reloc_link_order
00570   (bfd *, struct coff_final_link_info *, asection *,
00571    struct bfd_link_order *);
00572 
00573 
00574 #define coff_get_section_contents_in_window \
00575   _bfd_generic_get_section_contents_in_window
00576 
00577 /* Functions in xcofflink.c.  */
00578 
00579 extern long _bfd_xcoff_get_dynamic_symtab_upper_bound
00580   (bfd *);
00581 extern long _bfd_xcoff_canonicalize_dynamic_symtab
00582   (bfd *, asymbol **);
00583 extern long _bfd_xcoff_get_dynamic_reloc_upper_bound
00584   (bfd *);
00585 extern long _bfd_xcoff_canonicalize_dynamic_reloc
00586   (bfd *, arelent **, asymbol **);
00587 extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
00588   (bfd *);
00589 extern void _bfd_xcoff_bfd_link_hash_table_free
00590   (struct bfd_link_hash_table *);
00591 extern bfd_boolean _bfd_xcoff_bfd_link_add_symbols
00592   (bfd *, struct bfd_link_info *);
00593 extern bfd_boolean _bfd_xcoff_bfd_final_link
00594   (bfd *, struct bfd_link_info *);
00595 extern bfd_boolean _bfd_ppc_xcoff_relocate_section
00596   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
00597    struct internal_reloc *, struct internal_syment *, asection **);
00598 
00599 /* Functions in coff-ppc.c.  FIXME: These are called be pe.em in the
00600    linker, and so should start with bfd and be declared in bfd.h.  */
00601 
00602 extern bfd_boolean ppc_allocate_toc_section
00603   (struct bfd_link_info *);
00604 extern bfd_boolean ppc_process_before_allocation
00605   (bfd *, struct bfd_link_info *);
00606 
00607 /* Extracted from coffcode.h.  */
00608 typedef struct coff_ptr_struct
00609 {
00610   /* Remembers the offset from the first symbol in the file for
00611      this symbol. Generated by coff_renumber_symbols. */
00612   unsigned int offset;
00613 
00614   /* Should the value of this symbol be renumbered.  Used for
00615      XCOFF C_BSTAT symbols.  Set by coff_slurp_symbol_table.  */
00616   unsigned int fix_value : 1;
00617 
00618   /* Should the tag field of this symbol be renumbered.
00619      Created by coff_pointerize_aux. */
00620   unsigned int fix_tag : 1;
00621 
00622   /* Should the endidx field of this symbol be renumbered.
00623      Created by coff_pointerize_aux. */
00624   unsigned int fix_end : 1;
00625 
00626   /* Should the x_csect.x_scnlen field be renumbered.
00627      Created by coff_pointerize_aux. */
00628   unsigned int fix_scnlen : 1;
00629 
00630   /* Fix up an XCOFF C_BINCL/C_EINCL symbol.  The value is the
00631      index into the line number entries.  Set by coff_slurp_symbol_table.  */
00632   unsigned int fix_line : 1;
00633 
00634   /* The container for the symbol structure as read and translated
00635      from the file. */
00636   union
00637   {
00638     union internal_auxent auxent;
00639     struct internal_syment syment;
00640   } u;
00641 } combined_entry_type;
00642 
00643 
00644 /* Each canonical asymbol really looks like this: */
00645 
00646 typedef struct coff_symbol_struct
00647 {
00648   /* The actual symbol which the rest of BFD works with */
00649   asymbol symbol;
00650 
00651   /* A pointer to the hidden information for this symbol */
00652   combined_entry_type *native;
00653 
00654   /* A pointer to the linenumber information for this symbol */
00655   struct lineno_cache_entry *lineno;
00656 
00657   /* Have the line numbers been relocated yet ? */
00658   bfd_boolean done_lineno;
00659 } coff_symbol_type;
00660 /* COFF symbol classifications.  */
00661 
00662 enum coff_symbol_classification
00663 {
00664   /* Global symbol.  */
00665   COFF_SYMBOL_GLOBAL,
00666   /* Common symbol.  */
00667   COFF_SYMBOL_COMMON,
00668   /* Undefined symbol.  */
00669   COFF_SYMBOL_UNDEFINED,
00670   /* Local symbol.  */
00671   COFF_SYMBOL_LOCAL,
00672   /* PE section symbol.  */
00673   COFF_SYMBOL_PE_SECTION
00674 };
00675 
00676 typedef struct
00677 {
00678   void (*_bfd_coff_swap_aux_in)
00679     (bfd *, void *, int, int, int, int, void *);
00680 
00681   void (*_bfd_coff_swap_sym_in)
00682     (bfd *, void *, void *);
00683 
00684   void (*_bfd_coff_swap_lineno_in)
00685     (bfd *, void *, void *);
00686 
00687   unsigned int (*_bfd_coff_swap_aux_out)
00688     (bfd *, void *, int, int, int, int, void *);
00689 
00690   unsigned int (*_bfd_coff_swap_sym_out)
00691     (bfd *, void *, void *);
00692 
00693   unsigned int (*_bfd_coff_swap_lineno_out)
00694     (bfd *, void *, void *);
00695 
00696   unsigned int (*_bfd_coff_swap_reloc_out)
00697     (bfd *, void *, void *);
00698 
00699   unsigned int (*_bfd_coff_swap_filehdr_out)
00700     (bfd *, void *, void *);
00701 
00702   unsigned int (*_bfd_coff_swap_aouthdr_out)
00703     (bfd *, void *, void *);
00704 
00705   unsigned int (*_bfd_coff_swap_scnhdr_out)
00706     (bfd *, void *, void *);
00707 
00708   unsigned int _bfd_filhsz;
00709   unsigned int _bfd_aoutsz;
00710   unsigned int _bfd_scnhsz;
00711   unsigned int _bfd_symesz;
00712   unsigned int _bfd_auxesz;
00713   unsigned int _bfd_relsz;
00714   unsigned int _bfd_linesz;
00715   unsigned int _bfd_filnmlen;
00716   bfd_boolean _bfd_coff_long_filenames;
00717   bfd_boolean _bfd_coff_long_section_names;
00718   unsigned int _bfd_coff_default_section_alignment_power;
00719   bfd_boolean _bfd_coff_force_symnames_in_strings;
00720   unsigned int _bfd_coff_debug_string_prefix_length;
00721 
00722   void (*_bfd_coff_swap_filehdr_in)
00723     (bfd *, void *, void *);
00724 
00725   void (*_bfd_coff_swap_aouthdr_in)
00726     (bfd *, void *, void *);
00727 
00728   void (*_bfd_coff_swap_scnhdr_in)
00729     (bfd *, void *, void *);
00730 
00731   void (*_bfd_coff_swap_reloc_in)
00732     (bfd *abfd, void *, void *);
00733 
00734   bfd_boolean (*_bfd_coff_bad_format_hook)
00735     (bfd *, void *);
00736 
00737   bfd_boolean (*_bfd_coff_set_arch_mach_hook)
00738     (bfd *, void *);
00739 
00740   void * (*_bfd_coff_mkobject_hook)
00741     (bfd *, void *, void *);
00742 
00743   bfd_boolean (*_bfd_styp_to_sec_flags_hook)
00744     (bfd *, void *, const char *, asection *, flagword *);
00745 
00746   void (*_bfd_set_alignment_hook)
00747     (bfd *, asection *, void *);
00748 
00749   bfd_boolean (*_bfd_coff_slurp_symbol_table)
00750     (bfd *);
00751 
00752   bfd_boolean (*_bfd_coff_symname_in_debug)
00753     (bfd *, struct internal_syment *);
00754 
00755   bfd_boolean (*_bfd_coff_pointerize_aux_hook)
00756     (bfd *, combined_entry_type *, combined_entry_type *,
00757             unsigned int, combined_entry_type *);
00758 
00759   bfd_boolean (*_bfd_coff_print_aux)
00760     (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
00761             combined_entry_type *, unsigned int);
00762 
00763   void (*_bfd_coff_reloc16_extra_cases)
00764     (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
00765            bfd_byte *, unsigned int *, unsigned int *);
00766 
00767   int (*_bfd_coff_reloc16_estimate)
00768     (bfd *, asection *, arelent *, unsigned int,
00769             struct bfd_link_info *);
00770 
00771   enum coff_symbol_classification (*_bfd_coff_classify_symbol)
00772     (bfd *, struct internal_syment *);
00773 
00774   bfd_boolean (*_bfd_coff_compute_section_file_positions)
00775     (bfd *);
00776 
00777   bfd_boolean (*_bfd_coff_start_final_link)
00778     (bfd *, struct bfd_link_info *);
00779 
00780   bfd_boolean (*_bfd_coff_relocate_section)
00781     (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
00782             struct internal_reloc *, struct internal_syment *, asection **);
00783 
00784   reloc_howto_type *(*_bfd_coff_rtype_to_howto)
00785     (bfd *, asection *, struct internal_reloc *,
00786             struct coff_link_hash_entry *, struct internal_syment *,
00787             bfd_vma *);
00788 
00789   bfd_boolean (*_bfd_coff_adjust_symndx)
00790     (bfd *, struct bfd_link_info *, bfd *, asection *,
00791             struct internal_reloc *, bfd_boolean *);
00792 
00793   bfd_boolean (*_bfd_coff_link_add_one_symbol)
00794     (struct bfd_link_info *, bfd *, const char *, flagword,
00795             asection *, bfd_vma, const char *, bfd_boolean, bfd_boolean,
00796             struct bfd_link_hash_entry **);
00797 
00798   bfd_boolean (*_bfd_coff_link_output_has_begun)
00799     (bfd *, struct coff_final_link_info *);
00800 
00801   bfd_boolean (*_bfd_coff_final_link_postscript)
00802     (bfd *, struct coff_final_link_info *);
00803 
00804 } bfd_coff_backend_data;
00805 
00806 #define coff_backend_info(abfd) \
00807   ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
00808 
00809 #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
00810   ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
00811 
00812 #define bfd_coff_swap_sym_in(a,e,i) \
00813   ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
00814 
00815 #define bfd_coff_swap_lineno_in(a,e,i) \
00816   ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
00817 
00818 #define bfd_coff_swap_reloc_out(abfd, i, o) \
00819   ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
00820 
00821 #define bfd_coff_swap_lineno_out(abfd, i, o) \
00822   ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
00823 
00824 #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
00825   ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
00826 
00827 #define bfd_coff_swap_sym_out(abfd, i,o) \
00828   ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
00829 
00830 #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
00831   ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
00832 
00833 #define bfd_coff_swap_filehdr_out(abfd, i,o) \
00834   ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
00835 
00836 #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
00837   ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
00838 
00839 #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
00840 #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
00841 #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
00842 #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
00843 #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
00844 #define bfd_coff_relsz(abfd)  (coff_backend_info (abfd)->_bfd_relsz)
00845 #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
00846 #define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
00847 #define bfd_coff_long_filenames(abfd) \
00848   (coff_backend_info (abfd)->_bfd_coff_long_filenames)
00849 #define bfd_coff_long_section_names(abfd) \
00850   (coff_backend_info (abfd)->_bfd_coff_long_section_names)
00851 #define bfd_coff_default_section_alignment_power(abfd) \
00852   (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
00853 #define bfd_coff_swap_filehdr_in(abfd, i,o) \
00854   ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
00855 
00856 #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
00857   ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
00858 
00859 #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
00860   ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
00861 
00862 #define bfd_coff_swap_reloc_in(abfd, i, o) \
00863   ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
00864 
00865 #define bfd_coff_bad_format_hook(abfd, filehdr) \
00866   ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
00867 
00868 #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
00869   ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
00870 #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
00871   ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
00872    (abfd, filehdr, aouthdr))
00873 
00874 #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
00875   ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
00876    (abfd, scnhdr, name, section, flags_ptr))
00877 
00878 #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
00879   ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
00880 
00881 #define bfd_coff_slurp_symbol_table(abfd)\
00882   ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
00883 
00884 #define bfd_coff_symname_in_debug(abfd, sym)\
00885   ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
00886 
00887 #define bfd_coff_force_symnames_in_strings(abfd)\
00888   (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
00889 
00890 #define bfd_coff_debug_string_prefix_length(abfd)\
00891   (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
00892 
00893 #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
00894   ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
00895    (abfd, file, base, symbol, aux, indaux))
00896 
00897 #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
00898                                      reloc, data, src_ptr, dst_ptr)\
00899   ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
00900    (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
00901 
00902 #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
00903   ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
00904    (abfd, section, reloc, shrink, link_info))
00905 
00906 #define bfd_coff_classify_symbol(abfd, sym)\
00907   ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
00908    (abfd, sym))
00909 
00910 #define bfd_coff_compute_section_file_positions(abfd)\
00911   ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
00912    (abfd))
00913 
00914 #define bfd_coff_start_final_link(obfd, info)\
00915   ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
00916    (obfd, info))
00917 #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
00918   ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
00919    (obfd, info, ibfd, o, con, rel, isyms, secs))
00920 #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
00921   ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
00922    (abfd, sec, rel, h, sym, addendp))
00923 #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
00924   ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
00925    (obfd, info, ibfd, sec, rel, adjustedp))
00926 #define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
00927                                      value, string, cp, coll, hashp)\
00928   ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
00929    (info, abfd, name, flags, section, value, string, cp, coll, hashp))
00930 
00931 #define bfd_coff_link_output_has_begun(a,p) \
00932   ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
00933 #define bfd_coff_final_link_postscript(a,p) \
00934   ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p))
00935