aboutsummaryrefslogtreecommitdiff
path: root/bfd/som.h
blob: 1015943e5c55a30ce0aee6db0e31f0b474c313fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* HP PA-RISC SOM object file format:  definitions internal to BFD.
   Copyright (C) 1990-1991 Free Software Foundation, Inc.

   Contributed by the Center for Software Science at the
   University of Utah (pa-gdb-bugs@cs.utah.edu).

   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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */

#ifndef _SOM_H
#define _SOM_H

#include "../bfd/sysdep.h"

#include <a.out.h>


#ifdef HOST_HPPABSD
/* BSD uses a completely different scheme for object file identification.
   so for now, define _PA_RISC_ID to accept any random value for a model
   number.  */
#undef _PA_RISC_ID
#define _PA_RISC_ID(__m_num) 1
#endif /* HOST_HPPABSD */

#define FILE_HDR_SIZE sizeof(struct header)
#define AUX_HDR_SIZE sizeof(struct som_exec_auxhdr)

typedef struct som_symbol
  {
    asymbol symbol;
    short desc;
    char other;
    unsigned char type;
    unsigned int som_type;

    /* Structured like the ELF tc_data union.  Allows more code sharing
       in GAS this way.  */
    union
      {
	unsigned int hppa_arg_reloc;
	PTR any;
      }
    tc_data;

    /* Index of this symbol in the symbol table.  Only used when
       building relocation streams for incomplete objects.  */
    int index;

    /* How many times this symbol is used in a relocation.  By sorting
       the symbols from most used to least used we can significantly
       reduce the size of the relocation stream for incomplete objects.  */
    int reloc_count;

    /* The unwind descriptor bits associated with R_ENTRY relocations
       for functions (not enough room in a BFD reloc to store all the
       information, so we tack it onto the symbol associated with the
       function.  */
    char *unwind;
  }
som_symbol_type;

struct somdata
  {
    struct header *file_hdr;
    som_symbol_type *symtab;
    char *stringtab;

    /* We remember these offsets so that after check_file_format, we have
       no dependencies on the particular format of the exec_hdr.  */

    file_ptr sym_filepos;
    file_ptr str_filepos;
    file_ptr reloc_filepos;

    unsigned stringtab_size;
  };

struct som_data_struct
  {
    struct somdata a;
  };

/* Used to keep extra SOM specific information for a given section.

   reloc_size holds the size of the relocation stream, note this
   is very different from the number of relocations as SOM relocations
   are variable length. 

   reloc_stream is the actual stream of relocation entries.

   The BFD section index may not exactly match a SOM subspace index,
   for this reason we keep track of the original SOM subspace index
   when a subspace is turned into a BFD section.  */

struct som_section_data_struct
  {
    unsigned int reloc_size;
    char *reloc_stream;
    unsigned int subspace_index;
    asection *containing_space;
    int is_space;
    struct space_dictionary_record space_dict;
    int is_subspace;
    struct subspace_dictionary_record subspace_dict;
  };

#define somdata(bfd)			((bfd)->tdata.som_data->a)
#define obj_som_file_hdr(bfd)		(somdata(bfd).file_hdr)
#define obj_som_symtab(bfd)		(somdata(bfd).symtab)
#define obj_som_stringtab(bfd)		(somdata(bfd).stringtab)
#define obj_som_sym_filepos(bfd)	(somdata(bfd).sym_filepos)
#define obj_som_str_filepos(bfd)	(somdata(bfd).str_filepos)
#define obj_som_stringtab_size(bfd)	(somdata(bfd).stringtab_size)
#define obj_som_reloc_filepos(bfd)	(somdata(bfd).reloc_filepos)
#define som_section_data(sec) \
  ((struct som_section_data_struct *)sec->used_by_bfd)
#define som_symbol_data(symbol) \
  (((som_symbol_type **) symbol->udata))


/* Defines groups of basic relocations.  FIXME:  These should
   be the only basic relocations created by GAS.  The rest
   should be internal to the BFD backend.

   The idea is both SOM and ELF define these basic relocation
   types so they map into a SOM or ELF specific reloation as
   appropriate.  This allows GAS to share much more code 
   between the two object formats.  */

#define R_HPPA_NONE			R_NO_RELOCATION
#define	R_HPPA				R_CODE_ONE_SYMBOL
#define	R_HPPA_ABS_CALL			R_ABS_CALL
#define	R_HPPA_PCREL_CALL		R_PCREL_CALL
#define	R_HPPA_GOTOFF			R_DP_RELATIVE
#define	R_HPPA_COMPLEX			R_COMP1
#define	R_HPPA_COMPLEX_PCREL_CALL	R_COMP2
#define	R_HPPA_COMPLEX_ABS_CALL		R_COMP3
#define R_HPPA_ENTRY			R_ENTRY
#define R_HPPA_EXIT			R_EXIT

#endif /* _SOM_H */