]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/config/obj-som.c
* config/obj-som.c (obj_som_version): Pass version string to
[thirdparty/binutils-gdb.git] / gas / config / obj-som.c
1 /* SOM object file format.
2 Copyright (C) 1993 Free Software Foundation, Inc.
3
4 This file is part of GAS, the GNU Assembler.
5
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2,
9 or (at your option) any later version.
10
11 GAS is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
14 the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public
17 License along with GAS; see the file COPYING. If not, write
18 to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 Written by the Center for Software Science at the University of Utah
21 and by Cygnus Support. */
22
23 #include "as.h"
24 #include "subsegs.h"
25 #include "aout/stab_gnu.h"
26 #include "obstack.h"
27
28 /* SOM does not need any pseudo-ops. */
29
30 const pseudo_typeS obj_pseudo_table[] =
31 {
32 {NULL}
33 };
34
35 static int version_seen = 0;
36 static int copyright_seen = 0;
37
38 /* Handle a .version directive. */
39
40 void
41 obj_som_version (unused)
42 int unused;
43 {
44 char *version, c;
45
46 if (version_seen)
47 {
48 as_bad ("Only one .version pseudo-op per file!");
49 ignore_rest_of_line ();
50 return;
51 }
52
53 SKIP_WHITESPACE ();
54 if (*input_line_pointer == '\"')
55 {
56 version = input_line_pointer;
57 ++input_line_pointer;
58 while (is_a_char (next_char_of_string ()))
59 ;
60 c = *input_line_pointer;
61 *input_line_pointer = '\000';
62 }
63 else
64 {
65 as_bad ("Expected quoted string");
66 ignore_rest_of_line ();
67 return;
68 }
69
70 version_seen = 1;
71 bfd_som_attach_aux_hdr (stdoutput, VERSION_AUX_ID, version);
72 *input_line_pointer = c;
73 demand_empty_rest_of_line ();
74 }
75
76 /* Handle a .copyright directive. This probably isn't complete, but
77 it's of dubious value anyway and (IMHO) not worth the time to finish.
78 If you care about copyright strings that much, you fix it. */
79
80 void
81 obj_som_copyright (unused)
82 int unused;
83 {
84 char *copyright, c;
85
86 if (copyright_seen)
87 {
88 as_bad ("Only one .copyright pseudo-op per file!");
89 ignore_rest_of_line ();
90 return;
91 }
92
93 SKIP_WHITESPACE ();
94 if (*input_line_pointer == '\"')
95 {
96 copyright = input_line_pointer;
97 ++input_line_pointer;
98 while (is_a_char (next_char_of_string ()))
99 ;
100 c = *input_line_pointer;
101 *input_line_pointer = '\000';
102 }
103 else
104 {
105 as_bad ("Expected quoted string");
106 ignore_rest_of_line ();
107 return;
108 }
109
110 copyright_seen = 1;
111 bfd_som_attach_aux_hdr (stdoutput, COPYRIGHT_AUX_ID, copyright);
112 *input_line_pointer = c;
113 demand_empty_rest_of_line ();
114 }
115
116 /* Perform any initialization necessary for stabs support.
117
118 For SOM we need to create the space which will contain the
119 two stabs subspaces. Additionally we need to set up the
120 space/subspace relationships and set space/subspace attributes
121 which BFD does not understand. */
122
123 void
124 obj_som_init_stab_section (seg)
125 segT seg;
126 {
127 segT saved_seg = now_seg;
128 segT space;
129 subsegT saved_subseg = now_subseg;
130 char *p, *file;
131 unsigned int stroff;
132
133 /* Make the space which will contain the debug subspaces. */
134 space = bfd_make_section_old_way (stdoutput, "$GDB_DEBUG$");
135
136 /* Set SOM specific attributes for the space. In particular we set
137 the space "defined", "private", "sort_key", and "spnum" values.
138
139 Due to a bug in pxdb (called by hpux linker), the sort keys
140 of the various stabs spaces/subspaces need to be "small". We
141 reserve range 72/73 which appear to work well. */
142 obj_set_section_attributes (space, 1, 1, 72, 2);
143 bfd_set_section_alignment (stdoutput, space, 2);
144
145 /* Set the containing space for both stab sections to be $GDB_DEBUG$
146 (just created above). Also set some attributes which BFD does
147 not understand. In particular, access bits, sort keys, and load
148 quadrant. */
149 obj_set_subsection_attributes (seg, space, 0x1f, 73, 0);
150 bfd_set_section_alignment (stdoutput, seg, 2);
151
152 /* Make some space for the first stab entry which is special.
153 It contains information about the length of this file's
154 stab string and the like. Using it avoids the need to
155 relocate the stab strings.
156
157 The $GDB_STRINGS$ space will be created as a side effect of
158 the call to get_stab_string_offset. */
159 p = frag_more (12);
160 as_where (&file, (unsigned int *) NULL);
161 stroff = get_stab_string_offset (file, "$GDB_STRINGS$");
162 know (stroff == 1);
163 md_number_to_chars (p, stroff, 4);
164 seg_info (seg)->stabu.p = p;
165
166 /* Set the containing space for both stab sections to be $GDB_DEBUG$
167 (just created above). Also set some attributes which BFD does
168 not understand. In particular, access bits, sort keys, and load
169 quadrant. */
170 seg = bfd_get_section_by_name (stdoutput, "$GDB_STRINGS$");
171 obj_set_subsection_attributes (seg, space, 0x1f, 72, 0);
172 bfd_set_section_alignment (stdoutput, seg, 2);
173
174 subseg_set (saved_seg, saved_subseg);
175 }
176
177 /* Fill in the counts in the first entry in a .stabs section. */
178
179 static void
180 adjust_stab_sections (abfd, sec, xxx)
181 bfd *abfd;
182 asection *sec;
183 PTR xxx;
184 {
185 asection *strsec;
186 char *p;
187 int strsz, nsyms;
188
189 if (strcmp ("$GDB_SYMBOLS$", sec->name))
190 return;
191
192 strsec = bfd_get_section_by_name (abfd, "$GDB_STRINGS$");
193 if (strsec)
194 strsz = bfd_section_size (abfd, strsec);
195 else
196 strsz = 0;
197 nsyms = bfd_section_size (abfd, sec) / 12 - 1;
198
199 p = seg_info (sec)->stabu.p;
200 assert (p != 0);
201
202 bfd_h_put_16 (abfd, (bfd_vma) nsyms, (bfd_byte *) p + 6);
203 bfd_h_put_32 (abfd, (bfd_vma) strsz, (bfd_byte *) p + 8);
204 }
205
206 /* Called late in the asssembly phase to adjust the special
207 stab entry. This is where any other late object-file dependent
208 processing which should happen. */
209
210 void
211 som_frob_file ()
212 {
213 bfd_map_over_sections (stdoutput, adjust_stab_sections, (PTR) 0);
214 }