]>
Commit | Line | Data |
---|---|---|
1340861c | 1 | /* Read os9/os9k symbol tables and convert to internal format, for GDB. |
cef0333e | 2 | Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994 |
1340861c KH |
3 | Free Software Foundation, Inc. |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
21 | /* This module provides three functions: os9k_symfile_init, | |
22 | which initializes to read a symbol file; os9k_new_init, which | |
23 | discards existing cached information when all symbols are being | |
24 | discarded; and os9k_symfile_read, which reads a symbol table | |
25 | from a file. | |
26 | ||
27 | os9k_symfile_read only does the minimum work necessary for letting the | |
28 | user "name" things symbolically; it does not read the entire symtab. | |
29 | Instead, it reads the external and static symbols and puts them in partial | |
30 | symbol tables. When more extensive information is requested of a | |
31 | file, the corresponding partial symbol table is mutated into a full | |
32 | fledged symbol table by going back and reading the symbols | |
33 | for real. os9k_psymtab_to_symtab() is the function that does this */ | |
34 | ||
35 | #include "defs.h" | |
36 | #include <string.h> | |
37 | #include <stdio.h> | |
38 | ||
39 | #if defined(USG) || defined(__CYGNUSCLIB__) | |
40 | #include <sys/types.h> | |
41 | #include <fcntl.h> | |
42 | #endif | |
43 | ||
44 | #include <obstack.h> | |
45 | #include <sys/param.h> | |
46 | #ifndef NO_SYS_FILE | |
47 | #include <sys/file.h> | |
48 | #endif | |
49 | #include <sys/stat.h> | |
50 | #include <ctype.h> | |
51 | #include "symtab.h" | |
52 | #include "breakpoint.h" | |
53 | #include "command.h" | |
54 | #include "target.h" | |
55 | #include "gdbcore.h" /* for bfd stuff */ | |
1340861c KH |
56 | #include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */ |
57 | #include "symfile.h" | |
58 | #include "objfiles.h" | |
59 | #include "buildsym.h" | |
60 | #include "gdb-stabs.h" | |
61 | #include "demangle.h" | |
62 | #include "language.h" /* Needed inside partial-stab.h */ | |
63 | #include "complaints.h" | |
64 | #include "os9k.h" | |
25200748 | 65 | #include "stabsread.h" |
1340861c KH |
66 | |
67 | #if !defined (SEEK_SET) | |
68 | #define SEEK_SET 0 | |
69 | #define SEEK_CUR 1 | |
70 | #endif | |
71 | ||
72 | /* Each partial symbol table entry contains a pointer to private data for the | |
73 | read_symtab() function to use when expanding a partial symbol table entry | |
74 | to a full symbol table entry. | |
75 | ||
76 | For dbxread this structure contains the offset within the file symbol table | |
77 | of first local symbol for this file, and count of the section | |
78 | of the symbol table devoted to this file's symbols (actually, the section | |
79 | bracketed may contain more than just this file's symbols). It also contains | |
80 | further information needed to locate the symbols if they are in an ELF file. | |
81 | ||
82 | If ldsymcnt is 0, the only reason for this thing's existence is the | |
83 | dependency list. Nothing else will happen when it is read in. */ | |
84 | ||
85 | #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff) | |
86 | #define LDSYMCNT(p) (((struct symloc *)((p)->read_symtab_private))->ldsymnum) | |
87 | ||
88 | struct symloc { | |
89 | int ldsymoff; | |
90 | int ldsymnum; | |
91 | }; | |
92 | ||
93 | /* Remember what we deduced to be the source language of this psymtab. */ | |
94 | static enum language psymtab_language = language_unknown; | |
95 | ||
96 | /* keep partial symbol table file nested depth */ | |
97 | static int psymfile_depth = 0; | |
98 | ||
99 | /* keep symbol table file nested depth */ | |
100 | static int symfile_depth = 0; | |
101 | ||
102 | /* Nonzero means give verbose info on gdb action. From main.c. */ | |
103 | extern int info_verbose; | |
104 | ||
105 | extern int previous_stab_code; | |
106 | ||
1340861c KH |
107 | /* Name of last function encountered. Used in Solaris to approximate |
108 | object file boundaries. */ | |
109 | static char *last_function_name; | |
110 | ||
111 | /* Complaints about the symbols we have encountered. */ | |
112 | extern struct complaint lbrac_complaint; | |
113 | ||
114 | extern struct complaint unknown_symtype_complaint; | |
115 | ||
116 | extern struct complaint unknown_symchar_complaint; | |
117 | ||
118 | extern struct complaint lbrac_rbrac_complaint; | |
119 | ||
120 | extern struct complaint repeated_header_complaint; | |
121 | ||
122 | extern struct complaint repeated_header_name_complaint; | |
123 | ||
1c95d7ab | 124 | #if 0 |
1340861c KH |
125 | static struct complaint lbrac_unmatched_complaint = |
126 | {"unmatched Increment Block Entry before symtab pos %d", 0, 0}; | |
127 | ||
128 | static struct complaint lbrac_mismatch_complaint = | |
129 | {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0}; | |
1c95d7ab | 130 | #endif |
1340861c KH |
131 | \f |
132 | /* Local function prototypes */ | |
133 | static void | |
134 | os9k_read_ofile_symtab PARAMS ((struct partial_symtab *)); | |
135 | ||
136 | static void | |
137 | os9k_psymtab_to_symtab PARAMS ((struct partial_symtab *)); | |
138 | ||
139 | static void | |
140 | os9k_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *)); | |
141 | ||
142 | static void | |
143 | read_os9k_psymtab PARAMS ((struct section_offsets *, struct objfile *, | |
144 | CORE_ADDR, int)); | |
145 | ||
1340861c KH |
146 | static int |
147 | fill_sym PARAMS ((FILE *, bfd *)); | |
148 | ||
149 | static void | |
150 | os9k_symfile_init PARAMS ((struct objfile *)); | |
151 | ||
152 | static void | |
153 | os9k_new_init PARAMS ((struct objfile *)); | |
154 | ||
155 | static void | |
156 | os9k_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int)); | |
157 | ||
158 | static void | |
159 | os9k_symfile_finish PARAMS ((struct objfile *)); | |
160 | ||
161 | static void | |
162 | os9k_process_one_symbol PARAMS ((int, int, CORE_ADDR, char *, | |
163 | struct section_offsets *, struct objfile *)); | |
164 | ||
165 | static struct partial_symtab * | |
166 | os9k_start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *, | |
167 | CORE_ADDR, int, int, struct partial_symbol *, | |
168 | struct partial_symbol *)); | |
169 | ||
170 | static struct partial_symtab * | |
171 | os9k_end_psymtab PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR, | |
172 | struct partial_symtab **, int)); | |
173 | ||
174 | static void | |
d80ff70c KH |
175 | record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *, |
176 | struct section_offsets *)); | |
1340861c KH |
177 | \f |
178 | #define HANDLE_RBRAC(val) \ | |
179 | if ((val) > pst->texthigh) pst->texthigh = (val); | |
180 | ||
181 | #define SWAP_STBHDR(hdrp, abfd) \ | |
182 | { \ | |
183 | (hdrp)->fmtno = bfd_get_16(abfd, (unsigned char *)&(hdrp)->fmtno); \ | |
184 | (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \ | |
185 | (hdrp)->offset = bfd_get_32(abfd, (unsigned char *)&(hdrp)->offset); \ | |
186 | (hdrp)->nsym = bfd_get_32(abfd, (unsigned char *)&(hdrp)->nsym); \ | |
187 | } | |
188 | #define SWAP_STBSYM(symp, abfd) \ | |
189 | { \ | |
190 | (symp)->value = bfd_get_32(abfd, (unsigned char *)&(symp)->value); \ | |
191 | (symp)->type = bfd_get_16(abfd, (unsigned char *)&(symp)->type); \ | |
192 | (symp)->stroff = bfd_get_32(abfd, (unsigned char *)&(symp)->stroff); \ | |
193 | } | |
194 | #define N_DATA 0 | |
195 | #define N_BSS 1 | |
196 | #define N_RDATA 2 | |
197 | #define N_IDATA 3 | |
198 | #define N_TEXT 4 | |
199 | #define N_ABS 6 | |
200 | ||
201 | static void | |
d80ff70c | 202 | record_minimal_symbol (name, address, type, objfile, section_offsets) |
1340861c KH |
203 | char *name; |
204 | CORE_ADDR address; | |
205 | int type; | |
206 | struct objfile *objfile; | |
d80ff70c | 207 | struct section_offsets *section_offsets; |
1340861c KH |
208 | { |
209 | enum minimal_symbol_type ms_type; | |
210 | ||
211 | switch (type) | |
212 | { | |
d80ff70c KH |
213 | case N_TEXT: |
214 | ms_type = mst_text; | |
215 | address += ANOFFSET(section_offsets, SECT_OFF_TEXT); | |
216 | break; | |
217 | case N_DATA: | |
218 | ms_type = mst_data; | |
219 | break; | |
220 | case N_BSS: | |
221 | ms_type = mst_bss; | |
222 | break; | |
223 | case N_RDATA: | |
224 | ms_type = mst_bss; | |
225 | break; | |
226 | case N_IDATA: | |
227 | ms_type = mst_data; | |
228 | break; | |
229 | case N_ABS: | |
230 | ms_type = mst_abs; | |
231 | break; | |
232 | default: | |
233 | ms_type = mst_unknown; break; | |
1340861c KH |
234 | } |
235 | ||
236 | prim_record_minimal_symbol | |
237 | (obsavestring (name, strlen(name), &objfile->symbol_obstack), | |
238 | address, ms_type, objfile); | |
239 | } | |
240 | ||
241 | /* read and process .stb file and store in minimal symbol table */ | |
242 | typedef char mhhdr[80]; | |
243 | struct stbhdr { | |
244 | mhhdr comhdr; | |
245 | char * name; | |
246 | short fmtno; | |
247 | int crc; | |
248 | int offset; | |
249 | int nsym; | |
250 | char *pad; | |
251 | }; | |
252 | struct stbsymbol { | |
253 | int value; | |
254 | short type; | |
255 | int stroff; | |
256 | }; | |
257 | #define STBSYMSIZE 10 | |
258 | ||
1c95d7ab | 259 | static void |
d80ff70c | 260 | read_minimal_symbols(objfile, section_offsets) |
1340861c | 261 | struct objfile *objfile; |
d80ff70c | 262 | struct section_offsets *section_offsets; |
1340861c KH |
263 | { |
264 | FILE *fp; | |
265 | bfd *abfd; | |
266 | struct stbhdr hdr; | |
267 | struct stbsymbol sym; | |
268 | int ch, i, j, off; | |
269 | char buf[64], buf1[128]; | |
270 | ||
271 | fp = objfile->auxf1; | |
272 | if (fp == NULL) return; | |
273 | abfd = objfile->obfd; | |
274 | fread(&hdr.comhdr[0], sizeof(mhhdr), 1, fp); | |
275 | i = 0; | |
276 | ch = getc(fp); | |
277 | while (ch != -1) { | |
278 | buf[i] = (char)ch; | |
279 | i++; | |
280 | if (ch == 0) break; | |
281 | ch = getc(fp); | |
282 | }; | |
d9389f37 | 283 | if (i%2) ch=getc(fp); |
1340861c KH |
284 | hdr.name = &buf[0]; |
285 | ||
286 | fread(&hdr.fmtno, sizeof(hdr.fmtno), 1, fp); | |
287 | fread(&hdr.crc, sizeof(hdr.crc), 1, fp); | |
288 | fread(&hdr.offset, sizeof(hdr.offset), 1, fp); | |
289 | fread(&hdr.nsym, sizeof(hdr.nsym), 1, fp); | |
290 | SWAP_STBHDR(&hdr, abfd); | |
291 | ||
292 | /* read symbols */ | |
293 | init_minimal_symbol_collection(); | |
294 | off = hdr.offset; | |
295 | for (i = hdr.nsym; i > 0; i--) { | |
296 | fseek(fp, (long)off, 0); | |
297 | fread(&sym.value, sizeof(sym.value), 1, fp); | |
298 | fread(&sym.type, sizeof(sym.type), 1, fp); | |
299 | fread(&sym.stroff, sizeof(sym.stroff), 1, fp); | |
300 | SWAP_STBSYM (&sym, abfd); | |
301 | fseek(fp, (long)sym.stroff, 0); | |
302 | j = 0; | |
303 | ch = getc(fp); | |
304 | while (ch != -1) { | |
305 | buf1[j] = (char)ch; | |
306 | j++; | |
307 | if (ch == 0) break; | |
308 | ch = getc(fp); | |
309 | }; | |
d80ff70c | 310 | record_minimal_symbol(buf1, sym.value, sym.type&7, objfile, section_offsets); |
1340861c KH |
311 | off += STBSYMSIZE; |
312 | }; | |
313 | install_minimal_symbols (objfile); | |
1c95d7ab | 314 | return; |
1340861c KH |
315 | } |
316 | \f | |
317 | /* Scan and build partial symbols for a symbol file. | |
318 | We have been initialized by a call to os9k_symfile_init, which | |
319 | put all the relevant info into a "struct os9k_symfile_info", | |
320 | hung off the objfile structure. | |
321 | ||
322 | SECTION_OFFSETS contains offsets relative to which the symbols in the | |
323 | various sections are (depending where the sections were actually loaded). | |
324 | MAINLINE is true if we are reading the main symbol | |
325 | table (as opposed to a shared lib or dynamically loaded file). */ | |
326 | ||
327 | static void | |
328 | os9k_symfile_read (objfile, section_offsets, mainline) | |
329 | struct objfile *objfile; | |
330 | struct section_offsets *section_offsets; | |
331 | int mainline; /* FIXME comments above */ | |
332 | { | |
333 | bfd *sym_bfd; | |
1340861c KH |
334 | struct cleanup *back_to; |
335 | ||
336 | sym_bfd = objfile->obfd; | |
337 | /* If we are reinitializing, or if we have never loaded syms yet, init */ | |
338 | if (mainline || objfile->global_psymbols.size == 0 || | |
339 | objfile->static_psymbols.size == 0) | |
a367db89 | 340 | init_psymbol_list (objfile, DBX_SYMCOUNT (objfile)); |
1340861c KH |
341 | |
342 | pending_blocks = 0; | |
343 | back_to = make_cleanup (really_free_pendings, 0); | |
344 | ||
345 | make_cleanup (discard_minimal_symbols, 0); | |
d80ff70c | 346 | read_minimal_symbols (objfile, section_offsets); |
1340861c KH |
347 | |
348 | /* Now that the symbol table data of the executable file are all in core, | |
349 | process them and define symbols accordingly. */ | |
350 | read_os9k_psymtab (section_offsets, objfile, | |
f779e99f ILT |
351 | DBX_TEXT_ADDR (objfile), |
352 | DBX_TEXT_SIZE (objfile)); | |
1340861c | 353 | |
1340861c KH |
354 | do_cleanups (back_to); |
355 | } | |
356 | ||
357 | /* Initialize anything that needs initializing when a completely new | |
358 | symbol file is specified (not just adding some symbols from another | |
359 | file, e.g. a shared library). */ | |
360 | ||
361 | static void | |
362 | os9k_new_init (ignore) | |
363 | struct objfile *ignore; | |
364 | { | |
365 | stabsread_new_init (); | |
366 | buildsym_new_init (); | |
367 | psymfile_depth = 0; | |
368 | /* | |
369 | init_header_files (); | |
370 | */ | |
371 | } | |
372 | ||
373 | /* os9k_symfile_init () | |
374 | It is passed a struct objfile which contains, among other things, | |
375 | the BFD for the file whose symbols are being read, and a slot for a pointer | |
376 | to "private data" which we fill with goodies. | |
377 | ||
378 | Since BFD doesn't know how to read debug symbols in a format-independent | |
379 | way (and may never do so...), we have to do it ourselves. We will never | |
380 | be called unless this is an a.out (or very similar) file. | |
381 | FIXME, there should be a cleaner peephole into the BFD environment here. */ | |
382 | ||
383 | static void | |
384 | os9k_symfile_init (objfile) | |
385 | struct objfile *objfile; | |
386 | { | |
1340861c KH |
387 | bfd *sym_bfd = objfile->obfd; |
388 | char *name = bfd_get_filename (sym_bfd); | |
d80ff70c | 389 | char dbgname[512], stbname[512]; |
1340861c KH |
390 | FILE *symfile = 0; |
391 | FILE *minfile = 0; | |
f779e99f | 392 | asection *text_sect; |
1340861c KH |
393 | |
394 | strcpy(dbgname, name); | |
395 | strcat(dbgname, ".dbg"); | |
396 | strcpy(stbname, name); | |
397 | strcat(stbname, ".stb"); | |
398 | ||
399 | if ((symfile = fopen(dbgname, "r")) == NULL) { | |
400 | warning("Symbol file %s not found", dbgname); | |
401 | } | |
402 | objfile->auxf2 = symfile; | |
403 | ||
404 | if ((minfile = fopen(stbname, "r")) == NULL) { | |
405 | warning("Symbol file %s not found", stbname); | |
406 | } | |
407 | objfile->auxf1 = minfile; | |
408 | ||
409 | /* Allocate struct to keep track of the symfile */ | |
410 | objfile->sym_stab_info = (PTR) | |
411 | xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info)); | |
412 | DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL; | |
413 | ||
f779e99f ILT |
414 | text_sect = bfd_get_section_by_name (sym_bfd, ".text"); |
415 | if (!text_sect) | |
1340861c | 416 | error ("Can't find .text section in file"); |
f779e99f ILT |
417 | DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect); |
418 | DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect); | |
1340861c KH |
419 | |
420 | DBX_SYMBOL_SIZE (objfile) = 0; /* variable size symbol */ | |
421 | DBX_SYMCOUNT (objfile) = 0; /* used to be bfd_get_symcount(sym_bfd) */ | |
422 | DBX_SYMTAB_OFFSET (objfile) = 0; /* used to be SYMBOL_TABLE_OFFSET */ | |
423 | } | |
424 | ||
425 | /* Perform any local cleanups required when we are done with a particular | |
426 | objfile. I.E, we are in the process of discarding all symbol information | |
427 | for an objfile, freeing up all memory held for it, and unlinking the | |
428 | objfile struct from the global list of known objfiles. */ | |
429 | ||
430 | static void | |
431 | os9k_symfile_finish (objfile) | |
432 | struct objfile *objfile; | |
433 | { | |
434 | if (objfile->sym_stab_info != NULL) | |
435 | { | |
436 | mfree (objfile -> md, objfile->sym_stab_info); | |
437 | } | |
438 | /* | |
439 | free_header_files (); | |
440 | */ | |
441 | } | |
442 | ||
443 | \f | |
d9389f37 | 444 | struct st_dbghdr { |
1340861c KH |
445 | int sync; |
446 | short rev; | |
447 | int crc; | |
448 | short os; | |
449 | short cpu; | |
450 | }; | |
d9389f37 | 451 | #define SYNC (int)0xefbefeca |
1340861c KH |
452 | |
453 | #define SWAP_DBGHDR(hdrp, abfd) \ | |
454 | { \ | |
455 | (hdrp)->sync = bfd_get_32(abfd, (unsigned char *)&(hdrp)->sync); \ | |
456 | (hdrp)->rev = bfd_get_16(abfd, (unsigned char *)&(hdrp)->rev); \ | |
457 | (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \ | |
458 | (hdrp)->os = bfd_get_16(abfd, (unsigned char *)&(hdrp)->os); \ | |
459 | (hdrp)->cpu = bfd_get_16(abfd, (unsigned char *)&(hdrp)->cpu); \ | |
460 | } | |
461 | ||
462 | #define N_SYM_CMPLR 0 | |
463 | #define N_SYM_SLINE 1 | |
464 | #define N_SYM_SYM 2 | |
465 | #define N_SYM_LBRAC 3 | |
466 | #define N_SYM_RBRAC 4 | |
467 | #define N_SYM_SE 5 | |
468 | ||
469 | struct internal_symstruct { | |
470 | short n_type; | |
471 | short n_desc; | |
472 | long n_value; | |
473 | char * n_strx; | |
474 | }; | |
475 | static struct internal_symstruct symbol; | |
476 | static struct internal_symstruct *symbuf = &symbol; | |
d9389f37 KH |
477 | static char strbuf[4096]; |
478 | static struct st_dbghdr dbghdr; | |
479 | static short cmplrid; | |
480 | ||
481 | #define VER_PRE_ULTRAC ((short)4) | |
482 | #define VER_ULTRAC ((short)5) | |
1340861c KH |
483 | |
484 | static int | |
485 | fill_sym (dbg_file, abfd) | |
486 | FILE *dbg_file; | |
487 | bfd *abfd; | |
488 | { | |
d9389f37 | 489 | short si, nmask; |
1340861c KH |
490 | long li; |
491 | int ii; | |
d9389f37 | 492 | char *p; |
1340861c KH |
493 | |
494 | int nbytes = fread(&si, sizeof(si), 1, dbg_file); | |
495 | if (nbytes == 0) | |
496 | return 0; | |
497 | if (nbytes < 0) | |
498 | perror_with_name ("reading .dbg file."); | |
499 | symbuf->n_desc = 0; | |
500 | symbuf->n_value = 0; | |
501 | symbuf->n_strx = NULL; | |
502 | symbuf->n_type = bfd_get_16 (abfd, (unsigned char *)&si); | |
503 | symbuf->n_type = 0xf & symbuf->n_type; | |
504 | switch (symbuf->n_type) | |
505 | { | |
506 | case N_SYM_CMPLR: | |
507 | fread(&si, sizeof(si), 1, dbg_file); | |
508 | symbuf->n_desc = bfd_get_16(abfd, (unsigned char *)&si); | |
d9389f37 | 509 | cmplrid = symbuf->n_desc & 0xff; |
1340861c KH |
510 | break; |
511 | case N_SYM_SLINE: | |
512 | fread(&li, sizeof(li), 1, dbg_file); | |
513 | symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li); | |
514 | fread(&li, sizeof(li), 1, dbg_file); | |
515 | li = bfd_get_32(abfd, (unsigned char *)&li); | |
516 | symbuf->n_strx = (char *)(li >> 12); | |
517 | symbuf->n_desc = li & 0xfff; | |
518 | break; | |
519 | case N_SYM_SYM: | |
520 | fread(&li, sizeof(li), 1, dbg_file); | |
521 | symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li); | |
522 | si = 0; | |
523 | do { | |
524 | ii = getc(dbg_file); | |
525 | strbuf[si++] = (char) ii; | |
526 | } while (ii != 0 || si % 2 != 0); | |
527 | symbuf->n_strx = strbuf; | |
d9389f37 KH |
528 | p = (char *) strchr (strbuf, ':'); |
529 | if (!p) break; | |
530 | if ((p[1] == 'F' || p[1] == 'f') && cmplrid == VER_PRE_ULTRAC) | |
531 | { | |
532 | fread(&si, sizeof(si), 1, dbg_file); | |
533 | nmask = bfd_get_16(abfd, (unsigned char *)&si); | |
534 | for (ii=0; ii<nmask; ii++) | |
535 | fread(&si, sizeof(si), 1, dbg_file); | |
536 | } | |
1340861c KH |
537 | break; |
538 | case N_SYM_LBRAC: | |
539 | fread(&li, sizeof(li), 1, dbg_file); | |
540 | symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li); | |
541 | break; | |
542 | case N_SYM_RBRAC: | |
543 | fread(&li, sizeof(li), 1, dbg_file); | |
544 | symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li); | |
545 | break; | |
546 | case N_SYM_SE: | |
547 | break; | |
548 | } | |
549 | return 1; | |
550 | } | |
551 | \f | |
1340861c KH |
552 | /* Given pointers to an a.out symbol table in core containing dbx |
553 | style data, setup partial_symtab's describing each source file for | |
554 | which debugging information is available. | |
555 | SYMFILE_NAME is the name of the file we are reading from | |
556 | and SECTION_OFFSETS is the set of offsets for the various sections | |
557 | of the file (a set of zeros if the mainline program). */ | |
558 | ||
559 | static void | |
560 | read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) | |
561 | struct section_offsets *section_offsets; | |
562 | struct objfile *objfile; | |
563 | CORE_ADDR text_addr; | |
564 | int text_size; | |
565 | { | |
566 | register struct internal_symstruct *bufp = 0; /* =0 avoids gcc -Wall glitch*/ | |
567 | register char *namestring; | |
1340861c KH |
568 | int past_first_source_file = 0; |
569 | CORE_ADDR last_o_file_start = 0; | |
1c95d7ab | 570 | #if 0 |
1340861c | 571 | struct cleanup *back_to; |
1c95d7ab | 572 | #endif |
1340861c KH |
573 | bfd *abfd; |
574 | FILE *fp; | |
1340861c KH |
575 | |
576 | /* End of the text segment of the executable file. */ | |
577 | static CORE_ADDR end_of_text_addr; | |
578 | ||
579 | /* Current partial symtab */ | |
580 | static struct partial_symtab *pst = 0; | |
581 | ||
582 | /* List of current psymtab's include files */ | |
583 | char **psymtab_include_list; | |
584 | int includes_allocated; | |
585 | int includes_used; | |
586 | ||
587 | /* Index within current psymtab dependency list */ | |
588 | struct partial_symtab **dependency_list; | |
589 | int dependencies_used, dependencies_allocated; | |
590 | ||
591 | includes_allocated = 30; | |
592 | includes_used = 0; | |
593 | psymtab_include_list = (char **) alloca (includes_allocated * | |
594 | sizeof (char *)); | |
595 | ||
596 | dependencies_allocated = 30; | |
597 | dependencies_used = 0; | |
598 | dependency_list = | |
599 | (struct partial_symtab **) alloca (dependencies_allocated * | |
600 | sizeof (struct partial_symtab *)); | |
601 | ||
602 | last_source_file = NULL; | |
603 | ||
604 | #ifdef END_OF_TEXT_DEFAULT | |
605 | end_of_text_addr = END_OF_TEXT_DEFAULT; | |
606 | #else | |
607 | end_of_text_addr = text_addr + section_offsets->offsets[SECT_OFF_TEXT] | |
608 | + text_size; /* Relocate */ | |
609 | #endif | |
610 | ||
611 | abfd = objfile->obfd; | |
612 | fp = objfile->auxf2; | |
d80ff70c | 613 | if (!fp) return; |
1340861c | 614 | |
d9389f37 KH |
615 | fread(&dbghdr.sync, sizeof(dbghdr.sync), 1, fp); |
616 | fread(&dbghdr.rev, sizeof(dbghdr.rev), 1, fp); | |
617 | fread(&dbghdr.crc, sizeof(dbghdr.crc), 1, fp); | |
618 | fread(&dbghdr.os, sizeof(dbghdr.os), 1, fp); | |
619 | fread(&dbghdr.cpu, sizeof(dbghdr.cpu), 1, fp); | |
620 | SWAP_DBGHDR(&dbghdr, abfd); | |
1340861c KH |
621 | |
622 | symnum = 0; | |
623 | while(1) | |
624 | { | |
625 | int ret; | |
626 | long cursymoffset; | |
627 | ||
628 | /* Get the symbol for this run and pull out some info */ | |
629 | QUIT; /* allow this to be interruptable */ | |
630 | cursymoffset = ftell(objfile->auxf2); | |
631 | ret = fill_sym(objfile->auxf2, abfd); | |
632 | if (ret <= 0) break; | |
633 | else symnum++; | |
634 | bufp = symbuf; | |
635 | ||
636 | /* Special case to speed up readin. */ | |
637 | if (bufp->n_type == (short)N_SYM_SLINE) continue; | |
638 | ||
639 | #define CUR_SYMBOL_VALUE bufp->n_value | |
640 | /* partial-stab.h */ | |
641 | ||
642 | switch (bufp->n_type) | |
643 | { | |
644 | char *p; | |
645 | ||
646 | case N_SYM_CMPLR: | |
647 | continue; | |
648 | ||
649 | case N_SYM_SE: | |
650 | CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT); | |
651 | if (psymfile_depth == 1 && pst) | |
652 | { | |
653 | os9k_end_psymtab (pst, psymtab_include_list, includes_used, | |
654 | symnum, CUR_SYMBOL_VALUE, | |
655 | dependency_list, dependencies_used); | |
656 | pst = (struct partial_symtab *) 0; | |
657 | includes_used = 0; | |
658 | dependencies_used = 0; | |
659 | } | |
660 | psymfile_depth--; | |
661 | continue; | |
662 | ||
663 | case N_SYM_SYM: /* Typedef or automatic variable. */ | |
664 | namestring = bufp->n_strx; | |
665 | p = (char *) strchr (namestring, ':'); | |
666 | if (!p) | |
667 | continue; /* Not a debugging symbol. */ | |
668 | ||
669 | /* Main processing section for debugging symbols which | |
670 | the initial read through the symbol tables needs to worry | |
671 | about. If we reach this point, the symbol which we are | |
672 | considering is definitely one we are interested in. | |
673 | p must also contain the (valid) index into the namestring | |
674 | which indicates the debugging type symbol. */ | |
675 | ||
676 | switch (p[1]) | |
677 | { | |
678 | case 'S' : | |
679 | { | |
680 | unsigned long valu; | |
681 | enum language tmp_language; | |
d5336fc5 KH |
682 | char *str, *p; |
683 | int n; | |
1340861c | 684 | |
d80ff70c KH |
685 | valu = CUR_SYMBOL_VALUE; |
686 | if (valu) | |
687 | valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); | |
1340861c KH |
688 | past_first_source_file = 1; |
689 | ||
d5336fc5 KH |
690 | p = strchr(namestring, ':'); |
691 | if (p) n = p-namestring; | |
692 | else n = strlen(namestring); | |
693 | str = alloca(n+1); | |
694 | strncpy(str, namestring, n); | |
695 | str[n] = '\0'; | |
696 | ||
1340861c KH |
697 | if (psymfile_depth == 0) { |
698 | if (!pst) | |
699 | pst = os9k_start_psymtab (objfile, section_offsets, | |
d5336fc5 | 700 | str, valu, |
1340861c KH |
701 | cursymoffset, |
702 | symnum-1, | |
703 | objfile -> global_psymbols.next, | |
704 | objfile -> static_psymbols.next); | |
705 | } else { /* this is a include file */ | |
d5336fc5 | 706 | tmp_language = deduce_language_from_filename (str); |
1340861c KH |
707 | if (tmp_language != language_unknown |
708 | && (tmp_language != language_c | |
709 | || psymtab_language != language_cplus)) | |
710 | psymtab_language = tmp_language; | |
711 | ||
712 | /* | |
d5336fc5 | 713 | if (pst && STREQ (str, pst->filename)) |
1340861c KH |
714 | continue; |
715 | { | |
716 | register int i; | |
717 | for (i = 0; i < includes_used; i++) | |
d5336fc5 | 718 | if (STREQ (str, psymtab_include_list[i])) |
1340861c KH |
719 | { |
720 | i = -1; | |
721 | break; | |
722 | } | |
723 | if (i == -1) | |
724 | continue; | |
725 | } | |
726 | */ | |
727 | ||
d5336fc5 | 728 | psymtab_include_list[includes_used++] = str; |
1340861c KH |
729 | if (includes_used >= includes_allocated) |
730 | { | |
731 | char **orig = psymtab_include_list; | |
732 | ||
733 | psymtab_include_list = (char **) | |
734 | alloca ((includes_allocated *= 2) * sizeof (char *)); | |
735 | memcpy ((PTR)psymtab_include_list, (PTR)orig, | |
736 | includes_used * sizeof (char *)); | |
737 | } | |
738 | ||
739 | } | |
740 | psymfile_depth++; | |
741 | continue; | |
742 | } | |
743 | ||
744 | case 'v': | |
745 | ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring, | |
746 | VAR_NAMESPACE, LOC_STATIC, | |
747 | objfile->static_psymbols, | |
748 | CUR_SYMBOL_VALUE, | |
749 | psymtab_language, objfile); | |
750 | continue; | |
751 | case 'V': | |
752 | ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring, | |
753 | VAR_NAMESPACE, LOC_STATIC, | |
754 | objfile->global_psymbols, | |
755 | CUR_SYMBOL_VALUE, | |
756 | psymtab_language, objfile); | |
757 | continue; | |
758 | ||
759 | case 'T': | |
760 | if (p != namestring) /* a name is there, not just :T... */ | |
761 | { | |
762 | ADD_PSYMBOL_TO_LIST (namestring, p - namestring, | |
763 | STRUCT_NAMESPACE, LOC_TYPEDEF, | |
764 | objfile->static_psymbols, | |
765 | CUR_SYMBOL_VALUE, | |
766 | psymtab_language, objfile); | |
767 | if (p[2] == 't') | |
768 | { | |
769 | /* Also a typedef with the same name. */ | |
770 | ADD_PSYMBOL_TO_LIST (namestring, p - namestring, | |
771 | VAR_NAMESPACE, LOC_TYPEDEF, | |
772 | objfile->static_psymbols, | |
773 | CUR_SYMBOL_VALUE, psymtab_language, | |
774 | objfile); | |
775 | p += 1; | |
776 | } | |
777 | /* The semantics of C++ state that "struct foo { ... }" | |
778 | also defines a typedef for "foo". Unfortuantely, cfront | |
779 | never makes the typedef when translating from C++ to C. | |
780 | We make the typedef here so that "ptype foo" works as | |
781 | expected for cfront translated code. */ | |
782 | else if (psymtab_language == language_cplus) | |
783 | { | |
784 | /* Also a typedef with the same name. */ | |
785 | ADD_PSYMBOL_TO_LIST (namestring, p - namestring, | |
786 | VAR_NAMESPACE, LOC_TYPEDEF, | |
787 | objfile->static_psymbols, | |
788 | CUR_SYMBOL_VALUE, psymtab_language, | |
789 | objfile); | |
790 | } | |
791 | } | |
792 | goto check_enum; | |
793 | case 't': | |
794 | if (p != namestring) /* a name is there, not just :T... */ | |
795 | { | |
796 | ADD_PSYMBOL_TO_LIST (namestring, p - namestring, | |
797 | VAR_NAMESPACE, LOC_TYPEDEF, | |
798 | objfile->static_psymbols, | |
799 | CUR_SYMBOL_VALUE, | |
800 | psymtab_language, objfile); | |
801 | } | |
802 | check_enum: | |
803 | /* If this is an enumerated type, we need to | |
804 | add all the enum constants to the partial symbol | |
805 | table. This does not cover enums without names, e.g. | |
806 | "enum {a, b} c;" in C, but fortunately those are | |
807 | rare. There is no way for GDB to find those from the | |
808 | enum type without spending too much time on it. Thus | |
809 | to solve this problem, the compiler needs to put out the | |
810 | enum in a nameless type. GCC2 does this. */ | |
811 | ||
812 | /* We are looking for something of the form | |
813 | <name> ":" ("t" | "T") [<number> "="] "e" <size> | |
814 | {<constant> ":" <value> ","} ";". */ | |
815 | ||
816 | /* Skip over the colon and the 't' or 'T'. */ | |
817 | p += 2; | |
818 | /* This type may be given a number. Also, numbers can come | |
819 | in pairs like (0,26). Skip over it. */ | |
820 | while ((*p >= '0' && *p <= '9') | |
821 | || *p == '(' || *p == ',' || *p == ')' | |
822 | || *p == '=') | |
823 | p++; | |
824 | ||
825 | if (*p++ == 'e') | |
826 | { | |
827 | /* We have found an enumerated type. skip size */ | |
828 | while (*p >= '0' && *p <= '9') p++; | |
829 | /* According to comments in read_enum_type | |
830 | a comma could end it instead of a semicolon. | |
831 | I don't know where that happens. | |
832 | Accept either. */ | |
833 | while (*p && *p != ';' && *p != ',') | |
834 | { | |
835 | char *q; | |
836 | ||
837 | /* Check for and handle cretinous dbx symbol name | |
838 | continuation! | |
839 | if (*p == '\\') | |
840 | p = next_symbol_text (); | |
841 | */ | |
842 | ||
843 | /* Point to the character after the name | |
844 | of the enum constant. */ | |
845 | for (q = p; *q && *q != ':'; q++) | |
846 | ; | |
847 | /* Note that the value doesn't matter for | |
848 | enum constants in psymtabs, just in symtabs. */ | |
849 | ADD_PSYMBOL_TO_LIST (p, q - p, | |
850 | VAR_NAMESPACE, LOC_CONST, | |
851 | objfile->static_psymbols, 0, | |
852 | psymtab_language, objfile); | |
853 | /* Point past the name. */ | |
854 | p = q; | |
855 | /* Skip over the value. */ | |
856 | while (*p && *p != ',') | |
857 | p++; | |
858 | /* Advance past the comma. */ | |
859 | if (*p) | |
860 | p++; | |
861 | } | |
862 | } | |
863 | continue; | |
864 | case 'c': | |
865 | /* Constant, e.g. from "const" in Pascal. */ | |
866 | ADD_PSYMBOL_TO_LIST (namestring, p - namestring, | |
867 | VAR_NAMESPACE, LOC_CONST, | |
868 | objfile->static_psymbols, CUR_SYMBOL_VALUE, | |
869 | psymtab_language, objfile); | |
870 | continue; | |
871 | ||
872 | case 'f': | |
873 | CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT); | |
874 | if (pst && pst->textlow == 0) | |
875 | pst->textlow = CUR_SYMBOL_VALUE; | |
876 | ||
877 | ADD_PSYMBOL_TO_LIST (namestring, p - namestring, | |
878 | VAR_NAMESPACE, LOC_BLOCK, | |
879 | objfile->static_psymbols, CUR_SYMBOL_VALUE, | |
880 | psymtab_language, objfile); | |
881 | continue; | |
882 | ||
883 | case 'F': | |
884 | CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT); | |
885 | if (pst && pst->textlow == 0) | |
886 | pst->textlow = CUR_SYMBOL_VALUE; | |
887 | ||
888 | ADD_PSYMBOL_TO_LIST (namestring, p - namestring, | |
889 | VAR_NAMESPACE, LOC_BLOCK, | |
890 | objfile->global_psymbols, CUR_SYMBOL_VALUE, | |
891 | psymtab_language, objfile); | |
892 | continue; | |
893 | ||
894 | case 'p': | |
895 | case 'l': | |
d9389f37 | 896 | case 's': |
1340861c KH |
897 | continue; |
898 | ||
899 | case ':': | |
900 | /* It is a C++ nested symbol. We don't need to record it | |
901 | (I don't think); if we try to look up foo::bar::baz, | |
902 | then symbols for the symtab containing foo should get | |
903 | read in, I think. */ | |
904 | /* Someone says sun cc puts out symbols like | |
905 | /foo/baz/maclib::/usr/local/bin/maclib, | |
906 | which would get here with a symbol type of ':'. */ | |
907 | continue; | |
908 | ||
909 | default: | |
910 | /* Unexpected symbol descriptor. The second and subsequent stabs | |
911 | of a continued stab can show up here. The question is | |
912 | whether they ever can mimic a normal stab--it would be | |
913 | nice if not, since we certainly don't want to spend the | |
914 | time searching to the end of every string looking for | |
915 | a backslash. */ | |
916 | ||
917 | complain (&unknown_symchar_complaint, p[1]); | |
918 | continue; | |
919 | } | |
920 | ||
921 | case N_SYM_RBRAC: | |
922 | CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT); | |
923 | #ifdef HANDLE_RBRAC | |
924 | HANDLE_RBRAC(CUR_SYMBOL_VALUE); | |
925 | continue; | |
926 | #endif | |
927 | case N_SYM_LBRAC: | |
928 | continue; | |
929 | ||
930 | default: | |
931 | /* If we haven't found it yet, ignore it. It's probably some | |
932 | new type we don't know about yet. */ | |
933 | complain (&unknown_symtype_complaint, | |
934 | local_hex_string ((unsigned long) bufp->n_type)); | |
935 | continue; | |
936 | } | |
937 | } | |
938 | ||
939 | DBX_SYMCOUNT (objfile) = symnum; | |
940 | ||
941 | /* If there's stuff to be cleaned up, clean it up. */ | |
942 | if (DBX_SYMCOUNT (objfile) > 0 | |
943 | /*FIXME, does this have a bug at start address 0? */ | |
944 | && last_o_file_start | |
945 | && objfile -> ei.entry_point < bufp->n_value | |
946 | && objfile -> ei.entry_point >= last_o_file_start) | |
947 | { | |
948 | objfile -> ei.entry_file_lowpc = last_o_file_start; | |
949 | objfile -> ei.entry_file_highpc = bufp->n_value; | |
950 | } | |
951 | ||
952 | if (pst) | |
953 | { | |
954 | os9k_end_psymtab (pst, psymtab_include_list, includes_used, | |
955 | symnum, end_of_text_addr, | |
956 | dependency_list, dependencies_used); | |
957 | } | |
958 | /* | |
959 | do_cleanups (back_to); | |
960 | */ | |
961 | } | |
962 | ||
963 | /* Allocate and partially fill a partial symtab. It will be | |
964 | completely filled at the end of the symbol list. | |
965 | ||
966 | SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR | |
967 | is the address relative to which its symbols are (incremental) or 0 | |
968 | (normal). */ | |
969 | ||
970 | ||
971 | static struct partial_symtab * | |
972 | os9k_start_psymtab (objfile, section_offsets, | |
973 | filename, textlow, ldsymoff,ldsymcnt, global_syms, static_syms) | |
974 | struct objfile *objfile; | |
975 | struct section_offsets *section_offsets; | |
976 | char *filename; | |
977 | CORE_ADDR textlow; | |
978 | int ldsymoff; | |
979 | int ldsymcnt; | |
980 | struct partial_symbol *global_syms; | |
981 | struct partial_symbol *static_syms; | |
982 | { | |
983 | struct partial_symtab *result = | |
984 | start_psymtab_common(objfile, section_offsets, | |
985 | filename, textlow, global_syms, static_syms); | |
986 | ||
987 | result->read_symtab_private = (char *) | |
988 | obstack_alloc (&objfile -> psymbol_obstack, sizeof (struct symloc)); | |
989 | ||
990 | LDSYMOFF(result) = ldsymoff; | |
991 | LDSYMCNT(result) = ldsymcnt; | |
992 | result->read_symtab = os9k_psymtab_to_symtab; | |
993 | ||
994 | /* Deduce the source language from the filename for this psymtab. */ | |
995 | psymtab_language = deduce_language_from_filename (filename); | |
996 | return result; | |
997 | } | |
998 | ||
999 | /* Close off the current usage of PST. | |
1000 | Returns PST or NULL if the partial symtab was empty and thrown away. | |
1001 | FIXME: List variables and peculiarities of same. */ | |
1002 | ||
1003 | static struct partial_symtab * | |
1004 | os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, | |
1005 | capping_text, dependency_list, number_dependencies) | |
1006 | struct partial_symtab *pst; | |
1007 | char **include_list; | |
1008 | int num_includes; | |
1009 | int capping_symbol_cnt; | |
1010 | CORE_ADDR capping_text; | |
1011 | struct partial_symtab **dependency_list; | |
1012 | int number_dependencies; | |
1013 | /* struct partial_symbol *capping_global, *capping_static;*/ | |
1014 | { | |
1015 | int i; | |
1016 | struct partial_symtab *p1; | |
1017 | struct objfile *objfile = pst -> objfile; | |
1018 | ||
1019 | if (capping_symbol_cnt != -1) | |
1020 | LDSYMCNT(pst) = capping_symbol_cnt - LDSYMCNT(pst); | |
1021 | ||
1022 | /* Under Solaris, the N_SO symbols always have a value of 0, | |
1023 | instead of the usual address of the .o file. Therefore, | |
1024 | we have to do some tricks to fill in texthigh and textlow. | |
1025 | The first trick is in partial-stab.h: if we see a static | |
1026 | or global function, and the textlow for the current pst | |
1027 | is still 0, then we use that function's address for | |
1028 | the textlow of the pst. | |
1029 | ||
1030 | Now, to fill in texthigh, we remember the last function seen | |
1031 | in the .o file (also in partial-stab.h). Also, there's a hack in | |
1032 | bfd/elf.c and gdb/elfread.c to pass the ELF st_size field | |
1033 | to here via the misc_info field. Therefore, we can fill in | |
1034 | a reliable texthigh by taking the address plus size of the | |
1035 | last function in the file. | |
1036 | ||
1037 | Unfortunately, that does not cover the case where the last function | |
1038 | in the file is static. See the paragraph below for more comments | |
1039 | on this situation. | |
1040 | ||
1041 | Finally, if we have a valid textlow for the current file, we run | |
1042 | down the partial_symtab_list filling in previous texthighs that | |
1043 | are still unknown. */ | |
1044 | ||
1045 | if (pst->texthigh == 0 && last_function_name) { | |
1046 | char *p; | |
1047 | int n; | |
1048 | struct minimal_symbol *minsym; | |
1049 | ||
1050 | p = strchr (last_function_name, ':'); | |
1051 | if (p == NULL) | |
1052 | p = last_function_name; | |
1053 | n = p - last_function_name; | |
1054 | p = alloca (n + 1); | |
1055 | strncpy (p, last_function_name, n); | |
1056 | p[n] = 0; | |
1057 | ||
2d336b1b | 1058 | minsym = lookup_minimal_symbol (p, NULL, objfile); |
1340861c KH |
1059 | |
1060 | if (minsym) { | |
1061 | pst->texthigh = SYMBOL_VALUE_ADDRESS(minsym)+(long)MSYMBOL_INFO(minsym); | |
1062 | } else { | |
1063 | /* This file ends with a static function, and it's | |
1064 | difficult to imagine how hard it would be to track down | |
1065 | the elf symbol. Luckily, most of the time no one will notice, | |
1066 | since the next file will likely be compiled with -g, so | |
1067 | the code below will copy the first fuction's start address | |
1068 | back to our texthigh variable. (Also, if this file is the | |
1069 | last one in a dynamically linked program, texthigh already | |
1070 | has the right value.) If the next file isn't compiled | |
1071 | with -g, then the last function in this file winds up owning | |
1072 | all of the text space up to the next -g file, or the end (minus | |
1073 | shared libraries). This only matters for single stepping, | |
1074 | and even then it will still work, except that it will single | |
1075 | step through all of the covered functions, instead of setting | |
1076 | breakpoints around them as it usualy does. This makes it | |
1077 | pretty slow, but at least it doesn't fail. | |
1078 | ||
1079 | We can fix this with a fairly big change to bfd, but we need | |
1080 | to coordinate better with Cygnus if we want to do that. FIXME. */ | |
1081 | } | |
1082 | last_function_name = NULL; | |
1083 | } | |
1084 | ||
1085 | /* this test will be true if the last .o file is only data */ | |
1086 | if (pst->textlow == 0) | |
1087 | pst->textlow = pst->texthigh; | |
1088 | ||
1089 | /* If we know our own starting text address, then walk through all other | |
1090 | psymtabs for this objfile, and if any didn't know their ending text | |
1091 | address, set it to our starting address. Take care to not set our | |
1092 | own ending address to our starting address, nor to set addresses on | |
1093 | `dependency' files that have both textlow and texthigh zero. */ | |
1094 | if (pst->textlow) { | |
1095 | ALL_OBJFILE_PSYMTABS (objfile, p1) { | |
1096 | if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst) { | |
1097 | p1->texthigh = pst->textlow; | |
1098 | /* if this file has only data, then make textlow match texthigh */ | |
1099 | if (p1->textlow == 0) | |
1100 | p1->textlow = p1->texthigh; | |
1101 | } | |
1102 | } | |
1103 | } | |
1104 | ||
1105 | /* End of kludge for patching Solaris textlow and texthigh. */ | |
1106 | ||
1107 | pst->n_global_syms = | |
1108 | objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset); | |
1109 | pst->n_static_syms = | |
1110 | objfile->static_psymbols.next - (objfile->static_psymbols.list + pst->statics_offset); | |
1111 | ||
1112 | pst->number_of_dependencies = number_dependencies; | |
1113 | if (number_dependencies) | |
1114 | { | |
1115 | pst->dependencies = (struct partial_symtab **) | |
1116 | obstack_alloc (&objfile->psymbol_obstack, | |
1117 | number_dependencies * sizeof (struct partial_symtab *)); | |
1118 | memcpy (pst->dependencies, dependency_list, | |
1119 | number_dependencies * sizeof (struct partial_symtab *)); | |
1120 | } | |
1121 | else | |
1122 | pst->dependencies = 0; | |
1123 | ||
1124 | for (i = 0; i < num_includes; i++) | |
1125 | { | |
1126 | struct partial_symtab *subpst = | |
1127 | allocate_psymtab (include_list[i], objfile); | |
1128 | ||
1129 | subpst->section_offsets = pst->section_offsets; | |
1130 | subpst->read_symtab_private = | |
1131 | (char *) obstack_alloc (&objfile->psymbol_obstack, | |
1132 | sizeof (struct symloc)); | |
1133 | LDSYMOFF(subpst) = | |
1134 | LDSYMCNT(subpst) = | |
1135 | subpst->textlow = | |
1136 | subpst->texthigh = 0; | |
1137 | ||
1138 | /* We could save slight bits of space by only making one of these, | |
1139 | shared by the entire set of include files. FIXME-someday. */ | |
1140 | subpst->dependencies = (struct partial_symtab **) | |
1141 | obstack_alloc (&objfile->psymbol_obstack, | |
1142 | sizeof (struct partial_symtab *)); | |
1143 | subpst->dependencies[0] = pst; | |
1144 | subpst->number_of_dependencies = 1; | |
1145 | ||
1146 | subpst->globals_offset = | |
1147 | subpst->n_global_syms = | |
1148 | subpst->statics_offset = | |
1149 | subpst->n_static_syms = 0; | |
1150 | ||
1151 | subpst->readin = 0; | |
1152 | subpst->symtab = 0; | |
1153 | subpst->read_symtab = pst->read_symtab; | |
1154 | } | |
1155 | ||
1156 | sort_pst_symbols (pst); | |
1157 | ||
1158 | /* If there is already a psymtab or symtab for a file of this name, | |
1159 | remove it. | |
1160 | (If there is a symtab, more drastic things also happen.) | |
1161 | This happens in VxWorks. */ | |
1162 | free_named_symtabs (pst->filename); | |
1163 | ||
1164 | if (num_includes == 0 | |
1165 | && number_dependencies == 0 | |
1166 | && pst->n_global_syms == 0 | |
1167 | && pst->n_static_syms == 0) { | |
1168 | /* Throw away this psymtab, it's empty. We can't deallocate it, since | |
1169 | it is on the obstack, but we can forget to chain it on the list. */ | |
1170 | struct partial_symtab *prev_pst; | |
1171 | ||
1172 | /* First, snip it out of the psymtab chain */ | |
1173 | ||
1174 | if (pst->objfile->psymtabs == pst) | |
1175 | pst->objfile->psymtabs = pst->next; | |
1176 | else | |
1177 | for (prev_pst = pst->objfile->psymtabs; prev_pst; prev_pst = pst->next) | |
1178 | if (prev_pst->next == pst) | |
1179 | prev_pst->next = pst->next; | |
1180 | ||
1181 | /* Next, put it on a free list for recycling */ | |
1182 | pst->next = pst->objfile->free_psymtabs; | |
1183 | pst->objfile->free_psymtabs = pst; | |
1184 | ||
1185 | /* Indicate that psymtab was thrown away. */ | |
1186 | pst = (struct partial_symtab *)NULL; | |
1187 | } | |
1188 | return pst; | |
1189 | } | |
1190 | \f | |
1191 | static void | |
1192 | os9k_psymtab_to_symtab_1 (pst) | |
1193 | struct partial_symtab *pst; | |
1194 | { | |
1195 | struct cleanup *old_chain; | |
1196 | int i; | |
1197 | ||
1198 | if (!pst) | |
1199 | return; | |
1200 | ||
1201 | if (pst->readin) | |
1202 | { | |
1203 | fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n", | |
1204 | pst->filename); | |
1205 | return; | |
1206 | } | |
1207 | ||
1208 | /* Read in all partial symtabs on which this one is dependent */ | |
1209 | for (i = 0; i < pst->number_of_dependencies; i++) | |
1210 | if (!pst->dependencies[i]->readin) | |
1211 | { | |
1212 | /* Inform about additional files that need to be read in. */ | |
1213 | if (info_verbose) | |
1214 | { | |
1215 | fputs_filtered (" ", gdb_stdout); | |
1216 | wrap_here (""); | |
1217 | fputs_filtered ("and ", gdb_stdout); | |
1218 | wrap_here (""); | |
1219 | printf_filtered ("%s...", pst->dependencies[i]->filename); | |
1220 | wrap_here (""); /* Flush output */ | |
1221 | gdb_flush (gdb_stdout); | |
1222 | } | |
1223 | os9k_psymtab_to_symtab_1 (pst->dependencies[i]); | |
1224 | } | |
1225 | ||
1226 | if (LDSYMCNT(pst)) /* Otherwise it's a dummy */ | |
1227 | { | |
1228 | /* Init stuff necessary for reading in symbols */ | |
1229 | stabsread_init (); | |
1230 | buildsym_init (); | |
1231 | old_chain = make_cleanup (really_free_pendings, 0); | |
1232 | ||
1233 | /* Read in this file's symbols */ | |
1234 | os9k_read_ofile_symtab (pst); | |
1235 | sort_symtab_syms (pst->symtab); | |
1236 | do_cleanups (old_chain); | |
1237 | } | |
1238 | ||
1239 | pst->readin = 1; | |
1240 | } | |
1241 | ||
1242 | /* Read in all of the symbols for a given psymtab for real. | |
1243 | Be verbose about it if the user wants that. */ | |
1244 | ||
1245 | static void | |
1246 | os9k_psymtab_to_symtab (pst) | |
1247 | struct partial_symtab *pst; | |
1248 | { | |
1249 | bfd *sym_bfd; | |
1250 | ||
1251 | if (!pst) | |
1252 | return; | |
1253 | ||
1254 | if (pst->readin) | |
1255 | { | |
1256 | fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n", | |
1257 | pst->filename); | |
1258 | return; | |
1259 | } | |
1260 | ||
1261 | if (LDSYMCNT(pst) || pst->number_of_dependencies) | |
1262 | { | |
1263 | /* Print the message now, before reading the string table, | |
1264 | to avoid disconcerting pauses. */ | |
1265 | if (info_verbose) | |
1266 | { | |
1267 | printf_filtered ("Reading in symbols for %s...", pst->filename); | |
1268 | gdb_flush (gdb_stdout); | |
1269 | } | |
1270 | ||
1271 | sym_bfd = pst->objfile->obfd; | |
1272 | os9k_psymtab_to_symtab_1 (pst); | |
1273 | ||
1274 | /* Match with global symbols. This only needs to be done once, | |
1275 | after all of the symtabs and dependencies have been read in. */ | |
1276 | scan_file_globals (pst->objfile); | |
1277 | ||
1278 | /* Finish up the debug error message. */ | |
1279 | if (info_verbose) | |
1280 | printf_filtered ("done.\n"); | |
1281 | } | |
1282 | } | |
1283 | ||
1284 | /* Read in a defined section of a specific object file's symbols. */ | |
1285 | static void | |
1286 | os9k_read_ofile_symtab (pst) | |
1287 | struct partial_symtab *pst; | |
1288 | { | |
1289 | register struct internal_symstruct *bufp; | |
1290 | unsigned char type; | |
1291 | unsigned max_symnum; | |
1292 | register bfd *abfd; | |
1293 | struct objfile *objfile; | |
1294 | int sym_offset; /* Offset to start of symbols to read */ | |
1295 | CORE_ADDR text_offset; /* Start of text segment for symbols */ | |
1296 | int text_size; /* Size of text segment for symbols */ | |
1297 | struct section_offsets *section_offsets; | |
1298 | FILE *dbg_file; | |
1299 | ||
1300 | objfile = pst->objfile; | |
1301 | sym_offset = LDSYMOFF(pst); | |
1302 | max_symnum = LDSYMCNT(pst); | |
1303 | text_offset = pst->textlow; | |
1304 | text_size = pst->texthigh - pst->textlow; | |
1305 | section_offsets = pst->section_offsets; | |
1306 | ||
1307 | current_objfile = objfile; | |
1308 | subfile_stack = NULL; | |
1309 | last_source_file = NULL; | |
1310 | ||
1311 | abfd = objfile->obfd; | |
1312 | dbg_file = objfile->auxf2; | |
1313 | ||
1314 | #if 0 | |
1315 | /* It is necessary to actually read one symbol *before* the start | |
1316 | of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL | |
1317 | occurs before the N_SO symbol. | |
1318 | Detecting this in read_dbx_symtab | |
1319 | would slow down initial readin, so we look for it here instead. */ | |
1320 | if (!processing_acc_compilation && sym_offset >= (int)symbol_size) | |
1321 | { | |
1322 | fseek (objefile->auxf2, sym_offset, SEEK_CUR); | |
1323 | fill_sym(objfile->auxf2, abfd); | |
1324 | bufp = symbuf; | |
1325 | ||
1326 | processing_gcc_compilation = 0; | |
1327 | if (bufp->n_type == N_TEXT) | |
1328 | { | |
1329 | if (STREQ (namestring, GCC_COMPILED_FLAG_SYMBOL)) | |
1330 | processing_gcc_compilation = 1; | |
1331 | else if (STREQ (namestring, GCC2_COMPILED_FLAG_SYMBOL)) | |
1332 | processing_gcc_compilation = 2; | |
1333 | } | |
1334 | ||
1335 | /* Try to select a C++ demangling based on the compilation unit | |
1336 | producer. */ | |
1337 | ||
1338 | if (processing_gcc_compilation) | |
1339 | { | |
1340 | if (AUTO_DEMANGLING) | |
1341 | { | |
1342 | set_demangling_style (GNU_DEMANGLING_STYLE_STRING); | |
1343 | } | |
1344 | } | |
1345 | } | |
1346 | else | |
1347 | { | |
1348 | /* The N_SO starting this symtab is the first symbol, so we | |
1349 | better not check the symbol before it. I'm not this can | |
1350 | happen, but it doesn't hurt to check for it. */ | |
1351 | bfd_seek (symfile_bfd, sym_offset, SEEK_CUR); | |
1352 | processing_gcc_compilation = 0; | |
1353 | } | |
25200748 | 1354 | #endif /* 0 */ |
1340861c KH |
1355 | |
1356 | fseek(dbg_file, (long)sym_offset, 0); | |
1357 | /* | |
1358 | if (bufp->n_type != (unsigned char)N_SYM_SYM) | |
1359 | error("First symbol in segment of executable not a source symbol"); | |
1360 | */ | |
1361 | ||
1362 | for (symnum = 0; symnum < max_symnum; symnum++) | |
1363 | { | |
1364 | QUIT; /* Allow this to be interruptable */ | |
1365 | fill_sym(dbg_file, abfd); | |
1366 | bufp = symbuf; | |
1367 | type = bufp->n_type; | |
1368 | ||
d5336fc5 KH |
1369 | os9k_process_one_symbol ((int)type, (int)bufp->n_desc, |
1370 | (CORE_ADDR)bufp->n_value, bufp->n_strx, section_offsets, objfile); | |
1340861c KH |
1371 | |
1372 | /* We skip checking for a new .o or -l file; that should never | |
1373 | happen in this routine. */ | |
1374 | #if 0 | |
1375 | else if (type == N_TEXT) | |
1376 | { | |
1377 | /* I don't think this code will ever be executed, because | |
1378 | the GCC_COMPILED_FLAG_SYMBOL usually is right before | |
1379 | the N_SO symbol which starts this source file. | |
1380 | However, there is no reason not to accept | |
1381 | the GCC_COMPILED_FLAG_SYMBOL anywhere. */ | |
1382 | ||
1383 | if (STREQ (namestring, GCC_COMPILED_FLAG_SYMBOL)) | |
1384 | processing_gcc_compilation = 1; | |
1385 | else if (STREQ (namestring, GCC2_COMPILED_FLAG_SYMBOL)) | |
1386 | processing_gcc_compilation = 2; | |
1387 | ||
1388 | if (AUTO_DEMANGLING) | |
1389 | { | |
1390 | set_demangling_style (GNU_DEMANGLING_STYLE_STRING); | |
1391 | } | |
1392 | } | |
1393 | else if (type & N_EXT || type == (unsigned char)N_TEXT | |
1394 | || type == (unsigned char)N_NBTEXT | |
1395 | ) { | |
1396 | /* Global symbol: see if we came across a dbx defintion for | |
1397 | a corresponding symbol. If so, store the value. Remove | |
1398 | syms from the chain when their values are stored, but | |
1399 | search the whole chain, as there may be several syms from | |
1400 | different files with the same name. */ | |
1401 | /* This is probably not true. Since the files will be read | |
1402 | in one at a time, each reference to a global symbol will | |
1403 | be satisfied in each file as it appears. So we skip this | |
1404 | section. */ | |
1405 | ; | |
1406 | } | |
25200748 | 1407 | #endif /* 0 */ |
1340861c KH |
1408 | } |
1409 | ||
1410 | current_objfile = NULL; | |
1411 | ||
1412 | /* In a Solaris elf file, this variable, which comes from the | |
1413 | value of the N_SO symbol, will still be 0. Luckily, text_offset, | |
1414 | which comes from pst->textlow is correct. */ | |
1415 | if (last_source_start_addr == 0) | |
1416 | last_source_start_addr = text_offset; | |
1417 | pst->symtab = end_symtab (text_offset + text_size, 0, 0, objfile, | |
1418 | SECT_OFF_TEXT); | |
1419 | end_stabs (); | |
1420 | } | |
1421 | ||
1422 | \f | |
1423 | /* This handles a single symbol from the symbol-file, building symbols | |
1424 | into a GDB symtab. It takes these arguments and an implicit argument. | |
1425 | ||
1426 | TYPE is the type field of the ".stab" symbol entry. | |
1427 | DESC is the desc field of the ".stab" entry. | |
1428 | VALU is the value field of the ".stab" entry. | |
1429 | NAME is the symbol name, in our address space. | |
1430 | SECTION_OFFSETS is a set of amounts by which the sections of this object | |
1431 | file were relocated when it was loaded into memory. | |
1432 | All symbols that refer | |
1433 | to memory locations need to be offset by these amounts. | |
1434 | OBJFILE is the object file from which we are reading symbols. | |
1435 | It is used in end_symtab. */ | |
1436 | ||
1437 | static void | |
1438 | os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) | |
1439 | int type, desc; | |
1440 | CORE_ADDR valu; | |
1441 | char *name; | |
1442 | struct section_offsets *section_offsets; | |
1443 | struct objfile *objfile; | |
1444 | { | |
1445 | register struct context_stack *new; | |
1446 | /* The stab type used for the definition of the last function. | |
1447 | N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */ | |
1448 | static int function_stab_type = 0; | |
1449 | ||
1450 | #if 0 | |
1451 | /* Something is wrong if we see real data before | |
1452 | seeing a source file name. */ | |
1453 | if (last_source_file == NULL && type != (unsigned char)N_SO) | |
1454 | { | |
1455 | /* Ignore any symbols which appear before an N_SO symbol. Currently | |
1456 | no one puts symbols there, but we should deal gracefully with the | |
1457 | case. A complain()t might be in order (if !IGNORE_SYMBOL (type)), | |
1458 | but this should not be an error (). */ | |
1459 | return; | |
1460 | } | |
25200748 | 1461 | #endif /* 0 */ |
1340861c KH |
1462 | |
1463 | switch (type) | |
1464 | { | |
1465 | case N_SYM_LBRAC: | |
1466 | /* On most machines, the block addresses are relative to the | |
1467 | N_SO, the linker did not relocate them (sigh). */ | |
d9389f37 | 1468 | valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); |
1340861c KH |
1469 | new = push_context (desc, valu); |
1470 | break; | |
1471 | ||
1472 | case N_SYM_RBRAC: | |
d9389f37 | 1473 | valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); |
1340861c KH |
1474 | new = pop_context(); |
1475 | ||
25200748 JK |
1476 | #if !defined (OS9K_VARIABLES_INSIDE_BLOCK) |
1477 | #define OS9K_VARIABLES_INSIDE_BLOCK(desc, gcc_p) 1 | |
1340861c KH |
1478 | #endif |
1479 | ||
25200748 | 1480 | if (!OS9K_VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) |
1340861c KH |
1481 | local_symbols = new->locals; |
1482 | ||
1483 | if (context_stack_depth > 1) | |
1484 | { | |
1485 | /* This is not the outermost LBRAC...RBRAC pair in the function, | |
1486 | its local symbols preceded it, and are the ones just recovered | |
1487 | from the context stack. Define the block for them (but don't | |
1488 | bother if the block contains no symbols. Should we complain | |
1489 | on blocks without symbols? I can't think of any useful purpose | |
1490 | for them). */ | |
1491 | if (local_symbols != NULL) | |
1492 | { | |
1493 | /* Muzzle a compiler bug that makes end < start. (which | |
1494 | compilers? Is this ever harmful?). */ | |
1495 | if (new->start_addr > valu) | |
1496 | { | |
1497 | complain (&lbrac_rbrac_complaint); | |
1498 | new->start_addr = valu; | |
1499 | } | |
1500 | /* Make a block for the local symbols within. */ | |
1501 | finish_block (0, &local_symbols, new->old_blocks, | |
1502 | new->start_addr, valu, objfile); | |
1503 | } | |
1504 | } | |
1505 | else | |
1506 | { | |
1507 | if (context_stack_depth == 0) | |
1508 | { | |
1509 | within_function = 0; | |
1510 | /* Make a block for the local symbols within. */ | |
1511 | finish_block (new->name, &local_symbols, new->old_blocks, | |
1512 | new->start_addr, valu, objfile); | |
1513 | } | |
1514 | else | |
1515 | { | |
1516 | /* attach local_symbols to the end of new->locals */ | |
1517 | if (!new->locals) new->locals = local_symbols; | |
1518 | else { | |
1519 | struct pending *p; | |
1520 | ||
1521 | p = new->locals; | |
1522 | while (p->next) p = p->next; | |
1523 | p->next = local_symbols; | |
1524 | } | |
1525 | } | |
1526 | } | |
1527 | ||
25200748 | 1528 | if (OS9K_VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) |
1340861c KH |
1529 | /* Now pop locals of block just finished. */ |
1530 | local_symbols = new->locals; | |
1531 | break; | |
1532 | ||
1533 | ||
1534 | case N_SYM_SLINE: | |
1535 | /* This type of "symbol" really just records | |
1536 | one line-number -- core-address correspondence. | |
1537 | Enter it in the line list for this symbol table. */ | |
1538 | /* Relocate for dynamic loading and for ELF acc fn-relative syms. */ | |
d9389f37 | 1539 | valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); |
1340861c KH |
1540 | record_line (current_subfile, (int)name, valu); |
1541 | break; | |
1542 | ||
1543 | /* The following symbol types need to have the appropriate offset added | |
1544 | to their value; then we process symbol definitions in the name. */ | |
1545 | case N_SYM_SYM: | |
1546 | ||
1547 | if (name) | |
1548 | { | |
1549 | char deftype; | |
1550 | char *dirn, *n; | |
1551 | char *p = strchr (name, ':'); | |
1552 | if (p == NULL) | |
1553 | deftype = '\0'; | |
1554 | else | |
1555 | deftype = p[1]; | |
1556 | ||
1557 | ||
1558 | switch (deftype) | |
1559 | { | |
1560 | case 'S': | |
1561 | valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); | |
1562 | n = strrchr(name, '/'); | |
1563 | if (n != NULL) { | |
1564 | *n = '\0'; | |
1565 | n++; | |
1566 | dirn = name; | |
1567 | } else { | |
1568 | n = name; | |
1569 | dirn = NULL; | |
1570 | } | |
1571 | *p = '\0'; | |
1572 | if (symfile_depth++ == 0) { | |
1573 | if (last_source_file) { | |
1574 | end_symtab (valu, 0, 0, objfile, SECT_OFF_TEXT); | |
1575 | end_stabs (); | |
1576 | } | |
1577 | start_stabs (); | |
25200748 | 1578 | os9k_stabs = 1; |
1340861c KH |
1579 | start_symtab (n, dirn, valu); |
1580 | } else { | |
1581 | push_subfile(); | |
1582 | start_subfile (n, dirn!=NULL ? dirn : current_subfile->dirname); | |
1583 | } | |
1584 | break; | |
1585 | ||
1586 | case 'f': | |
1587 | case 'F': | |
1588 | valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); | |
1589 | function_stab_type = type; | |
1590 | ||
1591 | within_function = 1; | |
1592 | new = push_context (0, valu); | |
25200748 | 1593 | new->name = define_symbol (valu, name, desc, type, objfile); |
1340861c KH |
1594 | break; |
1595 | ||
1596 | case 'V': | |
1597 | case 'v': | |
1598 | valu += ANOFFSET (section_offsets, SECT_OFF_DATA); | |
25200748 | 1599 | define_symbol (valu, name, desc, type, objfile); |
1340861c KH |
1600 | break; |
1601 | ||
1602 | default: | |
25200748 | 1603 | define_symbol (valu, name, desc, type, objfile); |
1340861c KH |
1604 | break; |
1605 | } | |
1606 | } | |
1607 | break; | |
1608 | ||
1609 | case N_SYM_SE: | |
1610 | if (--symfile_depth != 0) | |
1611 | start_subfile(pop_subfile(), current_subfile->dirname); | |
1612 | break; | |
1613 | ||
1614 | default: | |
1615 | complain (&unknown_symtype_complaint, | |
1616 | local_hex_string((unsigned long) type)); | |
1617 | /* FALLTHROUGH */ | |
1618 | break; | |
1619 | ||
1620 | case N_SYM_CMPLR: | |
1621 | break; | |
1622 | } | |
1623 | previous_stab_code = type; | |
1624 | } | |
1625 | \f | |
1626 | /* Parse the user's idea of an offset for dynamic linking, into our idea | |
1627 | of how to represent it for fast symbol reading. */ | |
1628 | ||
1629 | static struct section_offsets * | |
1630 | os9k_symfile_offsets (objfile, addr) | |
1631 | struct objfile *objfile; | |
1632 | CORE_ADDR addr; | |
1633 | { | |
1634 | struct section_offsets *section_offsets; | |
1635 | int i; | |
1636 | ||
1637 | objfile->num_sections = SECT_OFF_MAX; | |
1638 | section_offsets = (struct section_offsets *) | |
1639 | obstack_alloc (&objfile -> psymbol_obstack, | |
1640 | sizeof (struct section_offsets) | |
1641 | + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1)); | |
1642 | ||
1643 | for (i = 0; i < SECT_OFF_MAX; i++) | |
1644 | ANOFFSET (section_offsets, i) = addr; | |
1645 | ||
1646 | return section_offsets; | |
1647 | } | |
1648 | \f | |
1649 | static struct sym_fns os9k_sym_fns = | |
1650 | { | |
1651 | bfd_target_os9k_flavour, | |
1652 | os9k_new_init, /* sym_new_init: init anything gbl to entire symtab */ | |
1653 | os9k_symfile_init, /* sym_init: read initial info, setup for sym_read() */ | |
1654 | os9k_symfile_read, /* sym_read: read a symbol file into symtab */ | |
1655 | os9k_symfile_finish, /* sym_finish: finished with file, cleanup */ | |
1656 | os9k_symfile_offsets, /* sym_offsets: parse user's offsets to internal form*/ | |
1657 | NULL /* next: pointer to next struct sym_fns */ | |
1658 | }; | |
1659 | ||
1660 | void | |
1661 | _initialize_os9kread () | |
1662 | { | |
1663 | add_symtab_fns(&os9k_sym_fns); | |
1664 | } |