From Eli Zaretskii <eliz@gnu.org>:
[deliverable/binutils-gdb.git] / binutils / rdcoff.c
1 /* stabs.c -- Parse COFF debugging information
2 Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc.
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
48 struct 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
67 struct 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
78 struct coff_types
79 {
80 /* Slots. */
81 struct coff_slots *slots;
82 /* Basic types. */
83 debug_type basic[T_MAX + 1];
84 };
85
86 static debug_type *coff_get_slot PARAMS ((struct coff_types *, int));
87 static debug_type parse_coff_type
88 PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, long, int,
89 union internal_auxent *, boolean, PTR));
90 static debug_type parse_coff_base_type
91 PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, long, int,
92 union internal_auxent *, PTR));
93 static debug_type parse_coff_struct_type
94 PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, int,
95 union internal_auxent *, PTR));
96 static debug_type parse_coff_enum_type
97 PARAMS ((bfd *, struct coff_symbols *, struct coff_types *,
98 union internal_auxent *, PTR));
99 static 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
105 static debug_type *
106 coff_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
136 static debug_type
137 parse_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 {
204 fprintf (stderr, _("%s: parse_coff_type: Bad type code 0x%x\n"),
205 program_name, ntype);
206 return DEBUG_TYPE_NULL;
207 }
208
209 return type;
210 }
211
212 if (pauxent != NULL && pauxent->x_sym.x_tagndx.l > 0)
213 {
214 debug_type *slot;
215
216 /* This is a reference to an existing type. FIXME: gdb checks
217 that the class is not C_STRTAG, nor C_UNTAG, nor C_ENTAG. */
218 slot = coff_get_slot (types, pauxent->x_sym.x_tagndx.l);
219 if (*slot != DEBUG_TYPE_NULL)
220 return *slot;
221 else
222 return debug_make_indirect_type (dhandle, slot, (const char *) NULL);
223 }
224
225 /* If the aux entry has already been used for something, useaux will
226 have been set to false, indicating that parse_coff_base_type
227 should not use it. We need to do it this way, rather than simply
228 passing pauxent as NULL, because we need to be able handle
229 multiple array dimensions while still discarding pauxent after
230 having handled all of them. */
231 if (! useaux)
232 pauxent = NULL;
233
234 return parse_coff_base_type (abfd, symbols, types, coff_symno, ntype,
235 pauxent, dhandle);
236 }
237
238 /* Parse a basic COFF type in NTYPE. */
239
240 static debug_type
241 parse_coff_base_type (abfd, symbols, types, coff_symno, ntype, pauxent,
242 dhandle)
243 bfd *abfd;
244 struct coff_symbols *symbols;
245 struct coff_types *types;
246 long coff_symno;
247 int ntype;
248 union internal_auxent *pauxent;
249 PTR dhandle;
250 {
251 debug_type ret;
252 boolean set_basic;
253 const char *name;
254 debug_type *slot;
255
256 if (ntype >= 0
257 && ntype <= T_MAX
258 && types->basic[ntype] != DEBUG_TYPE_NULL)
259 return types->basic[ntype];
260
261 set_basic = true;
262 name = NULL;
263
264 switch (ntype)
265 {
266 default:
267 ret = debug_make_void_type (dhandle);
268 break;
269
270 case T_NULL:
271 case T_VOID:
272 ret = debug_make_void_type (dhandle);
273 name = "void";
274 break;
275
276 case T_CHAR:
277 ret = debug_make_int_type (dhandle, 1, false);
278 name = "char";
279 break;
280
281 case T_SHORT:
282 ret = debug_make_int_type (dhandle, 2, false);
283 name = "short";
284 break;
285
286 case T_INT:
287 /* FIXME: Perhaps the size should depend upon the architecture. */
288 ret = debug_make_int_type (dhandle, 4, false);
289 name = "int";
290 break;
291
292 case T_LONG:
293 ret = debug_make_int_type (dhandle, 4, false);
294 name = "long";
295 break;
296
297 case T_FLOAT:
298 ret = debug_make_float_type (dhandle, 4);
299 name = "float";
300 break;
301
302 case T_DOUBLE:
303 ret = debug_make_float_type (dhandle, 8);
304 name = "double";
305 break;
306
307 case T_LNGDBL:
308 ret = debug_make_float_type (dhandle, 12);
309 name = "long double";
310 break;
311
312 case T_UCHAR:
313 ret = debug_make_int_type (dhandle, 1, true);
314 name = "unsigned char";
315 break;
316
317 case T_USHORT:
318 ret = debug_make_int_type (dhandle, 2, true);
319 name = "unsigned short";
320 break;
321
322 case T_UINT:
323 ret = debug_make_int_type (dhandle, 4, true);
324 name = "unsigned int";
325 break;
326
327 case T_ULONG:
328 ret = debug_make_int_type (dhandle, 4, true);
329 name = "unsigned long";
330 break;
331
332 case T_STRUCT:
333 if (pauxent == NULL)
334 ret = debug_make_struct_type (dhandle, true, 0,
335 (debug_field *) NULL);
336 else
337 ret = parse_coff_struct_type (abfd, symbols, types, ntype, pauxent,
338 dhandle);
339
340 slot = coff_get_slot (types, coff_symno);
341 *slot = ret;
342
343 set_basic = false;
344 break;
345
346 case T_UNION:
347 if (pauxent == NULL)
348 ret = debug_make_struct_type (dhandle, false, 0, (debug_field *) NULL);
349 else
350 ret = parse_coff_struct_type (abfd, symbols, types, ntype, pauxent,
351 dhandle);
352
353 slot = coff_get_slot (types, coff_symno);
354 *slot = ret;
355
356 set_basic = false;
357 break;
358
359 case T_ENUM:
360 if (pauxent == NULL)
361 ret = debug_make_enum_type (dhandle, (const char **) NULL,
362 (bfd_signed_vma *) NULL);
363 else
364 ret = parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle);
365
366 slot = coff_get_slot (types, coff_symno);
367 *slot = ret;
368
369 set_basic = false;
370 break;
371 }
372
373 if (name != NULL)
374 ret = debug_name_type (dhandle, name, ret);
375
376 if (set_basic
377 && ntype >= 0
378 && ntype <= T_MAX)
379 types->basic[ntype] = ret;
380
381 return ret;
382 }
383
384 /* Parse a struct type. */
385
386 static debug_type
387 parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, dhandle)
388 bfd *abfd;
389 struct coff_symbols *symbols;
390 struct coff_types *types;
391 int ntype;
392 union internal_auxent *pauxent;
393 PTR dhandle;
394 {
395 long symend;
396 int alloc;
397 debug_field *fields;
398 int count;
399 boolean done;
400
401 symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
402
403 alloc = 10;
404 fields = (debug_field *) xmalloc (alloc * sizeof *fields);
405 count = 0;
406
407 done = false;
408 while (! done
409 && symbols->coff_symno < symend
410 && symbols->symno < symbols->symcount)
411 {
412 asymbol *sym;
413 long this_coff_symno;
414 struct internal_syment syment;
415 union internal_auxent auxent;
416 union internal_auxent *psubaux;
417 bfd_vma bitpos = 0, bitsize = 0;
418
419 sym = symbols->syms[symbols->symno];
420
421 if (! bfd_coff_get_syment (abfd, sym, &syment))
422 {
423 fprintf (stderr, _("%s: bfd_coff_get_syment failed: %s\n"),
424 program_name, bfd_errmsg (bfd_get_error ()));
425 return DEBUG_TYPE_NULL;
426 }
427
428 this_coff_symno = symbols->coff_symno;
429
430 ++symbols->symno;
431 symbols->coff_symno += 1 + syment.n_numaux;
432
433 if (syment.n_numaux == 0)
434 psubaux = NULL;
435 else
436 {
437 if (! bfd_coff_get_auxent (abfd, sym, 0, &auxent))
438 {
439 fprintf (stderr, _("%s: bfd_coff_get_auxent failed: %s\n"),
440 program_name, bfd_errmsg (bfd_get_error ()));
441 return DEBUG_TYPE_NULL;
442 }
443 psubaux = &auxent;
444 }
445
446 switch (syment.n_sclass)
447 {
448 case C_MOS:
449 case C_MOU:
450 bitpos = 8 * bfd_asymbol_value (sym);
451 bitsize = 0;
452 break;
453
454 case C_FIELD:
455 bitpos = bfd_asymbol_value (sym);
456 bitsize = auxent.x_sym.x_misc.x_lnsz.x_size;
457 break;
458
459 case C_EOS:
460 done = true;
461 break;
462 }
463
464 if (! done)
465 {
466 debug_type ftype;
467 debug_field f;
468
469 ftype = parse_coff_type (abfd, symbols, types, this_coff_symno,
470 syment.n_type, psubaux, true, dhandle);
471 f = debug_make_field (dhandle, bfd_asymbol_name (sym), ftype,
472 bitpos, bitsize, DEBUG_VISIBILITY_PUBLIC);
473 if (f == DEBUG_FIELD_NULL)
474 return DEBUG_TYPE_NULL;
475
476 if (count + 1 >= alloc)
477 {
478 alloc += 10;
479 fields = ((debug_field *)
480 xrealloc (fields, alloc * sizeof *fields));
481 }
482
483 fields[count] = f;
484 ++count;
485 }
486 }
487
488 fields[count] = DEBUG_FIELD_NULL;
489
490 return debug_make_struct_type (dhandle, ntype == T_STRUCT,
491 pauxent->x_sym.x_misc.x_lnsz.x_size,
492 fields);
493 }
494
495 /* Parse an enum type. */
496
497 static debug_type
498 parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle)
499 bfd *abfd;
500 struct coff_symbols *symbols;
501 struct coff_types *types ATTRIBUTE_UNUSED;
502 union internal_auxent *pauxent;
503 PTR dhandle;
504 {
505 long symend;
506 int alloc;
507 const char **names;
508 bfd_signed_vma *vals;
509 int count;
510 boolean done;
511
512 symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
513
514 alloc = 10;
515 names = (const char **) xmalloc (alloc * sizeof *names);
516 vals = (bfd_signed_vma *) xmalloc (alloc * sizeof *vals);
517 count = 0;
518
519 done = false;
520 while (! done
521 && symbols->coff_symno < symend
522 && symbols->symno < symbols->symcount)
523 {
524 asymbol *sym;
525 struct internal_syment syment;
526
527 sym = symbols->syms[symbols->symno];
528
529 if (! bfd_coff_get_syment (abfd, sym, &syment))
530 {
531 fprintf (stderr, _("%s: bfd_coff_get_syment failed: %s\n"),
532 program_name, bfd_errmsg (bfd_get_error ()));
533 return DEBUG_TYPE_NULL;
534 }
535
536 ++symbols->symno;
537 symbols->coff_symno += 1 + syment.n_numaux;
538
539 switch (syment.n_sclass)
540 {
541 case C_MOE:
542 if (count + 1 >= alloc)
543 {
544 alloc += 10;
545 names = ((const char **)
546 xrealloc (names, alloc * sizeof *names));
547 vals = ((bfd_signed_vma *)
548 xrealloc (vals, alloc * sizeof *vals));
549 }
550
551 names[count] = bfd_asymbol_name (sym);
552 vals[count] = bfd_asymbol_value (sym);
553 ++count;
554 break;
555
556 case C_EOS:
557 done = true;
558 break;
559 }
560 }
561
562 names[count] = NULL;
563
564 return debug_make_enum_type (dhandle, names, vals);
565 }
566
567 /* Handle a single COFF symbol. */
568
569 static boolean
570 parse_coff_symbol (abfd, types, sym, coff_symno, psyment, dhandle, type,
571 within_function)
572 bfd *abfd ATTRIBUTE_UNUSED;
573 struct coff_types *types;
574 asymbol *sym;
575 long coff_symno;
576 struct internal_syment *psyment;
577 PTR dhandle;
578 debug_type type;
579 boolean within_function;
580 {
581 switch (psyment->n_sclass)
582 {
583 case C_NULL:
584 break;
585
586 case C_AUTO:
587 if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
588 DEBUG_LOCAL, bfd_asymbol_value (sym)))
589 return false;
590 break;
591
592 case C_EXT:
593 if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
594 DEBUG_GLOBAL, bfd_asymbol_value (sym)))
595 return false;
596 break;
597
598 case C_STAT:
599 if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
600 (within_function
601 ? DEBUG_LOCAL_STATIC
602 : DEBUG_STATIC),
603 bfd_asymbol_value (sym)))
604 return false;
605 break;
606
607 case C_REG:
608 /* FIXME: We may need to convert the register number. */
609 if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
610 DEBUG_REGISTER, bfd_asymbol_value (sym)))
611 return false;
612 break;
613
614 case C_LABEL:
615 break;
616
617 case C_ARG:
618 if (! debug_record_parameter (dhandle, bfd_asymbol_name (sym), type,
619 DEBUG_PARM_STACK, bfd_asymbol_value (sym)))
620 return false;
621 break;
622
623 case C_REGPARM:
624 /* FIXME: We may need to convert the register number. */
625 if (! debug_record_parameter (dhandle, bfd_asymbol_name (sym), type,
626 DEBUG_PARM_REG, bfd_asymbol_value (sym)))
627 return false;
628 break;
629
630 case C_TPDEF:
631 type = debug_name_type (dhandle, bfd_asymbol_name (sym), type);
632 if (type == DEBUG_TYPE_NULL)
633 return false;
634 break;
635
636 case C_STRTAG:
637 case C_UNTAG:
638 case C_ENTAG:
639 {
640 debug_type *slot;
641
642 type = debug_tag_type (dhandle, bfd_asymbol_name (sym), type);
643 if (type == DEBUG_TYPE_NULL)
644 return false;
645
646 /* Store the named type into the slot, so that references get
647 the name. */
648 slot = coff_get_slot (types, coff_symno);
649 *slot = type;
650 }
651 break;
652
653 default:
654 break;
655 }
656
657 return true;
658 }
659
660 /* This is the main routine. It looks through all the symbols and
661 handles them. */
662
663 boolean
664 parse_coff (abfd, syms, symcount, dhandle)
665 bfd *abfd;
666 asymbol **syms;
667 long symcount;
668 PTR dhandle;
669 {
670 struct coff_symbols symbols;
671 struct coff_types types;
672 int i;
673 long next_c_file;
674 const char *fnname;
675 int fnclass;
676 int fntype;
677 bfd_vma fnend;
678 alent *linenos;
679 boolean within_function;
680 long this_coff_symno;
681
682 symbols.syms = syms;
683 symbols.symcount = symcount;
684 symbols.symno = 0;
685 symbols.coff_symno = 0;
686
687 types.slots = NULL;
688 for (i = 0; i <= T_MAX; i++)
689 types.basic[i] = DEBUG_TYPE_NULL;
690
691 next_c_file = -1;
692 fnname = NULL;
693 fnclass = 0;
694 fntype = 0;
695 fnend = 0;
696 linenos = NULL;
697 within_function = false;
698
699 while (symbols.symno < symcount)
700 {
701 asymbol *sym;
702 const char *name;
703 struct internal_syment syment;
704 union internal_auxent auxent;
705 union internal_auxent *paux;
706 debug_type type;
707
708 sym = syms[symbols.symno];
709
710 if (! bfd_coff_get_syment (abfd, sym, &syment))
711 {
712 fprintf (stderr, _("%s: bfd_coff_get_syment failed: %s\n"),
713 program_name, bfd_errmsg (bfd_get_error ()));
714 return false;
715 }
716
717 name = bfd_asymbol_name (sym);
718
719 this_coff_symno = symbols.coff_symno;
720
721 ++symbols.symno;
722 symbols.coff_symno += 1 + syment.n_numaux;
723
724 /* We only worry about the first auxent, because that is the
725 only one which is relevant for debugging information. */
726 if (syment.n_numaux == 0)
727 paux = NULL;
728 else
729 {
730 if (! bfd_coff_get_auxent (abfd, sym, 0, &auxent))
731 {
732 fprintf (stderr, _("%s: bfd_coff_get_auxent failed: %s\n"),
733 program_name, bfd_errmsg (bfd_get_error ()));
734 return false;
735 }
736 paux = &auxent;
737 }
738
739 if (this_coff_symno == next_c_file && syment.n_sclass != C_FILE)
740 {
741 /* The last C_FILE symbol points to the first external
742 symbol. */
743 if (! debug_set_filename (dhandle, "*globals*"))
744 return false;
745 }
746
747 switch (syment.n_sclass)
748 {
749 case C_EFCN:
750 case C_EXTDEF:
751 case C_ULABEL:
752 case C_USTATIC:
753 case C_LINE:
754 case C_ALIAS:
755 case C_HIDDEN:
756 /* Just ignore these classes. */
757 break;
758
759 case C_FILE:
760 next_c_file = syment.n_value;
761 if (! debug_set_filename (dhandle, name))
762 return false;
763 break;
764
765 case C_STAT:
766 /* Ignore static symbols with a type of T_NULL. These
767 represent section entries. */
768 if (syment.n_type == T_NULL)
769 break;
770 /* Fall through. */
771 case C_EXT:
772 if (ISFCN (syment.n_type))
773 {
774 fnname = name;
775 fnclass = syment.n_sclass;
776 fntype = syment.n_type;
777 if (syment.n_numaux > 0)
778 fnend = bfd_asymbol_value (sym) + auxent.x_sym.x_misc.x_fsize;
779 else
780 fnend = 0;
781 linenos = BFD_SEND (abfd, _get_lineno, (abfd, sym));
782 break;
783 }
784 type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
785 syment.n_type, paux, true, dhandle);
786 if (type == DEBUG_TYPE_NULL)
787 return false;
788 if (! parse_coff_symbol (abfd, &types, sym, this_coff_symno, &syment,
789 dhandle, type, within_function))
790 return false;
791 break;
792
793 case C_FCN:
794 if (strcmp (name, ".bf") == 0)
795 {
796 if (fnname == NULL)
797 {
798 fprintf (stderr, _("%s: %ld: .bf without preceding function\n"),
799 program_name, this_coff_symno);
800 return false;
801 }
802
803 type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
804 DECREF (fntype), paux, false, dhandle);
805 if (type == DEBUG_TYPE_NULL)
806 return false;
807
808 if (! debug_record_function (dhandle, fnname, type,
809 fnclass == C_EXT,
810 bfd_asymbol_value (sym)))
811 return false;
812
813 if (linenos != NULL)
814 {
815 int base;
816 bfd_vma addr;
817
818 if (syment.n_numaux == 0)
819 base = 0;
820 else
821 base = auxent.x_sym.x_misc.x_lnsz.x_lnno - 1;
822
823 addr = bfd_get_section_vma (abfd, bfd_get_section (sym));
824
825 ++linenos;
826
827 while (linenos->line_number != 0)
828 {
829 if (! debug_record_line (dhandle,
830 linenos->line_number + base,
831 linenos->u.offset + addr))
832 return false;
833 ++linenos;
834 }
835 }
836
837 fnname = NULL;
838 linenos = NULL;
839 fnclass = 0;
840 fntype = 0;
841
842 within_function = true;
843 }
844 else if (strcmp (name, ".ef") == 0)
845 {
846 if (! within_function)
847 {
848 fprintf (stderr, _("%s: %ld: unexpected .ef\n"),
849 program_name, this_coff_symno);
850 return false;
851 }
852
853 if (bfd_asymbol_value (sym) > fnend)
854 fnend = bfd_asymbol_value (sym);
855 if (! debug_end_function (dhandle, fnend))
856 return false;
857
858 fnend = 0;
859 within_function = false;
860 }
861 break;
862
863 case C_BLOCK:
864 if (strcmp (name, ".bb") == 0)
865 {
866 if (! debug_start_block (dhandle, bfd_asymbol_value (sym)))
867 return false;
868 }
869 else if (strcmp (name, ".eb") == 0)
870 {
871 if (! debug_end_block (dhandle, bfd_asymbol_value (sym)))
872 return false;
873 }
874 break;
875
876 default:
877 type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
878 syment.n_type, paux, true, dhandle);
879 if (type == DEBUG_TYPE_NULL)
880 return false;
881 if (! parse_coff_symbol (abfd, &types, sym, this_coff_symno, &syment,
882 dhandle, type, within_function))
883 return false;
884 break;
885 }
886 }
887
888 return true;
889 }
This page took 0.048084 seconds and 4 git commands to generate.