1 /* SOM object file format.
2 Copyright 1993, 1994, 1998, 2000, 2002 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 Written by the Center for Software Science at the University of Utah
22 and by Cygnus Support. */
26 #include "aout/stab_gnu.h"
29 static void obj_som_weak
PARAMS ((int));
30 static void adjust_stab_sections
PARAMS ((bfd
*, asection
*, PTR
));
32 const pseudo_typeS obj_pseudo_table
[] =
34 {"weak", obj_som_weak
, 0},
38 static int version_seen
= 0;
39 static int copyright_seen
= 0;
40 static int compiler_seen
= 0;
45 obj_read_begin_hook ()
49 /* Handle a .compiler directive. This is intended to create the
50 compilation unit auxiliary header for MPE such that the linkeditor
51 can handle SOM extraction from archives. The format of the quoted
52 string is "sourcefile language version" and is delimited by blanks. */
55 obj_som_compiler (unused
)
56 int unused ATTRIBUTE_UNUSED
;
67 as_bad ("Only one .compiler pseudo-op per file!");
68 ignore_rest_of_line ();
73 if (*input_line_pointer
== '\"')
75 buf
= input_line_pointer
;
77 while (is_a_char (next_char_of_string ()))
79 c
= *input_line_pointer
;
80 *input_line_pointer
= '\000';
84 as_bad ("Expected quoted string");
85 ignore_rest_of_line ();
89 /* Parse the quoted string into its component parts. Skip the
93 while (*p
!= ' ' && *p
!= '\000')
97 as_bad (".compiler directive missing language and version");
103 while (*p
!= ' ' && *p
!= '\000')
107 as_bad (".compiler directive missing version");
115 /* Remove the trailing quote. */
119 if (! bfd_som_attach_compilation_unit (stdoutput
, filename
, language_name
,
120 "GNU Tools", version_id
))
122 bfd_perror (stdoutput
->filename
);
123 as_fatal ("FATAL: Attaching compiler header %s", stdoutput
->filename
);
125 *input_line_pointer
= c
;
126 demand_empty_rest_of_line ();
129 /* Handle a .version directive. */
132 obj_som_version (unused
)
133 int unused ATTRIBUTE_UNUSED
;
139 as_bad (_("Only one .version pseudo-op per file!"));
140 ignore_rest_of_line ();
145 if (*input_line_pointer
== '\"')
147 version
= input_line_pointer
;
148 ++input_line_pointer
;
149 while (is_a_char (next_char_of_string ()))
151 c
= *input_line_pointer
;
152 *input_line_pointer
= '\000';
156 as_bad (_("Expected quoted string"));
157 ignore_rest_of_line ();
162 if (!bfd_som_attach_aux_hdr (stdoutput
, VERSION_AUX_ID
, version
))
164 bfd_perror (stdoutput
->filename
);
165 as_perror (_("FATAL: Attaching version header %s"),
166 stdoutput
->filename
);
169 *input_line_pointer
= c
;
170 demand_empty_rest_of_line ();
173 /* Handle a .copyright directive. This probably isn't complete, but
174 it's of dubious value anyway and (IMHO) not worth the time to finish.
175 If you care about copyright strings that much, you fix it. */
178 obj_som_copyright (unused
)
179 int unused ATTRIBUTE_UNUSED
;
185 as_bad (_("Only one .copyright pseudo-op per file!"));
186 ignore_rest_of_line ();
191 if (*input_line_pointer
== '\"')
193 copyright
= input_line_pointer
;
194 ++input_line_pointer
;
195 while (is_a_char (next_char_of_string ()))
197 c
= *input_line_pointer
;
198 *input_line_pointer
= '\000';
202 as_bad (_("Expected quoted string"));
203 ignore_rest_of_line ();
208 if (!bfd_som_attach_aux_hdr (stdoutput
, COPYRIGHT_AUX_ID
, copyright
))
210 bfd_perror (stdoutput
->filename
);
211 as_perror (_("FATAL: Attaching copyright header %s"),
212 stdoutput
->filename
);
215 *input_line_pointer
= c
;
216 demand_empty_rest_of_line ();
219 /* Perform any initialization necessary for stabs support.
221 For SOM we need to create the space which will contain the
222 two stabs subspaces. Additionally we need to set up the
223 space/subspace relationships and set space/subspace attributes
224 which BFD does not understand. */
227 obj_som_init_stab_section (seg
)
230 segT saved_seg
= now_seg
;
232 subsegT saved_subseg
= now_subseg
;
236 /* Make the space which will contain the debug subspaces. */
237 space
= bfd_make_section_old_way (stdoutput
, "$GDB_DEBUG$");
239 /* Set SOM specific attributes for the space. In particular we set
240 the space "defined", "private", "sort_key", and "spnum" values.
242 Due to a bug in pxdb (called by hpux linker), the sort keys
243 of the various stabs spaces/subspaces need to be "small". We
244 reserve range 72/73 which appear to work well. */
245 obj_set_section_attributes (space
, 1, 1, 72, 2);
246 bfd_set_section_alignment (stdoutput
, space
, 2);
248 /* Set the containing space for both stab sections to be $GDB_DEBUG$
249 (just created above). Also set some attributes which BFD does
250 not understand. In particular, access bits, sort keys, and load
252 obj_set_subsection_attributes (seg
, space
, 0x1f, 73, 0, 0, 0, 0);
253 bfd_set_section_alignment (stdoutput
, seg
, 2);
255 /* Make some space for the first special stab entry and zero the memory.
256 It contains information about the length of this file's
257 stab string and the like. Using it avoids the need to
258 relocate the stab strings.
260 The $GDB_STRINGS$ space will be created as a side effect of
261 the call to get_stab_string_offset. */
264 as_where (&file
, (unsigned int *) NULL
);
265 stroff
= get_stab_string_offset (file
, "$GDB_STRINGS$");
267 md_number_to_chars (p
, stroff
, 4);
268 seg_info (seg
)->stabu
.p
= p
;
270 /* Set the containing space for both stab sections to be $GDB_DEBUG$
271 (just created above). Also set some attributes which BFD does
272 not understand. In particular, access bits, sort keys, and load
274 seg
= bfd_get_section_by_name (stdoutput
, "$GDB_STRINGS$");
275 obj_set_subsection_attributes (seg
, space
, 0x1f, 72, 0, 0, 0, 0);
276 bfd_set_section_alignment (stdoutput
, seg
, 2);
278 subseg_set (saved_seg
, saved_subseg
);
281 /* Fill in the counts in the first entry in a .stabs section. */
284 adjust_stab_sections (abfd
, sec
, xxx
)
287 PTR xxx ATTRIBUTE_UNUSED
;
293 if (strcmp ("$GDB_SYMBOLS$", sec
->name
))
296 strsec
= bfd_get_section_by_name (abfd
, "$GDB_STRINGS$");
298 strsz
= bfd_section_size (abfd
, strsec
);
301 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
303 p
= seg_info (sec
)->stabu
.p
;
306 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
307 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
310 /* Called late in the assembly phase to adjust the special
311 stab entry and to set the starting address for each code subspace. */
316 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
320 obj_som_weak (ignore
)
321 int ignore ATTRIBUTE_UNUSED
;
329 name
= input_line_pointer
;
330 c
= get_symbol_end ();
331 symbolP
= symbol_find_or_make (name
);
332 *input_line_pointer
= c
;
334 S_SET_WEAK (symbolP
);
336 symbol_get_obj (symbolP
)->local
= 1;
340 input_line_pointer
++;
342 if (*input_line_pointer
== '\n')
347 demand_empty_rest_of_line ();