1 /* SOM object file format.
2 Copyright 1993, 1994, 1998, 2000, 2002, 2003, 2004, 2005
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2,
10 or (at your option) any later version.
12 GAS is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 Written by the Center for Software Science at the University of Utah
23 and by Cygnus Support. */
27 #include "aout/stab_gnu.h"
30 static int version_seen
= 0;
31 static int copyright_seen
= 0;
32 static int compiler_seen
= 0;
37 obj_read_begin_hook (void)
41 /* Handle a .compiler directive. This is intended to create the
42 compilation unit auxiliary header for MPE such that the linkeditor
43 can handle SOM extraction from archives. The format of the quoted
44 string is "sourcefile language version" and is delimited by blanks. */
47 obj_som_compiler (int unused ATTRIBUTE_UNUSED
)
58 as_bad ("Only one .compiler pseudo-op per file!");
59 ignore_rest_of_line ();
64 if (*input_line_pointer
== '\"')
66 buf
= input_line_pointer
;
68 while (is_a_char (next_char_of_string ()))
70 c
= *input_line_pointer
;
71 *input_line_pointer
= '\000';
75 as_bad ("Expected quoted string");
76 ignore_rest_of_line ();
80 /* Parse the quoted string into its component parts. Skip the
84 while (*p
!= ' ' && *p
!= '\000')
88 as_bad (".compiler directive missing language and version");
94 while (*p
!= ' ' && *p
!= '\000')
98 as_bad (".compiler directive missing version");
106 /* Remove the trailing quote. */
110 if (! bfd_som_attach_compilation_unit (stdoutput
, filename
, language_name
,
111 "GNU Tools", version_id
))
113 bfd_perror (stdoutput
->filename
);
114 as_fatal ("FATAL: Attaching compiler header %s", stdoutput
->filename
);
116 *input_line_pointer
= c
;
117 demand_empty_rest_of_line ();
120 /* Handle a .version directive. */
123 obj_som_version (int unused ATTRIBUTE_UNUSED
)
129 as_bad (_("Only one .version pseudo-op per file!"));
130 ignore_rest_of_line ();
135 if (*input_line_pointer
== '\"')
137 version
= input_line_pointer
;
138 ++input_line_pointer
;
139 while (is_a_char (next_char_of_string ()))
141 c
= *input_line_pointer
;
142 *input_line_pointer
= '\000';
146 as_bad (_("Expected quoted string"));
147 ignore_rest_of_line ();
152 if (!bfd_som_attach_aux_hdr (stdoutput
, VERSION_AUX_ID
, version
))
154 bfd_perror (stdoutput
->filename
);
155 as_perror (_("FATAL: Attaching version header %s"),
156 stdoutput
->filename
);
159 *input_line_pointer
= c
;
160 demand_empty_rest_of_line ();
163 /* Handle a .copyright directive. This probably isn't complete, but
164 it's of dubious value anyway and (IMHO) not worth the time to finish.
165 If you care about copyright strings that much, you fix it. */
168 obj_som_copyright (int unused ATTRIBUTE_UNUSED
)
174 as_bad (_("Only one .copyright pseudo-op per file!"));
175 ignore_rest_of_line ();
180 if (*input_line_pointer
== '\"')
182 copyright
= input_line_pointer
;
183 ++input_line_pointer
;
184 while (is_a_char (next_char_of_string ()))
186 c
= *input_line_pointer
;
187 *input_line_pointer
= '\000';
191 as_bad (_("Expected quoted string"));
192 ignore_rest_of_line ();
197 if (!bfd_som_attach_aux_hdr (stdoutput
, COPYRIGHT_AUX_ID
, copyright
))
199 bfd_perror (stdoutput
->filename
);
200 as_perror (_("FATAL: Attaching copyright header %s"),
201 stdoutput
->filename
);
204 *input_line_pointer
= c
;
205 demand_empty_rest_of_line ();
208 /* Perform any initialization necessary for stabs support.
210 For SOM we need to create the space which will contain the
211 two stabs subspaces. Additionally we need to set up the
212 space/subspace relationships and set space/subspace attributes
213 which BFD does not understand. */
216 obj_som_init_stab_section (segT seg
)
218 segT saved_seg
= now_seg
;
220 subsegT saved_subseg
= now_subseg
;
224 /* Make the space which will contain the debug subspaces. */
225 space
= bfd_make_section_old_way (stdoutput
, "$GDB_DEBUG$");
227 /* Set SOM specific attributes for the space. In particular we set
228 the space "defined", "private", "sort_key", and "spnum" values.
230 Due to a bug in pxdb (called by hpux linker), the sort keys
231 of the various stabs spaces/subspaces need to be "small". We
232 reserve range 72/73 which appear to work well. */
233 obj_set_section_attributes (space
, 1, 1, 72, 2);
234 bfd_set_section_alignment (stdoutput
, space
, 2);
236 /* Set the containing space for both stab sections to be $GDB_DEBUG$
237 (just created above). Also set some attributes which BFD does
238 not understand. In particular, access bits, sort keys, and load
240 obj_set_subsection_attributes (seg
, space
, 0x1f, 73, 0, 0, 0, 0);
241 bfd_set_section_alignment (stdoutput
, seg
, 2);
243 /* Make some space for the first special stab entry and zero the memory.
244 It contains information about the length of this file's
245 stab string and the like. Using it avoids the need to
246 relocate the stab strings.
248 The $GDB_STRINGS$ space will be created as a side effect of
249 the call to get_stab_string_offset. */
252 as_where (&file
, (unsigned int *) NULL
);
253 stroff
= get_stab_string_offset (file
, "$GDB_STRINGS$");
255 md_number_to_chars (p
, stroff
, 4);
256 seg_info (seg
)->stabu
.p
= p
;
258 /* Set the containing space for both stab sections to be $GDB_DEBUG$
259 (just created above). Also set some attributes which BFD does
260 not understand. In particular, access bits, sort keys, and load
262 seg
= bfd_get_section_by_name (stdoutput
, "$GDB_STRINGS$");
263 obj_set_subsection_attributes (seg
, space
, 0x1f, 72, 0, 0, 0, 0);
264 bfd_set_section_alignment (stdoutput
, seg
, 2);
266 subseg_set (saved_seg
, saved_subseg
);
269 /* Fill in the counts in the first entry in a .stabs section. */
272 adjust_stab_sections (bfd
*abfd
, asection
*sec
, PTR xxx ATTRIBUTE_UNUSED
)
278 if (strcmp ("$GDB_SYMBOLS$", sec
->name
))
281 strsec
= bfd_get_section_by_name (abfd
, "$GDB_STRINGS$");
283 strsz
= bfd_section_size (abfd
, strsec
);
286 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
288 p
= seg_info (sec
)->stabu
.p
;
291 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
292 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
295 /* Called late in the assembly phase to adjust the special
296 stab entry and to set the starting address for each code subspace. */
301 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
305 obj_som_weak (int ignore ATTRIBUTE_UNUSED
)
313 name
= input_line_pointer
;
314 c
= get_symbol_end ();
315 symbolP
= symbol_find_or_make (name
);
316 *input_line_pointer
= c
;
318 S_SET_WEAK (symbolP
);
321 input_line_pointer
++;
323 if (*input_line_pointer
== '\n')
328 demand_empty_rest_of_line ();
331 const pseudo_typeS obj_pseudo_table
[] =
333 {"weak", obj_som_weak
, 0},