diff options
Diffstat (limited to 'include/som')
-rw-r--r-- | include/som/ChangeLog | 7 | ||||
-rw-r--r-- | include/som/aout.h | 249 | ||||
-rw-r--r-- | include/som/clock.h | 30 | ||||
-rw-r--r-- | include/som/internal.h | 206 | ||||
-rw-r--r-- | include/som/lst.h | 93 | ||||
-rw-r--r-- | include/som/reloc.h | 79 |
6 files changed, 664 insertions, 0 deletions
diff --git a/include/som/ChangeLog b/include/som/ChangeLog new file mode 100644 index 0000000..f55a417 --- /dev/null +++ b/include/som/ChangeLog @@ -0,0 +1,7 @@ +2010-06-10 Tristan Gingold <gingold@adacore.com> + + * aout.h: New file. + * clock.h: Likewise. + * lst.h: Likewise. + * reloc.h: Likewise. + * internal.h: Likewise. diff --git a/include/som/aout.h b/include/som/aout.h new file mode 100644 index 0000000..c3845ed --- /dev/null +++ b/include/som/aout.h @@ -0,0 +1,249 @@ +/* SOM a.out definitions for BFD. + Copyright 2010 Free Software Foundation, Inc. + Contributed by Tristan Gingold <gingold@adacore.com>, AdaCore. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _SOM_AOUT_H +#define _SOM_AOUT_H + +#include "clock.h" + +/* Note: SOM uses bit-field in its structure. All you need to know is: + - CPUs supported by SOM (hppa) are big-endian, + - the MSB is numbered 0. */ + +struct som_external_header +{ + unsigned char system_id[2]; + unsigned char a_magic[2]; + unsigned char version_id[4]; + struct som_external_clock file_time; + unsigned char entry_space[4]; + unsigned char entry_subspace[4]; + unsigned char entry_offset[4]; + unsigned char aux_header_location[4]; + unsigned char aux_header_size[4]; + unsigned char som_length[4]; + unsigned char presumed_dp[4]; + unsigned char space_location[4]; + unsigned char space_total[4]; + unsigned char subspace_location[4]; + unsigned char subspace_total[4]; + unsigned char loader_fixup_location[4]; + unsigned char loader_fixup_total[4]; + unsigned char space_strings_location[4]; + unsigned char space_strings_size[4]; + unsigned char init_array_location[4]; + unsigned char init_array_total[4]; + unsigned char compiler_location[4]; + unsigned char compiler_total[4]; + unsigned char symbol_location[4]; + unsigned char symbol_total[4]; + unsigned char fixup_request_location[4]; + unsigned char fixup_request_total[4]; + unsigned char symbol_strings_location[4]; + unsigned char symbol_strings_size[4]; + unsigned char unloadable_sp_location[4]; + unsigned char unloadable_sp_size[4]; + unsigned char checksum[4]; +}; + +#define OLD_VERSION_ID 85082112 +#define NEW_VERSION_ID 87102412 + +#define EXECLIBMAGIC 0x0104 +#define RELOC_MAGIC 0x0106 +#define EXEC_MAGIC 0x0107 +#define SHARE_MAGIC 0x0108 +#define SHMEM_MAGIC 0x0109 +#define DEMAND_MAGIC 0x010b +#define DL_MAGIC 0x010d +#define SHL_MAGIC 0x010e + +struct som_external_aux_id +{ + unsigned char flags[4]; + unsigned char length[4]; +}; + +/* Aux id types. */ +#define VERSION_AUX_ID 6 +#define COPYRIGHT_AUX_ID 9 + +/* Aux id flags. */ +#define SOM_AUX_ID_MANDATORY (1 << 31) +#define SOM_AUX_ID_COPY (1 << 30) +#define SOM_AUX_ID_APPEND (1 << 29) +#define SOM_AUX_ID_IGNORE (1 << 28) +#define SOM_AUX_ID_TYPE_SH 0 +#define SOM_AUX_ID_TYPE_MASK 0xffff + +struct som_external_string_auxhdr +{ + struct som_external_aux_id header_id; + + /* Length of the string, without the NUL. */ + unsigned char string_length[4]; + + /* The string. */ +}; + +struct som_external_exec_auxhdr +{ + struct som_external_aux_id som_auxhdr; + + unsigned char exec_tsize[4]; + unsigned char exec_tmem[4]; + unsigned char exec_tfile[4]; + unsigned char exec_dsize[4]; + unsigned char exec_dmem[4]; + unsigned char exec_dfile[4]; + unsigned char exec_bsize[4]; + unsigned char exec_entry[4]; + unsigned char exec_flags[4]; + unsigned char exec_bfill[4]; +}; + +#define AUX_HDR_SIZE sizeof (struct som_external_exec_auxhdr) + +struct som_external_space_dictionary_record +{ + unsigned char name[4]; + unsigned char flags[4]; + unsigned char space_number[4]; + unsigned char subspace_index[4]; + unsigned char subspace_quantity[4]; + unsigned char loader_fix_index[4]; + unsigned char loader_fix_quantity[4]; + unsigned char init_pointer_index[4]; + unsigned char init_pointer_quantity[4]; +}; + +#define SOM_SPACE_IS_LOADABLE (1 << 31) +#define SOM_SPACE_IS_DEFINED (1 << 30) +#define SOM_SPACE_IS_PRIVATE (1 << 29) +#define SOM_SPACE_HAS_INTERMEDIATE_CODE (1 << 28) +#define SOM_SPACE_IS_TSPECIFIC (1 << 27) +#define SOM_SPACE_SORT_KEY_SH 8 +#define SOM_SPACE_SORT_KEY_MASK 0xff + +struct som_external_subspace_dictionary_record +{ + unsigned char space_index[4]; + unsigned char flags[4]; + unsigned char file_loc_init_value[4]; + unsigned char initialization_length[4]; + unsigned char subspace_start[4]; + unsigned char subspace_length[4]; + unsigned char alignment[4]; + unsigned char name[4]; + unsigned char fixup_request_index[4]; + unsigned char fixup_request_quantity[4]; +}; + +#define SOM_SUBSPACE_ACCESS_CONTROL_BITS_SH 25 +#define SOM_SUBSPACE_ACCESS_CONTROL_BITS_MASK 0x7f +#define SOM_SUBSPACE_MEMORY_RESIDENT (1 << 24) +#define SOM_SUBSPACE_DUP_COMMON (1 << 23) +#define SOM_SUBSPACE_IS_COMMON (1 << 22) +#define SOM_SUBSPACE_IS_LOADABLE (1 << 21) +#define SOM_SUBSPACE_QUADRANT_SH 19 +#define SOM_SUBSPACE_QUADRANT_MASK 0x3 +#define SOM_SUBSPACE_INITIALLY_FROZEN (1 << 18) +#define SOM_SUBSPACE_IS_FIRST (1 << 17) +#define SOM_SUBSPACE_CODE_ONLY (1 << 16) +#define SOM_SUBSPACE_SORT_KEY_SH 8 +#define SOM_SUBSPACE_SORT_KEY_MASK 0xff +#define SOM_SUBSPACE_REPLICATE_INIT (1 << 7) +#define SOM_SUBSPACE_CONTINUATION (1 << 6) +#define SOM_SUBSPACE_IS_TSPECIFIC (1 << 5) +#define SOM_SUBSPACE_IS_COMDAT (1 << 4) + +struct som_external_compilation_unit +{ + unsigned char name[4]; + unsigned char language_name[4]; + unsigned char product_id[4]; + unsigned char version_id[4]; + unsigned char flags[4]; + struct som_external_clock compile_time; + struct som_external_clock source_time; +}; + +struct som_external_symbol_dictionary_record +{ + unsigned char flags[4]; + unsigned char name[4]; + unsigned char qualifier_name[4]; + unsigned char info[4]; + unsigned char symbol_value[4]; +}; + +/* Flags fields. */ +#define SOM_SYMBOL_HIDDEN (1 << 31) +#define SOM_SYMBOL_SECONDARY_DEF (1 << 30) +#define SOM_SYMBOL_TYPE_SH 24 +#define SOM_SYMBOL_TYPE_MASK 0x3f +#define SOM_SYMBOL_SCOPE_SH 20 +#define SOM_SYMBOL_SCOPE_MASK 0xf +#define SOM_SYMBOL_CHECK_LEVEL_SH 17 +#define SOM_SYMBOL_CHECK_LEVEL_MASK 0x7 +#define SOM_SYMBOL_MUST_QUALIFY (1 << 16) +#define SOM_SYMBOL_INITIALLY_FROZEN (1 << 15) +#define SOM_SYMBOL_MEMORY_RESIDENT (1 << 14) +#define SOM_SYMBOL_IS_COMMON (1 << 13) +#define SOM_SYMBOL_DUP_COMMON (1 << 12) +#define SOM_SYMBOL_XLEAST_SH 10 +#define SOM_SYMBOL_XLEAT_MASK 0x3 +#define SOM_SYMBOL_ARG_RELOC_SH 0 +#define SOM_SYMBOL_ARG_RELOC_MASK 0x3ff + +/* Info fields. */ +#define SOM_SYMBOL_HAS_LONG_RETURN (1 << 31) +#define SOM_SYMBOL_NO_RELOCATION (1 << 30) +#define SOM_SYMBOL_IS_COMDAT (1 << 29) +#define SOM_SYMBOL_SYMBOL_INFO_SH 0 +#define SOM_SYMBOL_SYMBOL_INFO_MASK 0xffffff + +/* Symbol type definition. */ +#define ST_NULL 0 +#define ST_ABSOLUTE 1 +#define ST_DATA 2 +#define ST_CODE 3 +#define ST_PRI_PROG 4 +#define ST_SEC_PROG 5 +#define ST_ENTRY 6 +#define ST_STORAGE 7 +#define ST_STUB 8 +#define ST_MODULE 9 +#define ST_SYM_EXT 10 +#define ST_ARG_EXT 11 +#define ST_MILLICODE 12 +#define ST_PLABEL 13 +#define ST_OCT_DIS 14 +#define ST_MILLI_EXT 15 +#define ST_TSTORAGE 16 +#define ST_COMDAT 17 + +/* Symbol scope. */ +#define SS_UNSAT 0 +#define SS_EXTERNAL 1 +#define SS_LOCAL 2 +#define SS_UNIVERSAL 3 + +#endif /* _SOM_AOUT_H */ diff --git a/include/som/clock.h b/include/som/clock.h new file mode 100644 index 0000000..e2a7ba6 --- /dev/null +++ b/include/som/clock.h @@ -0,0 +1,30 @@ +/* SOM clock definition for BFD. + Copyright 2010 Free Software Foundation, Inc. + Contributed by Tristan Gingold <gingold@adacore.com>, AdaCore. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _SOM_CLOCK_H +#define _SOM_CLOCK_H + +struct som_external_clock +{ + unsigned char secs[4]; + unsigned char nanosecs[4]; +}; + +#endif /* _SOM_CLOCK_H */ diff --git a/include/som/internal.h b/include/som/internal.h new file mode 100644 index 0000000..e3889fb --- /dev/null +++ b/include/som/internal.h @@ -0,0 +1,206 @@ +/* SOM internal definitions for BFD. + Copyright 2010 Free Software Foundation, Inc. + Contributed by Tristan Gingold <gingold@adacore.com>, AdaCore. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _SOM_INTERNAL_H +#define _SOM_INTERNAL_H + +struct som_clock +{ + unsigned int secs; + unsigned int nanosecs; +}; + +struct som_header +{ + unsigned short system_id; + unsigned short a_magic; + unsigned int version_id; + struct som_clock file_time; + unsigned int entry_space; + unsigned int entry_subspace; + unsigned int entry_offset; + unsigned int aux_header_location; + unsigned int aux_header_size; + unsigned int som_length; + unsigned int presumed_dp; + unsigned int space_location; + unsigned int space_total; + unsigned int subspace_location; + unsigned int subspace_total; + unsigned int loader_fixup_location; + unsigned int loader_fixup_total; + unsigned int space_strings_location; + unsigned int space_strings_size; + unsigned int init_array_location; + unsigned int init_array_total; + unsigned int compiler_location; + unsigned int compiler_total; + unsigned int symbol_location; + unsigned int symbol_total; + unsigned int fixup_request_location; + unsigned int fixup_request_total; + unsigned int symbol_strings_location; + unsigned int symbol_strings_size; + unsigned int unloadable_sp_location; + unsigned int unloadable_sp_size; + unsigned int checksum; +}; + +struct som_aux_id +{ + unsigned int mandatory : 1; + unsigned int copy : 1; + unsigned int append : 1; + unsigned int ignore : 1; + unsigned int reserved : 12; + + /* Header type. */ + unsigned int type : 16; + + /* Length of the header in bytes, without the two word identifier. */ + unsigned int length; +}; + +/* Generic auxiliary string header. */ +struct som_string_auxhdr +{ + struct som_aux_id header_id; + + /* Length of the string, without the NUL. */ + unsigned int string_length; + + /* The string. */ + char string[1]; +}; + +struct som_name_pt +{ + char *name; + unsigned int strx; +}; + +struct som_compilation_unit +{ + /* Source file that produced the SOM. */ + struct som_name_pt name; + + /* Name of the language used when creating this SOM. */ + struct som_name_pt language_name; + + /* Identificaton of the compiler. */ + struct som_name_pt product_id; + + /* Version id of the compiler. */ + struct som_name_pt version_id; + + unsigned int flags; + struct som_clock compile_time; + struct som_clock source_time; +}; + +struct som_exec_auxhdr +{ + struct som_aux_id som_auxhdr; + + long exec_tsize; + long exec_tmem; + long exec_tfile; + long exec_dsize; + long exec_dmem; + long exec_dfile; + long exec_bsize; + long exec_entry; + long exec_flags; + long exec_bfill; +}; + +struct som_space_dictionary_record +{ + unsigned int name; + unsigned int is_loadable : 1; + unsigned int is_defined : 1; + unsigned int is_private : 1; + unsigned int has_intermediate_code : 1; + unsigned int is_tspecific : 1; + unsigned int reserved : 11; + unsigned int sort_key : 8; + unsigned int reserved2 : 8; + int space_number; + int subspace_index; + unsigned int subspace_quantity; + int loader_fix_index; + unsigned int loader_fix_quantity; + int init_pointer_index; + unsigned int init_pointer_quantity; +}; + +struct som_subspace_dictionary_record +{ + int space_index; + unsigned int access_control_bits : 7; + unsigned int memory_resident : 1; + unsigned int dup_common : 1; + unsigned int is_common : 1; + unsigned int is_loadable : 1; + unsigned int quadrant : 2; + unsigned int initially_frozen : 1; + unsigned int is_first : 1; + unsigned int code_only : 1; + unsigned int sort_key : 8; + unsigned int replicate_init : 1; + unsigned int continuation : 1; + unsigned int is_tspecific : 1; + unsigned int is_comdat : 1; + unsigned int reserved : 4; + int file_loc_init_value; + unsigned int initialization_length; + unsigned int subspace_start; + unsigned int subspace_length; + unsigned int reserved2 : 5; + unsigned int alignment : 27; + unsigned int name; + int fixup_request_index; + unsigned int fixup_request_quantity; +}; + +struct som_lst_header +{ + unsigned short system_id; + unsigned short a_magic; + unsigned int version_id; + struct som_clock file_time; + unsigned int hash_loc; + unsigned int hash_size; + unsigned int module_count; + unsigned int module_limit; + unsigned int dir_loc; + unsigned int export_loc; + unsigned int export_count; + unsigned int import_loc; + unsigned int aux_loc; + unsigned int aux_size; + unsigned int string_loc; + unsigned int string_size; + unsigned int free_list; + unsigned int file_end; + unsigned int checksum; +}; + +#endif /* _SOM_INTERNAL_H */ diff --git a/include/som/lst.h b/include/som/lst.h new file mode 100644 index 0000000..6088b47 --- /dev/null +++ b/include/som/lst.h @@ -0,0 +1,93 @@ +/* SOM lst definitions for BFD. + Copyright 2010 Free Software Foundation, Inc. + Contributed by Tristan Gingold <gingold@adacore.com>, AdaCore. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _SOM_LST_H +#define _SOM_LST_H + +#include "clock.h" + +/* See 4.2 Libraray Symbol Table Header Record. */ +struct som_external_lst_header +{ + unsigned char system_id[2]; + unsigned char a_magic[2]; + unsigned char version_id[4]; + struct som_external_clock file_time; + unsigned char hash_loc[4]; + unsigned char hash_size[4]; + unsigned char module_count[4]; + unsigned char module_limit[4]; + unsigned char dir_loc[4]; + unsigned char export_loc[4]; + unsigned char export_count[4]; + unsigned char import_loc[4]; + unsigned char aux_loc[4]; + unsigned char aux_size[4]; + unsigned char string_loc[4]; + unsigned char string_size[4]; + unsigned char free_list[4]; + unsigned char file_end[4]; + unsigned char checksum[4]; +}; + +#define VERSION_ID 85082112 +#define LIBMAGIC 0x0619 +#define LIBMAGIC_EXEC 0x0104 + +struct som_external_lst_symbol_record +{ + unsigned char flags[4]; + unsigned char name[4]; + unsigned char qualifier_name[4]; + unsigned char symbol_info[4]; + unsigned char symbol_value[4]; + unsigned char symbol_descriptor[4]; + unsigned char reserved; + unsigned char max_num_args; + unsigned char min_num_args; + unsigned char num_args; + unsigned char som_index[4]; + unsigned char symbol_key[4]; + unsigned char next_entry[4]; +}; + +/* Fields of flags. */ +#define LST_SYMBOL_HIDDEN (1 << 31) +#define LST_SYMBOL_SECONDARY_DEF (1 << 30) +#define LST_SYMBOL_SYMBOL_TYPE_SH 24 +#define LST_SYMBOL_SYMBOL_SCOPE_SH 20 +#define LST_SYMBOL_CHECK_LEVEL_SH 17 +#define LST_SYMBOL_MUST_QUALIFY (1 << 16) +#define LST_SYMBOL_INITIALY_FROZEN (1 << 15) +#define LST_SYMBOL_MEMORY_RESIDENT (1 << 14) +#define LST_SYMBOL_IS_COMMON (1 << 13) +#define LST_SYMBOL_DUP_COMMON (1 << 12) +#define LST_SYMBOL_XLEAST_SH 10 +#define LST_SYMBOL_ARG_RELOC_SH 0 + +/* According to 4.3.2 SOM Directory. */ + +struct som_external_som_entry +{ + unsigned char location[4]; + unsigned char length[4]; +}; + +#endif /* _SOM_LST_H */ diff --git a/include/som/reloc.h b/include/som/reloc.h new file mode 100644 index 0000000..417b5ee --- /dev/null +++ b/include/som/reloc.h @@ -0,0 +1,79 @@ +/* SOM relocation definitions for BFD. + Copyright 2010 Free Software Foundation, Inc. + Contributed by Tristan Gingold <gingold@adacore.com>, AdaCore. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _SOM_RELOC_H +#define _SOM_RELOC_H + +#define R_NO_RELOCATION 0 +#define R_ZEROES 0x20 +#define R_UNINIT 0x22 +#define R_RELOCATION 0x24 +#define R_DATA_ONE_SYMBOL 0x25 +#define R_DATA_PLABEL 0x27 +#define R_SPACE_REF 0x29 +#define R_REPEATED_INIT 0x2a +#define R_PCREL_CALL 0x30 +#define R_SHORT_PCREL_MODE 0x3e +#define R_LONG_PCREL_MODE 0x3f +#define R_ABS_CALL 0x40 +#define R_DP_RELATIVE 0x50 +#define R_DATA_GPREL 0x72 +#define R_INDIRECT_CALL 0x76 +#define R_PLT_REL 0x77 +#define R_DLT_REL 0x78 +#define R_CODE_ONE_SYMBOL 0x80 +#define R_MILLI_REL 0xae +#define R_CODE_PLABEL 0xb0 +#define R_BREAKPOINT 0xb2 +#define R_ENTRY 0xb3 +#define R_ALT_ENTRY 0xb5 +#define R_EXIT 0xb6 +#define R_BEGIN_TRY 0xb7 +#define R_END_TRY 0xb8 +#define R_BEGIN_BRTAB 0xbb +#define R_END_BRTAB 0xbc +#define R_STATEMENT 0xbd +#define R_DATA_EXPR 0xc0 +#define R_CODE_EXPR 0xc1 +#define R_FSEL 0xc2 +#define R_LSEL 0xc3 +#define R_RSEL 0xc4 +#define R_N_MODE 0xc5 +#define R_S_MODE 0xc6 +#define R_D_MODE 0xc7 +#define R_R_MODE 0xc8 +#define R_DATA_OVERRIDE 0xc9 +#define R_TRANSLATED 0xce +#define R_AUX_UNWIND 0xcf +#define R_COMP1 0xd0 +#define R_COMP2 0xd1 +#define R_COMP3 0xd2 +#define R_PREV_FIXUP 0xd3 +#define R_SEC_STMT 0xd7 +#define R_N0SEL 0xd8 +#define R_N1SEL 0xd9 +#define R_LINETAB 0xda +#define R_LINETAB_ESC 0xdb +#define R_LTP_OVERRIDE 0xdc +#define R_COMMENT 0xdd +#define R_TP_OVERRIDE 0xde +#define R_RESERVED 0xdf + +#endif /* _SOM_RELOC_H */ |