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