1 /* dwarf.c -- display DWARF contents of a BFD binary file
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
22 #include "libiberty.h"
24 #include "bfd_stdint.h"
27 #include "elf/common.h"
30 #include "gdb/gdb-index.h"
31 #include "filenames.h"
32 #include "safe-ctype.h"
37 #define MAX(a, b) ((a) > (b) ? (a) : (b))
38 #define MIN(a, b) ((a) < (b) ? (a) : (b))
40 static const char *regname (unsigned int regno
, int row
);
42 static int have_frame_base
;
43 static int need_base_address
;
45 static unsigned int num_debug_info_entries
= 0;
46 static unsigned int alloc_num_debug_info_entries
= 0;
47 static debug_info
*debug_information
= NULL
;
48 /* Special value for num_debug_info_entries to indicate
49 that the .debug_info section could not be loaded/parsed. */
50 #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
52 /* A .debug_info section can contain multiple links to separate
53 DWO object files. We use these structures to record these links. */
61 typedef struct dwo_info
65 struct dwo_info
* next
;
68 static dwo_info
* first_dwo_info
= NULL
;
69 static bfd_boolean need_dwo_info
;
71 separate_info
* first_separate_info
= NULL
;
73 unsigned int eh_addr_size
;
78 int do_debug_pubnames
;
79 int do_debug_pubtypes
;
83 int do_debug_frames_interp
;
92 int do_debug_cu_index
;
97 int dwarf_cutoff_level
= -1;
98 unsigned long dwarf_start_die
;
102 /* Convenient constant, to avoid having to cast -1 to dwarf_vma when
103 testing whether e.g. a locview list is present. */
104 static const dwarf_vma vm1
= -1;
106 /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index
107 sections. For version 1 package files, each set is stored in SHNDX_POOL
108 as a zero-terminated list of section indexes comprising one set of debug
109 sections from a .dwo file. */
111 static unsigned int *shndx_pool
= NULL
;
112 static unsigned int shndx_pool_size
= 0;
113 static unsigned int shndx_pool_used
= 0;
115 /* For version 2 package files, each set contains an array of section offsets
116 and an array of section sizes, giving the offset and size of the
117 contribution from a CU or TU within one of the debug sections.
118 When displaying debug info from a package file, we need to use these
119 tables to locate the corresponding contributions to each section. */
124 dwarf_vma section_offsets
[DW_SECT_MAX
];
125 size_t section_sizes
[DW_SECT_MAX
];
128 static int cu_count
= 0;
129 static int tu_count
= 0;
130 static struct cu_tu_set
*cu_sets
= NULL
;
131 static struct cu_tu_set
*tu_sets
= NULL
;
133 static bfd_boolean
load_cu_tu_indexes (void *);
135 /* Values for do_debug_lines. */
136 #define FLAG_DEBUG_LINES_RAW 1
137 #define FLAG_DEBUG_LINES_DECODED 2
140 size_of_encoded_value (int encoding
)
142 switch (encoding
& 0x7)
145 case 0: return eh_addr_size
;
153 get_encoded_value (unsigned char **pdata
,
155 struct dwarf_section
*section
,
158 unsigned char * data
= * pdata
;
159 unsigned int size
= size_of_encoded_value (encoding
);
162 if (data
+ size
>= end
)
164 warn (_("Encoded value extends past end of section\n"));
169 /* PR 17512: file: 002-829853-0.004. */
172 warn (_("Encoded size of %d is too large to read\n"), size
);
177 /* PR 17512: file: 1085-5603-0.004. */
180 warn (_("Encoded size of 0 is too small to read\n"));
185 if (encoding
& DW_EH_PE_signed
)
186 val
= byte_get_signed (data
, size
);
188 val
= byte_get (data
, size
);
190 if ((encoding
& 0x70) == DW_EH_PE_pcrel
)
191 val
+= section
->address
+ (data
- section
->start
);
193 * pdata
= data
+ size
;
197 #if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
199 # define DWARF_VMA_FMT "ll"
200 # define DWARF_VMA_FMT_LONG "%16.16llx"
202 # define DWARF_VMA_FMT "I64"
203 # define DWARF_VMA_FMT_LONG "%016I64x"
206 # define DWARF_VMA_FMT "l"
207 # define DWARF_VMA_FMT_LONG "%16.16lx"
210 /* Convert a dwarf vma value into a string. Returns a pointer to a static
211 buffer containing the converted VALUE. The value is converted according
212 to the printf formating character FMTCH. If NUM_BYTES is non-zero then
213 it specifies the maximum number of bytes to be displayed in the converted
214 value and FMTCH is ignored - hex is always used. */
217 dwarf_vmatoa_1 (const char *fmtch
, dwarf_vma value
, unsigned num_bytes
)
219 /* As dwarf_vmatoa is used more then once in a printf call
220 for output, we are cycling through an fixed array of pointers
221 for return address. */
222 static int buf_pos
= 0;
223 static struct dwarf_vmatoa_buf
229 ret
= buf
[buf_pos
++].place
;
230 buf_pos
%= ARRAY_SIZE (buf
);
234 /* Printf does not have a way of specifying a maximum field width for an
235 integer value, so we print the full value into a buffer and then select
236 the precision we need. */
237 snprintf (ret
, sizeof (buf
[0].place
), DWARF_VMA_FMT_LONG
, value
);
240 return ret
+ (16 - 2 * num_bytes
);
247 sprintf (fmt
, "%%%s%s", DWARF_VMA_FMT
, fmtch
);
249 sprintf (fmt
, "%%%s", DWARF_VMA_FMT
);
250 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
255 static inline const char *
256 dwarf_vmatoa (const char * fmtch
, dwarf_vma value
)
258 return dwarf_vmatoa_1 (fmtch
, value
, 0);
261 /* Print a dwarf_vma value (typically an address, offset or length) in
262 hexadecimal format, followed by a space. The length of the VALUE (and
263 hence the precision displayed) is determined by the NUM_BYTES parameter. */
266 print_dwarf_vma (dwarf_vma value
, unsigned num_bytes
)
268 printf ("%s ", dwarf_vmatoa_1 (NULL
, value
, num_bytes
));
271 /* Print a view number in hexadecimal value, with the same width
272 print_dwarf_vma would have printed it with the same num_bytes.
273 Print blanks for zero view, unless force is nonzero. */
276 print_dwarf_view (dwarf_vma value
, unsigned num_bytes
, int force
)
284 assert (value
== (unsigned long) value
);
286 printf ("v%0*lx ", len
- 1, (unsigned long) value
);
288 printf ("%*s", len
+ 1, "");
291 /* Format a 64-bit value, given as two 32-bit values, in hex.
292 For reentrancy, this uses a buffer provided by the caller. */
295 dwarf_vmatoa64 (dwarf_vma hvalue
, dwarf_vma lvalue
, char *buf
,
296 unsigned int buf_len
)
301 snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", lvalue
);
304 len
= snprintf (buf
, buf_len
, "%" DWARF_VMA_FMT
"x", hvalue
);
305 snprintf (buf
+ len
, buf_len
- len
,
306 "%08" DWARF_VMA_FMT
"x", lvalue
);
312 /* Read in a LEB128 encoded value starting at address DATA.
313 If SIGN is true, return a signed LEB128 value.
314 If LENGTH_RETURN is not NULL, return in it the number of bytes read.
315 No bytes will be read at address END or beyond. */
318 read_leb128 (unsigned char *data
,
319 unsigned int *length_return
,
321 const unsigned char * const end
)
323 dwarf_vma result
= 0;
324 unsigned int num_read
= 0;
325 unsigned int shift
= 0;
326 unsigned char byte
= 0;
333 result
|= ((dwarf_vma
) (byte
& 0x7f)) << shift
;
336 if ((byte
& 0x80) == 0)
339 /* PR 17512: file: 0ca183b8.
340 FIXME: Should we signal this error somehow ? */
341 if (shift
>= sizeof (result
) * 8)
345 if (length_return
!= NULL
)
346 *length_return
= num_read
;
348 if (sign
&& (shift
< 8 * sizeof (result
)) && (byte
& 0x40))
349 result
|= -((dwarf_vma
) 1 << shift
);
354 /* Create a signed version to avoid painful typecasts. */
355 static inline dwarf_signed_vma
356 read_sleb128 (unsigned char * data
,
357 unsigned int * length_return
,
358 const unsigned char * const end
)
360 return (dwarf_signed_vma
) read_leb128 (data
, length_return
, TRUE
, end
);
363 static inline dwarf_vma
364 read_uleb128 (unsigned char * data
,
365 unsigned int * length_return
,
366 const unsigned char * const end
)
368 return read_leb128 (data
, length_return
, FALSE
, end
);
371 #define SKIP_ULEB() read_uleb128 (start, & length_return, end); start += length_return
372 #define SKIP_SLEB() read_sleb128 (start, & length_return, end); start += length_return
374 #define READ_ULEB(var) \
379 (var) = _val = read_uleb128 (start, &length_return, end); \
381 error (_("Internal error: %s:%d: LEB value (%s) " \
382 "too large for containing variable\n"), \
383 __FILE__, __LINE__, dwarf_vmatoa ("u", _val)); \
384 start += length_return; \
388 #define READ_SLEB(var) \
391 dwarf_signed_vma _val; \
393 (var) = _val = read_sleb128 (start, &length_return, end); \
395 error (_("Internal error: %s:%d: LEB value (%s) " \
396 "too large for containing variable\n"), \
397 __FILE__, __LINE__, dwarf_vmatoa ("d", _val)); \
398 start += length_return; \
402 /* Read AMOUNT bytes from PTR and store them in VAL as an unsigned value.
403 Checks to make sure that the read will not reach or pass END
404 and that VAL is big enough to hold AMOUNT bytes. */
405 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
408 unsigned int amount = (AMOUNT); \
409 if (sizeof (VAL) < amount) \
411 error (ngettext ("internal error: attempt to read %d byte " \
412 "of data in to %d sized variable", \
413 "internal error: attempt to read %d bytes " \
414 "of data in to %d sized variable", \
416 amount, (int) sizeof (VAL)); \
417 amount = sizeof (VAL); \
419 if (((PTR) + amount) >= (END)) \
422 amount = (END) - (PTR); \
426 if (amount == 0 || amount > 8) \
429 VAL = byte_get ((PTR), amount); \
433 /* Like SAFE_BYTE_GET, but also increments PTR by AMOUNT. */
434 #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
437 SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \
442 /* Like SAFE_BYTE_GET, but reads a signed value. */
443 #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \
446 unsigned int amount = (AMOUNT); \
447 if (((PTR) + amount) >= (END)) \
450 amount = (END) - (PTR); \
455 VAL = byte_get_signed ((PTR), amount); \
461 /* Like SAFE_SIGNED_BYTE_GET, but also increments PTR by AMOUNT. */
462 #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \
465 SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \
470 #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \
473 if (((PTR) + 8) <= (END)) \
475 byte_get_64 ((PTR), (HIGH), (LOW)); \
479 * (LOW) = * (HIGH) = 0; \
484 typedef struct State_Machine_Registers
493 unsigned char op_index
;
494 unsigned char end_sequence
;
495 /* This variable hold the number of the last entry seen
496 in the File Table. */
497 unsigned int last_file_entry
;
500 static SMR state_machine_regs
;
503 reset_state_machine (int is_stmt
)
505 state_machine_regs
.address
= 0;
506 state_machine_regs
.view
= 0;
507 state_machine_regs
.op_index
= 0;
508 state_machine_regs
.file
= 1;
509 state_machine_regs
.line
= 1;
510 state_machine_regs
.column
= 0;
511 state_machine_regs
.is_stmt
= is_stmt
;
512 state_machine_regs
.basic_block
= 0;
513 state_machine_regs
.end_sequence
= 0;
514 state_machine_regs
.last_file_entry
= 0;
517 /* Handled an extend line op.
518 Returns the number of bytes read. */
521 process_extended_line_op (unsigned char * data
,
525 unsigned char op_code
;
526 unsigned int bytes_read
;
529 unsigned char *orig_data
= data
;
532 len
= read_uleb128 (data
, & bytes_read
, end
);
535 if (len
== 0 || data
== end
|| len
> (uintptr_t) (end
- data
))
537 warn (_("Badly formed extended line op encountered!\n"));
544 printf (_(" Extended opcode %d: "), op_code
);
548 case DW_LNE_end_sequence
:
549 printf (_("End of Sequence\n\n"));
550 reset_state_machine (is_stmt
);
553 case DW_LNE_set_address
:
554 /* PR 17512: file: 002-100480-0.004. */
555 if (len
- bytes_read
- 1 > 8)
557 warn (_("Length (%d) of DW_LNE_set_address op is too long\n"),
558 len
- bytes_read
- 1);
562 SAFE_BYTE_GET (adr
, data
, len
- bytes_read
- 1, end
);
563 printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr
));
564 state_machine_regs
.address
= adr
;
565 state_machine_regs
.view
= 0;
566 state_machine_regs
.op_index
= 0;
569 case DW_LNE_define_file
:
570 printf (_("define new File Table entry\n"));
571 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
572 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
578 l
= strnlen ((char *) data
, end
- data
);
580 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
582 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
584 printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
586 printf ("%.*s\n\n", (int) l
, name
);
589 if (((unsigned int) (data
- orig_data
) != len
) || data
== end
)
590 warn (_("DW_LNE_define_file: Bad opcode length\n"));
593 case DW_LNE_set_discriminator
:
594 printf (_("set Discriminator to %s\n"),
595 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
599 case DW_LNE_HP_negate_is_UV_update
:
600 printf ("DW_LNE_HP_negate_is_UV_update\n");
602 case DW_LNE_HP_push_context
:
603 printf ("DW_LNE_HP_push_context\n");
605 case DW_LNE_HP_pop_context
:
606 printf ("DW_LNE_HP_pop_context\n");
608 case DW_LNE_HP_set_file_line_column
:
609 printf ("DW_LNE_HP_set_file_line_column\n");
611 case DW_LNE_HP_set_routine_name
:
612 printf ("DW_LNE_HP_set_routine_name\n");
614 case DW_LNE_HP_set_sequence
:
615 printf ("DW_LNE_HP_set_sequence\n");
617 case DW_LNE_HP_negate_post_semantics
:
618 printf ("DW_LNE_HP_negate_post_semantics\n");
620 case DW_LNE_HP_negate_function_exit
:
621 printf ("DW_LNE_HP_negate_function_exit\n");
623 case DW_LNE_HP_negate_front_end_logical
:
624 printf ("DW_LNE_HP_negate_front_end_logical\n");
626 case DW_LNE_HP_define_proc
:
627 printf ("DW_LNE_HP_define_proc\n");
629 case DW_LNE_HP_source_file_correlation
:
631 unsigned char *edata
= data
+ len
- bytes_read
- 1;
633 printf ("DW_LNE_HP_source_file_correlation\n");
639 opc
= read_uleb128 (data
, & bytes_read
, edata
);
644 case DW_LNE_HP_SFC_formfeed
:
645 printf (" DW_LNE_HP_SFC_formfeed\n");
647 case DW_LNE_HP_SFC_set_listing_line
:
648 printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n",
650 read_uleb128 (data
, & bytes_read
, edata
)));
653 case DW_LNE_HP_SFC_associate
:
654 printf (" DW_LNE_HP_SFC_associate ");
657 read_uleb128 (data
, & bytes_read
, edata
)));
661 read_uleb128 (data
, & bytes_read
, edata
)));
665 read_uleb128 (data
, & bytes_read
, edata
)));
669 printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc
);
679 unsigned int rlen
= len
- bytes_read
- 1;
681 if (op_code
>= DW_LNE_lo_user
682 /* The test against DW_LNW_hi_user is redundant due to
683 the limited range of the unsigned char data type used
685 /*&& op_code <= DW_LNE_hi_user*/)
686 printf (_("user defined: "));
688 printf (_("UNKNOWN: "));
689 printf (_("length %d ["), rlen
);
691 printf (" %02x", *data
++);
700 static const unsigned char *
701 fetch_indirect_string (dwarf_vma offset
)
703 struct dwarf_section
*section
= &debug_displays
[str
].section
;
704 const unsigned char * ret
;
706 if (section
->start
== NULL
)
707 return (const unsigned char *) _("<no .debug_str section>");
709 if (offset
>= section
->size
)
711 warn (_("DW_FORM_strp offset too big: %s\n"),
712 dwarf_vmatoa ("x", offset
));
713 return (const unsigned char *) _("<offset is too big>");
716 ret
= section
->start
+ offset
;
717 /* Unfortunately we cannot rely upon the .debug_str section ending with a
718 NUL byte. Since our caller is expecting to receive a well formed C
719 string we test for the lack of a terminating byte here. */
720 if (strnlen ((const char *) ret
, section
->size
- offset
)
721 == section
->size
- offset
)
722 ret
= (const unsigned char *)
723 _("<no NUL byte at end of .debug_str section>");
728 static const unsigned char *
729 fetch_indirect_line_string (dwarf_vma offset
)
731 struct dwarf_section
*section
= &debug_displays
[line_str
].section
;
732 const unsigned char * ret
;
734 if (section
->start
== NULL
)
735 return (const unsigned char *) _("<no .debug_line_str section>");
737 if (offset
>= section
->size
)
739 warn (_("DW_FORM_line_strp offset too big: %s\n"),
740 dwarf_vmatoa ("x", offset
));
741 return (const unsigned char *) _("<offset is too big>");
744 ret
= section
->start
+ offset
;
745 /* Unfortunately we cannot rely upon the .debug_line_str section ending
746 with a NUL byte. Since our caller is expecting to receive a well formed
747 C string we test for the lack of a terminating byte here. */
748 if (strnlen ((const char *) ret
, section
->size
- offset
)
749 == section
->size
- offset
)
750 ret
= (const unsigned char *)
751 _("<no NUL byte at end of .debug_line_str section>");
757 fetch_indexed_string (dwarf_vma idx
, struct cu_tu_set
*this_set
,
758 dwarf_vma offset_size
, bfd_boolean dwo
)
760 enum dwarf_section_display_enum str_sec_idx
= dwo
? str_dwo
: str
;
761 enum dwarf_section_display_enum idx_sec_idx
= dwo
? str_index_dwo
: str_index
;
762 struct dwarf_section
*index_section
= &debug_displays
[idx_sec_idx
].section
;
763 struct dwarf_section
*str_section
= &debug_displays
[str_sec_idx
].section
;
764 dwarf_vma index_offset
= idx
* offset_size
;
765 dwarf_vma str_offset
;
768 if (index_section
->start
== NULL
)
769 return (dwo
? _("<no .debug_str_offsets.dwo section>")
770 : _("<no .debug_str_offsets section>"));
772 if (this_set
!= NULL
)
773 index_offset
+= this_set
->section_offsets
[DW_SECT_STR_OFFSETS
];
774 if (index_offset
>= index_section
->size
)
776 warn (_("DW_FORM_GNU_str_index offset too big: %s\n"),
777 dwarf_vmatoa ("x", index_offset
));
778 return _("<index offset is too big>");
781 if (str_section
->start
== NULL
)
782 return (dwo
? _("<no .debug_str.dwo section>")
783 : _("<no .debug_str section>"));
785 str_offset
= byte_get (index_section
->start
+ index_offset
, offset_size
);
786 str_offset
-= str_section
->address
;
787 if (str_offset
>= str_section
->size
)
789 warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"),
790 dwarf_vmatoa ("x", str_offset
));
791 return _("<indirect index offset is too big>");
794 ret
= (const char *) str_section
->start
+ str_offset
;
795 /* Unfortunately we cannot rely upon str_section ending with a NUL byte.
796 Since our caller is expecting to receive a well formed C string we test
797 for the lack of a terminating byte here. */
798 if (strnlen (ret
, str_section
->size
- str_offset
)
799 == str_section
->size
- str_offset
)
800 ret
= (const char *) _("<no NUL byte at end of section>");
806 fetch_indexed_value (dwarf_vma offset
, dwarf_vma bytes
)
808 struct dwarf_section
*section
= &debug_displays
[debug_addr
].section
;
810 if (section
->start
== NULL
)
811 return (_("<no .debug_addr section>"));
813 if (offset
+ bytes
> section
->size
)
815 warn (_("Offset into section %s too big: %s\n"),
816 section
->name
, dwarf_vmatoa ("x", offset
));
817 return "<offset too big>";
820 return dwarf_vmatoa ("x", byte_get (section
->start
+ offset
, bytes
));
824 /* FIXME: There are better and more efficient ways to handle
825 these structures. For now though, I just want something that
826 is simple to implement. */
827 typedef struct abbrev_attr
829 unsigned long attribute
;
831 bfd_signed_vma implicit_const
;
832 struct abbrev_attr
*next
;
836 typedef struct abbrev_entry
841 struct abbrev_attr
*first_attr
;
842 struct abbrev_attr
*last_attr
;
843 struct abbrev_entry
*next
;
847 static abbrev_entry
*first_abbrev
= NULL
;
848 static abbrev_entry
*last_abbrev
= NULL
;
855 for (abbrv
= first_abbrev
; abbrv
;)
857 abbrev_entry
*next_abbrev
= abbrv
->next
;
860 for (attr
= abbrv
->first_attr
; attr
;)
862 abbrev_attr
*next_attr
= attr
->next
;
872 last_abbrev
= first_abbrev
= NULL
;
876 add_abbrev (unsigned long number
, unsigned long tag
, int children
)
880 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
885 entry
->entry
= number
;
887 entry
->children
= children
;
888 entry
->first_attr
= NULL
;
889 entry
->last_attr
= NULL
;
892 if (first_abbrev
== NULL
)
893 first_abbrev
= entry
;
895 last_abbrev
->next
= entry
;
901 add_abbrev_attr (unsigned long attribute
, unsigned long form
,
902 bfd_signed_vma implicit_const
)
906 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
911 attr
->attribute
= attribute
;
913 attr
->implicit_const
= implicit_const
;
916 if (last_abbrev
->first_attr
== NULL
)
917 last_abbrev
->first_attr
= attr
;
919 last_abbrev
->last_attr
->next
= attr
;
921 last_abbrev
->last_attr
= attr
;
924 /* Processes the (partial) contents of a .debug_abbrev section.
925 Returns NULL if the end of the section was encountered.
926 Returns the address after the last byte read if the end of
927 an abbreviation set was found. */
929 static unsigned char *
930 process_abbrev_section (unsigned char *start
, unsigned char *end
)
932 if (first_abbrev
!= NULL
)
937 unsigned int bytes_read
;
940 unsigned long attribute
;
943 entry
= read_uleb128 (start
, & bytes_read
, end
);
946 /* A single zero is supposed to end the section according
947 to the standard. If there's more, then signal that to
954 tag
= read_uleb128 (start
, & bytes_read
, end
);
961 add_abbrev (entry
, tag
, children
);
966 /* Initialize it due to a false compiler warning. */
967 bfd_signed_vma implicit_const
= -1;
969 attribute
= read_uleb128 (start
, & bytes_read
, end
);
974 form
= read_uleb128 (start
, & bytes_read
, end
);
979 if (form
== DW_FORM_implicit_const
)
981 implicit_const
= read_sleb128 (start
, & bytes_read
, end
);
987 add_abbrev_attr (attribute
, form
, implicit_const
);
989 while (attribute
!= 0);
992 /* Report the missing single zero which ends the section. */
993 error (_(".debug_abbrev section not zero terminated\n"));
999 get_TAG_name (unsigned long tag
)
1001 const char *name
= get_DW_TAG_name ((unsigned int) tag
);
1005 static char buffer
[100];
1007 if (tag
>= DW_TAG_lo_user
&& tag
<= DW_TAG_hi_user
)
1008 snprintf (buffer
, sizeof (buffer
), _("User TAG value: %#lx"), tag
);
1010 snprintf (buffer
, sizeof (buffer
), _("Unknown TAG value: %#lx"), tag
);
1018 get_FORM_name (unsigned long form
)
1023 return "DW_FORM value: 0";
1025 name
= get_DW_FORM_name (form
);
1028 static char buffer
[100];
1030 snprintf (buffer
, sizeof (buffer
), _("Unknown FORM value: %lx"), form
);
1038 get_IDX_name (unsigned long idx
)
1040 const char *name
= get_DW_IDX_name ((unsigned int) idx
);
1044 static char buffer
[100];
1046 snprintf (buffer
, sizeof (buffer
), _("Unknown IDX value: %lx"), idx
);
1053 static unsigned char *
1054 display_block (unsigned char *data
,
1056 const unsigned char * const end
, char delimiter
)
1060 printf (_("%c%s byte block: "), delimiter
, dwarf_vmatoa ("u", length
));
1062 return (unsigned char *) end
;
1064 maxlen
= (dwarf_vma
) (end
- data
);
1065 length
= length
> maxlen
? maxlen
: length
;
1068 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
1074 decode_location_expression (unsigned char * data
,
1075 unsigned int pointer_size
,
1076 unsigned int offset_size
,
1079 dwarf_vma cu_offset
,
1080 struct dwarf_section
* section
)
1083 unsigned int bytes_read
;
1085 dwarf_signed_vma svalue
;
1086 unsigned char *end
= data
+ length
;
1087 int need_frame_base
= 0;
1096 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1097 printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue
));
1100 printf ("DW_OP_deref");
1103 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1104 printf ("DW_OP_const1u: %lu", (unsigned long) uvalue
);
1107 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 1, end
);
1108 printf ("DW_OP_const1s: %ld", (long) svalue
);
1111 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
1112 printf ("DW_OP_const2u: %lu", (unsigned long) uvalue
);
1115 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1116 printf ("DW_OP_const2s: %ld", (long) svalue
);
1119 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1120 printf ("DW_OP_const4u: %lu", (unsigned long) uvalue
);
1123 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1124 printf ("DW_OP_const4s: %ld", (long) svalue
);
1127 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1128 printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue
);
1129 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1130 printf ("%lu", (unsigned long) uvalue
);
1133 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1134 printf ("DW_OP_const8s: %ld ", (long) svalue
);
1135 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1136 printf ("%ld", (long) svalue
);
1139 printf ("DW_OP_constu: %s",
1140 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1144 printf ("DW_OP_consts: %s",
1145 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1149 printf ("DW_OP_dup");
1152 printf ("DW_OP_drop");
1155 printf ("DW_OP_over");
1158 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1159 printf ("DW_OP_pick: %ld", (unsigned long) uvalue
);
1162 printf ("DW_OP_swap");
1165 printf ("DW_OP_rot");
1168 printf ("DW_OP_xderef");
1171 printf ("DW_OP_abs");
1174 printf ("DW_OP_and");
1177 printf ("DW_OP_div");
1180 printf ("DW_OP_minus");
1183 printf ("DW_OP_mod");
1186 printf ("DW_OP_mul");
1189 printf ("DW_OP_neg");
1192 printf ("DW_OP_not");
1195 printf ("DW_OP_or");
1198 printf ("DW_OP_plus");
1200 case DW_OP_plus_uconst
:
1201 printf ("DW_OP_plus_uconst: %s",
1202 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1206 printf ("DW_OP_shl");
1209 printf ("DW_OP_shr");
1212 printf ("DW_OP_shra");
1215 printf ("DW_OP_xor");
1218 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1219 printf ("DW_OP_bra: %ld", (long) svalue
);
1222 printf ("DW_OP_eq");
1225 printf ("DW_OP_ge");
1228 printf ("DW_OP_gt");
1231 printf ("DW_OP_le");
1234 printf ("DW_OP_lt");
1237 printf ("DW_OP_ne");
1240 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1241 printf ("DW_OP_skip: %ld", (long) svalue
);
1276 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
1311 printf ("DW_OP_reg%d (%s)", op
- DW_OP_reg0
,
1312 regname (op
- DW_OP_reg0
, 1));
1347 printf ("DW_OP_breg%d (%s): %s",
1349 regname (op
- DW_OP_breg0
, 1),
1350 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1355 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1357 printf ("DW_OP_regx: %s (%s)",
1358 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1361 need_frame_base
= 1;
1362 printf ("DW_OP_fbreg: %s",
1363 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1367 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1369 printf ("DW_OP_bregx: %s (%s) %s",
1370 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1),
1371 dwarf_vmatoa ("d", read_sleb128 (data
, &bytes_read
, end
)));
1375 printf ("DW_OP_piece: %s",
1376 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1379 case DW_OP_deref_size
:
1380 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1381 printf ("DW_OP_deref_size: %ld", (long) uvalue
);
1383 case DW_OP_xderef_size
:
1384 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1385 printf ("DW_OP_xderef_size: %ld", (long) uvalue
);
1388 printf ("DW_OP_nop");
1391 /* DWARF 3 extensions. */
1392 case DW_OP_push_object_address
:
1393 printf ("DW_OP_push_object_address");
1396 /* FIXME: Strictly speaking for 64-bit DWARF3 files
1397 this ought to be an 8-byte wide computation. */
1398 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 2, end
);
1399 printf ("DW_OP_call2: <0x%s>",
1400 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1403 /* FIXME: Strictly speaking for 64-bit DWARF3 files
1404 this ought to be an 8-byte wide computation. */
1405 SAFE_SIGNED_BYTE_GET_AND_INC (svalue
, data
, 4, end
);
1406 printf ("DW_OP_call4: <0x%s>",
1407 dwarf_vmatoa ("x", svalue
+ cu_offset
));
1409 case DW_OP_call_ref
:
1410 /* FIXME: Strictly speaking for 64-bit DWARF3 files
1411 this ought to be an 8-byte wide computation. */
1412 if (dwarf_version
== -1)
1414 printf (_("(DW_OP_call_ref in frame info)"));
1415 /* No way to tell where the next op is, so just bail. */
1416 return need_frame_base
;
1418 if (dwarf_version
== 2)
1420 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1424 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1426 printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue
));
1428 case DW_OP_form_tls_address
:
1429 printf ("DW_OP_form_tls_address");
1431 case DW_OP_call_frame_cfa
:
1432 printf ("DW_OP_call_frame_cfa");
1434 case DW_OP_bit_piece
:
1435 printf ("DW_OP_bit_piece: ");
1436 printf (_("size: %s "),
1437 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1439 printf (_("offset: %s "),
1440 dwarf_vmatoa ("u", read_uleb128 (data
, &bytes_read
, end
)));
1444 /* DWARF 4 extensions. */
1445 case DW_OP_stack_value
:
1446 printf ("DW_OP_stack_value");
1449 case DW_OP_implicit_value
:
1450 printf ("DW_OP_implicit_value");
1451 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1453 data
= display_block (data
, uvalue
, end
, ' ');
1456 /* GNU extensions. */
1457 case DW_OP_GNU_push_tls_address
:
1458 printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown"));
1460 case DW_OP_GNU_uninit
:
1461 printf ("DW_OP_GNU_uninit");
1462 /* FIXME: Is there data associated with this OP ? */
1464 case DW_OP_GNU_encoded_addr
:
1471 addr
= get_encoded_value (&data
, encoding
, section
, end
);
1473 printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding
);
1474 print_dwarf_vma (addr
, pointer_size
);
1477 case DW_OP_implicit_pointer
:
1478 case DW_OP_GNU_implicit_pointer
:
1479 /* FIXME: Strictly speaking for 64-bit DWARF3 files
1480 this ought to be an 8-byte wide computation. */
1481 if (dwarf_version
== -1)
1483 printf (_("(%s in frame info)"),
1484 (op
== DW_OP_implicit_pointer
1485 ? "DW_OP_implicit_pointer"
1486 : "DW_OP_GNU_implicit_pointer"));
1487 /* No way to tell where the next op is, so just bail. */
1488 return need_frame_base
;
1490 if (dwarf_version
== 2)
1492 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1496 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1498 printf ("%s: <0x%s> %s",
1499 (op
== DW_OP_implicit_pointer
1500 ? "DW_OP_implicit_pointer" : "DW_OP_GNU_implicit_pointer"),
1501 dwarf_vmatoa ("x", uvalue
),
1502 dwarf_vmatoa ("d", read_sleb128 (data
,
1503 &bytes_read
, end
)));
1506 case DW_OP_entry_value
:
1507 case DW_OP_GNU_entry_value
:
1508 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1510 /* PR 17531: file: 0cc9cd00. */
1511 if (uvalue
> (dwarf_vma
) (end
- data
))
1512 uvalue
= end
- data
;
1513 printf ("%s: (", (op
== DW_OP_entry_value
? "DW_OP_entry_value"
1514 : "DW_OP_GNU_entry_value"));
1515 if (decode_location_expression (data
, pointer_size
, offset_size
,
1516 dwarf_version
, uvalue
,
1517 cu_offset
, section
))
1518 need_frame_base
= 1;
1524 case DW_OP_const_type
:
1525 case DW_OP_GNU_const_type
:
1526 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1528 printf ("%s: <0x%s> ",
1529 (op
== DW_OP_const_type
? "DW_OP_const_type"
1530 : "DW_OP_GNU_const_type"),
1531 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1532 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1533 data
= display_block (data
, uvalue
, end
, ' ');
1535 case DW_OP_regval_type
:
1536 case DW_OP_GNU_regval_type
:
1537 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1539 printf ("%s: %s (%s)",
1540 (op
== DW_OP_regval_type
? "DW_OP_regval_type"
1541 : "DW_OP_GNU_regval_type"),
1542 dwarf_vmatoa ("u", uvalue
), regname (uvalue
, 1));
1543 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1545 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1547 case DW_OP_deref_type
:
1548 case DW_OP_GNU_deref_type
:
1549 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1551 (op
== DW_OP_deref_type
? "DW_OP_deref_type"
1552 : "DW_OP_GNU_deref_type"),
1554 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1556 printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1559 case DW_OP_GNU_convert
:
1560 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1562 printf ("%s <0x%s>",
1563 (op
== DW_OP_convert
? "DW_OP_convert" : "DW_OP_GNU_convert"),
1564 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1566 case DW_OP_reinterpret
:
1567 case DW_OP_GNU_reinterpret
:
1568 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1570 printf ("%s <0x%s>",
1571 (op
== DW_OP_reinterpret
? "DW_OP_reinterpret"
1572 : "DW_OP_GNU_reinterpret"),
1573 dwarf_vmatoa ("x", uvalue
? cu_offset
+ uvalue
: 0));
1575 case DW_OP_GNU_parameter_ref
:
1576 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1577 printf ("DW_OP_GNU_parameter_ref: <0x%s>",
1578 dwarf_vmatoa ("x", cu_offset
+ uvalue
));
1580 case DW_OP_GNU_addr_index
:
1581 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1583 printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1585 case DW_OP_GNU_const_index
:
1586 uvalue
= read_uleb128 (data
, &bytes_read
, end
);
1588 printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue
));
1590 case DW_OP_GNU_variable_value
:
1591 /* FIXME: Strictly speaking for 64-bit DWARF3 files
1592 this ought to be an 8-byte wide computation. */
1593 if (dwarf_version
== -1)
1595 printf (_("(DW_OP_GNU_variable_value in frame info)"));
1596 /* No way to tell where the next op is, so just bail. */
1597 return need_frame_base
;
1599 if (dwarf_version
== 2)
1601 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1605 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1607 printf ("DW_OP_GNU_variable_value: <0x%s>", dwarf_vmatoa ("x", uvalue
));
1610 /* HP extensions. */
1611 case DW_OP_HP_is_value
:
1612 printf ("DW_OP_HP_is_value");
1613 /* FIXME: Is there data associated with this OP ? */
1615 case DW_OP_HP_fltconst4
:
1616 printf ("DW_OP_HP_fltconst4");
1617 /* FIXME: Is there data associated with this OP ? */
1619 case DW_OP_HP_fltconst8
:
1620 printf ("DW_OP_HP_fltconst8");
1621 /* FIXME: Is there data associated with this OP ? */
1623 case DW_OP_HP_mod_range
:
1624 printf ("DW_OP_HP_mod_range");
1625 /* FIXME: Is there data associated with this OP ? */
1627 case DW_OP_HP_unmod_range
:
1628 printf ("DW_OP_HP_unmod_range");
1629 /* FIXME: Is there data associated with this OP ? */
1632 printf ("DW_OP_HP_tls");
1633 /* FIXME: Is there data associated with this OP ? */
1636 /* PGI (STMicroelectronics) extensions. */
1637 case DW_OP_PGI_omp_thread_num
:
1638 /* Pushes the thread number for the current thread as it would be
1639 returned by the standard OpenMP library function:
1640 omp_get_thread_num(). The "current thread" is the thread for
1641 which the expression is being evaluated. */
1642 printf ("DW_OP_PGI_omp_thread_num");
1646 if (op
>= DW_OP_lo_user
1647 && op
<= DW_OP_hi_user
)
1648 printf (_("(User defined location op 0x%x)"), op
);
1650 printf (_("(Unknown location op 0x%x)"), op
);
1651 /* No way to tell where the next op is, so just bail. */
1652 return need_frame_base
;
1655 /* Separate the ops. */
1660 return need_frame_base
;
1663 /* Find the CU or TU set corresponding to the given CU_OFFSET.
1664 This is used for DWARF package files. */
1666 static struct cu_tu_set
*
1667 find_cu_tu_set_v2 (dwarf_vma cu_offset
, int do_types
)
1669 struct cu_tu_set
*p
;
1671 unsigned int dw_sect
;
1677 dw_sect
= DW_SECT_TYPES
;
1683 dw_sect
= DW_SECT_INFO
;
1687 if (p
->section_offsets
[dw_sect
] == cu_offset
)
1695 /* Add INC to HIGH_BITS:LOW_BITS. */
1697 add64 (dwarf_vma
* high_bits
, dwarf_vma
* low_bits
, dwarf_vma inc
)
1699 dwarf_vma tmp
= * low_bits
;
1703 /* FIXME: There is probably a better way of handling this:
1705 We need to cope with dwarf_vma being a 32-bit or 64-bit
1706 type. Plus regardless of its size LOW_BITS is meant to
1707 only hold 32-bits, so if there is overflow or wrap around
1708 we must propagate into HIGH_BITS. */
1709 if (tmp
< * low_bits
)
1713 else if (sizeof (tmp
) > 8
1724 fetch_alt_indirect_string (dwarf_vma offset
)
1728 if (! do_follow_links
)
1731 if (first_separate_info
== NULL
)
1732 return _("<no links available>");
1734 for (i
= first_separate_info
; i
!= NULL
; i
= i
->next
)
1736 struct dwarf_section
* section
;
1739 if (! load_debug_section (separate_debug_str
, i
->handle
))
1742 section
= &debug_displays
[separate_debug_str
].section
;
1744 if (section
->start
== NULL
)
1747 if (offset
>= section
->size
)
1750 ret
= (const char *) (section
->start
+ offset
);
1751 /* Unfortunately we cannot rely upon the .debug_str section ending with a
1752 NUL byte. Since our caller is expecting to receive a well formed C
1753 string we test for the lack of a terminating byte here. */
1754 if (strnlen ((const char *) ret
, section
->size
- offset
)
1755 == section
->size
- offset
)
1756 return _("<no NUL byte at end of alt .debug_str section>");
1761 warn (_("DW_FORM_GNU_strp_alt offset (%s) too big or no string sections available\n"),
1762 dwarf_vmatoa ("x", offset
));
1763 return _("<offset is too big>");
1767 get_AT_name (unsigned long attribute
)
1772 return "DW_AT value: 0";
1774 /* One value is shared by the MIPS and HP extensions: */
1775 if (attribute
== DW_AT_MIPS_fde
)
1776 return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
1778 name
= get_DW_AT_name (attribute
);
1782 static char buffer
[100];
1784 snprintf (buffer
, sizeof (buffer
), _("Unknown AT value: %lx"),
1793 add_dwo_info (const char * field
, dwo_type type
)
1795 dwo_info
* dwinfo
= xmalloc (sizeof * dwinfo
);
1797 dwinfo
->type
= type
;
1798 dwinfo
->value
= field
;
1799 dwinfo
->next
= first_dwo_info
;
1800 first_dwo_info
= dwinfo
;
1804 add_dwo_name (const char * name
)
1806 add_dwo_info (name
, DWO_NAME
);
1810 add_dwo_dir (const char * dir
)
1812 add_dwo_info (dir
, DWO_DIR
);
1816 add_dwo_id (const char * id
)
1818 add_dwo_info (id
, DWO_ID
);
1822 free_dwo_info (void)
1827 for (dwinfo
= first_dwo_info
; dwinfo
!= NULL
; dwinfo
= next
)
1829 next
= dwinfo
->next
;
1832 first_dwo_info
= NULL
;
1835 /* Ensure that START + UVALUE is less than END.
1836 Return an adjusted UVALUE if necessary to ensure this relationship. */
1838 static inline dwarf_vma
1839 check_uvalue (const unsigned char * start
,
1841 const unsigned char * end
)
1843 dwarf_vma max_uvalue
= end
- start
;
1845 /* FIXME: Testing "(start + uvalue) < start" miscompiles with gcc 4.8.3
1846 running on an x86_64 host in 32-bit mode. So we pre-compute the value
1848 const unsigned char * ptr
= start
+ uvalue
;
1850 /* See PR 17512: file: 008-103549-0.001:0.1.
1851 and PR 24829 for examples of where these tests are triggered. */
1852 if (uvalue
> max_uvalue
1856 warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue
);
1857 uvalue
= max_uvalue
;
1863 static unsigned char *
1864 read_and_display_attr_value (unsigned long attribute
,
1866 dwarf_signed_vma implicit_const
,
1867 unsigned char * data
,
1868 unsigned char * end
,
1869 dwarf_vma cu_offset
,
1870 dwarf_vma pointer_size
,
1871 dwarf_vma offset_size
,
1873 debug_info
* debug_info_p
,
1875 struct dwarf_section
* section
,
1876 struct cu_tu_set
* this_set
,
1879 dwarf_vma uvalue
= 0;
1880 unsigned char *block_start
= NULL
;
1881 unsigned char * orig_data
= data
;
1882 unsigned int bytes_read
;
1884 if (data
> end
|| (data
== end
&& form
!= DW_FORM_flag_present
))
1886 warn (_("Corrupt attribute\n"));
1895 case DW_FORM_ref_addr
:
1896 if (dwarf_version
== 2)
1897 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1898 else if (dwarf_version
== 3 || dwarf_version
== 4)
1899 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1901 error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
1906 SAFE_BYTE_GET_AND_INC (uvalue
, data
, pointer_size
, end
);
1910 case DW_FORM_line_strp
:
1911 case DW_FORM_sec_offset
:
1912 case DW_FORM_GNU_ref_alt
:
1913 case DW_FORM_GNU_strp_alt
:
1914 SAFE_BYTE_GET_AND_INC (uvalue
, data
, offset_size
, end
);
1917 case DW_FORM_flag_present
:
1924 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 1, end
);
1929 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 2, end
);
1934 SAFE_BYTE_GET_AND_INC (uvalue
, data
, 4, end
);
1938 uvalue
= read_sleb128 (data
, & bytes_read
, end
);
1942 case DW_FORM_GNU_str_index
:
1943 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1947 case DW_FORM_ref_udata
:
1949 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1953 case DW_FORM_indirect
:
1954 form
= read_uleb128 (data
, & bytes_read
, end
);
1957 printf ("%c%s", delimiter
, get_FORM_name (form
));
1958 if (form
== DW_FORM_implicit_const
)
1960 implicit_const
= read_sleb128 (data
, & bytes_read
, end
);
1963 return read_and_display_attr_value (attribute
, form
, implicit_const
, data
,
1964 end
, cu_offset
, pointer_size
,
1965 offset_size
, dwarf_version
,
1966 debug_info_p
, do_loc
,
1967 section
, this_set
, delimiter
);
1968 case DW_FORM_GNU_addr_index
:
1969 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
1976 case DW_FORM_ref_addr
:
1978 printf ("%c<0x%s>", delimiter
, dwarf_vmatoa ("x",uvalue
));
1981 case DW_FORM_GNU_ref_alt
:
1983 printf ("%c<alt 0x%s>", delimiter
, dwarf_vmatoa ("x",uvalue
));
1984 /* FIXME: Follow the reference... */
1990 case DW_FORM_ref_udata
:
1992 printf ("%c<0x%s>", delimiter
, dwarf_vmatoa ("x", uvalue
+ cu_offset
));
1997 case DW_FORM_sec_offset
:
1999 printf ("%c0x%s", delimiter
, dwarf_vmatoa ("x", uvalue
));
2002 case DW_FORM_flag_present
:
2009 printf ("%c%s", delimiter
, dwarf_vmatoa ("d", uvalue
));
2012 case DW_FORM_implicit_const
:
2014 printf ("%c%s", delimiter
, dwarf_vmatoa ("d", implicit_const
));
2021 dwarf_vma high_bits
;
2025 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
2027 if (form
== DW_FORM_ref8
)
2028 add64 (& high_bits
, & utmp
, cu_offset
);
2029 printf ("%c0x%s", delimiter
,
2030 dwarf_vmatoa64 (high_bits
, utmp
, buf
, sizeof (buf
)));
2033 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2034 && num_debug_info_entries
== 0)
2036 if (sizeof (uvalue
) == 8)
2037 SAFE_BYTE_GET (uvalue
, data
, 8, end
);
2039 error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
2045 case DW_FORM_data16
:
2048 dwarf_vma left_high_bits
, left_low_bits
;
2049 dwarf_vma right_high_bits
, right_low_bits
;
2051 SAFE_BYTE_GET64 (data
, &left_high_bits
, &left_low_bits
, end
);
2052 SAFE_BYTE_GET64 (data
+ 8, &right_high_bits
, &right_low_bits
, end
);
2053 if (byte_get
== byte_get_little_endian
)
2056 left_high_bits
^= right_high_bits
;
2057 right_high_bits
^= left_high_bits
;
2058 left_high_bits
^= right_high_bits
;
2059 left_low_bits
^= right_low_bits
;
2060 right_low_bits
^= left_low_bits
;
2061 left_low_bits
^= right_low_bits
;
2063 printf (" 0x%08" DWARF_VMA_FMT
"x%08" DWARF_VMA_FMT
"x"
2064 "%08" DWARF_VMA_FMT
"x%08" DWARF_VMA_FMT
"x",
2065 left_high_bits
, left_low_bits
, right_high_bits
,
2071 case DW_FORM_string
:
2073 printf ("%c%.*s", delimiter
, (int) (end
- data
), data
);
2074 data
+= strnlen ((char *) data
, end
- data
) + 1;
2078 case DW_FORM_exprloc
:
2079 uvalue
= read_uleb128 (data
, & bytes_read
, end
);
2080 block_start
= data
+ bytes_read
;
2081 if (block_start
>= end
)
2083 warn (_("Block ends prematurely\n"));
2088 uvalue
= check_uvalue (block_start
, uvalue
, end
);
2091 data
= block_start
+ uvalue
;
2093 data
= display_block (block_start
, uvalue
, end
, delimiter
);
2096 case DW_FORM_block1
:
2097 SAFE_BYTE_GET (uvalue
, data
, 1, end
);
2098 block_start
= data
+ 1;
2099 if (block_start
>= end
)
2101 warn (_("Block ends prematurely\n"));
2106 uvalue
= check_uvalue (block_start
, uvalue
, end
);
2109 data
= block_start
+ uvalue
;
2111 data
= display_block (block_start
, uvalue
, end
, delimiter
);
2114 case DW_FORM_block2
:
2115 SAFE_BYTE_GET (uvalue
, data
, 2, end
);
2116 block_start
= data
+ 2;
2117 if (block_start
>= end
)
2119 warn (_("Block ends prematurely\n"));
2124 uvalue
= check_uvalue (block_start
, uvalue
, end
);
2127 data
= block_start
+ uvalue
;
2129 data
= display_block (block_start
, uvalue
, end
, delimiter
);
2132 case DW_FORM_block4
:
2133 SAFE_BYTE_GET (uvalue
, data
, 4, end
);
2134 block_start
= data
+ 4;
2135 /* PR 17512: file: 3371-3907-0.004. */
2136 if (block_start
>= end
)
2138 warn (_("Block ends prematurely\n"));
2143 uvalue
= check_uvalue (block_start
, uvalue
, end
);
2146 data
= block_start
+ uvalue
;
2148 data
= display_block (block_start
, uvalue
, end
, delimiter
);
2153 printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter
,
2154 dwarf_vmatoa ("x", uvalue
),
2155 fetch_indirect_string (uvalue
));
2158 case DW_FORM_line_strp
:
2160 printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter
,
2161 dwarf_vmatoa ("x", uvalue
),
2162 fetch_indirect_line_string (uvalue
));
2165 case DW_FORM_GNU_str_index
:
2168 const char * suffix
= strrchr (section
->name
, '.');
2169 bfd_boolean dwo
= (suffix
&& strcmp (suffix
, ".dwo") == 0) ? TRUE
: FALSE
;
2171 printf (_("%c(indexed string: 0x%s): %s"), delimiter
,
2172 dwarf_vmatoa ("x", uvalue
),
2173 fetch_indexed_string (uvalue
, this_set
, offset_size
, dwo
));
2177 case DW_FORM_GNU_strp_alt
:
2180 printf (_("%c(alt indirect string, offset: 0x%s) %s"), delimiter
,
2181 dwarf_vmatoa ("x", uvalue
),
2182 fetch_alt_indirect_string (uvalue
));
2186 case DW_FORM_indirect
:
2187 /* Handled above. */
2190 case DW_FORM_ref_sig8
:
2193 dwarf_vma high_bits
;
2196 SAFE_BYTE_GET64 (data
, &high_bits
, &uvalue
, end
);
2197 printf ("%csignature: 0x%s", delimiter
,
2198 dwarf_vmatoa64 (high_bits
, uvalue
, buf
, sizeof (buf
)));
2203 case DW_FORM_GNU_addr_index
:
2205 printf (_("%c(addr_index: 0x%s): %s"), delimiter
,
2206 dwarf_vmatoa ("x", uvalue
),
2207 fetch_indexed_value (uvalue
* pointer_size
, pointer_size
));
2211 warn (_("Unrecognized form: %lu\n"), form
);
2215 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2216 && num_debug_info_entries
== 0
2217 && debug_info_p
!= NULL
)
2221 case DW_AT_frame_base
:
2222 have_frame_base
= 1;
2224 case DW_AT_location
:
2225 case DW_AT_GNU_locviews
:
2226 case DW_AT_string_length
:
2227 case DW_AT_return_addr
:
2228 case DW_AT_data_member_location
:
2229 case DW_AT_vtable_elem_location
:
2231 case DW_AT_static_link
:
2232 case DW_AT_use_location
:
2233 case DW_AT_call_value
:
2234 case DW_AT_GNU_call_site_value
:
2235 case DW_AT_call_data_value
:
2236 case DW_AT_GNU_call_site_data_value
:
2237 case DW_AT_call_target
:
2238 case DW_AT_GNU_call_site_target
:
2239 case DW_AT_call_target_clobbered
:
2240 case DW_AT_GNU_call_site_target_clobbered
:
2241 if ((dwarf_version
< 4
2242 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
2243 || form
== DW_FORM_sec_offset
)
2245 /* Process location list. */
2246 unsigned int lmax
= debug_info_p
->max_loc_offsets
;
2247 unsigned int num
= debug_info_p
->num_loc_offsets
;
2249 if (lmax
== 0 || num
>= lmax
)
2252 debug_info_p
->loc_offsets
= (dwarf_vma
*)
2253 xcrealloc (debug_info_p
->loc_offsets
,
2254 lmax
, sizeof (*debug_info_p
->loc_offsets
));
2255 debug_info_p
->loc_views
= (dwarf_vma
*)
2256 xcrealloc (debug_info_p
->loc_views
,
2257 lmax
, sizeof (*debug_info_p
->loc_views
));
2258 debug_info_p
->have_frame_base
= (int *)
2259 xcrealloc (debug_info_p
->have_frame_base
,
2260 lmax
, sizeof (*debug_info_p
->have_frame_base
));
2261 debug_info_p
->max_loc_offsets
= lmax
;
2263 if (this_set
!= NULL
)
2264 uvalue
+= this_set
->section_offsets
[DW_SECT_LOC
];
2265 debug_info_p
->have_frame_base
[num
] = have_frame_base
;
2266 if (attribute
!= DW_AT_GNU_locviews
)
2268 /* Corrupt DWARF info can produce more offsets than views.
2269 See PR 23062 for an example. */
2270 if (debug_info_p
->num_loc_offsets
2271 > debug_info_p
->num_loc_views
)
2272 warn (_("More location offset attributes than DW_AT_GNU_locview attributes\n"));
2275 debug_info_p
->loc_offsets
[num
] = uvalue
;
2276 debug_info_p
->num_loc_offsets
++;
2281 assert (debug_info_p
->num_loc_views
<= num
);
2282 num
= debug_info_p
->num_loc_views
;
2283 if (num
> debug_info_p
->num_loc_offsets
)
2284 warn (_("More DW_AT_GNU_locview attributes than location offset attributes\n"));
2287 debug_info_p
->loc_views
[num
] = uvalue
;
2288 debug_info_p
->num_loc_views
++;
2295 if (need_base_address
)
2296 debug_info_p
->base_address
= uvalue
;
2299 case DW_AT_GNU_addr_base
:
2300 debug_info_p
->addr_base
= uvalue
;
2303 case DW_AT_GNU_ranges_base
:
2304 debug_info_p
->ranges_base
= uvalue
;
2308 if ((dwarf_version
< 4
2309 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
2310 || form
== DW_FORM_sec_offset
)
2312 /* Process range list. */
2313 unsigned int lmax
= debug_info_p
->max_range_lists
;
2314 unsigned int num
= debug_info_p
->num_range_lists
;
2316 if (lmax
== 0 || num
>= lmax
)
2319 debug_info_p
->range_lists
= (dwarf_vma
*)
2320 xcrealloc (debug_info_p
->range_lists
,
2321 lmax
, sizeof (*debug_info_p
->range_lists
));
2322 debug_info_p
->max_range_lists
= lmax
;
2324 debug_info_p
->range_lists
[num
] = uvalue
;
2325 debug_info_p
->num_range_lists
++;
2329 case DW_AT_GNU_dwo_name
:
2330 case DW_AT_dwo_name
:
2335 add_dwo_name ((const char *) fetch_indirect_string (uvalue
));
2337 case DW_FORM_GNU_str_index
:
2338 add_dwo_name (fetch_indexed_string (uvalue
, this_set
, offset_size
, FALSE
));
2340 case DW_FORM_string
:
2341 add_dwo_name ((const char *) orig_data
);
2344 warn (_("Unsupported form (%s) for attribute %s\n"),
2345 get_FORM_name (form
), get_AT_name (attribute
));
2350 case DW_AT_comp_dir
:
2351 /* FIXME: Also extract a build-id in a CU/TU. */
2356 add_dwo_dir ((const char *) fetch_indirect_string (uvalue
));
2358 case DW_FORM_line_strp
:
2359 add_dwo_dir ((const char *) fetch_indirect_line_string (uvalue
));
2361 case DW_FORM_GNU_str_index
:
2362 add_dwo_dir (fetch_indexed_string (uvalue
, this_set
, offset_size
, FALSE
));
2364 case DW_FORM_string
:
2365 add_dwo_dir ((const char *) orig_data
);
2368 warn (_("Unsupported form (%s) for attribute %s\n"),
2369 get_FORM_name (form
), get_AT_name (attribute
));
2374 case DW_AT_GNU_dwo_id
:
2379 /* FIXME: Record the length of the ID as well ? */
2380 add_dwo_id ((const char *) (data
- 8));
2383 warn (_("Unsupported form (%s) for attribute %s\n"),
2384 get_FORM_name (form
), get_AT_name (attribute
));
2394 if (do_loc
|| attribute
== 0)
2397 /* For some attributes we can display further information. */
2404 case DW_INL_not_inlined
:
2405 printf (_("(not inlined)"));
2407 case DW_INL_inlined
:
2408 printf (_("(inlined)"));
2410 case DW_INL_declared_not_inlined
:
2411 printf (_("(declared as inline but ignored)"));
2413 case DW_INL_declared_inlined
:
2414 printf (_("(declared as inline and inlined)"));
2417 printf (_(" (Unknown inline attribute value: %s)"),
2418 dwarf_vmatoa ("x", uvalue
));
2423 case DW_AT_language
:
2427 /* Ordered by the numeric value of these constants. */
2428 case DW_LANG_C89
: printf ("(ANSI C)"); break;
2429 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
2430 case DW_LANG_Ada83
: printf ("(Ada)"); break;
2431 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
2432 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
2433 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
2434 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
2435 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
2436 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
2437 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
2438 /* DWARF 2.1 values. */
2439 case DW_LANG_Java
: printf ("(Java)"); break;
2440 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
2441 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
2442 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
2443 /* DWARF 3 values. */
2444 case DW_LANG_PLI
: printf ("(PLI)"); break;
2445 case DW_LANG_ObjC
: printf ("(Objective C)"); break;
2446 case DW_LANG_ObjC_plus_plus
: printf ("(Objective C++)"); break;
2447 case DW_LANG_UPC
: printf ("(Unified Parallel C)"); break;
2448 case DW_LANG_D
: printf ("(D)"); break;
2449 /* DWARF 4 values. */
2450 case DW_LANG_Python
: printf ("(Python)"); break;
2451 /* DWARF 5 values. */
2452 case DW_LANG_OpenCL
: printf ("(OpenCL)"); break;
2453 case DW_LANG_Go
: printf ("(Go)"); break;
2454 case DW_LANG_Modula3
: printf ("(Modula 3)"); break;
2455 case DW_LANG_Haskell
: printf ("(Haskell)"); break;
2456 case DW_LANG_C_plus_plus_03
: printf ("(C++03)"); break;
2457 case DW_LANG_C_plus_plus_11
: printf ("(C++11)"); break;
2458 case DW_LANG_OCaml
: printf ("(OCaml)"); break;
2459 case DW_LANG_Rust
: printf ("(Rust)"); break;
2460 case DW_LANG_C11
: printf ("(C11)"); break;
2461 case DW_LANG_Swift
: printf ("(Swift)"); break;
2462 case DW_LANG_Julia
: printf ("(Julia)"); break;
2463 case DW_LANG_Dylan
: printf ("(Dylan)"); break;
2464 case DW_LANG_C_plus_plus_14
: printf ("(C++14)"); break;
2465 case DW_LANG_Fortran03
: printf ("(Fortran 03)"); break;
2466 case DW_LANG_Fortran08
: printf ("(Fortran 08)"); break;
2467 case DW_LANG_RenderScript
: printf ("(RenderScript)"); break;
2468 /* MIPS extension. */
2469 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
2470 /* UPC extension. */
2471 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
2473 if (uvalue
>= DW_LANG_lo_user
&& uvalue
<= DW_LANG_hi_user
)
2474 printf (_("(implementation defined: %s)"),
2475 dwarf_vmatoa ("x", uvalue
));
2477 printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue
));
2482 case DW_AT_encoding
:
2486 case DW_ATE_void
: printf ("(void)"); break;
2487 case DW_ATE_address
: printf ("(machine address)"); break;
2488 case DW_ATE_boolean
: printf ("(boolean)"); break;
2489 case DW_ATE_complex_float
: printf ("(complex float)"); break;
2490 case DW_ATE_float
: printf ("(float)"); break;
2491 case DW_ATE_signed
: printf ("(signed)"); break;
2492 case DW_ATE_signed_char
: printf ("(signed char)"); break;
2493 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
2494 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
2495 /* DWARF 2.1 values: */
2496 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
2497 case DW_ATE_decimal_float
: printf ("(decimal float)"); break;
2498 /* DWARF 3 values: */
2499 case DW_ATE_packed_decimal
: printf ("(packed_decimal)"); break;
2500 case DW_ATE_numeric_string
: printf ("(numeric_string)"); break;
2501 case DW_ATE_edited
: printf ("(edited)"); break;
2502 case DW_ATE_signed_fixed
: printf ("(signed_fixed)"); break;
2503 case DW_ATE_unsigned_fixed
: printf ("(unsigned_fixed)"); break;
2504 /* DWARF 4 values: */
2505 case DW_ATE_UTF
: printf ("(unicode string)"); break;
2506 /* DWARF 5 values: */
2507 case DW_ATE_UCS
: printf ("(UCS)"); break;
2508 case DW_ATE_ASCII
: printf ("(ASCII)"); break;
2510 /* HP extensions: */
2511 case DW_ATE_HP_float80
: printf ("(HP_float80)"); break;
2512 case DW_ATE_HP_complex_float80
: printf ("(HP_complex_float80)"); break;
2513 case DW_ATE_HP_float128
: printf ("(HP_float128)"); break;
2514 case DW_ATE_HP_complex_float128
:printf ("(HP_complex_float128)"); break;
2515 case DW_ATE_HP_floathpintel
: printf ("(HP_floathpintel)"); break;
2516 case DW_ATE_HP_imaginary_float80
: printf ("(HP_imaginary_float80)"); break;
2517 case DW_ATE_HP_imaginary_float128
: printf ("(HP_imaginary_float128)"); break;
2520 if (uvalue
>= DW_ATE_lo_user
2521 && uvalue
<= DW_ATE_hi_user
)
2522 printf (_("(user defined type)"));
2524 printf (_("(unknown type)"));
2529 case DW_AT_accessibility
:
2533 case DW_ACCESS_public
: printf ("(public)"); break;
2534 case DW_ACCESS_protected
: printf ("(protected)"); break;
2535 case DW_ACCESS_private
: printf ("(private)"); break;
2537 printf (_("(unknown accessibility)"));
2542 case DW_AT_visibility
:
2546 case DW_VIS_local
: printf ("(local)"); break;
2547 case DW_VIS_exported
: printf ("(exported)"); break;
2548 case DW_VIS_qualified
: printf ("(qualified)"); break;
2549 default: printf (_("(unknown visibility)")); break;
2553 case DW_AT_endianity
:
2557 case DW_END_default
: printf ("(default)"); break;
2558 case DW_END_big
: printf ("(big)"); break;
2559 case DW_END_little
: printf ("(little)"); break;
2561 if (uvalue
>= DW_END_lo_user
&& uvalue
<= DW_END_hi_user
)
2562 printf (_("(user specified)"));
2564 printf (_("(unknown endianity)"));
2569 case DW_AT_virtuality
:
2573 case DW_VIRTUALITY_none
: printf ("(none)"); break;
2574 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
2575 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
2576 default: printf (_("(unknown virtuality)")); break;
2580 case DW_AT_identifier_case
:
2584 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
2585 case DW_ID_up_case
: printf ("(up_case)"); break;
2586 case DW_ID_down_case
: printf ("(down_case)"); break;
2587 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
2588 default: printf (_("(unknown case)")); break;
2592 case DW_AT_calling_convention
:
2596 case DW_CC_normal
: printf ("(normal)"); break;
2597 case DW_CC_program
: printf ("(program)"); break;
2598 case DW_CC_nocall
: printf ("(nocall)"); break;
2599 case DW_CC_pass_by_reference
: printf ("(pass by ref)"); break;
2600 case DW_CC_pass_by_value
: printf ("(pass by value)"); break;
2601 case DW_CC_GNU_renesas_sh
: printf ("(Rensas SH)"); break;
2602 case DW_CC_GNU_borland_fastcall_i386
: printf ("(Borland fastcall i386)"); break;
2604 if (uvalue
>= DW_CC_lo_user
2605 && uvalue
<= DW_CC_hi_user
)
2606 printf (_("(user defined)"));
2608 printf (_("(unknown convention)"));
2612 case DW_AT_ordering
:
2617 case -1: printf (_("(undefined)")); break;
2618 case 0: printf ("(row major)"); break;
2619 case 1: printf ("(column major)"); break;
2623 case DW_AT_decimal_sign
:
2627 case DW_DS_unsigned
: printf (_("(unsigned)")); break;
2628 case DW_DS_leading_overpunch
: printf (_("(leading overpunch)")); break;
2629 case DW_DS_trailing_overpunch
: printf (_("(trailing overpunch)")); break;
2630 case DW_DS_leading_separate
: printf (_("(leading separate)")); break;
2631 case DW_DS_trailing_separate
: printf (_("(trailing separate)")); break;
2632 default: printf (_("(unrecognised)")); break;
2636 case DW_AT_defaulted
:
2640 case DW_DEFAULTED_no
: printf (_("(no)")); break;
2641 case DW_DEFAULTED_in_class
: printf (_("(in class)")); break;
2642 case DW_DEFAULTED_out_of_class
: printf (_("(out of class)")); break;
2643 default: printf (_("(unrecognised)")); break;
2647 case DW_AT_discr_list
:
2651 case DW_DSC_label
: printf (_("(label)")); break;
2652 case DW_DSC_range
: printf (_("(range)")); break;
2653 default: printf (_("(unrecognised)")); break;
2657 case DW_AT_frame_base
:
2658 have_frame_base
= 1;
2660 case DW_AT_location
:
2661 case DW_AT_string_length
:
2662 case DW_AT_return_addr
:
2663 case DW_AT_data_member_location
:
2664 case DW_AT_vtable_elem_location
:
2666 case DW_AT_static_link
:
2667 case DW_AT_use_location
:
2668 case DW_AT_call_value
:
2669 case DW_AT_GNU_call_site_value
:
2670 case DW_AT_call_data_value
:
2671 case DW_AT_GNU_call_site_data_value
:
2672 case DW_AT_call_target
:
2673 case DW_AT_GNU_call_site_target
:
2674 case DW_AT_call_target_clobbered
:
2675 case DW_AT_GNU_call_site_target_clobbered
:
2676 if ((dwarf_version
< 4
2677 && (form
== DW_FORM_data4
|| form
== DW_FORM_data8
))
2678 || form
== DW_FORM_sec_offset
)
2679 printf (_(" (location list)"));
2681 case DW_AT_allocated
:
2682 case DW_AT_associated
:
2683 case DW_AT_data_location
:
2685 case DW_AT_upper_bound
:
2686 case DW_AT_lower_bound
:
2689 int need_frame_base
;
2692 need_frame_base
= decode_location_expression (block_start
,
2697 cu_offset
, section
);
2699 if (need_frame_base
&& !have_frame_base
)
2700 printf (_(" [without DW_AT_frame_base]"));
2704 case DW_AT_data_bit_offset
:
2705 case DW_AT_byte_size
:
2706 case DW_AT_bit_size
:
2707 case DW_AT_string_length_byte_size
:
2708 case DW_AT_string_length_bit_size
:
2709 case DW_AT_bit_stride
:
2710 if (form
== DW_FORM_exprloc
)
2713 (void) decode_location_expression (block_start
, pointer_size
,
2714 offset_size
, dwarf_version
,
2715 uvalue
, cu_offset
, section
);
2722 if (form
== DW_FORM_ref_sig8
2723 || form
== DW_FORM_GNU_ref_alt
)
2726 if (form
== DW_FORM_ref1
2727 || form
== DW_FORM_ref2
2728 || form
== DW_FORM_ref4
2729 || form
== DW_FORM_ref_udata
)
2730 uvalue
+= cu_offset
;
2732 if (uvalue
>= section
->size
)
2733 warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset 0x%lx is too big.\n"),
2734 dwarf_vmatoa ("x", uvalue
),
2735 (unsigned long) (orig_data
- section
->start
));
2738 unsigned long abbrev_number
;
2739 abbrev_entry
* entry
;
2741 abbrev_number
= read_uleb128 (section
->start
+ uvalue
, NULL
, end
);
2743 printf (_("\t[Abbrev Number: %ld"), abbrev_number
);
2744 /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
2745 use different abbrev table, and we don't track .debug_info chunks
2747 if (form
!= DW_FORM_ref_addr
)
2749 for (entry
= first_abbrev
; entry
!= NULL
; entry
= entry
->next
)
2750 if (entry
->entry
== abbrev_number
)
2753 printf (" (%s)", get_TAG_name (entry
->tag
));
2767 static unsigned char *
2768 read_and_display_attr (unsigned long attribute
,
2770 dwarf_signed_vma implicit_const
,
2771 unsigned char * data
,
2772 unsigned char * end
,
2773 dwarf_vma cu_offset
,
2774 dwarf_vma pointer_size
,
2775 dwarf_vma offset_size
,
2777 debug_info
* debug_info_p
,
2779 struct dwarf_section
* section
,
2780 struct cu_tu_set
* this_set
)
2783 printf (" %-18s:", get_AT_name (attribute
));
2784 data
= read_and_display_attr_value (attribute
, form
, implicit_const
, data
, end
,
2785 cu_offset
, pointer_size
, offset_size
,
2786 dwarf_version
, debug_info_p
,
2787 do_loc
, section
, this_set
, ' ');
2793 /* Like load_debug_section, but if the ordinary call fails, and we are
2794 following debug links, then attempt to load the requested section
2795 from one of the separate debug info files. */
2798 load_debug_section_with_follow (enum dwarf_section_display_enum sec_enum
,
2801 if (load_debug_section (sec_enum
, handle
))
2803 if (debug_displays
[sec_enum
].section
.filename
== NULL
)
2805 /* See if we can associate a filename with this section. */
2808 for (i
= first_separate_info
; i
!= NULL
; i
= i
->next
)
2809 if (i
->handle
== handle
)
2811 debug_displays
[sec_enum
].section
.filename
= i
->filename
;
2819 if (do_follow_links
)
2823 for (i
= first_separate_info
; i
!= NULL
; i
= i
->next
)
2825 if (load_debug_section (sec_enum
, i
->handle
))
2827 debug_displays
[sec_enum
].section
.filename
= i
->filename
;
2829 /* FIXME: We should check to see if any of the remaining debug info
2830 files also contain this section, and, umm, do something about it. */
2840 introduce (struct dwarf_section
* section
, bfd_boolean raw
)
2844 if (do_follow_links
&& section
->filename
)
2845 printf (_("Raw dump of debug contents of section %s (loaded from %s):\n\n"),
2846 section
->name
, section
->filename
);
2848 printf (_("Raw dump of debug contents of section %s:\n\n"), section
->name
);
2852 if (do_follow_links
&& section
->filename
)
2853 printf (_("Contents of the %s section (loaded from %s):\n\n"),
2854 section
->name
, section
->filename
);
2856 printf (_("Contents of the %s section:\n\n"), section
->name
);
2860 /* Process the contents of a .debug_info section.
2861 If do_loc is TRUE then we are scanning for location lists and dwo tags
2862 and we do not want to display anything to the user.
2863 If do_types is TRUE, we are processing a .debug_types section instead of
2864 a .debug_info section.
2865 The information displayed is restricted by the values in DWARF_START_DIE
2866 and DWARF_CUTOFF_LEVEL.
2867 Returns TRUE upon success. Otherwise an error or warning message is
2868 printed and FALSE is returned. */
2871 process_debug_info (struct dwarf_section
* section
,
2873 enum dwarf_section_display_enum abbrev_sec
,
2875 bfd_boolean do_types
)
2877 unsigned char *start
= section
->start
;
2878 unsigned char *end
= start
+ section
->size
;
2879 unsigned char *section_begin
;
2881 unsigned int num_units
= 0;
2883 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
2884 && num_debug_info_entries
== 0
2889 /* First scan the section to get the number of comp units. */
2890 for (section_begin
= start
, num_units
= 0; section_begin
< end
;
2893 /* Read the first 4 bytes. For a 32-bit DWARF section, this
2894 will be the length. For a 64-bit DWARF section, it'll be
2895 the escape code 0xffffffff followed by an 8 byte length. */
2896 SAFE_BYTE_GET (length
, section_begin
, 4, end
);
2898 if (length
== 0xffffffff)
2900 SAFE_BYTE_GET (length
, section_begin
+ 4, 8, end
);
2901 section_begin
+= length
+ 12;
2903 else if (length
>= 0xfffffff0 && length
< 0xffffffff)
2905 warn (_("Reserved length value (0x%s) found in section %s\n"),
2906 dwarf_vmatoa ("x", length
), section
->name
);
2910 section_begin
+= length
+ 4;
2912 /* Negative values are illegal, they may even cause infinite
2913 looping. This can happen if we can't accurately apply
2914 relocations to an object file, or if the file is corrupt. */
2915 if ((signed long) length
<= 0 || section_begin
< start
)
2917 warn (_("Corrupt unit length (0x%s) found in section %s\n"),
2918 dwarf_vmatoa ("x", length
), section
->name
);
2925 error (_("No comp units in %s section ?\n"), section
->name
);
2929 /* Then allocate an array to hold the information. */
2930 debug_information
= (debug_info
*) cmalloc (num_units
,
2931 sizeof (* debug_information
));
2932 if (debug_information
== NULL
)
2934 error (_("Not enough memory for a debug info array of %u entries\n"),
2936 alloc_num_debug_info_entries
= num_debug_info_entries
= 0;
2940 /* PR 17531: file: 92ca3797.
2941 We cannot rely upon the debug_information array being initialised
2942 before it is used. A corrupt file could easily contain references
2943 to a unit for which information has not been made available. So
2944 we ensure that the array is zeroed here. */
2945 memset (debug_information
, 0, num_units
* sizeof (*debug_information
));
2947 alloc_num_debug_info_entries
= num_units
;
2952 load_debug_section_with_follow (str
, file
);
2953 load_debug_section_with_follow (line_str
, file
);
2954 load_debug_section_with_follow (str_dwo
, file
);
2955 load_debug_section_with_follow (str_index
, file
);
2956 load_debug_section_with_follow (str_index_dwo
, file
);
2957 load_debug_section_with_follow (debug_addr
, file
);
2960 load_debug_section_with_follow (abbrev_sec
, file
);
2961 if (debug_displays
[abbrev_sec
].section
.start
== NULL
)
2963 warn (_("Unable to locate %s section!\n"),
2964 debug_displays
[abbrev_sec
].section
.uncompressed_name
);
2968 if (!do_loc
&& dwarf_start_die
== 0)
2969 introduce (section
, FALSE
);
2971 for (section_begin
= start
, unit
= 0; start
< end
; unit
++)
2973 DWARF2_Internal_CompUnit compunit
;
2974 unsigned char *hdrptr
;
2975 unsigned char *tags
;
2976 int level
, last_level
, saved_level
;
2977 dwarf_vma cu_offset
;
2978 unsigned long sec_off
;
2979 unsigned int offset_size
;
2980 unsigned int initial_length_size
;
2981 dwarf_vma signature_high
= 0;
2982 dwarf_vma signature_low
= 0;
2983 dwarf_vma type_offset
= 0;
2984 struct cu_tu_set
*this_set
;
2985 dwarf_vma abbrev_base
;
2990 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 4, end
);
2992 if (compunit
.cu_length
== 0xffffffff)
2994 SAFE_BYTE_GET_AND_INC (compunit
.cu_length
, hdrptr
, 8, end
);
2996 initial_length_size
= 12;
3001 initial_length_size
= 4;
3004 SAFE_BYTE_GET_AND_INC (compunit
.cu_version
, hdrptr
, 2, end
);
3006 cu_offset
= start
- section_begin
;
3008 this_set
= find_cu_tu_set_v2 (cu_offset
, do_types
);
3010 if (compunit
.cu_version
< 5)
3012 compunit
.cu_unit_type
= DW_UT_compile
;
3013 /* Initialize it due to a false compiler warning. */
3014 compunit
.cu_pointer_size
= -1;
3018 SAFE_BYTE_GET_AND_INC (compunit
.cu_unit_type
, hdrptr
, 1, end
);
3019 do_types
= (compunit
.cu_unit_type
== DW_UT_type
);
3021 SAFE_BYTE_GET_AND_INC (compunit
.cu_pointer_size
, hdrptr
, 1, end
);
3024 SAFE_BYTE_GET_AND_INC (compunit
.cu_abbrev_offset
, hdrptr
, offset_size
, end
);
3026 if (this_set
== NULL
)
3029 abbrev_size
= debug_displays
[abbrev_sec
].section
.size
;
3033 abbrev_base
= this_set
->section_offsets
[DW_SECT_ABBREV
];
3034 abbrev_size
= this_set
->section_sizes
[DW_SECT_ABBREV
];
3037 if (compunit
.cu_version
< 5)
3038 SAFE_BYTE_GET_AND_INC (compunit
.cu_pointer_size
, hdrptr
, 1, end
);
3040 /* PR 17512: file: 001-108546-0.001:0.1. */
3041 if (compunit
.cu_pointer_size
< 2 || compunit
.cu_pointer_size
> 8)
3043 warn (_("Invalid pointer size (%d) in compunit header, using %d instead\n"),
3044 compunit
.cu_pointer_size
, offset_size
);
3045 compunit
.cu_pointer_size
= offset_size
;
3050 SAFE_BYTE_GET64 (hdrptr
, &signature_high
, &signature_low
, end
);
3052 SAFE_BYTE_GET_AND_INC (type_offset
, hdrptr
, offset_size
, end
);
3055 if (dwarf_start_die
> (cu_offset
+ compunit
.cu_length
3056 + initial_length_size
))
3058 start
= section_begin
+ cu_offset
+ compunit
.cu_length
3059 + initial_length_size
;
3063 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
3064 && num_debug_info_entries
== 0
3067 debug_information
[unit
].cu_offset
= cu_offset
;
3068 debug_information
[unit
].pointer_size
3069 = compunit
.cu_pointer_size
;
3070 debug_information
[unit
].offset_size
= offset_size
;
3071 debug_information
[unit
].dwarf_version
= compunit
.cu_version
;
3072 debug_information
[unit
].base_address
= 0;
3073 debug_information
[unit
].addr_base
= DEBUG_INFO_UNAVAILABLE
;
3074 debug_information
[unit
].ranges_base
= DEBUG_INFO_UNAVAILABLE
;
3075 debug_information
[unit
].loc_offsets
= NULL
;
3076 debug_information
[unit
].have_frame_base
= NULL
;
3077 debug_information
[unit
].max_loc_offsets
= 0;
3078 debug_information
[unit
].num_loc_offsets
= 0;
3079 debug_information
[unit
].range_lists
= NULL
;
3080 debug_information
[unit
].max_range_lists
= 0;
3081 debug_information
[unit
].num_range_lists
= 0;
3084 if (!do_loc
&& dwarf_start_die
== 0)
3086 printf (_(" Compilation Unit @ offset 0x%s:\n"),
3087 dwarf_vmatoa ("x", cu_offset
));
3088 printf (_(" Length: 0x%s (%s)\n"),
3089 dwarf_vmatoa ("x", compunit
.cu_length
),
3090 offset_size
== 8 ? "64-bit" : "32-bit");
3091 printf (_(" Version: %d\n"), compunit
.cu_version
);
3092 printf (_(" Abbrev Offset: 0x%s\n"),
3093 dwarf_vmatoa ("x", compunit
.cu_abbrev_offset
));
3094 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
3099 printf (_(" Signature: 0x%s\n"),
3100 dwarf_vmatoa64 (signature_high
, signature_low
,
3101 buf
, sizeof (buf
)));
3102 printf (_(" Type Offset: 0x%s\n"),
3103 dwarf_vmatoa ("x", type_offset
));
3105 if (this_set
!= NULL
)
3107 dwarf_vma
*offsets
= this_set
->section_offsets
;
3108 size_t *sizes
= this_set
->section_sizes
;
3110 printf (_(" Section contributions:\n"));
3111 printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"),
3112 dwarf_vmatoa ("x", offsets
[DW_SECT_ABBREV
]),
3113 dwarf_vmatoa ("x", sizes
[DW_SECT_ABBREV
]));
3114 printf (_(" .debug_line.dwo: 0x%s 0x%s\n"),
3115 dwarf_vmatoa ("x", offsets
[DW_SECT_LINE
]),
3116 dwarf_vmatoa ("x", sizes
[DW_SECT_LINE
]));
3117 printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"),
3118 dwarf_vmatoa ("x", offsets
[DW_SECT_LOC
]),
3119 dwarf_vmatoa ("x", sizes
[DW_SECT_LOC
]));
3120 printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"),
3121 dwarf_vmatoa ("x", offsets
[DW_SECT_STR_OFFSETS
]),
3122 dwarf_vmatoa ("x", sizes
[DW_SECT_STR_OFFSETS
]));
3126 sec_off
= cu_offset
+ initial_length_size
;
3127 if (sec_off
+ compunit
.cu_length
< sec_off
3128 || sec_off
+ compunit
.cu_length
> section
->size
)
3130 warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"),
3132 (unsigned long) cu_offset
,
3133 dwarf_vmatoa ("x", compunit
.cu_length
));
3139 start
+= compunit
.cu_length
+ initial_length_size
;
3141 if (compunit
.cu_version
< 2 || compunit
.cu_version
> 5)
3143 warn (_("CU at offset %s contains corrupt or "
3144 "unsupported version number: %d.\n"),
3145 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_version
);
3149 if (compunit
.cu_unit_type
!= DW_UT_compile
3150 && compunit
.cu_unit_type
!= DW_UT_type
)
3152 warn (_("CU at offset %s contains corrupt or "
3153 "unsupported unit type: %d.\n"),
3154 dwarf_vmatoa ("x", cu_offset
), compunit
.cu_unit_type
);
3160 /* Process the abbrevs used by this compilation unit. */
3161 if (compunit
.cu_abbrev_offset
>= abbrev_size
)
3162 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
3163 (unsigned long) compunit
.cu_abbrev_offset
,
3164 (unsigned long) abbrev_size
);
3165 /* PR 17531: file:4bcd9ce9. */
3166 else if ((abbrev_base
+ abbrev_size
)
3167 > debug_displays
[abbrev_sec
].section
.size
)
3168 warn (_("Debug info is corrupted, abbrev size (%lx) is larger than abbrev section size (%lx)\n"),
3169 (unsigned long) abbrev_base
+ abbrev_size
,
3170 (unsigned long) debug_displays
[abbrev_sec
].section
.size
);
3172 process_abbrev_section
3173 (((unsigned char *) debug_displays
[abbrev_sec
].section
.start
3174 + abbrev_base
+ compunit
.cu_abbrev_offset
),
3175 ((unsigned char *) debug_displays
[abbrev_sec
].section
.start
3176 + abbrev_base
+ abbrev_size
));
3181 while (tags
< start
)
3183 unsigned int bytes_read
;
3184 unsigned long abbrev_number
;
3185 unsigned long die_offset
;
3186 abbrev_entry
*entry
;
3188 int do_printing
= 1;
3190 die_offset
= tags
- section_begin
;
3192 abbrev_number
= read_uleb128 (tags
, & bytes_read
, start
);
3195 /* A null DIE marks the end of a list of siblings or it may also be
3196 a section padding. */
3197 if (abbrev_number
== 0)
3199 /* Check if it can be a section padding for the last CU. */
3200 if (level
== 0 && start
== end
)
3204 for (chk
= tags
; chk
< start
; chk
++)
3211 if (!do_loc
&& die_offset
>= dwarf_start_die
3212 && (dwarf_cutoff_level
== -1
3213 || level
< dwarf_cutoff_level
))
3214 printf (_(" <%d><%lx>: Abbrev Number: 0\n"),
3220 static unsigned num_bogus_warns
= 0;
3222 if (num_bogus_warns
< 3)
3224 warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"),
3225 die_offset
, section
->name
);
3227 if (num_bogus_warns
== 3)
3228 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
3231 if (dwarf_start_die
!= 0 && level
< saved_level
)
3238 if (dwarf_start_die
!= 0 && die_offset
< dwarf_start_die
)
3242 if (dwarf_start_die
!= 0 && die_offset
== dwarf_start_die
)
3243 saved_level
= level
;
3244 do_printing
= (dwarf_cutoff_level
== -1
3245 || level
< dwarf_cutoff_level
);
3247 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
3248 level
, die_offset
, abbrev_number
);
3249 else if (dwarf_cutoff_level
== -1
3250 || last_level
< dwarf_cutoff_level
)
3251 printf (_(" <%d><%lx>: ...\n"), level
, die_offset
);
3256 /* Scan through the abbreviation list until we reach the
3258 for (entry
= first_abbrev
;
3259 entry
&& entry
->entry
!= abbrev_number
;
3260 entry
= entry
->next
)
3265 if (!do_loc
&& do_printing
)
3270 warn (_("DIE at offset 0x%lx refers to abbreviation number %lu which does not exist\n"),
3271 die_offset
, abbrev_number
);
3275 if (!do_loc
&& do_printing
)
3276 printf (" (%s)\n", get_TAG_name (entry
->tag
));
3281 need_base_address
= 0;
3283 case DW_TAG_compile_unit
:
3284 need_base_address
= 1;
3285 need_dwo_info
= do_loc
;
3287 case DW_TAG_entry_point
:
3288 case DW_TAG_subprogram
:
3289 need_base_address
= 0;
3290 /* Assuming that there is no DW_AT_frame_base. */
3291 have_frame_base
= 0;
3295 debug_info
*debug_info_p
=
3296 (debug_information
&& unit
< alloc_num_debug_info_entries
)
3297 ? debug_information
+ unit
: NULL
;
3299 assert (!debug_info_p
3300 || (debug_info_p
->num_loc_offsets
3301 == debug_info_p
->num_loc_views
));
3303 for (attr
= entry
->first_attr
;
3304 attr
&& attr
->attribute
;
3307 if (! do_loc
&& do_printing
)
3308 /* Show the offset from where the tag was extracted. */
3309 printf (" <%lx>", (unsigned long)(tags
- section_begin
));
3310 tags
= read_and_display_attr (attr
->attribute
,
3312 attr
->implicit_const
,
3316 compunit
.cu_pointer_size
,
3318 compunit
.cu_version
,
3320 do_loc
|| ! do_printing
,
3325 /* If a locview attribute appears before a location one,
3326 make sure we don't associate it with an earlier
3329 switch (debug_info_p
->num_loc_offsets
- debug_info_p
->num_loc_views
)
3332 debug_info_p
->loc_views
[debug_info_p
->num_loc_views
] = vm1
;
3333 debug_info_p
->num_loc_views
++;
3334 assert (debug_info_p
->num_loc_views
3335 == debug_info_p
->num_loc_offsets
);
3342 warn(_("DIE has locviews without loclist\n"));
3343 debug_info_p
->num_loc_views
--;
3350 if (entry
->children
)
3355 /* Set num_debug_info_entries here so that it can be used to check if
3356 we need to process .debug_loc and .debug_ranges sections. */
3357 if ((do_loc
|| do_debug_loc
|| do_debug_ranges
)
3358 && num_debug_info_entries
== 0
3361 if (num_units
> alloc_num_debug_info_entries
)
3362 num_debug_info_entries
= alloc_num_debug_info_entries
;
3364 num_debug_info_entries
= num_units
;
3373 /* Locate and scan the .debug_info section in the file and record the pointer
3374 sizes and offsets for the compilation units in it. Usually an executable
3375 will have just one pointer size, but this is not guaranteed, and so we try
3376 not to make any assumptions. Returns zero upon failure, or the number of
3377 compilation units upon success. */
3380 load_debug_info (void * file
)
3382 /* If we have already tried and failed to load the .debug_info
3383 section then do not bother to repeat the task. */
3384 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
3387 /* If we already have the information there is nothing else to do. */
3388 if (num_debug_info_entries
> 0)
3389 return num_debug_info_entries
;
3391 /* If this is a DWARF package file, load the CU and TU indexes. */
3392 (void) load_cu_tu_indexes (file
);
3394 if (load_debug_section_with_follow (info
, file
)
3395 && process_debug_info (&debug_displays
[info
].section
, file
, abbrev
, TRUE
, FALSE
))
3396 return num_debug_info_entries
;
3398 if (load_debug_section_with_follow (info_dwo
, file
)
3399 && process_debug_info (&debug_displays
[info_dwo
].section
, file
,
3400 abbrev_dwo
, TRUE
, FALSE
))
3401 return num_debug_info_entries
;
3403 num_debug_info_entries
= DEBUG_INFO_UNAVAILABLE
;
3407 /* Read a DWARF .debug_line section header starting at DATA.
3408 Upon success returns an updated DATA pointer and the LINFO
3409 structure and the END_OF_SEQUENCE pointer will be filled in.
3410 Otherwise returns NULL. */
3412 static unsigned char *
3413 read_debug_line_header (struct dwarf_section
* section
,
3414 unsigned char * data
,
3415 unsigned char * end
,
3416 DWARF2_Internal_LineInfo
* linfo
,
3417 unsigned char ** end_of_sequence
)
3419 unsigned char *hdrptr
;
3420 unsigned int initial_length_size
;
3421 unsigned char address_size
, segment_selector_size
;
3423 /* Extract information from the Line Number Program Header.
3424 (section 6.2.4 in the Dwarf3 doc). */
3427 /* Get and check the length of the block. */
3428 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 4, end
);
3430 if (linfo
->li_length
== 0xffffffff)
3432 /* This section is 64-bit DWARF 3. */
3433 SAFE_BYTE_GET_AND_INC (linfo
->li_length
, hdrptr
, 8, end
);
3434 linfo
->li_offset_size
= 8;
3435 initial_length_size
= 12;
3439 linfo
->li_offset_size
= 4;
3440 initial_length_size
= 4;
3443 if (linfo
->li_length
+ initial_length_size
> section
->size
)
3445 /* If the length field has a relocation against it, then we should
3446 not complain if it is inaccurate (and probably negative). This
3447 happens in object files when the .debug_line section is actually
3448 comprised of several different .debug_line.* sections, (some of
3449 which may be removed by linker garbage collection), and a relocation
3450 is used to compute the correct length once that is done. */
3451 if (reloc_at (section
, (hdrptr
- section
->start
) - linfo
->li_offset_size
))
3453 linfo
->li_length
= (end
- data
) - initial_length_size
;
3457 warn (_("The length field (0x%lx) in the debug_line header is wrong - the section is too small\n"),
3458 (long) linfo
->li_length
);
3463 /* Get and check the version number. */
3464 SAFE_BYTE_GET_AND_INC (linfo
->li_version
, hdrptr
, 2, end
);
3466 if (linfo
->li_version
!= 2
3467 && linfo
->li_version
!= 3
3468 && linfo
->li_version
!= 4
3469 && linfo
->li_version
!= 5)
3471 warn (_("Only DWARF version 2, 3, 4 and 5 line info "
3472 "is currently supported.\n"));
3476 if (linfo
->li_version
>= 5)
3478 SAFE_BYTE_GET_AND_INC (address_size
, hdrptr
, 1, end
);
3480 SAFE_BYTE_GET_AND_INC (segment_selector_size
, hdrptr
, 1, end
);
3481 if (segment_selector_size
!= 0)
3483 warn (_("The %s section contains "
3484 "unsupported segment selector size: %d.\n"),
3485 section
->name
, segment_selector_size
);
3490 SAFE_BYTE_GET_AND_INC (linfo
->li_prologue_length
, hdrptr
,
3491 linfo
->li_offset_size
, end
);
3492 SAFE_BYTE_GET_AND_INC (linfo
->li_min_insn_length
, hdrptr
, 1, end
);
3494 if (linfo
->li_version
>= 4)
3496 SAFE_BYTE_GET_AND_INC (linfo
->li_max_ops_per_insn
, hdrptr
, 1, end
);
3498 if (linfo
->li_max_ops_per_insn
== 0)
3500 warn (_("Invalid maximum operations per insn.\n"));
3505 linfo
->li_max_ops_per_insn
= 1;
3507 SAFE_BYTE_GET_AND_INC (linfo
->li_default_is_stmt
, hdrptr
, 1, end
);
3508 SAFE_SIGNED_BYTE_GET_AND_INC (linfo
->li_line_base
, hdrptr
, 1, end
);
3509 SAFE_BYTE_GET_AND_INC (linfo
->li_line_range
, hdrptr
, 1, end
);
3510 SAFE_BYTE_GET_AND_INC (linfo
->li_opcode_base
, hdrptr
, 1, end
);
3512 * end_of_sequence
= data
+ linfo
->li_length
+ initial_length_size
;
3513 /* PR 17512: file:002-117414-0.004. */
3514 if (* end_of_sequence
> end
)
3516 warn (_("Line length %s extends beyond end of section\n"),
3517 dwarf_vmatoa ("u", linfo
->li_length
));
3518 * end_of_sequence
= end
;
3525 static unsigned char *
3526 display_formatted_table (unsigned char * data
,
3527 unsigned char * start
,
3528 unsigned char * end
,
3529 const DWARF2_Internal_LineInfo
* linfo
,
3530 struct dwarf_section
* section
,
3533 unsigned char *format_start
, format_count
, *format
, formati
;
3534 dwarf_vma data_count
, datai
;
3535 unsigned int bytes_read
, namepass
, last_entry
= 0;
3537 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
3538 format_start
= data
;
3539 for (formati
= 0; formati
< format_count
; formati
++)
3541 read_uleb128 (data
, & bytes_read
, end
);
3543 read_uleb128 (data
, & bytes_read
, end
);
3548 warn (_("Corrupt directory format table entry\n"));
3550 warn (_("Corrupt file name format table entry\n"));
3555 data_count
= read_uleb128 (data
, & bytes_read
, end
);
3560 warn (_("Corrupt directory list\n"));
3562 warn (_("Corrupt file name list\n"));
3566 if (data_count
== 0)
3569 printf (_("\n The Directory Table is empty.\n"));
3571 printf (_("\n The File Name Table is empty.\n"));
3576 printf (_("\n The Directory Table (offset 0x%lx):\n"),
3577 (long) (data
- start
));
3579 printf (_("\n The File Name Table (offset 0x%lx):\n"),
3580 (long) (data
- start
));
3582 printf (_(" Entry"));
3583 /* Delay displaying name as the last entry for better screen layout. */
3584 for (namepass
= 0; namepass
< 2; namepass
++)
3586 format
= format_start
;
3587 for (formati
= 0; formati
< format_count
; formati
++)
3589 dwarf_vma content_type
;
3591 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3592 format
+= bytes_read
;
3593 if ((content_type
== DW_LNCT_path
) == (namepass
== 1))
3594 switch (content_type
)
3597 printf (_("\tName"));
3599 case DW_LNCT_directory_index
:
3600 printf (_("\tDir"));
3602 case DW_LNCT_timestamp
:
3603 printf (_("\tTime"));
3606 printf (_("\tSize"));
3609 printf (_("\tMD5"));
3612 printf (_("\t(Unknown format content type %s)"),
3613 dwarf_vmatoa ("u", content_type
));
3615 read_uleb128 (format
, & bytes_read
, end
);
3616 format
+= bytes_read
;
3621 for (datai
= 0; datai
< data_count
; datai
++)
3623 unsigned char *datapass
= data
;
3625 printf (" %d", last_entry
++);
3626 /* Delay displaying name as the last entry for better screen layout. */
3627 for (namepass
= 0; namepass
< 2; namepass
++)
3629 format
= format_start
;
3631 for (formati
= 0; formati
< format_count
; formati
++)
3633 dwarf_vma content_type
, form
;
3635 content_type
= read_uleb128 (format
, & bytes_read
, end
);
3636 format
+= bytes_read
;
3637 form
= read_uleb128 (format
, & bytes_read
, end
);
3638 format
+= bytes_read
;
3639 data
= read_and_display_attr_value (0, form
, 0, data
, end
, 0, 0,
3640 linfo
->li_offset_size
,
3641 linfo
->li_version
, NULL
,
3642 ((content_type
== DW_LNCT_path
) != (namepass
== 1)),
3643 section
, NULL
, '\t');
3649 warn (_("Corrupt directory entries list\n"));
3651 warn (_("Corrupt file name entries list\n"));
3660 display_debug_lines_raw (struct dwarf_section
* section
,
3661 unsigned char * data
,
3662 unsigned char * end
,
3665 unsigned char *start
= section
->start
;
3666 int verbose_view
= 0;
3668 introduce (section
, TRUE
);
3672 static DWARF2_Internal_LineInfo saved_linfo
;
3673 DWARF2_Internal_LineInfo linfo
;
3674 unsigned char *standard_opcodes
;
3675 unsigned char *end_of_sequence
;
3678 if (const_strneq (section
->name
, ".debug_line.")
3679 /* Note: the following does not apply to .debug_line.dwo sections.
3680 These are full debug_line sections. */
3681 && strcmp (section
->name
, ".debug_line.dwo") != 0)
3683 /* Sections named .debug_line.<foo> are fragments of a .debug_line
3684 section containing just the Line Number Statements. They are
3685 created by the assembler and intended to be used alongside gcc's
3686 -ffunction-sections command line option. When the linker's
3687 garbage collection decides to discard a .text.<foo> section it
3688 can then also discard the line number information in .debug_line.<foo>.
3690 Since the section is a fragment it does not have the details
3691 needed to fill out a LineInfo structure, so instead we use the
3692 details from the last full debug_line section that we processed. */
3693 end_of_sequence
= end
;
3694 standard_opcodes
= NULL
;
3695 linfo
= saved_linfo
;
3696 /* PR 17531: file: 0522b371. */
3697 if (linfo
.li_line_range
== 0)
3699 warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n"));
3702 reset_state_machine (linfo
.li_default_is_stmt
);
3706 unsigned char * hdrptr
;
3708 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
3709 & end_of_sequence
)) == NULL
)
3712 printf (_(" Offset: 0x%lx\n"), (long)(data
- start
));
3713 printf (_(" Length: %ld\n"), (long) linfo
.li_length
);
3714 printf (_(" DWARF Version: %d\n"), linfo
.li_version
);
3715 printf (_(" Prologue Length: %d\n"), (int) linfo
.li_prologue_length
);
3716 printf (_(" Minimum Instruction Length: %d\n"), linfo
.li_min_insn_length
);
3717 if (linfo
.li_version
>= 4)
3718 printf (_(" Maximum Ops per Instruction: %d\n"), linfo
.li_max_ops_per_insn
);
3719 printf (_(" Initial value of 'is_stmt': %d\n"), linfo
.li_default_is_stmt
);
3720 printf (_(" Line Base: %d\n"), linfo
.li_line_base
);
3721 printf (_(" Line Range: %d\n"), linfo
.li_line_range
);
3722 printf (_(" Opcode Base: %d\n"), linfo
.li_opcode_base
);
3724 /* PR 17512: file: 1665-6428-0.004. */
3725 if (linfo
.li_line_range
== 0)
3727 warn (_("Line range of 0 is invalid, using 1 instead\n"));
3728 linfo
.li_line_range
= 1;
3731 reset_state_machine (linfo
.li_default_is_stmt
);
3733 /* Display the contents of the Opcodes table. */
3734 standard_opcodes
= hdrptr
;
3736 /* PR 17512: file: 002-417945-0.004. */
3737 if (standard_opcodes
+ linfo
.li_opcode_base
>= end
)
3739 warn (_("Line Base extends beyond end of section\n"));
3743 printf (_("\n Opcodes:\n"));
3745 for (i
= 1; i
< linfo
.li_opcode_base
; i
++)
3746 printf (ngettext (" Opcode %d has %d arg\n",
3747 " Opcode %d has %d args\n",
3748 standard_opcodes
[i
- 1]),
3749 i
, standard_opcodes
[i
- 1]);
3751 /* Display the contents of the Directory table. */
3752 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
3754 if (linfo
.li_version
>= 5)
3756 load_debug_section_with_follow (line_str
, file
);
3758 data
= display_formatted_table (data
, start
, end
, &linfo
, section
,
3760 data
= display_formatted_table (data
, start
, end
, &linfo
, section
,
3766 printf (_("\n The Directory Table is empty.\n"));
3769 unsigned int last_dir_entry
= 0;
3771 printf (_("\n The Directory Table (offset 0x%lx):\n"),
3772 (long)(data
- start
));
3774 while (data
< end
&& *data
!= 0)
3776 printf (" %d\t%.*s\n", ++last_dir_entry
, (int) (end
- data
), data
);
3778 data
+= strnlen ((char *) data
, end
- data
) + 1;
3781 /* PR 17512: file: 002-132094-0.004. */
3782 if (data
>= end
- 1)
3786 /* Skip the NUL at the end of the table. */
3789 /* Display the contents of the File Name table. */
3791 printf (_("\n The File Name Table is empty.\n"));
3794 printf (_("\n The File Name Table (offset 0x%lx):\n"),
3795 (long)(data
- start
));
3796 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
3798 while (data
< end
&& *data
!= 0)
3800 unsigned char *name
;
3801 unsigned int bytes_read
;
3803 printf (" %d\t", ++state_machine_regs
.last_file_entry
);
3805 data
+= strnlen ((char *) data
, end
- data
) + 1;
3808 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3811 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3814 dwarf_vmatoa ("u", read_uleb128 (data
, & bytes_read
, end
)));
3816 printf ("%.*s\n", (int)(end
- name
), name
);
3820 warn (_("Corrupt file name table entry\n"));
3826 /* Skip the NUL at the end of the table. */
3831 saved_linfo
= linfo
;
3834 /* Now display the statements. */
3835 if (data
>= end_of_sequence
)
3836 printf (_(" No Line Number Statements.\n"));
3839 printf (_(" Line Number Statements:\n"));
3841 while (data
< end_of_sequence
)
3843 unsigned char op_code
;
3844 dwarf_signed_vma adv
;
3846 unsigned int bytes_read
;
3848 printf (" [0x%08lx]", (long)(data
- start
));
3852 if (op_code
>= linfo
.li_opcode_base
)
3854 op_code
-= linfo
.li_opcode_base
;
3855 uladv
= (op_code
/ linfo
.li_line_range
);
3856 if (linfo
.li_max_ops_per_insn
== 1)
3858 uladv
*= linfo
.li_min_insn_length
;
3859 state_machine_regs
.address
+= uladv
;
3861 state_machine_regs
.view
= 0;
3862 printf (_(" Special opcode %d: "
3863 "advance Address by %s to 0x%s%s"),
3864 op_code
, dwarf_vmatoa ("u", uladv
),
3865 dwarf_vmatoa ("x", state_machine_regs
.address
),
3866 verbose_view
&& uladv
3867 ? _(" (reset view)") : "");
3872 = ((state_machine_regs
.op_index
+ uladv
)
3873 / linfo
.li_max_ops_per_insn
)
3874 * linfo
.li_min_insn_length
;
3876 state_machine_regs
.address
+= addrdelta
;
3877 state_machine_regs
.op_index
3878 = (state_machine_regs
.op_index
+ uladv
)
3879 % linfo
.li_max_ops_per_insn
;
3881 state_machine_regs
.view
= 0;
3882 printf (_(" Special opcode %d: "
3883 "advance Address by %s to 0x%s[%d]%s"),
3884 op_code
, dwarf_vmatoa ("u", uladv
),
3885 dwarf_vmatoa ("x", state_machine_regs
.address
),
3886 state_machine_regs
.op_index
,
3887 verbose_view
&& addrdelta
3888 ? _(" (reset view)") : "");
3890 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
3891 state_machine_regs
.line
+= adv
;
3892 printf (_(" and Line by %s to %d"),
3893 dwarf_vmatoa ("d", adv
), state_machine_regs
.line
);
3894 if (verbose_view
|| state_machine_regs
.view
)
3895 printf (_(" (view %u)\n"), state_machine_regs
.view
);
3898 state_machine_regs
.view
++;
3900 else switch (op_code
)
3902 case DW_LNS_extended_op
:
3903 data
+= process_extended_line_op (data
, linfo
.li_default_is_stmt
, end
);
3907 printf (_(" Copy"));
3908 if (verbose_view
|| state_machine_regs
.view
)
3909 printf (_(" (view %u)\n"), state_machine_regs
.view
);
3912 state_machine_regs
.view
++;
3915 case DW_LNS_advance_pc
:
3916 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3918 if (linfo
.li_max_ops_per_insn
== 1)
3920 uladv
*= linfo
.li_min_insn_length
;
3921 state_machine_regs
.address
+= uladv
;
3923 state_machine_regs
.view
= 0;
3924 printf (_(" Advance PC by %s to 0x%s%s\n"),
3925 dwarf_vmatoa ("u", uladv
),
3926 dwarf_vmatoa ("x", state_machine_regs
.address
),
3927 verbose_view
&& uladv
3928 ? _(" (reset view)") : "");
3933 = ((state_machine_regs
.op_index
+ uladv
)
3934 / linfo
.li_max_ops_per_insn
)
3935 * linfo
.li_min_insn_length
;
3936 state_machine_regs
.address
3938 state_machine_regs
.op_index
3939 = (state_machine_regs
.op_index
+ uladv
)
3940 % linfo
.li_max_ops_per_insn
;
3942 state_machine_regs
.view
= 0;
3943 printf (_(" Advance PC by %s to 0x%s[%d]%s\n"),
3944 dwarf_vmatoa ("u", uladv
),
3945 dwarf_vmatoa ("x", state_machine_regs
.address
),
3946 state_machine_regs
.op_index
,
3947 verbose_view
&& addrdelta
3948 ? _(" (reset view)") : "");
3952 case DW_LNS_advance_line
:
3953 adv
= read_sleb128 (data
, & bytes_read
, end
);
3955 state_machine_regs
.line
+= adv
;
3956 printf (_(" Advance Line by %s to %d\n"),
3957 dwarf_vmatoa ("d", adv
),
3958 state_machine_regs
.line
);
3961 case DW_LNS_set_file
:
3962 adv
= read_uleb128 (data
, & bytes_read
, end
);
3964 printf (_(" Set File Name to entry %s in the File Name Table\n"),
3965 dwarf_vmatoa ("d", adv
));
3966 state_machine_regs
.file
= adv
;
3969 case DW_LNS_set_column
:
3970 uladv
= read_uleb128 (data
, & bytes_read
, end
);
3972 printf (_(" Set column to %s\n"),
3973 dwarf_vmatoa ("u", uladv
));
3974 state_machine_regs
.column
= uladv
;
3977 case DW_LNS_negate_stmt
:
3978 adv
= state_machine_regs
.is_stmt
;
3980 printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv
));
3981 state_machine_regs
.is_stmt
= adv
;
3984 case DW_LNS_set_basic_block
:
3985 printf (_(" Set basic block\n"));
3986 state_machine_regs
.basic_block
= 1;
3989 case DW_LNS_const_add_pc
:
3990 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
3991 if (linfo
.li_max_ops_per_insn
)
3993 uladv
*= linfo
.li_min_insn_length
;
3994 state_machine_regs
.address
+= uladv
;
3996 state_machine_regs
.view
= 0;
3997 printf (_(" Advance PC by constant %s to 0x%s%s\n"),
3998 dwarf_vmatoa ("u", uladv
),
3999 dwarf_vmatoa ("x", state_machine_regs
.address
),
4000 verbose_view
&& uladv
4001 ? _(" (reset view)") : "");
4006 = ((state_machine_regs
.op_index
+ uladv
)
4007 / linfo
.li_max_ops_per_insn
)
4008 * linfo
.li_min_insn_length
;
4009 state_machine_regs
.address
4011 state_machine_regs
.op_index
4012 = (state_machine_regs
.op_index
+ uladv
)
4013 % linfo
.li_max_ops_per_insn
;
4015 state_machine_regs
.view
= 0;
4016 printf (_(" Advance PC by constant %s to 0x%s[%d]%s\n"),
4017 dwarf_vmatoa ("u", uladv
),
4018 dwarf_vmatoa ("x", state_machine_regs
.address
),
4019 state_machine_regs
.op_index
,
4020 verbose_view
&& addrdelta
4021 ? _(" (reset view)") : "");
4025 case DW_LNS_fixed_advance_pc
:
4026 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
4027 state_machine_regs
.address
+= uladv
;
4028 state_machine_regs
.op_index
= 0;
4029 printf (_(" Advance PC by fixed size amount %s to 0x%s\n"),
4030 dwarf_vmatoa ("u", uladv
),
4031 dwarf_vmatoa ("x", state_machine_regs
.address
));
4032 /* Do NOT reset view. */
4035 case DW_LNS_set_prologue_end
:
4036 printf (_(" Set prologue_end to true\n"));
4039 case DW_LNS_set_epilogue_begin
:
4040 printf (_(" Set epilogue_begin to true\n"));
4043 case DW_LNS_set_isa
:
4044 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4046 printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv
));
4050 printf (_(" Unknown opcode %d with operands: "), op_code
);
4052 if (standard_opcodes
!= NULL
)
4053 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
4055 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
4057 i
== 1 ? "" : ", ");
4073 unsigned char *name
;
4074 unsigned int directory_index
;
4075 unsigned int modification_date
;
4076 unsigned int length
;
4079 /* Output a decoded representation of the .debug_line section. */
4082 display_debug_lines_decoded (struct dwarf_section
* section
,
4083 unsigned char * data
,
4084 unsigned char * end
,
4087 static DWARF2_Internal_LineInfo saved_linfo
;
4089 introduce (section
, FALSE
);
4093 /* This loop amounts to one iteration per compilation unit. */
4094 DWARF2_Internal_LineInfo linfo
;
4095 unsigned char *standard_opcodes
;
4096 unsigned char *end_of_sequence
;
4098 File_Entry
*file_table
= NULL
;
4099 unsigned int n_files
= 0;
4100 unsigned char **directory_table
= NULL
;
4101 dwarf_vma n_directories
= 0;
4103 if (const_strneq (section
->name
, ".debug_line.")
4104 /* Note: the following does not apply to .debug_line.dwo sections.
4105 These are full debug_line sections. */
4106 && strcmp (section
->name
, ".debug_line.dwo") != 0)
4108 /* See comment in display_debug_lines_raw(). */
4109 end_of_sequence
= end
;
4110 standard_opcodes
= NULL
;
4111 linfo
= saved_linfo
;
4112 /* PR 17531: file: 0522b371. */
4113 if (linfo
.li_line_range
== 0)
4115 warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n"));
4118 reset_state_machine (linfo
.li_default_is_stmt
);
4122 unsigned char *hdrptr
;
4124 if ((hdrptr
= read_debug_line_header (section
, data
, end
, & linfo
,
4125 & end_of_sequence
)) == NULL
)
4128 /* PR 17531: file: 0522b371. */
4129 if (linfo
.li_line_range
== 0)
4131 warn (_("Line range of 0 is invalid, using 1 instead\n"));
4132 linfo
.li_line_range
= 1;
4134 reset_state_machine (linfo
.li_default_is_stmt
);
4136 /* Save a pointer to the contents of the Opcodes table. */
4137 standard_opcodes
= hdrptr
;
4139 /* Traverse the Directory table just to count entries. */
4140 data
= standard_opcodes
+ linfo
.li_opcode_base
- 1;
4144 warn (_("opcode base of %d extends beyond end of section\n"),
4145 linfo
.li_opcode_base
);
4149 if (linfo
.li_version
>= 5)
4151 unsigned char *format_start
, format_count
, *format
;
4152 dwarf_vma formati
, entryi
;
4153 unsigned int bytes_read
;
4155 load_debug_section_with_follow (line_str
, fileptr
);
4157 /* Skip directories format. */
4158 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
4159 format_start
= data
;
4160 for (formati
= 0; formati
< format_count
; formati
++)
4162 read_uleb128 (data
, & bytes_read
, end
);
4164 read_uleb128 (data
, & bytes_read
, end
);
4168 n_directories
= read_uleb128 (data
, & bytes_read
, end
);
4172 warn (_("Corrupt directories list\n"));
4176 directory_table
= (unsigned char **)
4177 xmalloc (n_directories
* sizeof (unsigned char *));
4179 for (entryi
= 0; entryi
< n_directories
; entryi
++)
4181 unsigned char **pathp
= &directory_table
[entryi
];
4183 format
= format_start
;
4184 for (formati
= 0; formati
< format_count
; formati
++)
4186 dwarf_vma content_type
, form
;
4189 content_type
= read_uleb128 (format
, & bytes_read
, end
);
4190 format
+= bytes_read
;
4191 form
= read_uleb128 (format
, & bytes_read
, end
);
4192 format
+= bytes_read
;
4195 warn (_("Corrupt directories list\n"));
4198 switch (content_type
)
4203 case DW_FORM_string
:
4206 case DW_FORM_line_strp
:
4207 SAFE_BYTE_GET (uvalue
, data
, linfo
.li_offset_size
,
4209 /* Remove const by the cast. */
4210 *pathp
= (unsigned char *)
4211 fetch_indirect_line_string (uvalue
);
4216 data
= read_and_display_attr_value (0, form
, 0, data
, end
,
4218 linfo
.li_offset_size
,
4225 warn (_("Corrupt directories list\n"));
4230 /* Skip files format. */
4231 SAFE_BYTE_GET_AND_INC (format_count
, data
, 1, end
);
4232 format_start
= data
;
4233 for (formati
= 0; formati
< format_count
; formati
++)
4235 read_uleb128 (data
, & bytes_read
, end
);
4237 read_uleb128 (data
, & bytes_read
, end
);
4241 n_files
= read_uleb128 (data
, & bytes_read
, end
);
4245 warn (_("Corrupt file name list\n"));
4249 file_table
= (File_Entry
*) xcalloc (1, n_files
4250 * sizeof (File_Entry
));
4252 for (entryi
= 0; entryi
< n_files
; entryi
++)
4254 File_Entry
*file
= &file_table
[entryi
];
4256 format
= format_start
;
4257 for (formati
= 0; formati
< format_count
; formati
++)
4259 dwarf_vma content_type
, form
;
4262 content_type
= read_uleb128 (format
, & bytes_read
, end
);
4263 format
+= bytes_read
;
4264 form
= read_uleb128 (format
, & bytes_read
, end
);
4265 format
+= bytes_read
;
4268 warn (_("Corrupt file name list\n"));
4271 switch (content_type
)
4276 case DW_FORM_string
:
4279 case DW_FORM_line_strp
:
4280 SAFE_BYTE_GET (uvalue
, data
, linfo
.li_offset_size
,
4282 /* Remove const by the cast. */
4283 file
->name
= (unsigned char *)
4284 fetch_indirect_line_string (uvalue
);
4288 case DW_LNCT_directory_index
:
4292 SAFE_BYTE_GET (file
->directory_index
, data
, 1,
4296 SAFE_BYTE_GET (file
->directory_index
, data
, 2,
4300 file
->directory_index
= read_uleb128 (data
, NULL
,
4306 data
= read_and_display_attr_value (0, form
, 0, data
, end
,
4308 linfo
.li_offset_size
,
4315 warn (_("Corrupt file name list\n"));
4324 unsigned char *ptr_directory_table
= data
;
4326 while (data
< end
&& *data
!= 0)
4328 data
+= strnlen ((char *) data
, end
- data
) + 1;
4335 warn (_("directory table ends unexpectedly\n"));
4340 /* Go through the directory table again to save the directories. */
4341 directory_table
= (unsigned char **)
4342 xmalloc (n_directories
* sizeof (unsigned char *));
4345 while (*ptr_directory_table
!= 0)
4347 directory_table
[i
] = ptr_directory_table
;
4348 ptr_directory_table
+= strnlen ((char *) ptr_directory_table
,
4349 ptr_directory_table
- end
) + 1;
4353 /* Skip the NUL at the end of the table. */
4356 /* Traverse the File Name table just to count the entries. */
4357 if (data
< end
&& *data
!= 0)
4359 unsigned char *ptr_file_name_table
= data
;
4361 while (data
< end
&& *data
!= 0)
4363 unsigned int bytes_read
;
4365 /* Skip Name, directory index, last modification time and length
4367 data
+= strnlen ((char *) data
, end
- data
) + 1;
4368 read_uleb128 (data
, & bytes_read
, end
);
4370 read_uleb128 (data
, & bytes_read
, end
);
4372 read_uleb128 (data
, & bytes_read
, end
);
4380 warn (_("file table ends unexpectedly\n"));
4385 /* Go through the file table again to save the strings. */
4386 file_table
= (File_Entry
*) xmalloc (n_files
* sizeof (File_Entry
));
4389 while (*ptr_file_name_table
!= 0)
4391 unsigned int bytes_read
;
4393 file_table
[i
].name
= ptr_file_name_table
;
4394 ptr_file_name_table
+= strnlen ((char *) ptr_file_name_table
,
4395 end
- ptr_file_name_table
) + 1;
4397 /* We are not interested in directory, time or size. */
4398 file_table
[i
].directory_index
= read_uleb128 (ptr_file_name_table
,
4400 ptr_file_name_table
+= bytes_read
;
4401 file_table
[i
].modification_date
= read_uleb128 (ptr_file_name_table
,
4403 ptr_file_name_table
+= bytes_read
;
4404 file_table
[i
].length
= read_uleb128 (ptr_file_name_table
, & bytes_read
, end
);
4405 ptr_file_name_table
+= bytes_read
;
4411 /* Skip the NUL at the end of the table. */
4415 /* Print the Compilation Unit's name and a header. */
4416 if (file_table
== NULL
)
4418 else if (directory_table
== NULL
)
4419 printf (_("CU: %s:\n"), file_table
[0].name
);
4422 unsigned int ix
= file_table
[0].directory_index
;
4423 const char *directory
;
4428 else if (n_directories
== 0)
4429 directory
= _("<unknown>");
4430 else if (ix
> n_directories
)
4432 warn (_("directory index %u > number of directories %s\n"),
4433 ix
, dwarf_vmatoa ("u", n_directories
));
4434 directory
= _("<corrupt>");
4437 directory
= (char *) directory_table
[ix
- 1];
4439 if (do_wide
|| strlen (directory
) < 76)
4440 printf (_("CU: %s/%s:\n"), directory
, file_table
[0].name
);
4442 printf ("%s:\n", file_table
[0].name
);
4445 printf (_("File name Line number Starting address View Stmt\n"));
4446 saved_linfo
= linfo
;
4449 /* This loop iterates through the Dwarf Line Number Program. */
4450 while (data
< end_of_sequence
)
4452 unsigned char op_code
;
4455 unsigned long int uladv
;
4456 unsigned int bytes_read
;
4457 int is_special_opcode
= 0;
4462 if (op_code
>= linfo
.li_opcode_base
)
4464 op_code
-= linfo
.li_opcode_base
;
4465 uladv
= (op_code
/ linfo
.li_line_range
);
4466 if (linfo
.li_max_ops_per_insn
== 1)
4468 uladv
*= linfo
.li_min_insn_length
;
4469 state_machine_regs
.address
+= uladv
;
4471 state_machine_regs
.view
= 0;
4476 = ((state_machine_regs
.op_index
+ uladv
)
4477 / linfo
.li_max_ops_per_insn
)
4478 * linfo
.li_min_insn_length
;
4479 state_machine_regs
.address
4481 state_machine_regs
.op_index
4482 = (state_machine_regs
.op_index
+ uladv
)
4483 % linfo
.li_max_ops_per_insn
;
4485 state_machine_regs
.view
= 0;
4488 adv
= (op_code
% linfo
.li_line_range
) + linfo
.li_line_base
;
4489 state_machine_regs
.line
+= adv
;
4490 is_special_opcode
= 1;
4491 /* Increment view after printing this row. */
4493 else switch (op_code
)
4495 case DW_LNS_extended_op
:
4497 unsigned int ext_op_code_len
;
4498 unsigned char ext_op_code
;
4499 unsigned char *op_code_data
= data
;
4501 ext_op_code_len
= read_uleb128 (op_code_data
, &bytes_read
,
4503 op_code_data
+= bytes_read
;
4505 if (ext_op_code_len
== 0)
4507 warn (_("Badly formed extended line op encountered!\n"));
4510 ext_op_code_len
+= bytes_read
;
4511 ext_op_code
= *op_code_data
++;
4515 switch (ext_op_code
)
4517 case DW_LNE_end_sequence
:
4518 /* Reset stuff after printing this row. */
4520 case DW_LNE_set_address
:
4521 SAFE_BYTE_GET_AND_INC (state_machine_regs
.address
,
4523 ext_op_code_len
- bytes_read
- 1,
4525 state_machine_regs
.op_index
= 0;
4526 state_machine_regs
.view
= 0;
4528 case DW_LNE_define_file
:
4530 file_table
= (File_Entry
*) xrealloc
4531 (file_table
, (n_files
+ 1) * sizeof (File_Entry
));
4533 ++state_machine_regs
.last_file_entry
;
4534 /* Source file name. */
4535 file_table
[n_files
].name
= op_code_data
;
4536 op_code_data
+= strlen ((char *) op_code_data
) + 1;
4537 /* Directory index. */
4538 file_table
[n_files
].directory_index
=
4539 read_uleb128 (op_code_data
, & bytes_read
,
4541 op_code_data
+= bytes_read
;
4542 /* Last modification time. */
4543 file_table
[n_files
].modification_date
=
4544 read_uleb128 (op_code_data
, & bytes_read
,
4546 op_code_data
+= bytes_read
;
4548 file_table
[n_files
].length
=
4549 read_uleb128 (op_code_data
, & bytes_read
,
4555 case DW_LNE_set_discriminator
:
4556 case DW_LNE_HP_set_sequence
:
4557 /* Simply ignored. */
4561 printf (_("UNKNOWN (%u): length %d\n"),
4562 ext_op_code
, ext_op_code_len
- bytes_read
);
4565 data
+= ext_op_code_len
;
4569 /* Increment view after printing this row. */
4572 case DW_LNS_advance_pc
:
4573 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4575 if (linfo
.li_max_ops_per_insn
== 1)
4577 uladv
*= linfo
.li_min_insn_length
;
4578 state_machine_regs
.address
+= uladv
;
4580 state_machine_regs
.view
= 0;
4585 = ((state_machine_regs
.op_index
+ uladv
)
4586 / linfo
.li_max_ops_per_insn
)
4587 * linfo
.li_min_insn_length
;
4588 state_machine_regs
.address
4590 state_machine_regs
.op_index
4591 = (state_machine_regs
.op_index
+ uladv
)
4592 % linfo
.li_max_ops_per_insn
;
4594 state_machine_regs
.view
= 0;
4598 case DW_LNS_advance_line
:
4599 adv
= read_sleb128 (data
, & bytes_read
, end
);
4601 state_machine_regs
.line
+= adv
;
4604 case DW_LNS_set_file
:
4605 adv
= read_uleb128 (data
, & bytes_read
, end
);
4607 state_machine_regs
.file
= adv
;
4610 unsigned file
= state_machine_regs
.file
- 1;
4613 if (file_table
== NULL
|| n_files
== 0)
4614 printf (_("\n [Use file table entry %d]\n"), file
);
4616 else if (file
>= n_files
)
4618 warn (_("file index %u > number of files %u\n"), file
+ 1, n_files
);
4619 printf (_("\n <over large file table index %u>"), file
);
4621 else if ((dir
= file_table
[file
].directory_index
) == 0)
4622 /* If directory index is 0, that means current directory. */
4623 printf ("\n./%s:[++]\n", file_table
[file
].name
);
4624 else if (directory_table
== NULL
|| n_directories
== 0)
4625 printf (_("\n [Use file %s in directory table entry %d]\n"),
4626 file_table
[file
].name
, dir
);
4628 else if (dir
> n_directories
)
4630 warn (_("directory index %u > number of directories %s\n"),
4631 dir
, dwarf_vmatoa ("u", n_directories
));
4632 printf (_("\n <over large directory table entry %u>\n"), dir
);
4635 printf ("\n%s/%s:\n",
4636 /* The directory index starts counting at 1. */
4637 directory_table
[dir
- 1], file_table
[file
].name
);
4641 case DW_LNS_set_column
:
4642 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4644 state_machine_regs
.column
= uladv
;
4647 case DW_LNS_negate_stmt
:
4648 adv
= state_machine_regs
.is_stmt
;
4650 state_machine_regs
.is_stmt
= adv
;
4653 case DW_LNS_set_basic_block
:
4654 state_machine_regs
.basic_block
= 1;
4657 case DW_LNS_const_add_pc
:
4658 uladv
= ((255 - linfo
.li_opcode_base
) / linfo
.li_line_range
);
4659 if (linfo
.li_max_ops_per_insn
== 1)
4661 uladv
*= linfo
.li_min_insn_length
;
4662 state_machine_regs
.address
+= uladv
;
4664 state_machine_regs
.view
= 0;
4669 = ((state_machine_regs
.op_index
+ uladv
)
4670 / linfo
.li_max_ops_per_insn
)
4671 * linfo
.li_min_insn_length
;
4672 state_machine_regs
.address
4674 state_machine_regs
.op_index
4675 = (state_machine_regs
.op_index
+ uladv
)
4676 % linfo
.li_max_ops_per_insn
;
4678 state_machine_regs
.view
= 0;
4682 case DW_LNS_fixed_advance_pc
:
4683 SAFE_BYTE_GET_AND_INC (uladv
, data
, 2, end
);
4684 state_machine_regs
.address
+= uladv
;
4685 state_machine_regs
.op_index
= 0;
4686 /* Do NOT reset view. */
4689 case DW_LNS_set_prologue_end
:
4692 case DW_LNS_set_epilogue_begin
:
4695 case DW_LNS_set_isa
:
4696 uladv
= read_uleb128 (data
, & bytes_read
, end
);
4698 printf (_(" Set ISA to %lu\n"), uladv
);
4702 printf (_(" Unknown opcode %d with operands: "), op_code
);
4704 if (standard_opcodes
!= NULL
)
4705 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
4707 printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data
,
4709 i
== 1 ? "" : ", ");
4716 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
4717 to the DWARF address/line matrix. */
4718 if ((is_special_opcode
) || (xop
== -DW_LNE_end_sequence
)
4719 || (xop
== DW_LNS_copy
))
4721 const unsigned int MAX_FILENAME_LENGTH
= 35;
4723 char *newFileName
= NULL
;
4724 size_t fileNameLength
;
4728 unsigned indx
= state_machine_regs
.file
- 1;
4730 if (indx
>= n_files
)
4732 warn (_("corrupt file index %u encountered\n"), indx
);
4733 fileName
= _("<corrupt>");
4736 fileName
= (char *) file_table
[indx
].name
;
4739 fileName
= _("<unknown>");
4741 fileNameLength
= strlen (fileName
);
4743 if ((fileNameLength
> MAX_FILENAME_LENGTH
) && (!do_wide
))
4745 newFileName
= (char *) xmalloc (MAX_FILENAME_LENGTH
+ 1);
4746 /* Truncate file name */
4747 strncpy (newFileName
,
4748 fileName
+ fileNameLength
- MAX_FILENAME_LENGTH
,
4749 MAX_FILENAME_LENGTH
+ 1);
4753 newFileName
= (char *) xmalloc (fileNameLength
+ 1);
4754 strncpy (newFileName
, fileName
, fileNameLength
+ 1);
4757 if (!do_wide
|| (fileNameLength
<= MAX_FILENAME_LENGTH
))
4759 if (linfo
.li_max_ops_per_insn
== 1)
4760 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x",
4761 newFileName
, state_machine_regs
.line
,
4762 state_machine_regs
.address
);
4764 printf ("%-35s %11d %#18" DWARF_VMA_FMT
"x[%d]",
4765 newFileName
, state_machine_regs
.line
,
4766 state_machine_regs
.address
,
4767 state_machine_regs
.op_index
);
4771 if (linfo
.li_max_ops_per_insn
== 1)
4772 printf ("%s %11d %#18" DWARF_VMA_FMT
"x",
4773 newFileName
, state_machine_regs
.line
,
4774 state_machine_regs
.address
);
4776 printf ("%s %11d %#18" DWARF_VMA_FMT
"x[%d]",
4777 newFileName
, state_machine_regs
.line
,
4778 state_machine_regs
.address
,
4779 state_machine_regs
.op_index
);
4782 if (state_machine_regs
.view
)
4783 printf (" %6u", state_machine_regs
.view
);
4787 if (state_machine_regs
.is_stmt
)
4791 state_machine_regs
.view
++;
4793 if (xop
== -DW_LNE_end_sequence
)
4795 reset_state_machine (linfo
.li_default_is_stmt
);
4810 if (directory_table
)
4812 free (directory_table
);
4813 directory_table
= NULL
;
4824 display_debug_lines (struct dwarf_section
*section
, void *file
)
4826 unsigned char *data
= section
->start
;
4827 unsigned char *end
= data
+ section
->size
;
4829 int retValDecoded
= 1;
4831 if (do_debug_lines
== 0)
4832 do_debug_lines
|= FLAG_DEBUG_LINES_RAW
;
4834 if (do_debug_lines
& FLAG_DEBUG_LINES_RAW
)
4835 retValRaw
= display_debug_lines_raw (section
, data
, end
, file
);
4837 if (do_debug_lines
& FLAG_DEBUG_LINES_DECODED
)
4838 retValDecoded
= display_debug_lines_decoded (section
, data
, end
, file
);
4840 if (!retValRaw
|| !retValDecoded
)
4847 find_debug_info_for_offset (unsigned long offset
)
4851 if (num_debug_info_entries
== DEBUG_INFO_UNAVAILABLE
)
4854 for (i
= 0; i
< num_debug_info_entries
; i
++)
4855 if (debug_information
[i
].cu_offset
== offset
)
4856 return debug_information
+ i
;
4862 get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind
)
4864 /* See gdb/gdb-index.h. */
4865 static const char * const kinds
[] =
4877 return _ (kinds
[kind
]);
4881 display_debug_pubnames_worker (struct dwarf_section
*section
,
4882 void *file ATTRIBUTE_UNUSED
,
4885 DWARF2_Internal_PubNames names
;
4886 unsigned char *start
= section
->start
;
4887 unsigned char *end
= start
+ section
->size
;
4889 /* It does not matter if this load fails,
4890 we test for that later on. */
4891 load_debug_info (file
);
4893 introduce (section
, FALSE
);
4897 unsigned char *data
;
4898 unsigned long sec_off
;
4899 unsigned int offset_size
, initial_length_size
;
4901 SAFE_BYTE_GET_AND_INC (names
.pn_length
, start
, 4, end
);
4902 if (names
.pn_length
== 0xffffffff)
4904 SAFE_BYTE_GET_AND_INC (names
.pn_length
, start
, 8, end
);
4906 initial_length_size
= 12;
4911 initial_length_size
= 4;
4914 sec_off
= start
- section
->start
;
4915 if (sec_off
+ names
.pn_length
< sec_off
4916 || sec_off
+ names
.pn_length
> section
->size
)
4918 warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"),
4920 sec_off
- initial_length_size
,
4921 dwarf_vmatoa ("x", names
.pn_length
));
4926 start
+= names
.pn_length
;
4928 SAFE_BYTE_GET_AND_INC (names
.pn_version
, data
, 2, end
);
4929 SAFE_BYTE_GET_AND_INC (names
.pn_offset
, data
, offset_size
, end
);
4931 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
4932 && num_debug_info_entries
> 0
4933 && find_debug_info_for_offset (names
.pn_offset
) == NULL
)
4934 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
4935 (unsigned long) names
.pn_offset
, section
->name
);
4937 SAFE_BYTE_GET_AND_INC (names
.pn_size
, data
, offset_size
, end
);
4939 printf (_(" Length: %ld\n"),
4940 (long) names
.pn_length
);
4941 printf (_(" Version: %d\n"),
4943 printf (_(" Offset into .debug_info section: 0x%lx\n"),
4944 (unsigned long) names
.pn_offset
);
4945 printf (_(" Size of area in .debug_info section: %ld\n"),
4946 (long) names
.pn_size
);
4948 if (names
.pn_version
!= 2 && names
.pn_version
!= 3)
4950 static int warned
= 0;
4954 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
4962 printf (_("\n Offset Kind Name\n"));
4964 printf (_("\n Offset\tName\n"));
4968 bfd_size_type maxprint
;
4971 SAFE_BYTE_GET (offset
, data
, offset_size
, end
);
4976 data
+= offset_size
;
4979 maxprint
= (end
- data
) - 1;
4983 unsigned int kind_data
;
4984 gdb_index_symbol_kind kind
;
4985 const char *kind_name
;
4988 SAFE_BYTE_GET (kind_data
, data
, 1, end
);
4991 /* GCC computes the kind as the upper byte in the CU index
4992 word, and then right shifts it by the CU index size.
4993 Left shift KIND to where the gdb-index.h accessor macros
4995 kind_data
<<= GDB_INDEX_CU_BITSIZE
;
4996 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (kind_data
);
4997 kind_name
= get_gdb_index_symbol_kind_name (kind
);
4998 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data
);
4999 printf (" %-6lx %s,%-10s %.*s\n",
5000 (unsigned long) offset
, is_static
? _("s") : _("g"),
5001 kind_name
, (int) maxprint
, data
);
5004 printf (" %-6lx\t%.*s\n",
5005 (unsigned long) offset
, (int) maxprint
, data
);
5007 data
+= strnlen ((char *) data
, maxprint
) + 1;
5018 display_debug_pubnames (struct dwarf_section
*section
, void *file
)
5020 return display_debug_pubnames_worker (section
, file
, 0);
5024 display_debug_gnu_pubnames (struct dwarf_section
*section
, void *file
)
5026 return display_debug_pubnames_worker (section
, file
, 1);
5030 display_debug_macinfo (struct dwarf_section
*section
,
5031 void *file ATTRIBUTE_UNUSED
)
5033 unsigned char *start
= section
->start
;
5034 unsigned char *end
= start
+ section
->size
;
5035 unsigned char *curr
= start
;
5036 unsigned int bytes_read
;
5037 enum dwarf_macinfo_record_type op
;
5039 introduce (section
, FALSE
);
5043 unsigned int lineno
;
5044 const unsigned char *string
;
5046 op
= (enum dwarf_macinfo_record_type
) *curr
;
5051 case DW_MACINFO_start_file
:
5053 unsigned int filenum
;
5055 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
5057 filenum
= read_uleb128 (curr
, & bytes_read
, end
);
5060 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
5065 case DW_MACINFO_end_file
:
5066 printf (_(" DW_MACINFO_end_file\n"));
5069 case DW_MACINFO_define
:
5070 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
5073 curr
+= strnlen ((char *) string
, end
- string
) + 1;
5074 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
5078 case DW_MACINFO_undef
:
5079 lineno
= read_uleb128 (curr
, & bytes_read
, end
);
5082 curr
+= strnlen ((char *) string
, end
- string
) + 1;
5083 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
5087 case DW_MACINFO_vendor_ext
:
5089 unsigned int constant
;
5091 constant
= read_uleb128 (curr
, & bytes_read
, end
);
5094 curr
+= strnlen ((char *) string
, end
- string
) + 1;
5095 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
5105 /* Given LINE_OFFSET into the .debug_line section, attempt to return
5106 filename and dirname corresponding to file name table entry with index
5107 FILEIDX. Return NULL on failure. */
5109 static unsigned char *
5110 get_line_filename_and_dirname (dwarf_vma line_offset
,
5112 unsigned char **dir_name
)
5114 struct dwarf_section
*section
= &debug_displays
[line
].section
;
5115 unsigned char *hdrptr
, *dirtable
, *file_name
;
5116 unsigned int offset_size
, initial_length_size
;
5117 unsigned int version
, opcode_base
, bytes_read
;
5118 dwarf_vma length
, diridx
;
5119 const unsigned char * end
;
5122 if (section
->start
== NULL
5123 || line_offset
>= section
->size
5127 hdrptr
= section
->start
+ line_offset
;
5128 end
= section
->start
+ section
->size
;
5130 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 4, end
);
5131 if (length
== 0xffffffff)
5133 /* This section is 64-bit DWARF 3. */
5134 SAFE_BYTE_GET_AND_INC (length
, hdrptr
, 8, end
);
5136 initial_length_size
= 12;
5141 initial_length_size
= 4;
5143 if (length
+ initial_length_size
< length
5144 || length
+ initial_length_size
> section
->size
)
5147 SAFE_BYTE_GET_AND_INC (version
, hdrptr
, 2, end
);
5148 if (version
!= 2 && version
!= 3 && version
!= 4)
5150 hdrptr
+= offset_size
+ 1;/* Skip prologue_length and min_insn_length. */
5152 hdrptr
++; /* Skip max_ops_per_insn. */
5153 hdrptr
+= 3; /* Skip default_is_stmt, line_base, line_range. */
5155 SAFE_BYTE_GET_AND_INC (opcode_base
, hdrptr
, 1, end
);
5156 if (opcode_base
== 0)
5159 hdrptr
+= opcode_base
- 1;
5164 /* Skip over dirname table. */
5165 while (*hdrptr
!= '\0')
5167 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
5171 hdrptr
++; /* Skip the NUL at the end of the table. */
5173 /* Now skip over preceding filename table entries. */
5174 for (; hdrptr
< end
&& *hdrptr
!= '\0' && fileidx
> 1; fileidx
--)
5176 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
5177 read_uleb128 (hdrptr
, &bytes_read
, end
);
5178 hdrptr
+= bytes_read
;
5179 read_uleb128 (hdrptr
, &bytes_read
, end
);
5180 hdrptr
+= bytes_read
;
5181 read_uleb128 (hdrptr
, &bytes_read
, end
);
5182 hdrptr
+= bytes_read
;
5184 if (hdrptr
>= end
|| *hdrptr
== '\0')
5188 hdrptr
+= strnlen ((char *) hdrptr
, end
- hdrptr
) + 1;
5191 diridx
= read_uleb128 (hdrptr
, &bytes_read
, end
);
5194 for (; dirtable
< end
&& *dirtable
!= '\0' && diridx
> 1; diridx
--)
5195 dirtable
+= strnlen ((char *) dirtable
, end
- dirtable
) + 1;
5196 if (dirtable
>= end
|| *dirtable
== '\0')
5198 *dir_name
= dirtable
;
5203 display_debug_macro (struct dwarf_section
*section
,
5206 unsigned char *start
= section
->start
;
5207 unsigned char *end
= start
+ section
->size
;
5208 unsigned char *curr
= start
;
5209 unsigned char *extended_op_buf
[256];
5210 unsigned int bytes_read
;
5212 load_debug_section_with_follow (str
, file
);
5213 load_debug_section_with_follow (line
, file
);
5215 introduce (section
, FALSE
);
5219 unsigned int lineno
, version
, flags
;
5220 unsigned int offset_size
= 4;
5221 const unsigned char *string
;
5222 dwarf_vma line_offset
= 0, sec_offset
= curr
- start
, offset
;
5223 unsigned char **extended_ops
= NULL
;
5225 SAFE_BYTE_GET_AND_INC (version
, curr
, 2, end
);
5226 if (version
!= 4 && version
!= 5)
5228 error (_("Only GNU extension to DWARF 4 or 5 of %s is currently supported.\n"),
5233 SAFE_BYTE_GET_AND_INC (flags
, curr
, 1, end
);
5236 printf (_(" Offset: 0x%lx\n"),
5237 (unsigned long) sec_offset
);
5238 printf (_(" Version: %d\n"), version
);
5239 printf (_(" Offset size: %d\n"), offset_size
);
5242 SAFE_BYTE_GET_AND_INC (line_offset
, curr
, offset_size
, end
);
5243 printf (_(" Offset into .debug_line: 0x%lx\n"),
5244 (unsigned long) line_offset
);
5248 unsigned int i
, count
, op
;
5251 SAFE_BYTE_GET_AND_INC (count
, curr
, 1, end
);
5253 memset (extended_op_buf
, 0, sizeof (extended_op_buf
));
5254 extended_ops
= extended_op_buf
;
5257 printf (_(" Extension opcode arguments:\n"));
5258 for (i
= 0; i
< count
; i
++)
5260 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
5261 extended_ops
[op
] = curr
;
5262 nargs
= read_uleb128 (curr
, &bytes_read
, end
);
5265 printf (_(" DW_MACRO_%02x has no arguments\n"), op
);
5268 printf (_(" DW_MACRO_%02x arguments: "), op
);
5269 for (n
= 0; n
< nargs
; n
++)
5273 SAFE_BYTE_GET_AND_INC (form
, curr
, 1, end
);
5274 printf ("%s%s", get_FORM_name (form
),
5275 n
== nargs
- 1 ? "\n" : ", ");
5285 case DW_FORM_block1
:
5286 case DW_FORM_block2
:
5287 case DW_FORM_block4
:
5289 case DW_FORM_string
:
5291 case DW_FORM_sec_offset
:
5294 error (_("Invalid extension opcode form %s\n"),
5295 get_FORM_name (form
));
5311 error (_(".debug_macro section not zero terminated\n"));
5315 SAFE_BYTE_GET_AND_INC (op
, curr
, 1, end
);
5321 case DW_MACRO_start_file
:
5323 unsigned int filenum
;
5324 unsigned char *file_name
= NULL
, *dir_name
= NULL
;
5326 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
5328 filenum
= read_uleb128 (curr
, &bytes_read
, end
);
5331 if ((flags
& 2) == 0)
5332 error (_("DW_MACRO_start_file used, but no .debug_line offset provided.\n"));
5335 = get_line_filename_and_dirname (line_offset
, filenum
,
5337 if (file_name
== NULL
)
5338 printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d\n"),
5341 printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
5343 dir_name
!= NULL
? (const char *) dir_name
: "",
5344 dir_name
!= NULL
? "/" : "", file_name
);
5348 case DW_MACRO_end_file
:
5349 printf (_(" DW_MACRO_end_file\n"));
5352 case DW_MACRO_define
:
5353 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
5356 curr
+= strnlen ((char *) string
, end
- string
) + 1;
5357 printf (_(" DW_MACRO_define - lineno : %d macro : %s\n"),
5361 case DW_MACRO_undef
:
5362 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
5365 curr
+= strnlen ((char *) string
, end
- string
) + 1;
5366 printf (_(" DW_MACRO_undef - lineno : %d macro : %s\n"),
5370 case DW_MACRO_define_strp
:
5371 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
5373 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
5374 string
= fetch_indirect_string (offset
);
5375 printf (_(" DW_MACRO_define_strp - lineno : %d macro : %s\n"),
5379 case DW_MACRO_undef_strp
:
5380 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
5382 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
5383 string
= fetch_indirect_string (offset
);
5384 printf (_(" DW_MACRO_undef_strp - lineno : %d macro : %s\n"),
5388 case DW_MACRO_import
:
5389 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
5390 printf (_(" DW_MACRO_import - offset : 0x%lx\n"),
5391 (unsigned long) offset
);
5394 case DW_MACRO_define_sup
:
5395 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
5397 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
5398 printf (_(" DW_MACRO_define_sup - lineno : %d macro offset : 0x%lx\n"),
5399 lineno
, (unsigned long) offset
);
5402 case DW_MACRO_undef_sup
:
5403 lineno
= read_uleb128 (curr
, &bytes_read
, end
);
5405 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
5406 printf (_(" DW_MACRO_undef_sup - lineno : %d macro offset : 0x%lx\n"),
5407 lineno
, (unsigned long) offset
);
5410 case DW_MACRO_import_sup
:
5411 SAFE_BYTE_GET_AND_INC (offset
, curr
, offset_size
, end
);
5412 printf (_(" DW_MACRO_import_sup - offset : 0x%lx\n"),
5413 (unsigned long) offset
);
5417 if (extended_ops
== NULL
|| extended_ops
[op
] == NULL
)
5419 error (_(" Unknown macro opcode %02x seen\n"), op
);
5424 /* Skip over unhandled opcodes. */
5426 unsigned char *desc
= extended_ops
[op
];
5427 nargs
= read_uleb128 (desc
, &bytes_read
, end
);
5431 printf (_(" DW_MACRO_%02x\n"), op
);
5434 printf (_(" DW_MACRO_%02x -"), op
);
5435 for (n
= 0; n
< nargs
; n
++)
5439 /* DW_FORM_implicit_const is not expected here. */
5440 SAFE_BYTE_GET_AND_INC (val
, desc
, 1, end
);
5442 = read_and_display_attr_value (0, val
, 0,
5443 curr
, end
, 0, 0, offset_size
,
5444 version
, NULL
, 0, NULL
,
5462 display_debug_abbrev (struct dwarf_section
*section
,
5463 void *file ATTRIBUTE_UNUSED
)
5465 abbrev_entry
*entry
;
5466 unsigned char *start
= section
->start
;
5467 unsigned char *end
= start
+ section
->size
;
5469 introduce (section
, FALSE
);
5473 unsigned char *last
;
5478 start
= process_abbrev_section (start
, end
);
5480 if (first_abbrev
== NULL
)
5483 printf (_(" Number TAG (0x%lx)\n"), (long) (last
- section
->start
));
5485 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
5489 printf (" %ld %s [%s]\n",
5491 get_TAG_name (entry
->tag
),
5492 entry
->children
? _("has children") : _("no children"));
5494 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
5496 printf (" %-18s %s",
5497 get_AT_name (attr
->attribute
),
5498 get_FORM_name (attr
->form
));
5499 if (attr
->form
== DW_FORM_implicit_const
)
5500 printf (": %" BFD_VMA_FMT
"d", attr
->implicit_const
);
5512 /* Return true when ADDR is the maximum address, when addresses are
5513 POINTER_SIZE bytes long. */
5516 is_max_address (dwarf_vma addr
, unsigned int pointer_size
)
5518 dwarf_vma mask
= ~(~(dwarf_vma
) 1 << (pointer_size
* 8 - 1));
5519 return ((addr
& mask
) == mask
);
5522 /* Display a view pair list starting at *VSTART_PTR and ending at
5523 VLISTEND within SECTION. */
5526 display_view_pair_list (struct dwarf_section
*section
,
5527 unsigned char **vstart_ptr
,
5528 unsigned int debug_info_entry
,
5529 unsigned char *vlistend
)
5531 unsigned char *vstart
= *vstart_ptr
;
5532 unsigned char *section_end
= section
->start
+ section
->size
;
5533 unsigned int pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5535 if (vlistend
< section_end
)
5536 section_end
= vlistend
;
5540 while (vstart
< section_end
)
5542 dwarf_vma off
= vstart
- section
->start
;
5543 dwarf_vma vbegin
, vend
;
5545 unsigned int bytes_read
;
5546 vbegin
= read_uleb128 (vstart
, &bytes_read
, section_end
);
5547 vstart
+= bytes_read
;
5548 if (vstart
== section_end
)
5550 vstart
-= bytes_read
;
5554 vend
= read_uleb128 (vstart
, &bytes_read
, section_end
);
5555 vstart
+= bytes_read
;
5557 printf (" %8.8lx ", (unsigned long) off
);
5559 print_dwarf_view (vbegin
, pointer_size
, 1);
5560 print_dwarf_view (vend
, pointer_size
, 1);
5561 printf (_("location view pair\n"));
5565 *vstart_ptr
= vstart
;
5568 /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */
5571 display_loc_list (struct dwarf_section
*section
,
5572 unsigned char **start_ptr
,
5573 unsigned int debug_info_entry
,
5575 dwarf_vma base_address
,
5576 unsigned char **vstart_ptr
,
5579 unsigned char *start
= *start_ptr
, *vstart
= *vstart_ptr
;
5580 unsigned char *section_end
= section
->start
+ section
->size
;
5581 unsigned long cu_offset
;
5582 unsigned int pointer_size
;
5583 unsigned int offset_size
;
5588 unsigned short length
;
5589 int need_frame_base
;
5591 if (debug_info_entry
>= num_debug_info_entries
)
5593 warn (_("No debug information available for loc lists of entry: %u\n"),
5598 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
5599 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5600 offset_size
= debug_information
[debug_info_entry
].offset_size
;
5601 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
5603 if (pointer_size
< 2 || pointer_size
> 8)
5605 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
5606 pointer_size
, debug_info_entry
);
5612 dwarf_vma off
= offset
+ (start
- *start_ptr
);
5613 dwarf_vma vbegin
= vm1
, vend
= vm1
;
5615 if (start
+ 2 * pointer_size
> section_end
)
5617 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5618 (unsigned long) offset
);
5622 printf (" %8.8lx ", (unsigned long) off
);
5624 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, section_end
);
5625 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, section_end
);
5627 if (begin
== 0 && end
== 0)
5629 /* PR 18374: In a object file we can have a location list that
5630 starts with a begin and end of 0 because there are relocations
5631 that need to be applied to the addresses. Actually applying
5632 the relocations now does not help as they will probably resolve
5633 to 0, since the object file has not been fully linked. Real
5634 end of list markers will not have any relocations against them. */
5635 if (! reloc_at (section
, off
)
5636 && ! reloc_at (section
, off
+ pointer_size
))
5638 printf (_("<End of list>\n"));
5643 /* Check base address specifiers. */
5644 if (is_max_address (begin
, pointer_size
)
5645 && !is_max_address (end
, pointer_size
))
5648 print_dwarf_vma (begin
, pointer_size
);
5649 print_dwarf_vma (end
, pointer_size
);
5650 printf (_("(base address)\n"));
5656 unsigned int bytes_read
;
5658 off
= offset
+ (vstart
- *start_ptr
);
5660 vbegin
= read_uleb128 (vstart
, &bytes_read
, section_end
);
5661 vstart
+= bytes_read
;
5662 print_dwarf_view (vbegin
, pointer_size
, 1);
5664 vend
= read_uleb128 (vstart
, &bytes_read
, section_end
);
5665 vstart
+= bytes_read
;
5666 print_dwarf_view (vend
, pointer_size
, 1);
5668 printf (_("views at %8.8lx for:\n %*s "),
5669 (unsigned long) off
, 8, "");
5672 if (start
+ 2 > section_end
)
5674 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5675 (unsigned long) offset
);
5679 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
5681 if (start
+ length
> section_end
)
5683 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5684 (unsigned long) offset
);
5688 print_dwarf_vma (begin
+ base_address
, pointer_size
);
5689 print_dwarf_vma (end
+ base_address
, pointer_size
);
5692 need_frame_base
= decode_location_expression (start
,
5697 cu_offset
, section
);
5700 if (need_frame_base
&& !has_frame_base
)
5701 printf (_(" [without DW_AT_frame_base]"));
5703 if (begin
== end
&& vbegin
== vend
)
5704 fputs (_(" (start == end)"), stdout
);
5705 else if (begin
> end
|| (begin
== end
&& vbegin
> vend
))
5706 fputs (_(" (start > end)"), stdout
);
5714 *vstart_ptr
= vstart
;
5717 /* Display a location list from a normal (ie, non-dwo) .debug_loclists section. */
5720 display_loclists_list (struct dwarf_section
*section
,
5721 unsigned char **start_ptr
,
5722 unsigned int debug_info_entry
,
5724 dwarf_vma base_address
,
5725 unsigned char **vstart_ptr
,
5728 unsigned char *start
= *start_ptr
, *vstart
= *vstart_ptr
;
5729 unsigned char *section_end
= section
->start
+ section
->size
;
5730 unsigned long cu_offset
;
5731 unsigned int pointer_size
;
5732 unsigned int offset_size
;
5734 unsigned int bytes_read
;
5736 /* Initialize it due to a false compiler warning. */
5737 dwarf_vma begin
= -1, vbegin
= -1;
5738 dwarf_vma end
= -1, vend
= -1;
5740 int need_frame_base
;
5742 if (debug_info_entry
>= num_debug_info_entries
)
5744 warn (_("No debug information available for "
5745 "loclists lists of entry: %u\n"),
5750 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
5751 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5752 offset_size
= debug_information
[debug_info_entry
].offset_size
;
5753 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
5755 if (pointer_size
< 2 || pointer_size
> 8)
5757 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
5758 pointer_size
, debug_info_entry
);
5764 dwarf_vma off
= offset
+ (start
- *start_ptr
);
5765 enum dwarf_location_list_entry_type llet
;
5767 if (start
+ 1 > section_end
)
5769 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5770 (unsigned long) offset
);
5774 printf (" %8.8lx ", (unsigned long) off
);
5776 SAFE_BYTE_GET_AND_INC (llet
, start
, 1, section_end
);
5778 if (vstart
&& llet
== DW_LLE_offset_pair
)
5780 off
= offset
+ (vstart
- *start_ptr
);
5782 vbegin
= read_uleb128 (vstart
, &bytes_read
, section_end
);
5783 vstart
+= bytes_read
;
5784 print_dwarf_view (vbegin
, pointer_size
, 1);
5786 vend
= read_uleb128 (vstart
, &bytes_read
, section_end
);
5787 vstart
+= bytes_read
;
5788 print_dwarf_view (vend
, pointer_size
, 1);
5790 printf (_("views at %8.8lx for:\n %*s "),
5791 (unsigned long) off
, 8, "");
5796 case DW_LLE_end_of_list
:
5797 printf (_("<End of list>\n"));
5799 case DW_LLE_offset_pair
:
5800 begin
= read_uleb128 (start
, &bytes_read
, section_end
);
5801 start
+= bytes_read
;
5802 end
= read_uleb128 (start
, &bytes_read
, section_end
);
5803 start
+= bytes_read
;
5805 case DW_LLE_base_address
:
5806 SAFE_BYTE_GET_AND_INC (base_address
, start
, pointer_size
,
5808 print_dwarf_vma (base_address
, pointer_size
);
5809 printf (_("(base address)\n"));
5811 #ifdef DW_LLE_view_pair
5812 case DW_LLE_view_pair
:
5814 printf (_("View pair entry in loclist with locviews attribute\n"));
5815 vbegin
= read_uleb128 (start
, &bytes_read
, section_end
);
5816 start
+= bytes_read
;
5817 print_dwarf_view (vbegin
, pointer_size
, 1);
5819 vend
= read_uleb128 (start
, &bytes_read
, section_end
);
5820 start
+= bytes_read
;
5821 print_dwarf_view (vend
, pointer_size
, 1);
5823 printf (_("views for:\n"));
5827 error (_("Invalid location list entry type %d\n"), llet
);
5830 if (llet
== DW_LLE_end_of_list
)
5832 if (llet
!= DW_LLE_offset_pair
)
5835 if (start
+ 2 > section_end
)
5837 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5838 (unsigned long) offset
);
5842 length
= read_uleb128 (start
, &bytes_read
, section_end
);
5843 start
+= bytes_read
;
5845 print_dwarf_vma (begin
+ base_address
, pointer_size
);
5846 print_dwarf_vma (end
+ base_address
, pointer_size
);
5849 need_frame_base
= decode_location_expression (start
,
5854 cu_offset
, section
);
5857 if (need_frame_base
&& !has_frame_base
)
5858 printf (_(" [without DW_AT_frame_base]"));
5860 if (begin
== end
&& vbegin
== vend
)
5861 fputs (_(" (start == end)"), stdout
);
5862 else if (begin
> end
|| (begin
== end
&& vbegin
> vend
))
5863 fputs (_(" (start > end)"), stdout
);
5871 if (vbegin
!= vm1
|| vend
!= vm1
)
5872 printf (_("Trailing view pair not used in a range"));
5875 *vstart_ptr
= vstart
;
5878 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
5879 right-adjusted in a field of length LEN, and followed by a space. */
5882 print_addr_index (unsigned int idx
, unsigned int len
)
5884 static char buf
[15];
5885 snprintf (buf
, sizeof (buf
), "[%d]", idx
);
5886 printf ("%*s ", len
, buf
);
5889 /* Display a location list from a .dwo section. It uses address indexes rather
5890 than embedded addresses. This code closely follows display_loc_list, but the
5891 two are sufficiently different that combining things is very ugly. */
5894 display_loc_list_dwo (struct dwarf_section
*section
,
5895 unsigned char **start_ptr
,
5896 unsigned int debug_info_entry
,
5898 unsigned char **vstart_ptr
,
5901 unsigned char *start
= *start_ptr
, *vstart
= *vstart_ptr
;
5902 unsigned char *section_end
= section
->start
+ section
->size
;
5903 unsigned long cu_offset
;
5904 unsigned int pointer_size
;
5905 unsigned int offset_size
;
5908 unsigned short length
;
5909 int need_frame_base
;
5911 unsigned int bytes_read
;
5913 if (debug_info_entry
>= num_debug_info_entries
)
5915 warn (_("No debug information for loc lists of entry: %u\n"),
5920 cu_offset
= debug_information
[debug_info_entry
].cu_offset
;
5921 pointer_size
= debug_information
[debug_info_entry
].pointer_size
;
5922 offset_size
= debug_information
[debug_info_entry
].offset_size
;
5923 dwarf_version
= debug_information
[debug_info_entry
].dwarf_version
;
5925 if (pointer_size
< 2 || pointer_size
> 8)
5927 warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
5928 pointer_size
, debug_info_entry
);
5934 printf (" %8.8lx ", (unsigned long) (offset
+ (start
- *start_ptr
)));
5936 if (start
>= section_end
)
5938 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
5939 (unsigned long) offset
);
5943 SAFE_BYTE_GET_AND_INC (entry_type
, start
, 1, section_end
);
5956 dwarf_vma off
= offset
+ (vstart
- *start_ptr
);
5958 view
= read_uleb128 (vstart
, &bytes_read
, section_end
);
5959 vstart
+= bytes_read
;
5960 print_dwarf_view (view
, 8, 1);
5962 view
= read_uleb128 (vstart
, &bytes_read
, section_end
);
5963 vstart
+= bytes_read
;
5964 print_dwarf_view (view
, 8, 1);
5966 printf (_("views at %8.8lx for:\n %*s "),
5967 (unsigned long) off
, 8, "");
5975 case 0: /* A terminating entry. */
5977 *vstart_ptr
= vstart
;
5978 printf (_("<End of list>\n"));
5980 case 1: /* A base-address entry. */
5981 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5982 start
+= bytes_read
;
5983 print_addr_index (idx
, 8);
5984 printf ("%*s", 9 + (vstart
? 2 * 6 : 0), "");
5985 printf (_("(base address selection entry)\n"));
5987 case 2: /* A start/end entry. */
5988 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5989 start
+= bytes_read
;
5990 print_addr_index (idx
, 8);
5991 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5992 start
+= bytes_read
;
5993 print_addr_index (idx
, 8);
5995 case 3: /* A start/length entry. */
5996 idx
= read_uleb128 (start
, &bytes_read
, section_end
);
5997 start
+= bytes_read
;
5998 print_addr_index (idx
, 8);
5999 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
6000 printf ("%08x ", idx
);
6002 case 4: /* An offset pair entry. */
6003 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
6004 printf ("%08x ", idx
);
6005 SAFE_BYTE_GET_AND_INC (idx
, start
, 4, section_end
);
6006 printf ("%08x ", idx
);
6009 warn (_("Unknown location list entry type 0x%x.\n"), entry_type
);
6011 *vstart_ptr
= vstart
;
6015 if (start
+ 2 > section_end
)
6017 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
6018 (unsigned long) offset
);
6022 SAFE_BYTE_GET_AND_INC (length
, start
, 2, section_end
);
6023 if (start
+ length
> section_end
)
6025 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
6026 (unsigned long) offset
);
6031 need_frame_base
= decode_location_expression (start
,
6036 cu_offset
, section
);
6039 if (need_frame_base
&& !has_frame_base
)
6040 printf (_(" [without DW_AT_frame_base]"));
6048 *vstart_ptr
= vstart
;
6051 /* Sort array of indexes in ascending order of loc_offsets[idx] and
6054 static dwarf_vma
*loc_offsets
, *loc_views
;
6057 loc_offsets_compar (const void *ap
, const void *bp
)
6059 dwarf_vma a
= loc_offsets
[*(const unsigned int *) ap
];
6060 dwarf_vma b
= loc_offsets
[*(const unsigned int *) bp
];
6062 int ret
= (a
> b
) - (b
> a
);
6066 a
= loc_views
[*(const unsigned int *) ap
];
6067 b
= loc_views
[*(const unsigned int *) bp
];
6069 ret
= (a
> b
) - (b
> a
);
6075 display_debug_loc (struct dwarf_section
*section
, void *file
)
6077 unsigned char *start
= section
->start
, *vstart
= NULL
;
6078 unsigned long bytes
;
6079 unsigned char *section_begin
= start
;
6080 unsigned int num_loc_list
= 0;
6081 unsigned long last_offset
= 0;
6082 unsigned long last_view
= 0;
6083 unsigned int first
= 0;
6086 int seen_first_offset
= 0;
6087 int locs_sorted
= 1;
6088 unsigned char *next
= start
, *vnext
= vstart
;
6089 unsigned int *array
= NULL
;
6090 const char *suffix
= strrchr (section
->name
, '.');
6091 bfd_boolean is_dwo
= FALSE
;
6092 int is_loclists
= strstr (section
->name
, "debug_loclists") != NULL
;
6093 dwarf_vma expected_start
= 0;
6095 if (suffix
&& strcmp (suffix
, ".dwo") == 0)
6098 bytes
= section
->size
;
6102 printf (_("\nThe %s section is empty.\n"), section
->name
);
6108 unsigned char *hdrptr
= section_begin
;
6109 dwarf_vma ll_length
;
6110 unsigned short ll_version
;
6111 unsigned char *end
= section_begin
+ section
->size
;
6112 unsigned char address_size
, segment_selector_size
;
6113 uint32_t offset_entry_count
;
6115 SAFE_BYTE_GET_AND_INC (ll_length
, hdrptr
, 4, end
);
6116 if (ll_length
== 0xffffffff)
6117 SAFE_BYTE_GET_AND_INC (ll_length
, hdrptr
, 8, end
);
6119 SAFE_BYTE_GET_AND_INC (ll_version
, hdrptr
, 2, end
);
6120 if (ll_version
!= 5)
6122 warn (_("The %s section contains corrupt or "
6123 "unsupported version number: %d.\n"),
6124 section
->name
, ll_version
);
6128 SAFE_BYTE_GET_AND_INC (address_size
, hdrptr
, 1, end
);
6130 SAFE_BYTE_GET_AND_INC (segment_selector_size
, hdrptr
, 1, end
);
6131 if (segment_selector_size
!= 0)
6133 warn (_("The %s section contains "
6134 "unsupported segment selector size: %d.\n"),
6135 section
->name
, segment_selector_size
);
6139 SAFE_BYTE_GET_AND_INC (offset_entry_count
, hdrptr
, 4, end
);
6140 if (offset_entry_count
!= 0)
6142 warn (_("The %s section contains "
6143 "unsupported offset entry count: %d.\n"),
6144 section
->name
, offset_entry_count
);
6148 expected_start
= hdrptr
- section_begin
;
6151 if (load_debug_info (file
) == 0)
6153 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
6158 /* Check the order of location list in .debug_info section. If
6159 offsets of location lists are in the ascending order, we can
6160 use `debug_information' directly. */
6161 for (i
= 0; i
< num_debug_info_entries
; i
++)
6165 num
= debug_information
[i
].num_loc_offsets
;
6166 if (num
> num_loc_list
)
6169 /* Check if we can use `debug_information' directly. */
6170 if (locs_sorted
&& num
!= 0)
6172 if (!seen_first_offset
)
6174 /* This is the first location list. */
6175 last_offset
= debug_information
[i
].loc_offsets
[0];
6176 last_view
= debug_information
[i
].loc_views
[0];
6178 seen_first_offset
= 1;
6184 for (; j
< num
; j
++)
6187 debug_information
[i
].loc_offsets
[j
]
6188 || (last_offset
== debug_information
[i
].loc_offsets
[j
]
6189 && last_view
> debug_information
[i
].loc_views
[j
]))
6194 last_offset
= debug_information
[i
].loc_offsets
[j
];
6195 last_view
= debug_information
[i
].loc_views
[j
];
6200 if (!seen_first_offset
)
6201 error (_("No location lists in .debug_info section!\n"));
6203 if (debug_information
[first
].num_loc_offsets
> 0
6204 && debug_information
[first
].loc_offsets
[0] != expected_start
6205 && debug_information
[first
].loc_views
[0] != expected_start
)
6206 warn (_("Location lists in %s section start at 0x%s\n"),
6208 dwarf_vmatoa ("x", debug_information
[first
].loc_offsets
[0]));
6211 array
= (unsigned int *) xcmalloc (num_loc_list
, sizeof (unsigned int));
6213 introduce (section
, FALSE
);
6215 if (reloc_at (section
, 0))
6216 printf (_(" Warning: This section has relocations - addresses seen here may not be accurate.\n\n"));
6218 printf (_(" Offset Begin End Expression\n"));
6220 seen_first_offset
= 0;
6221 for (i
= first
; i
< num_debug_info_entries
; i
++)
6223 dwarf_vma offset
, voffset
;
6224 dwarf_vma base_address
;
6230 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
6232 loc_offsets
= debug_information
[i
].loc_offsets
;
6233 loc_views
= debug_information
[i
].loc_views
;
6234 qsort (array
, debug_information
[i
].num_loc_offsets
,
6235 sizeof (*array
), loc_offsets_compar
);
6238 int adjacent_view_loclists
= 1;
6239 for (k
= 0; k
< debug_information
[i
].num_loc_offsets
; k
++)
6241 j
= locs_sorted
? k
: array
[k
];
6243 && (debug_information
[i
].loc_offsets
[locs_sorted
6244 ? k
- 1 : array
[k
- 1]]
6245 == debug_information
[i
].loc_offsets
[j
])
6246 && (debug_information
[i
].loc_views
[locs_sorted
6247 ? k
- 1 : array
[k
- 1]]
6248 == debug_information
[i
].loc_views
[j
]))
6250 has_frame_base
= debug_information
[i
].have_frame_base
[j
];
6251 offset
= debug_information
[i
].loc_offsets
[j
];
6252 next
= section_begin
+ offset
;
6253 voffset
= debug_information
[i
].loc_views
[j
];
6255 vnext
= section_begin
+ voffset
;
6258 base_address
= debug_information
[i
].base_address
;
6260 if (vnext
&& vnext
< next
)
6263 display_view_pair_list (section
, &vstart
, i
, next
);
6268 if (!seen_first_offset
|| !adjacent_view_loclists
)
6269 seen_first_offset
= 1;
6273 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
6274 (unsigned long) (start
- section_begin
),
6275 (unsigned long) offset
);
6276 else if (start
> next
)
6277 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
6278 (unsigned long) (start
- section_begin
),
6279 (unsigned long) offset
);
6284 if (offset
>= bytes
)
6286 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
6287 (unsigned long) offset
);
6291 if (vnext
&& voffset
>= bytes
)
6293 warn (_("View Offset 0x%lx is bigger than .debug_loc section size.\n"),
6294 (unsigned long) voffset
);
6301 display_loc_list_dwo (section
, &start
, i
, offset
,
6302 &vstart
, has_frame_base
);
6304 display_loc_list (section
, &start
, i
, offset
, base_address
,
6305 &vstart
, has_frame_base
);
6310 warn (_("DWO is not yet supported.\n"));
6312 display_loclists_list (section
, &start
, i
, offset
, base_address
,
6313 &vstart
, has_frame_base
);
6316 /* FIXME: this arrangement is quite simplistic. Nothing
6317 requires locview lists to be adjacent to corresponding
6318 loclists, and a single loclist could be augmented by
6319 different locview lists, and vice-versa, unlikely as it
6320 is that it would make sense to do so. Hopefully we'll
6321 have view pair support built into loclists before we ever
6322 need to address all these possibilities. */
6323 if (adjacent_view_loclists
&& vnext
6324 && vnext
!= start
&& vstart
!= next
)
6326 adjacent_view_loclists
= 0;
6327 warn (_("Hole and overlap detection requires adjacent view lists and loclists.\n"));
6330 if (vnext
&& vnext
== start
)
6331 display_view_pair_list (section
, &start
, i
, vstart
);
6335 if (start
< section
->start
+ section
->size
)
6336 warn (ngettext ("There is %ld unused byte at the end of section %s\n",
6337 "There are %ld unused bytes at the end of section %s\n",
6338 (long) (section
->start
+ section
->size
- start
)),
6339 (long) (section
->start
+ section
->size
- start
), section
->name
);
6346 display_debug_str (struct dwarf_section
*section
,
6347 void *file ATTRIBUTE_UNUSED
)
6349 unsigned char *start
= section
->start
;
6350 unsigned long bytes
= section
->size
;
6351 dwarf_vma addr
= section
->address
;
6355 printf (_("\nThe %s section is empty.\n"), section
->name
);
6359 introduce (section
, FALSE
);
6367 lbytes
= (bytes
> 16 ? 16 : bytes
);
6369 printf (" 0x%8.8lx ", (unsigned long) addr
);
6371 for (j
= 0; j
< 16; j
++)
6374 printf ("%2.2x", start
[j
]);
6382 for (j
= 0; j
< lbytes
; j
++)
6385 if (k
>= ' ' && k
< 0x80)
6404 display_debug_info (struct dwarf_section
*section
, void *file
)
6406 return process_debug_info (section
, file
, section
->abbrev_sec
, FALSE
, FALSE
);
6410 display_debug_types (struct dwarf_section
*section
, void *file
)
6412 return process_debug_info (section
, file
, section
->abbrev_sec
, FALSE
, TRUE
);
6416 display_trace_info (struct dwarf_section
*section
, void *file
)
6418 return process_debug_info (section
, file
, section
->abbrev_sec
, FALSE
, TRUE
);
6422 display_debug_aranges (struct dwarf_section
*section
,
6423 void *file ATTRIBUTE_UNUSED
)
6425 unsigned char *start
= section
->start
;
6426 unsigned char *end
= start
+ section
->size
;
6428 introduce (section
, FALSE
);
6430 /* It does not matter if this load fails,
6431 we test for that later on. */
6432 load_debug_info (file
);
6436 unsigned char *hdrptr
;
6437 DWARF2_Internal_ARange arange
;
6438 unsigned char *addr_ranges
;
6441 unsigned long sec_off
;
6442 unsigned char address_size
;
6444 unsigned int offset_size
;
6445 unsigned int initial_length_size
;
6449 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 4, end
);
6450 if (arange
.ar_length
== 0xffffffff)
6452 SAFE_BYTE_GET_AND_INC (arange
.ar_length
, hdrptr
, 8, end
);
6454 initial_length_size
= 12;
6459 initial_length_size
= 4;
6462 sec_off
= hdrptr
- section
->start
;
6463 if (sec_off
+ arange
.ar_length
< sec_off
6464 || sec_off
+ arange
.ar_length
> section
->size
)
6466 warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"),
6468 sec_off
- initial_length_size
,
6469 dwarf_vmatoa ("x", arange
.ar_length
));
6473 SAFE_BYTE_GET_AND_INC (arange
.ar_version
, hdrptr
, 2, end
);
6474 SAFE_BYTE_GET_AND_INC (arange
.ar_info_offset
, hdrptr
, offset_size
, end
);
6476 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
6477 && num_debug_info_entries
> 0
6478 && find_debug_info_for_offset (arange
.ar_info_offset
) == NULL
)
6479 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
6480 (unsigned long) arange
.ar_info_offset
, section
->name
);
6482 SAFE_BYTE_GET_AND_INC (arange
.ar_pointer_size
, hdrptr
, 1, end
);
6483 SAFE_BYTE_GET_AND_INC (arange
.ar_segment_size
, hdrptr
, 1, end
);
6485 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
6487 /* PR 19872: A version number of 0 probably means that there is
6488 padding at the end of the .debug_aranges section. Gold puts
6489 it there when performing an incremental link, for example.
6490 So do not generate a warning in this case. */
6491 if (arange
.ar_version
)
6492 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
6496 printf (_(" Length: %ld\n"),
6497 (long) arange
.ar_length
);
6498 printf (_(" Version: %d\n"), arange
.ar_version
);
6499 printf (_(" Offset into .debug_info: 0x%lx\n"),
6500 (unsigned long) arange
.ar_info_offset
);
6501 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
6502 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
6504 address_size
= arange
.ar_pointer_size
+ arange
.ar_segment_size
;
6506 /* PR 17512: file: 001-108546-0.001:0.1. */
6507 if (address_size
== 0 || address_size
> 8)
6509 error (_("Invalid address size in %s section!\n"),
6514 /* The DWARF spec does not require that the address size be a power
6515 of two, but we do. This will have to change if we ever encounter
6516 an uneven architecture. */
6517 if ((address_size
& (address_size
- 1)) != 0)
6519 warn (_("Pointer size + Segment size is not a power of two.\n"));
6523 if (address_size
> 4)
6524 printf (_("\n Address Length\n"));
6526 printf (_("\n Address Length\n"));
6528 addr_ranges
= hdrptr
;
6530 /* Must pad to an alignment boundary that is twice the address size. */
6531 excess
= (hdrptr
- start
) % (2 * address_size
);
6533 addr_ranges
+= (2 * address_size
) - excess
;
6535 start
+= arange
.ar_length
+ initial_length_size
;
6537 while (addr_ranges
+ 2 * address_size
<= start
)
6539 SAFE_BYTE_GET_AND_INC (address
, addr_ranges
, address_size
, end
);
6540 SAFE_BYTE_GET_AND_INC (length
, addr_ranges
, address_size
, end
);
6543 print_dwarf_vma (address
, address_size
);
6544 print_dwarf_vma (length
, address_size
);
6554 /* Comparison function for qsort. */
6556 comp_addr_base (const void * v0
, const void * v1
)
6558 debug_info
*info0
= *(debug_info
**) v0
;
6559 debug_info
*info1
= *(debug_info
**) v1
;
6560 return info0
->addr_base
- info1
->addr_base
;
6563 /* Display the debug_addr section. */
6565 display_debug_addr (struct dwarf_section
*section
,
6568 debug_info
**debug_addr_info
;
6569 unsigned char *entry
;
6574 if (section
->size
== 0)
6576 printf (_("\nThe %s section is empty.\n"), section
->name
);
6580 if (load_debug_info (file
) == 0)
6582 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
6587 introduce (section
, FALSE
);
6589 /* PR 17531: file: cf38d01b.
6590 We use xcalloc because a corrupt file may not have initialised all of the
6591 fields in the debug_info structure, which means that the sort below might
6592 try to move uninitialised data. */
6593 debug_addr_info
= (debug_info
**) xcalloc ((num_debug_info_entries
+ 1),
6594 sizeof (debug_info
*));
6597 for (i
= 0; i
< num_debug_info_entries
; i
++)
6598 if (debug_information
[i
].addr_base
!= DEBUG_INFO_UNAVAILABLE
)
6600 /* PR 17531: file: cf38d01b. */
6601 if (debug_information
[i
].addr_base
>= section
->size
)
6602 warn (_("Corrupt address base (%lx) found in debug section %u\n"),
6603 (unsigned long) debug_information
[i
].addr_base
, i
);
6605 debug_addr_info
[count
++] = debug_information
+ i
;
6608 /* Add a sentinel to make iteration convenient. */
6609 debug_addr_info
[count
] = (debug_info
*) xmalloc (sizeof (debug_info
));
6610 debug_addr_info
[count
]->addr_base
= section
->size
;
6611 qsort (debug_addr_info
, count
, sizeof (debug_info
*), comp_addr_base
);
6613 for (i
= 0; i
< count
; i
++)
6616 unsigned int address_size
= debug_addr_info
[i
]->pointer_size
;
6618 printf (_(" For compilation unit at offset 0x%s:\n"),
6619 dwarf_vmatoa ("x", debug_addr_info
[i
]->cu_offset
));
6621 printf (_("\tIndex\tAddress\n"));
6622 entry
= section
->start
+ debug_addr_info
[i
]->addr_base
;
6623 end
= section
->start
+ debug_addr_info
[i
+ 1]->addr_base
;
6627 dwarf_vma base
= byte_get (entry
, address_size
);
6628 printf (_("\t%d:\t"), idx
);
6629 print_dwarf_vma (base
, address_size
);
6631 entry
+= address_size
;
6637 free (debug_addr_info
);
6641 /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */
6644 display_debug_str_offsets (struct dwarf_section
*section
,
6645 void *file ATTRIBUTE_UNUSED
)
6647 if (section
->size
== 0)
6649 printf (_("\nThe %s section is empty.\n"), section
->name
);
6652 /* TODO: Dump the contents. This is made somewhat difficult by not knowing
6653 what the offset size is for this section. */
6657 /* Each debug_information[x].range_lists[y] gets this representation for
6658 sorting purposes. */
6662 /* The debug_information[x].range_lists[y] value. */
6663 dwarf_vma ranges_offset
;
6665 /* Original debug_information to find parameters of the data. */
6666 debug_info
*debug_info_p
;
6669 /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */
6672 range_entry_compar (const void *ap
, const void *bp
)
6674 const struct range_entry
*a_re
= (const struct range_entry
*) ap
;
6675 const struct range_entry
*b_re
= (const struct range_entry
*) bp
;
6676 const dwarf_vma a
= a_re
->ranges_offset
;
6677 const dwarf_vma b
= b_re
->ranges_offset
;
6679 return (a
> b
) - (b
> a
);
6683 display_debug_ranges_list (unsigned char *start
, unsigned char *finish
,
6684 unsigned int pointer_size
, unsigned long offset
,
6685 unsigned long base_address
)
6687 while (start
< finish
)
6692 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
6693 if (start
>= finish
)
6695 SAFE_SIGNED_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
6698 printf (" %8.8lx ", offset
);
6700 if (begin
== 0 && end
== 0)
6702 printf (_("<End of list>\n"));
6706 /* Check base address specifiers. */
6707 if (is_max_address (begin
, pointer_size
)
6708 && !is_max_address (end
, pointer_size
))
6711 print_dwarf_vma (begin
, pointer_size
);
6712 print_dwarf_vma (end
, pointer_size
);
6713 printf ("(base address)\n");
6717 print_dwarf_vma (begin
+ base_address
, pointer_size
);
6718 print_dwarf_vma (end
+ base_address
, pointer_size
);
6721 fputs (_("(start == end)"), stdout
);
6722 else if (begin
> end
)
6723 fputs (_("(start > end)"), stdout
);
6730 display_debug_rnglists_list (unsigned char *start
, unsigned char *finish
,
6731 unsigned int pointer_size
, unsigned long offset
,
6732 unsigned long base_address
)
6734 unsigned char *next
= start
;
6738 unsigned long off
= offset
+ (start
- next
);
6739 enum dwarf_range_list_entry rlet
;
6740 /* Initialize it due to a false compiler warning. */
6741 dwarf_vma begin
= -1, length
, end
= -1;
6742 unsigned int bytes_read
;
6744 if (start
+ 1 > finish
)
6746 warn (_("Range list starting at offset 0x%lx is not terminated.\n"),
6751 printf (" %8.8lx ", off
);
6753 SAFE_BYTE_GET_AND_INC (rlet
, start
, 1, finish
);
6757 case DW_RLE_end_of_list
:
6758 printf (_("<End of list>\n"));
6760 case DW_RLE_base_address
:
6761 SAFE_BYTE_GET_AND_INC (base_address
, start
, pointer_size
, finish
);
6762 print_dwarf_vma (base_address
, pointer_size
);
6763 printf (_("(base address)\n"));
6765 case DW_RLE_start_length
:
6766 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
6767 length
= read_uleb128 (start
, &bytes_read
, finish
);
6768 start
+= bytes_read
;
6769 end
= begin
+ length
;
6771 case DW_RLE_offset_pair
:
6772 begin
= read_uleb128 (start
, &bytes_read
, finish
);
6773 start
+= bytes_read
;
6774 end
= read_uleb128 (start
, &bytes_read
, finish
);
6775 start
+= bytes_read
;
6777 case DW_RLE_start_end
:
6778 SAFE_BYTE_GET_AND_INC (begin
, start
, pointer_size
, finish
);
6779 SAFE_BYTE_GET_AND_INC (end
, start
, pointer_size
, finish
);
6782 error (_("Invalid range list entry type %d\n"), rlet
);
6783 rlet
= DW_RLE_end_of_list
;
6786 if (rlet
== DW_RLE_end_of_list
)
6788 if (rlet
== DW_RLE_base_address
)
6791 print_dwarf_vma (begin
+ base_address
, pointer_size
);
6792 print_dwarf_vma (end
+ base_address
, pointer_size
);
6795 fputs (_("(start == end)"), stdout
);
6796 else if (begin
> end
)
6797 fputs (_("(start > end)"), stdout
);
6804 display_debug_ranges (struct dwarf_section
*section
,
6805 void *file ATTRIBUTE_UNUSED
)
6807 unsigned char *start
= section
->start
;
6808 unsigned char *last_start
= start
;
6809 unsigned long bytes
= section
->size
;
6810 unsigned char *section_begin
= start
;
6811 unsigned char *finish
= start
+ bytes
;
6812 unsigned int num_range_list
, i
;
6813 struct range_entry
*range_entries
, *range_entry_fill
;
6814 int is_rnglists
= strstr (section
->name
, "debug_rnglists") != NULL
;
6815 /* Initialize it due to a false compiler warning. */
6816 unsigned char address_size
= 0;
6820 printf (_("\nThe %s section is empty.\n"), section
->name
);
6826 dwarf_vma initial_length
;
6827 unsigned int initial_length_size
;
6828 unsigned char segment_selector_size
;
6829 unsigned int offset_size
, offset_entry_count
;
6830 unsigned short version
;
6832 /* Get and check the length of the block. */
6833 SAFE_BYTE_GET_AND_INC (initial_length
, start
, 4, finish
);
6835 if (initial_length
== 0xffffffff)
6837 /* This section is 64-bit DWARF 3. */
6838 SAFE_BYTE_GET_AND_INC (initial_length
, start
, 8, finish
);
6840 initial_length_size
= 12;
6845 initial_length_size
= 4;
6848 if (initial_length
+ initial_length_size
> section
->size
)
6850 /* If the length field has a relocation against it, then we should
6851 not complain if it is inaccurate (and probably negative).
6852 It is copied from .debug_line handling code. */
6853 if (reloc_at (section
, (start
- section
->start
) - offset_size
))
6855 initial_length
= (finish
- start
) - initial_length_size
;
6859 warn (_("The length field (0x%lx) in the debug_rnglists header is wrong - the section is too small\n"),
6860 (long) initial_length
);
6865 /* Get and check the version number. */
6866 SAFE_BYTE_GET_AND_INC (version
, start
, 2, finish
);
6870 warn (_("Only DWARF version 5 debug_rnglists info "
6871 "is currently supported.\n"));
6875 SAFE_BYTE_GET_AND_INC (address_size
, start
, 1, finish
);
6877 SAFE_BYTE_GET_AND_INC (segment_selector_size
, start
, 1, finish
);
6878 if (segment_selector_size
!= 0)
6880 warn (_("The %s section contains "
6881 "unsupported segment selector size: %d.\n"),
6882 section
->name
, segment_selector_size
);
6886 SAFE_BYTE_GET_AND_INC (offset_entry_count
, start
, 4, finish
);
6887 if (offset_entry_count
!= 0)
6889 warn (_("The %s section contains "
6890 "unsupported offset entry count: %u.\n"),
6891 section
->name
, offset_entry_count
);
6896 if (load_debug_info (file
) == 0)
6898 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
6904 for (i
= 0; i
< num_debug_info_entries
; i
++)
6905 num_range_list
+= debug_information
[i
].num_range_lists
;
6907 if (num_range_list
== 0)
6909 /* This can happen when the file was compiled with -gsplit-debug
6910 which removes references to range lists from the primary .o file. */
6911 printf (_("No range lists in .debug_info section.\n"));
6915 range_entries
= (struct range_entry
*)
6916 xmalloc (sizeof (*range_entries
) * num_range_list
);
6917 range_entry_fill
= range_entries
;
6919 for (i
= 0; i
< num_debug_info_entries
; i
++)
6921 debug_info
*debug_info_p
= &debug_information
[i
];
6924 for (j
= 0; j
< debug_info_p
->num_range_lists
; j
++)
6926 range_entry_fill
->ranges_offset
= debug_info_p
->range_lists
[j
];
6927 range_entry_fill
->debug_info_p
= debug_info_p
;
6932 qsort (range_entries
, num_range_list
, sizeof (*range_entries
),
6933 range_entry_compar
);
6935 if (dwarf_check
!= 0 && range_entries
[0].ranges_offset
!= 0)
6936 warn (_("Range lists in %s section start at 0x%lx\n"),
6937 section
->name
, (unsigned long) range_entries
[0].ranges_offset
);
6939 introduce (section
, FALSE
);
6941 printf (_(" Offset Begin End\n"));
6943 for (i
= 0; i
< num_range_list
; i
++)
6945 struct range_entry
*range_entry
= &range_entries
[i
];
6946 debug_info
*debug_info_p
= range_entry
->debug_info_p
;
6947 unsigned int pointer_size
;
6949 unsigned char *next
;
6950 dwarf_vma base_address
;
6952 pointer_size
= (is_rnglists
? address_size
: debug_info_p
->pointer_size
);
6953 offset
= range_entry
->ranges_offset
;
6954 next
= section_begin
+ offset
;
6955 base_address
= debug_info_p
->base_address
;
6957 /* PR 17512: file: 001-101485-0.001:0.1. */
6958 if (pointer_size
< 2 || pointer_size
> 8)
6960 warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"),
6961 pointer_size
, (unsigned long) offset
);
6965 if (next
< section_begin
|| next
>= finish
)
6967 warn (_("Corrupt offset (%#8.8lx) in range entry %u\n"),
6968 (unsigned long) offset
, i
);
6972 if (dwarf_check
!= 0 && i
> 0)
6975 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
6976 (unsigned long) (start
- section_begin
),
6977 (unsigned long) (next
- section_begin
), section
->name
);
6978 else if (start
> next
)
6980 if (next
== last_start
)
6982 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
6983 (unsigned long) (start
- section_begin
),
6984 (unsigned long) (next
- section_begin
), section
->name
);
6991 (is_rnglists
? display_debug_rnglists_list
: display_debug_ranges_list
)
6992 (start
, finish
, pointer_size
, offset
, base_address
);
6996 free (range_entries
);
7001 typedef struct Frame_Chunk
7003 struct Frame_Chunk
*next
;
7004 unsigned char *chunk_start
;
7006 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
7007 short int *col_type
;
7010 unsigned int code_factor
;
7014 unsigned int cfa_reg
;
7015 dwarf_vma cfa_offset
;
7017 unsigned char fde_encoding
;
7018 unsigned char cfa_exp
;
7019 unsigned char ptr_size
;
7020 unsigned char segment_size
;
7024 static const char *const *dwarf_regnames
;
7025 static unsigned int dwarf_regnames_count
;
7027 /* A marker for a col_type that means this column was never referenced
7028 in the frame info. */
7029 #define DW_CFA_unreferenced (-1)
7031 /* Return 0 if no more space is needed, 1 if more space is needed,
7032 -1 for invalid reg. */
7035 frame_need_space (Frame_Chunk
*fc
, unsigned int reg
)
7037 unsigned int prev
= fc
->ncols
;
7039 if (reg
< (unsigned int) fc
->ncols
)
7042 if (dwarf_regnames_count
7043 && reg
> dwarf_regnames_count
)
7046 fc
->ncols
= reg
+ 1;
7047 /* PR 17512: file: 10450-2643-0.004.
7048 If reg == -1 then this can happen... */
7052 /* PR 17512: file: 2844a11d. */
7053 if (fc
->ncols
> 1024)
7055 error (_("Unfeasibly large register number: %u\n"), reg
);
7057 /* FIXME: 1024 is an arbitrary limit. Increase it if
7058 we ever encounter a valid binary that exceeds it. */
7062 fc
->col_type
= (short int *) xcrealloc (fc
->col_type
, fc
->ncols
,
7063 sizeof (short int));
7064 fc
->col_offset
= (int *) xcrealloc (fc
->col_offset
, fc
->ncols
, sizeof (int));
7065 /* PR 17512: file:002-10025-0.005. */
7066 if (fc
->col_type
== NULL
|| fc
->col_offset
== NULL
)
7068 error (_("Out of memory allocating %u columns in dwarf frame arrays\n"),
7074 while (prev
< fc
->ncols
)
7076 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
7077 fc
->col_offset
[prev
] = 0;
7083 static const char *const dwarf_regnames_i386
[] =
7085 "eax", "ecx", "edx", "ebx", /* 0 - 3 */
7086 "esp", "ebp", "esi", "edi", /* 4 - 7 */
7087 "eip", "eflags", NULL
, /* 8 - 10 */
7088 "st0", "st1", "st2", "st3", /* 11 - 14 */
7089 "st4", "st5", "st6", "st7", /* 15 - 18 */
7090 NULL
, NULL
, /* 19 - 20 */
7091 "xmm0", "xmm1", "xmm2", "xmm3", /* 21 - 24 */
7092 "xmm4", "xmm5", "xmm6", "xmm7", /* 25 - 28 */
7093 "mm0", "mm1", "mm2", "mm3", /* 29 - 32 */
7094 "mm4", "mm5", "mm6", "mm7", /* 33 - 36 */
7095 "fcw", "fsw", "mxcsr", /* 37 - 39 */
7096 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
, /* 40 - 47 */
7097 "tr", "ldtr", /* 48 - 49 */
7098 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 50 - 57 */
7099 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 58 - 65 */
7100 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 66 - 73 */
7101 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 74 - 81 */
7102 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 82 - 89 */
7103 NULL
, NULL
, NULL
, /* 90 - 92 */
7104 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" /* 93 - 100 */
7107 static const char *const dwarf_regnames_iamcu
[] =
7109 "eax", "ecx", "edx", "ebx", /* 0 - 3 */
7110 "esp", "ebp", "esi", "edi", /* 4 - 7 */
7111 "eip", "eflags", NULL
, /* 8 - 10 */
7112 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 11 - 18 */
7113 NULL
, NULL
, /* 19 - 20 */
7114 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 21 - 28 */
7115 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 29 - 36 */
7116 NULL
, NULL
, NULL
, /* 37 - 39 */
7117 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
, /* 40 - 47 */
7118 "tr", "ldtr", /* 48 - 49 */
7119 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 50 - 57 */
7120 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 58 - 65 */
7121 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 66 - 73 */
7122 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 74 - 81 */
7123 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 82 - 89 */
7124 NULL
, NULL
, NULL
, /* 90 - 92 */
7125 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
/* 93 - 100 */
7129 init_dwarf_regnames_i386 (void)
7131 dwarf_regnames
= dwarf_regnames_i386
;
7132 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_i386
);
7136 init_dwarf_regnames_iamcu (void)
7138 dwarf_regnames
= dwarf_regnames_iamcu
;
7139 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_iamcu
);
7142 static const char *const dwarf_regnames_x86_64
[] =
7144 "rax", "rdx", "rcx", "rbx",
7145 "rsi", "rdi", "rbp", "rsp",
7146 "r8", "r9", "r10", "r11",
7147 "r12", "r13", "r14", "r15",
7149 "xmm0", "xmm1", "xmm2", "xmm3",
7150 "xmm4", "xmm5", "xmm6", "xmm7",
7151 "xmm8", "xmm9", "xmm10", "xmm11",
7152 "xmm12", "xmm13", "xmm14", "xmm15",
7153 "st0", "st1", "st2", "st3",
7154 "st4", "st5", "st6", "st7",
7155 "mm0", "mm1", "mm2", "mm3",
7156 "mm4", "mm5", "mm6", "mm7",
7158 "es", "cs", "ss", "ds", "fs", "gs", NULL
, NULL
,
7159 "fs.base", "gs.base", NULL
, NULL
,
7161 "mxcsr", "fcw", "fsw",
7162 "xmm16", "xmm17", "xmm18", "xmm19",
7163 "xmm20", "xmm21", "xmm22", "xmm23",
7164 "xmm24", "xmm25", "xmm26", "xmm27",
7165 "xmm28", "xmm29", "xmm30", "xmm31",
7166 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 83 - 90 */
7167 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 91 - 98 */
7168 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 99 - 106 */
7169 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, /* 107 - 114 */
7170 NULL
, NULL
, NULL
, /* 115 - 117 */
7171 "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7"
7175 init_dwarf_regnames_x86_64 (void)
7177 dwarf_regnames
= dwarf_regnames_x86_64
;
7178 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_x86_64
);
7181 static const char *const dwarf_regnames_aarch64
[] =
7183 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
7184 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
7185 "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
7186 "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp",
7187 NULL
, "elr", NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
7188 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, "vg", "ffr",
7189 "p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7",
7190 "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15",
7191 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
7192 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
7193 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
7194 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
7195 "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7",
7196 "z8", "z9", "z10", "z11", "z12", "z13", "z14", "z15",
7197 "z16", "z17", "z18", "z19", "z20", "z21", "z22", "z23",
7198 "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
7202 init_dwarf_regnames_aarch64 (void)
7204 dwarf_regnames
= dwarf_regnames_aarch64
;
7205 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_aarch64
);
7208 static const char *const dwarf_regnames_s390
[] =
7210 /* Avoid saying "r5 (r5)", so omit the names of r0-r15. */
7211 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
7212 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
7213 "f0", "f2", "f4", "f6", "f1", "f3", "f5", "f7",
7214 "f8", "f10", "f12", "f14", "f9", "f11", "f13", "f15",
7215 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
7216 "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", "cr15",
7217 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
7218 "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
7221 "v16", "v18", "v20", "v22", "v17", "v19", "v21", "v23",
7222 "v24", "v26", "v28", "v30", "v25", "v27", "v29", "v31",
7226 init_dwarf_regnames_s390 (void)
7228 dwarf_regnames
= dwarf_regnames_s390
;
7229 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_s390
);
7232 static const char *const dwarf_regnames_riscv
[] =
7234 "zero", "ra", "sp", "gp", "tp", "t0", "t1", "t2", /* 0 - 7 */
7235 "s0", "s1", "a0", "a1", "a2", "a3", "a4", "a5", /* 8 - 15 */
7236 "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7", /* 16 - 23 */
7237 "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6", /* 24 - 31 */
7238 "ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7", /* 32 - 39 */
7239 "fs0", "fs1", /* 40 - 41 */
7240 "fa0", "fa1", "fa2", "fa3", "fa4", "fa5", "fa6", "fa7", /* 42 - 49 */
7241 "fs2", "fs3", "fs4", "fs5", "fs6", "fs7", "fs8", "fs9", /* 50 - 57 */
7242 "fs10", "fs11", /* 58 - 59 */
7243 "ft8", "ft9", "ft10", "ft11" /* 60 - 63 */
7247 init_dwarf_regnames_riscv (void)
7249 dwarf_regnames
= dwarf_regnames_riscv
;
7250 dwarf_regnames_count
= ARRAY_SIZE (dwarf_regnames_riscv
);
7254 init_dwarf_regnames (unsigned int e_machine
)
7259 init_dwarf_regnames_i386 ();
7263 init_dwarf_regnames_iamcu ();
7269 init_dwarf_regnames_x86_64 ();
7273 init_dwarf_regnames_aarch64 ();
7277 init_dwarf_regnames_s390 ();
7281 init_dwarf_regnames_riscv ();
7290 regname (unsigned int regno
, int row
)
7292 static char reg
[64];
7295 && regno
< dwarf_regnames_count
7296 && dwarf_regnames
[regno
] != NULL
)
7299 return dwarf_regnames
[regno
];
7300 snprintf (reg
, sizeof (reg
), "r%d (%s)", regno
,
7301 dwarf_regnames
[regno
]);
7304 snprintf (reg
, sizeof (reg
), "r%d", regno
);
7309 frame_display_row (Frame_Chunk
*fc
, int *need_col_headers
, unsigned int *max_regs
)
7314 if (*max_regs
!= fc
->ncols
)
7315 *max_regs
= fc
->ncols
;
7317 if (*need_col_headers
)
7319 static const char *sloc
= " LOC";
7321 *need_col_headers
= 0;
7323 printf ("%-*s CFA ", eh_addr_size
* 2, sloc
);
7325 for (r
= 0; r
< *max_regs
; r
++)
7326 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
7331 printf ("%-5s ", regname (r
, 1));
7337 print_dwarf_vma (fc
->pc_begin
, eh_addr_size
);
7339 strcpy (tmp
, "exp");
7341 sprintf (tmp
, "%s%+d", regname (fc
->cfa_reg
, 1), (int) fc
->cfa_offset
);
7342 printf ("%-8s ", tmp
);
7344 for (r
= 0; r
< fc
->ncols
; r
++)
7346 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
7348 switch (fc
->col_type
[r
])
7350 case DW_CFA_undefined
:
7353 case DW_CFA_same_value
:
7357 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
7359 case DW_CFA_val_offset
:
7360 sprintf (tmp
, "v%+d", fc
->col_offset
[r
]);
7362 case DW_CFA_register
:
7363 sprintf (tmp
, "%s", regname (fc
->col_offset
[r
], 0));
7365 case DW_CFA_expression
:
7366 strcpy (tmp
, "exp");
7368 case DW_CFA_val_expression
:
7369 strcpy (tmp
, "vexp");
7372 strcpy (tmp
, "n/a");
7375 printf ("%-5s ", tmp
);
7381 #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end)
7383 static unsigned char *
7384 read_cie (unsigned char *start
, unsigned char *end
,
7385 Frame_Chunk
**p_cie
, int *p_version
,
7386 bfd_size_type
*p_aug_len
, unsigned char **p_aug
)
7390 unsigned int length_return
;
7391 unsigned char *augmentation_data
= NULL
;
7392 bfd_size_type augmentation_data_len
= 0;
7395 /* PR 17512: file: 001-228113-0.004. */
7399 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
7400 memset (fc
, 0, sizeof (Frame_Chunk
));
7402 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
7403 fc
->col_offset
= (int *) xmalloc (sizeof (int));
7407 fc
->augmentation
= (char *) start
;
7408 /* PR 17512: file: 001-228113-0.004.
7409 Skip past augmentation name, but avoid running off the end of the data. */
7411 if (* start
++ == '\0')
7415 warn (_("No terminator for augmentation name\n"));
7419 if (strcmp (fc
->augmentation
, "eh") == 0)
7420 start
+= eh_addr_size
;
7424 GET (fc
->ptr_size
, 1);
7425 if (fc
->ptr_size
< 1 || fc
->ptr_size
> 8)
7427 warn (_("Invalid pointer size (%d) in CIE data\n"), fc
->ptr_size
);
7431 GET (fc
->segment_size
, 1);
7432 /* PR 17512: file: e99d2804. */
7433 if (fc
->segment_size
> 8 || fc
->segment_size
+ fc
->ptr_size
> 8)
7435 warn (_("Invalid segment size (%d) in CIE data\n"), fc
->segment_size
);
7439 eh_addr_size
= fc
->ptr_size
;
7443 fc
->ptr_size
= eh_addr_size
;
7444 fc
->segment_size
= 0;
7447 READ_ULEB (fc
->code_factor
);
7448 READ_SLEB (fc
->data_factor
);
7459 if (fc
->augmentation
[0] == 'z')
7461 READ_ULEB (augmentation_data_len
);
7462 augmentation_data
= start
;
7463 /* PR 17512: file: 11042-2589-0.004. */
7464 if (augmentation_data_len
> (bfd_size_type
) (end
- start
))
7466 warn (_("Augmentation data too long: 0x%s, expected at most %#lx\n"),
7467 dwarf_vmatoa ("x", augmentation_data_len
),
7468 (unsigned long) (end
- start
));
7471 start
+= augmentation_data_len
;
7474 if (augmentation_data_len
)
7478 unsigned char *qend
;
7480 p
= (unsigned char *) fc
->augmentation
+ 1;
7481 q
= augmentation_data
;
7482 qend
= q
+ augmentation_data_len
;
7484 while (p
< end
&& q
< qend
)
7489 q
+= 1 + size_of_encoded_value (*q
);
7491 fc
->fde_encoding
= *q
++;
7500 /* Note - it is OK if this loop terminates with q < qend.
7501 Padding may have been inserted to align the end of the CIE. */
7506 *p_version
= version
;
7509 *p_aug_len
= augmentation_data_len
;
7510 *p_aug
= augmentation_data
;
7515 free (fc
->col_offset
);
7516 free (fc
->col_type
);
7521 /* Prints out the contents on the DATA array formatted as unsigned bytes.
7522 If do_wide is not enabled, then formats the output to fit into 80 columns.
7523 PRINTED contains the number of characters already written to the current
7527 display_data (bfd_size_type printed
,
7528 const unsigned char * data
,
7529 const bfd_size_type len
)
7531 if (do_wide
|| len
< ((80 - printed
) / 3))
7532 for (printed
= 0; printed
< len
; ++printed
)
7533 printf (" %02x", data
[printed
]);
7536 for (printed
= 0; printed
< len
; ++printed
)
7538 if (printed
% (80 / 3) == 0)
7540 printf (" %02x", data
[printed
]);
7545 /* Prints out the contents on the augmentation data array.
7546 If do_wide is not enabled, then formats the output to fit into 80 columns. */
7549 display_augmentation_data (const unsigned char * data
, const bfd_size_type len
)
7553 i
= printf (_(" Augmentation data: "));
7554 display_data (i
, data
, len
);
7558 display_debug_frames (struct dwarf_section
*section
,
7559 void *file ATTRIBUTE_UNUSED
)
7561 unsigned char *start
= section
->start
;
7562 unsigned char *end
= start
+ section
->size
;
7563 unsigned char *section_start
= start
;
7564 Frame_Chunk
*chunks
= NULL
, *forward_refs
= NULL
;
7565 Frame_Chunk
*remembered_state
= NULL
;
7567 bfd_boolean is_eh
= strcmp (section
->name
, ".eh_frame") == 0;
7568 unsigned int length_return
;
7569 unsigned int max_regs
= 0;
7570 const char *bad_reg
= _("bad register: ");
7571 unsigned int saved_eh_addr_size
= eh_addr_size
;
7573 introduce (section
, FALSE
);
7577 unsigned char *saved_start
;
7578 unsigned char *block_end
;
7583 int need_col_headers
= 1;
7584 unsigned char *augmentation_data
= NULL
;
7585 bfd_size_type augmentation_data_len
= 0;
7586 unsigned int encoded_ptr_size
= saved_eh_addr_size
;
7587 unsigned int offset_size
;
7588 unsigned int initial_length_size
;
7589 bfd_boolean all_nops
;
7591 saved_start
= start
;
7593 SAFE_BYTE_GET_AND_INC (length
, start
, 4, end
);
7597 printf ("\n%08lx ZERO terminator\n\n",
7598 (unsigned long)(saved_start
- section_start
));
7599 /* Skip any zero terminators that directly follow.
7600 A corrupt section size could have loaded a whole
7601 slew of zero filled memory bytes. eg
7602 PR 17512: file: 070-19381-0.004. */
7603 while (start
< end
&& * start
== 0)
7608 if (length
== 0xffffffff)
7610 SAFE_BYTE_GET_AND_INC (length
, start
, 8, end
);
7612 initial_length_size
= 12;
7617 initial_length_size
= 4;
7620 block_end
= saved_start
+ length
+ initial_length_size
;
7621 if (block_end
> end
|| block_end
< start
)
7623 warn ("Invalid length 0x%s in FDE at %#08lx\n",
7624 dwarf_vmatoa_1 (NULL
, length
, offset_size
),
7625 (unsigned long) (saved_start
- section_start
));
7629 SAFE_BYTE_GET_AND_INC (cie_id
, start
, offset_size
, end
);
7631 if (is_eh
? (cie_id
== 0) : ((offset_size
== 4 && cie_id
== DW_CIE_ID
)
7632 || (offset_size
== 8 && cie_id
== DW64_CIE_ID
)))
7637 start
= read_cie (start
, end
, &cie
, &version
,
7638 &augmentation_data_len
, &augmentation_data
);
7639 /* PR 17512: file: 027-135133-0.005. */
7646 fc
->chunk_start
= saved_start
;
7647 mreg
= max_regs
> 0 ? max_regs
- 1 : 0;
7650 if (frame_need_space (fc
, mreg
) < 0)
7652 if (fc
->fde_encoding
)
7653 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
7655 printf ("\n%08lx ", (unsigned long) (saved_start
- section_start
));
7656 print_dwarf_vma (length
, fc
->ptr_size
);
7657 print_dwarf_vma (cie_id
, offset_size
);
7659 if (do_debug_frames_interp
)
7661 printf ("CIE \"%s\" cf=%d df=%d ra=%d\n", fc
->augmentation
,
7662 fc
->code_factor
, fc
->data_factor
, fc
->ra
);
7667 printf (" Version: %d\n", version
);
7668 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
7671 printf (" Pointer Size: %u\n", fc
->ptr_size
);
7672 printf (" Segment Size: %u\n", fc
->segment_size
);
7674 printf (" Code alignment factor: %u\n", fc
->code_factor
);
7675 printf (" Data alignment factor: %d\n", fc
->data_factor
);
7676 printf (" Return address column: %d\n", fc
->ra
);
7678 if (augmentation_data_len
)
7679 display_augmentation_data (augmentation_data
, augmentation_data_len
);
7686 unsigned char *look_for
;
7687 static Frame_Chunk fde_fc
;
7688 unsigned long segment_selector
;
7692 dwarf_vma sign
= (dwarf_vma
) 1 << (offset_size
* 8 - 1);
7693 look_for
= start
- 4 - ((cie_id
^ sign
) - sign
);
7696 look_for
= section_start
+ cie_id
;
7698 if (look_for
<= saved_start
)
7700 for (cie
= chunks
; cie
; cie
= cie
->next
)
7701 if (cie
->chunk_start
== look_for
)
7706 for (cie
= forward_refs
; cie
; cie
= cie
->next
)
7707 if (cie
->chunk_start
== look_for
)
7711 unsigned int off_size
;
7712 unsigned char *cie_scan
;
7714 cie_scan
= look_for
;
7716 SAFE_BYTE_GET_AND_INC (length
, cie_scan
, 4, end
);
7717 if (length
== 0xffffffff)
7719 SAFE_BYTE_GET_AND_INC (length
, cie_scan
, 8, end
);
7726 SAFE_BYTE_GET_AND_INC (c_id
, cie_scan
, off_size
, end
);
7729 : ((off_size
== 4 && c_id
== DW_CIE_ID
)
7730 || (off_size
== 8 && c_id
== DW64_CIE_ID
)))
7735 read_cie (cie_scan
, end
, &cie
, &version
,
7736 &augmentation_data_len
, &augmentation_data
);
7737 /* PR 17512: file: 3450-2098-0.004. */
7740 warn (_("Failed to read CIE information\n"));
7743 cie
->next
= forward_refs
;
7745 cie
->chunk_start
= look_for
;
7746 mreg
= max_regs
> 0 ? max_regs
- 1 : 0;
7749 if (frame_need_space (cie
, mreg
) < 0)
7751 warn (_("Invalid max register\n"));
7754 if (cie
->fde_encoding
)
7756 = size_of_encoded_value (cie
->fde_encoding
);
7763 memset (fc
, 0, sizeof (Frame_Chunk
));
7767 warn ("Invalid CIE pointer 0x%s in FDE at %#08lx\n",
7768 dwarf_vmatoa_1 (NULL
, cie_id
, offset_size
),
7769 (unsigned long) (saved_start
- section_start
));
7771 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
7772 fc
->col_offset
= (int *) xmalloc (sizeof (int));
7773 if (frame_need_space (fc
, max_regs
> 0 ? max_regs
- 1 : 0) < 0)
7775 warn (_("Invalid max register\n"));
7779 fc
->augmentation
= "";
7780 fc
->fde_encoding
= 0;
7781 fc
->ptr_size
= eh_addr_size
;
7782 fc
->segment_size
= 0;
7786 fc
->ncols
= cie
->ncols
;
7787 fc
->col_type
= (short int *) xcmalloc (fc
->ncols
, sizeof (short int));
7788 fc
->col_offset
= (int *) xcmalloc (fc
->ncols
, sizeof (int));
7789 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
7790 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
7791 fc
->augmentation
= cie
->augmentation
;
7792 fc
->ptr_size
= cie
->ptr_size
;
7793 eh_addr_size
= cie
->ptr_size
;
7794 fc
->segment_size
= cie
->segment_size
;
7795 fc
->code_factor
= cie
->code_factor
;
7796 fc
->data_factor
= cie
->data_factor
;
7797 fc
->cfa_reg
= cie
->cfa_reg
;
7798 fc
->cfa_offset
= cie
->cfa_offset
;
7800 if (frame_need_space (fc
, max_regs
> 0 ? max_regs
- 1: 0) < 0)
7802 warn (_("Invalid max register\n"));
7805 fc
->fde_encoding
= cie
->fde_encoding
;
7808 if (fc
->fde_encoding
)
7809 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
7811 segment_selector
= 0;
7812 if (fc
->segment_size
)
7814 if (fc
->segment_size
> sizeof (segment_selector
))
7816 /* PR 17512: file: 9e196b3e. */
7817 warn (_("Probably corrupt segment size: %d - using 4 instead\n"), fc
->segment_size
);
7818 fc
->segment_size
= 4;
7820 SAFE_BYTE_GET_AND_INC (segment_selector
, start
, fc
->segment_size
, end
);
7823 fc
->pc_begin
= get_encoded_value (&start
, fc
->fde_encoding
, section
, end
);
7825 /* FIXME: It appears that sometimes the final pc_range value is
7826 encoded in less than encoded_ptr_size bytes. See the x86_64
7827 run of the "objcopy on compressed debug sections" test for an
7829 SAFE_BYTE_GET_AND_INC (fc
->pc_range
, start
, encoded_ptr_size
, end
);
7831 if (cie
->augmentation
[0] == 'z')
7833 READ_ULEB (augmentation_data_len
);
7834 augmentation_data
= start
;
7835 /* PR 17512 file: 722-8446-0.004 and PR 22386. */
7836 if (augmentation_data_len
> (bfd_size_type
) (end
- start
))
7838 warn (_("Augmentation data too long: 0x%s, "
7839 "expected at most %#lx\n"),
7840 dwarf_vmatoa ("x", augmentation_data_len
),
7841 (unsigned long) (end
- start
));
7843 augmentation_data
= NULL
;
7844 augmentation_data_len
= 0;
7846 start
+= augmentation_data_len
;
7849 printf ("\n%08lx %s %s FDE cie=%08lx pc=",
7850 (unsigned long)(saved_start
- section_start
),
7851 dwarf_vmatoa_1 (NULL
, length
, fc
->ptr_size
),
7852 dwarf_vmatoa_1 (NULL
, cie_id
, offset_size
),
7853 (unsigned long)(cie
->chunk_start
- section_start
));
7855 if (fc
->segment_size
)
7856 printf ("%04lx:", segment_selector
);
7859 dwarf_vmatoa_1 (NULL
, fc
->pc_begin
, fc
->ptr_size
),
7860 dwarf_vmatoa_1 (NULL
, fc
->pc_begin
+ fc
->pc_range
, fc
->ptr_size
));
7862 if (! do_debug_frames_interp
&& augmentation_data_len
)
7864 display_augmentation_data (augmentation_data
, augmentation_data_len
);
7869 /* At this point, fc is the current chunk, cie (if any) is set, and
7870 we're about to interpret instructions for the chunk. */
7871 /* ??? At present we need to do this always, since this sizes the
7872 fc->col_type and fc->col_offset arrays, which we write into always.
7873 We should probably split the interpreted and non-interpreted bits
7874 into two different routines, since there's so much that doesn't
7875 really overlap between them. */
7876 if (1 || do_debug_frames_interp
)
7878 /* Start by making a pass over the chunk, allocating storage
7879 and taking note of what registers are used. */
7880 unsigned char *tmp
= start
;
7882 while (start
< block_end
)
7884 unsigned int reg
, op
, opa
;
7886 unsigned char * new_start
;
7893 /* Warning: if you add any more cases to this switch, be
7894 sure to add them to the corresponding switch below. */
7897 case DW_CFA_advance_loc
:
7901 if (frame_need_space (fc
, opa
) >= 0)
7902 fc
->col_type
[opa
] = DW_CFA_undefined
;
7904 case DW_CFA_restore
:
7905 if (frame_need_space (fc
, opa
) >= 0)
7906 fc
->col_type
[opa
] = DW_CFA_undefined
;
7908 case DW_CFA_set_loc
:
7909 start
+= encoded_ptr_size
;
7911 case DW_CFA_advance_loc1
:
7914 case DW_CFA_advance_loc2
:
7917 case DW_CFA_advance_loc4
:
7920 case DW_CFA_offset_extended
:
7921 case DW_CFA_val_offset
:
7924 if (frame_need_space (fc
, reg
) >= 0)
7925 fc
->col_type
[reg
] = DW_CFA_undefined
;
7927 case DW_CFA_restore_extended
:
7929 if (frame_need_space (fc
, reg
) >= 0)
7930 fc
->col_type
[reg
] = DW_CFA_undefined
;
7932 case DW_CFA_undefined
:
7934 if (frame_need_space (fc
, reg
) >= 0)
7935 fc
->col_type
[reg
] = DW_CFA_undefined
;
7937 case DW_CFA_same_value
:
7939 if (frame_need_space (fc
, reg
) >= 0)
7940 fc
->col_type
[reg
] = DW_CFA_undefined
;
7942 case DW_CFA_register
:
7945 if (frame_need_space (fc
, reg
) >= 0)
7946 fc
->col_type
[reg
] = DW_CFA_undefined
;
7948 case DW_CFA_def_cfa
:
7952 case DW_CFA_def_cfa_register
:
7955 case DW_CFA_def_cfa_offset
:
7958 case DW_CFA_def_cfa_expression
:
7960 new_start
= start
+ temp
;
7961 if (new_start
< start
)
7963 warn (_("Corrupt CFA_def expression value: %lu\n"), temp
);
7969 case DW_CFA_expression
:
7970 case DW_CFA_val_expression
:
7973 new_start
= start
+ temp
;
7974 if (new_start
< start
)
7976 /* PR 17512: file:306-192417-0.005. */
7977 warn (_("Corrupt CFA expression value: %lu\n"), temp
);
7982 if (frame_need_space (fc
, reg
) >= 0)
7983 fc
->col_type
[reg
] = DW_CFA_undefined
;
7985 case DW_CFA_offset_extended_sf
:
7986 case DW_CFA_val_offset_sf
:
7989 if (frame_need_space (fc
, reg
) >= 0)
7990 fc
->col_type
[reg
] = DW_CFA_undefined
;
7992 case DW_CFA_def_cfa_sf
:
7996 case DW_CFA_def_cfa_offset_sf
:
7999 case DW_CFA_MIPS_advance_loc8
:
8002 case DW_CFA_GNU_args_size
:
8005 case DW_CFA_GNU_negative_offset_extended
:
8008 if (frame_need_space (fc
, reg
) >= 0)
8009 fc
->col_type
[reg
] = DW_CFA_undefined
;
8020 /* Now we know what registers are used, make a second pass over
8021 the chunk, this time actually printing out the info. */
8023 while (start
< block_end
)
8025 unsigned char * tmp
;
8027 unsigned long ul
, roffs
;
8028 /* Note: It is tempting to use an unsigned long for 'reg' but there
8029 are various functions, notably frame_space_needed() that assume that
8030 reg is an unsigned int. */
8035 const char *reg_prefix
= "";
8042 /* Make a note if something other than DW_CFA_nop happens. */
8043 if (op
!= DW_CFA_nop
)
8046 /* Warning: if you add any more cases to this switch, be
8047 sure to add them to the corresponding switch above. */
8050 case DW_CFA_advance_loc
:
8051 if (do_debug_frames_interp
)
8052 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8054 printf (" DW_CFA_advance_loc: %d to %s\n",
8055 opa
* fc
->code_factor
,
8056 dwarf_vmatoa_1 (NULL
,
8057 fc
->pc_begin
+ opa
* fc
->code_factor
,
8059 fc
->pc_begin
+= opa
* fc
->code_factor
;
8064 if (opa
>= (unsigned int) fc
->ncols
)
8065 reg_prefix
= bad_reg
;
8066 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8067 printf (" DW_CFA_offset: %s%s at cfa%+ld\n",
8068 reg_prefix
, regname (opa
, 0),
8069 roffs
* fc
->data_factor
);
8070 if (*reg_prefix
== '\0')
8072 fc
->col_type
[opa
] = DW_CFA_offset
;
8073 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
8077 case DW_CFA_restore
:
8078 if (opa
>= (unsigned int) fc
->ncols
)
8079 reg_prefix
= bad_reg
;
8080 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8081 printf (" DW_CFA_restore: %s%s\n",
8082 reg_prefix
, regname (opa
, 0));
8083 if (*reg_prefix
!= '\0')
8086 if (opa
>= (unsigned int) cie
->ncols
8087 || (do_debug_frames_interp
8088 && cie
->col_type
[opa
] == DW_CFA_unreferenced
))
8090 fc
->col_type
[opa
] = DW_CFA_undefined
;
8091 fc
->col_offset
[opa
] = 0;
8095 fc
->col_type
[opa
] = cie
->col_type
[opa
];
8096 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
8100 case DW_CFA_set_loc
:
8101 vma
= get_encoded_value (&start
, fc
->fde_encoding
, section
, block_end
);
8102 if (do_debug_frames_interp
)
8103 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8105 printf (" DW_CFA_set_loc: %s\n",
8106 dwarf_vmatoa_1 (NULL
, vma
, fc
->ptr_size
));
8110 case DW_CFA_advance_loc1
:
8111 SAFE_BYTE_GET_AND_INC (ofs
, start
, 1, end
);
8112 if (do_debug_frames_interp
)
8113 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8115 printf (" DW_CFA_advance_loc1: %ld to %s\n",
8116 (unsigned long) (ofs
* fc
->code_factor
),
8117 dwarf_vmatoa_1 (NULL
,
8118 fc
->pc_begin
+ ofs
* fc
->code_factor
,
8120 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8123 case DW_CFA_advance_loc2
:
8124 SAFE_BYTE_GET_AND_INC (ofs
, start
, 2, block_end
);
8125 if (do_debug_frames_interp
)
8126 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8128 printf (" DW_CFA_advance_loc2: %ld to %s\n",
8129 (unsigned long) (ofs
* fc
->code_factor
),
8130 dwarf_vmatoa_1 (NULL
,
8131 fc
->pc_begin
+ ofs
* fc
->code_factor
,
8133 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8136 case DW_CFA_advance_loc4
:
8137 SAFE_BYTE_GET_AND_INC (ofs
, start
, 4, block_end
);
8138 if (do_debug_frames_interp
)
8139 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8141 printf (" DW_CFA_advance_loc4: %ld to %s\n",
8142 (unsigned long) (ofs
* fc
->code_factor
),
8143 dwarf_vmatoa_1 (NULL
,
8144 fc
->pc_begin
+ ofs
* fc
->code_factor
,
8146 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8149 case DW_CFA_offset_extended
:
8152 if (reg
>= (unsigned int) fc
->ncols
)
8153 reg_prefix
= bad_reg
;
8154 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8155 printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n",
8156 reg_prefix
, regname (reg
, 0),
8157 roffs
* fc
->data_factor
);
8158 if (*reg_prefix
== '\0')
8160 fc
->col_type
[reg
] = DW_CFA_offset
;
8161 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
8165 case DW_CFA_val_offset
:
8168 if (reg
>= (unsigned int) fc
->ncols
)
8169 reg_prefix
= bad_reg
;
8170 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8171 printf (" DW_CFA_val_offset: %s%s is cfa%+ld\n",
8172 reg_prefix
, regname (reg
, 0),
8173 roffs
* fc
->data_factor
);
8174 if (*reg_prefix
== '\0')
8176 fc
->col_type
[reg
] = DW_CFA_val_offset
;
8177 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
8181 case DW_CFA_restore_extended
:
8183 if (reg
>= (unsigned int) fc
->ncols
)
8184 reg_prefix
= bad_reg
;
8185 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8186 printf (" DW_CFA_restore_extended: %s%s\n",
8187 reg_prefix
, regname (reg
, 0));
8188 if (*reg_prefix
!= '\0')
8191 if (reg
>= (unsigned int) cie
->ncols
)
8193 fc
->col_type
[reg
] = DW_CFA_undefined
;
8194 fc
->col_offset
[reg
] = 0;
8198 fc
->col_type
[reg
] = cie
->col_type
[reg
];
8199 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
8203 case DW_CFA_undefined
:
8205 if (reg
>= (unsigned int) fc
->ncols
)
8206 reg_prefix
= bad_reg
;
8207 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8208 printf (" DW_CFA_undefined: %s%s\n",
8209 reg_prefix
, regname (reg
, 0));
8210 if (*reg_prefix
== '\0')
8212 fc
->col_type
[reg
] = DW_CFA_undefined
;
8213 fc
->col_offset
[reg
] = 0;
8217 case DW_CFA_same_value
:
8219 if (reg
>= (unsigned int) fc
->ncols
)
8220 reg_prefix
= bad_reg
;
8221 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8222 printf (" DW_CFA_same_value: %s%s\n",
8223 reg_prefix
, regname (reg
, 0));
8224 if (*reg_prefix
== '\0')
8226 fc
->col_type
[reg
] = DW_CFA_same_value
;
8227 fc
->col_offset
[reg
] = 0;
8231 case DW_CFA_register
:
8234 if (reg
>= (unsigned int) fc
->ncols
)
8235 reg_prefix
= bad_reg
;
8236 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8238 printf (" DW_CFA_register: %s%s in ",
8239 reg_prefix
, regname (reg
, 0));
8240 puts (regname (roffs
, 0));
8242 if (*reg_prefix
== '\0')
8244 fc
->col_type
[reg
] = DW_CFA_register
;
8245 fc
->col_offset
[reg
] = roffs
;
8249 case DW_CFA_remember_state
:
8250 if (! do_debug_frames_interp
)
8251 printf (" DW_CFA_remember_state\n");
8252 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
8253 rs
->cfa_offset
= fc
->cfa_offset
;
8254 rs
->cfa_reg
= fc
->cfa_reg
;
8256 rs
->cfa_exp
= fc
->cfa_exp
;
8257 rs
->ncols
= fc
->ncols
;
8258 rs
->col_type
= (short int *) xcmalloc (rs
->ncols
,
8259 sizeof (* rs
->col_type
));
8260 rs
->col_offset
= (int *) xcmalloc (rs
->ncols
, sizeof (* rs
->col_offset
));
8261 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
* sizeof (* fc
->col_type
));
8262 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (* fc
->col_offset
));
8263 rs
->next
= remembered_state
;
8264 remembered_state
= rs
;
8267 case DW_CFA_restore_state
:
8268 if (! do_debug_frames_interp
)
8269 printf (" DW_CFA_restore_state\n");
8270 rs
= remembered_state
;
8273 remembered_state
= rs
->next
;
8274 fc
->cfa_offset
= rs
->cfa_offset
;
8275 fc
->cfa_reg
= rs
->cfa_reg
;
8277 fc
->cfa_exp
= rs
->cfa_exp
;
8278 if (frame_need_space (fc
, rs
->ncols
- 1) < 0)
8280 warn (_("Invalid column number in saved frame state\n"));
8284 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
* sizeof (* rs
->col_type
));
8285 memcpy (fc
->col_offset
, rs
->col_offset
,
8286 rs
->ncols
* sizeof (* rs
->col_offset
));
8287 free (rs
->col_type
);
8288 free (rs
->col_offset
);
8291 else if (do_debug_frames_interp
)
8292 printf ("Mismatched DW_CFA_restore_state\n");
8295 case DW_CFA_def_cfa
:
8296 READ_ULEB (fc
->cfa_reg
);
8297 READ_ULEB (fc
->cfa_offset
);
8299 if (! do_debug_frames_interp
)
8300 printf (" DW_CFA_def_cfa: %s ofs %d\n",
8301 regname (fc
->cfa_reg
, 0), (int) fc
->cfa_offset
);
8304 case DW_CFA_def_cfa_register
:
8305 READ_ULEB (fc
->cfa_reg
);
8307 if (! do_debug_frames_interp
)
8308 printf (" DW_CFA_def_cfa_register: %s\n",
8309 regname (fc
->cfa_reg
, 0));
8312 case DW_CFA_def_cfa_offset
:
8313 READ_ULEB (fc
->cfa_offset
);
8314 if (! do_debug_frames_interp
)
8315 printf (" DW_CFA_def_cfa_offset: %d\n", (int) fc
->cfa_offset
);
8319 if (! do_debug_frames_interp
)
8320 printf (" DW_CFA_nop\n");
8323 case DW_CFA_def_cfa_expression
:
8325 if (start
>= block_end
|| ul
> (unsigned long) (block_end
- start
))
8327 printf (_(" DW_CFA_def_cfa_expression: <corrupt len %lu>\n"), ul
);
8330 if (! do_debug_frames_interp
)
8332 printf (" DW_CFA_def_cfa_expression (");
8333 decode_location_expression (start
, eh_addr_size
, 0, -1,
8341 case DW_CFA_expression
:
8344 if (reg
>= (unsigned int) fc
->ncols
)
8345 reg_prefix
= bad_reg
;
8346 /* PR 17512: file: 069-133014-0.006. */
8347 /* PR 17512: file: 98c02eb4. */
8349 if (start
>= block_end
|| tmp
> block_end
|| tmp
< start
)
8351 printf (_(" DW_CFA_expression: <corrupt len %lu>\n"), ul
);
8354 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8356 printf (" DW_CFA_expression: %s%s (",
8357 reg_prefix
, regname (reg
, 0));
8358 decode_location_expression (start
, eh_addr_size
, 0, -1,
8362 if (*reg_prefix
== '\0')
8363 fc
->col_type
[reg
] = DW_CFA_expression
;
8367 case DW_CFA_val_expression
:
8370 if (reg
>= (unsigned int) fc
->ncols
)
8371 reg_prefix
= bad_reg
;
8373 if (start
>= block_end
|| tmp
> block_end
|| tmp
< start
)
8375 printf (" DW_CFA_val_expression: <corrupt len %lu>\n", ul
);
8378 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8380 printf (" DW_CFA_val_expression: %s%s (",
8381 reg_prefix
, regname (reg
, 0));
8382 decode_location_expression (start
, eh_addr_size
, 0, -1,
8386 if (*reg_prefix
== '\0')
8387 fc
->col_type
[reg
] = DW_CFA_val_expression
;
8391 case DW_CFA_offset_extended_sf
:
8394 if (frame_need_space (fc
, reg
) < 0)
8395 reg_prefix
= bad_reg
;
8396 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8397 printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
8398 reg_prefix
, regname (reg
, 0),
8399 (long)(l
* fc
->data_factor
));
8400 if (*reg_prefix
== '\0')
8402 fc
->col_type
[reg
] = DW_CFA_offset
;
8403 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
8407 case DW_CFA_val_offset_sf
:
8410 if (frame_need_space (fc
, reg
) < 0)
8411 reg_prefix
= bad_reg
;
8412 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8413 printf (" DW_CFA_val_offset_sf: %s%s is cfa%+ld\n",
8414 reg_prefix
, regname (reg
, 0),
8415 (long)(l
* fc
->data_factor
));
8416 if (*reg_prefix
== '\0')
8418 fc
->col_type
[reg
] = DW_CFA_val_offset
;
8419 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
8423 case DW_CFA_def_cfa_sf
:
8424 READ_ULEB (fc
->cfa_reg
);
8425 READ_ULEB (fc
->cfa_offset
);
8426 fc
->cfa_offset
= fc
->cfa_offset
* fc
->data_factor
;
8428 if (! do_debug_frames_interp
)
8429 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
8430 regname (fc
->cfa_reg
, 0), (int) fc
->cfa_offset
);
8433 case DW_CFA_def_cfa_offset_sf
:
8434 READ_ULEB (fc
->cfa_offset
);
8435 fc
->cfa_offset
*= fc
->data_factor
;
8436 if (! do_debug_frames_interp
)
8437 printf (" DW_CFA_def_cfa_offset_sf: %d\n", (int) fc
->cfa_offset
);
8440 case DW_CFA_MIPS_advance_loc8
:
8441 SAFE_BYTE_GET_AND_INC (ofs
, start
, 8, block_end
);
8442 if (do_debug_frames_interp
)
8443 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8445 printf (" DW_CFA_MIPS_advance_loc8: %ld to %s\n",
8446 (unsigned long) (ofs
* fc
->code_factor
),
8447 dwarf_vmatoa_1 (NULL
,
8448 fc
->pc_begin
+ ofs
* fc
->code_factor
,
8450 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8453 case DW_CFA_GNU_window_save
:
8454 if (! do_debug_frames_interp
)
8455 printf (" DW_CFA_GNU_window_save\n");
8458 case DW_CFA_GNU_args_size
:
8460 if (! do_debug_frames_interp
)
8461 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
8464 case DW_CFA_GNU_negative_offset_extended
:
8468 if (frame_need_space (fc
, reg
) < 0)
8469 reg_prefix
= bad_reg
;
8470 if (! do_debug_frames_interp
|| *reg_prefix
!= '\0')
8471 printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
8472 reg_prefix
, regname (reg
, 0),
8473 (long)(l
* fc
->data_factor
));
8474 if (*reg_prefix
== '\0')
8476 fc
->col_type
[reg
] = DW_CFA_offset
;
8477 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
8482 if (op
>= DW_CFA_lo_user
&& op
<= DW_CFA_hi_user
)
8483 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op
);
8485 warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op
);
8490 /* Interpret the CFA - as long as it is not completely full of NOPs. */
8491 if (do_debug_frames_interp
&& ! all_nops
)
8492 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8495 eh_addr_size
= saved_eh_addr_size
;
8500 while (remembered_state
!= NULL
)
8502 rs
= remembered_state
;
8503 remembered_state
= rs
->next
;
8504 free (rs
->col_type
);
8505 free (rs
->col_offset
);
8506 rs
->next
= NULL
; /* Paranoia. */
8510 while (chunks
!= NULL
)
8514 free (rs
->col_type
);
8515 free (rs
->col_offset
);
8516 rs
->next
= NULL
; /* Paranoia. */
8520 while (forward_refs
!= NULL
)
8523 forward_refs
= rs
->next
;
8524 free (rs
->col_type
);
8525 free (rs
->col_offset
);
8526 rs
->next
= NULL
; /* Paranoia. */
8536 display_debug_names (struct dwarf_section
*section
, void *file
)
8538 unsigned char *hdrptr
= section
->start
;
8539 dwarf_vma unit_length
;
8540 unsigned char *unit_start
;
8541 const unsigned char *const section_end
= section
->start
+ section
->size
;
8542 unsigned char *unit_end
;
8544 introduce (section
, FALSE
);
8546 load_debug_section_with_follow (str
, file
);
8548 for (; hdrptr
< section_end
; hdrptr
= unit_end
)
8550 unsigned int offset_size
;
8551 uint16_t dwarf_version
, padding
;
8552 uint32_t comp_unit_count
, local_type_unit_count
, foreign_type_unit_count
;
8553 uint32_t bucket_count
, name_count
, abbrev_table_size
;
8554 uint32_t augmentation_string_size
;
8556 unsigned long sec_off
;
8557 bfd_boolean augmentation_printable
;
8558 const char *augmentation_string
;
8560 unit_start
= hdrptr
;
8562 /* Get and check the length of the block. */
8563 SAFE_BYTE_GET_AND_INC (unit_length
, hdrptr
, 4, section_end
);
8565 if (unit_length
== 0xffffffff)
8567 /* This section is 64-bit DWARF. */
8568 SAFE_BYTE_GET_AND_INC (unit_length
, hdrptr
, 8, section_end
);
8573 unit_end
= hdrptr
+ unit_length
;
8575 sec_off
= hdrptr
- section
->start
;
8576 if (sec_off
+ unit_length
< sec_off
8577 || sec_off
+ unit_length
> section
->size
)
8579 warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"),
8581 (unsigned long) (unit_start
- section
->start
),
8582 dwarf_vmatoa ("x", unit_length
));
8586 /* Get and check the version number. */
8587 SAFE_BYTE_GET_AND_INC (dwarf_version
, hdrptr
, 2, unit_end
);
8588 printf (_("Version %ld\n"), (long) dwarf_version
);
8590 /* Prior versions did not exist, and future versions may not be
8591 backwards compatible. */
8592 if (dwarf_version
!= 5)
8594 warn (_("Only DWARF version 5 .debug_names "
8595 "is currently supported.\n"));
8599 SAFE_BYTE_GET_AND_INC (padding
, hdrptr
, 2, unit_end
);
8601 warn (_("Padding field of .debug_names must be 0 (found 0x%x)\n"),
8604 SAFE_BYTE_GET_AND_INC (comp_unit_count
, hdrptr
, 4, unit_end
);
8605 if (comp_unit_count
== 0)
8606 warn (_("Compilation unit count must be >= 1 in .debug_names\n"));
8608 SAFE_BYTE_GET_AND_INC (local_type_unit_count
, hdrptr
, 4, unit_end
);
8609 SAFE_BYTE_GET_AND_INC (foreign_type_unit_count
, hdrptr
, 4, unit_end
);
8610 SAFE_BYTE_GET_AND_INC (bucket_count
, hdrptr
, 4, unit_end
);
8611 SAFE_BYTE_GET_AND_INC (name_count
, hdrptr
, 4, unit_end
);
8612 SAFE_BYTE_GET_AND_INC (abbrev_table_size
, hdrptr
, 4, unit_end
);
8614 SAFE_BYTE_GET_AND_INC (augmentation_string_size
, hdrptr
, 4, unit_end
);
8615 if (augmentation_string_size
% 4 != 0)
8617 warn (_("Augmentation string length %u must be rounded up "
8618 "to a multiple of 4 in .debug_names.\n"),
8619 augmentation_string_size
);
8620 augmentation_string_size
+= (-augmentation_string_size
) & 3;
8623 printf (_("Augmentation string:"));
8625 augmentation_printable
= TRUE
;
8626 augmentation_string
= (const char *) hdrptr
;
8628 for (i
= 0; i
< augmentation_string_size
; i
++)
8632 SAFE_BYTE_GET_AND_INC (uc
, hdrptr
, 1, unit_end
);
8633 printf (" %02x", uc
);
8635 if (uc
!= 0 && !ISPRINT (uc
))
8636 augmentation_printable
= FALSE
;
8639 if (augmentation_printable
)
8643 i
< augmentation_string_size
&& augmentation_string
[i
];
8645 putchar (augmentation_string
[i
]);
8650 printf (_("CU table:\n"));
8651 for (i
= 0; i
< comp_unit_count
; i
++)
8655 SAFE_BYTE_GET_AND_INC (cu_offset
, hdrptr
, offset_size
, unit_end
);
8656 printf (_("[%3u] 0x%lx\n"), i
, (unsigned long) cu_offset
);
8660 printf (_("TU table:\n"));
8661 for (i
= 0; i
< local_type_unit_count
; i
++)
8665 SAFE_BYTE_GET_AND_INC (tu_offset
, hdrptr
, offset_size
, unit_end
);
8666 printf (_("[%3u] 0x%lx\n"), i
, (unsigned long) tu_offset
);
8670 printf (_("Foreign TU table:\n"));
8671 for (i
= 0; i
< foreign_type_unit_count
; i
++)
8675 SAFE_BYTE_GET_AND_INC (signature
, hdrptr
, 8, unit_end
);
8676 printf (_("[%3u] "), i
);
8677 print_dwarf_vma (signature
, 8);
8682 const uint32_t *const hash_table_buckets
= (uint32_t *) hdrptr
;
8683 hdrptr
+= bucket_count
* sizeof (uint32_t);
8684 const uint32_t *const hash_table_hashes
= (uint32_t *) hdrptr
;
8685 hdrptr
+= name_count
* sizeof (uint32_t);
8686 unsigned char *const name_table_string_offsets
= hdrptr
;
8687 hdrptr
+= name_count
* offset_size
;
8688 unsigned char *const name_table_entry_offsets
= hdrptr
;
8689 hdrptr
+= name_count
* offset_size
;
8690 unsigned char *const abbrev_table
= hdrptr
;
8691 hdrptr
+= abbrev_table_size
;
8692 const unsigned char *const abbrev_table_end
= hdrptr
;
8693 unsigned char *const entry_pool
= hdrptr
;
8694 if (hdrptr
> unit_end
)
8696 warn (_("Entry pool offset (0x%lx) exceeds unit size 0x%lx "
8697 "for unit 0x%lx in the debug_names\n"),
8698 (long) (hdrptr
- section
->start
),
8699 (long) (unit_end
- section
->start
),
8700 (long) (unit_start
- section
->start
));
8704 size_t buckets_filled
= 0;
8706 for (bucketi
= 0; bucketi
< bucket_count
; bucketi
++)
8708 const uint32_t bucket
= hash_table_buckets
[bucketi
];
8713 printf (ngettext ("Used %zu of %lu bucket.\n",
8714 "Used %zu of %lu buckets.\n",
8716 buckets_filled
, (unsigned long) bucket_count
);
8718 uint32_t hash_prev
= 0;
8719 size_t hash_clash_count
= 0;
8720 size_t longest_clash
= 0;
8721 size_t this_length
= 0;
8723 for (hashi
= 0; hashi
< name_count
; hashi
++)
8725 const uint32_t hash_this
= hash_table_hashes
[hashi
];
8729 if (hash_prev
% bucket_count
== hash_this
% bucket_count
)
8733 longest_clash
= MAX (longest_clash
, this_length
);
8738 hash_prev
= hash_this
;
8740 printf (_("Out of %lu items there are %zu bucket clashes"
8741 " (longest of %zu entries).\n"),
8742 (unsigned long) name_count
, hash_clash_count
, longest_clash
);
8743 assert (name_count
== buckets_filled
+ hash_clash_count
);
8745 struct abbrev_lookup_entry
8747 dwarf_vma abbrev_tag
;
8748 unsigned char *abbrev_lookup_ptr
;
8750 struct abbrev_lookup_entry
*abbrev_lookup
= NULL
;
8751 size_t abbrev_lookup_used
= 0;
8752 size_t abbrev_lookup_allocated
= 0;
8754 unsigned char *abbrevptr
= abbrev_table
;
8757 unsigned int bytes_read
;
8758 const dwarf_vma abbrev_tag
= read_uleb128 (abbrevptr
, &bytes_read
,
8760 abbrevptr
+= bytes_read
;
8761 if (abbrev_tag
== 0)
8763 if (abbrev_lookup_used
== abbrev_lookup_allocated
)
8765 abbrev_lookup_allocated
= MAX (0x100,
8766 abbrev_lookup_allocated
* 2);
8767 abbrev_lookup
= xrealloc (abbrev_lookup
,
8768 (abbrev_lookup_allocated
8769 * sizeof (*abbrev_lookup
)));
8771 assert (abbrev_lookup_used
< abbrev_lookup_allocated
);
8772 struct abbrev_lookup_entry
*entry
;
8773 for (entry
= abbrev_lookup
;
8774 entry
< abbrev_lookup
+ abbrev_lookup_used
;
8776 if (entry
->abbrev_tag
== abbrev_tag
)
8778 warn (_("Duplicate abbreviation tag %lu "
8779 "in unit 0x%lx in the debug_names\n"),
8780 (long) abbrev_tag
, (long) (unit_start
- section
->start
));
8783 entry
= &abbrev_lookup
[abbrev_lookup_used
++];
8784 entry
->abbrev_tag
= abbrev_tag
;
8785 entry
->abbrev_lookup_ptr
= abbrevptr
;
8787 /* Skip DWARF tag. */
8788 read_uleb128 (abbrevptr
, &bytes_read
, abbrev_table_end
);
8789 abbrevptr
+= bytes_read
;
8792 const dwarf_vma xindex
= read_uleb128 (abbrevptr
,
8795 abbrevptr
+= bytes_read
;
8796 const dwarf_vma form
= read_uleb128 (abbrevptr
, &bytes_read
,
8798 abbrevptr
+= bytes_read
;
8799 if (xindex
== 0 && form
== 0)
8804 printf (_("\nSymbol table:\n"));
8806 for (namei
= 0; namei
< name_count
; ++namei
)
8808 uint64_t string_offset
, entry_offset
;
8810 SAFE_BYTE_GET (string_offset
,
8811 name_table_string_offsets
+ namei
* offset_size
,
8812 offset_size
, unit_end
);
8813 SAFE_BYTE_GET (entry_offset
,
8814 name_table_entry_offsets
+ namei
* offset_size
,
8815 offset_size
, unit_end
);
8817 printf ("[%3u] #%08x %s:", namei
, hash_table_hashes
[namei
],
8818 fetch_indirect_string (string_offset
));
8820 unsigned char *entryptr
= entry_pool
+ entry_offset
;
8822 // We need to scan first whether there is a single or multiple
8823 // entries. TAGNO is -2 for the first entry, it is -1 for the
8824 // initial tag read of the second entry, then it becomes 0 for the
8825 // first entry for real printing etc.
8827 /* Initialize it due to a false compiler warning. */
8828 dwarf_vma second_abbrev_tag
= -1;
8831 unsigned int bytes_read
;
8832 const dwarf_vma abbrev_tag
= read_uleb128 (entryptr
, &bytes_read
,
8834 entryptr
+= bytes_read
;
8837 second_abbrev_tag
= abbrev_tag
;
8839 entryptr
= entry_pool
+ entry_offset
;
8842 if (abbrev_tag
== 0)
8846 (tagno
== 0 && second_abbrev_tag
== 0 ? " " : "\n\t"),
8847 (unsigned long) abbrev_tag
);
8849 const struct abbrev_lookup_entry
*entry
;
8850 for (entry
= abbrev_lookup
;
8851 entry
< abbrev_lookup
+ abbrev_lookup_used
;
8853 if (entry
->abbrev_tag
== abbrev_tag
)
8855 if (entry
>= abbrev_lookup
+ abbrev_lookup_used
)
8857 warn (_("Undefined abbreviation tag %lu "
8858 "in unit 0x%lx in the debug_names\n"),
8860 (long) (unit_start
- section
->start
));
8863 abbrevptr
= entry
->abbrev_lookup_ptr
;
8864 const dwarf_vma dwarf_tag
= read_uleb128 (abbrevptr
, &bytes_read
,
8866 abbrevptr
+= bytes_read
;
8868 printf (" %s", get_TAG_name (dwarf_tag
));
8871 const dwarf_vma xindex
= read_uleb128 (abbrevptr
,
8874 abbrevptr
+= bytes_read
;
8875 const dwarf_vma form
= read_uleb128 (abbrevptr
, &bytes_read
,
8877 abbrevptr
+= bytes_read
;
8878 if (xindex
== 0 && form
== 0)
8882 printf (" %s", get_IDX_name (xindex
));
8883 entryptr
= read_and_display_attr_value (0, form
, 0, entryptr
,
8886 dwarf_version
, NULL
,
8893 printf (_(" <no entries>"));
8897 free (abbrev_lookup
);
8904 display_debug_links (struct dwarf_section
* section
,
8905 void * file ATTRIBUTE_UNUSED
)
8907 const unsigned char * filename
;
8908 unsigned int filelen
;
8910 introduce (section
, FALSE
);
8912 /* The .gnu_debuglink section is formatted as:
8913 (c-string) Filename.
8914 (padding) If needed to reach a 4 byte boundary.
8915 (uint32_t) CRC32 value.
8917 The .gun_debugaltlink section is formatted as:
8918 (c-string) Filename.
8919 (binary) Build-ID. */
8921 filename
= section
->start
;
8922 filelen
= strnlen ((const char *) filename
, section
->size
);
8923 if (filelen
== section
->size
)
8925 warn (_("The debuglink filename is corrupt/missing\n"));
8929 printf (_(" Separate debug info file: %s\n"), filename
);
8931 if (const_strneq (section
->name
, ".gnu_debuglink"))
8934 unsigned int crc_offset
;
8936 crc_offset
= filelen
+ 1;
8937 crc_offset
= (crc_offset
+ 3) & ~3;
8938 if (crc_offset
+ 4 > section
->size
)
8940 warn (_("CRC offset missing/truncated\n"));
8944 crc32
= byte_get (filename
+ crc_offset
, 4);
8946 printf (_(" CRC value: %#x\n"), crc32
);
8948 if (crc_offset
+ 4 < section
->size
)
8950 warn (_("There are %#lx extraneous bytes at the end of the section\n"),
8951 (long)(section
->size
- (crc_offset
+ 4)));
8955 else /* const_strneq (section->name, ".gnu_debugaltlink") */
8957 const unsigned char * build_id
= section
->start
+ filelen
+ 1;
8958 bfd_size_type build_id_len
= section
->size
- (filelen
+ 1);
8959 bfd_size_type printed
;
8961 /* FIXME: Should we support smaller build-id notes ? */
8962 if (build_id_len
< 0x14)
8964 warn (_("Build-ID is too short (%#lx bytes)\n"), (long) build_id_len
);
8968 printed
= printf (_(" Build-ID (%#lx bytes):"), (long) build_id_len
);
8969 display_data (printed
, build_id
, build_id_len
);
8978 display_gdb_index (struct dwarf_section
*section
,
8979 void *file ATTRIBUTE_UNUSED
)
8981 unsigned char *start
= section
->start
;
8983 uint32_t cu_list_offset
, tu_list_offset
;
8984 uint32_t address_table_offset
, symbol_table_offset
, constant_pool_offset
;
8985 unsigned int cu_list_elements
, tu_list_elements
;
8986 unsigned int address_table_size
, symbol_table_slots
;
8987 unsigned char *cu_list
, *tu_list
;
8988 unsigned char *address_table
, *symbol_table
, *constant_pool
;
8991 /* The documentation for the format of this file is in gdb/dwarf2read.c. */
8993 introduce (section
, FALSE
);
8995 if (section
->size
< 6 * sizeof (uint32_t))
8997 warn (_("Truncated header in the %s section.\n"), section
->name
);
9001 version
= byte_get_little_endian (start
, 4);
9002 printf (_("Version %ld\n"), (long) version
);
9004 /* Prior versions are obsolete, and future versions may not be
9005 backwards compatible. */
9006 if (version
< 3 || version
> 8)
9008 warn (_("Unsupported version %lu.\n"), (unsigned long) version
);
9012 warn (_("The address table data in version 3 may be wrong.\n"));
9014 warn (_("Version 4 does not support case insensitive lookups.\n"));
9016 warn (_("Version 5 does not include inlined functions.\n"));
9018 warn (_("Version 6 does not include symbol attributes.\n"));
9019 /* Version 7 indices generated by Gold have bad type unit references,
9020 PR binutils/15021. But we don't know if the index was generated by
9021 Gold or not, so to avoid worrying users with gdb-generated indices
9022 we say nothing for version 7 here. */
9024 cu_list_offset
= byte_get_little_endian (start
+ 4, 4);
9025 tu_list_offset
= byte_get_little_endian (start
+ 8, 4);
9026 address_table_offset
= byte_get_little_endian (start
+ 12, 4);
9027 symbol_table_offset
= byte_get_little_endian (start
+ 16, 4);
9028 constant_pool_offset
= byte_get_little_endian (start
+ 20, 4);
9030 if (cu_list_offset
> section
->size
9031 || tu_list_offset
> section
->size
9032 || address_table_offset
> section
->size
9033 || symbol_table_offset
> section
->size
9034 || constant_pool_offset
> section
->size
)
9036 warn (_("Corrupt header in the %s section.\n"), section
->name
);
9040 /* PR 17531: file: 418d0a8a. */
9041 if (tu_list_offset
< cu_list_offset
)
9043 warn (_("TU offset (%x) is less than CU offset (%x)\n"),
9044 tu_list_offset
, cu_list_offset
);
9048 cu_list_elements
= (tu_list_offset
- cu_list_offset
) / 8;
9050 if (address_table_offset
< tu_list_offset
)
9052 warn (_("Address table offset (%x) is less than TU offset (%x)\n"),
9053 address_table_offset
, tu_list_offset
);
9057 tu_list_elements
= (address_table_offset
- tu_list_offset
) / 8;
9059 /* PR 17531: file: 18a47d3d. */
9060 if (symbol_table_offset
< address_table_offset
)
9062 warn (_("Symbol table offset (%x) is less then Address table offset (%x)\n"),
9063 symbol_table_offset
, address_table_offset
);
9067 address_table_size
= symbol_table_offset
- address_table_offset
;
9069 if (constant_pool_offset
< symbol_table_offset
)
9071 warn (_("Constant pool offset (%x) is less than symbol table offset (%x)\n"),
9072 constant_pool_offset
, symbol_table_offset
);
9076 symbol_table_slots
= (constant_pool_offset
- symbol_table_offset
) / 8;
9078 cu_list
= start
+ cu_list_offset
;
9079 tu_list
= start
+ tu_list_offset
;
9080 address_table
= start
+ address_table_offset
;
9081 symbol_table
= start
+ symbol_table_offset
;
9082 constant_pool
= start
+ constant_pool_offset
;
9084 if (address_table
+ address_table_size
> section
->start
+ section
->size
)
9086 warn (_("Address table extends beyond end of section.\n"));
9090 printf (_("\nCU table:\n"));
9091 for (i
= 0; i
< cu_list_elements
; i
+= 2)
9093 uint64_t cu_offset
= byte_get_little_endian (cu_list
+ i
* 8, 8);
9094 uint64_t cu_length
= byte_get_little_endian (cu_list
+ i
* 8 + 8, 8);
9096 printf (_("[%3u] 0x%lx - 0x%lx\n"), i
/ 2,
9097 (unsigned long) cu_offset
,
9098 (unsigned long) (cu_offset
+ cu_length
- 1));
9101 printf (_("\nTU table:\n"));
9102 for (i
= 0; i
< tu_list_elements
; i
+= 3)
9104 uint64_t tu_offset
= byte_get_little_endian (tu_list
+ i
* 8, 8);
9105 uint64_t type_offset
= byte_get_little_endian (tu_list
+ i
* 8 + 8, 8);
9106 uint64_t signature
= byte_get_little_endian (tu_list
+ i
* 8 + 16, 8);
9108 printf (_("[%3u] 0x%lx 0x%lx "), i
/ 3,
9109 (unsigned long) tu_offset
,
9110 (unsigned long) type_offset
);
9111 print_dwarf_vma (signature
, 8);
9115 printf (_("\nAddress table:\n"));
9116 for (i
= 0; i
< address_table_size
&& i
<= address_table_size
- (2 * 8 + 4);
9119 uint64_t low
= byte_get_little_endian (address_table
+ i
, 8);
9120 uint64_t high
= byte_get_little_endian (address_table
+ i
+ 8, 8);
9121 uint32_t cu_index
= byte_get_little_endian (address_table
+ i
+ 16, 4);
9123 print_dwarf_vma (low
, 8);
9124 print_dwarf_vma (high
, 8);
9125 printf (_("%lu\n"), (unsigned long) cu_index
);
9128 printf (_("\nSymbol table:\n"));
9129 for (i
= 0; i
< symbol_table_slots
; ++i
)
9131 uint32_t name_offset
= byte_get_little_endian (symbol_table
+ i
* 8, 4);
9132 uint32_t cu_vector_offset
= byte_get_little_endian (symbol_table
+ i
* 8 + 4, 4);
9133 uint32_t num_cus
, cu
;
9135 if (name_offset
!= 0
9136 || cu_vector_offset
!= 0)
9139 unsigned char * adr
;
9141 adr
= constant_pool
+ name_offset
;
9142 /* PR 17531: file: 5b7b07ad. */
9143 if (adr
< constant_pool
|| adr
>= section
->start
+ section
->size
)
9145 printf (_("[%3u] <corrupt offset: %x>"), i
, name_offset
);
9146 warn (_("Corrupt name offset of 0x%x found for symbol table slot %d\n"),
9150 printf ("[%3u] %.*s:", i
,
9151 (int) (section
->size
- (constant_pool_offset
+ name_offset
)),
9152 constant_pool
+ name_offset
);
9154 adr
= constant_pool
+ cu_vector_offset
;
9155 if (adr
< constant_pool
|| adr
>= section
->start
+ section
->size
- 3)
9157 printf (_("<invalid CU vector offset: %x>\n"), cu_vector_offset
);
9158 warn (_("Corrupt CU vector offset of 0x%x found for symbol table slot %d\n"),
9159 cu_vector_offset
, i
);
9163 num_cus
= byte_get_little_endian (adr
, 4);
9165 adr
= constant_pool
+ cu_vector_offset
+ 4 + num_cus
* 4;
9166 if (num_cus
* 4 < num_cus
9167 || adr
>= section
->start
+ section
->size
9168 || adr
< constant_pool
)
9170 printf ("<invalid number of CUs: %d>\n", num_cus
);
9171 warn (_("Invalid number of CUs (0x%x) for symbol table slot %d\n"),
9179 for (j
= 0; j
< num_cus
; ++j
)
9182 gdb_index_symbol_kind kind
;
9184 cu
= byte_get_little_endian (constant_pool
+ cu_vector_offset
+ 4 + j
* 4, 4);
9185 is_static
= GDB_INDEX_SYMBOL_STATIC_VALUE (cu
);
9186 kind
= GDB_INDEX_SYMBOL_KIND_VALUE (cu
);
9187 cu
= GDB_INDEX_CU_VALUE (cu
);
9188 /* Convert to TU number if it's for a type unit. */
9189 if (cu
>= cu_list_elements
/ 2)
9190 printf ("%cT%lu", num_cus
> 1 ? '\t' : ' ',
9191 (unsigned long) (cu
- cu_list_elements
/ 2));
9193 printf ("%c%lu", num_cus
> 1 ? '\t' : ' ', (unsigned long) cu
);
9195 printf (" [%s, %s]",
9196 is_static
? _("static") : _("global"),
9197 get_gdb_index_symbol_kind_name (kind
));
9209 /* Pre-allocate enough space for the CU/TU sets needed. */
9212 prealloc_cu_tu_list (unsigned int nshndx
)
9214 if (shndx_pool
== NULL
)
9216 shndx_pool_size
= nshndx
;
9217 shndx_pool_used
= 0;
9218 shndx_pool
= (unsigned int *) xcmalloc (shndx_pool_size
,
9219 sizeof (unsigned int));
9223 shndx_pool_size
= shndx_pool_used
+ nshndx
;
9224 shndx_pool
= (unsigned int *) xcrealloc (shndx_pool
, shndx_pool_size
,
9225 sizeof (unsigned int));
9230 add_shndx_to_cu_tu_entry (unsigned int shndx
)
9232 if (shndx_pool_used
>= shndx_pool_size
)
9234 error (_("Internal error: out of space in the shndx pool.\n"));
9237 shndx_pool
[shndx_pool_used
++] = shndx
;
9241 end_cu_tu_entry (void)
9243 if (shndx_pool_used
>= shndx_pool_size
)
9245 error (_("Internal error: out of space in the shndx pool.\n"));
9248 shndx_pool
[shndx_pool_used
++] = 0;
9251 /* Return the short name of a DWARF section given by a DW_SECT enumerator. */
9254 get_DW_SECT_short_name (unsigned int dw_sect
)
9256 static char buf
[16];
9264 case DW_SECT_ABBREV
:
9270 case DW_SECT_STR_OFFSETS
:
9272 case DW_SECT_MACINFO
:
9280 snprintf (buf
, sizeof (buf
), "%d", dw_sect
);
9284 /* Process a CU or TU index. If DO_DISPLAY is true, print the contents.
9285 These sections are extensions for Fission.
9286 See http://gcc.gnu.org/wiki/DebugFissionDWP. */
9289 process_cu_tu_index (struct dwarf_section
*section
, int do_display
)
9291 unsigned char *phdr
= section
->start
;
9292 unsigned char *limit
= phdr
+ section
->size
;
9293 unsigned char *phash
;
9294 unsigned char *pindex
;
9295 unsigned char *ppool
;
9296 unsigned int version
;
9297 unsigned int ncols
= 0;
9299 unsigned int nslots
;
9302 dwarf_vma signature_high
;
9303 dwarf_vma signature_low
;
9306 /* PR 17512: file: 002-168123-0.004. */
9309 warn (_("Section %s is empty\n"), section
->name
);
9312 /* PR 17512: file: 002-376-0.004. */
9313 if (section
->size
< 24)
9315 warn (_("Section %s is too small to contain a CU/TU header\n"),
9320 SAFE_BYTE_GET (version
, phdr
, 4, limit
);
9322 SAFE_BYTE_GET (ncols
, phdr
+ 4, 4, limit
);
9323 SAFE_BYTE_GET (nused
, phdr
+ 8, 4, limit
);
9324 SAFE_BYTE_GET (nslots
, phdr
+ 12, 4, limit
);
9327 pindex
= phash
+ (size_t) nslots
* 8;
9328 ppool
= pindex
+ (size_t) nslots
* 4;
9332 introduce (section
, FALSE
);
9334 printf (_(" Version: %u\n"), version
);
9336 printf (_(" Number of columns: %u\n"), ncols
);
9337 printf (_(" Number of used entries: %u\n"), nused
);
9338 printf (_(" Number of slots: %u\n\n"), nslots
);
9341 /* PR 17531: file: 45d69832. */
9342 if ((size_t) nslots
* 8 / 8 != nslots
9343 || phash
< phdr
|| phash
> limit
9344 || pindex
< phash
|| pindex
> limit
9345 || ppool
< pindex
|| ppool
> limit
)
9347 warn (ngettext ("Section %s is too small for %u slot\n",
9348 "Section %s is too small for %u slots\n",
9350 section
->name
, nslots
);
9357 prealloc_cu_tu_list ((limit
- ppool
) / 4);
9358 for (i
= 0; i
< nslots
; i
++)
9360 unsigned char *shndx_list
;
9363 SAFE_BYTE_GET64 (phash
, &signature_high
, &signature_low
, limit
);
9364 if (signature_high
!= 0 || signature_low
!= 0)
9366 SAFE_BYTE_GET (j
, pindex
, 4, limit
);
9367 shndx_list
= ppool
+ j
* 4;
9368 /* PR 17531: file: 705e010d. */
9369 if (shndx_list
< ppool
)
9371 warn (_("Section index pool located before start of section\n"));
9376 printf (_(" [%3d] Signature: 0x%s Sections: "),
9377 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
9378 buf
, sizeof (buf
)));
9381 if (shndx_list
>= limit
)
9383 warn (_("Section %s too small for shndx pool\n"),
9387 SAFE_BYTE_GET (shndx
, shndx_list
, 4, limit
);
9391 printf (" %d", shndx
);
9393 add_shndx_to_cu_tu_entry (shndx
);
9405 else if (version
== 2)
9408 unsigned int dw_sect
;
9409 unsigned char *ph
= phash
;
9410 unsigned char *pi
= pindex
;
9411 unsigned char *poffsets
= ppool
+ (size_t) ncols
* 4;
9412 unsigned char *psizes
= poffsets
+ (size_t) nused
* ncols
* 4;
9413 unsigned char *pend
= psizes
+ (size_t) nused
* ncols
* 4;
9414 bfd_boolean is_tu_index
;
9415 struct cu_tu_set
*this_set
= NULL
;
9417 unsigned char *prow
;
9419 is_tu_index
= strcmp (section
->name
, ".debug_tu_index") == 0;
9421 /* PR 17531: file: 0dd159bf.
9422 Check for integer overflow (can occur when size_t is 32-bit)
9423 with overlarge ncols or nused values. */
9425 && ((size_t) ncols
* 4 / 4 != ncols
9426 || (size_t) nused
* ncols
* 4 / ((size_t) ncols
* 4) != nused
9427 || poffsets
< ppool
|| poffsets
> limit
9428 || psizes
< poffsets
|| psizes
> limit
9429 || pend
< psizes
|| pend
> limit
))
9431 warn (_("Section %s too small for offset and size tables\n"),
9438 printf (_(" Offset table\n"));
9439 printf (" slot %-16s ",
9440 is_tu_index
? _("signature") : _("dwo_id"));
9447 tu_sets
= xcalloc2 (nused
, sizeof (struct cu_tu_set
));
9453 cu_sets
= xcalloc2 (nused
, sizeof (struct cu_tu_set
));
9460 for (j
= 0; j
< ncols
; j
++)
9462 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
9463 printf (" %8s", get_DW_SECT_short_name (dw_sect
));
9468 for (i
= 0; i
< nslots
; i
++)
9470 SAFE_BYTE_GET64 (ph
, &signature_high
, &signature_low
, limit
);
9472 SAFE_BYTE_GET (row
, pi
, 4, limit
);
9475 /* PR 17531: file: a05f6ab3. */
9478 warn (_("Row index (%u) is larger than number of used entries (%u)\n"),
9485 size_t num_copy
= sizeof (uint64_t);
9487 /* PR 23064: Beware of buffer overflow. */
9488 if (ph
+ num_copy
< limit
)
9489 memcpy (&this_set
[row
- 1].signature
, ph
, num_copy
);
9492 warn (_("Signature (%p) extends beyond end of space in section\n"), ph
);
9497 prow
= poffsets
+ (row
- 1) * ncols
* 4;
9498 /* PR 17531: file: b8ce60a8. */
9499 if (prow
< poffsets
|| prow
> limit
)
9501 warn (_("Row index (%u) * num columns (%u) > space remaining in section\n"),
9507 printf (_(" [%3d] 0x%s"),
9508 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
9509 buf
, sizeof (buf
)));
9510 for (j
= 0; j
< ncols
; j
++)
9512 SAFE_BYTE_GET (val
, prow
+ j
* 4, 4, limit
);
9514 printf (" %8d", val
);
9517 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
9519 /* PR 17531: file: 10796eb3. */
9520 if (dw_sect
>= DW_SECT_MAX
)
9521 warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect
);
9523 this_set
[row
- 1].section_offsets
[dw_sect
] = val
;
9539 printf (_(" Size table\n"));
9540 printf (" slot %-16s ",
9541 is_tu_index
? _("signature") : _("dwo_id"));
9544 for (j
= 0; j
< ncols
; j
++)
9546 SAFE_BYTE_GET (val
, ppool
+ j
* 4, 4, limit
);
9548 printf (" %8s", get_DW_SECT_short_name (val
));
9554 for (i
= 0; i
< nslots
; i
++)
9556 SAFE_BYTE_GET64 (ph
, &signature_high
, &signature_low
, limit
);
9558 SAFE_BYTE_GET (row
, pi
, 4, limit
);
9561 prow
= psizes
+ (row
- 1) * ncols
* 4;
9564 printf (_(" [%3d] 0x%s"),
9565 i
, dwarf_vmatoa64 (signature_high
, signature_low
,
9566 buf
, sizeof (buf
)));
9568 for (j
= 0; j
< ncols
; j
++)
9570 SAFE_BYTE_GET (val
, prow
+ j
* 4, 4, limit
);
9572 printf (" %8d", val
);
9575 SAFE_BYTE_GET (dw_sect
, ppool
+ j
* 4, 4, limit
);
9576 if (dw_sect
>= DW_SECT_MAX
)
9577 warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect
);
9579 this_set
[row
- 1].section_sizes
[dw_sect
] = val
;
9591 else if (do_display
)
9592 printf (_(" Unsupported version (%d)\n"), version
);
9600 /* Load the CU and TU indexes if present. This will build a list of
9601 section sets that we can use to associate a .debug_info.dwo section
9602 with its associated .debug_abbrev.dwo section in a .dwp file. */
9605 load_cu_tu_indexes (void *file
)
9607 static int cu_tu_indexes_read
= -1; /* Tri-state variable. */
9609 /* If we have already loaded (or tried to load) the CU and TU indexes
9610 then do not bother to repeat the task. */
9611 if (cu_tu_indexes_read
== -1)
9613 cu_tu_indexes_read
= TRUE
;
9615 if (load_debug_section_with_follow (dwp_cu_index
, file
))
9616 if (! process_cu_tu_index (&debug_displays
[dwp_cu_index
].section
, 0))
9617 cu_tu_indexes_read
= FALSE
;
9619 if (load_debug_section_with_follow (dwp_tu_index
, file
))
9620 if (! process_cu_tu_index (&debug_displays
[dwp_tu_index
].section
, 0))
9621 cu_tu_indexes_read
= FALSE
;
9624 return (bfd_boolean
) cu_tu_indexes_read
;
9627 /* Find the set of sections that includes section SHNDX. */
9630 find_cu_tu_set (void *file
, unsigned int shndx
)
9634 if (! load_cu_tu_indexes (file
))
9637 /* Find SHNDX in the shndx pool. */
9638 for (i
= 0; i
< shndx_pool_used
; i
++)
9639 if (shndx_pool
[i
] == shndx
)
9642 if (i
>= shndx_pool_used
)
9645 /* Now backup to find the first entry in the set. */
9646 while (i
> 0 && shndx_pool
[i
- 1] != 0)
9649 return shndx_pool
+ i
;
9652 /* Display a .debug_cu_index or .debug_tu_index section. */
9655 display_cu_index (struct dwarf_section
*section
, void *file ATTRIBUTE_UNUSED
)
9657 return process_cu_tu_index (section
, 1);
9661 display_debug_not_supported (struct dwarf_section
*section
,
9662 void *file ATTRIBUTE_UNUSED
)
9664 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
9670 /* Like malloc, but takes two parameters like calloc.
9671 Verifies that the first parameter is not too large.
9672 Note: does *not* initialise the allocated memory to zero. */
9675 cmalloc (size_t nmemb
, size_t size
)
9677 /* Check for overflow. */
9678 if (nmemb
>= ~(size_t) 0 / size
)
9681 return xmalloc (nmemb
* size
);
9684 /* Like xmalloc, but takes two parameters like calloc.
9685 Verifies that the first parameter is not too large.
9686 Note: does *not* initialise the allocated memory to zero. */
9689 xcmalloc (size_t nmemb
, size_t size
)
9691 /* Check for overflow. */
9692 if (nmemb
>= ~(size_t) 0 / size
)
9695 _("Attempt to allocate an array with an excessive number of elements: 0x%lx\n"),
9700 return xmalloc (nmemb
* size
);
9703 /* Like xrealloc, but takes three parameters.
9704 Verifies that the second parameter is not too large.
9705 Note: does *not* initialise any new memory to zero. */
9708 xcrealloc (void *ptr
, size_t nmemb
, size_t size
)
9710 /* Check for overflow. */
9711 if (nmemb
>= ~(size_t) 0 / size
)
9713 error (_("Attempt to re-allocate an array with an excessive number of elements: 0x%lx\n"),
9718 return xrealloc (ptr
, nmemb
* size
);
9721 /* Like xcalloc, but verifies that the first parameter is not too large. */
9724 xcalloc2 (size_t nmemb
, size_t size
)
9726 /* Check for overflow. */
9727 if (nmemb
>= ~(size_t) 0 / size
)
9729 error (_("Attempt to allocate a zero'ed array with an excessive number of elements: 0x%lx\n"),
9734 return xcalloc (nmemb
, size
);
9737 static unsigned long
9738 calc_gnu_debuglink_crc32 (unsigned long crc
,
9739 const unsigned char * buf
,
9742 static const unsigned long crc32_table
[256] =
9744 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
9745 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
9746 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
9747 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
9748 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
9749 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
9750 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
9751 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
9752 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
9753 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
9754 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
9755 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
9756 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
9757 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
9758 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
9759 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
9760 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
9761 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
9762 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
9763 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
9764 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
9765 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
9766 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
9767 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
9768 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
9769 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
9770 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
9771 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
9772 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
9773 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
9774 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
9775 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
9776 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
9777 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
9778 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
9779 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
9780 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
9781 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
9782 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
9783 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
9784 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
9785 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
9786 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
9787 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
9788 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
9789 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
9790 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
9791 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
9792 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
9793 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
9794 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
9797 const unsigned char *end
;
9799 crc
= ~crc
& 0xffffffff;
9800 for (end
= buf
+ len
; buf
< end
; ++ buf
)
9801 crc
= crc32_table
[(crc
^ *buf
) & 0xff] ^ (crc
>> 8);
9802 return ~crc
& 0xffffffff;
9805 typedef bfd_boolean (* check_func_type
) (const char *, void *);
9806 typedef const char * (* parse_func_type
) (struct dwarf_section
*, void *);
9809 check_gnu_debuglink (const char * pathname
, void * crc_pointer
)
9811 static unsigned char buffer
[8 * 1024];
9813 bfd_size_type count
;
9814 unsigned long crc
= 0;
9817 sep_data
= open_debug_file (pathname
);
9818 if (sep_data
== NULL
)
9821 /* Yes - we are opening the file twice... */
9822 f
= fopen (pathname
, "rb");
9825 /* Paranoia: This should never happen. */
9826 close_debug_file (sep_data
);
9827 warn (_("Unable to reopen separate debug info file: %s\n"), pathname
);
9831 while ((count
= fread (buffer
, 1, sizeof (buffer
), f
)) > 0)
9832 crc
= calc_gnu_debuglink_crc32 (crc
, buffer
, count
);
9836 if (crc
!= * (unsigned long *) crc_pointer
)
9838 close_debug_file (sep_data
);
9839 warn (_("Separate debug info file %s found, but CRC does not match - ignoring\n"),
9848 parse_gnu_debuglink (struct dwarf_section
* section
, void * data
)
9851 unsigned int crc_offset
;
9852 unsigned long * crc32
= (unsigned long *) data
;
9854 /* The name is first.
9855 The CRC value is stored after the filename, aligned up to 4 bytes. */
9856 name
= (const char *) section
->start
;
9859 crc_offset
= strnlen (name
, section
->size
) + 1;
9860 crc_offset
= (crc_offset
+ 3) & ~3;
9861 if (crc_offset
+ 4 > section
->size
)
9864 * crc32
= byte_get (section
->start
+ crc_offset
, 4);
9869 check_gnu_debugaltlink (const char * filename
, void * data ATTRIBUTE_UNUSED
)
9871 void * sep_data
= open_debug_file (filename
);
9873 if (sep_data
== NULL
)
9876 /* FIXME: We should now extract the build-id in the separate file
9882 typedef struct build_id_data
9885 const unsigned char * data
;
9889 parse_gnu_debugaltlink (struct dwarf_section
* section
, void * data
)
9892 bfd_size_type namelen
;
9893 bfd_size_type id_len
;
9894 Build_id_data
* build_id_data
;
9896 /* The name is first.
9897 The build-id follows immediately, with no padding, up to the section's end. */
9899 name
= (const char *) section
->start
;
9900 namelen
= strnlen (name
, section
->size
) + 1;
9901 if (namelen
>= section
->size
)
9904 id_len
= section
->size
- namelen
;
9908 build_id_data
= calloc (1, sizeof * build_id_data
);
9909 if (build_id_data
== NULL
)
9912 build_id_data
->len
= id_len
;
9913 build_id_data
->data
= section
->start
+ namelen
;
9915 * (Build_id_data
**) data
= build_id_data
;
9921 add_separate_debug_file (const char * filename
, void * handle
)
9923 separate_info
* i
= xmalloc (sizeof * i
);
9925 i
->filename
= filename
;
9927 i
->next
= first_separate_info
;
9928 first_separate_info
= i
;
9932 load_separate_debug_info (const char * main_filename
,
9933 struct dwarf_section
* xlink
,
9934 parse_func_type parse_func
,
9935 check_func_type check_func
,
9938 const char * separate_filename
;
9939 char * debug_filename
;
9941 size_t canon_dirlen
;
9944 if ((separate_filename
= parse_func (xlink
, func_data
)) == NULL
)
9946 warn (_("Corrupt debuglink section: %s\n"),
9947 xlink
->name
? xlink
->name
: xlink
->uncompressed_name
);
9951 /* Attempt to locate the separate file.
9952 This should duplicate the logic in bfd/opncls.c:find_separate_debug_file(). */
9954 canon_dir
= lrealpath (main_filename
);
9956 for (canon_dirlen
= strlen (canon_dir
); canon_dirlen
> 0; canon_dirlen
--)
9957 if (IS_DIR_SEPARATOR (canon_dir
[canon_dirlen
- 1]))
9959 canon_dir
[canon_dirlen
] = '\0';
9962 #define DEBUGDIR "/lib/debug"
9964 #ifndef EXTRA_DEBUG_ROOT1
9965 #define EXTRA_DEBUG_ROOT1 "/usr/lib/debug"
9967 #ifndef EXTRA_DEBUG_ROOT2
9968 #define EXTRA_DEBUG_ROOT2 "/usr/lib/debug/usr"
9971 debug_filename
= (char *) malloc (strlen (DEBUGDIR
) + 1
9973 + strlen (".debug/")
9974 #ifdef EXTRA_DEBUG_ROOT1
9975 + strlen (EXTRA_DEBUG_ROOT1
)
9977 #ifdef EXTRA_DEBUG_ROOT2
9978 + strlen (EXTRA_DEBUG_ROOT2
)
9980 + strlen (separate_filename
)
9982 if (debug_filename
== NULL
)
9984 warn (_("Out of memory"));
9989 /* First try in the current directory. */
9990 sprintf (debug_filename
, "%s", separate_filename
);
9991 if (check_func (debug_filename
, func_data
))
9994 /* Then try in a subdirectory called .debug. */
9995 sprintf (debug_filename
, ".debug/%s", separate_filename
);
9996 if (check_func (debug_filename
, func_data
))
9999 /* Then try in the same directory as the original file. */
10000 sprintf (debug_filename
, "%s%s", canon_dir
, separate_filename
);
10001 if (check_func (debug_filename
, func_data
))
10004 /* And the .debug subdirectory of that directory. */
10005 sprintf (debug_filename
, "%s.debug/%s", canon_dir
, separate_filename
);
10006 if (check_func (debug_filename
, func_data
))
10009 #ifdef EXTRA_DEBUG_ROOT1
10010 /* Try the first extra debug file root. */
10011 sprintf (debug_filename
, "%s/%s", EXTRA_DEBUG_ROOT1
, separate_filename
);
10012 if (check_func (debug_filename
, func_data
))
10015 /* Try the first extra debug file root. */
10016 sprintf (debug_filename
, "%s/%s/%s", EXTRA_DEBUG_ROOT1
, canon_dir
, separate_filename
);
10017 if (check_func (debug_filename
, func_data
))
10021 #ifdef EXTRA_DEBUG_ROOT2
10022 /* Try the second extra debug file root. */
10023 sprintf (debug_filename
, "%s/%s", EXTRA_DEBUG_ROOT2
, separate_filename
);
10024 if (check_func (debug_filename
, func_data
))
10028 /* Then try in the global debug_filename directory. */
10029 strcpy (debug_filename
, DEBUGDIR
);
10030 dirlen
= strlen (DEBUGDIR
) - 1;
10031 if (dirlen
> 0 && DEBUGDIR
[dirlen
] != '/')
10032 strcat (debug_filename
, "/");
10033 strcat (debug_filename
, (const char *) separate_filename
);
10035 if (check_func (debug_filename
, func_data
))
10038 /* Failed to find the file. */
10039 warn (_("could not find separate debug file '%s'\n"), separate_filename
);
10040 warn (_("tried: %s\n"), debug_filename
);
10042 #ifdef EXTRA_DEBUG_ROOT2
10043 sprintf (debug_filename
, "%s/%s", EXTRA_DEBUG_ROOT2
, separate_filename
);
10044 warn (_("tried: %s\n"), debug_filename
);
10047 #ifdef EXTRA_DEBUG_ROOT1
10048 sprintf (debug_filename
, "%s/%s/%s", EXTRA_DEBUG_ROOT1
, canon_dir
, separate_filename
);
10049 warn (_("tried: %s\n"), debug_filename
);
10051 sprintf (debug_filename
, "%s/%s", EXTRA_DEBUG_ROOT1
, separate_filename
);
10052 warn (_("tried: %s\n"), debug_filename
);
10055 sprintf (debug_filename
, "%s.debug/%s", canon_dir
, separate_filename
);
10056 warn (_("tried: %s\n"), debug_filename
);
10058 sprintf (debug_filename
, "%s%s", canon_dir
, separate_filename
);
10059 warn (_("tried: %s\n"), debug_filename
);
10061 sprintf (debug_filename
, ".debug/%s", separate_filename
);
10062 warn (_("tried: %s\n"), debug_filename
);
10064 sprintf (debug_filename
, "%s", separate_filename
);
10065 warn (_("tried: %s\n"), debug_filename
);
10068 free (debug_filename
);
10074 void * debug_handle
;
10076 /* Now open the file.... */
10077 if ((debug_handle
= open_debug_file (debug_filename
)) == NULL
)
10079 warn (_("failed to open separate debug file: %s\n"), debug_filename
);
10080 free (debug_filename
);
10084 /* FIXME: We do not check to see if there are any other separate debug info
10085 files that would also match. */
10087 printf (_("%s: Found separate debug info file: %s\n\n"), main_filename
, debug_filename
);
10088 add_separate_debug_file (debug_filename
, debug_handle
);
10090 /* Do not free debug_filename - it might be referenced inside
10091 the structure returned by open_debug_file(). */
10092 return debug_handle
;
10095 /* Attempt to load a separate dwarf object file. */
10098 load_dwo_file (const char * main_filename
, const char * name
, const char * dir
, const char * id ATTRIBUTE_UNUSED
)
10100 char * separate_filename
;
10101 void * separate_handle
;
10103 /* FIXME: Skip adding / if dwo_dir ends in /. */
10104 separate_filename
= concat (dir
, "/", name
, NULL
);
10105 if (separate_filename
== NULL
)
10107 warn (_("Out of memory allocating dwo filename\n"));
10111 if ((separate_handle
= open_debug_file (separate_filename
)) == NULL
)
10113 warn (_("Unable to load dwo file: %s\n"), separate_filename
);
10114 free (separate_filename
);
10118 /* FIXME: We should check the dwo_id. */
10120 printf (_("%s: Found separate debug object file: %s\n\n"), main_filename
, separate_filename
);
10121 add_separate_debug_file (separate_filename
, separate_handle
);
10122 /* Note - separate_filename will be freed in free_debug_memory(). */
10123 return separate_handle
;
10126 /* Load the separate debug info file(s) attached to FILE, if any exist.
10127 Returns TRUE if any were found, FALSE otherwise.
10128 If TRUE is returned then the linked list starting at first_separate_info
10129 will be populated with open file handles. */
10132 load_separate_debug_files (void * file
, const char * filename
)
10134 /* Skip this operation if we are not interested in debug links. */
10135 if (! do_follow_links
&& ! do_debug_links
)
10138 /* See if there are any dwo links. */
10139 if (load_debug_section (str
, file
)
10140 && load_debug_section (abbrev
, file
)
10141 && load_debug_section (info
, file
))
10145 if (process_debug_info (& debug_displays
[info
].section
, file
, abbrev
, TRUE
, FALSE
))
10147 bfd_boolean introduced
= FALSE
;
10149 const char * dir
= NULL
;
10150 const char * id
= NULL
;
10152 for (dwinfo
= first_dwo_info
; dwinfo
!= NULL
; dwinfo
= dwinfo
->next
)
10154 switch (dwinfo
->type
)
10157 if (do_debug_links
)
10161 printf (_("The %s section contains link(s) to dwo file(s):\n\n"),
10162 debug_displays
[info
].section
.uncompressed_name
);
10166 printf (_(" Name: %s\n"), dwinfo
->value
);
10167 printf (_(" Directory: %s\n"), dir
? dir
: _("<not-found>"));
10169 display_data (printf (_(" ID: ")), (unsigned char *) id
, 8);
10171 printf (_(" ID: <unknown>\n"));
10175 if (do_follow_links
)
10176 load_dwo_file (filename
, dwinfo
->value
, dir
, id
);
10180 dir
= dwinfo
->value
;
10184 id
= dwinfo
->value
;
10188 error (_("Unexpected DWO INFO type"));
10195 if (! do_follow_links
)
10196 /* The other debug links will be displayed by display_debug_links()
10197 so we do not need to do any further processing here. */
10200 /* FIXME: We do not check for the presence of both link sections in the same file. */
10201 /* FIXME: We do not check the separate debug info file to see if it too contains debuglinks. */
10202 /* FIXME: We do not check for the presence of multiple, same-name debuglink sections. */
10203 /* FIXME: We do not check for the presence of a dwo link as well as a debuglink. */
10205 if (load_debug_section (gnu_debugaltlink
, file
))
10207 Build_id_data
* build_id_data
;
10209 load_separate_debug_info (filename
,
10210 & debug_displays
[gnu_debugaltlink
].section
,
10211 parse_gnu_debugaltlink
,
10212 check_gnu_debugaltlink
,
10216 if (load_debug_section (gnu_debuglink
, file
))
10218 unsigned long crc32
;
10220 load_separate_debug_info (filename
,
10221 & debug_displays
[gnu_debuglink
].section
,
10222 parse_gnu_debuglink
,
10223 check_gnu_debuglink
,
10227 if (first_separate_info
!= NULL
)
10230 do_follow_links
= 0;
10235 free_debug_memory (void)
10241 for (i
= 0; i
< max
; i
++)
10242 free_debug_section ((enum dwarf_section_display_enum
) i
);
10244 if (debug_information
!= NULL
)
10246 if (num_debug_info_entries
!= DEBUG_INFO_UNAVAILABLE
)
10248 for (i
= 0; i
< num_debug_info_entries
; i
++)
10250 if (!debug_information
[i
].max_loc_offsets
)
10252 free (debug_information
[i
].loc_offsets
);
10253 free (debug_information
[i
].have_frame_base
);
10255 if (!debug_information
[i
].max_range_lists
)
10256 free (debug_information
[i
].range_lists
);
10259 free (debug_information
);
10260 debug_information
= NULL
;
10261 alloc_num_debug_info_entries
= num_debug_info_entries
= 0;
10265 separate_info
* next
;
10267 for (d
= first_separate_info
; d
!= NULL
; d
= next
)
10269 close_debug_file (d
->handle
);
10270 free ((void *) d
->filename
);
10274 first_separate_info
= NULL
;
10280 dwarf_select_sections_by_names (const char *names
)
10284 const char * option
;
10288 debug_dump_long_opts
;
10290 static const debug_dump_long_opts opts_table
[] =
10292 /* Please keep this table alpha- sorted. */
10293 { "Ranges", & do_debug_ranges
, 1 },
10294 { "abbrev", & do_debug_abbrevs
, 1 },
10295 { "addr", & do_debug_addr
, 1 },
10296 { "aranges", & do_debug_aranges
, 1 },
10297 { "cu_index", & do_debug_cu_index
, 1 },
10298 { "decodedline", & do_debug_lines
, FLAG_DEBUG_LINES_DECODED
},
10299 { "follow-links", & do_follow_links
, 1 },
10300 { "frames", & do_debug_frames
, 1 },
10301 { "frames-interp", & do_debug_frames_interp
, 1 },
10302 /* The special .gdb_index section. */
10303 { "gdb_index", & do_gdb_index
, 1 },
10304 { "info", & do_debug_info
, 1 },
10305 { "line", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
}, /* For backwards compatibility. */
10306 { "links", & do_debug_links
, 1 },
10307 { "loc", & do_debug_loc
, 1 },
10308 { "macro", & do_debug_macinfo
, 1 },
10309 { "pubnames", & do_debug_pubnames
, 1 },
10310 { "pubtypes", & do_debug_pubtypes
, 1 },
10311 /* This entry is for compatibility
10312 with earlier versions of readelf. */
10313 { "ranges", & do_debug_aranges
, 1 },
10314 { "rawline", & do_debug_lines
, FLAG_DEBUG_LINES_RAW
},
10315 { "str", & do_debug_str
, 1 },
10316 /* These trace_* sections are used by Itanium VMS. */
10317 { "trace_abbrev", & do_trace_abbrevs
, 1 },
10318 { "trace_aranges", & do_trace_aranges
, 1 },
10319 { "trace_info", & do_trace_info
, 1 },
10328 const debug_dump_long_opts
* entry
;
10330 for (entry
= opts_table
; entry
->option
; entry
++)
10332 size_t len
= strlen (entry
->option
);
10334 if (strncmp (p
, entry
->option
, len
) == 0
10335 && (p
[len
] == ',' || p
[len
] == '\0'))
10337 * entry
->variable
|= entry
->val
;
10339 /* The --debug-dump=frames-interp option also
10340 enables the --debug-dump=frames option. */
10341 if (do_debug_frames_interp
)
10342 do_debug_frames
= 1;
10349 if (entry
->option
== NULL
)
10351 warn (_("Unrecognized debug option '%s'\n"), p
);
10352 p
= strchr (p
, ',');
10363 dwarf_select_sections_by_letters (const char *letters
)
10365 unsigned int lindex
= 0;
10367 while (letters
[lindex
])
10368 switch (letters
[lindex
++])
10370 case 'A': do_debug_addr
= 1; break;
10371 case 'a': do_debug_abbrevs
= 1; break;
10372 case 'c': do_debug_cu_index
= 1; break;
10373 case 'F': do_debug_frames_interp
= 1; /* Fall through. */
10374 case 'f': do_debug_frames
= 1; break;
10375 case 'g': do_gdb_index
= 1; break;
10376 case 'i': do_debug_info
= 1; break;
10377 case 'K': do_follow_links
= 1; break;
10378 case 'k': do_debug_links
= 1; break;
10379 case 'l': do_debug_lines
|= FLAG_DEBUG_LINES_RAW
; break;
10380 case 'L': do_debug_lines
|= FLAG_DEBUG_LINES_DECODED
; break;
10381 case 'm': do_debug_macinfo
= 1; break;
10382 case 'o': do_debug_loc
= 1; break;
10383 case 'p': do_debug_pubnames
= 1; break;
10384 case 'R': do_debug_ranges
= 1; break;
10385 case 'r': do_debug_aranges
= 1; break;
10386 case 's': do_debug_str
= 1; break;
10387 case 'T': do_trace_aranges
= 1; break;
10388 case 't': do_debug_pubtypes
= 1; break;
10389 case 'U': do_trace_info
= 1; break;
10390 case 'u': do_trace_abbrevs
= 1; break;
10393 warn (_("Unrecognized debug option '%s'\n"), letters
);
10399 dwarf_select_sections_all (void)
10402 do_debug_abbrevs
= 1;
10403 do_debug_lines
= FLAG_DEBUG_LINES_RAW
;
10404 do_debug_pubnames
= 1;
10405 do_debug_pubtypes
= 1;
10406 do_debug_aranges
= 1;
10407 do_debug_ranges
= 1;
10408 do_debug_frames
= 1;
10409 do_debug_macinfo
= 1;
10414 do_trace_abbrevs
= 1;
10415 do_trace_aranges
= 1;
10417 do_debug_cu_index
= 1;
10418 do_follow_links
= 1;
10419 do_debug_links
= 1;
10422 #define NO_ABBREVS NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL
10423 #define ABBREV(N) NULL, NULL, NULL, 0, 0, N, NULL, 0, NULL
10425 /* N.B. The order here must match the order in section_display_enum. */
10427 struct dwarf_section_display debug_displays
[] =
10429 { { ".debug_abbrev", ".zdebug_abbrev", NO_ABBREVS
}, display_debug_abbrev
, &do_debug_abbrevs
, FALSE
},
10430 { { ".debug_aranges", ".zdebug_aranges", NO_ABBREVS
}, display_debug_aranges
, &do_debug_aranges
, TRUE
},
10431 { { ".debug_frame", ".zdebug_frame", NO_ABBREVS
}, display_debug_frames
, &do_debug_frames
, TRUE
},
10432 { { ".debug_info", ".zdebug_info", ABBREV (abbrev
)}, display_debug_info
, &do_debug_info
, TRUE
},
10433 { { ".debug_line", ".zdebug_line", NO_ABBREVS
}, display_debug_lines
, &do_debug_lines
, TRUE
},
10434 { { ".debug_pubnames", ".zdebug_pubnames", NO_ABBREVS
}, display_debug_pubnames
, &do_debug_pubnames
, FALSE
},
10435 { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NO_ABBREVS
}, display_debug_gnu_pubnames
, &do_debug_pubnames
, FALSE
},
10436 { { ".eh_frame", "", NO_ABBREVS
}, display_debug_frames
, &do_debug_frames
, TRUE
},
10437 { { ".debug_macinfo", ".zdebug_macinfo", NO_ABBREVS
}, display_debug_macinfo
, &do_debug_macinfo
, FALSE
},
10438 { { ".debug_macro", ".zdebug_macro", NO_ABBREVS
}, display_debug_macro
, &do_debug_macinfo
, TRUE
},
10439 { { ".debug_str", ".zdebug_str", NO_ABBREVS
}, display_debug_str
, &do_debug_str
, FALSE
},
10440 { { ".debug_line_str", ".zdebug_line_str", NO_ABBREVS
}, display_debug_str
, &do_debug_str
, FALSE
},
10441 { { ".debug_loc", ".zdebug_loc", NO_ABBREVS
}, display_debug_loc
, &do_debug_loc
, TRUE
},
10442 { { ".debug_loclists", ".zdebug_loclists", NO_ABBREVS
}, display_debug_loc
, &do_debug_loc
, TRUE
},
10443 { { ".debug_pubtypes", ".zdebug_pubtypes", NO_ABBREVS
}, display_debug_pubnames
, &do_debug_pubtypes
, FALSE
},
10444 { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NO_ABBREVS
}, display_debug_gnu_pubnames
, &do_debug_pubtypes
, FALSE
},
10445 { { ".debug_ranges", ".zdebug_ranges", NO_ABBREVS
}, display_debug_ranges
, &do_debug_ranges
, TRUE
},
10446 { { ".debug_rnglists", ".zdebug_rnglists", NO_ABBREVS
}, display_debug_ranges
, &do_debug_ranges
, TRUE
},
10447 { { ".debug_static_func", ".zdebug_static_func", NO_ABBREVS
}, display_debug_not_supported
, NULL
, FALSE
},
10448 { { ".debug_static_vars", ".zdebug_static_vars", NO_ABBREVS
}, display_debug_not_supported
, NULL
, FALSE
},
10449 { { ".debug_types", ".zdebug_types", ABBREV (abbrev
) }, display_debug_types
, &do_debug_info
, TRUE
},
10450 { { ".debug_weaknames", ".zdebug_weaknames", NO_ABBREVS
}, display_debug_not_supported
, NULL
, FALSE
},
10451 { { ".gdb_index", "", NO_ABBREVS
}, display_gdb_index
, &do_gdb_index
, FALSE
},
10452 { { ".debug_names", "", NO_ABBREVS
}, display_debug_names
, &do_gdb_index
, FALSE
},
10453 { { ".trace_info", "", ABBREV (trace_abbrev
) }, display_trace_info
, &do_trace_info
, TRUE
},
10454 { { ".trace_abbrev", "", NO_ABBREVS
}, display_debug_abbrev
, &do_trace_abbrevs
, FALSE
},
10455 { { ".trace_aranges", "", NO_ABBREVS
}, display_debug_aranges
, &do_trace_aranges
, FALSE
},
10456 { { ".debug_info.dwo", ".zdebug_info.dwo", ABBREV (abbrev_dwo
) }, display_debug_info
, &do_debug_info
, TRUE
},
10457 { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NO_ABBREVS
}, display_debug_abbrev
, &do_debug_abbrevs
, FALSE
},
10458 { { ".debug_types.dwo", ".zdebug_types.dwo", ABBREV (abbrev_dwo
) }, display_debug_types
, &do_debug_info
, TRUE
},
10459 { { ".debug_line.dwo", ".zdebug_line.dwo", NO_ABBREVS
}, display_debug_lines
, &do_debug_lines
, TRUE
},
10460 { { ".debug_loc.dwo", ".zdebug_loc.dwo", NO_ABBREVS
}, display_debug_loc
, &do_debug_loc
, TRUE
},
10461 { { ".debug_macro.dwo", ".zdebug_macro.dwo", NO_ABBREVS
}, display_debug_macro
, &do_debug_macinfo
, TRUE
},
10462 { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NO_ABBREVS
}, display_debug_macinfo
, &do_debug_macinfo
, FALSE
},
10463 { { ".debug_str.dwo", ".zdebug_str.dwo", NO_ABBREVS
}, display_debug_str
, &do_debug_str
, TRUE
},
10464 { { ".debug_str_offsets", ".zdebug_str_offsets", NO_ABBREVS
}, display_debug_str_offsets
, NULL
, FALSE
},
10465 { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NO_ABBREVS
}, display_debug_str_offsets
, NULL
, FALSE
},
10466 { { ".debug_addr", ".zdebug_addr", NO_ABBREVS
}, display_debug_addr
, &do_debug_addr
, TRUE
},
10467 { { ".debug_cu_index", "", NO_ABBREVS
}, display_cu_index
, &do_debug_cu_index
, FALSE
},
10468 { { ".debug_tu_index", "", NO_ABBREVS
}, display_cu_index
, &do_debug_cu_index
, FALSE
},
10469 { { ".gnu_debuglink", "", NO_ABBREVS
}, display_debug_links
, &do_debug_links
, FALSE
},
10470 { { ".gnu_debugaltlink", "", NO_ABBREVS
}, display_debug_links
, &do_debug_links
, FALSE
},
10471 /* Separate debug info files can containt their own .debug_str section,
10472 and this might be in *addition* to a .debug_str section already present
10473 in the main file. Hence we need to have two entries for .debug_str. */
10474 { { ".debug_str", ".zdebug_str", NO_ABBREVS
}, display_debug_str
, &do_debug_str
, FALSE
},
10477 /* A static assertion. */
10478 extern int debug_displays_assert
[ARRAY_SIZE (debug_displays
) == max
? 1 : -1];