A mostly cosmetic tidy up of warnings and error message reporting.
[deliverable/binutils-gdb.git] / binutils / rdcoff.c
CommitLineData
252b5132 1/* stabs.c -- Parse COFF debugging information
37cc8ec1 2 Copyright (C) 1996, 98, 99, 2000 Free Software Foundation, Inc.
252b5132
RH
3 Written by Ian Lance Taylor <ian@cygnus.com>.
4
5 This file is part of GNU Binutils.
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
20 02111-1307, USA. */
21
22/* This file contains code which parses COFF debugging information. */
23
24#include "bfd.h"
25#include "coff/internal.h"
26#include "bucomm.h"
27#include "libiberty.h"
28#include "demangle.h"
29#include "debug.h"
30#include "budbg.h"
31
32/* FIXME: We should not need this BFD internal file. We need it for
33 the N_BTMASK, etc., values. */
34#include "libcoff.h"
35
36/* These macros extract the right mask and shifts for this BFD. They
37 assume that there is a local variable named ABFD. This is so that
38 macros like ISFCN and DECREF, from coff/internal.h, will work
39 without modification. */
40#define N_BTMASK (coff_data (abfd)->local_n_btmask)
41#define N_BTSHFT (coff_data (abfd)->local_n_btshft)
42#define N_TMASK (coff_data (abfd)->local_n_tmask)
43#define N_TSHIFT (coff_data (abfd)->local_n_tshift)
44
45/* This structure is used to hold the symbols, as well as the current
46 location within the symbols. */
47
48struct coff_symbols
49{
50 /* The symbols. */
51 asymbol **syms;
52 /* The number of symbols. */
53 long symcount;
54 /* The index of the current symbol. */
55 long symno;
56 /* The index of the current symbol in the COFF symbol table (where
57 each auxent counts as a symbol). */
58 long coff_symno;
59};
60
61/* The largest basic type we are prepared to handle. */
62
63#define T_MAX (T_LNGDBL)
64
65/* This structure is used to hold slots. */
66
67struct coff_slots
68{
69 /* Next set of slots. */
70 struct coff_slots *next;
71 /* Slots. */
72#define COFF_SLOTS (16)
73 debug_type slots[COFF_SLOTS];
74};
75
76/* This structure is used to map symbol indices to types. */
77
78struct coff_types
79{
80 /* Slots. */
81 struct coff_slots *slots;
82 /* Basic types. */
83 debug_type basic[T_MAX + 1];
84};
85
86static debug_type *coff_get_slot PARAMS ((struct coff_types *, int));
87static debug_type parse_coff_type
88 PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, long, int,
89 union internal_auxent *, boolean, PTR));
90static debug_type parse_coff_base_type
91 PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, long, int,
92 union internal_auxent *, PTR));
93static debug_type parse_coff_struct_type
94 PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, int,
95 union internal_auxent *, PTR));
96static debug_type parse_coff_enum_type
97 PARAMS ((bfd *, struct coff_symbols *, struct coff_types *,
98 union internal_auxent *, PTR));
99static boolean parse_coff_symbol
100 PARAMS ((bfd *, struct coff_types *, asymbol *, long,
101 struct internal_syment *, PTR, debug_type, boolean));
102\f
103/* Return the slot for a type. */
104
105static debug_type *
106coff_get_slot (types, indx)
107 struct coff_types *types;
108 int indx;
109{
110 struct coff_slots **pps;
111
112 pps = &types->slots;
113
114 while (indx >= COFF_SLOTS)
115 {
116 if (*pps == NULL)
117 {
118 *pps = (struct coff_slots *) xmalloc (sizeof **pps);
119 memset (*pps, 0, sizeof **pps);
120 }
121 pps = &(*pps)->next;
122 indx -= COFF_SLOTS;
123 }
124
125 if (*pps == NULL)
126 {
127 *pps = (struct coff_slots *) xmalloc (sizeof **pps);
128 memset (*pps, 0, sizeof **pps);
129 }
130
131 return (*pps)->slots + indx;
132}
133
134/* Parse a COFF type code in NTYPE. */
135
136static debug_type
137parse_coff_type (abfd, symbols, types, coff_symno, ntype, pauxent, useaux,
138 dhandle)
139 bfd *abfd;
140 struct coff_symbols *symbols;
141 struct coff_types *types;
142 long coff_symno;
143 int ntype;
144 union internal_auxent *pauxent;
145 boolean useaux;
146 PTR dhandle;
147{
148 debug_type type;
149
150 if ((ntype & ~N_BTMASK) != 0)
151 {
152 int newtype;
153
154 newtype = DECREF (ntype);
155
156 if (ISPTR (ntype))
157 {
158 type = parse_coff_type (abfd, symbols, types, coff_symno, newtype,
159 pauxent, useaux, dhandle);
160 type = debug_make_pointer_type (dhandle, type);
161 }
162 else if (ISFCN (ntype))
163 {
164 type = parse_coff_type (abfd, symbols, types, coff_symno, newtype,
165 pauxent, useaux, dhandle);
166 type = debug_make_function_type (dhandle, type, (debug_type *) NULL,
167 false);
168 }
169 else if (ISARY (ntype))
170 {
171 int n;
172
173 if (pauxent == NULL)
174 n = 0;
175 else
176 {
177 unsigned short *dim;
178 int i;
179
180 /* FIXME: If pauxent->x_sym.x_tagndx.l == 0, gdb sets
181 the c_naux field of the syment to 0. */
182
183 /* Move the dimensions down, so that the next array
184 picks up the next one. */
185 dim = pauxent->x_sym.x_fcnary.x_ary.x_dimen;
186 n = dim[0];
187 for (i = 0; *dim != 0 && i < DIMNUM - 1; i++, dim++)
188 *dim = *(dim + 1);
189 *dim = 0;
190 }
191
192 type = parse_coff_type (abfd, symbols, types, coff_symno, newtype,
193 pauxent, false, dhandle);
194 type = debug_make_array_type (dhandle, type,
195 parse_coff_base_type (abfd, symbols,
196 types,
197 coff_symno,
198 T_INT,
199 NULL, dhandle),
200 0, n - 1, false);
201 }
202 else
203 {
37cc8ec1 204 non_fatal (_("parse_coff_type: Bad type code 0x%x"), ntype);
252b5132
RH
205 return DEBUG_TYPE_NULL;
206 }
207
208 return type;
209 }
210
211 if (pauxent != NULL && pauxent->x_sym.x_tagndx.l > 0)
212 {
213 debug_type *slot;
214
215 /* This is a reference to an existing type. FIXME: gdb checks
216 that the class is not C_STRTAG, nor C_UNTAG, nor C_ENTAG. */
217 slot = coff_get_slot (types, pauxent->x_sym.x_tagndx.l);
218 if (*slot != DEBUG_TYPE_NULL)
219 return *slot;
220 else
221 return debug_make_indirect_type (dhandle, slot, (const char *) NULL);
222 }
223
224 /* If the aux entry has already been used for something, useaux will
225 have been set to false, indicating that parse_coff_base_type
226 should not use it. We need to do it this way, rather than simply
227 passing pauxent as NULL, because we need to be able handle
228 multiple array dimensions while still discarding pauxent after
229 having handled all of them. */
230 if (! useaux)
231 pauxent = NULL;
232
233 return parse_coff_base_type (abfd, symbols, types, coff_symno, ntype,
234 pauxent, dhandle);
235}
236
237/* Parse a basic COFF type in NTYPE. */
238
239static debug_type
240parse_coff_base_type (abfd, symbols, types, coff_symno, ntype, pauxent,
241 dhandle)
242 bfd *abfd;
243 struct coff_symbols *symbols;
244 struct coff_types *types;
245 long coff_symno;
246 int ntype;
247 union internal_auxent *pauxent;
248 PTR dhandle;
249{
250 debug_type ret;
251 boolean set_basic;
252 const char *name;
253 debug_type *slot;
254
255 if (ntype >= 0
256 && ntype <= T_MAX
257 && types->basic[ntype] != DEBUG_TYPE_NULL)
258 return types->basic[ntype];
259
260 set_basic = true;
261 name = NULL;
262
263 switch (ntype)
264 {
265 default:
266 ret = debug_make_void_type (dhandle);
267 break;
268
269 case T_NULL:
270 case T_VOID:
271 ret = debug_make_void_type (dhandle);
272 name = "void";
273 break;
274
275 case T_CHAR:
276 ret = debug_make_int_type (dhandle, 1, false);
277 name = "char";
278 break;
279
280 case T_SHORT:
281 ret = debug_make_int_type (dhandle, 2, false);
282 name = "short";
283 break;
284
285 case T_INT:
286 /* FIXME: Perhaps the size should depend upon the architecture. */
287 ret = debug_make_int_type (dhandle, 4, false);
288 name = "int";
289 break;
290
291 case T_LONG:
292 ret = debug_make_int_type (dhandle, 4, false);
293 name = "long";
294 break;
295
296 case T_FLOAT:
297 ret = debug_make_float_type (dhandle, 4);
298 name = "float";
299 break;
300
301 case T_DOUBLE:
302 ret = debug_make_float_type (dhandle, 8);
303 name = "double";
304 break;
305
306 case T_LNGDBL:
307 ret = debug_make_float_type (dhandle, 12);
308 name = "long double";
309 break;
310
311 case T_UCHAR:
312 ret = debug_make_int_type (dhandle, 1, true);
313 name = "unsigned char";
314 break;
315
316 case T_USHORT:
317 ret = debug_make_int_type (dhandle, 2, true);
318 name = "unsigned short";
319 break;
320
321 case T_UINT:
322 ret = debug_make_int_type (dhandle, 4, true);
323 name = "unsigned int";
324 break;
325
326 case T_ULONG:
327 ret = debug_make_int_type (dhandle, 4, true);
328 name = "unsigned long";
329 break;
330
331 case T_STRUCT:
332 if (pauxent == NULL)
333 ret = debug_make_struct_type (dhandle, true, 0,
334 (debug_field *) NULL);
335 else
336 ret = parse_coff_struct_type (abfd, symbols, types, ntype, pauxent,
337 dhandle);
338
339 slot = coff_get_slot (types, coff_symno);
340 *slot = ret;
341
342 set_basic = false;
343 break;
344
345 case T_UNION:
346 if (pauxent == NULL)
347 ret = debug_make_struct_type (dhandle, false, 0, (debug_field *) NULL);
348 else
349 ret = parse_coff_struct_type (abfd, symbols, types, ntype, pauxent,
350 dhandle);
351
352 slot = coff_get_slot (types, coff_symno);
353 *slot = ret;
354
355 set_basic = false;
356 break;
357
358 case T_ENUM:
359 if (pauxent == NULL)
360 ret = debug_make_enum_type (dhandle, (const char **) NULL,
361 (bfd_signed_vma *) NULL);
362 else
363 ret = parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle);
364
365 slot = coff_get_slot (types, coff_symno);
366 *slot = ret;
367
368 set_basic = false;
369 break;
370 }
371
372 if (name != NULL)
373 ret = debug_name_type (dhandle, name, ret);
374
375 if (set_basic
376 && ntype >= 0
377 && ntype <= T_MAX)
378 types->basic[ntype] = ret;
379
380 return ret;
381}
382
383/* Parse a struct type. */
384
385static debug_type
386parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, dhandle)
387 bfd *abfd;
388 struct coff_symbols *symbols;
389 struct coff_types *types;
390 int ntype;
391 union internal_auxent *pauxent;
392 PTR dhandle;
393{
394 long symend;
395 int alloc;
396 debug_field *fields;
397 int count;
398 boolean done;
399
400 symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
401
402 alloc = 10;
403 fields = (debug_field *) xmalloc (alloc * sizeof *fields);
404 count = 0;
405
406 done = false;
407 while (! done
408 && symbols->coff_symno < symend
409 && symbols->symno < symbols->symcount)
410 {
411 asymbol *sym;
412 long this_coff_symno;
413 struct internal_syment syment;
414 union internal_auxent auxent;
415 union internal_auxent *psubaux;
416 bfd_vma bitpos = 0, bitsize = 0;
417
418 sym = symbols->syms[symbols->symno];
419
420 if (! bfd_coff_get_syment (abfd, sym, &syment))
421 {
37cc8ec1
AM
422 non_fatal (_("bfd_coff_get_syment failed: %s"),
423 bfd_errmsg (bfd_get_error ()));
252b5132
RH
424 return DEBUG_TYPE_NULL;
425 }
426
427 this_coff_symno = symbols->coff_symno;
428
429 ++symbols->symno;
430 symbols->coff_symno += 1 + syment.n_numaux;
431
432 if (syment.n_numaux == 0)
433 psubaux = NULL;
434 else
435 {
436 if (! bfd_coff_get_auxent (abfd, sym, 0, &auxent))
437 {
37cc8ec1
AM
438 non_fatal (_("bfd_coff_get_auxent failed: %s"),
439 bfd_errmsg (bfd_get_error ()));
252b5132
RH
440 return DEBUG_TYPE_NULL;
441 }
442 psubaux = &auxent;
443 }
444
445 switch (syment.n_sclass)
446 {
447 case C_MOS:
448 case C_MOU:
449 bitpos = 8 * bfd_asymbol_value (sym);
450 bitsize = 0;
451 break;
452
453 case C_FIELD:
454 bitpos = bfd_asymbol_value (sym);
455 bitsize = auxent.x_sym.x_misc.x_lnsz.x_size;
456 break;
457
458 case C_EOS:
459 done = true;
460 break;
461 }
462
463 if (! done)
464 {
465 debug_type ftype;
466 debug_field f;
467
468 ftype = parse_coff_type (abfd, symbols, types, this_coff_symno,
469 syment.n_type, psubaux, true, dhandle);
470 f = debug_make_field (dhandle, bfd_asymbol_name (sym), ftype,
471 bitpos, bitsize, DEBUG_VISIBILITY_PUBLIC);
472 if (f == DEBUG_FIELD_NULL)
473 return DEBUG_TYPE_NULL;
474
475 if (count + 1 >= alloc)
476 {
477 alloc += 10;
478 fields = ((debug_field *)
479 xrealloc (fields, alloc * sizeof *fields));
480 }
481
482 fields[count] = f;
483 ++count;
484 }
485 }
486
487 fields[count] = DEBUG_FIELD_NULL;
488
489 return debug_make_struct_type (dhandle, ntype == T_STRUCT,
490 pauxent->x_sym.x_misc.x_lnsz.x_size,
491 fields);
492}
493
494/* Parse an enum type. */
495
496static debug_type
497parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle)
498 bfd *abfd;
499 struct coff_symbols *symbols;
b4c96d0d 500 struct coff_types *types ATTRIBUTE_UNUSED;
252b5132
RH
501 union internal_auxent *pauxent;
502 PTR dhandle;
503{
504 long symend;
505 int alloc;
506 const char **names;
507 bfd_signed_vma *vals;
508 int count;
509 boolean done;
510
511 symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
512
513 alloc = 10;
514 names = (const char **) xmalloc (alloc * sizeof *names);
515 vals = (bfd_signed_vma *) xmalloc (alloc * sizeof *vals);
516 count = 0;
517
518 done = false;
519 while (! done
520 && symbols->coff_symno < symend
521 && symbols->symno < symbols->symcount)
522 {
523 asymbol *sym;
524 struct internal_syment syment;
525
526 sym = symbols->syms[symbols->symno];
527
528 if (! bfd_coff_get_syment (abfd, sym, &syment))
529 {
37cc8ec1
AM
530 non_fatal (_("bfd_coff_get_syment failed: %s"),
531 bfd_errmsg (bfd_get_error ()));
252b5132
RH
532 return DEBUG_TYPE_NULL;
533 }
534
535 ++symbols->symno;
536 symbols->coff_symno += 1 + syment.n_numaux;
537
538 switch (syment.n_sclass)
539 {
540 case C_MOE:
541 if (count + 1 >= alloc)
542 {
543 alloc += 10;
544 names = ((const char **)
545 xrealloc (names, alloc * sizeof *names));
546 vals = ((bfd_signed_vma *)
547 xrealloc (vals, alloc * sizeof *vals));
548 }
549
550 names[count] = bfd_asymbol_name (sym);
551 vals[count] = bfd_asymbol_value (sym);
552 ++count;
553 break;
554
555 case C_EOS:
556 done = true;
557 break;
558 }
559 }
560
561 names[count] = NULL;
562
563 return debug_make_enum_type (dhandle, names, vals);
564}
565
566/* Handle a single COFF symbol. */
567
568static boolean
569parse_coff_symbol (abfd, types, sym, coff_symno, psyment, dhandle, type,
570 within_function)
b4c96d0d 571 bfd *abfd ATTRIBUTE_UNUSED;
252b5132
RH
572 struct coff_types *types;
573 asymbol *sym;
574 long coff_symno;
575 struct internal_syment *psyment;
576 PTR dhandle;
577 debug_type type;
578 boolean within_function;
579{
580 switch (psyment->n_sclass)
581 {
582 case C_NULL:
583 break;
584
585 case C_AUTO:
586 if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
587 DEBUG_LOCAL, bfd_asymbol_value (sym)))
588 return false;
589 break;
590
591 case C_EXT:
592 if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
593 DEBUG_GLOBAL, bfd_asymbol_value (sym)))
594 return false;
595 break;
596
597 case C_STAT:
598 if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
599 (within_function
600 ? DEBUG_LOCAL_STATIC
601 : DEBUG_STATIC),
602 bfd_asymbol_value (sym)))
603 return false;
604 break;
605
606 case C_REG:
607 /* FIXME: We may need to convert the register number. */
608 if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
609 DEBUG_REGISTER, bfd_asymbol_value (sym)))
610 return false;
611 break;
612
613 case C_LABEL:
614 break;
615
616 case C_ARG:
617 if (! debug_record_parameter (dhandle, bfd_asymbol_name (sym), type,
618 DEBUG_PARM_STACK, bfd_asymbol_value (sym)))
619 return false;
620 break;
621
622 case C_REGPARM:
623 /* FIXME: We may need to convert the register number. */
624 if (! debug_record_parameter (dhandle, bfd_asymbol_name (sym), type,
625 DEBUG_PARM_REG, bfd_asymbol_value (sym)))
626 return false;
627 break;
628
629 case C_TPDEF:
630 type = debug_name_type (dhandle, bfd_asymbol_name (sym), type);
631 if (type == DEBUG_TYPE_NULL)
632 return false;
633 break;
634
635 case C_STRTAG:
636 case C_UNTAG:
637 case C_ENTAG:
638 {
639 debug_type *slot;
640
641 type = debug_tag_type (dhandle, bfd_asymbol_name (sym), type);
642 if (type == DEBUG_TYPE_NULL)
643 return false;
644
645 /* Store the named type into the slot, so that references get
646 the name. */
647 slot = coff_get_slot (types, coff_symno);
648 *slot = type;
649 }
650 break;
651
652 default:
653 break;
654 }
655
656 return true;
657}
658
659/* This is the main routine. It looks through all the symbols and
660 handles them. */
661
662boolean
663parse_coff (abfd, syms, symcount, dhandle)
664 bfd *abfd;
665 asymbol **syms;
666 long symcount;
667 PTR dhandle;
668{
669 struct coff_symbols symbols;
670 struct coff_types types;
671 int i;
672 long next_c_file;
673 const char *fnname;
674 int fnclass;
675 int fntype;
676 bfd_vma fnend;
677 alent *linenos;
678 boolean within_function;
679 long this_coff_symno;
680
681 symbols.syms = syms;
682 symbols.symcount = symcount;
683 symbols.symno = 0;
684 symbols.coff_symno = 0;
685
686 types.slots = NULL;
687 for (i = 0; i <= T_MAX; i++)
688 types.basic[i] = DEBUG_TYPE_NULL;
689
690 next_c_file = -1;
691 fnname = NULL;
692 fnclass = 0;
693 fntype = 0;
694 fnend = 0;
695 linenos = NULL;
696 within_function = false;
697
698 while (symbols.symno < symcount)
699 {
700 asymbol *sym;
701 const char *name;
702 struct internal_syment syment;
703 union internal_auxent auxent;
704 union internal_auxent *paux;
705 debug_type type;
706
707 sym = syms[symbols.symno];
708
709 if (! bfd_coff_get_syment (abfd, sym, &syment))
710 {
37cc8ec1
AM
711 non_fatal (_("bfd_coff_get_syment failed: %s"),
712 bfd_errmsg (bfd_get_error ()));
252b5132
RH
713 return false;
714 }
715
716 name = bfd_asymbol_name (sym);
717
718 this_coff_symno = symbols.coff_symno;
719
720 ++symbols.symno;
721 symbols.coff_symno += 1 + syment.n_numaux;
722
723 /* We only worry about the first auxent, because that is the
724 only one which is relevant for debugging information. */
725 if (syment.n_numaux == 0)
726 paux = NULL;
727 else
728 {
729 if (! bfd_coff_get_auxent (abfd, sym, 0, &auxent))
730 {
37cc8ec1
AM
731 non_fatal (_("bfd_coff_get_auxent failed: %s"),
732 bfd_errmsg (bfd_get_error ()));
252b5132
RH
733 return false;
734 }
735 paux = &auxent;
736 }
737
738 if (this_coff_symno == next_c_file && syment.n_sclass != C_FILE)
739 {
740 /* The last C_FILE symbol points to the first external
741 symbol. */
742 if (! debug_set_filename (dhandle, "*globals*"))
743 return false;
744 }
745
746 switch (syment.n_sclass)
747 {
748 case C_EFCN:
749 case C_EXTDEF:
750 case C_ULABEL:
751 case C_USTATIC:
752 case C_LINE:
753 case C_ALIAS:
754 case C_HIDDEN:
755 /* Just ignore these classes. */
756 break;
757
758 case C_FILE:
759 next_c_file = syment.n_value;
760 if (! debug_set_filename (dhandle, name))
761 return false;
762 break;
763
764 case C_STAT:
765 /* Ignore static symbols with a type of T_NULL. These
766 represent section entries. */
767 if (syment.n_type == T_NULL)
768 break;
769 /* Fall through. */
770 case C_EXT:
771 if (ISFCN (syment.n_type))
772 {
773 fnname = name;
774 fnclass = syment.n_sclass;
775 fntype = syment.n_type;
776 if (syment.n_numaux > 0)
777 fnend = bfd_asymbol_value (sym) + auxent.x_sym.x_misc.x_fsize;
778 else
779 fnend = 0;
780 linenos = BFD_SEND (abfd, _get_lineno, (abfd, sym));
781 break;
782 }
783 type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
784 syment.n_type, paux, true, dhandle);
785 if (type == DEBUG_TYPE_NULL)
786 return false;
787 if (! parse_coff_symbol (abfd, &types, sym, this_coff_symno, &syment,
788 dhandle, type, within_function))
789 return false;
790 break;
791
792 case C_FCN:
793 if (strcmp (name, ".bf") == 0)
794 {
795 if (fnname == NULL)
796 {
37cc8ec1
AM
797 non_fatal (_("%ld: .bf without preceding function"),
798 this_coff_symno);
252b5132
RH
799 return false;
800 }
801
802 type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
803 DECREF (fntype), paux, false, dhandle);
804 if (type == DEBUG_TYPE_NULL)
805 return false;
806
807 if (! debug_record_function (dhandle, fnname, type,
808 fnclass == C_EXT,
809 bfd_asymbol_value (sym)))
810 return false;
811
812 if (linenos != NULL)
813 {
814 int base;
815 bfd_vma addr;
816
817 if (syment.n_numaux == 0)
818 base = 0;
819 else
820 base = auxent.x_sym.x_misc.x_lnsz.x_lnno - 1;
821
822 addr = bfd_get_section_vma (abfd, bfd_get_section (sym));
823
824 ++linenos;
825
826 while (linenos->line_number != 0)
827 {
828 if (! debug_record_line (dhandle,
829 linenos->line_number + base,
830 linenos->u.offset + addr))
831 return false;
832 ++linenos;
833 }
834 }
835
836 fnname = NULL;
837 linenos = NULL;
838 fnclass = 0;
839 fntype = 0;
840
841 within_function = true;
842 }
843 else if (strcmp (name, ".ef") == 0)
844 {
845 if (! within_function)
846 {
37cc8ec1 847 non_fatal (_("%ld: unexpected .ef\n"), this_coff_symno);
252b5132
RH
848 return false;
849 }
850
851 if (bfd_asymbol_value (sym) > fnend)
852 fnend = bfd_asymbol_value (sym);
853 if (! debug_end_function (dhandle, fnend))
854 return false;
855
856 fnend = 0;
857 within_function = false;
858 }
859 break;
860
861 case C_BLOCK:
862 if (strcmp (name, ".bb") == 0)
863 {
864 if (! debug_start_block (dhandle, bfd_asymbol_value (sym)))
865 return false;
866 }
867 else if (strcmp (name, ".eb") == 0)
868 {
869 if (! debug_end_block (dhandle, bfd_asymbol_value (sym)))
870 return false;
871 }
872 break;
873
874 default:
875 type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
876 syment.n_type, paux, true, dhandle);
877 if (type == DEBUG_TYPE_NULL)
878 return false;
879 if (! parse_coff_symbol (abfd, &types, sym, this_coff_symno, &syment,
880 dhandle, type, within_function))
881 return false;
882 break;
883 }
884 }
885
886 return true;
887}
This page took 0.069229 seconds and 4 git commands to generate.