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