Back to index

cell-binutils  2.17cvs20070401
som.h
Go to the documentation of this file.
00001 /* HP PA-RISC SOM object file format:  definitions internal to BFD.
00002    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001,
00003    2002, 2003, 2004, 2005 Free Software Foundation, Inc.
00004 
00005    Contributed by the Center for Software Science at the
00006    University of Utah (pa-gdb-bugs@cs.utah.edu).
00007 
00008    This file is part of BFD, the Binary File Descriptor library.
00009 
00010    This program is free software; you can redistribute it and/or modify
00011    it under the terms of the GNU General Public License as published by
00012    the Free Software Foundation; either version 2 of the License, or
00013    (at your option) any later version.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License
00021    along with this program; if not, write to the Free Software
00022    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
00023    02110-1301, USA.  */
00024 
00025 #ifndef _SOM_H
00026 #define _SOM_H
00027 
00028 #include "libhppa.h"
00029 
00030 /* We want reloc.h to provide PA 2.0 defines.  */
00031 #define PA_2_0
00032 
00033 #include <a.out.h>
00034 #include <lst.h>
00035 #include <ar.h>
00036 
00037 /* The SOM BFD backend doesn't currently use anything from these
00038    two include files, but it's likely to need them in the future.  */
00039 #ifdef R_DLT_REL
00040 #include <shl.h>
00041 #include <dl.h>
00042 #endif
00043 
00044 #if defined(HOST_HPPABSD) || defined (HOST_HPPAOSF)
00045 /* BSD uses a completely different scheme for object file identification.
00046    so for now, define _PA_RISC_ID to accept any random value for a model
00047    number.  */
00048 #undef _PA_RISC_ID
00049 #define _PA_RISC_ID(__m_num) 1
00050 #endif /* HOST_HPPABSD */
00051 
00052 #define FILE_HDR_SIZE sizeof (struct header)
00053 #define AUX_HDR_SIZE sizeof (struct som_exec_auxhdr)
00054 
00055 typedef struct som_symbol
00056 {
00057   asymbol symbol;
00058   unsigned int som_type;
00059 
00060   /* Structured like the ELF tc_data union.  Allows more code sharing
00061      in GAS this way.  */
00062   union
00063   {
00064     struct
00065     {
00066       unsigned int hppa_arg_reloc;
00067       unsigned int hppa_priv_level;
00068     } ap;
00069     PTR any;
00070   }
00071   tc_data;
00072 
00073   /* Index of this symbol in the symbol table.  Only used when
00074      building relocation streams for incomplete objects.  */
00075   int index;
00076 
00077   /* How many times this symbol is used in a relocation.  By sorting
00078      the symbols from most used to least used we can significantly
00079      reduce the size of the relocation stream for incomplete objects.  */
00080   int reloc_count;
00081 
00082   /* During object file writing, the offset of the name of this symbol
00083      in the SOM string table.  */
00084   int stringtab_offset;
00085 }
00086 som_symbol_type;
00087 
00088 /* A structure containing all the magic information stored in a BFD's
00089    private data which needs to be copied during an objcopy/strip run.  */
00090 struct som_exec_data
00091 {
00092   /* Sort-of a magic number.  BSD uses it to distinguish between
00093      native executables and hpux executables.  */
00094   short system_id;
00095 
00096   /* Magic exec flags.  These control things like whether or not
00097      null pointer dereferencing is allowed and the like.  */
00098   long exec_flags;
00099 
00100   /* We must preserve the version identifier too.  Some versions
00101      of the HP linker do not grok NEW_VERSION_ID for reasons unknown.  */
00102   unsigned int version_id;
00103 
00104   /* Add more stuff here as needed.  Good examples of information
00105      we might want to pass would be presumed_dp, entry_* and maybe
00106      others from the file header.  */
00107 };
00108 
00109 struct somdata
00110 {
00111   /* All the magic information about an executable which lives
00112      in the private BFD structure and needs to be copied from
00113      the input bfd to the output bfd during an objcopy/strip.  */
00114   struct som_exec_data *exec_data;
00115 
00116   /* These three fields are only used when writing files and are
00117      generated from scratch.  They need not be copied for objcopy
00118      or strip to work.  */
00119   struct header *file_hdr;
00120   struct copyright_aux_hdr *copyright_aux_hdr;
00121   struct user_string_aux_hdr *version_aux_hdr;
00122   struct som_exec_auxhdr *exec_hdr;
00123   COMPUNIT *comp_unit;
00124 
00125   /* Pointers to a saved copy of the symbol and string tables.  These
00126      need not be copied for objcopy or strip to work.  */
00127   som_symbol_type *symtab;
00128   char *stringtab;
00129   asymbol **sorted_syms;
00130 
00131   /* We remember these offsets so that after check_file_format, we have
00132      no dependencies on the particular format of the exec_hdr.
00133      These offsets need not be copied for objcopy or strip to work.  */
00134 
00135   file_ptr sym_filepos;
00136   file_ptr str_filepos;
00137   file_ptr reloc_filepos;
00138   unsigned stringtab_size;
00139 };
00140 
00141 struct som_data_struct
00142 {
00143   struct somdata a;
00144 };
00145 
00146 struct som_subspace_dictionary_record
00147 {
00148   int space_index;
00149   unsigned int access_control_bits : 7;
00150   unsigned int memory_resident : 1;
00151   unsigned int dup_common : 1;
00152   unsigned int is_common : 1;
00153   unsigned int is_loadable : 1;
00154   unsigned int quadrant : 2;
00155   unsigned int initially_frozen : 1;
00156   unsigned int is_first : 1;
00157   unsigned int code_only : 1;
00158   unsigned int sort_key : 8;
00159   unsigned int replicate_init      : 1;
00160   unsigned int continuation : 1;
00161   unsigned int is_tspecific : 1;
00162   unsigned int is_comdat : 1;
00163   unsigned int reserved : 4;
00164   int file_loc_init_value;
00165   unsigned int initialization_length;
00166   unsigned int subspace_start;
00167   unsigned int subspace_length;
00168   unsigned int reserved2 : 5;   
00169   unsigned int alignment :27;
00170   union name_pt name;
00171   int fixup_request_index;
00172   unsigned int fixup_request_quantity;
00173 };
00174 
00175 /* Substructure of som_section_data_struct used to hold information
00176    which can't be represented by the generic BFD section structure,
00177    but which must be copied during objcopy or strip.  */
00178 struct som_copyable_section_data_struct
00179 {
00180   /* Various fields in space and subspace headers that we need
00181      to pass around.  */
00182   unsigned int sort_key : 8;
00183   unsigned int access_control_bits : 7;
00184   unsigned int is_defined : 1;
00185   unsigned int is_private : 1;
00186   unsigned int quadrant : 2;
00187   unsigned int is_comdat : 1;
00188   unsigned int is_common : 1;
00189   unsigned int dup_common : 1;
00190 
00191   /* For subspaces, this points to the section which represents the
00192      space in which the subspace is contained.  For spaces it points
00193      back to the section for this space.  */
00194   asection *container;
00195 
00196   /* The user-specified space number.  It is wrong to use this as
00197      an index since duplicates and holes are allowed.  */
00198   int space_number;
00199 
00200   /* Add more stuff here as needed.  Good examples of information
00201      we might want to pass would be initialization pointers,
00202      and the many subspace flags we do not represent yet.  */
00203 };
00204 
00205 /* Used to keep extra SOM specific information for a given section.
00206 
00207    reloc_size holds the size of the relocation stream, note this
00208    is very different from the number of relocations as SOM relocations
00209    are variable length.
00210 
00211    reloc_stream is the actual stream of relocation entries.  */
00212 
00213 struct som_section_data_struct
00214 {
00215   struct som_copyable_section_data_struct *copy_data;
00216   unsigned int reloc_size;
00217   unsigned char *reloc_stream;
00218   struct space_dictionary_record *space_dict;
00219   struct som_subspace_dictionary_record *subspace_dict;
00220 };
00221 
00222 #define somdata(bfd)               ((bfd)->tdata.som_data->a)
00223 #define obj_som_exec_data(bfd)            (somdata (bfd).exec_data)
00224 #define obj_som_file_hdr(bfd)             (somdata (bfd).file_hdr)
00225 #define obj_som_exec_hdr(bfd)             (somdata (bfd).exec_hdr)
00226 #define obj_som_copyright_hdr(bfd) (somdata (bfd).copyright_aux_hdr)
00227 #define obj_som_version_hdr(bfd)   (somdata (bfd).version_aux_hdr)
00228 #define obj_som_compilation_unit(bfd)     (somdata (bfd).comp_unit)
00229 #define obj_som_symtab(bfd)        (somdata (bfd).symtab)
00230 #define obj_som_stringtab(bfd)            (somdata (bfd).stringtab)
00231 #define obj_som_sym_filepos(bfd)   (somdata (bfd).sym_filepos)
00232 #define obj_som_str_filepos(bfd)   (somdata (bfd).str_filepos)
00233 #define obj_som_stringtab_size(bfd)       (somdata (bfd).stringtab_size)
00234 #define obj_som_reloc_filepos(bfd) (somdata (bfd).reloc_filepos)
00235 #define obj_som_sorted_syms(bfd)   (somdata (bfd).sorted_syms)
00236 #define som_section_data(sec)      ((struct som_section_data_struct *) sec->used_by_bfd)
00237 #define som_symbol_data(symbol)           ((som_symbol_type *) symbol)
00238 
00239 /* Defines groups of basic relocations.  FIXME:  These should
00240    be the only basic relocations created by GAS.  The rest
00241    should be internal to the BFD backend.
00242 
00243    The idea is both SOM and ELF define these basic relocation
00244    types so they map into a SOM or ELF specific relocation as
00245    appropriate.  This allows GAS to share much more code
00246    between the two object formats.  */
00247 
00248 #define R_HPPA_NONE                R_NO_RELOCATION
00249 #define       R_HPPA                      R_CODE_ONE_SYMBOL
00250 #define       R_HPPA_PCREL_CALL           R_PCREL_CALL
00251 #define R_HPPA_ABS_CALL                   R_ABS_CALL
00252 #define       R_HPPA_GOTOFF               R_DP_RELATIVE
00253 #define R_HPPA_ENTRY               R_ENTRY
00254 #define R_HPPA_EXIT                R_EXIT
00255 #define R_HPPA_COMPLEX                    R_COMP1
00256 #define R_HPPA_BEGIN_BRTAB         R_BEGIN_BRTAB
00257 #define R_HPPA_END_BRTAB           R_END_BRTAB
00258 #define R_HPPA_BEGIN_TRY           R_BEGIN_TRY
00259 #define R_HPPA_END_TRY                    R_END_TRY
00260 
00261 /* Exported functions, mostly for use by GAS.  */
00262 bfd_boolean  bfd_som_set_section_attributes    (asection *, int, int, unsigned int, int);
00263 bfd_boolean  bfd_som_set_subsection_attributes (asection *, asection *, int, unsigned int, int, int, int, int);
00264 void         bfd_som_set_symbol_type           (asymbol *, unsigned int);
00265 bfd_boolean  bfd_som_attach_aux_hdr            (bfd *, int, char *);
00266 int **       hppa_som_gen_reloc_type           (bfd *, int, int, enum hppa_reloc_field_selector_type_alt, int, asymbol *);
00267 bfd_boolean  bfd_som_attach_compilation_unit   (bfd *, const char *, const char *, const char *, const char *);
00268 
00269 #endif /* _SOM_H */