1*3d8817e4Smiod /* HP PA-RISC SOM object file format: definitions internal to BFD. 2*3d8817e4Smiod Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001, 3*3d8817e4Smiod 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 4*3d8817e4Smiod 5*3d8817e4Smiod Contributed by the Center for Software Science at the 6*3d8817e4Smiod University of Utah (pa-gdb-bugs@cs.utah.edu). 7*3d8817e4Smiod 8*3d8817e4Smiod This file is part of BFD, the Binary File Descriptor library. 9*3d8817e4Smiod 10*3d8817e4Smiod This program is free software; you can redistribute it and/or modify 11*3d8817e4Smiod it under the terms of the GNU General Public License as published by 12*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or 13*3d8817e4Smiod (at your option) any later version. 14*3d8817e4Smiod 15*3d8817e4Smiod This program is distributed in the hope that it will be useful, 16*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of 17*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*3d8817e4Smiod GNU General Public License for more details. 19*3d8817e4Smiod 20*3d8817e4Smiod You should have received a copy of the GNU General Public License 21*3d8817e4Smiod along with this program; if not, write to the Free Software 22*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 23*3d8817e4Smiod 02110-1301, USA. */ 24*3d8817e4Smiod 25*3d8817e4Smiod #ifndef _SOM_H 26*3d8817e4Smiod #define _SOM_H 27*3d8817e4Smiod 28*3d8817e4Smiod #include "libhppa.h" 29*3d8817e4Smiod 30*3d8817e4Smiod /* We want reloc.h to provide PA 2.0 defines. */ 31*3d8817e4Smiod #define PA_2_0 32*3d8817e4Smiod 33*3d8817e4Smiod #include <a.out.h> 34*3d8817e4Smiod #include <lst.h> 35*3d8817e4Smiod #include <ar.h> 36*3d8817e4Smiod 37*3d8817e4Smiod /* The SOM BFD backend doesn't currently use anything from these 38*3d8817e4Smiod two include files, but it's likely to need them in the future. */ 39*3d8817e4Smiod #ifdef R_DLT_REL 40*3d8817e4Smiod #include <shl.h> 41*3d8817e4Smiod #include <dl.h> 42*3d8817e4Smiod #endif 43*3d8817e4Smiod 44*3d8817e4Smiod #if defined(HOST_HPPABSD) || defined (HOST_HPPAOSF) 45*3d8817e4Smiod /* BSD uses a completely different scheme for object file identification. 46*3d8817e4Smiod so for now, define _PA_RISC_ID to accept any random value for a model 47*3d8817e4Smiod number. */ 48*3d8817e4Smiod #undef _PA_RISC_ID 49*3d8817e4Smiod #define _PA_RISC_ID(__m_num) 1 50*3d8817e4Smiod #endif /* HOST_HPPABSD */ 51*3d8817e4Smiod 52*3d8817e4Smiod #define FILE_HDR_SIZE sizeof (struct header) 53*3d8817e4Smiod #define AUX_HDR_SIZE sizeof (struct som_exec_auxhdr) 54*3d8817e4Smiod 55*3d8817e4Smiod typedef struct som_symbol 56*3d8817e4Smiod { 57*3d8817e4Smiod asymbol symbol; 58*3d8817e4Smiod unsigned int som_type; 59*3d8817e4Smiod 60*3d8817e4Smiod /* Structured like the ELF tc_data union. Allows more code sharing 61*3d8817e4Smiod in GAS this way. */ 62*3d8817e4Smiod union 63*3d8817e4Smiod { 64*3d8817e4Smiod struct 65*3d8817e4Smiod { 66*3d8817e4Smiod unsigned int hppa_arg_reloc; 67*3d8817e4Smiod unsigned int hppa_priv_level; 68*3d8817e4Smiod } ap; 69*3d8817e4Smiod PTR any; 70*3d8817e4Smiod } 71*3d8817e4Smiod tc_data; 72*3d8817e4Smiod 73*3d8817e4Smiod /* Index of this symbol in the symbol table. Only used when 74*3d8817e4Smiod building relocation streams for incomplete objects. */ 75*3d8817e4Smiod int index; 76*3d8817e4Smiod 77*3d8817e4Smiod /* How many times this symbol is used in a relocation. By sorting 78*3d8817e4Smiod the symbols from most used to least used we can significantly 79*3d8817e4Smiod reduce the size of the relocation stream for incomplete objects. */ 80*3d8817e4Smiod int reloc_count; 81*3d8817e4Smiod 82*3d8817e4Smiod /* During object file writing, the offset of the name of this symbol 83*3d8817e4Smiod in the SOM string table. */ 84*3d8817e4Smiod int stringtab_offset; 85*3d8817e4Smiod } 86*3d8817e4Smiod som_symbol_type; 87*3d8817e4Smiod 88*3d8817e4Smiod /* A structure containing all the magic information stored in a BFD's 89*3d8817e4Smiod private data which needs to be copied during an objcopy/strip run. */ 90*3d8817e4Smiod struct som_exec_data 91*3d8817e4Smiod { 92*3d8817e4Smiod /* Sort-of a magic number. BSD uses it to distinguish between 93*3d8817e4Smiod native executables and hpux executables. */ 94*3d8817e4Smiod short system_id; 95*3d8817e4Smiod 96*3d8817e4Smiod /* Magic exec flags. These control things like whether or not 97*3d8817e4Smiod null pointer dereferencing is allowed and the like. */ 98*3d8817e4Smiod long exec_flags; 99*3d8817e4Smiod 100*3d8817e4Smiod /* We must preserve the version identifier too. Some versions 101*3d8817e4Smiod of the HP linker do not grok NEW_VERSION_ID for reasons unknown. */ 102*3d8817e4Smiod unsigned int version_id; 103*3d8817e4Smiod 104*3d8817e4Smiod /* Add more stuff here as needed. Good examples of information 105*3d8817e4Smiod we might want to pass would be presumed_dp, entry_* and maybe 106*3d8817e4Smiod others from the file header. */ 107*3d8817e4Smiod }; 108*3d8817e4Smiod 109*3d8817e4Smiod struct somdata 110*3d8817e4Smiod { 111*3d8817e4Smiod /* All the magic information about an executable which lives 112*3d8817e4Smiod in the private BFD structure and needs to be copied from 113*3d8817e4Smiod the input bfd to the output bfd during an objcopy/strip. */ 114*3d8817e4Smiod struct som_exec_data *exec_data; 115*3d8817e4Smiod 116*3d8817e4Smiod /* These three fields are only used when writing files and are 117*3d8817e4Smiod generated from scratch. They need not be copied for objcopy 118*3d8817e4Smiod or strip to work. */ 119*3d8817e4Smiod struct header *file_hdr; 120*3d8817e4Smiod struct copyright_aux_hdr *copyright_aux_hdr; 121*3d8817e4Smiod struct user_string_aux_hdr *version_aux_hdr; 122*3d8817e4Smiod struct som_exec_auxhdr *exec_hdr; 123*3d8817e4Smiod COMPUNIT *comp_unit; 124*3d8817e4Smiod 125*3d8817e4Smiod /* Pointers to a saved copy of the symbol and string tables. These 126*3d8817e4Smiod need not be copied for objcopy or strip to work. */ 127*3d8817e4Smiod som_symbol_type *symtab; 128*3d8817e4Smiod char *stringtab; 129*3d8817e4Smiod asymbol **sorted_syms; 130*3d8817e4Smiod 131*3d8817e4Smiod /* We remember these offsets so that after check_file_format, we have 132*3d8817e4Smiod no dependencies on the particular format of the exec_hdr. 133*3d8817e4Smiod These offsets need not be copied for objcopy or strip to work. */ 134*3d8817e4Smiod 135*3d8817e4Smiod file_ptr sym_filepos; 136*3d8817e4Smiod file_ptr str_filepos; 137*3d8817e4Smiod file_ptr reloc_filepos; 138*3d8817e4Smiod unsigned stringtab_size; 139*3d8817e4Smiod }; 140*3d8817e4Smiod 141*3d8817e4Smiod struct som_data_struct 142*3d8817e4Smiod { 143*3d8817e4Smiod struct somdata a; 144*3d8817e4Smiod }; 145*3d8817e4Smiod 146*3d8817e4Smiod struct som_subspace_dictionary_record 147*3d8817e4Smiod { 148*3d8817e4Smiod int space_index; 149*3d8817e4Smiod unsigned int access_control_bits : 7; 150*3d8817e4Smiod unsigned int memory_resident : 1; 151*3d8817e4Smiod unsigned int dup_common : 1; 152*3d8817e4Smiod unsigned int is_common : 1; 153*3d8817e4Smiod unsigned int is_loadable : 1; 154*3d8817e4Smiod unsigned int quadrant : 2; 155*3d8817e4Smiod unsigned int initially_frozen : 1; 156*3d8817e4Smiod unsigned int is_first : 1; 157*3d8817e4Smiod unsigned int code_only : 1; 158*3d8817e4Smiod unsigned int sort_key : 8; 159*3d8817e4Smiod unsigned int replicate_init : 1; 160*3d8817e4Smiod unsigned int continuation : 1; 161*3d8817e4Smiod unsigned int is_tspecific : 1; 162*3d8817e4Smiod unsigned int is_comdat : 1; 163*3d8817e4Smiod unsigned int reserved : 4; 164*3d8817e4Smiod int file_loc_init_value; 165*3d8817e4Smiod unsigned int initialization_length; 166*3d8817e4Smiod unsigned int subspace_start; 167*3d8817e4Smiod unsigned int subspace_length; 168*3d8817e4Smiod unsigned int reserved2 : 5; 169*3d8817e4Smiod unsigned int alignment :27; 170*3d8817e4Smiod union name_pt name; 171*3d8817e4Smiod int fixup_request_index; 172*3d8817e4Smiod unsigned int fixup_request_quantity; 173*3d8817e4Smiod }; 174*3d8817e4Smiod 175*3d8817e4Smiod /* Substructure of som_section_data_struct used to hold information 176*3d8817e4Smiod which can't be represented by the generic BFD section structure, 177*3d8817e4Smiod but which must be copied during objcopy or strip. */ 178*3d8817e4Smiod struct som_copyable_section_data_struct 179*3d8817e4Smiod { 180*3d8817e4Smiod /* Various fields in space and subspace headers that we need 181*3d8817e4Smiod to pass around. */ 182*3d8817e4Smiod unsigned int sort_key : 8; 183*3d8817e4Smiod unsigned int access_control_bits : 7; 184*3d8817e4Smiod unsigned int is_defined : 1; 185*3d8817e4Smiod unsigned int is_private : 1; 186*3d8817e4Smiod unsigned int quadrant : 2; 187*3d8817e4Smiod unsigned int is_comdat : 1; 188*3d8817e4Smiod unsigned int is_common : 1; 189*3d8817e4Smiod unsigned int dup_common : 1; 190*3d8817e4Smiod 191*3d8817e4Smiod /* For subspaces, this points to the section which represents the 192*3d8817e4Smiod space in which the subspace is contained. For spaces it points 193*3d8817e4Smiod back to the section for this space. */ 194*3d8817e4Smiod asection *container; 195*3d8817e4Smiod 196*3d8817e4Smiod /* The user-specified space number. It is wrong to use this as 197*3d8817e4Smiod an index since duplicates and holes are allowed. */ 198*3d8817e4Smiod int space_number; 199*3d8817e4Smiod 200*3d8817e4Smiod /* Add more stuff here as needed. Good examples of information 201*3d8817e4Smiod we might want to pass would be initialization pointers, 202*3d8817e4Smiod and the many subspace flags we do not represent yet. */ 203*3d8817e4Smiod }; 204*3d8817e4Smiod 205*3d8817e4Smiod /* Used to keep extra SOM specific information for a given section. 206*3d8817e4Smiod 207*3d8817e4Smiod reloc_size holds the size of the relocation stream, note this 208*3d8817e4Smiod is very different from the number of relocations as SOM relocations 209*3d8817e4Smiod are variable length. 210*3d8817e4Smiod 211*3d8817e4Smiod reloc_stream is the actual stream of relocation entries. */ 212*3d8817e4Smiod 213*3d8817e4Smiod struct som_section_data_struct 214*3d8817e4Smiod { 215*3d8817e4Smiod struct som_copyable_section_data_struct *copy_data; 216*3d8817e4Smiod unsigned int reloc_size; 217*3d8817e4Smiod unsigned char *reloc_stream; 218*3d8817e4Smiod struct space_dictionary_record *space_dict; 219*3d8817e4Smiod struct som_subspace_dictionary_record *subspace_dict; 220*3d8817e4Smiod }; 221*3d8817e4Smiod 222*3d8817e4Smiod #define somdata(bfd) ((bfd)->tdata.som_data->a) 223*3d8817e4Smiod #define obj_som_exec_data(bfd) (somdata (bfd).exec_data) 224*3d8817e4Smiod #define obj_som_file_hdr(bfd) (somdata (bfd).file_hdr) 225*3d8817e4Smiod #define obj_som_exec_hdr(bfd) (somdata (bfd).exec_hdr) 226*3d8817e4Smiod #define obj_som_copyright_hdr(bfd) (somdata (bfd).copyright_aux_hdr) 227*3d8817e4Smiod #define obj_som_version_hdr(bfd) (somdata (bfd).version_aux_hdr) 228*3d8817e4Smiod #define obj_som_compilation_unit(bfd) (somdata (bfd).comp_unit) 229*3d8817e4Smiod #define obj_som_symtab(bfd) (somdata (bfd).symtab) 230*3d8817e4Smiod #define obj_som_stringtab(bfd) (somdata (bfd).stringtab) 231*3d8817e4Smiod #define obj_som_sym_filepos(bfd) (somdata (bfd).sym_filepos) 232*3d8817e4Smiod #define obj_som_str_filepos(bfd) (somdata (bfd).str_filepos) 233*3d8817e4Smiod #define obj_som_stringtab_size(bfd) (somdata (bfd).stringtab_size) 234*3d8817e4Smiod #define obj_som_reloc_filepos(bfd) (somdata (bfd).reloc_filepos) 235*3d8817e4Smiod #define obj_som_sorted_syms(bfd) (somdata (bfd).sorted_syms) 236*3d8817e4Smiod #define som_section_data(sec) ((struct som_section_data_struct *) sec->used_by_bfd) 237*3d8817e4Smiod #define som_symbol_data(symbol) ((som_symbol_type *) symbol) 238*3d8817e4Smiod 239*3d8817e4Smiod /* Defines groups of basic relocations. FIXME: These should 240*3d8817e4Smiod be the only basic relocations created by GAS. The rest 241*3d8817e4Smiod should be internal to the BFD backend. 242*3d8817e4Smiod 243*3d8817e4Smiod The idea is both SOM and ELF define these basic relocation 244*3d8817e4Smiod types so they map into a SOM or ELF specific relocation as 245*3d8817e4Smiod appropriate. This allows GAS to share much more code 246*3d8817e4Smiod between the two object formats. */ 247*3d8817e4Smiod 248*3d8817e4Smiod #define R_HPPA_NONE R_NO_RELOCATION 249*3d8817e4Smiod #define R_HPPA R_CODE_ONE_SYMBOL 250*3d8817e4Smiod #define R_HPPA_PCREL_CALL R_PCREL_CALL 251*3d8817e4Smiod #define R_HPPA_ABS_CALL R_ABS_CALL 252*3d8817e4Smiod #define R_HPPA_GOTOFF R_DP_RELATIVE 253*3d8817e4Smiod #define R_HPPA_ENTRY R_ENTRY 254*3d8817e4Smiod #define R_HPPA_EXIT R_EXIT 255*3d8817e4Smiod #define R_HPPA_COMPLEX R_COMP1 256*3d8817e4Smiod #define R_HPPA_BEGIN_BRTAB R_BEGIN_BRTAB 257*3d8817e4Smiod #define R_HPPA_END_BRTAB R_END_BRTAB 258*3d8817e4Smiod #define R_HPPA_BEGIN_TRY R_BEGIN_TRY 259*3d8817e4Smiod #define R_HPPA_END_TRY R_END_TRY 260*3d8817e4Smiod 261*3d8817e4Smiod /* Exported functions, mostly for use by GAS. */ 262*3d8817e4Smiod bfd_boolean bfd_som_set_section_attributes (asection *, int, int, unsigned int, int); 263*3d8817e4Smiod bfd_boolean bfd_som_set_subsection_attributes (asection *, asection *, int, unsigned int, int, int, int, int); 264*3d8817e4Smiod void bfd_som_set_symbol_type (asymbol *, unsigned int); 265*3d8817e4Smiod bfd_boolean bfd_som_attach_aux_hdr (bfd *, int, char *); 266*3d8817e4Smiod int ** hppa_som_gen_reloc_type (bfd *, int, int, enum hppa_reloc_field_selector_type_alt, int, asymbol *); 267*3d8817e4Smiod bfd_boolean bfd_som_attach_compilation_unit (bfd *, const char *, const char *, const char *, const char *); 268*3d8817e4Smiod 269*3d8817e4Smiod #endif /* _SOM_H */ 270