Home | History | Annotate | Download | only in som
      1 /* SOM a.out definitions for BFD.
      2    Copyright (C) 2010-2014 Free Software Foundation, Inc.
      3    Contributed by Tristan Gingold <gingold (at) adacore.com>, AdaCore.
      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 3 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 Foundation,
     19    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
     20 
     21 #ifndef _SOM_AOUT_H
     22 #define _SOM_AOUT_H
     23 
     24 #include "clock.h"
     25 
     26 /* Note: SOM uses bit-field in its structure.  All you need to know is:
     27    - CPUs supported by SOM (hppa) are big-endian,
     28    - the MSB is numbered 0.  */
     29 
     30 struct som_external_header
     31 {
     32   unsigned char system_id[2];
     33   unsigned char a_magic[2];
     34   unsigned char version_id[4];
     35   struct som_external_clock file_time;
     36   unsigned char entry_space[4];
     37   unsigned char entry_subspace[4];
     38   unsigned char entry_offset[4];
     39   unsigned char aux_header_location[4];
     40   unsigned char aux_header_size[4];
     41   unsigned char som_length[4];
     42   unsigned char presumed_dp[4];
     43   unsigned char space_location[4];
     44   unsigned char space_total[4];
     45   unsigned char subspace_location[4];
     46   unsigned char subspace_total[4];
     47   unsigned char loader_fixup_location[4];
     48   unsigned char loader_fixup_total[4];
     49   unsigned char space_strings_location[4];
     50   unsigned char space_strings_size[4];
     51   unsigned char init_array_location[4];
     52   unsigned char init_array_total[4];
     53   unsigned char compiler_location[4];
     54   unsigned char compiler_total[4];
     55   unsigned char symbol_location[4];
     56   unsigned char symbol_total[4];
     57   unsigned char fixup_request_location[4];
     58   unsigned char fixup_request_total[4];
     59   unsigned char symbol_strings_location[4];
     60   unsigned char symbol_strings_size[4];
     61   unsigned char unloadable_sp_location[4];
     62   unsigned char unloadable_sp_size[4];
     63   unsigned char checksum[4];
     64 };
     65 
     66 #define OLD_VERSION_ID 85082112
     67 #define NEW_VERSION_ID 87102412
     68 
     69 #define EXECLIBMAGIC	0x0104
     70 #define RELOC_MAGIC	0x0106
     71 #define EXEC_MAGIC	0x0107
     72 #define SHARE_MAGIC	0x0108
     73 #define SHMEM_MAGIC	0x0109
     74 #define DEMAND_MAGIC	0x010b
     75 #define DL_MAGIC	0x010d
     76 #define SHL_MAGIC	0x010e
     77 
     78 struct som_external_aux_id
     79 {
     80   unsigned char flags[4];
     81   unsigned char length[4];
     82 };
     83 
     84 /* Aux id types.  */
     85 #define VERSION_AUX_ID 6
     86 #define COPYRIGHT_AUX_ID 9
     87 
     88 /* Aux id flags.  */
     89 #define SOM_AUX_ID_MANDATORY	(1 << 31)
     90 #define SOM_AUX_ID_COPY		(1 << 30)
     91 #define SOM_AUX_ID_APPEND	(1 << 29)
     92 #define SOM_AUX_ID_IGNORE	(1 << 28)
     93 #define SOM_AUX_ID_TYPE_SH	0
     94 #define SOM_AUX_ID_TYPE_MASK	0xffff
     95 
     96 struct som_external_string_auxhdr
     97 {
     98   struct som_external_aux_id header_id;
     99 
    100   /* Length of the string, without the NUL.  */
    101   unsigned char string_length[4];
    102 
    103   /* The string.  */
    104 };
    105 
    106 struct som_external_exec_auxhdr
    107 {
    108   struct som_external_aux_id som_auxhdr;
    109 
    110   unsigned char exec_tsize[4];
    111   unsigned char exec_tmem[4];
    112   unsigned char exec_tfile[4];
    113   unsigned char exec_dsize[4];
    114   unsigned char exec_dmem[4];
    115   unsigned char exec_dfile[4];
    116   unsigned char exec_bsize[4];
    117   unsigned char exec_entry[4];
    118   unsigned char exec_flags[4];
    119   unsigned char exec_bfill[4];
    120 };
    121 
    122 #define AUX_HDR_SIZE sizeof (struct som_external_exec_auxhdr)
    123 
    124 struct som_external_space_dictionary_record
    125 {
    126   unsigned char name[4];
    127   unsigned char flags[4];
    128   unsigned char space_number[4];
    129   unsigned char subspace_index[4];
    130   unsigned char subspace_quantity[4];
    131   unsigned char loader_fix_index[4];
    132   unsigned char loader_fix_quantity[4];
    133   unsigned char init_pointer_index[4];
    134   unsigned char init_pointer_quantity[4];
    135 };
    136 
    137 #define SOM_SPACE_IS_LOADABLE		(1 << 31)
    138 #define SOM_SPACE_IS_DEFINED		(1 << 30)
    139 #define SOM_SPACE_IS_PRIVATE		(1 << 29)
    140 #define SOM_SPACE_HAS_INTERMEDIATE_CODE (1 << 28)
    141 #define SOM_SPACE_IS_TSPECIFIC		(1 << 27)
    142 #define SOM_SPACE_SORT_KEY_SH		8
    143 #define SOM_SPACE_SORT_KEY_MASK		0xff
    144 
    145 struct som_external_subspace_dictionary_record
    146 {
    147   unsigned char space_index[4];
    148   unsigned char flags[4];
    149   unsigned char file_loc_init_value[4];
    150   unsigned char initialization_length[4];
    151   unsigned char subspace_start[4];
    152   unsigned char subspace_length[4];
    153   unsigned char alignment[4];
    154   unsigned char name[4];
    155   unsigned char fixup_request_index[4];
    156   unsigned char fixup_request_quantity[4];
    157 };
    158 
    159 #define SOM_SUBSPACE_ACCESS_CONTROL_BITS_SH	25
    160 #define SOM_SUBSPACE_ACCESS_CONTROL_BITS_MASK	0x7f
    161 #define SOM_SUBSPACE_MEMORY_RESIDENT		(1 << 24)
    162 #define SOM_SUBSPACE_DUP_COMMON			(1 << 23)
    163 #define SOM_SUBSPACE_IS_COMMON			(1 << 22)
    164 #define SOM_SUBSPACE_IS_LOADABLE		(1 << 21)
    165 #define SOM_SUBSPACE_QUADRANT_SH		19
    166 #define SOM_SUBSPACE_QUADRANT_MASK		0x3
    167 #define SOM_SUBSPACE_INITIALLY_FROZEN		(1 << 18)
    168 #define SOM_SUBSPACE_IS_FIRST			(1 << 17)
    169 #define SOM_SUBSPACE_CODE_ONLY			(1 << 16)
    170 #define SOM_SUBSPACE_SORT_KEY_SH		8
    171 #define SOM_SUBSPACE_SORT_KEY_MASK		0xff
    172 #define SOM_SUBSPACE_REPLICATE_INIT		(1 << 7)
    173 #define SOM_SUBSPACE_CONTINUATION		(1 << 6)
    174 #define SOM_SUBSPACE_IS_TSPECIFIC		(1 << 5)
    175 #define SOM_SUBSPACE_IS_COMDAT			(1 << 4)
    176 
    177 struct som_external_compilation_unit
    178 {
    179   unsigned char name[4];
    180   unsigned char language_name[4];
    181   unsigned char product_id[4];
    182   unsigned char version_id[4];
    183   unsigned char flags[4];
    184   struct som_external_clock compile_time;
    185   struct som_external_clock source_time;
    186 };
    187 
    188 struct som_external_symbol_dictionary_record
    189 {
    190   unsigned char flags[4];
    191   unsigned char name[4];
    192   unsigned char qualifier_name[4];
    193   unsigned char info[4];
    194   unsigned char symbol_value[4];
    195 };
    196 
    197 /* Flags fields.  */
    198 #define SOM_SYMBOL_HIDDEN (1 << 31)
    199 #define SOM_SYMBOL_SECONDARY_DEF (1 << 30)
    200 #define SOM_SYMBOL_TYPE_SH 24
    201 #define SOM_SYMBOL_TYPE_MASK 0x3f
    202 #define SOM_SYMBOL_SCOPE_SH 20
    203 #define SOM_SYMBOL_SCOPE_MASK 0xf
    204 #define SOM_SYMBOL_CHECK_LEVEL_SH 17
    205 #define SOM_SYMBOL_CHECK_LEVEL_MASK 0x7
    206 #define SOM_SYMBOL_MUST_QUALIFY (1 << 16)
    207 #define SOM_SYMBOL_INITIALLY_FROZEN (1 << 15)
    208 #define SOM_SYMBOL_MEMORY_RESIDENT (1 << 14)
    209 #define SOM_SYMBOL_IS_COMMON (1 << 13)
    210 #define SOM_SYMBOL_DUP_COMMON (1 << 12)
    211 #define SOM_SYMBOL_XLEAST_SH 10
    212 #define SOM_SYMBOL_XLEAT_MASK 0x3
    213 #define SOM_SYMBOL_ARG_RELOC_SH 0
    214 #define SOM_SYMBOL_ARG_RELOC_MASK 0x3ff
    215 
    216 /* Info fields.  */
    217 #define SOM_SYMBOL_HAS_LONG_RETURN (1 << 31)
    218 #define SOM_SYMBOL_NO_RELOCATION (1 << 30)
    219 #define SOM_SYMBOL_IS_COMDAT (1 << 29)
    220 #define SOM_SYMBOL_SYMBOL_INFO_SH 0
    221 #define SOM_SYMBOL_SYMBOL_INFO_MASK 0xffffff
    222 
    223 /* Symbol type definition.  */
    224 #define ST_NULL		0
    225 #define ST_ABSOLUTE	1
    226 #define ST_DATA		2
    227 #define ST_CODE		3
    228 #define ST_PRI_PROG	4
    229 #define ST_SEC_PROG	5
    230 #define ST_ENTRY	6
    231 #define ST_STORAGE	7
    232 #define ST_STUB		8
    233 #define ST_MODULE	9
    234 #define ST_SYM_EXT	10
    235 #define ST_ARG_EXT	11
    236 #define ST_MILLICODE	12
    237 #define ST_PLABEL	13
    238 #define ST_OCT_DIS	14
    239 #define ST_MILLI_EXT	15
    240 #define ST_TSTORAGE	16
    241 #define ST_COMDAT	17
    242 
    243 /* Symbol scope.  */
    244 #define SS_UNSAT	0
    245 #define SS_EXTERNAL	1
    246 #define SS_LOCAL	2
    247 #define SS_UNIVERSAL	3
    248 
    249 #endif /* _SOM_AOUT_H */
    250