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 void obj_som_weak
PARAMS ((int));
31 static void adjust_stab_sections
PARAMS ((bfd
*, asection
*, PTR
));
33 const pseudo_typeS obj_pseudo_table
[] =
35 {"weak", obj_som_weak
, 0},
39 static int version_seen
= 0;
40 static int copyright_seen
= 0;
41 static int compiler_seen
= 0;
46 obj_read_begin_hook ()
50 /* Handle a .compiler directive. This is intended to create the
51 compilation unit auxiliary header for MPE such that the linkeditor
52 can handle SOM extraction from archives. The format of the quoted
53 string is "sourcefile language version" and is delimited by blanks. */
56 obj_som_compiler (unused
)
57 int unused ATTRIBUTE_UNUSED
;
68 as_bad ("Only one .compiler pseudo-op per file!");
69 ignore_rest_of_line ();
74 if (*input_line_pointer
== '\"')
76 buf
= input_line_pointer
;
78 while (is_a_char (next_char_of_string ()))
80 c
= *input_line_pointer
;
81 *input_line_pointer
= '\000';
85 as_bad ("Expected quoted string");
86 ignore_rest_of_line ();
90 /* Parse the quoted string into its component parts. Skip the
94 while (*p
!= ' ' && *p
!= '\000')
98 as_bad (".compiler directive missing language and version");
104 while (*p
!= ' ' && *p
!= '\000')
108 as_bad (".compiler directive missing version");
116 /* Remove the trailing quote. */
120 if (! bfd_som_attach_compilation_unit (stdoutput
, filename
, language_name
,
121 "GNU Tools", version_id
))
123 bfd_perror (stdoutput
->filename
);
124 as_fatal ("FATAL: Attaching compiler header %s", stdoutput
->filename
);
126 *input_line_pointer
= c
;
127 demand_empty_rest_of_line ();
130 /* Handle a .version directive. */
133 obj_som_version (unused
)
134 int unused ATTRIBUTE_UNUSED
;
140 as_bad (_("Only one .version pseudo-op per file!"));
141 ignore_rest_of_line ();
146 if (*input_line_pointer
== '\"')
148 version
= input_line_pointer
;
149 ++input_line_pointer
;
150 while (is_a_char (next_char_of_string ()))
152 c
= *input_line_pointer
;
153 *input_line_pointer
= '\000';
157 as_bad (_("Expected quoted string"));
158 ignore_rest_of_line ();
163 if (!bfd_som_attach_aux_hdr (stdoutput
, VERSION_AUX_ID
, version
))
165 bfd_perror (stdoutput
->filename
);
166 as_perror (_("FATAL: Attaching version header %s"),
167 stdoutput
->filename
);
170 *input_line_pointer
= c
;
171 demand_empty_rest_of_line ();
174 /* Handle a .copyright directive. This probably isn't complete, but
175 it's of dubious value anyway and (IMHO) not worth the time to finish.
176 If you care about copyright strings that much, you fix it. */
179 obj_som_copyright (unused
)
180 int unused ATTRIBUTE_UNUSED
;
186 as_bad (_("Only one .copyright pseudo-op per file!"));
187 ignore_rest_of_line ();
192 if (*input_line_pointer
== '\"')
194 copyright
= input_line_pointer
;
195 ++input_line_pointer
;
196 while (is_a_char (next_char_of_string ()))
198 c
= *input_line_pointer
;
199 *input_line_pointer
= '\000';
203 as_bad (_("Expected quoted string"));
204 ignore_rest_of_line ();
209 if (!bfd_som_attach_aux_hdr (stdoutput
, COPYRIGHT_AUX_ID
, copyright
))
211 bfd_perror (stdoutput
->filename
);
212 as_perror (_("FATAL: Attaching copyright header %s"),
213 stdoutput
->filename
);
216 *input_line_pointer
= c
;
217 demand_empty_rest_of_line ();
220 /* Perform any initialization necessary for stabs support.
222 For SOM we need to create the space which will contain the
223 two stabs subspaces. Additionally we need to set up the
224 space/subspace relationships and set space/subspace attributes
225 which BFD does not understand. */
228 obj_som_init_stab_section (seg
)
231 segT saved_seg
= now_seg
;
233 subsegT saved_subseg
= now_subseg
;
237 /* Make the space which will contain the debug subspaces. */
238 space
= bfd_make_section_old_way (stdoutput
, "$GDB_DEBUG$");
240 /* Set SOM specific attributes for the space. In particular we set
241 the space "defined", "private", "sort_key", and "spnum" values.
243 Due to a bug in pxdb (called by hpux linker), the sort keys
244 of the various stabs spaces/subspaces need to be "small". We
245 reserve range 72/73 which appear to work well. */
246 obj_set_section_attributes (space
, 1, 1, 72, 2);
247 bfd_set_section_alignment (stdoutput
, space
, 2);
249 /* Set the containing space for both stab sections to be $GDB_DEBUG$
250 (just created above). Also set some attributes which BFD does
251 not understand. In particular, access bits, sort keys, and load
253 obj_set_subsection_attributes (seg
, space
, 0x1f, 73, 0, 0, 0, 0);
254 bfd_set_section_alignment (stdoutput
, seg
, 2);
256 /* Make some space for the first special stab entry and zero the memory.
257 It contains information about the length of this file's
258 stab string and the like. Using it avoids the need to
259 relocate the stab strings.
261 The $GDB_STRINGS$ space will be created as a side effect of
262 the call to get_stab_string_offset. */
265 as_where (&file
, (unsigned int *) NULL
);
266 stroff
= get_stab_string_offset (file
, "$GDB_STRINGS$");
268 md_number_to_chars (p
, stroff
, 4);
269 seg_info (seg
)->stabu
.p
= p
;
271 /* Set the containing space for both stab sections to be $GDB_DEBUG$
272 (just created above). Also set some attributes which BFD does
273 not understand. In particular, access bits, sort keys, and load
275 seg
= bfd_get_section_by_name (stdoutput
, "$GDB_STRINGS$");
276 obj_set_subsection_attributes (seg
, space
, 0x1f, 72, 0, 0, 0, 0);
277 bfd_set_section_alignment (stdoutput
, seg
, 2);
279 subseg_set (saved_seg
, saved_subseg
);
282 /* Fill in the counts in the first entry in a .stabs section. */
285 adjust_stab_sections (abfd
, sec
, xxx
)
288 PTR xxx ATTRIBUTE_UNUSED
;
294 if (strcmp ("$GDB_SYMBOLS$", sec
->name
))
297 strsec
= bfd_get_section_by_name (abfd
, "$GDB_STRINGS$");
299 strsz
= bfd_section_size (abfd
, strsec
);
302 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
304 p
= seg_info (sec
)->stabu
.p
;
307 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
308 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
311 /* Called late in the assembly phase to adjust the special
312 stab entry and to set the starting address for each code subspace. */
317 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
321 obj_som_weak (ignore
)
322 int ignore ATTRIBUTE_UNUSED
;
330 name
= input_line_pointer
;
331 c
= get_symbol_end ();
332 symbolP
= symbol_find_or_make (name
);
333 *input_line_pointer
= c
;
335 S_SET_WEAK (symbolP
);
338 input_line_pointer
++;
340 if (*input_line_pointer
== '\n')
345 demand_empty_rest_of_line ();