1 /* SOM object file format.
2 Copyright (C) 1993, 1998 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));
31 const pseudo_typeS obj_pseudo_table
[] =
33 {"weak", obj_som_weak
, 0},
37 static int version_seen
= 0;
38 static int copyright_seen
= 0;
39 static int compiler_seen
= 0;
42 void obj_read_begin_hook () {}
44 /* Handle a .compiler directive. This is intended to create the
45 compilation unit auxiliary header for MPE such that the linkeditor
46 can handle SOM extraction from archives. The format of the quoted
47 string is "sourcefile language version" and is delimited by blanks.*/
50 obj_som_compiler (unused
)
62 as_bad ("Only one .compiler pseudo-op per file!");
63 ignore_rest_of_line ();
68 if (*input_line_pointer
== '\"')
70 buf
= input_line_pointer
;
72 while (is_a_char (next_char_of_string ()))
74 c
= *input_line_pointer
;
75 *input_line_pointer
= '\000';
79 as_bad ("Expected quoted string");
80 ignore_rest_of_line ();
84 /* Parse the quoted string into its component parts. Skip the
88 while (*p
!= ' ' && *p
!= '\000')
92 as_bad (".compiler directive missing language and version");
98 while (*p
!= ' ' && *p
!= '\000') p
++;
101 as_bad (".compiler directive missing version");
107 while (*p
!= '\000') p
++;
108 /* Remove the trailing quote. */
112 if (! bfd_som_attach_compilation_unit (stdoutput
, filename
, language_name
,
113 "GNU Tools", version_id
))
115 bfd_perror (stdoutput
->filename
);
116 as_fatal ("FATAL: Attaching compiler header %s", stdoutput
->filename
);
118 *input_line_pointer
= c
;
119 demand_empty_rest_of_line ();
122 /* Handle a .version directive. */
125 obj_som_version (unused
)
132 as_bad (_("Only one .version pseudo-op per file!"));
133 ignore_rest_of_line ();
138 if (*input_line_pointer
== '\"')
140 version
= input_line_pointer
;
141 ++input_line_pointer
;
142 while (is_a_char (next_char_of_string ()))
144 c
= *input_line_pointer
;
145 *input_line_pointer
= '\000';
149 as_bad (_("Expected quoted string"));
150 ignore_rest_of_line ();
155 if (bfd_som_attach_aux_hdr (stdoutput
, VERSION_AUX_ID
, version
) == false)
157 bfd_perror (stdoutput
->filename
);
158 as_perror (_("FATAL: Attaching version header %s"), stdoutput
->filename
);
161 *input_line_pointer
= c
;
162 demand_empty_rest_of_line ();
165 /* Handle a .copyright directive. This probably isn't complete, but
166 it's of dubious value anyway and (IMHO) not worth the time to finish.
167 If you care about copyright strings that much, you fix it. */
170 obj_som_copyright (unused
)
177 as_bad (_("Only one .copyright pseudo-op per file!"));
178 ignore_rest_of_line ();
183 if (*input_line_pointer
== '\"')
185 copyright
= input_line_pointer
;
186 ++input_line_pointer
;
187 while (is_a_char (next_char_of_string ()))
189 c
= *input_line_pointer
;
190 *input_line_pointer
= '\000';
194 as_bad (_("Expected quoted string"));
195 ignore_rest_of_line ();
200 if (bfd_som_attach_aux_hdr (stdoutput
, COPYRIGHT_AUX_ID
, copyright
) == false)
202 bfd_perror (stdoutput
->filename
);
203 as_perror (_("FATAL: Attaching copyright header %s"), stdoutput
->filename
);
206 *input_line_pointer
= c
;
207 demand_empty_rest_of_line ();
210 /* Perform any initialization necessary for stabs support.
212 For SOM we need to create the space which will contain the
213 two stabs subspaces. Additionally we need to set up the
214 space/subspace relationships and set space/subspace attributes
215 which BFD does not understand. */
218 obj_som_init_stab_section (seg
)
221 segT saved_seg
= now_seg
;
223 subsegT saved_subseg
= now_subseg
;
227 /* Make the space which will contain the debug subspaces. */
228 space
= bfd_make_section_old_way (stdoutput
, "$GDB_DEBUG$");
230 /* Set SOM specific attributes for the space. In particular we set
231 the space "defined", "private", "sort_key", and "spnum" values.
233 Due to a bug in pxdb (called by hpux linker), the sort keys
234 of the various stabs spaces/subspaces need to be "small". We
235 reserve range 72/73 which appear to work well. */
236 obj_set_section_attributes (space
, 1, 1, 72, 2);
237 bfd_set_section_alignment (stdoutput
, space
, 2);
239 /* Set the containing space for both stab sections to be $GDB_DEBUG$
240 (just created above). Also set some attributes which BFD does
241 not understand. In particular, access bits, sort keys, and load
243 obj_set_subsection_attributes (seg
, space
, 0x1f, 73, 0);
244 bfd_set_section_alignment (stdoutput
, seg
, 2);
246 /* Make some space for the first special stab entry and zero the memory.
247 It contains information about the length of this file's
248 stab string and the like. Using it avoids the need to
249 relocate the stab strings.
251 The $GDB_STRINGS$ space will be created as a side effect of
252 the call to get_stab_string_offset. */
255 as_where (&file
, (unsigned int *) NULL
);
256 stroff
= get_stab_string_offset (file
, "$GDB_STRINGS$");
258 md_number_to_chars (p
, stroff
, 4);
259 seg_info (seg
)->stabu
.p
= p
;
261 /* Set the containing space for both stab sections to be $GDB_DEBUG$
262 (just created above). Also set some attributes which BFD does
263 not understand. In particular, access bits, sort keys, and load
265 seg
= bfd_get_section_by_name (stdoutput
, "$GDB_STRINGS$");
266 obj_set_subsection_attributes (seg
, space
, 0x1f, 72, 0);
267 bfd_set_section_alignment (stdoutput
, seg
, 2);
269 subseg_set (saved_seg
, saved_subseg
);
272 /* Fill in the counts in the first entry in a .stabs section. */
275 adjust_stab_sections (abfd
, sec
, xxx
)
284 if (strcmp ("$GDB_SYMBOLS$", sec
->name
))
287 strsec
= bfd_get_section_by_name (abfd
, "$GDB_STRINGS$");
289 strsz
= bfd_section_size (abfd
, strsec
);
292 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
294 p
= seg_info (sec
)->stabu
.p
;
297 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
298 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
301 /* Called late in the asssembly phase to adjust the special
302 stab entry and to set the starting address for each code subspace. */
307 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
311 obj_som_weak (ignore
)
312 int ignore ATTRIBUTE_UNUSED
;
320 name
= input_line_pointer
;
321 c
= get_symbol_end ();
322 symbolP
= symbol_find_or_make (name
);
323 *input_line_pointer
= c
;
325 S_SET_WEAK (symbolP
);
327 symbol_get_obj (symbolP
)->local
= 1;
331 input_line_pointer
++;
333 if (*input_line_pointer
== '\n')
338 demand_empty_rest_of_line ();