2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions
8 From the dwarf2read.c header:
9 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
10 Inc. with support from Florida State University (under contract
11 with the Ada Joint Program Office), and Silicon Graphics, Inc.
12 Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
13 based on Fred Fish's (Cygnus Support) implementation of DWARF 1
14 support in dwarfread.c
16 This file is part of BFD.
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 3 of the License, or (at
21 your option) any later version.
23 This program is distributed in the hope that it will be useful, but
24 WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 General Public License for more details.
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
31 MA 02110-1301, USA. */
35 #include "libiberty.h"
38 #include "elf/dwarf2.h"
40 /* The data in the .debug_line statement prologue looks like this. */
45 unsigned short version
;
46 bfd_vma prologue_length
;
47 unsigned char minimum_instruction_length
;
48 unsigned char default_is_stmt
;
50 unsigned char line_range
;
51 unsigned char opcode_base
;
52 unsigned char *standard_opcode_lengths
;
55 /* Attributes have a name and a value. */
59 enum dwarf_attribute name
;
64 struct dwarf_block
*blk
;
71 /* Blocks are a bunch of untyped bytes. */
78 struct loadable_section
86 /* A list of all previously read comp_units. */
87 struct comp_unit
*all_comp_units
;
89 /* The next unread compilation unit within the .debug_info section.
90 Zero indicates that the .debug_info section has not been loaded
94 /* Pointer to the end of the .debug_info section memory buffer. */
95 bfd_byte
*info_ptr_end
;
97 /* Pointer to the bfd, section and address of the beginning of the
98 section. The bfd might be different than expected because of
99 gnu_debuglink sections. */
102 bfd_byte
*sec_info_ptr
;
104 /* Pointer to the symbol table. */
107 /* Pointer to the .debug_abbrev section loaded into memory. */
108 bfd_byte
*dwarf_abbrev_buffer
;
110 /* Length of the loaded .debug_abbrev section. */
111 unsigned long dwarf_abbrev_size
;
113 /* Buffer for decode_line_info. */
114 bfd_byte
*dwarf_line_buffer
;
116 /* Length of the loaded .debug_line section. */
117 unsigned long dwarf_line_size
;
119 /* Pointer to the .debug_str section loaded into memory. */
120 bfd_byte
*dwarf_str_buffer
;
122 /* Length of the loaded .debug_str section. */
123 unsigned long dwarf_str_size
;
125 /* Pointer to the .debug_ranges section loaded into memory. */
126 bfd_byte
*dwarf_ranges_buffer
;
128 /* Length of the loaded .debug_ranges section. */
129 unsigned long dwarf_ranges_size
;
131 /* If the most recent call to bfd_find_nearest_line was given an
132 address in an inlined function, preserve a pointer into the
133 calling chain for subsequent calls to bfd_find_inliner_info to
135 struct funcinfo
*inliner_chain
;
137 /* Number of loadable sections. */
138 unsigned int loadable_section_count
;
140 /* Array of loadable sections. */
141 struct loadable_section
*loadable_sections
;
151 /* A minimal decoding of DWARF2 compilation units. We only decode
152 what's needed to get to the line number information. */
156 /* Chain the previously read compilation units. */
157 struct comp_unit
*next_unit
;
159 /* Keep the bfd convenient (for memory allocation). */
162 /* The lowest and highest addresses contained in this compilation
163 unit as specified in the compilation unit header. */
164 struct arange arange
;
166 /* The DW_AT_name attribute (for error messages). */
169 /* The abbrev hash table. */
170 struct abbrev_info
**abbrevs
;
172 /* Note that an error was found by comp_unit_find_nearest_line. */
175 /* The DW_AT_comp_dir attribute. */
178 /* TRUE if there is a line number table associated with this comp. unit. */
181 /* Pointer to the current comp_unit so that we can find a given entry
183 bfd_byte
*info_ptr_unit
;
185 /* The offset into .debug_line of the line number table. */
186 unsigned long line_offset
;
188 /* Pointer to the first child die for the comp unit. */
189 bfd_byte
*first_child_die_ptr
;
191 /* The end of the comp unit. */
194 /* The decoded line number, NULL if not yet decoded. */
195 struct line_info_table
*line_table
;
197 /* A list of the functions found in this comp. unit. */
198 struct funcinfo
*function_table
;
200 /* A list of the variables found in this comp. unit. */
201 struct varinfo
*variable_table
;
203 /* Pointer to dwarf2_debug structure. */
204 struct dwarf2_debug
*stash
;
206 /* Address size for this unit - from unit header. */
207 unsigned char addr_size
;
209 /* Offset size for this unit - from unit header. */
210 unsigned char offset_size
;
212 /* Base address for this unit - from DW_AT_low_pc attribute of
213 DW_TAG_compile_unit DIE */
214 bfd_vma base_address
;
217 /* This data structure holds the information of an abbrev. */
220 unsigned int number
; /* Number identifying abbrev. */
221 enum dwarf_tag tag
; /* DWARF tag. */
222 int has_children
; /* Boolean. */
223 unsigned int num_attrs
; /* Number of attributes. */
224 struct attr_abbrev
*attrs
; /* An array of attribute descriptions. */
225 struct abbrev_info
*next
; /* Next in chain. */
230 enum dwarf_attribute name
;
231 enum dwarf_form form
;
234 #ifndef ABBREV_HASH_SIZE
235 #define ABBREV_HASH_SIZE 121
237 #ifndef ATTR_ALLOC_CHUNK
238 #define ATTR_ALLOC_CHUNK 4
242 The following function up to the END VERBATIM mark are
243 copied directly from dwarf2read.c. */
245 /* Read dwarf information from a buffer. */
248 read_1_byte (bfd
*abfd ATTRIBUTE_UNUSED
, bfd_byte
*buf
)
250 return bfd_get_8 (abfd
, buf
);
254 read_1_signed_byte (bfd
*abfd ATTRIBUTE_UNUSED
, bfd_byte
*buf
)
256 return bfd_get_signed_8 (abfd
, buf
);
260 read_2_bytes (bfd
*abfd
, bfd_byte
*buf
)
262 return bfd_get_16 (abfd
, buf
);
266 read_4_bytes (bfd
*abfd
, bfd_byte
*buf
)
268 return bfd_get_32 (abfd
, buf
);
272 read_8_bytes (bfd
*abfd
, bfd_byte
*buf
)
274 return bfd_get_64 (abfd
, buf
);
278 read_n_bytes (bfd
*abfd ATTRIBUTE_UNUSED
,
280 unsigned int size ATTRIBUTE_UNUSED
)
282 /* If the size of a host char is 8 bits, we can return a pointer
283 to the buffer, otherwise we have to copy the data to a buffer
284 allocated on the temporary obstack. */
289 read_string (bfd
*abfd ATTRIBUTE_UNUSED
,
291 unsigned int *bytes_read_ptr
)
293 /* Return a pointer to the embedded string. */
294 char *str
= (char *) buf
;
301 *bytes_read_ptr
= strlen (str
) + 1;
306 read_indirect_string (struct comp_unit
* unit
,
308 unsigned int *bytes_read_ptr
)
311 struct dwarf2_debug
*stash
= unit
->stash
;
314 if (unit
->offset_size
== 4)
315 offset
= read_4_bytes (unit
->abfd
, buf
);
317 offset
= read_8_bytes (unit
->abfd
, buf
);
318 *bytes_read_ptr
= unit
->offset_size
;
320 if (! stash
->dwarf_str_buffer
)
323 bfd
*abfd
= unit
->abfd
;
326 msec
= bfd_get_section_by_name (abfd
, ".debug_str");
329 (*_bfd_error_handler
)
330 (_("Dwarf Error: Can't find .debug_str section."));
331 bfd_set_error (bfd_error_bad_value
);
335 sz
= msec
->rawsize
? msec
->rawsize
: msec
->size
;
336 stash
->dwarf_str_size
= sz
;
337 stash
->dwarf_str_buffer
= bfd_alloc (abfd
, sz
);
338 if (! stash
->dwarf_str_buffer
)
341 if (! bfd_get_section_contents (abfd
, msec
, stash
->dwarf_str_buffer
,
346 if (offset
>= stash
->dwarf_str_size
)
348 (*_bfd_error_handler
) (_("Dwarf Error: DW_FORM_strp offset (%lu) greater than or equal to .debug_str size (%lu)."),
349 (unsigned long) offset
, stash
->dwarf_str_size
);
350 bfd_set_error (bfd_error_bad_value
);
354 str
= (char *) stash
->dwarf_str_buffer
+ offset
;
363 read_address (struct comp_unit
*unit
, bfd_byte
*buf
)
365 int signed_vma
= get_elf_backend_data (unit
->abfd
)->sign_extend_vma
;
369 switch (unit
->addr_size
)
372 return bfd_get_signed_64 (unit
->abfd
, buf
);
374 return bfd_get_signed_32 (unit
->abfd
, buf
);
376 return bfd_get_signed_16 (unit
->abfd
, buf
);
383 switch (unit
->addr_size
)
386 return bfd_get_64 (unit
->abfd
, buf
);
388 return bfd_get_32 (unit
->abfd
, buf
);
390 return bfd_get_16 (unit
->abfd
, buf
);
397 /* Lookup an abbrev_info structure in the abbrev hash table. */
399 static struct abbrev_info
*
400 lookup_abbrev (unsigned int number
, struct abbrev_info
**abbrevs
)
402 unsigned int hash_number
;
403 struct abbrev_info
*abbrev
;
405 hash_number
= number
% ABBREV_HASH_SIZE
;
406 abbrev
= abbrevs
[hash_number
];
410 if (abbrev
->number
== number
)
413 abbrev
= abbrev
->next
;
419 /* In DWARF version 2, the description of the debugging information is
420 stored in a separate .debug_abbrev section. Before we read any
421 dies from a section we read in all abbreviations and install them
424 static struct abbrev_info
**
425 read_abbrevs (bfd
*abfd
, bfd_uint64_t offset
, struct dwarf2_debug
*stash
)
427 struct abbrev_info
**abbrevs
;
428 bfd_byte
*abbrev_ptr
;
429 struct abbrev_info
*cur_abbrev
;
430 unsigned int abbrev_number
, bytes_read
, abbrev_name
;
431 unsigned int abbrev_form
, hash_number
;
434 if (! stash
->dwarf_abbrev_buffer
)
438 msec
= bfd_get_section_by_name (abfd
, ".debug_abbrev");
441 (*_bfd_error_handler
) (_("Dwarf Error: Can't find .debug_abbrev section."));
442 bfd_set_error (bfd_error_bad_value
);
446 stash
->dwarf_abbrev_size
= msec
->size
;
447 stash
->dwarf_abbrev_buffer
448 = bfd_simple_get_relocated_section_contents (abfd
, msec
, NULL
,
450 if (! stash
->dwarf_abbrev_buffer
)
454 if (offset
>= stash
->dwarf_abbrev_size
)
456 (*_bfd_error_handler
) (_("Dwarf Error: Abbrev offset (%lu) greater than or equal to .debug_abbrev size (%lu)."),
457 (unsigned long) offset
, stash
->dwarf_abbrev_size
);
458 bfd_set_error (bfd_error_bad_value
);
462 amt
= sizeof (struct abbrev_info
*) * ABBREV_HASH_SIZE
;
463 abbrevs
= bfd_zalloc (abfd
, amt
);
465 abbrev_ptr
= stash
->dwarf_abbrev_buffer
+ offset
;
466 abbrev_number
= read_unsigned_leb128 (abfd
, abbrev_ptr
, &bytes_read
);
467 abbrev_ptr
+= bytes_read
;
469 /* Loop until we reach an abbrev number of 0. */
470 while (abbrev_number
)
472 amt
= sizeof (struct abbrev_info
);
473 cur_abbrev
= bfd_zalloc (abfd
, amt
);
475 /* Read in abbrev header. */
476 cur_abbrev
->number
= abbrev_number
;
477 cur_abbrev
->tag
= (enum dwarf_tag
)
478 read_unsigned_leb128 (abfd
, abbrev_ptr
, &bytes_read
);
479 abbrev_ptr
+= bytes_read
;
480 cur_abbrev
->has_children
= read_1_byte (abfd
, abbrev_ptr
);
483 /* Now read in declarations. */
484 abbrev_name
= read_unsigned_leb128 (abfd
, abbrev_ptr
, &bytes_read
);
485 abbrev_ptr
+= bytes_read
;
486 abbrev_form
= read_unsigned_leb128 (abfd
, abbrev_ptr
, &bytes_read
);
487 abbrev_ptr
+= bytes_read
;
491 if ((cur_abbrev
->num_attrs
% ATTR_ALLOC_CHUNK
) == 0)
493 struct attr_abbrev
*tmp
;
495 amt
= cur_abbrev
->num_attrs
+ ATTR_ALLOC_CHUNK
;
496 amt
*= sizeof (struct attr_abbrev
);
497 tmp
= bfd_realloc (cur_abbrev
->attrs
, amt
);
502 for (i
= 0; i
< ABBREV_HASH_SIZE
; i
++)
504 struct abbrev_info
*abbrev
= abbrevs
[i
];
508 free (abbrev
->attrs
);
509 abbrev
= abbrev
->next
;
514 cur_abbrev
->attrs
= tmp
;
517 cur_abbrev
->attrs
[cur_abbrev
->num_attrs
].name
518 = (enum dwarf_attribute
) abbrev_name
;
519 cur_abbrev
->attrs
[cur_abbrev
->num_attrs
++].form
520 = (enum dwarf_form
) abbrev_form
;
521 abbrev_name
= read_unsigned_leb128 (abfd
, abbrev_ptr
, &bytes_read
);
522 abbrev_ptr
+= bytes_read
;
523 abbrev_form
= read_unsigned_leb128 (abfd
, abbrev_ptr
, &bytes_read
);
524 abbrev_ptr
+= bytes_read
;
527 hash_number
= abbrev_number
% ABBREV_HASH_SIZE
;
528 cur_abbrev
->next
= abbrevs
[hash_number
];
529 abbrevs
[hash_number
] = cur_abbrev
;
531 /* Get next abbreviation.
532 Under Irix6 the abbreviations for a compilation unit are not
533 always properly terminated with an abbrev number of 0.
534 Exit loop if we encounter an abbreviation which we have
535 already read (which means we are about to read the abbreviations
536 for the next compile unit) or if the end of the abbreviation
538 if ((unsigned int) (abbrev_ptr
- stash
->dwarf_abbrev_buffer
)
539 >= stash
->dwarf_abbrev_size
)
541 abbrev_number
= read_unsigned_leb128 (abfd
, abbrev_ptr
, &bytes_read
);
542 abbrev_ptr
+= bytes_read
;
543 if (lookup_abbrev (abbrev_number
,abbrevs
) != NULL
)
550 /* Read an attribute value described by an attribute form. */
553 read_attribute_value (struct attribute
*attr
,
555 struct comp_unit
*unit
,
558 bfd
*abfd
= unit
->abfd
;
559 unsigned int bytes_read
;
560 struct dwarf_block
*blk
;
563 attr
->form
= (enum dwarf_form
) form
;
568 /* FIXME: DWARF3 draft says DW_FORM_ref_addr is offset_size. */
569 case DW_FORM_ref_addr
:
570 attr
->u
.val
= read_address (unit
, info_ptr
);
571 info_ptr
+= unit
->addr_size
;
574 amt
= sizeof (struct dwarf_block
);
575 blk
= bfd_alloc (abfd
, amt
);
576 blk
->size
= read_2_bytes (abfd
, info_ptr
);
578 blk
->data
= read_n_bytes (abfd
, info_ptr
, blk
->size
);
579 info_ptr
+= blk
->size
;
583 amt
= sizeof (struct dwarf_block
);
584 blk
= bfd_alloc (abfd
, amt
);
585 blk
->size
= read_4_bytes (abfd
, info_ptr
);
587 blk
->data
= read_n_bytes (abfd
, info_ptr
, blk
->size
);
588 info_ptr
+= blk
->size
;
592 attr
->u
.val
= read_2_bytes (abfd
, info_ptr
);
596 attr
->u
.val
= read_4_bytes (abfd
, info_ptr
);
600 attr
->u
.val
= read_8_bytes (abfd
, info_ptr
);
604 attr
->u
.str
= read_string (abfd
, info_ptr
, &bytes_read
);
605 info_ptr
+= bytes_read
;
608 attr
->u
.str
= read_indirect_string (unit
, info_ptr
, &bytes_read
);
609 info_ptr
+= bytes_read
;
612 amt
= sizeof (struct dwarf_block
);
613 blk
= bfd_alloc (abfd
, amt
);
614 blk
->size
= read_unsigned_leb128 (abfd
, info_ptr
, &bytes_read
);
615 info_ptr
+= bytes_read
;
616 blk
->data
= read_n_bytes (abfd
, info_ptr
, blk
->size
);
617 info_ptr
+= blk
->size
;
621 amt
= sizeof (struct dwarf_block
);
622 blk
= bfd_alloc (abfd
, amt
);
623 blk
->size
= read_1_byte (abfd
, info_ptr
);
625 blk
->data
= read_n_bytes (abfd
, info_ptr
, blk
->size
);
626 info_ptr
+= blk
->size
;
630 attr
->u
.val
= read_1_byte (abfd
, info_ptr
);
634 attr
->u
.val
= read_1_byte (abfd
, info_ptr
);
638 attr
->u
.sval
= read_signed_leb128 (abfd
, info_ptr
, &bytes_read
);
639 info_ptr
+= bytes_read
;
642 attr
->u
.val
= read_unsigned_leb128 (abfd
, info_ptr
, &bytes_read
);
643 info_ptr
+= bytes_read
;
646 attr
->u
.val
= read_1_byte (abfd
, info_ptr
);
650 attr
->u
.val
= read_2_bytes (abfd
, info_ptr
);
654 attr
->u
.val
= read_4_bytes (abfd
, info_ptr
);
658 attr
->u
.val
= read_8_bytes (abfd
, info_ptr
);
661 case DW_FORM_ref_udata
:
662 attr
->u
.val
= read_unsigned_leb128 (abfd
, info_ptr
, &bytes_read
);
663 info_ptr
+= bytes_read
;
665 case DW_FORM_indirect
:
666 form
= read_unsigned_leb128 (abfd
, info_ptr
, &bytes_read
);
667 info_ptr
+= bytes_read
;
668 info_ptr
= read_attribute_value (attr
, form
, unit
, info_ptr
);
671 (*_bfd_error_handler
) (_("Dwarf Error: Invalid or unhandled FORM value: %u."),
673 bfd_set_error (bfd_error_bad_value
);
678 /* Read an attribute described by an abbreviated attribute. */
681 read_attribute (struct attribute
*attr
,
682 struct attr_abbrev
*abbrev
,
683 struct comp_unit
*unit
,
686 attr
->name
= abbrev
->name
;
687 info_ptr
= read_attribute_value (attr
, abbrev
->form
, unit
, info_ptr
);
691 /* Source line information table routines. */
693 #define FILE_ALLOC_CHUNK 5
694 #define DIR_ALLOC_CHUNK 5
698 struct line_info
* prev_line
;
703 int end_sequence
; /* End of (sequential) code sequence. */
714 struct line_info_table
717 unsigned int num_files
;
718 unsigned int num_dirs
;
721 struct fileinfo
* files
;
722 struct line_info
* last_line
; /* largest VMA */
723 struct line_info
* lcl_head
; /* local head; used in 'add_line_info' */
726 /* Remember some information about each function. If the function is
727 inlined (DW_TAG_inlined_subroutine) it may have two additional
728 attributes, DW_AT_call_file and DW_AT_call_line, which specify the
729 source code location where this function was inlined. */
733 struct funcinfo
*prev_func
; /* Pointer to previous function in list of all functions */
734 struct funcinfo
*caller_func
; /* Pointer to function one scope higher */
735 char *caller_file
; /* Source location file name where caller_func inlines this func */
736 int caller_line
; /* Source location line number where caller_func inlines this func */
737 char *file
; /* Source location file name */
738 int line
; /* Source location line number */
741 struct arange arange
;
742 asection
*sec
; /* Where the symbol is defined */
747 /* Pointer to previous variable in list of all variables */
748 struct varinfo
*prev_var
;
749 /* Source location file name */
751 /* Source location line number */
756 /* Where the symbol is defined */
758 /* Is this a stack variable? */
759 unsigned int stack
: 1;
762 /* Return TRUE if NEW_LINE should sort after LINE. */
764 static inline bfd_boolean
765 new_line_sorts_after (struct line_info
*new_line
, struct line_info
*line
)
767 return (new_line
->address
> line
->address
768 || (new_line
->address
== line
->address
769 && new_line
->end_sequence
< line
->end_sequence
));
773 /* Adds a new entry to the line_info list in the line_info_table, ensuring
774 that the list is sorted. Note that the line_info list is sorted from
775 highest to lowest VMA (with possible duplicates); that is,
776 line_info->prev_line always accesses an equal or smaller VMA. */
779 add_line_info (struct line_info_table
*table
,
786 bfd_size_type amt
= sizeof (struct line_info
);
787 struct line_info
* info
= bfd_alloc (table
->abfd
, amt
);
789 /* Set member data of 'info'. */
790 info
->address
= address
;
792 info
->column
= column
;
793 info
->end_sequence
= end_sequence
;
795 if (filename
&& filename
[0])
797 info
->filename
= bfd_alloc (table
->abfd
, strlen (filename
) + 1);
799 strcpy (info
->filename
, filename
);
802 info
->filename
= NULL
;
804 /* Find the correct location for 'info'. Normally we will receive
805 new line_info data 1) in order and 2) with increasing VMAs.
806 However some compilers break the rules (cf. decode_line_info) and
807 so we include some heuristics for quickly finding the correct
808 location for 'info'. In particular, these heuristics optimize for
809 the common case in which the VMA sequence that we receive is a
810 list of locally sorted VMAs such as
811 p...z a...j (where a < j < p < z)
813 Note: table->lcl_head is used to head an *actual* or *possible*
814 sequence within the list (such as a...j) that is not directly
815 headed by table->last_line
817 Note: we may receive duplicate entries from 'decode_line_info'. */
819 if (!table
->last_line
820 || new_line_sorts_after (info
, table
->last_line
))
822 /* Normal case: add 'info' to the beginning of the list */
823 info
->prev_line
= table
->last_line
;
824 table
->last_line
= info
;
826 /* lcl_head: initialize to head a *possible* sequence at the end. */
827 if (!table
->lcl_head
)
828 table
->lcl_head
= info
;
830 else if (!new_line_sorts_after (info
, table
->lcl_head
)
831 && (!table
->lcl_head
->prev_line
832 || new_line_sorts_after (info
, table
->lcl_head
->prev_line
)))
834 /* Abnormal but easy: lcl_head is the head of 'info'. */
835 info
->prev_line
= table
->lcl_head
->prev_line
;
836 table
->lcl_head
->prev_line
= info
;
840 /* Abnormal and hard: Neither 'last_line' nor 'lcl_head' are valid
841 heads for 'info'. Reset 'lcl_head'. */
842 struct line_info
* li2
= table
->last_line
; /* always non-NULL */
843 struct line_info
* li1
= li2
->prev_line
;
847 if (!new_line_sorts_after (info
, li2
)
848 && new_line_sorts_after (info
, li1
))
851 li2
= li1
; /* always non-NULL */
852 li1
= li1
->prev_line
;
854 table
->lcl_head
= li2
;
855 info
->prev_line
= table
->lcl_head
->prev_line
;
856 table
->lcl_head
->prev_line
= info
;
860 /* Extract a fully qualified filename from a line info table.
861 The returned string has been malloc'ed and it is the caller's
862 responsibility to free it. */
865 concat_filename (struct line_info_table
*table
, unsigned int file
)
869 if (file
- 1 >= table
->num_files
)
871 /* FILE == 0 means unknown. */
873 (*_bfd_error_handler
)
874 (_("Dwarf Error: mangled line number section (bad file number)."));
875 return strdup ("<unknown>");
878 filename
= table
->files
[file
- 1].name
;
880 if (!IS_ABSOLUTE_PATH (filename
))
882 char *dirname
= NULL
;
883 char *subdirname
= NULL
;
887 if (table
->files
[file
- 1].dir
)
888 subdirname
= table
->dirs
[table
->files
[file
- 1].dir
- 1];
890 if (!subdirname
|| !IS_ABSOLUTE_PATH (subdirname
))
891 dirname
= table
->comp_dir
;
895 dirname
= subdirname
;
900 return strdup (filename
);
902 len
= strlen (dirname
) + strlen (filename
) + 2;
906 len
+= strlen (subdirname
) + 1;
907 name
= bfd_malloc (len
);
909 sprintf (name
, "%s/%s/%s", dirname
, subdirname
, filename
);
913 name
= bfd_malloc (len
);
915 sprintf (name
, "%s/%s", dirname
, filename
);
921 return strdup (filename
);
925 arange_add (bfd
*abfd
, struct arange
*first_arange
, bfd_vma low_pc
, bfd_vma high_pc
)
927 struct arange
*arange
;
929 /* If the first arange is empty, use it. */
930 if (first_arange
->high
== 0)
932 first_arange
->low
= low_pc
;
933 first_arange
->high
= high_pc
;
937 /* Next see if we can cheaply extend an existing range. */
938 arange
= first_arange
;
941 if (low_pc
== arange
->high
)
943 arange
->high
= high_pc
;
946 if (high_pc
== arange
->low
)
948 arange
->low
= low_pc
;
951 arange
= arange
->next
;
955 /* Need to allocate a new arange and insert it into the arange list.
956 Order isn't significant, so just insert after the first arange. */
957 arange
= bfd_zalloc (abfd
, sizeof (*arange
));
958 arange
->low
= low_pc
;
959 arange
->high
= high_pc
;
960 arange
->next
= first_arange
->next
;
961 first_arange
->next
= arange
;
964 /* Decode the line number information for UNIT. */
966 static struct line_info_table
*
967 decode_line_info (struct comp_unit
*unit
, struct dwarf2_debug
*stash
)
969 bfd
*abfd
= unit
->abfd
;
970 struct line_info_table
* table
;
974 unsigned int i
, bytes_read
, offset_size
;
975 char *cur_file
, *cur_dir
;
976 unsigned char op_code
, extended_op
, adj_opcode
;
979 if (! stash
->dwarf_line_buffer
)
983 msec
= bfd_get_section_by_name (abfd
, ".debug_line");
986 (*_bfd_error_handler
) (_("Dwarf Error: Can't find .debug_line section."));
987 bfd_set_error (bfd_error_bad_value
);
991 stash
->dwarf_line_size
= msec
->size
;
992 stash
->dwarf_line_buffer
993 = bfd_simple_get_relocated_section_contents (abfd
, msec
, NULL
,
995 if (! stash
->dwarf_line_buffer
)
999 /* It is possible to get a bad value for the line_offset. Validate
1000 it here so that we won't get a segfault below. */
1001 if (unit
->line_offset
>= stash
->dwarf_line_size
)
1003 (*_bfd_error_handler
) (_("Dwarf Error: Line offset (%lu) greater than or equal to .debug_line size (%lu)."),
1004 unit
->line_offset
, stash
->dwarf_line_size
);
1005 bfd_set_error (bfd_error_bad_value
);
1009 amt
= sizeof (struct line_info_table
);
1010 table
= bfd_alloc (abfd
, amt
);
1012 table
->comp_dir
= unit
->comp_dir
;
1014 table
->num_files
= 0;
1015 table
->files
= NULL
;
1017 table
->num_dirs
= 0;
1020 table
->files
= NULL
;
1021 table
->last_line
= NULL
;
1022 table
->lcl_head
= NULL
;
1024 line_ptr
= stash
->dwarf_line_buffer
+ unit
->line_offset
;
1026 /* Read in the prologue. */
1027 lh
.total_length
= read_4_bytes (abfd
, line_ptr
);
1030 if (lh
.total_length
== 0xffffffff)
1032 lh
.total_length
= read_8_bytes (abfd
, line_ptr
);
1036 else if (lh
.total_length
== 0 && unit
->addr_size
== 8)
1038 /* Handle (non-standard) 64-bit DWARF2 formats. */
1039 lh
.total_length
= read_4_bytes (abfd
, line_ptr
);
1043 line_end
= line_ptr
+ lh
.total_length
;
1044 lh
.version
= read_2_bytes (abfd
, line_ptr
);
1046 if (offset_size
== 4)
1047 lh
.prologue_length
= read_4_bytes (abfd
, line_ptr
);
1049 lh
.prologue_length
= read_8_bytes (abfd
, line_ptr
);
1050 line_ptr
+= offset_size
;
1051 lh
.minimum_instruction_length
= read_1_byte (abfd
, line_ptr
);
1053 lh
.default_is_stmt
= read_1_byte (abfd
, line_ptr
);
1055 lh
.line_base
= read_1_signed_byte (abfd
, line_ptr
);
1057 lh
.line_range
= read_1_byte (abfd
, line_ptr
);
1059 lh
.opcode_base
= read_1_byte (abfd
, line_ptr
);
1061 amt
= lh
.opcode_base
* sizeof (unsigned char);
1062 lh
.standard_opcode_lengths
= bfd_alloc (abfd
, amt
);
1064 lh
.standard_opcode_lengths
[0] = 1;
1066 for (i
= 1; i
< lh
.opcode_base
; ++i
)
1068 lh
.standard_opcode_lengths
[i
] = read_1_byte (abfd
, line_ptr
);
1072 /* Read directory table. */
1073 while ((cur_dir
= read_string (abfd
, line_ptr
, &bytes_read
)) != NULL
)
1075 line_ptr
+= bytes_read
;
1077 if ((table
->num_dirs
% DIR_ALLOC_CHUNK
) == 0)
1081 amt
= table
->num_dirs
+ DIR_ALLOC_CHUNK
;
1082 amt
*= sizeof (char *);
1084 tmp
= bfd_realloc (table
->dirs
, amt
);
1093 table
->dirs
[table
->num_dirs
++] = cur_dir
;
1096 line_ptr
+= bytes_read
;
1098 /* Read file name table. */
1099 while ((cur_file
= read_string (abfd
, line_ptr
, &bytes_read
)) != NULL
)
1101 line_ptr
+= bytes_read
;
1103 if ((table
->num_files
% FILE_ALLOC_CHUNK
) == 0)
1105 struct fileinfo
*tmp
;
1107 amt
= table
->num_files
+ FILE_ALLOC_CHUNK
;
1108 amt
*= sizeof (struct fileinfo
);
1110 tmp
= bfd_realloc (table
->files
, amt
);
1113 free (table
->files
);
1120 table
->files
[table
->num_files
].name
= cur_file
;
1121 table
->files
[table
->num_files
].dir
=
1122 read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1123 line_ptr
+= bytes_read
;
1124 table
->files
[table
->num_files
].time
=
1125 read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1126 line_ptr
+= bytes_read
;
1127 table
->files
[table
->num_files
].size
=
1128 read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1129 line_ptr
+= bytes_read
;
1133 line_ptr
+= bytes_read
;
1135 /* Read the statement sequences until there's nothing left. */
1136 while (line_ptr
< line_end
)
1138 /* State machine registers. */
1139 bfd_vma address
= 0;
1140 char * filename
= table
->num_files
? concat_filename (table
, 1) : NULL
;
1141 unsigned int line
= 1;
1142 unsigned int column
= 0;
1143 int is_stmt
= lh
.default_is_stmt
;
1144 int end_sequence
= 0;
1145 /* eraxxon@alumni.rice.edu: Against the DWARF2 specs, some
1146 compilers generate address sequences that are wildly out of
1147 order using DW_LNE_set_address (e.g. Intel C++ 6.0 compiler
1148 for ia64-Linux). Thus, to determine the low and high
1149 address, we must compare on every DW_LNS_copy, etc. */
1150 bfd_vma low_pc
= (bfd_vma
) -1;
1151 bfd_vma high_pc
= 0;
1153 /* Decode the table. */
1154 while (! end_sequence
)
1156 op_code
= read_1_byte (abfd
, line_ptr
);
1159 if (op_code
>= lh
.opcode_base
)
1161 /* Special operand. */
1162 adj_opcode
= op_code
- lh
.opcode_base
;
1163 address
+= (adj_opcode
/ lh
.line_range
)
1164 * lh
.minimum_instruction_length
;
1165 line
+= lh
.line_base
+ (adj_opcode
% lh
.line_range
);
1166 /* Append row to matrix using current values. */
1167 add_line_info (table
, address
, filename
, line
, column
, 0);
1168 if (address
< low_pc
)
1170 if (address
> high_pc
)
1173 else switch (op_code
)
1175 case DW_LNS_extended_op
:
1176 /* Ignore length. */
1178 extended_op
= read_1_byte (abfd
, line_ptr
);
1181 switch (extended_op
)
1183 case DW_LNE_end_sequence
:
1185 add_line_info (table
, address
, filename
, line
, column
,
1187 if (address
< low_pc
)
1189 if (address
> high_pc
)
1191 arange_add (unit
->abfd
, &unit
->arange
, low_pc
, high_pc
);
1193 case DW_LNE_set_address
:
1194 address
= read_address (unit
, line_ptr
);
1195 line_ptr
+= unit
->addr_size
;
1197 case DW_LNE_define_file
:
1198 cur_file
= read_string (abfd
, line_ptr
, &bytes_read
);
1199 line_ptr
+= bytes_read
;
1200 if ((table
->num_files
% FILE_ALLOC_CHUNK
) == 0)
1202 struct fileinfo
*tmp
;
1204 amt
= table
->num_files
+ FILE_ALLOC_CHUNK
;
1205 amt
*= sizeof (struct fileinfo
);
1206 tmp
= bfd_realloc (table
->files
, amt
);
1209 free (table
->files
);
1216 table
->files
[table
->num_files
].name
= cur_file
;
1217 table
->files
[table
->num_files
].dir
=
1218 read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1219 line_ptr
+= bytes_read
;
1220 table
->files
[table
->num_files
].time
=
1221 read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1222 line_ptr
+= bytes_read
;
1223 table
->files
[table
->num_files
].size
=
1224 read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1225 line_ptr
+= bytes_read
;
1229 (*_bfd_error_handler
) (_("Dwarf Error: mangled line number section."));
1230 bfd_set_error (bfd_error_bad_value
);
1232 free (table
->files
);
1238 add_line_info (table
, address
, filename
, line
, column
, 0);
1239 if (address
< low_pc
)
1241 if (address
> high_pc
)
1244 case DW_LNS_advance_pc
:
1245 address
+= lh
.minimum_instruction_length
1246 * read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1247 line_ptr
+= bytes_read
;
1249 case DW_LNS_advance_line
:
1250 line
+= read_signed_leb128 (abfd
, line_ptr
, &bytes_read
);
1251 line_ptr
+= bytes_read
;
1253 case DW_LNS_set_file
:
1257 /* The file and directory tables are 0
1258 based, the references are 1 based. */
1259 file
= read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1260 line_ptr
+= bytes_read
;
1263 filename
= concat_filename (table
, file
);
1266 case DW_LNS_set_column
:
1267 column
= read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1268 line_ptr
+= bytes_read
;
1270 case DW_LNS_negate_stmt
:
1271 is_stmt
= (!is_stmt
);
1273 case DW_LNS_set_basic_block
:
1275 case DW_LNS_const_add_pc
:
1276 address
+= lh
.minimum_instruction_length
1277 * ((255 - lh
.opcode_base
) / lh
.line_range
);
1279 case DW_LNS_fixed_advance_pc
:
1280 address
+= read_2_bytes (abfd
, line_ptr
);
1287 /* Unknown standard opcode, ignore it. */
1288 for (i
= 0; i
< lh
.standard_opcode_lengths
[op_code
]; i
++)
1290 (void) read_unsigned_leb128 (abfd
, line_ptr
, &bytes_read
);
1291 line_ptr
+= bytes_read
;
1304 /* If ADDR is within TABLE set the output parameters and return TRUE,
1305 otherwise return FALSE. The output parameters, FILENAME_PTR and
1306 LINENUMBER_PTR, are pointers to the objects to be filled in. */
1309 lookup_address_in_line_info_table (struct line_info_table
*table
,
1311 struct funcinfo
*function
,
1312 const char **filename_ptr
,
1313 unsigned int *linenumber_ptr
)
1315 /* Note: table->last_line should be a descendingly sorted list. */
1316 struct line_info
* next_line
= table
->last_line
;
1317 struct line_info
* each_line
= NULL
;
1318 *filename_ptr
= NULL
;
1323 each_line
= next_line
->prev_line
;
1325 /* Check for large addresses */
1326 if (addr
> next_line
->address
)
1327 each_line
= NULL
; /* ensure we skip over the normal case */
1329 /* Normal case: search the list; save */
1330 while (each_line
&& next_line
)
1332 /* If we have an address match, save this info. This allows us
1333 to return as good as results as possible for strange debugging
1335 bfd_boolean addr_match
= FALSE
;
1336 if (each_line
->address
<= addr
&& addr
< next_line
->address
)
1340 /* If this line appears to span functions, and addr is in the
1341 later function, return the first line of that function instead
1342 of the last line of the earlier one. This check is for GCC
1343 2.95, which emits the first line number for a function late. */
1345 if (function
!= NULL
)
1348 struct arange
*arange
;
1350 /* Find the lowest address in the function's range list */
1351 lowest_pc
= function
->arange
.low
;
1352 for (arange
= &function
->arange
;
1354 arange
= arange
->next
)
1356 if (function
->arange
.low
< lowest_pc
)
1357 lowest_pc
= function
->arange
.low
;
1359 /* Check for spanning function and set outgoing line info */
1360 if (addr
>= lowest_pc
1361 && each_line
->address
< lowest_pc
1362 && next_line
->address
> lowest_pc
)
1364 *filename_ptr
= next_line
->filename
;
1365 *linenumber_ptr
= next_line
->line
;
1369 *filename_ptr
= each_line
->filename
;
1370 *linenumber_ptr
= each_line
->line
;
1375 *filename_ptr
= each_line
->filename
;
1376 *linenumber_ptr
= each_line
->line
;
1380 if (addr_match
&& !each_line
->end_sequence
)
1381 return TRUE
; /* we have definitely found what we want */
1383 next_line
= each_line
;
1384 each_line
= each_line
->prev_line
;
1387 /* At this point each_line is NULL but next_line is not. If we found
1388 a candidate end-of-sequence point in the loop above, we can return
1389 that (compatibility with a bug in the Intel compiler); otherwise,
1390 assuming that we found the containing function for this address in
1391 this compilation unit, return the first line we have a number for
1392 (compatibility with GCC 2.95). */
1393 if (*filename_ptr
== NULL
&& function
!= NULL
)
1395 *filename_ptr
= next_line
->filename
;
1396 *linenumber_ptr
= next_line
->line
;
1403 /* Read in the .debug_ranges section for future reference */
1406 read_debug_ranges (struct comp_unit
*unit
)
1408 struct dwarf2_debug
*stash
= unit
->stash
;
1409 if (! stash
->dwarf_ranges_buffer
)
1411 bfd
*abfd
= unit
->abfd
;
1414 msec
= bfd_get_section_by_name (abfd
, ".debug_ranges");
1417 (*_bfd_error_handler
) (_("Dwarf Error: Can't find .debug_ranges section."));
1418 bfd_set_error (bfd_error_bad_value
);
1422 stash
->dwarf_ranges_size
= msec
->size
;
1423 stash
->dwarf_ranges_buffer
1424 = bfd_simple_get_relocated_section_contents (abfd
, msec
, NULL
,
1426 if (! stash
->dwarf_ranges_buffer
)
1432 /* Function table functions. */
1434 /* If ADDR is within TABLE, set FUNCTIONNAME_PTR, and return TRUE.
1435 Note that we need to find the function that has the smallest
1436 range that contains ADDR, to handle inlined functions without
1437 depending upon them being ordered in TABLE by increasing range. */
1440 lookup_address_in_function_table (struct comp_unit
*unit
,
1442 struct funcinfo
**function_ptr
,
1443 const char **functionname_ptr
)
1445 struct funcinfo
* each_func
;
1446 struct funcinfo
* best_fit
= NULL
;
1447 struct arange
*arange
;
1449 for (each_func
= unit
->function_table
;
1451 each_func
= each_func
->prev_func
)
1453 for (arange
= &each_func
->arange
;
1455 arange
= arange
->next
)
1457 if (addr
>= arange
->low
&& addr
< arange
->high
)
1460 ((arange
->high
- arange
->low
) < (best_fit
->arange
.high
- best_fit
->arange
.low
)))
1461 best_fit
= each_func
;
1468 *functionname_ptr
= best_fit
->name
;
1469 *function_ptr
= best_fit
;
1478 /* If SYM at ADDR is within function table of UNIT, set FILENAME_PTR
1479 and LINENUMBER_PTR, and return TRUE. */
1482 lookup_symbol_in_function_table (struct comp_unit
*unit
,
1485 const char **filename_ptr
,
1486 unsigned int *linenumber_ptr
)
1488 struct funcinfo
* each_func
;
1489 struct funcinfo
* best_fit
= NULL
;
1490 struct arange
*arange
;
1491 const char *name
= bfd_asymbol_name (sym
);
1492 asection
*sec
= bfd_get_section (sym
);
1494 for (each_func
= unit
->function_table
;
1496 each_func
= each_func
->prev_func
)
1498 for (arange
= &each_func
->arange
;
1500 arange
= arange
->next
)
1502 if ((!each_func
->sec
|| each_func
->sec
== sec
)
1503 && addr
>= arange
->low
1504 && addr
< arange
->high
1506 && strcmp (name
, each_func
->name
) == 0
1508 || ((arange
->high
- arange
->low
)
1509 < (best_fit
->arange
.high
- best_fit
->arange
.low
))))
1510 best_fit
= each_func
;
1516 best_fit
->sec
= sec
;
1517 *filename_ptr
= best_fit
->file
;
1518 *linenumber_ptr
= best_fit
->line
;
1525 /* Variable table functions. */
1527 /* If SYM is within variable table of UNIT, set FILENAME_PTR and
1528 LINENUMBER_PTR, and return TRUE. */
1531 lookup_symbol_in_variable_table (struct comp_unit
*unit
,
1534 const char **filename_ptr
,
1535 unsigned int *linenumber_ptr
)
1537 const char *name
= bfd_asymbol_name (sym
);
1538 asection
*sec
= bfd_get_section (sym
);
1539 struct varinfo
* each
;
1541 for (each
= unit
->variable_table
; each
; each
= each
->prev_var
)
1542 if (each
->stack
== 0
1543 && each
->file
!= NULL
1544 && each
->name
!= NULL
1545 && each
->addr
== addr
1546 && (!each
->sec
|| each
->sec
== sec
)
1547 && strcmp (name
, each
->name
) == 0)
1553 *filename_ptr
= each
->file
;
1554 *linenumber_ptr
= each
->line
;
1562 find_abstract_instance_name (struct comp_unit
*unit
, bfd_uint64_t die_ref
)
1564 bfd
*abfd
= unit
->abfd
;
1566 unsigned int abbrev_number
, bytes_read
, i
;
1567 struct abbrev_info
*abbrev
;
1568 struct attribute attr
;
1571 info_ptr
= unit
->info_ptr_unit
+ die_ref
;
1572 abbrev_number
= read_unsigned_leb128 (abfd
, info_ptr
, &bytes_read
);
1573 info_ptr
+= bytes_read
;
1577 abbrev
= lookup_abbrev (abbrev_number
, unit
->abbrevs
);
1580 (*_bfd_error_handler
) (_("Dwarf Error: Could not find abbrev number %u."),
1582 bfd_set_error (bfd_error_bad_value
);
1586 for (i
= 0; i
< abbrev
->num_attrs
; ++i
)
1588 info_ptr
= read_attribute (&attr
, &abbrev
->attrs
[i
], unit
, info_ptr
);
1592 /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
1596 case DW_AT_specification
:
1597 name
= find_abstract_instance_name (unit
, attr
.u
.val
);
1599 case DW_AT_MIPS_linkage_name
:
1612 read_rangelist (struct comp_unit
*unit
, struct arange
*arange
, bfd_uint64_t offset
)
1614 bfd_byte
*ranges_ptr
;
1615 bfd_vma base_address
= unit
->base_address
;
1617 if (! unit
->stash
->dwarf_ranges_buffer
)
1619 if (! read_debug_ranges (unit
))
1622 ranges_ptr
= unit
->stash
->dwarf_ranges_buffer
+ offset
;
1629 if (unit
->addr_size
== 4)
1631 low_pc
= read_4_bytes (unit
->abfd
, ranges_ptr
);
1633 high_pc
= read_4_bytes (unit
->abfd
, ranges_ptr
);
1638 low_pc
= read_8_bytes (unit
->abfd
, ranges_ptr
);
1640 high_pc
= read_8_bytes (unit
->abfd
, ranges_ptr
);
1643 if (low_pc
== 0 && high_pc
== 0)
1645 if (low_pc
== -1UL && high_pc
!= -1UL)
1646 base_address
= high_pc
;
1648 arange_add (unit
->abfd
, arange
, base_address
+ low_pc
, base_address
+ high_pc
);
1652 /* DWARF2 Compilation unit functions. */
1654 /* Scan over each die in a comp. unit looking for functions to add
1655 to the function table and variables to the variable table. */
1658 scan_unit_for_symbols (struct comp_unit
*unit
)
1660 bfd
*abfd
= unit
->abfd
;
1661 bfd_byte
*info_ptr
= unit
->first_child_die_ptr
;
1662 int nesting_level
= 1;
1663 struct funcinfo
**nested_funcs
;
1664 int nested_funcs_size
;
1666 /* Maintain a stack of in-scope functions and inlined functions, which we
1667 can use to set the caller_func field. */
1668 nested_funcs_size
= 32;
1669 nested_funcs
= bfd_malloc (nested_funcs_size
* sizeof (struct funcinfo
*));
1670 if (nested_funcs
== NULL
)
1672 nested_funcs
[nesting_level
] = 0;
1674 while (nesting_level
)
1676 unsigned int abbrev_number
, bytes_read
, i
;
1677 struct abbrev_info
*abbrev
;
1678 struct attribute attr
;
1679 struct funcinfo
*func
;
1680 struct varinfo
*var
;
1682 bfd_vma high_pc
= 0;
1684 abbrev_number
= read_unsigned_leb128 (abfd
, info_ptr
, &bytes_read
);
1685 info_ptr
+= bytes_read
;
1687 if (! abbrev_number
)
1693 abbrev
= lookup_abbrev (abbrev_number
,unit
->abbrevs
);
1696 (*_bfd_error_handler
) (_("Dwarf Error: Could not find abbrev number %u."),
1698 bfd_set_error (bfd_error_bad_value
);
1699 free (nested_funcs
);
1704 if (abbrev
->tag
== DW_TAG_subprogram
1705 || abbrev
->tag
== DW_TAG_entry_point
1706 || abbrev
->tag
== DW_TAG_inlined_subroutine
)
1708 bfd_size_type amt
= sizeof (struct funcinfo
);
1709 func
= bfd_zalloc (abfd
, amt
);
1710 func
->tag
= abbrev
->tag
;
1711 func
->prev_func
= unit
->function_table
;
1712 unit
->function_table
= func
;
1714 if (func
->tag
== DW_TAG_inlined_subroutine
)
1715 for (i
= nesting_level
- 1; i
>= 1; i
--)
1716 if (nested_funcs
[i
])
1718 func
->caller_func
= nested_funcs
[i
];
1721 nested_funcs
[nesting_level
] = func
;
1726 if (abbrev
->tag
== DW_TAG_variable
)
1728 bfd_size_type amt
= sizeof (struct varinfo
);
1729 var
= bfd_zalloc (abfd
, amt
);
1730 var
->tag
= abbrev
->tag
;
1732 var
->prev_var
= unit
->variable_table
;
1733 unit
->variable_table
= var
;
1736 /* No inline function in scope at this nesting level. */
1737 nested_funcs
[nesting_level
] = 0;
1740 for (i
= 0; i
< abbrev
->num_attrs
; ++i
)
1742 info_ptr
= read_attribute (&attr
, &abbrev
->attrs
[i
], unit
, info_ptr
);
1748 case DW_AT_call_file
:
1749 func
->caller_file
= concat_filename (unit
->line_table
, attr
.u
.val
);
1752 case DW_AT_call_line
:
1753 func
->caller_line
= attr
.u
.val
;
1756 case DW_AT_abstract_origin
:
1757 func
->name
= find_abstract_instance_name (unit
, attr
.u
.val
);
1761 /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
1762 if (func
->name
== NULL
)
1763 func
->name
= attr
.u
.str
;
1766 case DW_AT_MIPS_linkage_name
:
1767 func
->name
= attr
.u
.str
;
1771 low_pc
= attr
.u
.val
;
1775 high_pc
= attr
.u
.val
;
1779 read_rangelist (unit
, &func
->arange
, attr
.u
.val
);
1782 case DW_AT_decl_file
:
1783 func
->file
= concat_filename (unit
->line_table
,
1787 case DW_AT_decl_line
:
1788 func
->line
= attr
.u
.val
;
1800 var
->name
= attr
.u
.str
;
1803 case DW_AT_decl_file
:
1804 var
->file
= concat_filename (unit
->line_table
,
1808 case DW_AT_decl_line
:
1809 var
->line
= attr
.u
.val
;
1812 case DW_AT_external
:
1813 if (attr
.u
.val
!= 0)
1817 case DW_AT_location
:
1821 case DW_FORM_block1
:
1822 case DW_FORM_block2
:
1823 case DW_FORM_block4
:
1824 if (*attr
.u
.blk
->data
== DW_OP_addr
)
1828 /* Verify that DW_OP_addr is the only opcode in the
1829 location, in which case the block size will be 1
1830 plus the address size. */
1831 /* ??? For TLS variables, gcc can emit
1832 DW_OP_addr <addr> DW_OP_GNU_push_tls_address
1833 which we don't handle here yet. */
1834 if (attr
.u
.blk
->size
== unit
->addr_size
+ 1U)
1835 var
->addr
= bfd_get (unit
->addr_size
* 8,
1837 attr
.u
.blk
->data
+ 1);
1852 if (func
&& high_pc
!= 0)
1854 arange_add (unit
->abfd
, &func
->arange
, low_pc
, high_pc
);
1857 if (abbrev
->has_children
)
1861 if (nesting_level
>= nested_funcs_size
)
1863 struct funcinfo
**tmp
;
1865 nested_funcs_size
*= 2;
1866 tmp
= bfd_realloc (nested_funcs
,
1868 * sizeof (struct funcinfo
*)));
1871 free (nested_funcs
);
1876 nested_funcs
[nesting_level
] = 0;
1880 free (nested_funcs
);
1884 /* Parse a DWARF2 compilation unit starting at INFO_PTR. This
1885 includes the compilation unit header that proceeds the DIE's, but
1886 does not include the length field that precedes each compilation
1887 unit header. END_PTR points one past the end of this comp unit.
1888 OFFSET_SIZE is the size of DWARF2 offsets (either 4 or 8 bytes).
1890 This routine does not read the whole compilation unit; only enough
1891 to get to the line number information for the compilation unit. */
1893 static struct comp_unit
*
1894 parse_comp_unit (struct dwarf2_debug
*stash
,
1895 bfd_vma unit_length
,
1896 bfd_byte
*info_ptr_unit
,
1897 unsigned int offset_size
)
1899 struct comp_unit
* unit
;
1900 unsigned int version
;
1901 bfd_uint64_t abbrev_offset
= 0;
1902 unsigned int addr_size
;
1903 struct abbrev_info
** abbrevs
;
1904 unsigned int abbrev_number
, bytes_read
, i
;
1905 struct abbrev_info
*abbrev
;
1906 struct attribute attr
;
1907 bfd_byte
*info_ptr
= stash
->info_ptr
;
1908 bfd_byte
*end_ptr
= info_ptr
+ unit_length
;
1911 bfd_vma high_pc
= 0;
1912 bfd
*abfd
= stash
->bfd
;
1914 version
= read_2_bytes (abfd
, info_ptr
);
1916 BFD_ASSERT (offset_size
== 4 || offset_size
== 8);
1917 if (offset_size
== 4)
1918 abbrev_offset
= read_4_bytes (abfd
, info_ptr
);
1920 abbrev_offset
= read_8_bytes (abfd
, info_ptr
);
1921 info_ptr
+= offset_size
;
1922 addr_size
= read_1_byte (abfd
, info_ptr
);
1927 (*_bfd_error_handler
) (_("Dwarf Error: found dwarf version '%u', this reader only handles version 2 information."), version
);
1928 bfd_set_error (bfd_error_bad_value
);
1932 if (addr_size
> sizeof (bfd_vma
))
1934 (*_bfd_error_handler
) (_("Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."),
1936 (unsigned int) sizeof (bfd_vma
));
1937 bfd_set_error (bfd_error_bad_value
);
1941 if (addr_size
!= 2 && addr_size
!= 4 && addr_size
!= 8)
1943 (*_bfd_error_handler
) ("Dwarf Error: found address size '%u', this reader can only handle address sizes '2', '4' and '8'.", addr_size
);
1944 bfd_set_error (bfd_error_bad_value
);
1948 /* Read the abbrevs for this compilation unit into a table. */
1949 abbrevs
= read_abbrevs (abfd
, abbrev_offset
, stash
);
1953 abbrev_number
= read_unsigned_leb128 (abfd
, info_ptr
, &bytes_read
);
1954 info_ptr
+= bytes_read
;
1955 if (! abbrev_number
)
1957 (*_bfd_error_handler
) (_("Dwarf Error: Bad abbrev number: %u."),
1959 bfd_set_error (bfd_error_bad_value
);
1963 abbrev
= lookup_abbrev (abbrev_number
, abbrevs
);
1966 (*_bfd_error_handler
) (_("Dwarf Error: Could not find abbrev number %u."),
1968 bfd_set_error (bfd_error_bad_value
);
1972 amt
= sizeof (struct comp_unit
);
1973 unit
= bfd_zalloc (abfd
, amt
);
1975 unit
->addr_size
= addr_size
;
1976 unit
->offset_size
= offset_size
;
1977 unit
->abbrevs
= abbrevs
;
1978 unit
->end_ptr
= end_ptr
;
1979 unit
->stash
= stash
;
1980 unit
->info_ptr_unit
= info_ptr_unit
;
1982 for (i
= 0; i
< abbrev
->num_attrs
; ++i
)
1984 info_ptr
= read_attribute (&attr
, &abbrev
->attrs
[i
], unit
, info_ptr
);
1986 /* Store the data if it is of an attribute we want to keep in a
1987 partial symbol table. */
1990 case DW_AT_stmt_list
:
1992 unit
->line_offset
= attr
.u
.val
;
1996 unit
->name
= attr
.u
.str
;
2000 low_pc
= attr
.u
.val
;
2001 /* If the compilation unit DIE has a DW_AT_low_pc attribute,
2002 this is the base address to use when reading location
2003 lists or range lists. */
2004 unit
->base_address
= low_pc
;
2008 high_pc
= attr
.u
.val
;
2012 read_rangelist (unit
, &unit
->arange
, attr
.u
.val
);
2015 case DW_AT_comp_dir
:
2017 char *comp_dir
= attr
.u
.str
;
2020 /* Irix 6.2 native cc prepends <machine>.: to the compilation
2021 directory, get rid of it. */
2022 char *cp
= strchr (comp_dir
, ':');
2024 if (cp
&& cp
!= comp_dir
&& cp
[-1] == '.' && cp
[1] == '/')
2027 unit
->comp_dir
= comp_dir
;
2037 arange_add (unit
->abfd
, &unit
->arange
, low_pc
, high_pc
);
2040 unit
->first_child_die_ptr
= info_ptr
;
2044 /* Return TRUE if UNIT may contain the address given by ADDR. When
2045 there are functions written entirely with inline asm statements, the
2046 range info in the compilation unit header may not be correct. We
2047 need to consult the line info table to see if a compilation unit
2048 really contains the given address. */
2051 comp_unit_contains_address (struct comp_unit
*unit
, bfd_vma addr
)
2053 struct arange
*arange
;
2058 arange
= &unit
->arange
;
2061 if (addr
>= arange
->low
&& addr
< arange
->high
)
2063 arange
= arange
->next
;
2070 /* If UNIT contains ADDR, set the output parameters to the values for
2071 the line containing ADDR. The output parameters, FILENAME_PTR,
2072 FUNCTIONNAME_PTR, and LINENUMBER_PTR, are pointers to the objects
2075 Return TRUE if UNIT contains ADDR, and no errors were encountered;
2079 comp_unit_find_nearest_line (struct comp_unit
*unit
,
2081 const char **filename_ptr
,
2082 const char **functionname_ptr
,
2083 unsigned int *linenumber_ptr
,
2084 struct dwarf2_debug
*stash
)
2088 struct funcinfo
*function
;
2093 if (! unit
->line_table
)
2095 if (! unit
->stmtlist
)
2101 unit
->line_table
= decode_line_info (unit
, stash
);
2103 if (! unit
->line_table
)
2109 if (unit
->first_child_die_ptr
< unit
->end_ptr
2110 && ! scan_unit_for_symbols (unit
))
2118 func_p
= lookup_address_in_function_table (unit
, addr
,
2119 &function
, functionname_ptr
);
2120 if (func_p
&& (function
->tag
== DW_TAG_inlined_subroutine
))
2121 stash
->inliner_chain
= function
;
2122 line_p
= lookup_address_in_line_info_table (unit
->line_table
, addr
,
2123 function
, filename_ptr
,
2125 return line_p
|| func_p
;
2128 /* If UNIT contains SYM at ADDR, set the output parameters to the
2129 values for the line containing SYM. The output parameters,
2130 FILENAME_PTR, and LINENUMBER_PTR, are pointers to the objects to be
2133 Return TRUE if UNIT contains SYM, and no errors were encountered;
2137 comp_unit_find_line (struct comp_unit
*unit
,
2140 const char **filename_ptr
,
2141 unsigned int *linenumber_ptr
,
2142 struct dwarf2_debug
*stash
)
2147 if (! unit
->line_table
)
2149 if (! unit
->stmtlist
)
2155 unit
->line_table
= decode_line_info (unit
, stash
);
2157 if (! unit
->line_table
)
2163 if (unit
->first_child_die_ptr
< unit
->end_ptr
2164 && ! scan_unit_for_symbols (unit
))
2171 if (sym
->flags
& BSF_FUNCTION
)
2172 return lookup_symbol_in_function_table (unit
, sym
, addr
,
2176 return lookup_symbol_in_variable_table (unit
, sym
, addr
,
2181 /* Locate a section in a BFD containing debugging info. The search starts
2182 from the section after AFTER_SEC, or from the first section in the BFD if
2183 AFTER_SEC is NULL. The search works by examining the names of the
2184 sections. There are two permissiable names. The first is .debug_info.
2185 This is the standard DWARF2 name. The second is a prefix .gnu.linkonce.wi.
2186 This is a variation on the .debug_info section which has a checksum
2187 describing the contents appended onto the name. This allows the linker to
2188 identify and discard duplicate debugging sections for different
2189 compilation units. */
2190 #define DWARF2_DEBUG_INFO ".debug_info"
2191 #define GNU_LINKONCE_INFO ".gnu.linkonce.wi."
2194 find_debug_info (bfd
*abfd
, asection
*after_sec
)
2198 msec
= after_sec
!= NULL
? after_sec
->next
: abfd
->sections
;
2202 if (strcmp (msec
->name
, DWARF2_DEBUG_INFO
) == 0)
2205 if (CONST_STRNEQ (msec
->name
, GNU_LINKONCE_INFO
))
2214 /* Unset vmas for loadable sections in STASH. */
2217 unset_sections (struct dwarf2_debug
*stash
)
2220 struct loadable_section
*p
;
2222 i
= stash
->loadable_section_count
;
2223 p
= stash
->loadable_sections
;
2224 for (; i
> 0; i
--, p
++)
2225 p
->section
->vma
= 0;
2228 /* Set unique vmas for loadable sections in ABFD and save vmas in
2229 STASH for unset_sections. */
2232 place_sections (bfd
*abfd
, struct dwarf2_debug
*stash
)
2234 struct loadable_section
*p
;
2237 if (stash
->loadable_section_count
!= 0)
2239 i
= stash
->loadable_section_count
;
2240 p
= stash
->loadable_sections
;
2241 for (; i
> 0; i
--, p
++)
2242 p
->section
->vma
= p
->adj_vma
;
2247 bfd_vma last_vma
= 0;
2249 struct loadable_section
*p
;
2252 for (sect
= abfd
->sections
; sect
!= NULL
; sect
= sect
->next
)
2256 if (sect
->vma
!= 0 || (sect
->flags
& SEC_LOAD
) == 0)
2259 sz
= sect
->rawsize
? sect
->rawsize
: sect
->size
;
2266 amt
= i
* sizeof (struct loadable_section
);
2267 p
= (struct loadable_section
*) bfd_zalloc (abfd
, amt
);
2271 stash
->loadable_sections
= p
;
2272 stash
->loadable_section_count
= i
;
2274 for (sect
= abfd
->sections
; sect
!= NULL
; sect
= sect
->next
)
2278 if (sect
->vma
!= 0 || (sect
->flags
& SEC_LOAD
) == 0)
2281 sz
= sect
->rawsize
? sect
->rawsize
: sect
->size
;
2288 /* Align the new address to the current section
2290 last_vma
= ((last_vma
2291 + ~((bfd_vma
) -1 << sect
->alignment_power
))
2292 & ((bfd_vma
) -1 << sect
->alignment_power
));
2293 sect
->vma
= last_vma
;
2295 p
->adj_vma
= sect
->vma
;
2296 last_vma
+= sect
->vma
+ sz
;
2305 /* Find the source code location of SYMBOL. If SYMBOL is NULL
2306 then find the nearest source code location corresponding to
2307 the address SECTION + OFFSET.
2308 Returns TRUE if the line is found without error and fills in
2309 FILENAME_PTR and LINENUMBER_PTR. In the case where SYMBOL was
2310 NULL the FUNCTIONNAME_PTR is also filled in.
2311 SYMBOLS contains the symbol table for ABFD.
2312 ADDR_SIZE is the number of bytes in the initial .debug_info length
2313 field and in the abbreviation offset, or zero to indicate that the
2314 default value should be used. */
2317 find_line (bfd
*abfd
,
2322 const char **filename_ptr
,
2323 const char **functionname_ptr
,
2324 unsigned int *linenumber_ptr
,
2325 unsigned int addr_size
,
2328 /* Read each compilation unit from the section .debug_info, and check
2329 to see if it contains the address we are searching for. If yes,
2330 lookup the address, and return the line number info. If no, go
2331 on to the next compilation unit.
2333 We keep a list of all the previously read compilation units, and
2334 a pointer to the next un-read compilation unit. Check the
2335 previously read units before reading more. */
2336 struct dwarf2_debug
*stash
;
2337 /* What address are we looking for? */
2339 struct comp_unit
* each
;
2340 bfd_vma found
= FALSE
;
2341 bfd_boolean do_line
;
2347 bfd_size_type amt
= sizeof (struct dwarf2_debug
);
2349 stash
= bfd_zalloc (abfd
, amt
);
2354 /* In a relocatable file, 2 functions may have the same address.
2355 We change the section vma so that they won't overlap. */
2356 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0)
2358 if (! place_sections (abfd
, stash
))
2362 do_line
= (section
== NULL
2364 && functionname_ptr
== NULL
2368 addr
= symbol
->value
;
2369 section
= bfd_get_section (symbol
);
2371 else if (section
!= NULL
2372 && functionname_ptr
!= NULL
2378 if (section
->output_section
)
2379 addr
+= section
->output_section
->vma
+ section
->output_offset
;
2381 addr
+= section
->vma
;
2382 *filename_ptr
= NULL
;
2383 *functionname_ptr
= NULL
;
2384 *linenumber_ptr
= 0;
2389 bfd_size_type total_size
;
2394 msec
= find_debug_info (abfd
, NULL
);
2397 char * debug_filename
= bfd_follow_gnu_debuglink (abfd
, DEBUGDIR
);
2399 if (debug_filename
== NULL
)
2400 /* No dwarf2 info, and no gnu_debuglink to follow.
2401 Note that at this point the stash has been allocated, but
2402 contains zeros. This lets future calls to this function
2403 fail more quickly. */
2406 if ((debug_bfd
= bfd_openr (debug_filename
, NULL
)) == NULL
2407 || ! bfd_check_format (debug_bfd
, bfd_object
)
2408 || (msec
= find_debug_info (debug_bfd
, NULL
)) == NULL
)
2411 bfd_close (debug_bfd
);
2412 /* FIXME: Should we report our failure to follow the debuglink ? */
2413 free (debug_filename
);
2420 /* There can be more than one DWARF2 info section in a BFD these days.
2421 Read them all in and produce one large stash. We do this in two
2422 passes - in the first pass we just accumulate the section sizes.
2423 In the second pass we read in the section's contents. The allows
2424 us to avoid reallocing the data as we add sections to the stash. */
2425 for (total_size
= 0; msec
; msec
= find_debug_info (debug_bfd
, msec
))
2426 total_size
+= msec
->size
;
2428 stash
->info_ptr
= bfd_alloc (debug_bfd
, total_size
);
2429 if (stash
->info_ptr
== NULL
)
2432 stash
->info_ptr_end
= stash
->info_ptr
;
2434 for (msec
= find_debug_info (debug_bfd
, NULL
);
2436 msec
= find_debug_info (debug_bfd
, msec
))
2439 bfd_size_type start
;
2445 start
= stash
->info_ptr_end
- stash
->info_ptr
;
2447 if ((bfd_simple_get_relocated_section_contents
2448 (debug_bfd
, msec
, stash
->info_ptr
+ start
, symbols
)) == NULL
)
2451 stash
->info_ptr_end
= stash
->info_ptr
+ start
+ size
;
2454 BFD_ASSERT (stash
->info_ptr_end
== stash
->info_ptr
+ total_size
);
2456 stash
->sec
= find_debug_info (debug_bfd
, NULL
);
2457 stash
->sec_info_ptr
= stash
->info_ptr
;
2458 stash
->syms
= symbols
;
2459 stash
->bfd
= debug_bfd
;
2462 /* A null info_ptr indicates that there is no dwarf2 info
2463 (or that an error occured while setting up the stash). */
2464 if (! stash
->info_ptr
)
2467 stash
->inliner_chain
= NULL
;
2469 /* Check the previously read comp. units first. */
2470 for (each
= stash
->all_comp_units
; each
; each
= each
->next_unit
)
2473 found
= (((symbol
->flags
& BSF_FUNCTION
) == 0
2474 || comp_unit_contains_address (each
, addr
))
2475 && comp_unit_find_line (each
, symbol
, addr
,
2476 filename_ptr
, linenumber_ptr
,
2479 found
= (comp_unit_contains_address (each
, addr
)
2480 && comp_unit_find_nearest_line (each
, addr
,
2489 /* The DWARF2 spec says that the initial length field, and the
2490 offset of the abbreviation table, should both be 4-byte values.
2491 However, some compilers do things differently. */
2494 BFD_ASSERT (addr_size
== 4 || addr_size
== 8);
2496 /* Read each remaining comp. units checking each as they are read. */
2497 while (stash
->info_ptr
< stash
->info_ptr_end
)
2500 unsigned int offset_size
= addr_size
;
2501 bfd_byte
*info_ptr_unit
= stash
->info_ptr
;
2503 length
= read_4_bytes (stash
->bfd
, stash
->info_ptr
);
2504 /* A 0xffffff length is the DWARF3 way of indicating
2505 we use 64-bit offsets, instead of 32-bit offsets. */
2506 if (length
== 0xffffffff)
2509 length
= read_8_bytes (stash
->bfd
, stash
->info_ptr
+ 4);
2510 stash
->info_ptr
+= 12;
2512 /* A zero length is the IRIX way of indicating 64-bit offsets,
2513 mostly because the 64-bit length will generally fit in 32
2514 bits, and the endianness helps. */
2515 else if (length
== 0)
2518 length
= read_4_bytes (stash
->bfd
, stash
->info_ptr
+ 4);
2519 stash
->info_ptr
+= 8;
2521 /* In the absence of the hints above, we assume 32-bit DWARF2
2522 offsets even for targets with 64-bit addresses, because:
2523 a) most of the time these targets will not have generated
2524 more than 2Gb of debug info and so will not need 64-bit
2527 b) if they do use 64-bit offsets but they are not using
2528 the size hints that are tested for above then they are
2529 not conforming to the DWARF3 standard anyway. */
2530 else if (addr_size
== 8)
2533 stash
->info_ptr
+= 4;
2536 stash
->info_ptr
+= 4;
2540 each
= parse_comp_unit (stash
, length
, info_ptr_unit
,
2542 stash
->info_ptr
+= length
;
2544 if ((bfd_vma
) (stash
->info_ptr
- stash
->sec_info_ptr
)
2545 == stash
->sec
->size
)
2547 stash
->sec
= find_debug_info (stash
->bfd
, stash
->sec
);
2548 stash
->sec_info_ptr
= stash
->info_ptr
;
2553 each
->next_unit
= stash
->all_comp_units
;
2554 stash
->all_comp_units
= each
;
2556 /* DW_AT_low_pc and DW_AT_high_pc are optional for
2557 compilation units. If we don't have them (i.e.,
2558 unit->high == 0), we need to consult the line info
2559 table to see if a compilation unit contains the given
2562 found
= (((symbol
->flags
& BSF_FUNCTION
) == 0
2563 || each
->arange
.high
== 0
2564 || comp_unit_contains_address (each
, addr
))
2565 && comp_unit_find_line (each
, symbol
, addr
,
2570 found
= ((each
->arange
.high
== 0
2571 || comp_unit_contains_address (each
, addr
))
2572 && comp_unit_find_nearest_line (each
, addr
,
2584 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0)
2585 unset_sections (stash
);
2590 /* The DWARF2 version of find_nearest_line.
2591 Return TRUE if the line is found without error. */
2594 _bfd_dwarf2_find_nearest_line (bfd
*abfd
,
2598 const char **filename_ptr
,
2599 const char **functionname_ptr
,
2600 unsigned int *linenumber_ptr
,
2601 unsigned int addr_size
,
2604 return find_line (abfd
, section
, offset
, NULL
, symbols
, filename_ptr
,
2605 functionname_ptr
, linenumber_ptr
, addr_size
,
2609 /* The DWARF2 version of find_line.
2610 Return TRUE if the line is found without error. */
2613 _bfd_dwarf2_find_line (bfd
*abfd
,
2616 const char **filename_ptr
,
2617 unsigned int *linenumber_ptr
,
2618 unsigned int addr_size
,
2621 return find_line (abfd
, NULL
, 0, symbol
, symbols
, filename_ptr
,
2622 NULL
, linenumber_ptr
, addr_size
,
2627 _bfd_dwarf2_find_inliner_info (bfd
*abfd ATTRIBUTE_UNUSED
,
2628 const char **filename_ptr
,
2629 const char **functionname_ptr
,
2630 unsigned int *linenumber_ptr
,
2633 struct dwarf2_debug
*stash
;
2638 struct funcinfo
*func
= stash
->inliner_chain
;
2640 if (func
&& func
->caller_func
)
2642 *filename_ptr
= func
->caller_file
;
2643 *functionname_ptr
= func
->caller_func
->name
;
2644 *linenumber_ptr
= func
->caller_line
;
2645 stash
->inliner_chain
= func
->caller_func
;
2654 _bfd_dwarf2_cleanup_debug_info (bfd
*abfd
)
2656 struct comp_unit
*each
;
2657 struct dwarf2_debug
*stash
;
2659 if (abfd
== NULL
|| elf_tdata (abfd
) == NULL
)
2662 stash
= elf_tdata (abfd
)->dwarf2_find_line_info
;
2667 for (each
= stash
->all_comp_units
; each
; each
= each
->next_unit
)
2669 struct abbrev_info
**abbrevs
= each
->abbrevs
;
2672 for (i
= 0; i
< ABBREV_HASH_SIZE
; i
++)
2674 struct abbrev_info
*abbrev
= abbrevs
[i
];
2678 free (abbrev
->attrs
);
2679 abbrev
= abbrev
->next
;
2683 if (each
->line_table
)
2685 free (each
->line_table
->dirs
);
2686 free (each
->line_table
->files
);
2690 free (stash
->dwarf_abbrev_buffer
);
2691 free (stash
->dwarf_line_buffer
);
2692 free (stash
->dwarf_ranges_buffer
);