| 1 | /* dwarf.c -- display DWARF contents of a BFD binary file |
| 2 | Copyright (C) 2005-2017 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GNU Binutils. |
| 5 | |
| 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. |
| 10 | |
| 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. |
| 15 | |
| 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 |
| 19 | 02110-1301, USA. */ |
| 20 | |
| 21 | #include "sysdep.h" |
| 22 | #include "libiberty.h" |
| 23 | #include "bfd.h" |
| 24 | #include "bfd_stdint.h" |
| 25 | #include "bucomm.h" |
| 26 | #include "elfcomm.h" |
| 27 | #include "elf/common.h" |
| 28 | #include "dwarf2.h" |
| 29 | #include "dwarf.h" |
| 30 | #include "gdb/gdb-index.h" |
| 31 | |
| 32 | static const char *regname (unsigned int regno, int row); |
| 33 | |
| 34 | static int have_frame_base; |
| 35 | static int need_base_address; |
| 36 | |
| 37 | static unsigned int last_pointer_size = 0; |
| 38 | static int warned_about_missing_comp_units = FALSE; |
| 39 | |
| 40 | static unsigned int num_debug_info_entries = 0; |
| 41 | static unsigned int alloc_num_debug_info_entries = 0; |
| 42 | static debug_info *debug_information = NULL; |
| 43 | /* Special value for num_debug_info_entries to indicate |
| 44 | that the .debug_info section could not be loaded/parsed. */ |
| 45 | #define DEBUG_INFO_UNAVAILABLE (unsigned int) -1 |
| 46 | |
| 47 | unsigned int eh_addr_size; |
| 48 | |
| 49 | int do_debug_info; |
| 50 | int do_debug_abbrevs; |
| 51 | int do_debug_lines; |
| 52 | int do_debug_pubnames; |
| 53 | int do_debug_pubtypes; |
| 54 | int do_debug_aranges; |
| 55 | int do_debug_ranges; |
| 56 | int do_debug_frames; |
| 57 | int do_debug_frames_interp; |
| 58 | int do_debug_macinfo; |
| 59 | int do_debug_str; |
| 60 | int do_debug_loc; |
| 61 | int do_gdb_index; |
| 62 | int do_trace_info; |
| 63 | int do_trace_abbrevs; |
| 64 | int do_trace_aranges; |
| 65 | int do_debug_addr; |
| 66 | int do_debug_cu_index; |
| 67 | int do_wide; |
| 68 | |
| 69 | int dwarf_cutoff_level = -1; |
| 70 | unsigned long dwarf_start_die; |
| 71 | |
| 72 | int dwarf_check = 0; |
| 73 | |
| 74 | /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index |
| 75 | sections. For version 1 package files, each set is stored in SHNDX_POOL |
| 76 | as a zero-terminated list of section indexes comprising one set of debug |
| 77 | sections from a .dwo file. */ |
| 78 | |
| 79 | static unsigned int *shndx_pool = NULL; |
| 80 | static unsigned int shndx_pool_size = 0; |
| 81 | static unsigned int shndx_pool_used = 0; |
| 82 | |
| 83 | /* For version 2 package files, each set contains an array of section offsets |
| 84 | and an array of section sizes, giving the offset and size of the |
| 85 | contribution from a CU or TU within one of the debug sections. |
| 86 | When displaying debug info from a package file, we need to use these |
| 87 | tables to locate the corresponding contributions to each section. */ |
| 88 | |
| 89 | struct cu_tu_set |
| 90 | { |
| 91 | uint64_t signature; |
| 92 | dwarf_vma section_offsets[DW_SECT_MAX]; |
| 93 | size_t section_sizes[DW_SECT_MAX]; |
| 94 | }; |
| 95 | |
| 96 | static int cu_count = 0; |
| 97 | static int tu_count = 0; |
| 98 | static struct cu_tu_set *cu_sets = NULL; |
| 99 | static struct cu_tu_set *tu_sets = NULL; |
| 100 | |
| 101 | static bfd_boolean load_cu_tu_indexes (void *); |
| 102 | |
| 103 | /* Values for do_debug_lines. */ |
| 104 | #define FLAG_DEBUG_LINES_RAW 1 |
| 105 | #define FLAG_DEBUG_LINES_DECODED 2 |
| 106 | |
| 107 | static unsigned int |
| 108 | size_of_encoded_value (int encoding) |
| 109 | { |
| 110 | switch (encoding & 0x7) |
| 111 | { |
| 112 | default: /* ??? */ |
| 113 | case 0: return eh_addr_size; |
| 114 | case 2: return 2; |
| 115 | case 3: return 4; |
| 116 | case 4: return 8; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | static dwarf_vma |
| 121 | get_encoded_value (unsigned char **pdata, |
| 122 | int encoding, |
| 123 | struct dwarf_section *section, |
| 124 | unsigned char * end) |
| 125 | { |
| 126 | unsigned char * data = * pdata; |
| 127 | unsigned int size = size_of_encoded_value (encoding); |
| 128 | dwarf_vma val; |
| 129 | |
| 130 | if (data + size >= end) |
| 131 | { |
| 132 | warn (_("Encoded value extends past end of section\n")); |
| 133 | * pdata = end; |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | /* PR 17512: file: 002-829853-0.004. */ |
| 138 | if (size > 8) |
| 139 | { |
| 140 | warn (_("Encoded size of %d is too large to read\n"), size); |
| 141 | * pdata = end; |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | /* PR 17512: file: 1085-5603-0.004. */ |
| 146 | if (size == 0) |
| 147 | { |
| 148 | warn (_("Encoded size of 0 is too small to read\n")); |
| 149 | * pdata = end; |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | if (encoding & DW_EH_PE_signed) |
| 154 | val = byte_get_signed (data, size); |
| 155 | else |
| 156 | val = byte_get (data, size); |
| 157 | |
| 158 | if ((encoding & 0x70) == DW_EH_PE_pcrel) |
| 159 | val += section->address + (data - section->start); |
| 160 | |
| 161 | * pdata = data + size; |
| 162 | return val; |
| 163 | } |
| 164 | |
| 165 | #if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG |
| 166 | # ifndef __MINGW32__ |
| 167 | # define DWARF_VMA_FMT "ll" |
| 168 | # define DWARF_VMA_FMT_LONG "%16.16llx" |
| 169 | # else |
| 170 | # define DWARF_VMA_FMT "I64" |
| 171 | # define DWARF_VMA_FMT_LONG "%016I64x" |
| 172 | # endif |
| 173 | #else |
| 174 | # define DWARF_VMA_FMT "l" |
| 175 | # define DWARF_VMA_FMT_LONG "%16.16lx" |
| 176 | #endif |
| 177 | |
| 178 | /* Convert a dwarf vma value into a string. Returns a pointer to a static |
| 179 | buffer containing the converted VALUE. The value is converted according |
| 180 | to the printf formating character FMTCH. If NUM_BYTES is non-zero then |
| 181 | it specifies the maximum number of bytes to be displayed in the converted |
| 182 | value and FMTCH is ignored - hex is always used. */ |
| 183 | |
| 184 | static const char * |
| 185 | dwarf_vmatoa_1 (const char *fmtch, dwarf_vma value, unsigned num_bytes) |
| 186 | { |
| 187 | /* As dwarf_vmatoa is used more then once in a printf call |
| 188 | for output, we are cycling through an fixed array of pointers |
| 189 | for return address. */ |
| 190 | static int buf_pos = 0; |
| 191 | static struct dwarf_vmatoa_buf |
| 192 | { |
| 193 | char place[64]; |
| 194 | } buf[16]; |
| 195 | char *ret; |
| 196 | |
| 197 | ret = buf[buf_pos++].place; |
| 198 | buf_pos %= ARRAY_SIZE (buf); |
| 199 | |
| 200 | if (num_bytes) |
| 201 | { |
| 202 | /* Printf does not have a way of specifying a maximum field width for an |
| 203 | integer value, so we print the full value into a buffer and then select |
| 204 | the precision we need. */ |
| 205 | snprintf (ret, sizeof (buf[0].place), DWARF_VMA_FMT_LONG, value); |
| 206 | if (num_bytes > 8) |
| 207 | num_bytes = 8; |
| 208 | return ret + (16 - 2 * num_bytes); |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | char fmt[32]; |
| 213 | |
| 214 | sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch); |
| 215 | snprintf (ret, sizeof (buf[0].place), fmt, value); |
| 216 | return ret; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | static inline const char * |
| 221 | dwarf_vmatoa (const char * fmtch, dwarf_vma value) |
| 222 | { |
| 223 | return dwarf_vmatoa_1 (fmtch, value, 0); |
| 224 | } |
| 225 | |
| 226 | /* Print a dwarf_vma value (typically an address, offset or length) in |
| 227 | hexadecimal format, followed by a space. The length of the VALUE (and |
| 228 | hence the precision displayed) is determined by the NUM_BYTES parameter. */ |
| 229 | |
| 230 | static void |
| 231 | print_dwarf_vma (dwarf_vma value, unsigned num_bytes) |
| 232 | { |
| 233 | printf ("%s ", dwarf_vmatoa_1 (NULL, value, num_bytes)); |
| 234 | } |
| 235 | |
| 236 | /* Format a 64-bit value, given as two 32-bit values, in hex. |
| 237 | For reentrancy, this uses a buffer provided by the caller. */ |
| 238 | |
| 239 | static const char * |
| 240 | dwarf_vmatoa64 (dwarf_vma hvalue, dwarf_vma lvalue, char *buf, |
| 241 | unsigned int buf_len) |
| 242 | { |
| 243 | int len = 0; |
| 244 | |
| 245 | if (hvalue == 0) |
| 246 | snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", lvalue); |
| 247 | else |
| 248 | { |
| 249 | len = snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", hvalue); |
| 250 | snprintf (buf + len, buf_len - len, |
| 251 | "%08" DWARF_VMA_FMT "x", lvalue); |
| 252 | } |
| 253 | |
| 254 | return buf; |
| 255 | } |
| 256 | |
| 257 | /* Read in a LEB128 encoded value starting at address DATA. |
| 258 | If SIGN is true, return a signed LEB128 value. |
| 259 | If LENGTH_RETURN is not NULL, return in it the number of bytes read. |
| 260 | No bytes will be read at address END or beyond. */ |
| 261 | |
| 262 | dwarf_vma |
| 263 | read_leb128 (unsigned char *data, |
| 264 | unsigned int *length_return, |
| 265 | bfd_boolean sign, |
| 266 | const unsigned char * const end) |
| 267 | { |
| 268 | dwarf_vma result = 0; |
| 269 | unsigned int num_read = 0; |
| 270 | unsigned int shift = 0; |
| 271 | unsigned char byte = 0; |
| 272 | |
| 273 | while (data < end) |
| 274 | { |
| 275 | byte = *data++; |
| 276 | num_read++; |
| 277 | |
| 278 | result |= ((dwarf_vma) (byte & 0x7f)) << shift; |
| 279 | |
| 280 | shift += 7; |
| 281 | if ((byte & 0x80) == 0) |
| 282 | break; |
| 283 | |
| 284 | /* PR 17512: file: 0ca183b8. |
| 285 | FIXME: Should we signal this error somehow ? */ |
| 286 | if (shift >= sizeof (result) * 8) |
| 287 | break; |
| 288 | } |
| 289 | |
| 290 | if (length_return != NULL) |
| 291 | *length_return = num_read; |
| 292 | |
| 293 | if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40)) |
| 294 | result |= -((dwarf_vma) 1 << shift); |
| 295 | |
| 296 | return result; |
| 297 | } |
| 298 | |
| 299 | /* Create a signed version to avoid painful typecasts. */ |
| 300 | static inline dwarf_signed_vma |
| 301 | read_sleb128 (unsigned char * data, |
| 302 | unsigned int * length_return, |
| 303 | const unsigned char * const end) |
| 304 | { |
| 305 | return (dwarf_signed_vma) read_leb128 (data, length_return, TRUE, end); |
| 306 | } |
| 307 | |
| 308 | static inline dwarf_vma |
| 309 | read_uleb128 (unsigned char * data, |
| 310 | unsigned int * length_return, |
| 311 | const unsigned char * const end) |
| 312 | { |
| 313 | return read_leb128 (data, length_return, FALSE, end); |
| 314 | } |
| 315 | |
| 316 | #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \ |
| 317 | do \ |
| 318 | { \ |
| 319 | unsigned int amount = (AMOUNT); \ |
| 320 | if (sizeof (VAL) < amount) \ |
| 321 | { \ |
| 322 | error (_("internal error: attempt to read %d bytes of data in to %d sized variable"),\ |
| 323 | amount, (int) sizeof (VAL)); \ |
| 324 | amount = sizeof (VAL); \ |
| 325 | } \ |
| 326 | if (((PTR) + amount) >= (END)) \ |
| 327 | { \ |
| 328 | if ((PTR) < (END)) \ |
| 329 | amount = (END) - (PTR); \ |
| 330 | else \ |
| 331 | amount = 0; \ |
| 332 | } \ |
| 333 | if (amount == 0 || amount > 8) \ |
| 334 | VAL = 0; \ |
| 335 | else \ |
| 336 | VAL = byte_get ((PTR), amount); \ |
| 337 | } \ |
| 338 | while (0) |
| 339 | |
| 340 | #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ |
| 341 | do \ |
| 342 | { \ |
| 343 | SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \ |
| 344 | PTR += AMOUNT; \ |
| 345 | } \ |
| 346 | while (0) |
| 347 | |
| 348 | #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \ |
| 349 | do \ |
| 350 | { \ |
| 351 | unsigned int amount = (AMOUNT); \ |
| 352 | if (((PTR) + amount) >= (END)) \ |
| 353 | { \ |
| 354 | if ((PTR) < (END)) \ |
| 355 | amount = (END) - (PTR); \ |
| 356 | else \ |
| 357 | amount = 0; \ |
| 358 | } \ |
| 359 | if (amount) \ |
| 360 | VAL = byte_get_signed ((PTR), amount); \ |
| 361 | else \ |
| 362 | VAL = 0; \ |
| 363 | } \ |
| 364 | while (0) |
| 365 | |
| 366 | #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ |
| 367 | do \ |
| 368 | { \ |
| 369 | SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \ |
| 370 | PTR += AMOUNT; \ |
| 371 | } \ |
| 372 | while (0) |
| 373 | |
| 374 | #define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \ |
| 375 | do \ |
| 376 | { \ |
| 377 | if (((PTR) + 8) <= (END)) \ |
| 378 | { \ |
| 379 | byte_get_64 ((PTR), (HIGH), (LOW)); \ |
| 380 | } \ |
| 381 | else \ |
| 382 | { \ |
| 383 | * (LOW) = * (HIGH) = 0; \ |
| 384 | } \ |
| 385 | } \ |
| 386 | while (0) |
| 387 | |
| 388 | typedef struct State_Machine_Registers |
| 389 | { |
| 390 | dwarf_vma address; |
| 391 | unsigned int file; |
| 392 | unsigned int line; |
| 393 | unsigned int column; |
| 394 | int is_stmt; |
| 395 | int basic_block; |
| 396 | unsigned char op_index; |
| 397 | unsigned char end_sequence; |
| 398 | /* This variable hold the number of the last entry seen |
| 399 | in the File Table. */ |
| 400 | unsigned int last_file_entry; |
| 401 | } SMR; |
| 402 | |
| 403 | static SMR state_machine_regs; |
| 404 | |
| 405 | static void |
| 406 | reset_state_machine (int is_stmt) |
| 407 | { |
| 408 | state_machine_regs.address = 0; |
| 409 | state_machine_regs.op_index = 0; |
| 410 | state_machine_regs.file = 1; |
| 411 | state_machine_regs.line = 1; |
| 412 | state_machine_regs.column = 0; |
| 413 | state_machine_regs.is_stmt = is_stmt; |
| 414 | state_machine_regs.basic_block = 0; |
| 415 | state_machine_regs.end_sequence = 0; |
| 416 | state_machine_regs.last_file_entry = 0; |
| 417 | } |
| 418 | |
| 419 | /* Handled an extend line op. |
| 420 | Returns the number of bytes read. */ |
| 421 | |
| 422 | static int |
| 423 | process_extended_line_op (unsigned char * data, |
| 424 | int is_stmt, |
| 425 | unsigned char * end) |
| 426 | { |
| 427 | unsigned char op_code; |
| 428 | unsigned int bytes_read; |
| 429 | unsigned int len; |
| 430 | unsigned char *name; |
| 431 | unsigned char *orig_data = data; |
| 432 | dwarf_vma adr; |
| 433 | |
| 434 | len = read_uleb128 (data, & bytes_read, end); |
| 435 | data += bytes_read; |
| 436 | |
| 437 | if (len == 0 || data == end || len > (uintptr_t) (end - data)) |
| 438 | { |
| 439 | warn (_("Badly formed extended line op encountered!\n")); |
| 440 | return bytes_read; |
| 441 | } |
| 442 | |
| 443 | len += bytes_read; |
| 444 | op_code = *data++; |
| 445 | |
| 446 | printf (_(" Extended opcode %d: "), op_code); |
| 447 | |
| 448 | switch (op_code) |
| 449 | { |
| 450 | case DW_LNE_end_sequence: |
| 451 | printf (_("End of Sequence\n\n")); |
| 452 | reset_state_machine (is_stmt); |
| 453 | break; |
| 454 | |
| 455 | case DW_LNE_set_address: |
| 456 | /* PR 17512: file: 002-100480-0.004. */ |
| 457 | if (len - bytes_read - 1 > 8) |
| 458 | { |
| 459 | warn (_("Length (%d) of DW_LNE_set_address op is too long\n"), |
| 460 | len - bytes_read - 1); |
| 461 | adr = 0; |
| 462 | } |
| 463 | else |
| 464 | SAFE_BYTE_GET (adr, data, len - bytes_read - 1, end); |
| 465 | printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); |
| 466 | state_machine_regs.address = adr; |
| 467 | state_machine_regs.op_index = 0; |
| 468 | break; |
| 469 | |
| 470 | case DW_LNE_define_file: |
| 471 | printf (_("define new File Table entry\n")); |
| 472 | printf (_(" Entry\tDir\tTime\tSize\tName\n")); |
| 473 | printf (" %d\t", ++state_machine_regs.last_file_entry); |
| 474 | |
| 475 | name = data; |
| 476 | data += strnlen ((char *) data, end - data) + 1; |
| 477 | printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
| 478 | data += bytes_read; |
| 479 | printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
| 480 | data += bytes_read; |
| 481 | printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
| 482 | data += bytes_read; |
| 483 | printf ("%s\n\n", name); |
| 484 | |
| 485 | if (((unsigned int) (data - orig_data) != len) || data == end) |
| 486 | warn (_("DW_LNE_define_file: Bad opcode length\n")); |
| 487 | break; |
| 488 | |
| 489 | case DW_LNE_set_discriminator: |
| 490 | printf (_("set Discriminator to %s\n"), |
| 491 | dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
| 492 | break; |
| 493 | |
| 494 | /* HP extensions. */ |
| 495 | case DW_LNE_HP_negate_is_UV_update: |
| 496 | printf ("DW_LNE_HP_negate_is_UV_update\n"); |
| 497 | break; |
| 498 | case DW_LNE_HP_push_context: |
| 499 | printf ("DW_LNE_HP_push_context\n"); |
| 500 | break; |
| 501 | case DW_LNE_HP_pop_context: |
| 502 | printf ("DW_LNE_HP_pop_context\n"); |
| 503 | break; |
| 504 | case DW_LNE_HP_set_file_line_column: |
| 505 | printf ("DW_LNE_HP_set_file_line_column\n"); |
| 506 | break; |
| 507 | case DW_LNE_HP_set_routine_name: |
| 508 | printf ("DW_LNE_HP_set_routine_name\n"); |
| 509 | break; |
| 510 | case DW_LNE_HP_set_sequence: |
| 511 | printf ("DW_LNE_HP_set_sequence\n"); |
| 512 | break; |
| 513 | case DW_LNE_HP_negate_post_semantics: |
| 514 | printf ("DW_LNE_HP_negate_post_semantics\n"); |
| 515 | break; |
| 516 | case DW_LNE_HP_negate_function_exit: |
| 517 | printf ("DW_LNE_HP_negate_function_exit\n"); |
| 518 | break; |
| 519 | case DW_LNE_HP_negate_front_end_logical: |
| 520 | printf ("DW_LNE_HP_negate_front_end_logical\n"); |
| 521 | break; |
| 522 | case DW_LNE_HP_define_proc: |
| 523 | printf ("DW_LNE_HP_define_proc\n"); |
| 524 | break; |
| 525 | case DW_LNE_HP_source_file_correlation: |
| 526 | { |
| 527 | unsigned char *edata = data + len - bytes_read - 1; |
| 528 | |
| 529 | printf ("DW_LNE_HP_source_file_correlation\n"); |
| 530 | |
| 531 | while (data < edata) |
| 532 | { |
| 533 | unsigned int opc; |
| 534 | |
| 535 | opc = read_uleb128 (data, & bytes_read, edata); |
| 536 | data += bytes_read; |
| 537 | |
| 538 | switch (opc) |
| 539 | { |
| 540 | case DW_LNE_HP_SFC_formfeed: |
| 541 | printf (" DW_LNE_HP_SFC_formfeed\n"); |
| 542 | break; |
| 543 | case DW_LNE_HP_SFC_set_listing_line: |
| 544 | printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n", |
| 545 | dwarf_vmatoa ("u", |
| 546 | read_uleb128 (data, & bytes_read, edata))); |
| 547 | data += bytes_read; |
| 548 | break; |
| 549 | case DW_LNE_HP_SFC_associate: |
| 550 | printf (" DW_LNE_HP_SFC_associate "); |
| 551 | printf ("(%s", |
| 552 | dwarf_vmatoa ("u", |
| 553 | read_uleb128 (data, & bytes_read, edata))); |
| 554 | data += bytes_read; |
| 555 | printf (",%s", |
| 556 | dwarf_vmatoa ("u", |
| 557 | read_uleb128 (data, & bytes_read, edata))); |
| 558 | data += bytes_read; |
| 559 | printf (",%s)\n", |
| 560 | dwarf_vmatoa ("u", |
| 561 | read_uleb128 (data, & bytes_read, edata))); |
| 562 | data += bytes_read; |
| 563 | break; |
| 564 | default: |
| 565 | printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc); |
| 566 | data = edata; |
| 567 | break; |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | break; |
| 572 | |
| 573 | default: |
| 574 | { |
| 575 | unsigned int rlen = len - bytes_read - 1; |
| 576 | |
| 577 | if (op_code >= DW_LNE_lo_user |
| 578 | /* The test against DW_LNW_hi_user is redundant due to |
| 579 | the limited range of the unsigned char data type used |
| 580 | for op_code. */ |
| 581 | /*&& op_code <= DW_LNE_hi_user*/) |
| 582 | printf (_("user defined: ")); |
| 583 | else |
| 584 | printf (_("UNKNOWN: ")); |
| 585 | printf (_("length %d ["), rlen); |
| 586 | for (; rlen; rlen--) |
| 587 | printf (" %02x", *data++); |
| 588 | printf ("]\n"); |
| 589 | } |
| 590 | break; |
| 591 | } |
| 592 | |
| 593 | return len; |
| 594 | } |
| 595 | |
| 596 | static const unsigned char * |
| 597 | fetch_indirect_string (dwarf_vma offset) |
| 598 | { |
| 599 | struct dwarf_section *section = &debug_displays [str].section; |
| 600 | |
| 601 | if (section->start == NULL) |
| 602 | return (const unsigned char *) _("<no .debug_str section>"); |
| 603 | |
| 604 | if (offset > section->size) |
| 605 | { |
| 606 | warn (_("DW_FORM_strp offset too big: %s\n"), |
| 607 | dwarf_vmatoa ("x", offset)); |
| 608 | return (const unsigned char *) _("<offset is too big>"); |
| 609 | } |
| 610 | |
| 611 | return (const unsigned char *) section->start + offset; |
| 612 | } |
| 613 | |
| 614 | static const unsigned char * |
| 615 | fetch_indirect_line_string (dwarf_vma offset) |
| 616 | { |
| 617 | struct dwarf_section *section = &debug_displays [line_str].section; |
| 618 | |
| 619 | if (section->start == NULL) |
| 620 | return (const unsigned char *) _("<no .debug_line_str section>"); |
| 621 | |
| 622 | if (offset > section->size) |
| 623 | { |
| 624 | warn (_("DW_FORM_line_strp offset too big: %s\n"), |
| 625 | dwarf_vmatoa ("x", offset)); |
| 626 | return (const unsigned char *) _("<offset is too big>"); |
| 627 | } |
| 628 | |
| 629 | return (const unsigned char *) section->start + offset; |
| 630 | } |
| 631 | |
| 632 | static const char * |
| 633 | fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set, |
| 634 | dwarf_vma offset_size, int dwo) |
| 635 | { |
| 636 | enum dwarf_section_display_enum str_sec_idx = dwo ? str_dwo : str; |
| 637 | enum dwarf_section_display_enum idx_sec_idx = dwo ? str_index_dwo : str_index; |
| 638 | struct dwarf_section *index_section = &debug_displays [idx_sec_idx].section; |
| 639 | struct dwarf_section *str_section = &debug_displays [str_sec_idx].section; |
| 640 | dwarf_vma index_offset = idx * offset_size; |
| 641 | dwarf_vma str_offset; |
| 642 | |
| 643 | if (index_section->start == NULL) |
| 644 | return (dwo ? _("<no .debug_str_offsets.dwo section>") |
| 645 | : _("<no .debug_str_offsets section>")); |
| 646 | |
| 647 | if (this_set != NULL) |
| 648 | index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS]; |
| 649 | if (index_offset > index_section->size) |
| 650 | { |
| 651 | warn (_("DW_FORM_GNU_str_index offset too big: %s\n"), |
| 652 | dwarf_vmatoa ("x", index_offset)); |
| 653 | return _("<index offset is too big>"); |
| 654 | } |
| 655 | |
| 656 | if (str_section->start == NULL) |
| 657 | return (dwo ? _("<no .debug_str.dwo section>") |
| 658 | : _("<no .debug_str section>")); |
| 659 | |
| 660 | str_offset = byte_get (index_section->start + index_offset, offset_size); |
| 661 | str_offset -= str_section->address; |
| 662 | if (str_offset > str_section->size) |
| 663 | { |
| 664 | warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"), |
| 665 | dwarf_vmatoa ("x", str_offset)); |
| 666 | return _("<indirect index offset is too big>"); |
| 667 | } |
| 668 | |
| 669 | return (const char *) str_section->start + str_offset; |
| 670 | } |
| 671 | |
| 672 | static const char * |
| 673 | fetch_indexed_value (dwarf_vma offset, dwarf_vma bytes) |
| 674 | { |
| 675 | struct dwarf_section *section = &debug_displays [debug_addr].section; |
| 676 | |
| 677 | if (section->start == NULL) |
| 678 | return (_("<no .debug_addr section>")); |
| 679 | |
| 680 | if (offset + bytes > section->size) |
| 681 | { |
| 682 | warn (_("Offset into section %s too big: %s\n"), |
| 683 | section->name, dwarf_vmatoa ("x", offset)); |
| 684 | return "<offset too big>"; |
| 685 | } |
| 686 | |
| 687 | return dwarf_vmatoa ("x", byte_get (section->start + offset, bytes)); |
| 688 | } |
| 689 | |
| 690 | |
| 691 | /* FIXME: There are better and more efficient ways to handle |
| 692 | these structures. For now though, I just want something that |
| 693 | is simple to implement. */ |
| 694 | typedef struct abbrev_attr |
| 695 | { |
| 696 | unsigned long attribute; |
| 697 | unsigned long form; |
| 698 | bfd_signed_vma implicit_const; |
| 699 | struct abbrev_attr *next; |
| 700 | } |
| 701 | abbrev_attr; |
| 702 | |
| 703 | typedef struct abbrev_entry |
| 704 | { |
| 705 | unsigned long entry; |
| 706 | unsigned long tag; |
| 707 | int children; |
| 708 | struct abbrev_attr *first_attr; |
| 709 | struct abbrev_attr *last_attr; |
| 710 | struct abbrev_entry *next; |
| 711 | } |
| 712 | abbrev_entry; |
| 713 | |
| 714 | static abbrev_entry *first_abbrev = NULL; |
| 715 | static abbrev_entry *last_abbrev = NULL; |
| 716 | |
| 717 | static void |
| 718 | free_abbrevs (void) |
| 719 | { |
| 720 | abbrev_entry *abbrv; |
| 721 | |
| 722 | for (abbrv = first_abbrev; abbrv;) |
| 723 | { |
| 724 | abbrev_entry *next_abbrev = abbrv->next; |
| 725 | abbrev_attr *attr; |
| 726 | |
| 727 | for (attr = abbrv->first_attr; attr;) |
| 728 | { |
| 729 | abbrev_attr *next_attr = attr->next; |
| 730 | |
| 731 | free (attr); |
| 732 | attr = next_attr; |
| 733 | } |
| 734 | |
| 735 | free (abbrv); |
| 736 | abbrv = next_abbrev; |
| 737 | } |
| 738 | |
| 739 | last_abbrev = first_abbrev = NULL; |
| 740 | } |
| 741 | |
| 742 | static void |
| 743 | add_abbrev (unsigned long number, unsigned long tag, int children) |
| 744 | { |
| 745 | abbrev_entry *entry; |
| 746 | |
| 747 | entry = (abbrev_entry *) malloc (sizeof (*entry)); |
| 748 | if (entry == NULL) |
| 749 | /* ugg */ |
| 750 | return; |
| 751 | |
| 752 | entry->entry = number; |
| 753 | entry->tag = tag; |
| 754 | entry->children = children; |
| 755 | entry->first_attr = NULL; |
| 756 | entry->last_attr = NULL; |
| 757 | entry->next = NULL; |
| 758 | |
| 759 | if (first_abbrev == NULL) |
| 760 | first_abbrev = entry; |
| 761 | else |
| 762 | last_abbrev->next = entry; |
| 763 | |
| 764 | last_abbrev = entry; |
| 765 | } |
| 766 | |
| 767 | static void |
| 768 | add_abbrev_attr (unsigned long attribute, unsigned long form, |
| 769 | bfd_signed_vma implicit_const) |
| 770 | { |
| 771 | abbrev_attr *attr; |
| 772 | |
| 773 | attr = (abbrev_attr *) malloc (sizeof (*attr)); |
| 774 | if (attr == NULL) |
| 775 | /* ugg */ |
| 776 | return; |
| 777 | |
| 778 | attr->attribute = attribute; |
| 779 | attr->form = form; |
| 780 | attr->implicit_const = implicit_const; |
| 781 | attr->next = NULL; |
| 782 | |
| 783 | if (last_abbrev->first_attr == NULL) |
| 784 | last_abbrev->first_attr = attr; |
| 785 | else |
| 786 | last_abbrev->last_attr->next = attr; |
| 787 | |
| 788 | last_abbrev->last_attr = attr; |
| 789 | } |
| 790 | |
| 791 | /* Processes the (partial) contents of a .debug_abbrev section. |
| 792 | Returns NULL if the end of the section was encountered. |
| 793 | Returns the address after the last byte read if the end of |
| 794 | an abbreviation set was found. */ |
| 795 | |
| 796 | static unsigned char * |
| 797 | process_abbrev_section (unsigned char *start, unsigned char *end) |
| 798 | { |
| 799 | if (first_abbrev != NULL) |
| 800 | return NULL; |
| 801 | |
| 802 | while (start < end) |
| 803 | { |
| 804 | unsigned int bytes_read; |
| 805 | unsigned long entry; |
| 806 | unsigned long tag; |
| 807 | unsigned long attribute; |
| 808 | int children; |
| 809 | |
| 810 | entry = read_uleb128 (start, & bytes_read, end); |
| 811 | start += bytes_read; |
| 812 | |
| 813 | /* A single zero is supposed to end the section according |
| 814 | to the standard. If there's more, then signal that to |
| 815 | the caller. */ |
| 816 | if (start == end) |
| 817 | return NULL; |
| 818 | if (entry == 0) |
| 819 | return start; |
| 820 | |
| 821 | tag = read_uleb128 (start, & bytes_read, end); |
| 822 | start += bytes_read; |
| 823 | if (start == end) |
| 824 | return NULL; |
| 825 | |
| 826 | children = *start++; |
| 827 | |
| 828 | add_abbrev (entry, tag, children); |
| 829 | |
| 830 | do |
| 831 | { |
| 832 | unsigned long form; |
| 833 | /* Initialize it due to a false compiler warning. */ |
| 834 | bfd_signed_vma implicit_const = -1; |
| 835 | |
| 836 | attribute = read_uleb128 (start, & bytes_read, end); |
| 837 | start += bytes_read; |
| 838 | if (start == end) |
| 839 | break; |
| 840 | |
| 841 | form = read_uleb128 (start, & bytes_read, end); |
| 842 | start += bytes_read; |
| 843 | if (start == end) |
| 844 | break; |
| 845 | |
| 846 | if (form == DW_FORM_implicit_const) |
| 847 | { |
| 848 | implicit_const = read_sleb128 (start, & bytes_read, end); |
| 849 | start += bytes_read; |
| 850 | if (start == end) |
| 851 | break; |
| 852 | } |
| 853 | |
| 854 | add_abbrev_attr (attribute, form, implicit_const); |
| 855 | } |
| 856 | while (attribute != 0); |
| 857 | } |
| 858 | |
| 859 | /* Report the missing single zero which ends the section. */ |
| 860 | error (_(".debug_abbrev section not zero terminated\n")); |
| 861 | |
| 862 | return NULL; |
| 863 | } |
| 864 | |
| 865 | static const char * |
| 866 | get_TAG_name (unsigned long tag) |
| 867 | { |
| 868 | const char *name = get_DW_TAG_name ((unsigned int)tag); |
| 869 | |
| 870 | if (name == NULL) |
| 871 | { |
| 872 | static char buffer[100]; |
| 873 | |
| 874 | snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %lx"), tag); |
| 875 | return buffer; |
| 876 | } |
| 877 | |
| 878 | return name; |
| 879 | } |
| 880 | |
| 881 | static const char * |
| 882 | get_FORM_name (unsigned long form) |
| 883 | { |
| 884 | const char *name; |
| 885 | |
| 886 | if (form == 0) |
| 887 | return "DW_FORM value: 0"; |
| 888 | |
| 889 | name = get_DW_FORM_name (form); |
| 890 | if (name == NULL) |
| 891 | { |
| 892 | static char buffer[100]; |
| 893 | |
| 894 | snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form); |
| 895 | return buffer; |
| 896 | } |
| 897 | |
| 898 | return name; |
| 899 | } |
| 900 | |
| 901 | static unsigned char * |
| 902 | display_block (unsigned char *data, |
| 903 | dwarf_vma length, |
| 904 | const unsigned char * const end, char delimiter) |
| 905 | { |
| 906 | dwarf_vma maxlen; |
| 907 | |
| 908 | printf (_("%c%s byte block: "), delimiter, dwarf_vmatoa ("u", length)); |
| 909 | if (data > end) |
| 910 | return (unsigned char *) end; |
| 911 | |
| 912 | maxlen = (dwarf_vma) (end - data); |
| 913 | length = length > maxlen ? maxlen : length; |
| 914 | |
| 915 | while (length --) |
| 916 | printf ("%lx ", (unsigned long) byte_get (data++, 1)); |
| 917 | |
| 918 | return data; |
| 919 | } |
| 920 | |
| 921 | static int |
| 922 | decode_location_expression (unsigned char * data, |
| 923 | unsigned int pointer_size, |
| 924 | unsigned int offset_size, |
| 925 | int dwarf_version, |
| 926 | dwarf_vma length, |
| 927 | dwarf_vma cu_offset, |
| 928 | struct dwarf_section * section) |
| 929 | { |
| 930 | unsigned op; |
| 931 | unsigned int bytes_read; |
| 932 | dwarf_vma uvalue; |
| 933 | dwarf_signed_vma svalue; |
| 934 | unsigned char *end = data + length; |
| 935 | int need_frame_base = 0; |
| 936 | |
| 937 | while (data < end) |
| 938 | { |
| 939 | op = *data++; |
| 940 | |
| 941 | switch (op) |
| 942 | { |
| 943 | case DW_OP_addr: |
| 944 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| 945 | printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue)); |
| 946 | break; |
| 947 | case DW_OP_deref: |
| 948 | printf ("DW_OP_deref"); |
| 949 | break; |
| 950 | case DW_OP_const1u: |
| 951 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| 952 | printf ("DW_OP_const1u: %lu", (unsigned long) uvalue); |
| 953 | break; |
| 954 | case DW_OP_const1s: |
| 955 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 1, end); |
| 956 | printf ("DW_OP_const1s: %ld", (long) svalue); |
| 957 | break; |
| 958 | case DW_OP_const2u: |
| 959 | SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
| 960 | printf ("DW_OP_const2u: %lu", (unsigned long) uvalue); |
| 961 | break; |
| 962 | case DW_OP_const2s: |
| 963 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
| 964 | printf ("DW_OP_const2s: %ld", (long) svalue); |
| 965 | break; |
| 966 | case DW_OP_const4u: |
| 967 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| 968 | printf ("DW_OP_const4u: %lu", (unsigned long) uvalue); |
| 969 | break; |
| 970 | case DW_OP_const4s: |
| 971 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
| 972 | printf ("DW_OP_const4s: %ld", (long) svalue); |
| 973 | break; |
| 974 | case DW_OP_const8u: |
| 975 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| 976 | printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue); |
| 977 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| 978 | printf ("%lu", (unsigned long) uvalue); |
| 979 | break; |
| 980 | case DW_OP_const8s: |
| 981 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
| 982 | printf ("DW_OP_const8s: %ld ", (long) svalue); |
| 983 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
| 984 | printf ("%ld", (long) svalue); |
| 985 | break; |
| 986 | case DW_OP_constu: |
| 987 | printf ("DW_OP_constu: %s", |
| 988 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
| 989 | data += bytes_read; |
| 990 | break; |
| 991 | case DW_OP_consts: |
| 992 | printf ("DW_OP_consts: %s", |
| 993 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); |
| 994 | data += bytes_read; |
| 995 | break; |
| 996 | case DW_OP_dup: |
| 997 | printf ("DW_OP_dup"); |
| 998 | break; |
| 999 | case DW_OP_drop: |
| 1000 | printf ("DW_OP_drop"); |
| 1001 | break; |
| 1002 | case DW_OP_over: |
| 1003 | printf ("DW_OP_over"); |
| 1004 | break; |
| 1005 | case DW_OP_pick: |
| 1006 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| 1007 | printf ("DW_OP_pick: %ld", (unsigned long) uvalue); |
| 1008 | break; |
| 1009 | case DW_OP_swap: |
| 1010 | printf ("DW_OP_swap"); |
| 1011 | break; |
| 1012 | case DW_OP_rot: |
| 1013 | printf ("DW_OP_rot"); |
| 1014 | break; |
| 1015 | case DW_OP_xderef: |
| 1016 | printf ("DW_OP_xderef"); |
| 1017 | break; |
| 1018 | case DW_OP_abs: |
| 1019 | printf ("DW_OP_abs"); |
| 1020 | break; |
| 1021 | case DW_OP_and: |
| 1022 | printf ("DW_OP_and"); |
| 1023 | break; |
| 1024 | case DW_OP_div: |
| 1025 | printf ("DW_OP_div"); |
| 1026 | break; |
| 1027 | case DW_OP_minus: |
| 1028 | printf ("DW_OP_minus"); |
| 1029 | break; |
| 1030 | case DW_OP_mod: |
| 1031 | printf ("DW_OP_mod"); |
| 1032 | break; |
| 1033 | case DW_OP_mul: |
| 1034 | printf ("DW_OP_mul"); |
| 1035 | break; |
| 1036 | case DW_OP_neg: |
| 1037 | printf ("DW_OP_neg"); |
| 1038 | break; |
| 1039 | case DW_OP_not: |
| 1040 | printf ("DW_OP_not"); |
| 1041 | break; |
| 1042 | case DW_OP_or: |
| 1043 | printf ("DW_OP_or"); |
| 1044 | break; |
| 1045 | case DW_OP_plus: |
| 1046 | printf ("DW_OP_plus"); |
| 1047 | break; |
| 1048 | case DW_OP_plus_uconst: |
| 1049 | printf ("DW_OP_plus_uconst: %s", |
| 1050 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
| 1051 | data += bytes_read; |
| 1052 | break; |
| 1053 | case DW_OP_shl: |
| 1054 | printf ("DW_OP_shl"); |
| 1055 | break; |
| 1056 | case DW_OP_shr: |
| 1057 | printf ("DW_OP_shr"); |
| 1058 | break; |
| 1059 | case DW_OP_shra: |
| 1060 | printf ("DW_OP_shra"); |
| 1061 | break; |
| 1062 | case DW_OP_xor: |
| 1063 | printf ("DW_OP_xor"); |
| 1064 | break; |
| 1065 | case DW_OP_bra: |
| 1066 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
| 1067 | printf ("DW_OP_bra: %ld", (long) svalue); |
| 1068 | break; |
| 1069 | case DW_OP_eq: |
| 1070 | printf ("DW_OP_eq"); |
| 1071 | break; |
| 1072 | case DW_OP_ge: |
| 1073 | printf ("DW_OP_ge"); |
| 1074 | break; |
| 1075 | case DW_OP_gt: |
| 1076 | printf ("DW_OP_gt"); |
| 1077 | break; |
| 1078 | case DW_OP_le: |
| 1079 | printf ("DW_OP_le"); |
| 1080 | break; |
| 1081 | case DW_OP_lt: |
| 1082 | printf ("DW_OP_lt"); |
| 1083 | break; |
| 1084 | case DW_OP_ne: |
| 1085 | printf ("DW_OP_ne"); |
| 1086 | break; |
| 1087 | case DW_OP_skip: |
| 1088 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
| 1089 | printf ("DW_OP_skip: %ld", (long) svalue); |
| 1090 | break; |
| 1091 | |
| 1092 | case DW_OP_lit0: |
| 1093 | case DW_OP_lit1: |
| 1094 | case DW_OP_lit2: |
| 1095 | case DW_OP_lit3: |
| 1096 | case DW_OP_lit4: |
| 1097 | case DW_OP_lit5: |
| 1098 | case DW_OP_lit6: |
| 1099 | case DW_OP_lit7: |
| 1100 | case DW_OP_lit8: |
| 1101 | case DW_OP_lit9: |
| 1102 | case DW_OP_lit10: |
| 1103 | case DW_OP_lit11: |
| 1104 | case DW_OP_lit12: |
| 1105 | case DW_OP_lit13: |
| 1106 | case DW_OP_lit14: |
| 1107 | case DW_OP_lit15: |
| 1108 | case DW_OP_lit16: |
| 1109 | case DW_OP_lit17: |
| 1110 | case DW_OP_lit18: |
| 1111 | case DW_OP_lit19: |
| 1112 | case DW_OP_lit20: |
| 1113 | case DW_OP_lit21: |
| 1114 | case DW_OP_lit22: |
| 1115 | case DW_OP_lit23: |
| 1116 | case DW_OP_lit24: |
| 1117 | case DW_OP_lit25: |
| 1118 | case DW_OP_lit26: |
| 1119 | case DW_OP_lit27: |
| 1120 | case DW_OP_lit28: |
| 1121 | case DW_OP_lit29: |
| 1122 | case DW_OP_lit30: |
| 1123 | case DW_OP_lit31: |
| 1124 | printf ("DW_OP_lit%d", op - DW_OP_lit0); |
| 1125 | break; |
| 1126 | |
| 1127 | case DW_OP_reg0: |
| 1128 | case DW_OP_reg1: |
| 1129 | case DW_OP_reg2: |
| 1130 | case DW_OP_reg3: |
| 1131 | case DW_OP_reg4: |
| 1132 | case DW_OP_reg5: |
| 1133 | case DW_OP_reg6: |
| 1134 | case DW_OP_reg7: |
| 1135 | case DW_OP_reg8: |
| 1136 | case DW_OP_reg9: |
| 1137 | case DW_OP_reg10: |
| 1138 | case DW_OP_reg11: |
| 1139 | case DW_OP_reg12: |
| 1140 | case DW_OP_reg13: |
| 1141 | case DW_OP_reg14: |
| 1142 | case DW_OP_reg15: |
| 1143 | case DW_OP_reg16: |
| 1144 | case DW_OP_reg17: |
| 1145 | case DW_OP_reg18: |
| 1146 | case DW_OP_reg19: |
| 1147 | case DW_OP_reg20: |
| 1148 | case DW_OP_reg21: |
| 1149 | case DW_OP_reg22: |
| 1150 | case DW_OP_reg23: |
| 1151 | case DW_OP_reg24: |
| 1152 | case DW_OP_reg25: |
| 1153 | case DW_OP_reg26: |
| 1154 | case DW_OP_reg27: |
| 1155 | case DW_OP_reg28: |
| 1156 | case DW_OP_reg29: |
| 1157 | case DW_OP_reg30: |
| 1158 | case DW_OP_reg31: |
| 1159 | printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0, |
| 1160 | regname (op - DW_OP_reg0, 1)); |
| 1161 | break; |
| 1162 | |
| 1163 | case DW_OP_breg0: |
| 1164 | case DW_OP_breg1: |
| 1165 | case DW_OP_breg2: |
| 1166 | case DW_OP_breg3: |
| 1167 | case DW_OP_breg4: |
| 1168 | case DW_OP_breg5: |
| 1169 | case DW_OP_breg6: |
| 1170 | case DW_OP_breg7: |
| 1171 | case DW_OP_breg8: |
| 1172 | case DW_OP_breg9: |
| 1173 | case DW_OP_breg10: |
| 1174 | case DW_OP_breg11: |
| 1175 | case DW_OP_breg12: |
| 1176 | case DW_OP_breg13: |
| 1177 | case DW_OP_breg14: |
| 1178 | case DW_OP_breg15: |
| 1179 | case DW_OP_breg16: |
| 1180 | case DW_OP_breg17: |
| 1181 | case DW_OP_breg18: |
| 1182 | case DW_OP_breg19: |
| 1183 | case DW_OP_breg20: |
| 1184 | case DW_OP_breg21: |
| 1185 | case DW_OP_breg22: |
| 1186 | case DW_OP_breg23: |
| 1187 | case DW_OP_breg24: |
| 1188 | case DW_OP_breg25: |
| 1189 | case DW_OP_breg26: |
| 1190 | case DW_OP_breg27: |
| 1191 | case DW_OP_breg28: |
| 1192 | case DW_OP_breg29: |
| 1193 | case DW_OP_breg30: |
| 1194 | case DW_OP_breg31: |
| 1195 | printf ("DW_OP_breg%d (%s): %s", |
| 1196 | op - DW_OP_breg0, |
| 1197 | regname (op - DW_OP_breg0, 1), |
| 1198 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); |
| 1199 | data += bytes_read; |
| 1200 | break; |
| 1201 | |
| 1202 | case DW_OP_regx: |
| 1203 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1204 | data += bytes_read; |
| 1205 | printf ("DW_OP_regx: %s (%s)", |
| 1206 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); |
| 1207 | break; |
| 1208 | case DW_OP_fbreg: |
| 1209 | need_frame_base = 1; |
| 1210 | printf ("DW_OP_fbreg: %s", |
| 1211 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); |
| 1212 | data += bytes_read; |
| 1213 | break; |
| 1214 | case DW_OP_bregx: |
| 1215 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1216 | data += bytes_read; |
| 1217 | printf ("DW_OP_bregx: %s (%s) %s", |
| 1218 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1), |
| 1219 | dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); |
| 1220 | data += bytes_read; |
| 1221 | break; |
| 1222 | case DW_OP_piece: |
| 1223 | printf ("DW_OP_piece: %s", |
| 1224 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
| 1225 | data += bytes_read; |
| 1226 | break; |
| 1227 | case DW_OP_deref_size: |
| 1228 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| 1229 | printf ("DW_OP_deref_size: %ld", (long) uvalue); |
| 1230 | break; |
| 1231 | case DW_OP_xderef_size: |
| 1232 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| 1233 | printf ("DW_OP_xderef_size: %ld", (long) uvalue); |
| 1234 | break; |
| 1235 | case DW_OP_nop: |
| 1236 | printf ("DW_OP_nop"); |
| 1237 | break; |
| 1238 | |
| 1239 | /* DWARF 3 extensions. */ |
| 1240 | case DW_OP_push_object_address: |
| 1241 | printf ("DW_OP_push_object_address"); |
| 1242 | break; |
| 1243 | case DW_OP_call2: |
| 1244 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
| 1245 | this ought to be an 8-byte wide computation. */ |
| 1246 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); |
| 1247 | printf ("DW_OP_call2: <0x%s>", |
| 1248 | dwarf_vmatoa ("x", svalue + cu_offset)); |
| 1249 | break; |
| 1250 | case DW_OP_call4: |
| 1251 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
| 1252 | this ought to be an 8-byte wide computation. */ |
| 1253 | SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); |
| 1254 | printf ("DW_OP_call4: <0x%s>", |
| 1255 | dwarf_vmatoa ("x", svalue + cu_offset)); |
| 1256 | break; |
| 1257 | case DW_OP_call_ref: |
| 1258 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
| 1259 | this ought to be an 8-byte wide computation. */ |
| 1260 | if (dwarf_version == -1) |
| 1261 | { |
| 1262 | printf (_("(DW_OP_call_ref in frame info)")); |
| 1263 | /* No way to tell where the next op is, so just bail. */ |
| 1264 | return need_frame_base; |
| 1265 | } |
| 1266 | if (dwarf_version == 2) |
| 1267 | { |
| 1268 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| 1269 | } |
| 1270 | else |
| 1271 | { |
| 1272 | SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| 1273 | } |
| 1274 | printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue)); |
| 1275 | break; |
| 1276 | case DW_OP_form_tls_address: |
| 1277 | printf ("DW_OP_form_tls_address"); |
| 1278 | break; |
| 1279 | case DW_OP_call_frame_cfa: |
| 1280 | printf ("DW_OP_call_frame_cfa"); |
| 1281 | break; |
| 1282 | case DW_OP_bit_piece: |
| 1283 | printf ("DW_OP_bit_piece: "); |
| 1284 | printf (_("size: %s "), |
| 1285 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
| 1286 | data += bytes_read; |
| 1287 | printf (_("offset: %s "), |
| 1288 | dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); |
| 1289 | data += bytes_read; |
| 1290 | break; |
| 1291 | |
| 1292 | /* DWARF 4 extensions. */ |
| 1293 | case DW_OP_stack_value: |
| 1294 | printf ("DW_OP_stack_value"); |
| 1295 | break; |
| 1296 | |
| 1297 | case DW_OP_implicit_value: |
| 1298 | printf ("DW_OP_implicit_value"); |
| 1299 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1300 | data += bytes_read; |
| 1301 | data = display_block (data, uvalue, end, ' '); |
| 1302 | break; |
| 1303 | |
| 1304 | /* GNU extensions. */ |
| 1305 | case DW_OP_GNU_push_tls_address: |
| 1306 | printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown")); |
| 1307 | break; |
| 1308 | case DW_OP_GNU_uninit: |
| 1309 | printf ("DW_OP_GNU_uninit"); |
| 1310 | /* FIXME: Is there data associated with this OP ? */ |
| 1311 | break; |
| 1312 | case DW_OP_GNU_encoded_addr: |
| 1313 | { |
| 1314 | int encoding = 0; |
| 1315 | dwarf_vma addr; |
| 1316 | |
| 1317 | if (data < end) |
| 1318 | encoding = *data++; |
| 1319 | addr = get_encoded_value (&data, encoding, section, end); |
| 1320 | |
| 1321 | printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding); |
| 1322 | print_dwarf_vma (addr, pointer_size); |
| 1323 | } |
| 1324 | break; |
| 1325 | case DW_OP_implicit_pointer: |
| 1326 | case DW_OP_GNU_implicit_pointer: |
| 1327 | /* XXX: Strictly speaking for 64-bit DWARF3 files |
| 1328 | this ought to be an 8-byte wide computation. */ |
| 1329 | if (dwarf_version == -1) |
| 1330 | { |
| 1331 | printf (_("(%s in frame info)"), |
| 1332 | (op == DW_OP_implicit_pointer |
| 1333 | ? "DW_OP_implicit_pointer" |
| 1334 | : "DW_OP_GNU_implicit_pointer")); |
| 1335 | /* No way to tell where the next op is, so just bail. */ |
| 1336 | return need_frame_base; |
| 1337 | } |
| 1338 | if (dwarf_version == 2) |
| 1339 | { |
| 1340 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| 1341 | } |
| 1342 | else |
| 1343 | { |
| 1344 | SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| 1345 | } |
| 1346 | printf ("%s: <0x%s> %s", |
| 1347 | (op == DW_OP_implicit_pointer |
| 1348 | ? "DW_OP_implicit_pointer" : "DW_OP_GNU_implicit_pointer"), |
| 1349 | dwarf_vmatoa ("x", uvalue), |
| 1350 | dwarf_vmatoa ("d", read_sleb128 (data, |
| 1351 | &bytes_read, end))); |
| 1352 | data += bytes_read; |
| 1353 | break; |
| 1354 | case DW_OP_entry_value: |
| 1355 | case DW_OP_GNU_entry_value: |
| 1356 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1357 | data += bytes_read; |
| 1358 | /* PR 17531: file: 0cc9cd00. */ |
| 1359 | if (uvalue > (dwarf_vma) (end - data)) |
| 1360 | uvalue = end - data; |
| 1361 | printf ("%s: (", (op == DW_OP_entry_value ? "DW_OP_entry_value" |
| 1362 | : "DW_OP_GNU_entry_value")); |
| 1363 | if (decode_location_expression (data, pointer_size, offset_size, |
| 1364 | dwarf_version, uvalue, |
| 1365 | cu_offset, section)) |
| 1366 | need_frame_base = 1; |
| 1367 | putchar (')'); |
| 1368 | data += uvalue; |
| 1369 | if (data > end) |
| 1370 | data = end; |
| 1371 | break; |
| 1372 | case DW_OP_const_type: |
| 1373 | case DW_OP_GNU_const_type: |
| 1374 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1375 | data += bytes_read; |
| 1376 | printf ("%s: <0x%s> ", |
| 1377 | (op == DW_OP_const_type ? "DW_OP_const_type" |
| 1378 | : "DW_OP_GNU_const_type"), |
| 1379 | dwarf_vmatoa ("x", cu_offset + uvalue)); |
| 1380 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| 1381 | data = display_block (data, uvalue, end, ' '); |
| 1382 | break; |
| 1383 | case DW_OP_regval_type: |
| 1384 | case DW_OP_GNU_regval_type: |
| 1385 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1386 | data += bytes_read; |
| 1387 | printf ("%s: %s (%s)", |
| 1388 | (op == DW_OP_regval_type ? "DW_OP_regval_type" |
| 1389 | : "DW_OP_GNU_regval_type"), |
| 1390 | dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); |
| 1391 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1392 | data += bytes_read; |
| 1393 | printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); |
| 1394 | break; |
| 1395 | case DW_OP_deref_type: |
| 1396 | case DW_OP_GNU_deref_type: |
| 1397 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| 1398 | printf ("%s: %ld", |
| 1399 | (op == DW_OP_deref_type ? "DW_OP_deref_type" |
| 1400 | : "DW_OP_GNU_deref_type"), |
| 1401 | (long) uvalue); |
| 1402 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1403 | data += bytes_read; |
| 1404 | printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); |
| 1405 | break; |
| 1406 | case DW_OP_convert: |
| 1407 | case DW_OP_GNU_convert: |
| 1408 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1409 | data += bytes_read; |
| 1410 | printf ("%s <0x%s>", |
| 1411 | (op == DW_OP_convert ? "DW_OP_convert" : "DW_OP_GNU_convert"), |
| 1412 | dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
| 1413 | break; |
| 1414 | case DW_OP_reinterpret: |
| 1415 | case DW_OP_GNU_reinterpret: |
| 1416 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1417 | data += bytes_read; |
| 1418 | printf ("%s <0x%s>", |
| 1419 | (op == DW_OP_reinterpret ? "DW_OP_reinterpret" |
| 1420 | : "DW_OP_GNU_reinterpret"), |
| 1421 | dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); |
| 1422 | break; |
| 1423 | case DW_OP_GNU_parameter_ref: |
| 1424 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| 1425 | printf ("DW_OP_GNU_parameter_ref: <0x%s>", |
| 1426 | dwarf_vmatoa ("x", cu_offset + uvalue)); |
| 1427 | break; |
| 1428 | case DW_OP_GNU_addr_index: |
| 1429 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1430 | data += bytes_read; |
| 1431 | printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue)); |
| 1432 | break; |
| 1433 | case DW_OP_GNU_const_index: |
| 1434 | uvalue = read_uleb128 (data, &bytes_read, end); |
| 1435 | data += bytes_read; |
| 1436 | printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue)); |
| 1437 | break; |
| 1438 | |
| 1439 | /* HP extensions. */ |
| 1440 | case DW_OP_HP_is_value: |
| 1441 | printf ("DW_OP_HP_is_value"); |
| 1442 | /* FIXME: Is there data associated with this OP ? */ |
| 1443 | break; |
| 1444 | case DW_OP_HP_fltconst4: |
| 1445 | printf ("DW_OP_HP_fltconst4"); |
| 1446 | /* FIXME: Is there data associated with this OP ? */ |
| 1447 | break; |
| 1448 | case DW_OP_HP_fltconst8: |
| 1449 | printf ("DW_OP_HP_fltconst8"); |
| 1450 | /* FIXME: Is there data associated with this OP ? */ |
| 1451 | break; |
| 1452 | case DW_OP_HP_mod_range: |
| 1453 | printf ("DW_OP_HP_mod_range"); |
| 1454 | /* FIXME: Is there data associated with this OP ? */ |
| 1455 | break; |
| 1456 | case DW_OP_HP_unmod_range: |
| 1457 | printf ("DW_OP_HP_unmod_range"); |
| 1458 | /* FIXME: Is there data associated with this OP ? */ |
| 1459 | break; |
| 1460 | case DW_OP_HP_tls: |
| 1461 | printf ("DW_OP_HP_tls"); |
| 1462 | /* FIXME: Is there data associated with this OP ? */ |
| 1463 | break; |
| 1464 | |
| 1465 | /* PGI (STMicroelectronics) extensions. */ |
| 1466 | case DW_OP_PGI_omp_thread_num: |
| 1467 | /* Pushes the thread number for the current thread as it would be |
| 1468 | returned by the standard OpenMP library function: |
| 1469 | omp_get_thread_num(). The "current thread" is the thread for |
| 1470 | which the expression is being evaluated. */ |
| 1471 | printf ("DW_OP_PGI_omp_thread_num"); |
| 1472 | break; |
| 1473 | |
| 1474 | default: |
| 1475 | if (op >= DW_OP_lo_user |
| 1476 | && op <= DW_OP_hi_user) |
| 1477 | printf (_("(User defined location op 0x%x)"), op); |
| 1478 | else |
| 1479 | printf (_("(Unknown location op 0x%x)"), op); |
| 1480 | /* No way to tell where the next op is, so just bail. */ |
| 1481 | return need_frame_base; |
| 1482 | } |
| 1483 | |
| 1484 | /* Separate the ops. */ |
| 1485 | if (data < end) |
| 1486 | printf ("; "); |
| 1487 | } |
| 1488 | |
| 1489 | return need_frame_base; |
| 1490 | } |
| 1491 | |
| 1492 | /* Find the CU or TU set corresponding to the given CU_OFFSET. |
| 1493 | This is used for DWARF package files. */ |
| 1494 | |
| 1495 | static struct cu_tu_set * |
| 1496 | find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types) |
| 1497 | { |
| 1498 | struct cu_tu_set *p; |
| 1499 | unsigned int nsets; |
| 1500 | unsigned int dw_sect; |
| 1501 | |
| 1502 | if (do_types) |
| 1503 | { |
| 1504 | p = tu_sets; |
| 1505 | nsets = tu_count; |
| 1506 | dw_sect = DW_SECT_TYPES; |
| 1507 | } |
| 1508 | else |
| 1509 | { |
| 1510 | p = cu_sets; |
| 1511 | nsets = cu_count; |
| 1512 | dw_sect = DW_SECT_INFO; |
| 1513 | } |
| 1514 | while (nsets > 0) |
| 1515 | { |
| 1516 | if (p->section_offsets [dw_sect] == cu_offset) |
| 1517 | return p; |
| 1518 | p++; |
| 1519 | nsets--; |
| 1520 | } |
| 1521 | return NULL; |
| 1522 | } |
| 1523 | |
| 1524 | /* Add INC to HIGH_BITS:LOW_BITS. */ |
| 1525 | static void |
| 1526 | add64 (dwarf_vma * high_bits, dwarf_vma * low_bits, dwarf_vma inc) |
| 1527 | { |
| 1528 | dwarf_vma tmp = * low_bits; |
| 1529 | |
| 1530 | tmp += inc; |
| 1531 | |
| 1532 | /* FIXME: There is probably a better way of handling this: |
| 1533 | |
| 1534 | We need to cope with dwarf_vma being a 32-bit or 64-bit |
| 1535 | type. Plus regardless of its size LOW_BITS is meant to |
| 1536 | only hold 32-bits, so if there is overflow or wrap around |
| 1537 | we must propagate into HIGH_BITS. */ |
| 1538 | if (tmp < * low_bits) |
| 1539 | { |
| 1540 | ++ * high_bits; |
| 1541 | } |
| 1542 | else if (sizeof (tmp) > 8 |
| 1543 | && (tmp >> 31) > 1) |
| 1544 | { |
| 1545 | ++ * high_bits; |
| 1546 | tmp &= 0xFFFFFFFF; |
| 1547 | } |
| 1548 | |
| 1549 | * low_bits = tmp; |
| 1550 | } |
| 1551 | |
| 1552 | static unsigned char * |
| 1553 | read_and_display_attr_value (unsigned long attribute, |
| 1554 | unsigned long form, |
| 1555 | dwarf_signed_vma implicit_const, |
| 1556 | unsigned char * data, |
| 1557 | unsigned char * end, |
| 1558 | dwarf_vma cu_offset, |
| 1559 | dwarf_vma pointer_size, |
| 1560 | dwarf_vma offset_size, |
| 1561 | int dwarf_version, |
| 1562 | debug_info * debug_info_p, |
| 1563 | int do_loc, |
| 1564 | struct dwarf_section * section, |
| 1565 | struct cu_tu_set * this_set, char delimiter) |
| 1566 | { |
| 1567 | dwarf_vma uvalue = 0; |
| 1568 | unsigned char *block_start = NULL; |
| 1569 | unsigned char * orig_data = data; |
| 1570 | unsigned int bytes_read; |
| 1571 | |
| 1572 | if (data > end || (data == end && form != DW_FORM_flag_present)) |
| 1573 | { |
| 1574 | warn (_("Corrupt attribute\n")); |
| 1575 | return data; |
| 1576 | } |
| 1577 | |
| 1578 | switch (form) |
| 1579 | { |
| 1580 | default: |
| 1581 | break; |
| 1582 | |
| 1583 | case DW_FORM_ref_addr: |
| 1584 | if (dwarf_version == 2) |
| 1585 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| 1586 | else if (dwarf_version == 3 || dwarf_version == 4) |
| 1587 | SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| 1588 | else |
| 1589 | error (_("Internal error: DWARF version is not 2, 3 or 4.\n")); |
| 1590 | |
| 1591 | break; |
| 1592 | |
| 1593 | case DW_FORM_addr: |
| 1594 | SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); |
| 1595 | break; |
| 1596 | |
| 1597 | case DW_FORM_strp: |
| 1598 | case DW_FORM_line_strp: |
| 1599 | case DW_FORM_sec_offset: |
| 1600 | case DW_FORM_GNU_ref_alt: |
| 1601 | case DW_FORM_GNU_strp_alt: |
| 1602 | SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); |
| 1603 | break; |
| 1604 | |
| 1605 | case DW_FORM_flag_present: |
| 1606 | uvalue = 1; |
| 1607 | break; |
| 1608 | |
| 1609 | case DW_FORM_ref1: |
| 1610 | case DW_FORM_flag: |
| 1611 | case DW_FORM_data1: |
| 1612 | SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); |
| 1613 | break; |
| 1614 | |
| 1615 | case DW_FORM_ref2: |
| 1616 | case DW_FORM_data2: |
| 1617 | SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); |
| 1618 | break; |
| 1619 | |
| 1620 | case DW_FORM_ref4: |
| 1621 | case DW_FORM_data4: |
| 1622 | SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); |
| 1623 | break; |
| 1624 | |
| 1625 | case DW_FORM_sdata: |
| 1626 | uvalue = read_sleb128 (data, & bytes_read, end); |
| 1627 | data += bytes_read; |
| 1628 | break; |
| 1629 | |
| 1630 | case DW_FORM_GNU_str_index: |
| 1631 | uvalue = read_uleb128 (data, & bytes_read, end); |
| 1632 | data += bytes_read; |
| 1633 | break; |
| 1634 | |
| 1635 | case DW_FORM_ref_udata: |
| 1636 | case DW_FORM_udata: |
| 1637 | uvalue = read_uleb128 (data, & bytes_read, end); |
| 1638 | data += bytes_read; |
| 1639 | break; |
| 1640 | |
| 1641 | case DW_FORM_indirect: |
| 1642 | form = read_uleb128 (data, & bytes_read, end); |
| 1643 | data += bytes_read; |
| 1644 | if (!do_loc) |
| 1645 | printf ("%c%s", delimiter, get_FORM_name (form)); |
| 1646 | if (form == DW_FORM_implicit_const) |
| 1647 | { |
| 1648 | implicit_const = read_sleb128 (data, & bytes_read, end); |
| 1649 | data += bytes_read; |
| 1650 | } |
| 1651 | return read_and_display_attr_value (attribute, form, implicit_const, data, |
| 1652 | end, cu_offset, pointer_size, |
| 1653 | offset_size, dwarf_version, |
| 1654 | debug_info_p, do_loc, |
| 1655 | section, this_set, delimiter); |
| 1656 | case DW_FORM_GNU_addr_index: |
| 1657 | uvalue = read_uleb128 (data, & bytes_read, end); |
| 1658 | data += bytes_read; |
| 1659 | break; |
| 1660 | } |
| 1661 | |
| 1662 | switch (form) |
| 1663 | { |
| 1664 | case DW_FORM_ref_addr: |
| 1665 | if (!do_loc) |
| 1666 | printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x",uvalue)); |
| 1667 | break; |
| 1668 | |
| 1669 | case DW_FORM_GNU_ref_alt: |
| 1670 | if (!do_loc) |
| 1671 | printf ("%c<alt 0x%s>", delimiter, dwarf_vmatoa ("x",uvalue)); |
| 1672 | break; |
| 1673 | |
| 1674 | case DW_FORM_ref1: |
| 1675 | case DW_FORM_ref2: |
| 1676 | case DW_FORM_ref4: |
| 1677 | case DW_FORM_ref_udata: |
| 1678 | if (!do_loc) |
| 1679 | printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset)); |
| 1680 | break; |
| 1681 | |
| 1682 | case DW_FORM_data4: |
| 1683 | case DW_FORM_addr: |
| 1684 | case DW_FORM_sec_offset: |
| 1685 | if (!do_loc) |
| 1686 | printf ("%c0x%s", delimiter, dwarf_vmatoa ("x", uvalue)); |
| 1687 | break; |
| 1688 | |
| 1689 | case DW_FORM_flag_present: |
| 1690 | case DW_FORM_flag: |
| 1691 | case DW_FORM_data1: |
| 1692 | case DW_FORM_data2: |
| 1693 | case DW_FORM_sdata: |
| 1694 | case DW_FORM_udata: |
| 1695 | if (!do_loc) |
| 1696 | printf ("%c%s", delimiter, dwarf_vmatoa ("d", uvalue)); |
| 1697 | break; |
| 1698 | |
| 1699 | case DW_FORM_implicit_const: |
| 1700 | if (!do_loc) |
| 1701 | printf ("%c%s", delimiter, dwarf_vmatoa ("d", implicit_const)); |
| 1702 | break; |
| 1703 | |
| 1704 | case DW_FORM_ref8: |
| 1705 | case DW_FORM_data8: |
| 1706 | if (!do_loc) |
| 1707 | { |
| 1708 | dwarf_vma high_bits; |
| 1709 | dwarf_vma utmp; |
| 1710 | char buf[64]; |
| 1711 | |
| 1712 | SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end); |
| 1713 | utmp = uvalue; |
| 1714 | if (form == DW_FORM_ref8) |
| 1715 | add64 (& high_bits, & utmp, cu_offset); |
| 1716 | printf ("%c0x%s", delimiter, |
| 1717 | dwarf_vmatoa64 (high_bits, utmp, buf, sizeof (buf))); |
| 1718 | } |
| 1719 | |
| 1720 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 1721 | && num_debug_info_entries == 0) |
| 1722 | { |
| 1723 | if (sizeof (uvalue) == 8) |
| 1724 | SAFE_BYTE_GET (uvalue, data, 8, end); |
| 1725 | else |
| 1726 | error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n")); |
| 1727 | } |
| 1728 | |
| 1729 | data += 8; |
| 1730 | break; |
| 1731 | |
| 1732 | case DW_FORM_string: |
| 1733 | if (!do_loc) |
| 1734 | printf ("%c%.*s", delimiter, (int) (end - data), data); |
| 1735 | data += strnlen ((char *) data, end - data) + 1; |
| 1736 | break; |
| 1737 | |
| 1738 | case DW_FORM_block: |
| 1739 | case DW_FORM_exprloc: |
| 1740 | uvalue = read_uleb128 (data, & bytes_read, end); |
| 1741 | block_start = data + bytes_read; |
| 1742 | if (block_start >= end) |
| 1743 | { |
| 1744 | warn (_("Block ends prematurely\n")); |
| 1745 | uvalue = 0; |
| 1746 | block_start = end; |
| 1747 | } |
| 1748 | /* FIXME: Testing "(block_start + uvalue) < block_start" miscompiles with |
| 1749 | gcc 4.8.3 running on an x86_64 host in 32-bit mode. So we pre-compute |
| 1750 | block_start + uvalue here. */ |
| 1751 | data = block_start + uvalue; |
| 1752 | /* PR 17512: file: 008-103549-0.001:0.1. */ |
| 1753 | if (block_start + uvalue > end || data < block_start) |
| 1754 | { |
| 1755 | warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); |
| 1756 | uvalue = end - block_start; |
| 1757 | } |
| 1758 | if (do_loc) |
| 1759 | data = block_start + uvalue; |
| 1760 | else |
| 1761 | data = display_block (block_start, uvalue, end, delimiter); |
| 1762 | break; |
| 1763 | |
| 1764 | case DW_FORM_block1: |
| 1765 | SAFE_BYTE_GET (uvalue, data, 1, end); |
| 1766 | block_start = data + 1; |
| 1767 | if (block_start >= end) |
| 1768 | { |
| 1769 | warn (_("Block ends prematurely\n")); |
| 1770 | uvalue = 0; |
| 1771 | block_start = end; |
| 1772 | } |
| 1773 | data = block_start + uvalue; |
| 1774 | if (block_start + uvalue > end || data < block_start) |
| 1775 | { |
| 1776 | warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); |
| 1777 | uvalue = end - block_start; |
| 1778 | } |
| 1779 | if (do_loc) |
| 1780 | data = block_start + uvalue; |
| 1781 | else |
| 1782 | data = display_block (block_start, uvalue, end, delimiter); |
| 1783 | break; |
| 1784 | |
| 1785 | case DW_FORM_block2: |
| 1786 | SAFE_BYTE_GET (uvalue, data, 2, end); |
| 1787 | block_start = data + 2; |
| 1788 | if (block_start >= end) |
| 1789 | { |
| 1790 | warn (_("Block ends prematurely\n")); |
| 1791 | uvalue = 0; |
| 1792 | block_start = end; |
| 1793 | } |
| 1794 | data = block_start + uvalue; |
| 1795 | if (block_start + uvalue > end || data < block_start) |
| 1796 | { |
| 1797 | warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); |
| 1798 | uvalue = end - block_start; |
| 1799 | } |
| 1800 | if (do_loc) |
| 1801 | data = block_start + uvalue; |
| 1802 | else |
| 1803 | data = display_block (block_start, uvalue, end, delimiter); |
| 1804 | break; |
| 1805 | |
| 1806 | case DW_FORM_block4: |
| 1807 | SAFE_BYTE_GET (uvalue, data, 4, end); |
| 1808 | block_start = data + 4; |
| 1809 | /* PR 17512: file: 3371-3907-0.004. */ |
| 1810 | if (block_start >= end) |
| 1811 | { |
| 1812 | warn (_("Block ends prematurely\n")); |
| 1813 | uvalue = 0; |
| 1814 | block_start = end; |
| 1815 | } |
| 1816 | data = block_start + uvalue; |
| 1817 | if (block_start + uvalue > end |
| 1818 | /* PR 17531: file: 5b5f0592. */ |
| 1819 | || data < block_start) |
| 1820 | { |
| 1821 | warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); |
| 1822 | uvalue = end - block_start; |
| 1823 | } |
| 1824 | if (do_loc) |
| 1825 | data = block_start + uvalue; |
| 1826 | else |
| 1827 | data = display_block (block_start, uvalue, end, delimiter); |
| 1828 | break; |
| 1829 | |
| 1830 | case DW_FORM_strp: |
| 1831 | if (!do_loc) |
| 1832 | printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter, |
| 1833 | dwarf_vmatoa ("x", uvalue), |
| 1834 | fetch_indirect_string (uvalue)); |
| 1835 | break; |
| 1836 | |
| 1837 | case DW_FORM_line_strp: |
| 1838 | if (!do_loc) |
| 1839 | printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter, |
| 1840 | dwarf_vmatoa ("x", uvalue), |
| 1841 | fetch_indirect_line_string (uvalue)); |
| 1842 | break; |
| 1843 | |
| 1844 | case DW_FORM_GNU_str_index: |
| 1845 | if (!do_loc) |
| 1846 | { |
| 1847 | const char *suffix = strrchr (section->name, '.'); |
| 1848 | int dwo = (suffix && strcmp (suffix, ".dwo") == 0) ? 1 : 0; |
| 1849 | |
| 1850 | printf (_("%c(indexed string: 0x%s): %s"), delimiter, |
| 1851 | dwarf_vmatoa ("x", uvalue), |
| 1852 | fetch_indexed_string (uvalue, this_set, offset_size, dwo)); |
| 1853 | } |
| 1854 | break; |
| 1855 | |
| 1856 | case DW_FORM_GNU_strp_alt: |
| 1857 | if (!do_loc) |
| 1858 | printf (_("%c(alt indirect string, offset: 0x%s)"), delimiter, |
| 1859 | dwarf_vmatoa ("x", uvalue)); |
| 1860 | break; |
| 1861 | |
| 1862 | case DW_FORM_indirect: |
| 1863 | /* Handled above. */ |
| 1864 | break; |
| 1865 | |
| 1866 | case DW_FORM_ref_sig8: |
| 1867 | if (!do_loc) |
| 1868 | { |
| 1869 | dwarf_vma high_bits; |
| 1870 | char buf[64]; |
| 1871 | |
| 1872 | SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end); |
| 1873 | printf ("%csignature: 0x%s", delimiter, |
| 1874 | dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf))); |
| 1875 | } |
| 1876 | data += 8; |
| 1877 | break; |
| 1878 | |
| 1879 | case DW_FORM_GNU_addr_index: |
| 1880 | if (!do_loc) |
| 1881 | printf (_("%c(addr_index: 0x%s): %s"), delimiter, |
| 1882 | dwarf_vmatoa ("x", uvalue), |
| 1883 | fetch_indexed_value (uvalue * pointer_size, pointer_size)); |
| 1884 | break; |
| 1885 | |
| 1886 | default: |
| 1887 | warn (_("Unrecognized form: %lu\n"), form); |
| 1888 | break; |
| 1889 | } |
| 1890 | |
| 1891 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 1892 | && num_debug_info_entries == 0 |
| 1893 | && debug_info_p != NULL) |
| 1894 | { |
| 1895 | switch (attribute) |
| 1896 | { |
| 1897 | case DW_AT_frame_base: |
| 1898 | have_frame_base = 1; |
| 1899 | /* Fall through. */ |
| 1900 | case DW_AT_location: |
| 1901 | case DW_AT_string_length: |
| 1902 | case DW_AT_return_addr: |
| 1903 | case DW_AT_data_member_location: |
| 1904 | case DW_AT_vtable_elem_location: |
| 1905 | case DW_AT_segment: |
| 1906 | case DW_AT_static_link: |
| 1907 | case DW_AT_use_location: |
| 1908 | case DW_AT_call_value: |
| 1909 | case DW_AT_GNU_call_site_value: |
| 1910 | case DW_AT_call_data_value: |
| 1911 | case DW_AT_GNU_call_site_data_value: |
| 1912 | case DW_AT_call_target: |
| 1913 | case DW_AT_GNU_call_site_target: |
| 1914 | case DW_AT_call_target_clobbered: |
| 1915 | case DW_AT_GNU_call_site_target_clobbered: |
| 1916 | if ((dwarf_version < 4 |
| 1917 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) |
| 1918 | || form == DW_FORM_sec_offset) |
| 1919 | { |
| 1920 | /* Process location list. */ |
| 1921 | unsigned int lmax = debug_info_p->max_loc_offsets; |
| 1922 | unsigned int num = debug_info_p->num_loc_offsets; |
| 1923 | |
| 1924 | if (lmax == 0 || num >= lmax) |
| 1925 | { |
| 1926 | lmax += 1024; |
| 1927 | debug_info_p->loc_offsets = (dwarf_vma *) |
| 1928 | xcrealloc (debug_info_p->loc_offsets, |
| 1929 | lmax, sizeof (*debug_info_p->loc_offsets)); |
| 1930 | debug_info_p->have_frame_base = (int *) |
| 1931 | xcrealloc (debug_info_p->have_frame_base, |
| 1932 | lmax, sizeof (*debug_info_p->have_frame_base)); |
| 1933 | debug_info_p->max_loc_offsets = lmax; |
| 1934 | } |
| 1935 | if (this_set != NULL) |
| 1936 | uvalue += this_set->section_offsets [DW_SECT_LOC]; |
| 1937 | debug_info_p->loc_offsets [num] = uvalue; |
| 1938 | debug_info_p->have_frame_base [num] = have_frame_base; |
| 1939 | debug_info_p->num_loc_offsets++; |
| 1940 | } |
| 1941 | break; |
| 1942 | |
| 1943 | case DW_AT_low_pc: |
| 1944 | if (need_base_address) |
| 1945 | debug_info_p->base_address = uvalue; |
| 1946 | break; |
| 1947 | |
| 1948 | case DW_AT_GNU_addr_base: |
| 1949 | debug_info_p->addr_base = uvalue; |
| 1950 | break; |
| 1951 | |
| 1952 | case DW_AT_GNU_ranges_base: |
| 1953 | debug_info_p->ranges_base = uvalue; |
| 1954 | break; |
| 1955 | |
| 1956 | case DW_AT_ranges: |
| 1957 | if ((dwarf_version < 4 |
| 1958 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) |
| 1959 | || form == DW_FORM_sec_offset) |
| 1960 | { |
| 1961 | /* Process range list. */ |
| 1962 | unsigned int lmax = debug_info_p->max_range_lists; |
| 1963 | unsigned int num = debug_info_p->num_range_lists; |
| 1964 | |
| 1965 | if (lmax == 0 || num >= lmax) |
| 1966 | { |
| 1967 | lmax += 1024; |
| 1968 | debug_info_p->range_lists = (dwarf_vma *) |
| 1969 | xcrealloc (debug_info_p->range_lists, |
| 1970 | lmax, sizeof (*debug_info_p->range_lists)); |
| 1971 | debug_info_p->max_range_lists = lmax; |
| 1972 | } |
| 1973 | debug_info_p->range_lists [num] = uvalue; |
| 1974 | debug_info_p->num_range_lists++; |
| 1975 | } |
| 1976 | break; |
| 1977 | |
| 1978 | default: |
| 1979 | break; |
| 1980 | } |
| 1981 | } |
| 1982 | |
| 1983 | if (do_loc || attribute == 0) |
| 1984 | return data; |
| 1985 | |
| 1986 | /* For some attributes we can display further information. */ |
| 1987 | switch (attribute) |
| 1988 | { |
| 1989 | case DW_AT_inline: |
| 1990 | printf ("\t"); |
| 1991 | switch (uvalue) |
| 1992 | { |
| 1993 | case DW_INL_not_inlined: |
| 1994 | printf (_("(not inlined)")); |
| 1995 | break; |
| 1996 | case DW_INL_inlined: |
| 1997 | printf (_("(inlined)")); |
| 1998 | break; |
| 1999 | case DW_INL_declared_not_inlined: |
| 2000 | printf (_("(declared as inline but ignored)")); |
| 2001 | break; |
| 2002 | case DW_INL_declared_inlined: |
| 2003 | printf (_("(declared as inline and inlined)")); |
| 2004 | break; |
| 2005 | default: |
| 2006 | printf (_(" (Unknown inline attribute value: %s)"), |
| 2007 | dwarf_vmatoa ("x", uvalue)); |
| 2008 | break; |
| 2009 | } |
| 2010 | break; |
| 2011 | |
| 2012 | case DW_AT_language: |
| 2013 | printf ("\t"); |
| 2014 | switch (uvalue) |
| 2015 | { |
| 2016 | /* Ordered by the numeric value of these constants. */ |
| 2017 | case DW_LANG_C89: printf ("(ANSI C)"); break; |
| 2018 | case DW_LANG_C: printf ("(non-ANSI C)"); break; |
| 2019 | case DW_LANG_Ada83: printf ("(Ada)"); break; |
| 2020 | case DW_LANG_C_plus_plus: printf ("(C++)"); break; |
| 2021 | case DW_LANG_Cobol74: printf ("(Cobol 74)"); break; |
| 2022 | case DW_LANG_Cobol85: printf ("(Cobol 85)"); break; |
| 2023 | case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break; |
| 2024 | case DW_LANG_Fortran90: printf ("(Fortran 90)"); break; |
| 2025 | case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break; |
| 2026 | case DW_LANG_Modula2: printf ("(Modula 2)"); break; |
| 2027 | /* DWARF 2.1 values. */ |
| 2028 | case DW_LANG_Java: printf ("(Java)"); break; |
| 2029 | case DW_LANG_C99: printf ("(ANSI C99)"); break; |
| 2030 | case DW_LANG_Ada95: printf ("(ADA 95)"); break; |
| 2031 | case DW_LANG_Fortran95: printf ("(Fortran 95)"); break; |
| 2032 | /* DWARF 3 values. */ |
| 2033 | case DW_LANG_PLI: printf ("(PLI)"); break; |
| 2034 | case DW_LANG_ObjC: printf ("(Objective C)"); break; |
| 2035 | case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break; |
| 2036 | case DW_LANG_UPC: printf ("(Unified Parallel C)"); break; |
| 2037 | case DW_LANG_D: printf ("(D)"); break; |
| 2038 | /* DWARF 4 values. */ |
| 2039 | case DW_LANG_Python: printf ("(Python)"); break; |
| 2040 | /* DWARF 5 values. */ |
| 2041 | case DW_LANG_Go: printf ("(Go)"); break; |
| 2042 | case DW_LANG_C_plus_plus_11: printf ("(C++11)"); break; |
| 2043 | case DW_LANG_C11: printf ("(C11)"); break; |
| 2044 | case DW_LANG_C_plus_plus_14: printf ("(C++14)"); break; |
| 2045 | case DW_LANG_Fortran03: printf ("(Fortran 03)"); break; |
| 2046 | case DW_LANG_Fortran08: printf ("(Fortran 08)"); break; |
| 2047 | /* MIPS extension. */ |
| 2048 | case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break; |
| 2049 | /* UPC extension. */ |
| 2050 | case DW_LANG_Upc: printf ("(Unified Parallel C)"); break; |
| 2051 | default: |
| 2052 | if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user) |
| 2053 | printf (_("(implementation defined: %s)"), |
| 2054 | dwarf_vmatoa ("x", uvalue)); |
| 2055 | else |
| 2056 | printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue)); |
| 2057 | break; |
| 2058 | } |
| 2059 | break; |
| 2060 | |
| 2061 | case DW_AT_encoding: |
| 2062 | printf ("\t"); |
| 2063 | switch (uvalue) |
| 2064 | { |
| 2065 | case DW_ATE_void: printf ("(void)"); break; |
| 2066 | case DW_ATE_address: printf ("(machine address)"); break; |
| 2067 | case DW_ATE_boolean: printf ("(boolean)"); break; |
| 2068 | case DW_ATE_complex_float: printf ("(complex float)"); break; |
| 2069 | case DW_ATE_float: printf ("(float)"); break; |
| 2070 | case DW_ATE_signed: printf ("(signed)"); break; |
| 2071 | case DW_ATE_signed_char: printf ("(signed char)"); break; |
| 2072 | case DW_ATE_unsigned: printf ("(unsigned)"); break; |
| 2073 | case DW_ATE_unsigned_char: printf ("(unsigned char)"); break; |
| 2074 | /* DWARF 2.1 values: */ |
| 2075 | case DW_ATE_imaginary_float: printf ("(imaginary float)"); break; |
| 2076 | case DW_ATE_decimal_float: printf ("(decimal float)"); break; |
| 2077 | /* DWARF 3 values: */ |
| 2078 | case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break; |
| 2079 | case DW_ATE_numeric_string: printf ("(numeric_string)"); break; |
| 2080 | case DW_ATE_edited: printf ("(edited)"); break; |
| 2081 | case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break; |
| 2082 | case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break; |
| 2083 | /* HP extensions: */ |
| 2084 | case DW_ATE_HP_float80: printf ("(HP_float80)"); break; |
| 2085 | case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break; |
| 2086 | case DW_ATE_HP_float128: printf ("(HP_float128)"); break; |
| 2087 | case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break; |
| 2088 | case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break; |
| 2089 | case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break; |
| 2090 | case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break; |
| 2091 | /* DWARF 4 values: */ |
| 2092 | case DW_ATE_UTF: printf ("(unicode string)"); break; |
| 2093 | |
| 2094 | default: |
| 2095 | if (uvalue >= DW_ATE_lo_user |
| 2096 | && uvalue <= DW_ATE_hi_user) |
| 2097 | printf (_("(user defined type)")); |
| 2098 | else |
| 2099 | printf (_("(unknown type)")); |
| 2100 | break; |
| 2101 | } |
| 2102 | break; |
| 2103 | |
| 2104 | case DW_AT_accessibility: |
| 2105 | printf ("\t"); |
| 2106 | switch (uvalue) |
| 2107 | { |
| 2108 | case DW_ACCESS_public: printf ("(public)"); break; |
| 2109 | case DW_ACCESS_protected: printf ("(protected)"); break; |
| 2110 | case DW_ACCESS_private: printf ("(private)"); break; |
| 2111 | default: |
| 2112 | printf (_("(unknown accessibility)")); |
| 2113 | break; |
| 2114 | } |
| 2115 | break; |
| 2116 | |
| 2117 | case DW_AT_visibility: |
| 2118 | printf ("\t"); |
| 2119 | switch (uvalue) |
| 2120 | { |
| 2121 | case DW_VIS_local: printf ("(local)"); break; |
| 2122 | case DW_VIS_exported: printf ("(exported)"); break; |
| 2123 | case DW_VIS_qualified: printf ("(qualified)"); break; |
| 2124 | default: printf (_("(unknown visibility)")); break; |
| 2125 | } |
| 2126 | break; |
| 2127 | |
| 2128 | case DW_AT_virtuality: |
| 2129 | printf ("\t"); |
| 2130 | switch (uvalue) |
| 2131 | { |
| 2132 | case DW_VIRTUALITY_none: printf ("(none)"); break; |
| 2133 | case DW_VIRTUALITY_virtual: printf ("(virtual)"); break; |
| 2134 | case DW_VIRTUALITY_pure_virtual:printf ("(pure_virtual)"); break; |
| 2135 | default: printf (_("(unknown virtuality)")); break; |
| 2136 | } |
| 2137 | break; |
| 2138 | |
| 2139 | case DW_AT_identifier_case: |
| 2140 | printf ("\t"); |
| 2141 | switch (uvalue) |
| 2142 | { |
| 2143 | case DW_ID_case_sensitive: printf ("(case_sensitive)"); break; |
| 2144 | case DW_ID_up_case: printf ("(up_case)"); break; |
| 2145 | case DW_ID_down_case: printf ("(down_case)"); break; |
| 2146 | case DW_ID_case_insensitive: printf ("(case_insensitive)"); break; |
| 2147 | default: printf (_("(unknown case)")); break; |
| 2148 | } |
| 2149 | break; |
| 2150 | |
| 2151 | case DW_AT_calling_convention: |
| 2152 | printf ("\t"); |
| 2153 | switch (uvalue) |
| 2154 | { |
| 2155 | case DW_CC_normal: printf ("(normal)"); break; |
| 2156 | case DW_CC_program: printf ("(program)"); break; |
| 2157 | case DW_CC_nocall: printf ("(nocall)"); break; |
| 2158 | default: |
| 2159 | if (uvalue >= DW_CC_lo_user |
| 2160 | && uvalue <= DW_CC_hi_user) |
| 2161 | printf (_("(user defined)")); |
| 2162 | else |
| 2163 | printf (_("(unknown convention)")); |
| 2164 | } |
| 2165 | break; |
| 2166 | |
| 2167 | case DW_AT_ordering: |
| 2168 | printf ("\t"); |
| 2169 | switch (uvalue) |
| 2170 | { |
| 2171 | case -1: printf (_("(undefined)")); break; |
| 2172 | case 0: printf ("(row major)"); break; |
| 2173 | case 1: printf ("(column major)"); break; |
| 2174 | } |
| 2175 | break; |
| 2176 | |
| 2177 | case DW_AT_frame_base: |
| 2178 | have_frame_base = 1; |
| 2179 | /* Fall through. */ |
| 2180 | case DW_AT_location: |
| 2181 | case DW_AT_string_length: |
| 2182 | case DW_AT_return_addr: |
| 2183 | case DW_AT_data_member_location: |
| 2184 | case DW_AT_vtable_elem_location: |
| 2185 | case DW_AT_segment: |
| 2186 | case DW_AT_static_link: |
| 2187 | case DW_AT_use_location: |
| 2188 | case DW_AT_call_value: |
| 2189 | case DW_AT_GNU_call_site_value: |
| 2190 | case DW_AT_call_data_value: |
| 2191 | case DW_AT_GNU_call_site_data_value: |
| 2192 | case DW_AT_call_target: |
| 2193 | case DW_AT_GNU_call_site_target: |
| 2194 | case DW_AT_call_target_clobbered: |
| 2195 | case DW_AT_GNU_call_site_target_clobbered: |
| 2196 | if ((dwarf_version < 4 |
| 2197 | && (form == DW_FORM_data4 || form == DW_FORM_data8)) |
| 2198 | || form == DW_FORM_sec_offset) |
| 2199 | printf (_(" (location list)")); |
| 2200 | /* Fall through. */ |
| 2201 | case DW_AT_allocated: |
| 2202 | case DW_AT_associated: |
| 2203 | case DW_AT_data_location: |
| 2204 | case DW_AT_stride: |
| 2205 | case DW_AT_upper_bound: |
| 2206 | case DW_AT_lower_bound: |
| 2207 | if (block_start) |
| 2208 | { |
| 2209 | int need_frame_base; |
| 2210 | |
| 2211 | printf ("\t("); |
| 2212 | need_frame_base = decode_location_expression (block_start, |
| 2213 | pointer_size, |
| 2214 | offset_size, |
| 2215 | dwarf_version, |
| 2216 | uvalue, |
| 2217 | cu_offset, section); |
| 2218 | printf (")"); |
| 2219 | if (need_frame_base && !have_frame_base) |
| 2220 | printf (_(" [without DW_AT_frame_base]")); |
| 2221 | } |
| 2222 | break; |
| 2223 | |
| 2224 | case DW_AT_import: |
| 2225 | { |
| 2226 | if (form == DW_FORM_ref_sig8 |
| 2227 | || form == DW_FORM_GNU_ref_alt) |
| 2228 | break; |
| 2229 | |
| 2230 | if (form == DW_FORM_ref1 |
| 2231 | || form == DW_FORM_ref2 |
| 2232 | || form == DW_FORM_ref4 |
| 2233 | || form == DW_FORM_ref_udata) |
| 2234 | uvalue += cu_offset; |
| 2235 | |
| 2236 | if (uvalue >= section->size) |
| 2237 | warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset 0x%lx is too big.\n"), |
| 2238 | dwarf_vmatoa ("x", uvalue), |
| 2239 | (unsigned long) (orig_data - section->start)); |
| 2240 | else |
| 2241 | { |
| 2242 | unsigned long abbrev_number; |
| 2243 | abbrev_entry * entry; |
| 2244 | |
| 2245 | abbrev_number = read_uleb128 (section->start + uvalue, NULL, end); |
| 2246 | |
| 2247 | printf (_("\t[Abbrev Number: %ld"), abbrev_number); |
| 2248 | /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will |
| 2249 | use different abbrev table, and we don't track .debug_info chunks |
| 2250 | yet. */ |
| 2251 | if (form != DW_FORM_ref_addr) |
| 2252 | { |
| 2253 | for (entry = first_abbrev; entry != NULL; entry = entry->next) |
| 2254 | if (entry->entry == abbrev_number) |
| 2255 | break; |
| 2256 | if (entry != NULL) |
| 2257 | printf (" (%s)", get_TAG_name (entry->tag)); |
| 2258 | } |
| 2259 | printf ("]"); |
| 2260 | } |
| 2261 | } |
| 2262 | break; |
| 2263 | |
| 2264 | default: |
| 2265 | break; |
| 2266 | } |
| 2267 | |
| 2268 | return data; |
| 2269 | } |
| 2270 | |
| 2271 | static const char * |
| 2272 | get_AT_name (unsigned long attribute) |
| 2273 | { |
| 2274 | const char *name; |
| 2275 | |
| 2276 | if (attribute == 0) |
| 2277 | return "DW_AT value: 0"; |
| 2278 | |
| 2279 | /* One value is shared by the MIPS and HP extensions: */ |
| 2280 | if (attribute == DW_AT_MIPS_fde) |
| 2281 | return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable"; |
| 2282 | |
| 2283 | name = get_DW_AT_name (attribute); |
| 2284 | |
| 2285 | if (name == NULL) |
| 2286 | { |
| 2287 | static char buffer[100]; |
| 2288 | |
| 2289 | snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"), |
| 2290 | attribute); |
| 2291 | return buffer; |
| 2292 | } |
| 2293 | |
| 2294 | return name; |
| 2295 | } |
| 2296 | |
| 2297 | static unsigned char * |
| 2298 | read_and_display_attr (unsigned long attribute, |
| 2299 | unsigned long form, |
| 2300 | dwarf_signed_vma implicit_const, |
| 2301 | unsigned char * data, |
| 2302 | unsigned char * end, |
| 2303 | dwarf_vma cu_offset, |
| 2304 | dwarf_vma pointer_size, |
| 2305 | dwarf_vma offset_size, |
| 2306 | int dwarf_version, |
| 2307 | debug_info * debug_info_p, |
| 2308 | int do_loc, |
| 2309 | struct dwarf_section * section, |
| 2310 | struct cu_tu_set * this_set) |
| 2311 | { |
| 2312 | if (!do_loc) |
| 2313 | printf (" %-18s:", get_AT_name (attribute)); |
| 2314 | data = read_and_display_attr_value (attribute, form, implicit_const, data, end, |
| 2315 | cu_offset, pointer_size, offset_size, |
| 2316 | dwarf_version, debug_info_p, |
| 2317 | do_loc, section, this_set, ' '); |
| 2318 | if (!do_loc) |
| 2319 | printf ("\n"); |
| 2320 | return data; |
| 2321 | } |
| 2322 | |
| 2323 | /* Process the contents of a .debug_info section. If do_loc is non-zero |
| 2324 | then we are scanning for location lists and we do not want to display |
| 2325 | anything to the user. If do_types is non-zero, we are processing |
| 2326 | a .debug_types section instead of a .debug_info section. */ |
| 2327 | |
| 2328 | static int |
| 2329 | process_debug_info (struct dwarf_section *section, |
| 2330 | void *file, |
| 2331 | enum dwarf_section_display_enum abbrev_sec, |
| 2332 | int do_loc, |
| 2333 | int do_types) |
| 2334 | { |
| 2335 | unsigned char *start = section->start; |
| 2336 | unsigned char *end = start + section->size; |
| 2337 | unsigned char *section_begin; |
| 2338 | unsigned int unit; |
| 2339 | unsigned int num_units = 0; |
| 2340 | |
| 2341 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 2342 | && num_debug_info_entries == 0 |
| 2343 | && ! do_types) |
| 2344 | { |
| 2345 | dwarf_vma length; |
| 2346 | |
| 2347 | /* First scan the section to get the number of comp units. */ |
| 2348 | for (section_begin = start, num_units = 0; section_begin < end; |
| 2349 | num_units ++) |
| 2350 | { |
| 2351 | /* Read the first 4 bytes. For a 32-bit DWARF section, this |
| 2352 | will be the length. For a 64-bit DWARF section, it'll be |
| 2353 | the escape code 0xffffffff followed by an 8 byte length. */ |
| 2354 | SAFE_BYTE_GET (length, section_begin, 4, end); |
| 2355 | |
| 2356 | if (length == 0xffffffff) |
| 2357 | { |
| 2358 | SAFE_BYTE_GET (length, section_begin + 4, 8, end); |
| 2359 | section_begin += length + 12; |
| 2360 | } |
| 2361 | else if (length >= 0xfffffff0 && length < 0xffffffff) |
| 2362 | { |
| 2363 | warn (_("Reserved length value (0x%s) found in section %s\n"), |
| 2364 | dwarf_vmatoa ("x", length), section->name); |
| 2365 | return 0; |
| 2366 | } |
| 2367 | else |
| 2368 | section_begin += length + 4; |
| 2369 | |
| 2370 | /* Negative values are illegal, they may even cause infinite |
| 2371 | looping. This can happen if we can't accurately apply |
| 2372 | relocations to an object file, or if the file is corrupt. */ |
| 2373 | if ((signed long) length <= 0 || section_begin < start) |
| 2374 | { |
| 2375 | warn (_("Corrupt unit length (0x%s) found in section %s\n"), |
| 2376 | dwarf_vmatoa ("x", length), section->name); |
| 2377 | return 0; |
| 2378 | } |
| 2379 | } |
| 2380 | |
| 2381 | if (num_units == 0) |
| 2382 | { |
| 2383 | error (_("No comp units in %s section ?\n"), section->name); |
| 2384 | return 0; |
| 2385 | } |
| 2386 | |
| 2387 | /* Then allocate an array to hold the information. */ |
| 2388 | debug_information = (debug_info *) cmalloc (num_units, |
| 2389 | sizeof (* debug_information)); |
| 2390 | if (debug_information == NULL) |
| 2391 | { |
| 2392 | error (_("Not enough memory for a debug info array of %u entries\n"), |
| 2393 | num_units); |
| 2394 | alloc_num_debug_info_entries = num_debug_info_entries = 0; |
| 2395 | return 0; |
| 2396 | } |
| 2397 | /* PR 17531: file: 92ca3797. |
| 2398 | We cannot rely upon the debug_information array being initialised |
| 2399 | before it is used. A corrupt file could easily contain references |
| 2400 | to a unit for which information has not been made available. So |
| 2401 | we ensure that the array is zeroed here. */ |
| 2402 | memset (debug_information, 0, num_units * sizeof (*debug_information)); |
| 2403 | |
| 2404 | alloc_num_debug_info_entries = num_units; |
| 2405 | } |
| 2406 | |
| 2407 | if (!do_loc) |
| 2408 | { |
| 2409 | if (dwarf_start_die == 0) |
| 2410 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 2411 | |
| 2412 | load_debug_section (str, file); |
| 2413 | load_debug_section (line_str, file); |
| 2414 | load_debug_section (str_dwo, file); |
| 2415 | load_debug_section (str_index, file); |
| 2416 | load_debug_section (str_index_dwo, file); |
| 2417 | load_debug_section (debug_addr, file); |
| 2418 | } |
| 2419 | |
| 2420 | load_debug_section (abbrev_sec, file); |
| 2421 | if (debug_displays [abbrev_sec].section.start == NULL) |
| 2422 | { |
| 2423 | warn (_("Unable to locate %s section!\n"), |
| 2424 | debug_displays [abbrev_sec].section.name); |
| 2425 | return 0; |
| 2426 | } |
| 2427 | |
| 2428 | for (section_begin = start, unit = 0; start < end; unit++) |
| 2429 | { |
| 2430 | DWARF2_Internal_CompUnit compunit; |
| 2431 | unsigned char *hdrptr; |
| 2432 | unsigned char *tags; |
| 2433 | int level, last_level, saved_level; |
| 2434 | dwarf_vma cu_offset; |
| 2435 | unsigned int offset_size; |
| 2436 | int initial_length_size; |
| 2437 | dwarf_vma signature_high = 0; |
| 2438 | dwarf_vma signature_low = 0; |
| 2439 | dwarf_vma type_offset = 0; |
| 2440 | struct cu_tu_set *this_set; |
| 2441 | dwarf_vma abbrev_base; |
| 2442 | size_t abbrev_size; |
| 2443 | |
| 2444 | hdrptr = start; |
| 2445 | |
| 2446 | SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 4, end); |
| 2447 | |
| 2448 | if (compunit.cu_length == 0xffffffff) |
| 2449 | { |
| 2450 | SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 8, end); |
| 2451 | offset_size = 8; |
| 2452 | initial_length_size = 12; |
| 2453 | } |
| 2454 | else |
| 2455 | { |
| 2456 | offset_size = 4; |
| 2457 | initial_length_size = 4; |
| 2458 | } |
| 2459 | |
| 2460 | SAFE_BYTE_GET_AND_INC (compunit.cu_version, hdrptr, 2, end); |
| 2461 | |
| 2462 | cu_offset = start - section_begin; |
| 2463 | |
| 2464 | this_set = find_cu_tu_set_v2 (cu_offset, do_types); |
| 2465 | |
| 2466 | if (compunit.cu_version < 5) |
| 2467 | { |
| 2468 | compunit.cu_unit_type = DW_UT_compile; |
| 2469 | /* Initialize it due to a false compiler warning. */ |
| 2470 | compunit.cu_pointer_size = -1; |
| 2471 | } |
| 2472 | else |
| 2473 | { |
| 2474 | SAFE_BYTE_GET_AND_INC (compunit.cu_unit_type, hdrptr, 1, end); |
| 2475 | do_types = (compunit.cu_unit_type == DW_UT_type); |
| 2476 | |
| 2477 | SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end); |
| 2478 | } |
| 2479 | |
| 2480 | SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end); |
| 2481 | |
| 2482 | if (this_set == NULL) |
| 2483 | { |
| 2484 | abbrev_base = 0; |
| 2485 | abbrev_size = debug_displays [abbrev_sec].section.size; |
| 2486 | } |
| 2487 | else |
| 2488 | { |
| 2489 | abbrev_base = this_set->section_offsets [DW_SECT_ABBREV]; |
| 2490 | abbrev_size = this_set->section_sizes [DW_SECT_ABBREV]; |
| 2491 | } |
| 2492 | |
| 2493 | if (compunit.cu_version < 5) |
| 2494 | SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end); |
| 2495 | |
| 2496 | /* PR 17512: file: 001-108546-0.001:0.1. */ |
| 2497 | if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8) |
| 2498 | { |
| 2499 | warn (_("Invalid pointer size (%d) in compunit header, using %d instead\n"), |
| 2500 | compunit.cu_pointer_size, offset_size); |
| 2501 | compunit.cu_pointer_size = offset_size; |
| 2502 | } |
| 2503 | |
| 2504 | if (do_types) |
| 2505 | { |
| 2506 | SAFE_BYTE_GET64 (hdrptr, &signature_high, &signature_low, end); |
| 2507 | hdrptr += 8; |
| 2508 | SAFE_BYTE_GET_AND_INC (type_offset, hdrptr, offset_size, end); |
| 2509 | } |
| 2510 | |
| 2511 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 2512 | && num_debug_info_entries == 0 |
| 2513 | && ! do_types) |
| 2514 | { |
| 2515 | debug_information [unit].cu_offset = cu_offset; |
| 2516 | debug_information [unit].pointer_size |
| 2517 | = compunit.cu_pointer_size; |
| 2518 | debug_information [unit].offset_size = offset_size; |
| 2519 | debug_information [unit].dwarf_version = compunit.cu_version; |
| 2520 | debug_information [unit].base_address = 0; |
| 2521 | debug_information [unit].addr_base = DEBUG_INFO_UNAVAILABLE; |
| 2522 | debug_information [unit].ranges_base = DEBUG_INFO_UNAVAILABLE; |
| 2523 | debug_information [unit].loc_offsets = NULL; |
| 2524 | debug_information [unit].have_frame_base = NULL; |
| 2525 | debug_information [unit].max_loc_offsets = 0; |
| 2526 | debug_information [unit].num_loc_offsets = 0; |
| 2527 | debug_information [unit].range_lists = NULL; |
| 2528 | debug_information [unit].max_range_lists= 0; |
| 2529 | debug_information [unit].num_range_lists = 0; |
| 2530 | } |
| 2531 | |
| 2532 | if (!do_loc && dwarf_start_die == 0) |
| 2533 | { |
| 2534 | printf (_(" Compilation Unit @ offset 0x%s:\n"), |
| 2535 | dwarf_vmatoa ("x", cu_offset)); |
| 2536 | printf (_(" Length: 0x%s (%s)\n"), |
| 2537 | dwarf_vmatoa ("x", compunit.cu_length), |
| 2538 | offset_size == 8 ? "64-bit" : "32-bit"); |
| 2539 | printf (_(" Version: %d\n"), compunit.cu_version); |
| 2540 | printf (_(" Abbrev Offset: 0x%s\n"), |
| 2541 | dwarf_vmatoa ("x", compunit.cu_abbrev_offset)); |
| 2542 | printf (_(" Pointer Size: %d\n"), compunit.cu_pointer_size); |
| 2543 | if (do_types) |
| 2544 | { |
| 2545 | char buf[64]; |
| 2546 | |
| 2547 | printf (_(" Signature: 0x%s\n"), |
| 2548 | dwarf_vmatoa64 (signature_high, signature_low, |
| 2549 | buf, sizeof (buf))); |
| 2550 | printf (_(" Type Offset: 0x%s\n"), |
| 2551 | dwarf_vmatoa ("x", type_offset)); |
| 2552 | } |
| 2553 | if (this_set != NULL) |
| 2554 | { |
| 2555 | dwarf_vma *offsets = this_set->section_offsets; |
| 2556 | size_t *sizes = this_set->section_sizes; |
| 2557 | |
| 2558 | printf (_(" Section contributions:\n")); |
| 2559 | printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"), |
| 2560 | dwarf_vmatoa ("x", offsets [DW_SECT_ABBREV]), |
| 2561 | dwarf_vmatoa ("x", sizes [DW_SECT_ABBREV])); |
| 2562 | printf (_(" .debug_line.dwo: 0x%s 0x%s\n"), |
| 2563 | dwarf_vmatoa ("x", offsets [DW_SECT_LINE]), |
| 2564 | dwarf_vmatoa ("x", sizes [DW_SECT_LINE])); |
| 2565 | printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"), |
| 2566 | dwarf_vmatoa ("x", offsets [DW_SECT_LOC]), |
| 2567 | dwarf_vmatoa ("x", sizes [DW_SECT_LOC])); |
| 2568 | printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"), |
| 2569 | dwarf_vmatoa ("x", offsets [DW_SECT_STR_OFFSETS]), |
| 2570 | dwarf_vmatoa ("x", sizes [DW_SECT_STR_OFFSETS])); |
| 2571 | } |
| 2572 | } |
| 2573 | |
| 2574 | if (cu_offset + compunit.cu_length + initial_length_size |
| 2575 | > section->size) |
| 2576 | { |
| 2577 | warn (_("Debug info is corrupted, length of CU at %s" |
| 2578 | " extends beyond end of section (length = %s)\n"), |
| 2579 | dwarf_vmatoa ("x", cu_offset), |
| 2580 | dwarf_vmatoa ("x", compunit.cu_length)); |
| 2581 | num_units = unit; |
| 2582 | break; |
| 2583 | } |
| 2584 | tags = hdrptr; |
| 2585 | start += compunit.cu_length + initial_length_size; |
| 2586 | |
| 2587 | if (start > end) |
| 2588 | { |
| 2589 | warn (_("Debug info is corrupt. CU at %s extends beyond end of section"), |
| 2590 | dwarf_vmatoa ("x", cu_offset)); |
| 2591 | start = end; |
| 2592 | } |
| 2593 | |
| 2594 | if (compunit.cu_version < 2 || compunit.cu_version > 5) |
| 2595 | { |
| 2596 | warn (_("CU at offset %s contains corrupt or " |
| 2597 | "unsupported version number: %d.\n"), |
| 2598 | dwarf_vmatoa ("x", cu_offset), compunit.cu_version); |
| 2599 | continue; |
| 2600 | } |
| 2601 | |
| 2602 | if (compunit.cu_unit_type != DW_UT_compile |
| 2603 | && compunit.cu_unit_type != DW_UT_type) |
| 2604 | { |
| 2605 | warn (_("CU at offset %s contains corrupt or " |
| 2606 | "unsupported unit type: %d.\n"), |
| 2607 | dwarf_vmatoa ("x", cu_offset), compunit.cu_unit_type); |
| 2608 | continue; |
| 2609 | } |
| 2610 | |
| 2611 | free_abbrevs (); |
| 2612 | |
| 2613 | /* Process the abbrevs used by this compilation unit. */ |
| 2614 | if (compunit.cu_abbrev_offset >= abbrev_size) |
| 2615 | warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"), |
| 2616 | (unsigned long) compunit.cu_abbrev_offset, |
| 2617 | (unsigned long) abbrev_size); |
| 2618 | /* PR 17531: file:4bcd9ce9. */ |
| 2619 | else if ((abbrev_base + abbrev_size) |
| 2620 | > debug_displays [abbrev_sec].section.size) |
| 2621 | warn (_("Debug info is corrupted, abbrev size (%lx) is larger than abbrev section size (%lx)\n"), |
| 2622 | (unsigned long) abbrev_base + abbrev_size, |
| 2623 | (unsigned long) debug_displays [abbrev_sec].section.size); |
| 2624 | else |
| 2625 | process_abbrev_section |
| 2626 | (((unsigned char *) debug_displays [abbrev_sec].section.start |
| 2627 | + abbrev_base + compunit.cu_abbrev_offset), |
| 2628 | ((unsigned char *) debug_displays [abbrev_sec].section.start |
| 2629 | + abbrev_base + abbrev_size)); |
| 2630 | |
| 2631 | level = 0; |
| 2632 | last_level = level; |
| 2633 | saved_level = -1; |
| 2634 | while (tags < start) |
| 2635 | { |
| 2636 | unsigned int bytes_read; |
| 2637 | unsigned long abbrev_number; |
| 2638 | unsigned long die_offset; |
| 2639 | abbrev_entry *entry; |
| 2640 | abbrev_attr *attr; |
| 2641 | int do_printing = 1; |
| 2642 | |
| 2643 | die_offset = tags - section_begin; |
| 2644 | |
| 2645 | abbrev_number = read_uleb128 (tags, & bytes_read, start); |
| 2646 | tags += bytes_read; |
| 2647 | |
| 2648 | /* A null DIE marks the end of a list of siblings or it may also be |
| 2649 | a section padding. */ |
| 2650 | if (abbrev_number == 0) |
| 2651 | { |
| 2652 | /* Check if it can be a section padding for the last CU. */ |
| 2653 | if (level == 0 && start == end) |
| 2654 | { |
| 2655 | unsigned char *chk; |
| 2656 | |
| 2657 | for (chk = tags; chk < start; chk++) |
| 2658 | if (*chk != 0) |
| 2659 | break; |
| 2660 | if (chk == start) |
| 2661 | break; |
| 2662 | } |
| 2663 | |
| 2664 | if (!do_loc && die_offset >= dwarf_start_die |
| 2665 | && (dwarf_cutoff_level == -1 |
| 2666 | || level < dwarf_cutoff_level)) |
| 2667 | printf (_(" <%d><%lx>: Abbrev Number: 0\n"), |
| 2668 | level, die_offset); |
| 2669 | |
| 2670 | --level; |
| 2671 | if (level < 0) |
| 2672 | { |
| 2673 | static unsigned num_bogus_warns = 0; |
| 2674 | |
| 2675 | if (num_bogus_warns < 3) |
| 2676 | { |
| 2677 | warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"), |
| 2678 | die_offset, section->name); |
| 2679 | num_bogus_warns ++; |
| 2680 | if (num_bogus_warns == 3) |
| 2681 | warn (_("Further warnings about bogus end-of-sibling markers suppressed\n")); |
| 2682 | } |
| 2683 | } |
| 2684 | if (dwarf_start_die != 0 && level < saved_level) |
| 2685 | return 1; |
| 2686 | continue; |
| 2687 | } |
| 2688 | |
| 2689 | if (!do_loc) |
| 2690 | { |
| 2691 | if (dwarf_start_die != 0 && die_offset < dwarf_start_die) |
| 2692 | do_printing = 0; |
| 2693 | else |
| 2694 | { |
| 2695 | if (dwarf_start_die != 0 && die_offset == dwarf_start_die) |
| 2696 | saved_level = level; |
| 2697 | do_printing = (dwarf_cutoff_level == -1 |
| 2698 | || level < dwarf_cutoff_level); |
| 2699 | if (do_printing) |
| 2700 | printf (_(" <%d><%lx>: Abbrev Number: %lu"), |
| 2701 | level, die_offset, abbrev_number); |
| 2702 | else if (dwarf_cutoff_level == -1 |
| 2703 | || last_level < dwarf_cutoff_level) |
| 2704 | printf (_(" <%d><%lx>: ...\n"), level, die_offset); |
| 2705 | last_level = level; |
| 2706 | } |
| 2707 | } |
| 2708 | |
| 2709 | /* Scan through the abbreviation list until we reach the |
| 2710 | correct entry. */ |
| 2711 | for (entry = first_abbrev; |
| 2712 | entry && entry->entry != abbrev_number; |
| 2713 | entry = entry->next) |
| 2714 | continue; |
| 2715 | |
| 2716 | if (entry == NULL) |
| 2717 | { |
| 2718 | if (!do_loc && do_printing) |
| 2719 | { |
| 2720 | printf ("\n"); |
| 2721 | fflush (stdout); |
| 2722 | } |
| 2723 | warn (_("DIE at offset 0x%lx refers to abbreviation number %lu which does not exist\n"), |
| 2724 | die_offset, abbrev_number); |
| 2725 | return 0; |
| 2726 | } |
| 2727 | |
| 2728 | if (!do_loc && do_printing) |
| 2729 | printf (" (%s)\n", get_TAG_name (entry->tag)); |
| 2730 | |
| 2731 | switch (entry->tag) |
| 2732 | { |
| 2733 | default: |
| 2734 | need_base_address = 0; |
| 2735 | break; |
| 2736 | case DW_TAG_compile_unit: |
| 2737 | need_base_address = 1; |
| 2738 | break; |
| 2739 | case DW_TAG_entry_point: |
| 2740 | case DW_TAG_subprogram: |
| 2741 | need_base_address = 0; |
| 2742 | /* Assuming that there is no DW_AT_frame_base. */ |
| 2743 | have_frame_base = 0; |
| 2744 | break; |
| 2745 | } |
| 2746 | |
| 2747 | for (attr = entry->first_attr; |
| 2748 | attr && attr->attribute; |
| 2749 | attr = attr->next) |
| 2750 | { |
| 2751 | debug_info *arg; |
| 2752 | |
| 2753 | if (! do_loc && do_printing) |
| 2754 | /* Show the offset from where the tag was extracted. */ |
| 2755 | printf (" <%lx>", (unsigned long)(tags - section_begin)); |
| 2756 | |
| 2757 | if (debug_information && unit < alloc_num_debug_info_entries) |
| 2758 | arg = debug_information + unit; |
| 2759 | else |
| 2760 | arg = NULL; |
| 2761 | |
| 2762 | tags = read_and_display_attr (attr->attribute, |
| 2763 | attr->form, |
| 2764 | attr->implicit_const, |
| 2765 | tags, |
| 2766 | end, |
| 2767 | cu_offset, |
| 2768 | compunit.cu_pointer_size, |
| 2769 | offset_size, |
| 2770 | compunit.cu_version, |
| 2771 | arg, |
| 2772 | do_loc || ! do_printing, |
| 2773 | section, |
| 2774 | this_set); |
| 2775 | } |
| 2776 | |
| 2777 | if (entry->children) |
| 2778 | ++level; |
| 2779 | } |
| 2780 | } |
| 2781 | |
| 2782 | /* Set num_debug_info_entries here so that it can be used to check if |
| 2783 | we need to process .debug_loc and .debug_ranges sections. */ |
| 2784 | if ((do_loc || do_debug_loc || do_debug_ranges) |
| 2785 | && num_debug_info_entries == 0 |
| 2786 | && ! do_types) |
| 2787 | { |
| 2788 | if (num_units > alloc_num_debug_info_entries) |
| 2789 | num_debug_info_entries = alloc_num_debug_info_entries; |
| 2790 | else |
| 2791 | num_debug_info_entries = num_units; |
| 2792 | } |
| 2793 | |
| 2794 | if (!do_loc) |
| 2795 | printf ("\n"); |
| 2796 | |
| 2797 | return 1; |
| 2798 | } |
| 2799 | |
| 2800 | /* Locate and scan the .debug_info section in the file and record the pointer |
| 2801 | sizes and offsets for the compilation units in it. Usually an executable |
| 2802 | will have just one pointer size, but this is not guaranteed, and so we try |
| 2803 | not to make any assumptions. Returns zero upon failure, or the number of |
| 2804 | compilation units upon success. */ |
| 2805 | |
| 2806 | static unsigned int |
| 2807 | load_debug_info (void * file) |
| 2808 | { |
| 2809 | /* Reset the last pointer size so that we can issue correct error |
| 2810 | messages if we are displaying the contents of more than one section. */ |
| 2811 | last_pointer_size = 0; |
| 2812 | warned_about_missing_comp_units = FALSE; |
| 2813 | |
| 2814 | /* If we have already tried and failed to load the .debug_info |
| 2815 | section then do not bother to repeat the task. */ |
| 2816 | if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) |
| 2817 | return 0; |
| 2818 | |
| 2819 | /* If we already have the information there is nothing else to do. */ |
| 2820 | if (num_debug_info_entries > 0) |
| 2821 | return num_debug_info_entries; |
| 2822 | |
| 2823 | /* If this is a DWARF package file, load the CU and TU indexes. */ |
| 2824 | (void) load_cu_tu_indexes (file); |
| 2825 | |
| 2826 | if (load_debug_section (info, file) |
| 2827 | && process_debug_info (&debug_displays [info].section, file, abbrev, 1, 0)) |
| 2828 | return num_debug_info_entries; |
| 2829 | |
| 2830 | if (load_debug_section (info_dwo, file) |
| 2831 | && process_debug_info (&debug_displays [info_dwo].section, file, |
| 2832 | abbrev_dwo, 1, 0)) |
| 2833 | return num_debug_info_entries; |
| 2834 | |
| 2835 | num_debug_info_entries = DEBUG_INFO_UNAVAILABLE; |
| 2836 | return 0; |
| 2837 | } |
| 2838 | |
| 2839 | /* Read a DWARF .debug_line section header starting at DATA. |
| 2840 | Upon success returns an updated DATA pointer and the LINFO |
| 2841 | structure and the END_OF_SEQUENCE pointer will be filled in. |
| 2842 | Otherwise returns NULL. */ |
| 2843 | |
| 2844 | static unsigned char * |
| 2845 | read_debug_line_header (struct dwarf_section * section, |
| 2846 | unsigned char * data, |
| 2847 | unsigned char * end, |
| 2848 | DWARF2_Internal_LineInfo * linfo, |
| 2849 | unsigned char ** end_of_sequence) |
| 2850 | { |
| 2851 | unsigned char *hdrptr; |
| 2852 | unsigned int initial_length_size; |
| 2853 | unsigned char address_size, segment_selector_size; |
| 2854 | |
| 2855 | /* Extract information from the Line Number Program Header. |
| 2856 | (section 6.2.4 in the Dwarf3 doc). */ |
| 2857 | hdrptr = data; |
| 2858 | |
| 2859 | /* Get and check the length of the block. */ |
| 2860 | SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 4, end); |
| 2861 | |
| 2862 | if (linfo->li_length == 0xffffffff) |
| 2863 | { |
| 2864 | /* This section is 64-bit DWARF 3. */ |
| 2865 | SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 8, end); |
| 2866 | linfo->li_offset_size = 8; |
| 2867 | initial_length_size = 12; |
| 2868 | } |
| 2869 | else |
| 2870 | { |
| 2871 | linfo->li_offset_size = 4; |
| 2872 | initial_length_size = 4; |
| 2873 | } |
| 2874 | |
| 2875 | if (linfo->li_length + initial_length_size > section->size) |
| 2876 | { |
| 2877 | /* If the length field has a relocation against it, then we should |
| 2878 | not complain if it is inaccurate (and probably negative). This |
| 2879 | happens in object files when the .debug_line section is actually |
| 2880 | comprised of several different .debug_line.* sections, (some of |
| 2881 | which may be removed by linker garbage collection), and a relocation |
| 2882 | is used to compute the correct length once that is done. */ |
| 2883 | if (reloc_at (section, (hdrptr - section->start) - linfo->li_offset_size)) |
| 2884 | { |
| 2885 | linfo->li_length = (end - data) - initial_length_size; |
| 2886 | } |
| 2887 | else |
| 2888 | { |
| 2889 | warn (_("The length field (0x%lx) in the debug_line header is wrong - the section is too small\n"), |
| 2890 | (long) linfo->li_length); |
| 2891 | return NULL; |
| 2892 | } |
| 2893 | } |
| 2894 | |
| 2895 | /* Get and check the version number. */ |
| 2896 | SAFE_BYTE_GET_AND_INC (linfo->li_version, hdrptr, 2, end); |
| 2897 | |
| 2898 | if (linfo->li_version != 2 |
| 2899 | && linfo->li_version != 3 |
| 2900 | && linfo->li_version != 4 |
| 2901 | && linfo->li_version != 5) |
| 2902 | { |
| 2903 | warn (_("Only DWARF version 2, 3, 4 and 5 line info " |
| 2904 | "is currently supported.\n")); |
| 2905 | return NULL; |
| 2906 | } |
| 2907 | |
| 2908 | if (linfo->li_version >= 5) |
| 2909 | { |
| 2910 | SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end); |
| 2911 | |
| 2912 | SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end); |
| 2913 | if (segment_selector_size != 0) |
| 2914 | { |
| 2915 | warn (_("The %s section contains " |
| 2916 | "unsupported segment selector size: %d.\n"), |
| 2917 | section->name, segment_selector_size); |
| 2918 | return 0; |
| 2919 | } |
| 2920 | } |
| 2921 | |
| 2922 | SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr, |
| 2923 | linfo->li_offset_size, end); |
| 2924 | SAFE_BYTE_GET_AND_INC (linfo->li_min_insn_length, hdrptr, 1, end); |
| 2925 | |
| 2926 | if (linfo->li_version >= 4) |
| 2927 | { |
| 2928 | SAFE_BYTE_GET_AND_INC (linfo->li_max_ops_per_insn, hdrptr, 1, end); |
| 2929 | |
| 2930 | if (linfo->li_max_ops_per_insn == 0) |
| 2931 | { |
| 2932 | warn (_("Invalid maximum operations per insn.\n")); |
| 2933 | return NULL; |
| 2934 | } |
| 2935 | } |
| 2936 | else |
| 2937 | linfo->li_max_ops_per_insn = 1; |
| 2938 | |
| 2939 | SAFE_BYTE_GET_AND_INC (linfo->li_default_is_stmt, hdrptr, 1, end); |
| 2940 | SAFE_SIGNED_BYTE_GET_AND_INC (linfo->li_line_base, hdrptr, 1, end); |
| 2941 | SAFE_BYTE_GET_AND_INC (linfo->li_line_range, hdrptr, 1, end); |
| 2942 | SAFE_BYTE_GET_AND_INC (linfo->li_opcode_base, hdrptr, 1, end); |
| 2943 | |
| 2944 | * end_of_sequence = data + linfo->li_length + initial_length_size; |
| 2945 | /* PR 17512: file:002-117414-0.004. */ |
| 2946 | if (* end_of_sequence > end) |
| 2947 | { |
| 2948 | warn (_("Line length %s extends beyond end of section\n"), |
| 2949 | dwarf_vmatoa ("u", linfo->li_length)); |
| 2950 | * end_of_sequence = end; |
| 2951 | return NULL; |
| 2952 | } |
| 2953 | |
| 2954 | return hdrptr; |
| 2955 | } |
| 2956 | |
| 2957 | static unsigned char * |
| 2958 | display_formatted_table (unsigned char *data, |
| 2959 | unsigned char *start, unsigned char *end, |
| 2960 | const DWARF2_Internal_LineInfo *linfo, |
| 2961 | struct dwarf_section *section, const char *what) |
| 2962 | { |
| 2963 | unsigned char *format_start, format_count, *format, formati; |
| 2964 | dwarf_vma data_count, datai; |
| 2965 | unsigned int bytes_read, namepass, last_entry = 0; |
| 2966 | |
| 2967 | SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); |
| 2968 | format_start = data; |
| 2969 | for (formati = 0; formati < format_count; formati++) |
| 2970 | { |
| 2971 | read_uleb128 (data, & bytes_read, end); |
| 2972 | data += bytes_read; |
| 2973 | read_uleb128 (data, & bytes_read, end); |
| 2974 | data += bytes_read; |
| 2975 | if (data == end) |
| 2976 | { |
| 2977 | warn (_("Corrupt %s entry format table entry\n"), what); |
| 2978 | return data; |
| 2979 | } |
| 2980 | } |
| 2981 | |
| 2982 | data_count = read_uleb128 (data, & bytes_read, end); |
| 2983 | data += bytes_read; |
| 2984 | if (data == end) |
| 2985 | { |
| 2986 | warn (_("Corrupt %s list\n"), what); |
| 2987 | return data; |
| 2988 | } |
| 2989 | |
| 2990 | if (data_count == 0) |
| 2991 | { |
| 2992 | printf (_("\n The %s Table is empty.\n"), what); |
| 2993 | return data; |
| 2994 | } |
| 2995 | |
| 2996 | printf (_("\n The %s Table (offset 0x%lx):\n"), what, |
| 2997 | (long)(data - start)); |
| 2998 | |
| 2999 | printf (_(" Entry")); |
| 3000 | /* Delay displaying name as the last entry for better screen layout. */ |
| 3001 | for (namepass = 0; namepass < 2; namepass++) |
| 3002 | { |
| 3003 | format = format_start; |
| 3004 | for (formati = 0; formati < format_count; formati++) |
| 3005 | { |
| 3006 | dwarf_vma content_type; |
| 3007 | |
| 3008 | content_type = read_uleb128 (format, & bytes_read, end); |
| 3009 | format += bytes_read; |
| 3010 | if ((content_type == DW_LNCT_path) == (namepass == 1)) |
| 3011 | switch (content_type) |
| 3012 | { |
| 3013 | case DW_LNCT_path: |
| 3014 | printf (_("\tName")); |
| 3015 | break; |
| 3016 | case DW_LNCT_directory_index: |
| 3017 | printf (_("\tDir")); |
| 3018 | break; |
| 3019 | case DW_LNCT_timestamp: |
| 3020 | printf (_("\tTime")); |
| 3021 | break; |
| 3022 | case DW_LNCT_size: |
| 3023 | printf (_("\tSize")); |
| 3024 | break; |
| 3025 | case DW_LNCT_MD5: |
| 3026 | printf (_("\tMD5")); |
| 3027 | break; |
| 3028 | default: |
| 3029 | printf (_("\t(Unknown format content type %s)"), |
| 3030 | dwarf_vmatoa ("u", content_type)); |
| 3031 | } |
| 3032 | read_uleb128 (format, & bytes_read, end); |
| 3033 | format += bytes_read; |
| 3034 | } |
| 3035 | } |
| 3036 | putchar ('\n'); |
| 3037 | |
| 3038 | for (datai = 0; datai < data_count; datai++) |
| 3039 | { |
| 3040 | unsigned char *datapass = data; |
| 3041 | |
| 3042 | printf (" %d", last_entry++); |
| 3043 | /* Delay displaying name as the last entry for better screen layout. */ |
| 3044 | for (namepass = 0; namepass < 2; namepass++) |
| 3045 | { |
| 3046 | format = format_start; |
| 3047 | data = datapass; |
| 3048 | for (formati = 0; formati < format_count; formati++) |
| 3049 | { |
| 3050 | dwarf_vma content_type, form; |
| 3051 | |
| 3052 | content_type = read_uleb128 (format, & bytes_read, end); |
| 3053 | format += bytes_read; |
| 3054 | form = read_uleb128 (format, & bytes_read, end); |
| 3055 | format += bytes_read; |
| 3056 | data = read_and_display_attr_value (0, form, 0, data, end, 0, 0, |
| 3057 | linfo->li_offset_size, |
| 3058 | linfo->li_version, NULL, |
| 3059 | ((content_type == DW_LNCT_path) != (namepass == 1)), |
| 3060 | section, NULL, '\t'); |
| 3061 | } |
| 3062 | } |
| 3063 | if (data == end) |
| 3064 | { |
| 3065 | warn (_("Corrupt %s entries list\n"), what); |
| 3066 | return data; |
| 3067 | } |
| 3068 | putchar ('\n'); |
| 3069 | } |
| 3070 | return data; |
| 3071 | } |
| 3072 | |
| 3073 | static int |
| 3074 | display_debug_lines_raw (struct dwarf_section *section, |
| 3075 | unsigned char *data, |
| 3076 | unsigned char *end, void *file) |
| 3077 | { |
| 3078 | unsigned char *start = section->start; |
| 3079 | |
| 3080 | printf (_("Raw dump of debug contents of section %s:\n\n"), |
| 3081 | section->name); |
| 3082 | |
| 3083 | while (data < end) |
| 3084 | { |
| 3085 | static DWARF2_Internal_LineInfo saved_linfo; |
| 3086 | DWARF2_Internal_LineInfo linfo; |
| 3087 | unsigned char *standard_opcodes; |
| 3088 | unsigned char *end_of_sequence; |
| 3089 | int i; |
| 3090 | |
| 3091 | if (const_strneq (section->name, ".debug_line.") |
| 3092 | /* Note: the following does not apply to .debug_line.dwo sections. |
| 3093 | These are full debug_line sections. */ |
| 3094 | && strcmp (section->name, ".debug_line.dwo") != 0) |
| 3095 | { |
| 3096 | /* Sections named .debug_line.<foo> are fragments of a .debug_line |
| 3097 | section containing just the Line Number Statements. They are |
| 3098 | created by the assembler and intended to be used alongside gcc's |
| 3099 | -ffunction-sections command line option. When the linker's |
| 3100 | garbage collection decides to discard a .text.<foo> section it |
| 3101 | can then also discard the line number information in .debug_line.<foo>. |
| 3102 | |
| 3103 | Since the section is a fragment it does not have the details |
| 3104 | needed to fill out a LineInfo structure, so instead we use the |
| 3105 | details from the last full debug_line section that we processed. */ |
| 3106 | end_of_sequence = end; |
| 3107 | standard_opcodes = NULL; |
| 3108 | linfo = saved_linfo; |
| 3109 | /* PR 17531: file: 0522b371. */ |
| 3110 | if (linfo.li_line_range == 0) |
| 3111 | { |
| 3112 | warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n")); |
| 3113 | return 0; |
| 3114 | } |
| 3115 | reset_state_machine (linfo.li_default_is_stmt); |
| 3116 | } |
| 3117 | else |
| 3118 | { |
| 3119 | unsigned char * hdrptr; |
| 3120 | |
| 3121 | if ((hdrptr = read_debug_line_header (section, data, end, & linfo, |
| 3122 | & end_of_sequence)) == NULL) |
| 3123 | return 0; |
| 3124 | |
| 3125 | printf (_(" Offset: 0x%lx\n"), (long)(data - start)); |
| 3126 | printf (_(" Length: %ld\n"), (long) linfo.li_length); |
| 3127 | printf (_(" DWARF Version: %d\n"), linfo.li_version); |
| 3128 | printf (_(" Prologue Length: %d\n"), (int) linfo.li_prologue_length); |
| 3129 | printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length); |
| 3130 | if (linfo.li_version >= 4) |
| 3131 | printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn); |
| 3132 | printf (_(" Initial value of 'is_stmt': %d\n"), linfo.li_default_is_stmt); |
| 3133 | printf (_(" Line Base: %d\n"), linfo.li_line_base); |
| 3134 | printf (_(" Line Range: %d\n"), linfo.li_line_range); |
| 3135 | printf (_(" Opcode Base: %d\n"), linfo.li_opcode_base); |
| 3136 | |
| 3137 | /* PR 17512: file: 1665-6428-0.004. */ |
| 3138 | if (linfo.li_line_range == 0) |
| 3139 | { |
| 3140 | warn (_("Line range of 0 is invalid, using 1 instead\n")); |
| 3141 | linfo.li_line_range = 1; |
| 3142 | } |
| 3143 | |
| 3144 | reset_state_machine (linfo.li_default_is_stmt); |
| 3145 | |
| 3146 | /* Display the contents of the Opcodes table. */ |
| 3147 | standard_opcodes = hdrptr; |
| 3148 | |
| 3149 | /* PR 17512: file: 002-417945-0.004. */ |
| 3150 | if (standard_opcodes + linfo.li_opcode_base >= end) |
| 3151 | { |
| 3152 | warn (_("Line Base extends beyond end of section\n")); |
| 3153 | return 0; |
| 3154 | } |
| 3155 | |
| 3156 | printf (_("\n Opcodes:\n")); |
| 3157 | |
| 3158 | for (i = 1; i < linfo.li_opcode_base; i++) |
| 3159 | printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]); |
| 3160 | |
| 3161 | /* Display the contents of the Directory table. */ |
| 3162 | data = standard_opcodes + linfo.li_opcode_base - 1; |
| 3163 | |
| 3164 | if (linfo.li_version >= 5) |
| 3165 | { |
| 3166 | load_debug_section (line_str, file); |
| 3167 | |
| 3168 | data = display_formatted_table (data, start, end, &linfo, section, |
| 3169 | _("Directory")); |
| 3170 | data = display_formatted_table (data, start, end, &linfo, section, |
| 3171 | _("File name")); |
| 3172 | } |
| 3173 | else |
| 3174 | { |
| 3175 | if (*data == 0) |
| 3176 | printf (_("\n The Directory Table is empty.\n")); |
| 3177 | else |
| 3178 | { |
| 3179 | unsigned int last_dir_entry = 0; |
| 3180 | |
| 3181 | printf (_("\n The Directory Table (offset 0x%lx):\n"), |
| 3182 | (long)(data - start)); |
| 3183 | |
| 3184 | while (data < end && *data != 0) |
| 3185 | { |
| 3186 | printf (" %d\t%.*s\n", ++last_dir_entry, (int) (end - data), data); |
| 3187 | |
| 3188 | data += strnlen ((char *) data, end - data) + 1; |
| 3189 | } |
| 3190 | |
| 3191 | /* PR 17512: file: 002-132094-0.004. */ |
| 3192 | if (data >= end - 1) |
| 3193 | break; |
| 3194 | } |
| 3195 | |
| 3196 | /* Skip the NUL at the end of the table. */ |
| 3197 | data++; |
| 3198 | |
| 3199 | /* Display the contents of the File Name table. */ |
| 3200 | if (*data == 0) |
| 3201 | printf (_("\n The File Name Table is empty.\n")); |
| 3202 | else |
| 3203 | { |
| 3204 | printf (_("\n The File Name Table (offset 0x%lx):\n"), |
| 3205 | (long)(data - start)); |
| 3206 | printf (_(" Entry\tDir\tTime\tSize\tName\n")); |
| 3207 | |
| 3208 | while (data < end && *data != 0) |
| 3209 | { |
| 3210 | unsigned char *name; |
| 3211 | unsigned int bytes_read; |
| 3212 | |
| 3213 | printf (" %d\t", ++state_machine_regs.last_file_entry); |
| 3214 | name = data; |
| 3215 | data += strnlen ((char *) data, end - data) + 1; |
| 3216 | |
| 3217 | printf ("%s\t", |
| 3218 | dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
| 3219 | data += bytes_read; |
| 3220 | printf ("%s\t", |
| 3221 | dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
| 3222 | data += bytes_read; |
| 3223 | printf ("%s\t", |
| 3224 | dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); |
| 3225 | data += bytes_read; |
| 3226 | printf ("%.*s\n", (int)(end - name), name); |
| 3227 | |
| 3228 | if (data == end) |
| 3229 | { |
| 3230 | warn (_("Corrupt file name table entry\n")); |
| 3231 | break; |
| 3232 | } |
| 3233 | } |
| 3234 | } |
| 3235 | |
| 3236 | /* Skip the NUL at the end of the table. */ |
| 3237 | data++; |
| 3238 | } |
| 3239 | |
| 3240 | putchar ('\n'); |
| 3241 | saved_linfo = linfo; |
| 3242 | } |
| 3243 | |
| 3244 | /* Now display the statements. */ |
| 3245 | if (data >= end_of_sequence) |
| 3246 | printf (_(" No Line Number Statements.\n")); |
| 3247 | else |
| 3248 | { |
| 3249 | printf (_(" Line Number Statements:\n")); |
| 3250 | |
| 3251 | while (data < end_of_sequence) |
| 3252 | { |
| 3253 | unsigned char op_code; |
| 3254 | dwarf_signed_vma adv; |
| 3255 | dwarf_vma uladv; |
| 3256 | unsigned int bytes_read; |
| 3257 | |
| 3258 | printf (" [0x%08lx]", (long)(data - start)); |
| 3259 | |
| 3260 | op_code = *data++; |
| 3261 | |
| 3262 | if (op_code >= linfo.li_opcode_base) |
| 3263 | { |
| 3264 | op_code -= linfo.li_opcode_base; |
| 3265 | uladv = (op_code / linfo.li_line_range); |
| 3266 | if (linfo.li_max_ops_per_insn == 1) |
| 3267 | { |
| 3268 | uladv *= linfo.li_min_insn_length; |
| 3269 | state_machine_regs.address += uladv; |
| 3270 | printf (_(" Special opcode %d: " |
| 3271 | "advance Address by %s to 0x%s"), |
| 3272 | op_code, dwarf_vmatoa ("u", uladv), |
| 3273 | dwarf_vmatoa ("x", state_machine_regs.address)); |
| 3274 | } |
| 3275 | else |
| 3276 | { |
| 3277 | state_machine_regs.address |
| 3278 | += ((state_machine_regs.op_index + uladv) |
| 3279 | / linfo.li_max_ops_per_insn) |
| 3280 | * linfo.li_min_insn_length; |
| 3281 | state_machine_regs.op_index |
| 3282 | = (state_machine_regs.op_index + uladv) |
| 3283 | % linfo.li_max_ops_per_insn; |
| 3284 | printf (_(" Special opcode %d: " |
| 3285 | "advance Address by %s to 0x%s[%d]"), |
| 3286 | op_code, dwarf_vmatoa ("u", uladv), |
| 3287 | dwarf_vmatoa ("x", state_machine_regs.address), |
| 3288 | state_machine_regs.op_index); |
| 3289 | } |
| 3290 | adv = (op_code % linfo.li_line_range) + linfo.li_line_base; |
| 3291 | state_machine_regs.line += adv; |
| 3292 | printf (_(" and Line by %s to %d\n"), |
| 3293 | dwarf_vmatoa ("d", adv), state_machine_regs.line); |
| 3294 | } |
| 3295 | else switch (op_code) |
| 3296 | { |
| 3297 | case DW_LNS_extended_op: |
| 3298 | data += process_extended_line_op (data, linfo.li_default_is_stmt, end); |
| 3299 | break; |
| 3300 | |
| 3301 | case DW_LNS_copy: |
| 3302 | printf (_(" Copy\n")); |
| 3303 | break; |
| 3304 | |
| 3305 | case DW_LNS_advance_pc: |
| 3306 | uladv = read_uleb128 (data, & bytes_read, end); |
| 3307 | data += bytes_read; |
| 3308 | if (linfo.li_max_ops_per_insn == 1) |
| 3309 | { |
| 3310 | uladv *= linfo.li_min_insn_length; |
| 3311 | state_machine_regs.address += uladv; |
| 3312 | printf (_(" Advance PC by %s to 0x%s\n"), |
| 3313 | dwarf_vmatoa ("u", uladv), |
| 3314 | dwarf_vmatoa ("x", state_machine_regs.address)); |
| 3315 | } |
| 3316 | else |
| 3317 | { |
| 3318 | state_machine_regs.address |
| 3319 | += ((state_machine_regs.op_index + uladv) |
| 3320 | / linfo.li_max_ops_per_insn) |
| 3321 | * linfo.li_min_insn_length; |
| 3322 | state_machine_regs.op_index |
| 3323 | = (state_machine_regs.op_index + uladv) |
| 3324 | % linfo.li_max_ops_per_insn; |
| 3325 | printf (_(" Advance PC by %s to 0x%s[%d]\n"), |
| 3326 | dwarf_vmatoa ("u", uladv), |
| 3327 | dwarf_vmatoa ("x", state_machine_regs.address), |
| 3328 | state_machine_regs.op_index); |
| 3329 | } |
| 3330 | break; |
| 3331 | |
| 3332 | case DW_LNS_advance_line: |
| 3333 | adv = read_sleb128 (data, & bytes_read, end); |
| 3334 | data += bytes_read; |
| 3335 | state_machine_regs.line += adv; |
| 3336 | printf (_(" Advance Line by %s to %d\n"), |
| 3337 | dwarf_vmatoa ("d", adv), |
| 3338 | state_machine_regs.line); |
| 3339 | break; |
| 3340 | |
| 3341 | case DW_LNS_set_file: |
| 3342 | adv = read_uleb128 (data, & bytes_read, end); |
| 3343 | data += bytes_read; |
| 3344 | printf (_(" Set File Name to entry %s in the File Name Table\n"), |
| 3345 | dwarf_vmatoa ("d", adv)); |
| 3346 | state_machine_regs.file = adv; |
| 3347 | break; |
| 3348 | |
| 3349 | case DW_LNS_set_column: |
| 3350 | uladv = read_uleb128 (data, & bytes_read, end); |
| 3351 | data += bytes_read; |
| 3352 | printf (_(" Set column to %s\n"), |
| 3353 | dwarf_vmatoa ("u", uladv)); |
| 3354 | state_machine_regs.column = uladv; |
| 3355 | break; |
| 3356 | |
| 3357 | case DW_LNS_negate_stmt: |
| 3358 | adv = state_machine_regs.is_stmt; |
| 3359 | adv = ! adv; |
| 3360 | printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv)); |
| 3361 | state_machine_regs.is_stmt = adv; |
| 3362 | break; |
| 3363 | |
| 3364 | case DW_LNS_set_basic_block: |
| 3365 | printf (_(" Set basic block\n")); |
| 3366 | state_machine_regs.basic_block = 1; |
| 3367 | break; |
| 3368 | |
| 3369 | case DW_LNS_const_add_pc: |
| 3370 | uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); |
| 3371 | if (linfo.li_max_ops_per_insn) |
| 3372 | { |
| 3373 | uladv *= linfo.li_min_insn_length; |
| 3374 | state_machine_regs.address += uladv; |
| 3375 | printf (_(" Advance PC by constant %s to 0x%s\n"), |
| 3376 | dwarf_vmatoa ("u", uladv), |
| 3377 | dwarf_vmatoa ("x", state_machine_regs.address)); |
| 3378 | } |
| 3379 | else |
| 3380 | { |
| 3381 | state_machine_regs.address |
| 3382 | += ((state_machine_regs.op_index + uladv) |
| 3383 | / linfo.li_max_ops_per_insn) |
| 3384 | * linfo.li_min_insn_length; |
| 3385 | state_machine_regs.op_index |
| 3386 | = (state_machine_regs.op_index + uladv) |
| 3387 | % linfo.li_max_ops_per_insn; |
| 3388 | printf (_(" Advance PC by constant %s to 0x%s[%d]\n"), |
| 3389 | dwarf_vmatoa ("u", uladv), |
| 3390 | dwarf_vmatoa ("x", state_machine_regs.address), |
| 3391 | state_machine_regs.op_index); |
| 3392 | } |
| 3393 | break; |
| 3394 | |
| 3395 | case DW_LNS_fixed_advance_pc: |
| 3396 | SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); |
| 3397 | state_machine_regs.address += uladv; |
| 3398 | state_machine_regs.op_index = 0; |
| 3399 | printf (_(" Advance PC by fixed size amount %s to 0x%s\n"), |
| 3400 | dwarf_vmatoa ("u", uladv), |
| 3401 | dwarf_vmatoa ("x", state_machine_regs.address)); |
| 3402 | break; |
| 3403 | |
| 3404 | case DW_LNS_set_prologue_end: |
| 3405 | printf (_(" Set prologue_end to true\n")); |
| 3406 | break; |
| 3407 | |
| 3408 | case DW_LNS_set_epilogue_begin: |
| 3409 | printf (_(" Set epilogue_begin to true\n")); |
| 3410 | break; |
| 3411 | |
| 3412 | case DW_LNS_set_isa: |
| 3413 | uladv = read_uleb128 (data, & bytes_read, end); |
| 3414 | data += bytes_read; |
| 3415 | printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv)); |
| 3416 | break; |
| 3417 | |
| 3418 | default: |
| 3419 | printf (_(" Unknown opcode %d with operands: "), op_code); |
| 3420 | |
| 3421 | if (standard_opcodes != NULL) |
| 3422 | for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) |
| 3423 | { |
| 3424 | printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data, |
| 3425 | &bytes_read, end)), |
| 3426 | i == 1 ? "" : ", "); |
| 3427 | data += bytes_read; |
| 3428 | } |
| 3429 | putchar ('\n'); |
| 3430 | break; |
| 3431 | } |
| 3432 | } |
| 3433 | putchar ('\n'); |
| 3434 | } |
| 3435 | } |
| 3436 | |
| 3437 | return 1; |
| 3438 | } |
| 3439 | |
| 3440 | typedef struct |
| 3441 | { |
| 3442 | unsigned char *name; |
| 3443 | unsigned int directory_index; |
| 3444 | unsigned int modification_date; |
| 3445 | unsigned int length; |
| 3446 | } File_Entry; |
| 3447 | |
| 3448 | /* Output a decoded representation of the .debug_line section. */ |
| 3449 | |
| 3450 | static int |
| 3451 | display_debug_lines_decoded (struct dwarf_section *section, |
| 3452 | unsigned char *data, |
| 3453 | unsigned char *end, void *fileptr) |
| 3454 | { |
| 3455 | static DWARF2_Internal_LineInfo saved_linfo; |
| 3456 | |
| 3457 | printf (_("Decoded dump of debug contents of section %s:\n\n"), |
| 3458 | section->name); |
| 3459 | |
| 3460 | while (data < end) |
| 3461 | { |
| 3462 | /* This loop amounts to one iteration per compilation unit. */ |
| 3463 | DWARF2_Internal_LineInfo linfo; |
| 3464 | unsigned char *standard_opcodes; |
| 3465 | unsigned char *end_of_sequence; |
| 3466 | int i; |
| 3467 | File_Entry *file_table = NULL; |
| 3468 | unsigned int n_files = 0; |
| 3469 | unsigned char **directory_table = NULL; |
| 3470 | dwarf_vma n_directories = 0; |
| 3471 | |
| 3472 | if (const_strneq (section->name, ".debug_line.") |
| 3473 | /* Note: the following does not apply to .debug_line.dwo sections. |
| 3474 | These are full debug_line sections. */ |
| 3475 | && strcmp (section->name, ".debug_line.dwo") != 0) |
| 3476 | { |
| 3477 | /* See comment in display_debug_lines_raw(). */ |
| 3478 | end_of_sequence = end; |
| 3479 | standard_opcodes = NULL; |
| 3480 | linfo = saved_linfo; |
| 3481 | /* PR 17531: file: 0522b371. */ |
| 3482 | if (linfo.li_line_range == 0) |
| 3483 | { |
| 3484 | warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n")); |
| 3485 | return 0; |
| 3486 | } |
| 3487 | reset_state_machine (linfo.li_default_is_stmt); |
| 3488 | } |
| 3489 | else |
| 3490 | { |
| 3491 | unsigned char *hdrptr; |
| 3492 | |
| 3493 | if ((hdrptr = read_debug_line_header (section, data, end, & linfo, |
| 3494 | & end_of_sequence)) == NULL) |
| 3495 | return 0; |
| 3496 | |
| 3497 | /* PR 17531: file: 0522b371. */ |
| 3498 | if (linfo.li_line_range == 0) |
| 3499 | { |
| 3500 | warn (_("Line range of 0 is invalid, using 1 instead\n")); |
| 3501 | linfo.li_line_range = 1; |
| 3502 | } |
| 3503 | reset_state_machine (linfo.li_default_is_stmt); |
| 3504 | |
| 3505 | /* Save a pointer to the contents of the Opcodes table. */ |
| 3506 | standard_opcodes = hdrptr; |
| 3507 | |
| 3508 | /* Traverse the Directory table just to count entries. */ |
| 3509 | data = standard_opcodes + linfo.li_opcode_base - 1; |
| 3510 | /* PR 20440 */ |
| 3511 | if (data >= end) |
| 3512 | { |
| 3513 | warn (_("opcode base of %d extends beyond end of section\n"), |
| 3514 | linfo.li_opcode_base); |
| 3515 | return 0; |
| 3516 | } |
| 3517 | |
| 3518 | if (linfo.li_version >= 5) |
| 3519 | { |
| 3520 | unsigned char *format_start, format_count, *format; |
| 3521 | dwarf_vma formati, entryi; |
| 3522 | unsigned int bytes_read; |
| 3523 | |
| 3524 | load_debug_section (line_str, fileptr); |
| 3525 | |
| 3526 | /* Skip directories format. */ |
| 3527 | SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); |
| 3528 | format_start = data; |
| 3529 | for (formati = 0; formati < format_count; formati++) |
| 3530 | { |
| 3531 | read_uleb128 (data, & bytes_read, end); |
| 3532 | data += bytes_read; |
| 3533 | read_uleb128 (data, & bytes_read, end); |
| 3534 | data += bytes_read; |
| 3535 | } |
| 3536 | |
| 3537 | n_directories = read_uleb128 (data, & bytes_read, end); |
| 3538 | data += bytes_read; |
| 3539 | if (data == end) |
| 3540 | { |
| 3541 | warn (_("Corrupt directories list\n")); |
| 3542 | break; |
| 3543 | } |
| 3544 | |
| 3545 | directory_table = (unsigned char **) |
| 3546 | xmalloc (n_directories * sizeof (unsigned char *)); |
| 3547 | |
| 3548 | for (entryi = 0; entryi < n_directories; entryi++) |
| 3549 | { |
| 3550 | unsigned char **pathp = &directory_table[entryi]; |
| 3551 | |
| 3552 | format = format_start; |
| 3553 | for (formati = 0; formati < format_count; formati++) |
| 3554 | { |
| 3555 | dwarf_vma content_type, form; |
| 3556 | dwarf_vma uvalue; |
| 3557 | |
| 3558 | content_type = read_uleb128 (format, & bytes_read, end); |
| 3559 | format += bytes_read; |
| 3560 | form = read_uleb128 (format, & bytes_read, end); |
| 3561 | format += bytes_read; |
| 3562 | if (data == end) |
| 3563 | { |
| 3564 | warn (_("Corrupt directories list\n")); |
| 3565 | break; |
| 3566 | } |
| 3567 | switch (content_type) |
| 3568 | { |
| 3569 | case DW_LNCT_path: |
| 3570 | switch (form) |
| 3571 | { |
| 3572 | case DW_FORM_string: |
| 3573 | *pathp = data; |
| 3574 | break; |
| 3575 | case DW_FORM_line_strp: |
| 3576 | SAFE_BYTE_GET (uvalue, data, linfo.li_offset_size, |
| 3577 | end); |
| 3578 | /* Remove const by the cast. */ |
| 3579 | *pathp = (unsigned char *) |
| 3580 | fetch_indirect_line_string (uvalue); |
| 3581 | break; |
| 3582 | } |
| 3583 | break; |
| 3584 | } |
| 3585 | data = read_and_display_attr_value (0, form, 0, data, end, |
| 3586 | 0, 0, |
| 3587 | linfo.li_offset_size, |
| 3588 | linfo.li_version, |
| 3589 | NULL, 1, section, |
| 3590 | NULL, '\t'); |
| 3591 | } |
| 3592 | if (data == end) |
| 3593 | { |
| 3594 | warn (_("Corrupt directories list\n")); |
| 3595 | break; |
| 3596 | } |
| 3597 | } |
| 3598 | |
| 3599 | /* Skip files format. */ |
| 3600 | SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); |
| 3601 | format_start = data; |
| 3602 | for (formati = 0; formati < format_count; formati++) |
| 3603 | { |
| 3604 | read_uleb128 (data, & bytes_read, end); |
| 3605 | data += bytes_read; |
| 3606 | read_uleb128 (data, & bytes_read, end); |
| 3607 | data += bytes_read; |
| 3608 | } |
| 3609 | |
| 3610 | n_files = read_uleb128 (data, & bytes_read, end); |
| 3611 | data += bytes_read; |
| 3612 | if (data == end) |
| 3613 | { |
| 3614 | warn (_("Corrupt file name list\n")); |
| 3615 | break; |
| 3616 | } |
| 3617 | |
| 3618 | file_table = (File_Entry *) xcalloc (1, n_files |
| 3619 | * sizeof (File_Entry)); |
| 3620 | |
| 3621 | for (entryi = 0; entryi < n_files; entryi++) |
| 3622 | { |
| 3623 | File_Entry *file = &file_table[entryi]; |
| 3624 | |
| 3625 | format = format_start; |
| 3626 | for (formati = 0; formati < format_count; formati++) |
| 3627 | { |
| 3628 | dwarf_vma content_type, form; |
| 3629 | dwarf_vma uvalue; |
| 3630 | |
| 3631 | content_type = read_uleb128 (format, & bytes_read, end); |
| 3632 | format += bytes_read; |
| 3633 | form = read_uleb128 (format, & bytes_read, end); |
| 3634 | format += bytes_read; |
| 3635 | if (data == end) |
| 3636 | { |
| 3637 | warn (_("Corrupt file name list\n")); |
| 3638 | break; |
| 3639 | } |
| 3640 | switch (content_type) |
| 3641 | { |
| 3642 | case DW_LNCT_path: |
| 3643 | switch (form) |
| 3644 | { |
| 3645 | case DW_FORM_string: |
| 3646 | file->name = data; |
| 3647 | break; |
| 3648 | case DW_FORM_line_strp: |
| 3649 | SAFE_BYTE_GET (uvalue, data, linfo.li_offset_size, |
| 3650 | end); |
| 3651 | /* Remove const by the cast. */ |
| 3652 | file->name = (unsigned char *) |
| 3653 | fetch_indirect_line_string (uvalue); |
| 3654 | break; |
| 3655 | } |
| 3656 | break; |
| 3657 | case DW_LNCT_directory_index: |
| 3658 | switch (form) |
| 3659 | { |
| 3660 | case DW_FORM_data1: |
| 3661 | SAFE_BYTE_GET (file->directory_index, data, 1, |
| 3662 | end); |
| 3663 | break; |
| 3664 | case DW_FORM_data2: |
| 3665 | SAFE_BYTE_GET (file->directory_index, data, 2, |
| 3666 | end); |
| 3667 | break; |
| 3668 | case DW_FORM_udata: |
| 3669 | file->directory_index = read_uleb128 (data, NULL, |
| 3670 | end); |
| 3671 | break; |
| 3672 | } |
| 3673 | break; |
| 3674 | } |
| 3675 | data = read_and_display_attr_value (0, form, 0, data, end, |
| 3676 | 0, 0, |
| 3677 | linfo.li_offset_size, |
| 3678 | linfo.li_version, |
| 3679 | NULL, 1, section, |
| 3680 | NULL, '\t'); |
| 3681 | } |
| 3682 | if (data == end) |
| 3683 | { |
| 3684 | warn (_("Corrupt file name list\n")); |
| 3685 | break; |
| 3686 | } |
| 3687 | } |
| 3688 | } |
| 3689 | else |
| 3690 | { |
| 3691 | if (*data != 0) |
| 3692 | { |
| 3693 | unsigned char *ptr_directory_table = data; |
| 3694 | |
| 3695 | while (data < end && *data != 0) |
| 3696 | { |
| 3697 | data += strnlen ((char *) data, end - data) + 1; |
| 3698 | n_directories++; |
| 3699 | } |
| 3700 | |
| 3701 | /* PR 20440 */ |
| 3702 | if (data >= end) |
| 3703 | { |
| 3704 | warn (_("directory table ends unexpectedly\n")); |
| 3705 | n_directories = 0; |
| 3706 | break; |
| 3707 | } |
| 3708 | |
| 3709 | /* Go through the directory table again to save the directories. */ |
| 3710 | directory_table = (unsigned char **) |
| 3711 | xmalloc (n_directories * sizeof (unsigned char *)); |
| 3712 | |
| 3713 | i = 0; |
| 3714 | while (*ptr_directory_table != 0) |
| 3715 | { |
| 3716 | directory_table[i] = ptr_directory_table; |
| 3717 | ptr_directory_table += strnlen ((char *) ptr_directory_table, |
| 3718 | ptr_directory_table - end) + 1; |
| 3719 | i++; |
| 3720 | } |
| 3721 | } |
| 3722 | /* Skip the NUL at the end of the table. */ |
| 3723 | data++; |
| 3724 | |
| 3725 | /* Traverse the File Name table just to count the entries. */ |
| 3726 | if (data < end && *data != 0) |
| 3727 | { |
| 3728 | unsigned char *ptr_file_name_table = data; |
| 3729 | |
| 3730 | while (data < end && *data != 0) |
| 3731 | { |
| 3732 | unsigned int bytes_read; |
| 3733 | |
| 3734 | /* Skip Name, directory index, last modification time and length |
| 3735 | of file. */ |
| 3736 | data += strnlen ((char *) data, end - data) + 1; |
| 3737 | read_uleb128 (data, & bytes_read, end); |
| 3738 | data += bytes_read; |
| 3739 | read_uleb128 (data, & bytes_read, end); |
| 3740 | data += bytes_read; |
| 3741 | read_uleb128 (data, & bytes_read, end); |
| 3742 | data += bytes_read; |
| 3743 | |
| 3744 | n_files++; |
| 3745 | } |
| 3746 | |
| 3747 | if (data >= end) |
| 3748 | { |
| 3749 | warn (_("file table ends unexpectedly\n")); |
| 3750 | n_files = 0; |
| 3751 | break; |
| 3752 | } |
| 3753 | |
| 3754 | /* Go through the file table again to save the strings. */ |
| 3755 | file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry)); |
| 3756 | |
| 3757 | i = 0; |
| 3758 | while (*ptr_file_name_table != 0) |
| 3759 | { |
| 3760 | unsigned int bytes_read; |
| 3761 | |
| 3762 | file_table[i].name = ptr_file_name_table; |
| 3763 | ptr_file_name_table += strnlen ((char *) ptr_file_name_table, |
| 3764 | end - ptr_file_name_table) + 1; |
| 3765 | |
| 3766 | /* We are not interested in directory, time or size. */ |
| 3767 | file_table[i].directory_index = read_uleb128 (ptr_file_name_table, |
| 3768 | & bytes_read, end); |
| 3769 | ptr_file_name_table += bytes_read; |
| 3770 | file_table[i].modification_date = read_uleb128 (ptr_file_name_table, |
| 3771 | & bytes_read, end); |
| 3772 | ptr_file_name_table += bytes_read; |
| 3773 | file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end); |
| 3774 | ptr_file_name_table += bytes_read; |
| 3775 | i++; |
| 3776 | } |
| 3777 | i = 0; |
| 3778 | } |
| 3779 | |
| 3780 | /* Skip the NUL at the end of the table. */ |
| 3781 | data++; |
| 3782 | } |
| 3783 | |
| 3784 | /* Print the Compilation Unit's name and a header. */ |
| 3785 | if (directory_table == NULL) |
| 3786 | { |
| 3787 | printf (_("CU: %s:\n"), file_table[0].name); |
| 3788 | printf (_("File name Line number Starting address\n")); |
| 3789 | } |
| 3790 | else |
| 3791 | { |
| 3792 | unsigned int ix = file_table[0].directory_index; |
| 3793 | const char *directory; |
| 3794 | |
| 3795 | if (ix == 0) |
| 3796 | directory = "."; |
| 3797 | /* PR 20439 */ |
| 3798 | else if (n_directories == 0) |
| 3799 | directory = _("<unknown>"); |
| 3800 | else if (ix > n_directories) |
| 3801 | { |
| 3802 | warn (_("directory index %u > number of directories %s\n"), |
| 3803 | ix, dwarf_vmatoa ("u", n_directories)); |
| 3804 | directory = _("<corrupt>"); |
| 3805 | } |
| 3806 | else |
| 3807 | directory = (char *) directory_table[ix - 1]; |
| 3808 | |
| 3809 | if (do_wide || strlen (directory) < 76) |
| 3810 | printf (_("CU: %s/%s:\n"), directory, file_table[0].name); |
| 3811 | else |
| 3812 | printf ("%s:\n", file_table[0].name); |
| 3813 | |
| 3814 | printf (_("File name Line number Starting address\n")); |
| 3815 | } |
| 3816 | |
| 3817 | saved_linfo = linfo; |
| 3818 | } |
| 3819 | |
| 3820 | /* This loop iterates through the Dwarf Line Number Program. */ |
| 3821 | while (data < end_of_sequence) |
| 3822 | { |
| 3823 | unsigned char op_code; |
| 3824 | int adv; |
| 3825 | unsigned long int uladv; |
| 3826 | unsigned int bytes_read; |
| 3827 | int is_special_opcode = 0; |
| 3828 | |
| 3829 | op_code = *data++; |
| 3830 | |
| 3831 | if (op_code >= linfo.li_opcode_base) |
| 3832 | { |
| 3833 | op_code -= linfo.li_opcode_base; |
| 3834 | uladv = (op_code / linfo.li_line_range); |
| 3835 | if (linfo.li_max_ops_per_insn == 1) |
| 3836 | { |
| 3837 | uladv *= linfo.li_min_insn_length; |
| 3838 | state_machine_regs.address += uladv; |
| 3839 | } |
| 3840 | else |
| 3841 | { |
| 3842 | state_machine_regs.address |
| 3843 | += ((state_machine_regs.op_index + uladv) |
| 3844 | / linfo.li_max_ops_per_insn) |
| 3845 | * linfo.li_min_insn_length; |
| 3846 | state_machine_regs.op_index |
| 3847 | = (state_machine_regs.op_index + uladv) |
| 3848 | % linfo.li_max_ops_per_insn; |
| 3849 | } |
| 3850 | |
| 3851 | adv = (op_code % linfo.li_line_range) + linfo.li_line_base; |
| 3852 | state_machine_regs.line += adv; |
| 3853 | is_special_opcode = 1; |
| 3854 | } |
| 3855 | else switch (op_code) |
| 3856 | { |
| 3857 | case DW_LNS_extended_op: |
| 3858 | { |
| 3859 | unsigned int ext_op_code_len; |
| 3860 | unsigned char ext_op_code; |
| 3861 | unsigned char *op_code_data = data; |
| 3862 | |
| 3863 | ext_op_code_len = read_uleb128 (op_code_data, &bytes_read, |
| 3864 | end_of_sequence); |
| 3865 | op_code_data += bytes_read; |
| 3866 | |
| 3867 | if (ext_op_code_len == 0) |
| 3868 | { |
| 3869 | warn (_("Badly formed extended line op encountered!\n")); |
| 3870 | break; |
| 3871 | } |
| 3872 | ext_op_code_len += bytes_read; |
| 3873 | ext_op_code = *op_code_data++; |
| 3874 | |
| 3875 | switch (ext_op_code) |
| 3876 | { |
| 3877 | case DW_LNE_end_sequence: |
| 3878 | reset_state_machine (linfo.li_default_is_stmt); |
| 3879 | break; |
| 3880 | case DW_LNE_set_address: |
| 3881 | SAFE_BYTE_GET_AND_INC (state_machine_regs.address, |
| 3882 | op_code_data, |
| 3883 | ext_op_code_len - bytes_read - 1, |
| 3884 | end); |
| 3885 | state_machine_regs.op_index = 0; |
| 3886 | break; |
| 3887 | case DW_LNE_define_file: |
| 3888 | { |
| 3889 | file_table = (File_Entry *) xrealloc |
| 3890 | (file_table, (n_files + 1) * sizeof (File_Entry)); |
| 3891 | |
| 3892 | ++state_machine_regs.last_file_entry; |
| 3893 | /* Source file name. */ |
| 3894 | file_table[n_files].name = op_code_data; |
| 3895 | op_code_data += strlen ((char *) op_code_data) + 1; |
| 3896 | /* Directory index. */ |
| 3897 | file_table[n_files].directory_index = |
| 3898 | read_uleb128 (op_code_data, & bytes_read, |
| 3899 | end_of_sequence); |
| 3900 | op_code_data += bytes_read; |
| 3901 | /* Last modification time. */ |
| 3902 | file_table[n_files].modification_date = |
| 3903 | read_uleb128 (op_code_data, & bytes_read, |
| 3904 | end_of_sequence); |
| 3905 | op_code_data += bytes_read; |
| 3906 | /* File length. */ |
| 3907 | file_table[n_files].length = |
| 3908 | read_uleb128 (op_code_data, & bytes_read, |
| 3909 | end_of_sequence); |
| 3910 | |
| 3911 | n_files++; |
| 3912 | break; |
| 3913 | } |
| 3914 | case DW_LNE_set_discriminator: |
| 3915 | case DW_LNE_HP_set_sequence: |
| 3916 | /* Simply ignored. */ |
| 3917 | break; |
| 3918 | |
| 3919 | default: |
| 3920 | printf (_("UNKNOWN (%u): length %d\n"), |
| 3921 | ext_op_code, ext_op_code_len - bytes_read); |
| 3922 | break; |
| 3923 | } |
| 3924 | data += ext_op_code_len; |
| 3925 | break; |
| 3926 | } |
| 3927 | case DW_LNS_copy: |
| 3928 | break; |
| 3929 | |
| 3930 | case DW_LNS_advance_pc: |
| 3931 | uladv = read_uleb128 (data, & bytes_read, end); |
| 3932 | data += bytes_read; |
| 3933 | if (linfo.li_max_ops_per_insn == 1) |
| 3934 | { |
| 3935 | uladv *= linfo.li_min_insn_length; |
| 3936 | state_machine_regs.address += uladv; |
| 3937 | } |
| 3938 | else |
| 3939 | { |
| 3940 | state_machine_regs.address |
| 3941 | += ((state_machine_regs.op_index + uladv) |
| 3942 | / linfo.li_max_ops_per_insn) |
| 3943 | * linfo.li_min_insn_length; |
| 3944 | state_machine_regs.op_index |
| 3945 | = (state_machine_regs.op_index + uladv) |
| 3946 | % linfo.li_max_ops_per_insn; |
| 3947 | } |
| 3948 | break; |
| 3949 | |
| 3950 | case DW_LNS_advance_line: |
| 3951 | adv = read_sleb128 (data, & bytes_read, end); |
| 3952 | data += bytes_read; |
| 3953 | state_machine_regs.line += adv; |
| 3954 | break; |
| 3955 | |
| 3956 | case DW_LNS_set_file: |
| 3957 | adv = read_uleb128 (data, & bytes_read, end); |
| 3958 | data += bytes_read; |
| 3959 | state_machine_regs.file = adv; |
| 3960 | |
| 3961 | { |
| 3962 | unsigned file = state_machine_regs.file - 1; |
| 3963 | unsigned dir; |
| 3964 | |
| 3965 | if (file_table == NULL || n_files == 0) |
| 3966 | printf (_("\n [Use file table entry %d]\n"), file); |
| 3967 | /* PR 20439 */ |
| 3968 | else if (file >= n_files) |
| 3969 | { |
| 3970 | warn (_("file index %u > number of files %u\n"), file + 1, n_files); |
| 3971 | printf (_("\n <over large file table index %u>"), file); |
| 3972 | } |
| 3973 | else if ((dir = file_table[file].directory_index) == 0) |
| 3974 | /* If directory index is 0, that means current directory. */ |
| 3975 | printf ("\n./%s:[++]\n", file_table[file].name); |
| 3976 | else if (directory_table == NULL || n_directories == 0) |
| 3977 | printf (_("\n [Use file %s in directory table entry %d]\n"), |
| 3978 | file_table[file].name, dir); |
| 3979 | /* PR 20439 */ |
| 3980 | else if (dir > n_directories) |
| 3981 | { |
| 3982 | warn (_("directory index %u > number of directories %s\n"), |
| 3983 | dir, dwarf_vmatoa ("u", n_directories)); |
| 3984 | printf (_("\n <over large directory table entry %u>\n"), dir); |
| 3985 | } |
| 3986 | else |
| 3987 | printf ("\n%s/%s:\n", |
| 3988 | /* The directory index starts counting at 1. */ |
| 3989 | directory_table[dir - 1], file_table[file].name); |
| 3990 | } |
| 3991 | break; |
| 3992 | |
| 3993 | case DW_LNS_set_column: |
| 3994 | uladv = read_uleb128 (data, & bytes_read, end); |
| 3995 | data += bytes_read; |
| 3996 | state_machine_regs.column = uladv; |
| 3997 | break; |
| 3998 | |
| 3999 | case DW_LNS_negate_stmt: |
| 4000 | adv = state_machine_regs.is_stmt; |
| 4001 | adv = ! adv; |
| 4002 | state_machine_regs.is_stmt = adv; |
| 4003 | break; |
| 4004 | |
| 4005 | case DW_LNS_set_basic_block: |
| 4006 | state_machine_regs.basic_block = 1; |
| 4007 | break; |
| 4008 | |
| 4009 | case DW_LNS_const_add_pc: |
| 4010 | uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); |
| 4011 | if (linfo.li_max_ops_per_insn == 1) |
| 4012 | { |
| 4013 | uladv *= linfo.li_min_insn_length; |
| 4014 | state_machine_regs.address += uladv; |
| 4015 | } |
| 4016 | else |
| 4017 | { |
| 4018 | state_machine_regs.address |
| 4019 | += ((state_machine_regs.op_index + uladv) |
| 4020 | / linfo.li_max_ops_per_insn) |
| 4021 | * linfo.li_min_insn_length; |
| 4022 | state_machine_regs.op_index |
| 4023 | = (state_machine_regs.op_index + uladv) |
| 4024 | % linfo.li_max_ops_per_insn; |
| 4025 | } |
| 4026 | break; |
| 4027 | |
| 4028 | case DW_LNS_fixed_advance_pc: |
| 4029 | SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); |
| 4030 | state_machine_regs.address += uladv; |
| 4031 | state_machine_regs.op_index = 0; |
| 4032 | break; |
| 4033 | |
| 4034 | case DW_LNS_set_prologue_end: |
| 4035 | break; |
| 4036 | |
| 4037 | case DW_LNS_set_epilogue_begin: |
| 4038 | break; |
| 4039 | |
| 4040 | case DW_LNS_set_isa: |
| 4041 | uladv = read_uleb128 (data, & bytes_read, end); |
| 4042 | data += bytes_read; |
| 4043 | printf (_(" Set ISA to %lu\n"), uladv); |
| 4044 | break; |
| 4045 | |
| 4046 | default: |
| 4047 | printf (_(" Unknown opcode %d with operands: "), op_code); |
| 4048 | |
| 4049 | if (standard_opcodes != NULL) |
| 4050 | for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) |
| 4051 | { |
| 4052 | printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data, |
| 4053 | &bytes_read, end)), |
| 4054 | i == 1 ? "" : ", "); |
| 4055 | data += bytes_read; |
| 4056 | } |
| 4057 | putchar ('\n'); |
| 4058 | break; |
| 4059 | } |
| 4060 | |
| 4061 | /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row |
| 4062 | to the DWARF address/line matrix. */ |
| 4063 | if ((is_special_opcode) || (op_code == DW_LNE_end_sequence) |
| 4064 | || (op_code == DW_LNS_copy)) |
| 4065 | { |
| 4066 | const unsigned int MAX_FILENAME_LENGTH = 35; |
| 4067 | char *fileName; |
| 4068 | char *newFileName = NULL; |
| 4069 | size_t fileNameLength; |
| 4070 | |
| 4071 | if (file_table) |
| 4072 | { |
| 4073 | unsigned indx = state_machine_regs.file - 1; |
| 4074 | /* PR 20439 */ |
| 4075 | if (indx >= n_files) |
| 4076 | { |
| 4077 | warn (_("corrupt file index %u encountered\n"), indx); |
| 4078 | fileName = _("<corrupt>"); |
| 4079 | } |
| 4080 | else |
| 4081 | fileName = (char *) file_table[indx].name; |
| 4082 | } |
| 4083 | else |
| 4084 | fileName = _("<unknown>"); |
| 4085 | |
| 4086 | fileNameLength = strlen (fileName); |
| 4087 | |
| 4088 | if ((fileNameLength > MAX_FILENAME_LENGTH) && (!do_wide)) |
| 4089 | { |
| 4090 | newFileName = (char *) xmalloc (MAX_FILENAME_LENGTH + 1); |
| 4091 | /* Truncate file name */ |
| 4092 | strncpy (newFileName, |
| 4093 | fileName + fileNameLength - MAX_FILENAME_LENGTH, |
| 4094 | MAX_FILENAME_LENGTH + 1); |
| 4095 | } |
| 4096 | else |
| 4097 | { |
| 4098 | newFileName = (char *) xmalloc (fileNameLength + 1); |
| 4099 | strncpy (newFileName, fileName, fileNameLength + 1); |
| 4100 | } |
| 4101 | |
| 4102 | if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH)) |
| 4103 | { |
| 4104 | if (linfo.li_max_ops_per_insn == 1) |
| 4105 | printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n", |
| 4106 | newFileName, state_machine_regs.line, |
| 4107 | state_machine_regs.address); |
| 4108 | else |
| 4109 | printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n", |
| 4110 | newFileName, state_machine_regs.line, |
| 4111 | state_machine_regs.address, |
| 4112 | state_machine_regs.op_index); |
| 4113 | } |
| 4114 | else |
| 4115 | { |
| 4116 | if (linfo.li_max_ops_per_insn == 1) |
| 4117 | printf ("%s %11d %#18" DWARF_VMA_FMT "x\n", |
| 4118 | newFileName, state_machine_regs.line, |
| 4119 | state_machine_regs.address); |
| 4120 | else |
| 4121 | printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n", |
| 4122 | newFileName, state_machine_regs.line, |
| 4123 | state_machine_regs.address, |
| 4124 | state_machine_regs.op_index); |
| 4125 | } |
| 4126 | |
| 4127 | if (op_code == DW_LNE_end_sequence) |
| 4128 | printf ("\n"); |
| 4129 | |
| 4130 | free (newFileName); |
| 4131 | } |
| 4132 | } |
| 4133 | |
| 4134 | if (file_table) |
| 4135 | { |
| 4136 | free (file_table); |
| 4137 | file_table = NULL; |
| 4138 | n_files = 0; |
| 4139 | } |
| 4140 | |
| 4141 | if (directory_table) |
| 4142 | { |
| 4143 | free (directory_table); |
| 4144 | directory_table = NULL; |
| 4145 | n_directories = 0; |
| 4146 | } |
| 4147 | |
| 4148 | putchar ('\n'); |
| 4149 | } |
| 4150 | |
| 4151 | return 1; |
| 4152 | } |
| 4153 | |
| 4154 | static int |
| 4155 | display_debug_lines (struct dwarf_section *section, void *file) |
| 4156 | { |
| 4157 | unsigned char *data = section->start; |
| 4158 | unsigned char *end = data + section->size; |
| 4159 | int retValRaw = 1; |
| 4160 | int retValDecoded = 1; |
| 4161 | |
| 4162 | if (do_debug_lines == 0) |
| 4163 | do_debug_lines |= FLAG_DEBUG_LINES_RAW; |
| 4164 | |
| 4165 | if (do_debug_lines & FLAG_DEBUG_LINES_RAW) |
| 4166 | retValRaw = display_debug_lines_raw (section, data, end, file); |
| 4167 | |
| 4168 | if (do_debug_lines & FLAG_DEBUG_LINES_DECODED) |
| 4169 | retValDecoded = display_debug_lines_decoded (section, data, end, file); |
| 4170 | |
| 4171 | if (!retValRaw || !retValDecoded) |
| 4172 | return 0; |
| 4173 | |
| 4174 | return 1; |
| 4175 | } |
| 4176 | |
| 4177 | static debug_info * |
| 4178 | find_debug_info_for_offset (unsigned long offset) |
| 4179 | { |
| 4180 | unsigned int i; |
| 4181 | |
| 4182 | if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) |
| 4183 | return NULL; |
| 4184 | |
| 4185 | for (i = 0; i < num_debug_info_entries; i++) |
| 4186 | if (debug_information[i].cu_offset == offset) |
| 4187 | return debug_information + i; |
| 4188 | |
| 4189 | return NULL; |
| 4190 | } |
| 4191 | |
| 4192 | static const char * |
| 4193 | get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind) |
| 4194 | { |
| 4195 | /* See gdb/gdb-index.h. */ |
| 4196 | static const char * const kinds[] = |
| 4197 | { |
| 4198 | N_ ("no info"), |
| 4199 | N_ ("type"), |
| 4200 | N_ ("variable"), |
| 4201 | N_ ("function"), |
| 4202 | N_ ("other"), |
| 4203 | N_ ("unused5"), |
| 4204 | N_ ("unused6"), |
| 4205 | N_ ("unused7") |
| 4206 | }; |
| 4207 | |
| 4208 | return _ (kinds[kind]); |
| 4209 | } |
| 4210 | |
| 4211 | static int |
| 4212 | display_debug_pubnames_worker (struct dwarf_section *section, |
| 4213 | void *file ATTRIBUTE_UNUSED, |
| 4214 | int is_gnu) |
| 4215 | { |
| 4216 | DWARF2_Internal_PubNames names; |
| 4217 | unsigned char *start = section->start; |
| 4218 | unsigned char *end = start + section->size; |
| 4219 | |
| 4220 | /* It does not matter if this load fails, |
| 4221 | we test for that later on. */ |
| 4222 | load_debug_info (file); |
| 4223 | |
| 4224 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 4225 | |
| 4226 | while (start < end) |
| 4227 | { |
| 4228 | unsigned char *data; |
| 4229 | unsigned char *adr; |
| 4230 | dwarf_vma offset; |
| 4231 | unsigned int offset_size, initial_length_size; |
| 4232 | |
| 4233 | data = start; |
| 4234 | |
| 4235 | SAFE_BYTE_GET_AND_INC (names.pn_length, data, 4, end); |
| 4236 | if (names.pn_length == 0xffffffff) |
| 4237 | { |
| 4238 | SAFE_BYTE_GET_AND_INC (names.pn_length, data, 8, end); |
| 4239 | offset_size = 8; |
| 4240 | initial_length_size = 12; |
| 4241 | } |
| 4242 | else |
| 4243 | { |
| 4244 | offset_size = 4; |
| 4245 | initial_length_size = 4; |
| 4246 | } |
| 4247 | |
| 4248 | SAFE_BYTE_GET_AND_INC (names.pn_version, data, 2, end); |
| 4249 | SAFE_BYTE_GET_AND_INC (names.pn_offset, data, offset_size, end); |
| 4250 | |
| 4251 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE |
| 4252 | && num_debug_info_entries > 0 |
| 4253 | && find_debug_info_for_offset (names.pn_offset) == NULL) |
| 4254 | warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), |
| 4255 | (unsigned long) names.pn_offset, section->name); |
| 4256 | |
| 4257 | SAFE_BYTE_GET_AND_INC (names.pn_size, data, offset_size, end); |
| 4258 | |
| 4259 | adr = start + names.pn_length + initial_length_size; |
| 4260 | /* PR 17531: file: 7615b6b2. */ |
| 4261 | if ((dwarf_signed_vma) names.pn_length < 0 |
| 4262 | /* PR 17531: file: a5dbeaa7. */ |
| 4263 | || adr < start) |
| 4264 | { |
| 4265 | warn (_("Negative length for public name: 0x%lx\n"), (long) names.pn_length); |
| 4266 | start = end; |
| 4267 | } |
| 4268 | else |
| 4269 | start = adr; |
| 4270 | |
| 4271 | printf (_(" Length: %ld\n"), |
| 4272 | (long) names.pn_length); |
| 4273 | printf (_(" Version: %d\n"), |
| 4274 | names.pn_version); |
| 4275 | printf (_(" Offset into .debug_info section: 0x%lx\n"), |
| 4276 | (unsigned long) names.pn_offset); |
| 4277 | printf (_(" Size of area in .debug_info section: %ld\n"), |
| 4278 | (long) names.pn_size); |
| 4279 | |
| 4280 | if (names.pn_version != 2 && names.pn_version != 3) |
| 4281 | { |
| 4282 | static int warned = 0; |
| 4283 | |
| 4284 | if (! warned) |
| 4285 | { |
| 4286 | warn (_("Only DWARF 2 and 3 pubnames are currently supported\n")); |
| 4287 | warned = 1; |
| 4288 | } |
| 4289 | |
| 4290 | continue; |
| 4291 | } |
| 4292 | |
| 4293 | if (is_gnu) |
| 4294 | printf (_("\n Offset Kind Name\n")); |
| 4295 | else |
| 4296 | printf (_("\n Offset\tName\n")); |
| 4297 | |
| 4298 | do |
| 4299 | { |
| 4300 | bfd_size_type maxprint; |
| 4301 | |
| 4302 | SAFE_BYTE_GET (offset, data, offset_size, end); |
| 4303 | |
| 4304 | if (offset != 0) |
| 4305 | { |
| 4306 | data += offset_size; |
| 4307 | if (data >= end) |
| 4308 | break; |
| 4309 | maxprint = (end - data) - 1; |
| 4310 | |
| 4311 | if (is_gnu) |
| 4312 | { |
| 4313 | unsigned int kind_data; |
| 4314 | gdb_index_symbol_kind kind; |
| 4315 | const char *kind_name; |
| 4316 | int is_static; |
| 4317 | |
| 4318 | SAFE_BYTE_GET (kind_data, data, 1, end); |
| 4319 | data++; |
| 4320 | maxprint --; |
| 4321 | /* GCC computes the kind as the upper byte in the CU index |
| 4322 | word, and then right shifts it by the CU index size. |
| 4323 | Left shift KIND to where the gdb-index.h accessor macros |
| 4324 | can use it. */ |
| 4325 | kind_data <<= GDB_INDEX_CU_BITSIZE; |
| 4326 | kind = GDB_INDEX_SYMBOL_KIND_VALUE (kind_data); |
| 4327 | kind_name = get_gdb_index_symbol_kind_name (kind); |
| 4328 | is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data); |
| 4329 | printf (" %-6lx %s,%-10s %.*s\n", |
| 4330 | (unsigned long) offset, is_static ? _("s") : _("g"), |
| 4331 | kind_name, (int) maxprint, data); |
| 4332 | } |
| 4333 | else |
| 4334 | printf (" %-6lx\t%.*s\n", |
| 4335 | (unsigned long) offset, (int) maxprint, data); |
| 4336 | |
| 4337 | data += strnlen ((char *) data, maxprint) + 1; |
| 4338 | if (data >= end) |
| 4339 | break; |
| 4340 | } |
| 4341 | } |
| 4342 | while (offset != 0); |
| 4343 | } |
| 4344 | |
| 4345 | printf ("\n"); |
| 4346 | return 1; |
| 4347 | } |
| 4348 | |
| 4349 | static int |
| 4350 | display_debug_pubnames (struct dwarf_section *section, void *file) |
| 4351 | { |
| 4352 | return display_debug_pubnames_worker (section, file, 0); |
| 4353 | } |
| 4354 | |
| 4355 | static int |
| 4356 | display_debug_gnu_pubnames (struct dwarf_section *section, void *file) |
| 4357 | { |
| 4358 | return display_debug_pubnames_worker (section, file, 1); |
| 4359 | } |
| 4360 | |
| 4361 | static int |
| 4362 | display_debug_macinfo (struct dwarf_section *section, |
| 4363 | void *file ATTRIBUTE_UNUSED) |
| 4364 | { |
| 4365 | unsigned char *start = section->start; |
| 4366 | unsigned char *end = start + section->size; |
| 4367 | unsigned char *curr = start; |
| 4368 | unsigned int bytes_read; |
| 4369 | enum dwarf_macinfo_record_type op; |
| 4370 | |
| 4371 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 4372 | |
| 4373 | while (curr < end) |
| 4374 | { |
| 4375 | unsigned int lineno; |
| 4376 | const unsigned char *string; |
| 4377 | |
| 4378 | op = (enum dwarf_macinfo_record_type) *curr; |
| 4379 | curr++; |
| 4380 | |
| 4381 | switch (op) |
| 4382 | { |
| 4383 | case DW_MACINFO_start_file: |
| 4384 | { |
| 4385 | unsigned int filenum; |
| 4386 | |
| 4387 | lineno = read_uleb128 (curr, & bytes_read, end); |
| 4388 | curr += bytes_read; |
| 4389 | filenum = read_uleb128 (curr, & bytes_read, end); |
| 4390 | curr += bytes_read; |
| 4391 | |
| 4392 | printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), |
| 4393 | lineno, filenum); |
| 4394 | } |
| 4395 | break; |
| 4396 | |
| 4397 | case DW_MACINFO_end_file: |
| 4398 | printf (_(" DW_MACINFO_end_file\n")); |
| 4399 | break; |
| 4400 | |
| 4401 | case DW_MACINFO_define: |
| 4402 | lineno = read_uleb128 (curr, & bytes_read, end); |
| 4403 | curr += bytes_read; |
| 4404 | string = curr; |
| 4405 | curr += strnlen ((char *) string, end - string) + 1; |
| 4406 | printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), |
| 4407 | lineno, string); |
| 4408 | break; |
| 4409 | |
| 4410 | case DW_MACINFO_undef: |
| 4411 | lineno = read_uleb128 (curr, & bytes_read, end); |
| 4412 | curr += bytes_read; |
| 4413 | string = curr; |
| 4414 | curr += strnlen ((char *) string, end - string) + 1; |
| 4415 | printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), |
| 4416 | lineno, string); |
| 4417 | break; |
| 4418 | |
| 4419 | case DW_MACINFO_vendor_ext: |
| 4420 | { |
| 4421 | unsigned int constant; |
| 4422 | |
| 4423 | constant = read_uleb128 (curr, & bytes_read, end); |
| 4424 | curr += bytes_read; |
| 4425 | string = curr; |
| 4426 | curr += strnlen ((char *) string, end - string) + 1; |
| 4427 | printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), |
| 4428 | constant, string); |
| 4429 | } |
| 4430 | break; |
| 4431 | } |
| 4432 | } |
| 4433 | |
| 4434 | return 1; |
| 4435 | } |
| 4436 | |
| 4437 | /* Given LINE_OFFSET into the .debug_line section, attempt to return |
| 4438 | filename and dirname corresponding to file name table entry with index |
| 4439 | FILEIDX. Return NULL on failure. */ |
| 4440 | |
| 4441 | static unsigned char * |
| 4442 | get_line_filename_and_dirname (dwarf_vma line_offset, |
| 4443 | dwarf_vma fileidx, |
| 4444 | unsigned char **dir_name) |
| 4445 | { |
| 4446 | struct dwarf_section *section = &debug_displays [line].section; |
| 4447 | unsigned char *hdrptr, *dirtable, *file_name; |
| 4448 | unsigned int offset_size, initial_length_size; |
| 4449 | unsigned int version, opcode_base, bytes_read; |
| 4450 | dwarf_vma length, diridx; |
| 4451 | const unsigned char * end; |
| 4452 | |
| 4453 | *dir_name = NULL; |
| 4454 | if (section->start == NULL |
| 4455 | || line_offset >= section->size |
| 4456 | || fileidx == 0) |
| 4457 | return NULL; |
| 4458 | |
| 4459 | hdrptr = section->start + line_offset; |
| 4460 | end = section->start + section->size; |
| 4461 | |
| 4462 | SAFE_BYTE_GET_AND_INC (length, hdrptr, 4, end); |
| 4463 | if (length == 0xffffffff) |
| 4464 | { |
| 4465 | /* This section is 64-bit DWARF 3. */ |
| 4466 | SAFE_BYTE_GET_AND_INC (length, hdrptr, 8, end); |
| 4467 | offset_size = 8; |
| 4468 | initial_length_size = 12; |
| 4469 | } |
| 4470 | else |
| 4471 | { |
| 4472 | offset_size = 4; |
| 4473 | initial_length_size = 4; |
| 4474 | } |
| 4475 | if (length + initial_length_size > section->size) |
| 4476 | return NULL; |
| 4477 | |
| 4478 | SAFE_BYTE_GET_AND_INC (version, hdrptr, 2, end); |
| 4479 | if (version != 2 && version != 3 && version != 4) |
| 4480 | return NULL; |
| 4481 | hdrptr += offset_size + 1;/* Skip prologue_length and min_insn_length. */ |
| 4482 | if (version >= 4) |
| 4483 | hdrptr++; /* Skip max_ops_per_insn. */ |
| 4484 | hdrptr += 3; /* Skip default_is_stmt, line_base, line_range. */ |
| 4485 | |
| 4486 | SAFE_BYTE_GET_AND_INC (opcode_base, hdrptr, 1, end); |
| 4487 | if (opcode_base == 0) |
| 4488 | return NULL; |
| 4489 | |
| 4490 | hdrptr += opcode_base - 1; |
| 4491 | dirtable = hdrptr; |
| 4492 | /* Skip over dirname table. */ |
| 4493 | while (*hdrptr != '\0') |
| 4494 | hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; |
| 4495 | hdrptr++; /* Skip the NUL at the end of the table. */ |
| 4496 | /* Now skip over preceding filename table entries. */ |
| 4497 | for (; *hdrptr != '\0' && fileidx > 1; fileidx--) |
| 4498 | { |
| 4499 | hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; |
| 4500 | read_uleb128 (hdrptr, &bytes_read, end); |
| 4501 | hdrptr += bytes_read; |
| 4502 | read_uleb128 (hdrptr, &bytes_read, end); |
| 4503 | hdrptr += bytes_read; |
| 4504 | read_uleb128 (hdrptr, &bytes_read, end); |
| 4505 | hdrptr += bytes_read; |
| 4506 | } |
| 4507 | if (hdrptr == end || *hdrptr == '\0') |
| 4508 | return NULL; |
| 4509 | file_name = hdrptr; |
| 4510 | hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; |
| 4511 | diridx = read_uleb128 (hdrptr, &bytes_read, end); |
| 4512 | if (diridx == 0) |
| 4513 | return file_name; |
| 4514 | for (; *dirtable != '\0' && diridx > 1; diridx--) |
| 4515 | dirtable += strnlen ((char *) dirtable, end - dirtable) + 1; |
| 4516 | if (*dirtable == '\0') |
| 4517 | return NULL; |
| 4518 | *dir_name = dirtable; |
| 4519 | return file_name; |
| 4520 | } |
| 4521 | |
| 4522 | static int |
| 4523 | display_debug_macro (struct dwarf_section *section, |
| 4524 | void *file) |
| 4525 | { |
| 4526 | unsigned char *start = section->start; |
| 4527 | unsigned char *end = start + section->size; |
| 4528 | unsigned char *curr = start; |
| 4529 | unsigned char *extended_op_buf[256]; |
| 4530 | unsigned int bytes_read; |
| 4531 | |
| 4532 | load_debug_section (str, file); |
| 4533 | load_debug_section (line, file); |
| 4534 | |
| 4535 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 4536 | |
| 4537 | while (curr < end) |
| 4538 | { |
| 4539 | unsigned int lineno, version, flags; |
| 4540 | unsigned int offset_size = 4; |
| 4541 | const unsigned char *string; |
| 4542 | dwarf_vma line_offset = 0, sec_offset = curr - start, offset; |
| 4543 | unsigned char **extended_ops = NULL; |
| 4544 | |
| 4545 | SAFE_BYTE_GET_AND_INC (version, curr, 2, end); |
| 4546 | if (version != 4 && version != 5) |
| 4547 | { |
| 4548 | error (_("Only GNU extension to DWARF 4 or 5 of %s is currently supported.\n"), |
| 4549 | section->name); |
| 4550 | return 0; |
| 4551 | } |
| 4552 | |
| 4553 | SAFE_BYTE_GET_AND_INC (flags, curr, 1, end); |
| 4554 | if (flags & 1) |
| 4555 | offset_size = 8; |
| 4556 | printf (_(" Offset: 0x%lx\n"), |
| 4557 | (unsigned long) sec_offset); |
| 4558 | printf (_(" Version: %d\n"), version); |
| 4559 | printf (_(" Offset size: %d\n"), offset_size); |
| 4560 | if (flags & 2) |
| 4561 | { |
| 4562 | SAFE_BYTE_GET_AND_INC (line_offset, curr, offset_size, end); |
| 4563 | printf (_(" Offset into .debug_line: 0x%lx\n"), |
| 4564 | (unsigned long) line_offset); |
| 4565 | } |
| 4566 | if (flags & 4) |
| 4567 | { |
| 4568 | unsigned int i, count, op; |
| 4569 | dwarf_vma nargs, n; |
| 4570 | |
| 4571 | SAFE_BYTE_GET_AND_INC (count, curr, 1, end); |
| 4572 | |
| 4573 | memset (extended_op_buf, 0, sizeof (extended_op_buf)); |
| 4574 | extended_ops = extended_op_buf; |
| 4575 | if (count) |
| 4576 | { |
| 4577 | printf (_(" Extension opcode arguments:\n")); |
| 4578 | for (i = 0; i < count; i++) |
| 4579 | { |
| 4580 | SAFE_BYTE_GET_AND_INC (op, curr, 1, end); |
| 4581 | extended_ops[op] = curr; |
| 4582 | nargs = read_uleb128 (curr, &bytes_read, end); |
| 4583 | curr += bytes_read; |
| 4584 | if (nargs == 0) |
| 4585 | printf (_(" DW_MACRO_%02x has no arguments\n"), op); |
| 4586 | else |
| 4587 | { |
| 4588 | printf (_(" DW_MACRO_%02x arguments: "), op); |
| 4589 | for (n = 0; n < nargs; n++) |
| 4590 | { |
| 4591 | unsigned int form; |
| 4592 | |
| 4593 | SAFE_BYTE_GET_AND_INC (form, curr, 1, end); |
| 4594 | printf ("%s%s", get_FORM_name (form), |
| 4595 | n == nargs - 1 ? "\n" : ", "); |
| 4596 | switch (form) |
| 4597 | { |
| 4598 | case DW_FORM_data1: |
| 4599 | case DW_FORM_data2: |
| 4600 | case DW_FORM_data4: |
| 4601 | case DW_FORM_data8: |
| 4602 | case DW_FORM_sdata: |
| 4603 | case DW_FORM_udata: |
| 4604 | case DW_FORM_block: |
| 4605 | case DW_FORM_block1: |
| 4606 | case DW_FORM_block2: |
| 4607 | case DW_FORM_block4: |
| 4608 | case DW_FORM_flag: |
| 4609 | case DW_FORM_string: |
| 4610 | case DW_FORM_strp: |
| 4611 | case DW_FORM_sec_offset: |
| 4612 | break; |
| 4613 | default: |
| 4614 | error (_("Invalid extension opcode form %s\n"), |
| 4615 | get_FORM_name (form)); |
| 4616 | return 0; |
| 4617 | } |
| 4618 | } |
| 4619 | } |
| 4620 | } |
| 4621 | } |
| 4622 | } |
| 4623 | printf ("\n"); |
| 4624 | |
| 4625 | while (1) |
| 4626 | { |
| 4627 | unsigned int op; |
| 4628 | |
| 4629 | if (curr >= end) |
| 4630 | { |
| 4631 | error (_(".debug_macro section not zero terminated\n")); |
| 4632 | return 0; |
| 4633 | } |
| 4634 | |
| 4635 | SAFE_BYTE_GET_AND_INC (op, curr, 1, end); |
| 4636 | if (op == 0) |
| 4637 | break; |
| 4638 | |
| 4639 | switch (op) |
| 4640 | { |
| 4641 | case DW_MACRO_start_file: |
| 4642 | { |
| 4643 | unsigned int filenum; |
| 4644 | unsigned char *file_name = NULL, *dir_name = NULL; |
| 4645 | |
| 4646 | lineno = read_uleb128 (curr, &bytes_read, end); |
| 4647 | curr += bytes_read; |
| 4648 | filenum = read_uleb128 (curr, &bytes_read, end); |
| 4649 | curr += bytes_read; |
| 4650 | |
| 4651 | if ((flags & 2) == 0) |
| 4652 | error (_("DW_MACRO_start_file used, but no .debug_line offset provided.\n")); |
| 4653 | else |
| 4654 | file_name |
| 4655 | = get_line_filename_and_dirname (line_offset, filenum, |
| 4656 | &dir_name); |
| 4657 | if (file_name == NULL) |
| 4658 | printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d\n"), |
| 4659 | lineno, filenum); |
| 4660 | else |
| 4661 | printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d filename: %s%s%s\n"), |
| 4662 | lineno, filenum, |
| 4663 | dir_name != NULL ? (const char *) dir_name : "", |
| 4664 | dir_name != NULL ? "/" : "", file_name); |
| 4665 | } |
| 4666 | break; |
| 4667 | |
| 4668 | case DW_MACRO_end_file: |
| 4669 | printf (_(" DW_MACRO_end_file\n")); |
| 4670 | break; |
| 4671 | |
| 4672 | case DW_MACRO_define: |
| 4673 | lineno = read_uleb128 (curr, &bytes_read, end); |
| 4674 | curr += bytes_read; |
| 4675 | string = curr; |
| 4676 | curr += strnlen ((char *) string, end - string) + 1; |
| 4677 | printf (_(" DW_MACRO_define - lineno : %d macro : %s\n"), |
| 4678 | lineno, string); |
| 4679 | break; |
| 4680 | |
| 4681 | case DW_MACRO_undef: |
| 4682 | lineno = read_uleb128 (curr, &bytes_read, end); |
| 4683 | curr += bytes_read; |
| 4684 | string = curr; |
| 4685 | curr += strnlen ((char *) string, end - string) + 1; |
| 4686 | printf (_(" DW_MACRO_undef - lineno : %d macro : %s\n"), |
| 4687 | lineno, string); |
| 4688 | break; |
| 4689 | |
| 4690 | case DW_MACRO_define_strp: |
| 4691 | lineno = read_uleb128 (curr, &bytes_read, end); |
| 4692 | curr += bytes_read; |
| 4693 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
| 4694 | string = fetch_indirect_string (offset); |
| 4695 | printf (_(" DW_MACRO_define_strp - lineno : %d macro : %s\n"), |
| 4696 | lineno, string); |
| 4697 | break; |
| 4698 | |
| 4699 | case DW_MACRO_undef_strp: |
| 4700 | lineno = read_uleb128 (curr, &bytes_read, end); |
| 4701 | curr += bytes_read; |
| 4702 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
| 4703 | string = fetch_indirect_string (offset); |
| 4704 | printf (_(" DW_MACRO_undef_strp - lineno : %d macro : %s\n"), |
| 4705 | lineno, string); |
| 4706 | break; |
| 4707 | |
| 4708 | case DW_MACRO_import: |
| 4709 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
| 4710 | printf (_(" DW_MACRO_import - offset : 0x%lx\n"), |
| 4711 | (unsigned long) offset); |
| 4712 | break; |
| 4713 | |
| 4714 | case DW_MACRO_define_sup: |
| 4715 | lineno = read_uleb128 (curr, &bytes_read, end); |
| 4716 | curr += bytes_read; |
| 4717 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
| 4718 | printf (_(" DW_MACRO_define_sup - lineno : %d macro offset : 0x%lx\n"), |
| 4719 | lineno, (unsigned long) offset); |
| 4720 | break; |
| 4721 | |
| 4722 | case DW_MACRO_undef_sup: |
| 4723 | lineno = read_uleb128 (curr, &bytes_read, end); |
| 4724 | curr += bytes_read; |
| 4725 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
| 4726 | printf (_(" DW_MACRO_undef_sup - lineno : %d macro offset : 0x%lx\n"), |
| 4727 | lineno, (unsigned long) offset); |
| 4728 | break; |
| 4729 | |
| 4730 | case DW_MACRO_import_sup: |
| 4731 | SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); |
| 4732 | printf (_(" DW_MACRO_import_sup - offset : 0x%lx\n"), |
| 4733 | (unsigned long) offset); |
| 4734 | break; |
| 4735 | |
| 4736 | default: |
| 4737 | if (extended_ops == NULL || extended_ops[op] == NULL) |
| 4738 | { |
| 4739 | error (_(" Unknown macro opcode %02x seen\n"), op); |
| 4740 | return 0; |
| 4741 | } |
| 4742 | else |
| 4743 | { |
| 4744 | /* Skip over unhandled opcodes. */ |
| 4745 | dwarf_vma nargs, n; |
| 4746 | unsigned char *desc = extended_ops[op]; |
| 4747 | nargs = read_uleb128 (desc, &bytes_read, end); |
| 4748 | desc += bytes_read; |
| 4749 | if (nargs == 0) |
| 4750 | { |
| 4751 | printf (_(" DW_MACRO_%02x\n"), op); |
| 4752 | break; |
| 4753 | } |
| 4754 | printf (_(" DW_MACRO_%02x -"), op); |
| 4755 | for (n = 0; n < nargs; n++) |
| 4756 | { |
| 4757 | int val; |
| 4758 | |
| 4759 | /* DW_FORM_implicit_const is not expected here. */ |
| 4760 | SAFE_BYTE_GET_AND_INC (val, desc, 1, end); |
| 4761 | curr |
| 4762 | = read_and_display_attr_value (0, val, 0, |
| 4763 | curr, end, 0, 0, offset_size, |
| 4764 | version, NULL, 0, NULL, |
| 4765 | NULL, ' '); |
| 4766 | if (n != nargs - 1) |
| 4767 | printf (","); |
| 4768 | } |
| 4769 | printf ("\n"); |
| 4770 | } |
| 4771 | break; |
| 4772 | } |
| 4773 | } |
| 4774 | |
| 4775 | printf ("\n"); |
| 4776 | } |
| 4777 | |
| 4778 | return 1; |
| 4779 | } |
| 4780 | |
| 4781 | static int |
| 4782 | display_debug_abbrev (struct dwarf_section *section, |
| 4783 | void *file ATTRIBUTE_UNUSED) |
| 4784 | { |
| 4785 | abbrev_entry *entry; |
| 4786 | unsigned char *start = section->start; |
| 4787 | unsigned char *end = start + section->size; |
| 4788 | |
| 4789 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 4790 | |
| 4791 | do |
| 4792 | { |
| 4793 | unsigned char *last; |
| 4794 | |
| 4795 | free_abbrevs (); |
| 4796 | |
| 4797 | last = start; |
| 4798 | start = process_abbrev_section (start, end); |
| 4799 | |
| 4800 | if (first_abbrev == NULL) |
| 4801 | continue; |
| 4802 | |
| 4803 | printf (_(" Number TAG (0x%lx)\n"), (long) (last - section->start)); |
| 4804 | |
| 4805 | for (entry = first_abbrev; entry; entry = entry->next) |
| 4806 | { |
| 4807 | abbrev_attr *attr; |
| 4808 | |
| 4809 | printf (" %ld %s [%s]\n", |
| 4810 | entry->entry, |
| 4811 | get_TAG_name (entry->tag), |
| 4812 | entry->children ? _("has children") : _("no children")); |
| 4813 | |
| 4814 | for (attr = entry->first_attr; attr; attr = attr->next) |
| 4815 | { |
| 4816 | printf (" %-18s %s", |
| 4817 | get_AT_name (attr->attribute), |
| 4818 | get_FORM_name (attr->form)); |
| 4819 | if (attr->form == DW_FORM_implicit_const) |
| 4820 | printf (": %" BFD_VMA_FMT "d", attr->implicit_const); |
| 4821 | putchar ('\n'); |
| 4822 | } |
| 4823 | } |
| 4824 | } |
| 4825 | while (start); |
| 4826 | |
| 4827 | printf ("\n"); |
| 4828 | |
| 4829 | return 1; |
| 4830 | } |
| 4831 | |
| 4832 | /* Return true when ADDR is the maximum address, when addresses are |
| 4833 | POINTER_SIZE bytes long. */ |
| 4834 | |
| 4835 | static bfd_boolean |
| 4836 | is_max_address (dwarf_vma addr, unsigned int pointer_size) |
| 4837 | { |
| 4838 | dwarf_vma mask = ~(~(dwarf_vma) 1 << (pointer_size * 8 - 1)); |
| 4839 | return ((addr & mask) == mask); |
| 4840 | } |
| 4841 | |
| 4842 | /* Display a location list from a normal (ie, non-dwo) .debug_loc section. */ |
| 4843 | |
| 4844 | static void |
| 4845 | display_loc_list (struct dwarf_section *section, |
| 4846 | unsigned char **start_ptr, |
| 4847 | unsigned int debug_info_entry, |
| 4848 | dwarf_vma offset, |
| 4849 | dwarf_vma base_address, |
| 4850 | int has_frame_base) |
| 4851 | { |
| 4852 | unsigned char *start = *start_ptr; |
| 4853 | unsigned char *section_end = section->start + section->size; |
| 4854 | unsigned long cu_offset; |
| 4855 | unsigned int pointer_size; |
| 4856 | unsigned int offset_size; |
| 4857 | int dwarf_version; |
| 4858 | |
| 4859 | dwarf_vma begin; |
| 4860 | dwarf_vma end; |
| 4861 | unsigned short length; |
| 4862 | int need_frame_base; |
| 4863 | |
| 4864 | if (debug_info_entry >= num_debug_info_entries) |
| 4865 | { |
| 4866 | warn (_("No debug information available for loc lists of entry: %u\n"), |
| 4867 | debug_info_entry); |
| 4868 | return; |
| 4869 | } |
| 4870 | |
| 4871 | cu_offset = debug_information [debug_info_entry].cu_offset; |
| 4872 | pointer_size = debug_information [debug_info_entry].pointer_size; |
| 4873 | offset_size = debug_information [debug_info_entry].offset_size; |
| 4874 | dwarf_version = debug_information [debug_info_entry].dwarf_version; |
| 4875 | |
| 4876 | if (pointer_size < 2 || pointer_size > 8) |
| 4877 | { |
| 4878 | warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), |
| 4879 | pointer_size, debug_info_entry); |
| 4880 | return; |
| 4881 | } |
| 4882 | |
| 4883 | while (1) |
| 4884 | { |
| 4885 | dwarf_vma off = offset + (start - *start_ptr); |
| 4886 | |
| 4887 | if (start + 2 * pointer_size > section_end) |
| 4888 | { |
| 4889 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 4890 | (unsigned long) offset); |
| 4891 | break; |
| 4892 | } |
| 4893 | |
| 4894 | printf (" %8.8lx ", (unsigned long) off); |
| 4895 | |
| 4896 | SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end); |
| 4897 | SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end); |
| 4898 | |
| 4899 | if (begin == 0 && end == 0) |
| 4900 | { |
| 4901 | /* PR 18374: In a object file we can have a location list that |
| 4902 | starts with a begin and end of 0 because there are relocations |
| 4903 | that need to be applied to the addresses. Actually applying |
| 4904 | the relocations now does not help as they will probably resolve |
| 4905 | to 0, since the object file has not been fully linked. Real |
| 4906 | end of list markers will not have any relocations against them. */ |
| 4907 | if (! reloc_at (section, off) |
| 4908 | && ! reloc_at (section, off + pointer_size)) |
| 4909 | { |
| 4910 | printf (_("<End of list>\n")); |
| 4911 | break; |
| 4912 | } |
| 4913 | } |
| 4914 | |
| 4915 | /* Check base address specifiers. */ |
| 4916 | if (is_max_address (begin, pointer_size) |
| 4917 | && !is_max_address (end, pointer_size)) |
| 4918 | { |
| 4919 | base_address = end; |
| 4920 | print_dwarf_vma (begin, pointer_size); |
| 4921 | print_dwarf_vma (end, pointer_size); |
| 4922 | printf (_("(base address)\n")); |
| 4923 | continue; |
| 4924 | } |
| 4925 | |
| 4926 | if (start + 2 > section_end) |
| 4927 | { |
| 4928 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 4929 | (unsigned long) offset); |
| 4930 | break; |
| 4931 | } |
| 4932 | |
| 4933 | SAFE_BYTE_GET_AND_INC (length, start, 2, section_end); |
| 4934 | |
| 4935 | if (start + length > section_end) |
| 4936 | { |
| 4937 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 4938 | (unsigned long) offset); |
| 4939 | break; |
| 4940 | } |
| 4941 | |
| 4942 | print_dwarf_vma (begin + base_address, pointer_size); |
| 4943 | print_dwarf_vma (end + base_address, pointer_size); |
| 4944 | |
| 4945 | putchar ('('); |
| 4946 | need_frame_base = decode_location_expression (start, |
| 4947 | pointer_size, |
| 4948 | offset_size, |
| 4949 | dwarf_version, |
| 4950 | length, |
| 4951 | cu_offset, section); |
| 4952 | putchar (')'); |
| 4953 | |
| 4954 | if (need_frame_base && !has_frame_base) |
| 4955 | printf (_(" [without DW_AT_frame_base]")); |
| 4956 | |
| 4957 | if (begin == end) |
| 4958 | fputs (_(" (start == end)"), stdout); |
| 4959 | else if (begin > end) |
| 4960 | fputs (_(" (start > end)"), stdout); |
| 4961 | |
| 4962 | putchar ('\n'); |
| 4963 | |
| 4964 | start += length; |
| 4965 | } |
| 4966 | |
| 4967 | *start_ptr = start; |
| 4968 | } |
| 4969 | |
| 4970 | /* Display a location list from a normal (ie, non-dwo) .debug_loclists section. */ |
| 4971 | |
| 4972 | static void |
| 4973 | display_loclists_list (struct dwarf_section *section, |
| 4974 | unsigned char **start_ptr, |
| 4975 | unsigned int debug_info_entry, |
| 4976 | dwarf_vma offset, |
| 4977 | dwarf_vma base_address, |
| 4978 | int has_frame_base) |
| 4979 | { |
| 4980 | unsigned char *start = *start_ptr; |
| 4981 | unsigned char *section_end = section->start + section->size; |
| 4982 | unsigned long cu_offset; |
| 4983 | unsigned int pointer_size; |
| 4984 | unsigned int offset_size; |
| 4985 | int dwarf_version; |
| 4986 | unsigned int bytes_read; |
| 4987 | |
| 4988 | dwarf_vma begin; |
| 4989 | dwarf_vma end; |
| 4990 | dwarf_vma length; |
| 4991 | int need_frame_base; |
| 4992 | |
| 4993 | if (debug_info_entry >= num_debug_info_entries) |
| 4994 | { |
| 4995 | warn (_("No debug information available for " |
| 4996 | "loclists lists of entry: %u\n"), |
| 4997 | debug_info_entry); |
| 4998 | return; |
| 4999 | } |
| 5000 | |
| 5001 | cu_offset = debug_information [debug_info_entry].cu_offset; |
| 5002 | pointer_size = debug_information [debug_info_entry].pointer_size; |
| 5003 | offset_size = debug_information [debug_info_entry].offset_size; |
| 5004 | dwarf_version = debug_information [debug_info_entry].dwarf_version; |
| 5005 | |
| 5006 | if (pointer_size < 2 || pointer_size > 8) |
| 5007 | { |
| 5008 | warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), |
| 5009 | pointer_size, debug_info_entry); |
| 5010 | return; |
| 5011 | } |
| 5012 | |
| 5013 | while (1) |
| 5014 | { |
| 5015 | dwarf_vma off = offset + (start - *start_ptr); |
| 5016 | enum dwarf_location_list_entry_type llet; |
| 5017 | |
| 5018 | if (start + 1 > section_end) |
| 5019 | { |
| 5020 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 5021 | (unsigned long) offset); |
| 5022 | break; |
| 5023 | } |
| 5024 | |
| 5025 | printf (" %8.8lx ", (unsigned long) off); |
| 5026 | |
| 5027 | SAFE_BYTE_GET_AND_INC (llet, start, 1, section_end); |
| 5028 | |
| 5029 | switch (llet) |
| 5030 | { |
| 5031 | case DW_LLE_end_of_list: |
| 5032 | printf (_("<End of list>\n")); |
| 5033 | break; |
| 5034 | case DW_LLE_offset_pair: |
| 5035 | begin = read_uleb128 (start, &bytes_read, section_end); |
| 5036 | start += bytes_read; |
| 5037 | end = read_uleb128 (start, &bytes_read, section_end); |
| 5038 | start += bytes_read; |
| 5039 | break; |
| 5040 | case DW_LLE_base_address: |
| 5041 | SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, |
| 5042 | section_end); |
| 5043 | print_dwarf_vma (base_address, pointer_size); |
| 5044 | printf (_("(base address)\n")); |
| 5045 | break; |
| 5046 | default: |
| 5047 | error (_("Invalid location list entry type %d\n"), llet); |
| 5048 | return; |
| 5049 | } |
| 5050 | if (llet == DW_LLE_end_of_list) |
| 5051 | break; |
| 5052 | if (llet != DW_LLE_offset_pair) |
| 5053 | continue; |
| 5054 | |
| 5055 | if (start + 2 > section_end) |
| 5056 | { |
| 5057 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 5058 | (unsigned long) offset); |
| 5059 | break; |
| 5060 | } |
| 5061 | |
| 5062 | length = read_uleb128 (start, &bytes_read, section_end); |
| 5063 | start += bytes_read; |
| 5064 | |
| 5065 | print_dwarf_vma (begin + base_address, pointer_size); |
| 5066 | print_dwarf_vma (end + base_address, pointer_size); |
| 5067 | |
| 5068 | putchar ('('); |
| 5069 | need_frame_base = decode_location_expression (start, |
| 5070 | pointer_size, |
| 5071 | offset_size, |
| 5072 | dwarf_version, |
| 5073 | length, |
| 5074 | cu_offset, section); |
| 5075 | putchar (')'); |
| 5076 | |
| 5077 | if (need_frame_base && !has_frame_base) |
| 5078 | printf (_(" [without DW_AT_frame_base]")); |
| 5079 | |
| 5080 | if (begin == end) |
| 5081 | fputs (_(" (start == end)"), stdout); |
| 5082 | else if (begin > end) |
| 5083 | fputs (_(" (start > end)"), stdout); |
| 5084 | |
| 5085 | putchar ('\n'); |
| 5086 | |
| 5087 | start += length; |
| 5088 | } |
| 5089 | |
| 5090 | *start_ptr = start; |
| 5091 | } |
| 5092 | |
| 5093 | /* Print a .debug_addr table index in decimal, surrounded by square brackets, |
| 5094 | right-adjusted in a field of length LEN, and followed by a space. */ |
| 5095 | |
| 5096 | static void |
| 5097 | print_addr_index (unsigned int idx, unsigned int len) |
| 5098 | { |
| 5099 | static char buf[15]; |
| 5100 | snprintf (buf, sizeof (buf), "[%d]", idx); |
| 5101 | printf ("%*s ", len, buf); |
| 5102 | } |
| 5103 | |
| 5104 | /* Display a location list from a .dwo section. It uses address indexes rather |
| 5105 | than embedded addresses. This code closely follows display_loc_list, but the |
| 5106 | two are sufficiently different that combining things is very ugly. */ |
| 5107 | |
| 5108 | static void |
| 5109 | display_loc_list_dwo (struct dwarf_section *section, |
| 5110 | unsigned char **start_ptr, |
| 5111 | unsigned int debug_info_entry, |
| 5112 | dwarf_vma offset, |
| 5113 | int has_frame_base) |
| 5114 | { |
| 5115 | unsigned char *start = *start_ptr; |
| 5116 | unsigned char *section_end = section->start + section->size; |
| 5117 | unsigned long cu_offset; |
| 5118 | unsigned int pointer_size; |
| 5119 | unsigned int offset_size; |
| 5120 | int dwarf_version; |
| 5121 | int entry_type; |
| 5122 | unsigned short length; |
| 5123 | int need_frame_base; |
| 5124 | unsigned int idx; |
| 5125 | unsigned int bytes_read; |
| 5126 | |
| 5127 | if (debug_info_entry >= num_debug_info_entries) |
| 5128 | { |
| 5129 | warn (_("No debug information for loc lists of entry: %u\n"), |
| 5130 | debug_info_entry); |
| 5131 | return; |
| 5132 | } |
| 5133 | |
| 5134 | cu_offset = debug_information [debug_info_entry].cu_offset; |
| 5135 | pointer_size = debug_information [debug_info_entry].pointer_size; |
| 5136 | offset_size = debug_information [debug_info_entry].offset_size; |
| 5137 | dwarf_version = debug_information [debug_info_entry].dwarf_version; |
| 5138 | |
| 5139 | if (pointer_size < 2 || pointer_size > 8) |
| 5140 | { |
| 5141 | warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), |
| 5142 | pointer_size, debug_info_entry); |
| 5143 | return; |
| 5144 | } |
| 5145 | |
| 5146 | while (1) |
| 5147 | { |
| 5148 | printf (" %8.8lx ", (unsigned long) (offset + (start - *start_ptr))); |
| 5149 | |
| 5150 | if (start >= section_end) |
| 5151 | { |
| 5152 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 5153 | (unsigned long) offset); |
| 5154 | break; |
| 5155 | } |
| 5156 | |
| 5157 | SAFE_BYTE_GET_AND_INC (entry_type, start, 1, section_end); |
| 5158 | switch (entry_type) |
| 5159 | { |
| 5160 | case 0: /* A terminating entry. */ |
| 5161 | *start_ptr = start; |
| 5162 | printf (_("<End of list>\n")); |
| 5163 | return; |
| 5164 | case 1: /* A base-address entry. */ |
| 5165 | idx = read_uleb128 (start, &bytes_read, section_end); |
| 5166 | start += bytes_read; |
| 5167 | print_addr_index (idx, 8); |
| 5168 | printf (" "); |
| 5169 | printf (_("(base address selection entry)\n")); |
| 5170 | continue; |
| 5171 | case 2: /* A start/end entry. */ |
| 5172 | idx = read_uleb128 (start, &bytes_read, section_end); |
| 5173 | start += bytes_read; |
| 5174 | print_addr_index (idx, 8); |
| 5175 | idx = read_uleb128 (start, &bytes_read, section_end); |
| 5176 | start += bytes_read; |
| 5177 | print_addr_index (idx, 8); |
| 5178 | break; |
| 5179 | case 3: /* A start/length entry. */ |
| 5180 | idx = read_uleb128 (start, &bytes_read, section_end); |
| 5181 | start += bytes_read; |
| 5182 | print_addr_index (idx, 8); |
| 5183 | SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); |
| 5184 | printf ("%08x ", idx); |
| 5185 | break; |
| 5186 | case 4: /* An offset pair entry. */ |
| 5187 | SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); |
| 5188 | printf ("%08x ", idx); |
| 5189 | SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); |
| 5190 | printf ("%08x ", idx); |
| 5191 | break; |
| 5192 | default: |
| 5193 | warn (_("Unknown location list entry type 0x%x.\n"), entry_type); |
| 5194 | *start_ptr = start; |
| 5195 | return; |
| 5196 | } |
| 5197 | |
| 5198 | if (start + 2 > section_end) |
| 5199 | { |
| 5200 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 5201 | (unsigned long) offset); |
| 5202 | break; |
| 5203 | } |
| 5204 | |
| 5205 | SAFE_BYTE_GET_AND_INC (length, start, 2, section_end); |
| 5206 | if (start + length > section_end) |
| 5207 | { |
| 5208 | warn (_("Location list starting at offset 0x%lx is not terminated.\n"), |
| 5209 | (unsigned long) offset); |
| 5210 | break; |
| 5211 | } |
| 5212 | |
| 5213 | putchar ('('); |
| 5214 | need_frame_base = decode_location_expression (start, |
| 5215 | pointer_size, |
| 5216 | offset_size, |
| 5217 | dwarf_version, |
| 5218 | length, |
| 5219 | cu_offset, section); |
| 5220 | putchar (')'); |
| 5221 | |
| 5222 | if (need_frame_base && !has_frame_base) |
| 5223 | printf (_(" [without DW_AT_frame_base]")); |
| 5224 | |
| 5225 | putchar ('\n'); |
| 5226 | |
| 5227 | start += length; |
| 5228 | } |
| 5229 | |
| 5230 | *start_ptr = start; |
| 5231 | } |
| 5232 | |
| 5233 | /* Sort array of indexes in ascending order of loc_offsets[idx]. */ |
| 5234 | |
| 5235 | static dwarf_vma *loc_offsets; |
| 5236 | |
| 5237 | static int |
| 5238 | loc_offsets_compar (const void *ap, const void *bp) |
| 5239 | { |
| 5240 | dwarf_vma a = loc_offsets[*(const unsigned int *) ap]; |
| 5241 | dwarf_vma b = loc_offsets[*(const unsigned int *) bp]; |
| 5242 | |
| 5243 | return (a > b) - (b > a); |
| 5244 | } |
| 5245 | |
| 5246 | static int |
| 5247 | display_debug_loc (struct dwarf_section *section, void *file) |
| 5248 | { |
| 5249 | unsigned char *start = section->start; |
| 5250 | unsigned long bytes; |
| 5251 | unsigned char *section_begin = start; |
| 5252 | unsigned int num_loc_list = 0; |
| 5253 | unsigned long last_offset = 0; |
| 5254 | unsigned int first = 0; |
| 5255 | unsigned int i; |
| 5256 | unsigned int j; |
| 5257 | int seen_first_offset = 0; |
| 5258 | int locs_sorted = 1; |
| 5259 | unsigned char *next; |
| 5260 | unsigned int *array = NULL; |
| 5261 | const char *suffix = strrchr (section->name, '.'); |
| 5262 | int is_dwo = 0; |
| 5263 | int is_loclists = strstr (section->name, "debug_loclists") != NULL; |
| 5264 | dwarf_vma expected_start = 0; |
| 5265 | |
| 5266 | if (suffix && strcmp (suffix, ".dwo") == 0) |
| 5267 | is_dwo = 1; |
| 5268 | |
| 5269 | bytes = section->size; |
| 5270 | |
| 5271 | if (bytes == 0) |
| 5272 | { |
| 5273 | printf (_("\nThe %s section is empty.\n"), section->name); |
| 5274 | return 0; |
| 5275 | } |
| 5276 | |
| 5277 | if (is_loclists) |
| 5278 | { |
| 5279 | unsigned char *hdrptr = section_begin; |
| 5280 | dwarf_vma ll_length; |
| 5281 | unsigned short ll_version; |
| 5282 | unsigned char *end = section_begin + section->size; |
| 5283 | unsigned char address_size, segment_selector_size; |
| 5284 | uint32_t offset_entry_count; |
| 5285 | |
| 5286 | SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 4, end); |
| 5287 | if (ll_length == 0xffffffff) |
| 5288 | SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 8, end); |
| 5289 | |
| 5290 | SAFE_BYTE_GET_AND_INC (ll_version, hdrptr, 2, end); |
| 5291 | if (ll_version != 5) |
| 5292 | { |
| 5293 | warn (_("The %s section contains corrupt or " |
| 5294 | "unsupported version number: %d.\n"), |
| 5295 | section->name, ll_version); |
| 5296 | return 0; |
| 5297 | } |
| 5298 | |
| 5299 | SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end); |
| 5300 | |
| 5301 | SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end); |
| 5302 | if (segment_selector_size != 0) |
| 5303 | { |
| 5304 | warn (_("The %s section contains " |
| 5305 | "unsupported segment selector size: %d.\n"), |
| 5306 | section->name, segment_selector_size); |
| 5307 | return 0; |
| 5308 | } |
| 5309 | |
| 5310 | SAFE_BYTE_GET_AND_INC (offset_entry_count, hdrptr, 4, end); |
| 5311 | if (offset_entry_count != 0) |
| 5312 | { |
| 5313 | warn (_("The %s section contains " |
| 5314 | "unsupported offset entry count: %d.\n"), |
| 5315 | section->name, offset_entry_count); |
| 5316 | return 0; |
| 5317 | } |
| 5318 | |
| 5319 | expected_start = hdrptr - section_begin; |
| 5320 | } |
| 5321 | |
| 5322 | if (load_debug_info (file) == 0) |
| 5323 | { |
| 5324 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), |
| 5325 | section->name); |
| 5326 | return 0; |
| 5327 | } |
| 5328 | |
| 5329 | /* Check the order of location list in .debug_info section. If |
| 5330 | offsets of location lists are in the ascending order, we can |
| 5331 | use `debug_information' directly. */ |
| 5332 | for (i = 0; i < num_debug_info_entries; i++) |
| 5333 | { |
| 5334 | unsigned int num; |
| 5335 | |
| 5336 | num = debug_information [i].num_loc_offsets; |
| 5337 | if (num > num_loc_list) |
| 5338 | num_loc_list = num; |
| 5339 | |
| 5340 | /* Check if we can use `debug_information' directly. */ |
| 5341 | if (locs_sorted && num != 0) |
| 5342 | { |
| 5343 | if (!seen_first_offset) |
| 5344 | { |
| 5345 | /* This is the first location list. */ |
| 5346 | last_offset = debug_information [i].loc_offsets [0]; |
| 5347 | first = i; |
| 5348 | seen_first_offset = 1; |
| 5349 | j = 1; |
| 5350 | } |
| 5351 | else |
| 5352 | j = 0; |
| 5353 | |
| 5354 | for (; j < num; j++) |
| 5355 | { |
| 5356 | if (last_offset > |
| 5357 | debug_information [i].loc_offsets [j]) |
| 5358 | { |
| 5359 | locs_sorted = 0; |
| 5360 | break; |
| 5361 | } |
| 5362 | last_offset = debug_information [i].loc_offsets [j]; |
| 5363 | } |
| 5364 | } |
| 5365 | } |
| 5366 | |
| 5367 | if (!seen_first_offset) |
| 5368 | error (_("No location lists in .debug_info section!\n")); |
| 5369 | |
| 5370 | if (debug_information [first].num_loc_offsets > 0 |
| 5371 | && debug_information [first].loc_offsets [0] != expected_start) |
| 5372 | warn (_("Location lists in %s section start at 0x%s\n"), |
| 5373 | section->name, |
| 5374 | dwarf_vmatoa ("x", debug_information [first].loc_offsets [0])); |
| 5375 | |
| 5376 | if (!locs_sorted) |
| 5377 | array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int)); |
| 5378 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 5379 | if (reloc_at (section, 0)) |
| 5380 | printf (_(" Warning: This section has relocations - addresses seen here may not be accurate.\n\n")); |
| 5381 | printf (_(" Offset Begin End Expression\n")); |
| 5382 | |
| 5383 | seen_first_offset = 0; |
| 5384 | for (i = first; i < num_debug_info_entries; i++) |
| 5385 | { |
| 5386 | dwarf_vma offset; |
| 5387 | dwarf_vma base_address; |
| 5388 | unsigned int k; |
| 5389 | int has_frame_base; |
| 5390 | |
| 5391 | if (!locs_sorted) |
| 5392 | { |
| 5393 | for (k = 0; k < debug_information [i].num_loc_offsets; k++) |
| 5394 | array[k] = k; |
| 5395 | loc_offsets = debug_information [i].loc_offsets; |
| 5396 | qsort (array, debug_information [i].num_loc_offsets, |
| 5397 | sizeof (*array), loc_offsets_compar); |
| 5398 | } |
| 5399 | |
| 5400 | for (k = 0; k < debug_information [i].num_loc_offsets; k++) |
| 5401 | { |
| 5402 | j = locs_sorted ? k : array[k]; |
| 5403 | if (k |
| 5404 | && debug_information [i].loc_offsets [locs_sorted |
| 5405 | ? k - 1 : array [k - 1]] |
| 5406 | == debug_information [i].loc_offsets [j]) |
| 5407 | continue; |
| 5408 | has_frame_base = debug_information [i].have_frame_base [j]; |
| 5409 | offset = debug_information [i].loc_offsets [j]; |
| 5410 | next = section_begin + offset; |
| 5411 | base_address = debug_information [i].base_address; |
| 5412 | |
| 5413 | if (!seen_first_offset) |
| 5414 | seen_first_offset = 1; |
| 5415 | else |
| 5416 | { |
| 5417 | if (start < next) |
| 5418 | warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"), |
| 5419 | (unsigned long) (start - section_begin), |
| 5420 | (unsigned long) offset); |
| 5421 | else if (start > next) |
| 5422 | warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"), |
| 5423 | (unsigned long) (start - section_begin), |
| 5424 | (unsigned long) offset); |
| 5425 | } |
| 5426 | start = next; |
| 5427 | |
| 5428 | if (offset >= bytes) |
| 5429 | { |
| 5430 | warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"), |
| 5431 | (unsigned long) offset); |
| 5432 | continue; |
| 5433 | } |
| 5434 | |
| 5435 | if (!is_loclists) |
| 5436 | { |
| 5437 | if (is_dwo) |
| 5438 | display_loc_list_dwo (section, &start, i, offset, |
| 5439 | has_frame_base); |
| 5440 | else |
| 5441 | display_loc_list (section, &start, i, offset, base_address, |
| 5442 | has_frame_base); |
| 5443 | } |
| 5444 | else |
| 5445 | { |
| 5446 | if (is_dwo) |
| 5447 | warn (_("DWO is not yet supported.\n")); |
| 5448 | else |
| 5449 | display_loclists_list (section, &start, i, offset, base_address, |
| 5450 | has_frame_base); |
| 5451 | } |
| 5452 | } |
| 5453 | } |
| 5454 | |
| 5455 | if (start < section->start + section->size) |
| 5456 | warn (_("There are %ld unused bytes at the end of section %s\n"), |
| 5457 | (long) (section->start + section->size - start), section->name); |
| 5458 | putchar ('\n'); |
| 5459 | free (array); |
| 5460 | return 1; |
| 5461 | } |
| 5462 | |
| 5463 | static int |
| 5464 | display_debug_str (struct dwarf_section *section, |
| 5465 | void *file ATTRIBUTE_UNUSED) |
| 5466 | { |
| 5467 | unsigned char *start = section->start; |
| 5468 | unsigned long bytes = section->size; |
| 5469 | dwarf_vma addr = section->address; |
| 5470 | |
| 5471 | if (bytes == 0) |
| 5472 | { |
| 5473 | printf (_("\nThe %s section is empty.\n"), section->name); |
| 5474 | return 0; |
| 5475 | } |
| 5476 | |
| 5477 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 5478 | |
| 5479 | while (bytes) |
| 5480 | { |
| 5481 | int j; |
| 5482 | int k; |
| 5483 | int lbytes; |
| 5484 | |
| 5485 | lbytes = (bytes > 16 ? 16 : bytes); |
| 5486 | |
| 5487 | printf (" 0x%8.8lx ", (unsigned long) addr); |
| 5488 | |
| 5489 | for (j = 0; j < 16; j++) |
| 5490 | { |
| 5491 | if (j < lbytes) |
| 5492 | printf ("%2.2x", start[j]); |
| 5493 | else |
| 5494 | printf (" "); |
| 5495 | |
| 5496 | if ((j & 3) == 3) |
| 5497 | printf (" "); |
| 5498 | } |
| 5499 | |
| 5500 | for (j = 0; j < lbytes; j++) |
| 5501 | { |
| 5502 | k = start[j]; |
| 5503 | if (k >= ' ' && k < 0x80) |
| 5504 | printf ("%c", k); |
| 5505 | else |
| 5506 | printf ("."); |
| 5507 | } |
| 5508 | |
| 5509 | putchar ('\n'); |
| 5510 | |
| 5511 | start += lbytes; |
| 5512 | addr += lbytes; |
| 5513 | bytes -= lbytes; |
| 5514 | } |
| 5515 | |
| 5516 | putchar ('\n'); |
| 5517 | |
| 5518 | return 1; |
| 5519 | } |
| 5520 | |
| 5521 | static int |
| 5522 | display_debug_info (struct dwarf_section *section, void *file) |
| 5523 | { |
| 5524 | return process_debug_info (section, file, section->abbrev_sec, 0, 0); |
| 5525 | } |
| 5526 | |
| 5527 | static int |
| 5528 | display_debug_types (struct dwarf_section *section, void *file) |
| 5529 | { |
| 5530 | return process_debug_info (section, file, section->abbrev_sec, 0, 1); |
| 5531 | } |
| 5532 | |
| 5533 | static int |
| 5534 | display_trace_info (struct dwarf_section *section, void *file) |
| 5535 | { |
| 5536 | return process_debug_info (section, file, section->abbrev_sec, 0, 0); |
| 5537 | } |
| 5538 | |
| 5539 | static int |
| 5540 | display_debug_aranges (struct dwarf_section *section, |
| 5541 | void *file ATTRIBUTE_UNUSED) |
| 5542 | { |
| 5543 | unsigned char *start = section->start; |
| 5544 | unsigned char *end = start + section->size; |
| 5545 | |
| 5546 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 5547 | |
| 5548 | /* It does not matter if this load fails, |
| 5549 | we test for that later on. */ |
| 5550 | load_debug_info (file); |
| 5551 | |
| 5552 | while (start < end) |
| 5553 | { |
| 5554 | unsigned char *hdrptr; |
| 5555 | DWARF2_Internal_ARange arange; |
| 5556 | unsigned char *addr_ranges; |
| 5557 | dwarf_vma length; |
| 5558 | dwarf_vma address; |
| 5559 | unsigned char address_size; |
| 5560 | int excess; |
| 5561 | unsigned int offset_size; |
| 5562 | unsigned int initial_length_size; |
| 5563 | |
| 5564 | hdrptr = start; |
| 5565 | |
| 5566 | SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 4, end); |
| 5567 | if (arange.ar_length == 0xffffffff) |
| 5568 | { |
| 5569 | SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 8, end); |
| 5570 | offset_size = 8; |
| 5571 | initial_length_size = 12; |
| 5572 | } |
| 5573 | else |
| 5574 | { |
| 5575 | offset_size = 4; |
| 5576 | initial_length_size = 4; |
| 5577 | } |
| 5578 | |
| 5579 | SAFE_BYTE_GET_AND_INC (arange.ar_version, hdrptr, 2, end); |
| 5580 | SAFE_BYTE_GET_AND_INC (arange.ar_info_offset, hdrptr, offset_size, end); |
| 5581 | |
| 5582 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE |
| 5583 | && num_debug_info_entries > 0 |
| 5584 | && find_debug_info_for_offset (arange.ar_info_offset) == NULL) |
| 5585 | warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), |
| 5586 | (unsigned long) arange.ar_info_offset, section->name); |
| 5587 | |
| 5588 | SAFE_BYTE_GET_AND_INC (arange.ar_pointer_size, hdrptr, 1, end); |
| 5589 | SAFE_BYTE_GET_AND_INC (arange.ar_segment_size, hdrptr, 1, end); |
| 5590 | |
| 5591 | if (arange.ar_version != 2 && arange.ar_version != 3) |
| 5592 | { |
| 5593 | /* PR 19872: A version number of 0 probably means that there is |
| 5594 | padding at the end of the .debug_aranges section. Gold puts |
| 5595 | it there when performing an incremental link, for example. |
| 5596 | So do not generate a warning in this case. */ |
| 5597 | if (arange.ar_version) |
| 5598 | warn (_("Only DWARF 2 and 3 aranges are currently supported.\n")); |
| 5599 | break; |
| 5600 | } |
| 5601 | |
| 5602 | printf (_(" Length: %ld\n"), |
| 5603 | (long) arange.ar_length); |
| 5604 | printf (_(" Version: %d\n"), arange.ar_version); |
| 5605 | printf (_(" Offset into .debug_info: 0x%lx\n"), |
| 5606 | (unsigned long) arange.ar_info_offset); |
| 5607 | printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size); |
| 5608 | printf (_(" Segment Size: %d\n"), arange.ar_segment_size); |
| 5609 | |
| 5610 | address_size = arange.ar_pointer_size + arange.ar_segment_size; |
| 5611 | |
| 5612 | /* PR 17512: file: 001-108546-0.001:0.1. */ |
| 5613 | if (address_size == 0 || address_size > 8) |
| 5614 | { |
| 5615 | error (_("Invalid address size in %s section!\n"), |
| 5616 | section->name); |
| 5617 | break; |
| 5618 | } |
| 5619 | |
| 5620 | /* The DWARF spec does not require that the address size be a power |
| 5621 | of two, but we do. This will have to change if we ever encounter |
| 5622 | an uneven architecture. */ |
| 5623 | if ((address_size & (address_size - 1)) != 0) |
| 5624 | { |
| 5625 | warn (_("Pointer size + Segment size is not a power of two.\n")); |
| 5626 | break; |
| 5627 | } |
| 5628 | |
| 5629 | if (address_size > 4) |
| 5630 | printf (_("\n Address Length\n")); |
| 5631 | else |
| 5632 | printf (_("\n Address Length\n")); |
| 5633 | |
| 5634 | addr_ranges = hdrptr; |
| 5635 | |
| 5636 | /* Must pad to an alignment boundary that is twice the address size. */ |
| 5637 | excess = (hdrptr - start) % (2 * address_size); |
| 5638 | if (excess) |
| 5639 | addr_ranges += (2 * address_size) - excess; |
| 5640 | |
| 5641 | hdrptr = start + arange.ar_length + initial_length_size; |
| 5642 | if (hdrptr < start || hdrptr > end) |
| 5643 | { |
| 5644 | error (_("Excessive header length: %lx\n"), (long) arange.ar_length); |
| 5645 | break; |
| 5646 | } |
| 5647 | start = hdrptr; |
| 5648 | |
| 5649 | while (addr_ranges + 2 * address_size <= start) |
| 5650 | { |
| 5651 | SAFE_BYTE_GET_AND_INC (address, addr_ranges, address_size, end); |
| 5652 | SAFE_BYTE_GET_AND_INC (length, addr_ranges, address_size, end); |
| 5653 | |
| 5654 | printf (" "); |
| 5655 | print_dwarf_vma (address, address_size); |
| 5656 | print_dwarf_vma (length, address_size); |
| 5657 | putchar ('\n'); |
| 5658 | } |
| 5659 | } |
| 5660 | |
| 5661 | printf ("\n"); |
| 5662 | |
| 5663 | return 1; |
| 5664 | } |
| 5665 | |
| 5666 | /* Comparison function for qsort. */ |
| 5667 | static int |
| 5668 | comp_addr_base (const void * v0, const void * v1) |
| 5669 | { |
| 5670 | debug_info * info0 = (debug_info *) v0; |
| 5671 | debug_info * info1 = (debug_info *) v1; |
| 5672 | return info0->addr_base - info1->addr_base; |
| 5673 | } |
| 5674 | |
| 5675 | /* Display the debug_addr section. */ |
| 5676 | static int |
| 5677 | display_debug_addr (struct dwarf_section *section, |
| 5678 | void *file) |
| 5679 | { |
| 5680 | debug_info **debug_addr_info; |
| 5681 | unsigned char *entry; |
| 5682 | unsigned char *end; |
| 5683 | unsigned int i; |
| 5684 | unsigned int count; |
| 5685 | |
| 5686 | if (section->size == 0) |
| 5687 | { |
| 5688 | printf (_("\nThe %s section is empty.\n"), section->name); |
| 5689 | return 0; |
| 5690 | } |
| 5691 | |
| 5692 | if (load_debug_info (file) == 0) |
| 5693 | { |
| 5694 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), |
| 5695 | section->name); |
| 5696 | return 0; |
| 5697 | } |
| 5698 | |
| 5699 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 5700 | |
| 5701 | /* PR 17531: file: cf38d01b. |
| 5702 | We use xcalloc because a corrupt file may not have initialised all of the |
| 5703 | fields in the debug_info structure, which means that the sort below might |
| 5704 | try to move uninitialised data. */ |
| 5705 | debug_addr_info = (debug_info **) xcalloc ((num_debug_info_entries + 1), |
| 5706 | sizeof (debug_info *)); |
| 5707 | |
| 5708 | count = 0; |
| 5709 | for (i = 0; i < num_debug_info_entries; i++) |
| 5710 | if (debug_information [i].addr_base != DEBUG_INFO_UNAVAILABLE) |
| 5711 | { |
| 5712 | /* PR 17531: file: cf38d01b. */ |
| 5713 | if (debug_information[i].addr_base >= section->size) |
| 5714 | warn (_("Corrupt address base (%lx) found in debug section %u\n"), |
| 5715 | (unsigned long) debug_information[i].addr_base, i); |
| 5716 | else |
| 5717 | debug_addr_info [count++] = debug_information + i; |
| 5718 | } |
| 5719 | |
| 5720 | /* Add a sentinel to make iteration convenient. */ |
| 5721 | debug_addr_info [count] = (debug_info *) xmalloc (sizeof (debug_info)); |
| 5722 | debug_addr_info [count]->addr_base = section->size; |
| 5723 | qsort (debug_addr_info, count, sizeof (debug_info *), comp_addr_base); |
| 5724 | |
| 5725 | for (i = 0; i < count; i++) |
| 5726 | { |
| 5727 | unsigned int idx; |
| 5728 | unsigned int address_size = debug_addr_info [i]->pointer_size; |
| 5729 | |
| 5730 | printf (_(" For compilation unit at offset 0x%s:\n"), |
| 5731 | dwarf_vmatoa ("x", debug_addr_info [i]->cu_offset)); |
| 5732 | |
| 5733 | printf (_("\tIndex\tAddress\n")); |
| 5734 | entry = section->start + debug_addr_info [i]->addr_base; |
| 5735 | end = section->start + debug_addr_info [i + 1]->addr_base; |
| 5736 | idx = 0; |
| 5737 | while (entry < end) |
| 5738 | { |
| 5739 | dwarf_vma base = byte_get (entry, address_size); |
| 5740 | printf (_("\t%d:\t"), idx); |
| 5741 | print_dwarf_vma (base, address_size); |
| 5742 | printf ("\n"); |
| 5743 | entry += address_size; |
| 5744 | idx++; |
| 5745 | } |
| 5746 | } |
| 5747 | printf ("\n"); |
| 5748 | |
| 5749 | free (debug_addr_info); |
| 5750 | return 1; |
| 5751 | } |
| 5752 | |
| 5753 | /* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */ |
| 5754 | static int |
| 5755 | display_debug_str_offsets (struct dwarf_section *section, |
| 5756 | void *file ATTRIBUTE_UNUSED) |
| 5757 | { |
| 5758 | if (section->size == 0) |
| 5759 | { |
| 5760 | printf (_("\nThe %s section is empty.\n"), section->name); |
| 5761 | return 0; |
| 5762 | } |
| 5763 | /* TODO: Dump the contents. This is made somewhat difficult by not knowing |
| 5764 | what the offset size is for this section. */ |
| 5765 | return 1; |
| 5766 | } |
| 5767 | |
| 5768 | /* Each debug_information[x].range_lists[y] gets this representation for |
| 5769 | sorting purposes. */ |
| 5770 | |
| 5771 | struct range_entry |
| 5772 | { |
| 5773 | /* The debug_information[x].range_lists[y] value. */ |
| 5774 | dwarf_vma ranges_offset; |
| 5775 | |
| 5776 | /* Original debug_information to find parameters of the data. */ |
| 5777 | debug_info *debug_info_p; |
| 5778 | }; |
| 5779 | |
| 5780 | /* Sort struct range_entry in ascending order of its RANGES_OFFSET. */ |
| 5781 | |
| 5782 | static int |
| 5783 | range_entry_compar (const void *ap, const void *bp) |
| 5784 | { |
| 5785 | const struct range_entry *a_re = (const struct range_entry *) ap; |
| 5786 | const struct range_entry *b_re = (const struct range_entry *) bp; |
| 5787 | const dwarf_vma a = a_re->ranges_offset; |
| 5788 | const dwarf_vma b = b_re->ranges_offset; |
| 5789 | |
| 5790 | return (a > b) - (b > a); |
| 5791 | } |
| 5792 | |
| 5793 | static void |
| 5794 | display_debug_ranges_list (unsigned char *start, unsigned char *finish, |
| 5795 | unsigned int pointer_size, unsigned long offset, |
| 5796 | unsigned long base_address) |
| 5797 | { |
| 5798 | while (start < finish) |
| 5799 | { |
| 5800 | dwarf_vma begin; |
| 5801 | dwarf_vma end; |
| 5802 | |
| 5803 | SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish); |
| 5804 | if (start >= finish) |
| 5805 | break; |
| 5806 | SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish); |
| 5807 | |
| 5808 | printf (" %8.8lx ", offset); |
| 5809 | |
| 5810 | if (begin == 0 && end == 0) |
| 5811 | { |
| 5812 | printf (_("<End of list>\n")); |
| 5813 | break; |
| 5814 | } |
| 5815 | |
| 5816 | /* Check base address specifiers. */ |
| 5817 | if (is_max_address (begin, pointer_size) |
| 5818 | && !is_max_address (end, pointer_size)) |
| 5819 | { |
| 5820 | base_address = end; |
| 5821 | print_dwarf_vma (begin, pointer_size); |
| 5822 | print_dwarf_vma (end, pointer_size); |
| 5823 | printf ("(base address)\n"); |
| 5824 | continue; |
| 5825 | } |
| 5826 | |
| 5827 | print_dwarf_vma (begin + base_address, pointer_size); |
| 5828 | print_dwarf_vma (end + base_address, pointer_size); |
| 5829 | |
| 5830 | if (begin == end) |
| 5831 | fputs (_("(start == end)"), stdout); |
| 5832 | else if (begin > end) |
| 5833 | fputs (_("(start > end)"), stdout); |
| 5834 | |
| 5835 | putchar ('\n'); |
| 5836 | } |
| 5837 | } |
| 5838 | |
| 5839 | static void |
| 5840 | display_debug_rnglists_list (unsigned char *start, unsigned char *finish, |
| 5841 | unsigned int pointer_size, unsigned long offset, |
| 5842 | unsigned long base_address) |
| 5843 | { |
| 5844 | unsigned char *next = start; |
| 5845 | |
| 5846 | while (1) |
| 5847 | { |
| 5848 | unsigned long off = offset + (start - next); |
| 5849 | enum dwarf_range_list_entry rlet; |
| 5850 | dwarf_vma begin, length, end; |
| 5851 | unsigned int bytes_read; |
| 5852 | |
| 5853 | if (start + 1 > finish) |
| 5854 | { |
| 5855 | warn (_("Range list starting at offset 0x%lx is not terminated.\n"), |
| 5856 | offset); |
| 5857 | break; |
| 5858 | } |
| 5859 | |
| 5860 | printf (" %8.8lx ", off); |
| 5861 | |
| 5862 | SAFE_BYTE_GET_AND_INC (rlet, start, 1, finish); |
| 5863 | |
| 5864 | switch (rlet) |
| 5865 | { |
| 5866 | case DW_RLE_end_of_list: |
| 5867 | printf (_("<End of list>\n")); |
| 5868 | break; |
| 5869 | case DW_RLE_base_address: |
| 5870 | SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, finish); |
| 5871 | print_dwarf_vma (base_address, pointer_size); |
| 5872 | printf (_("(base address)\n")); |
| 5873 | break; |
| 5874 | case DW_RLE_start_length: |
| 5875 | SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish); |
| 5876 | length = read_uleb128 (start, &bytes_read, finish); |
| 5877 | start += bytes_read; |
| 5878 | end = begin + length; |
| 5879 | break; |
| 5880 | case DW_RLE_offset_pair: |
| 5881 | begin = read_uleb128 (start, &bytes_read, finish); |
| 5882 | start += bytes_read; |
| 5883 | end = read_uleb128 (start, &bytes_read, finish); |
| 5884 | start += bytes_read; |
| 5885 | break; |
| 5886 | case DW_RLE_start_end: |
| 5887 | SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish); |
| 5888 | SAFE_BYTE_GET_AND_INC (end, start, pointer_size, finish); |
| 5889 | break; |
| 5890 | default: |
| 5891 | error (_("Invalid range list entry type %d\n"), rlet); |
| 5892 | rlet = DW_RLE_end_of_list; |
| 5893 | break; |
| 5894 | } |
| 5895 | if (rlet == DW_RLE_end_of_list) |
| 5896 | break; |
| 5897 | if (rlet == DW_RLE_base_address) |
| 5898 | continue; |
| 5899 | |
| 5900 | print_dwarf_vma (begin + base_address, pointer_size); |
| 5901 | print_dwarf_vma (end + base_address, pointer_size); |
| 5902 | |
| 5903 | if (begin == end) |
| 5904 | fputs (_("(start == end)"), stdout); |
| 5905 | else if (begin > end) |
| 5906 | fputs (_("(start > end)"), stdout); |
| 5907 | |
| 5908 | putchar ('\n'); |
| 5909 | } |
| 5910 | } |
| 5911 | |
| 5912 | static int |
| 5913 | display_debug_ranges (struct dwarf_section *section, |
| 5914 | void *file ATTRIBUTE_UNUSED) |
| 5915 | { |
| 5916 | unsigned char *start = section->start; |
| 5917 | unsigned char *last_start = start; |
| 5918 | unsigned long bytes = section->size; |
| 5919 | unsigned char *section_begin = start; |
| 5920 | unsigned char *finish = start + bytes; |
| 5921 | unsigned int num_range_list, i; |
| 5922 | struct range_entry *range_entries, *range_entry_fill; |
| 5923 | int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; |
| 5924 | /* Initialize it due to a false compiler warning. */ |
| 5925 | unsigned char address_size = 0; |
| 5926 | |
| 5927 | if (bytes == 0) |
| 5928 | { |
| 5929 | printf (_("\nThe %s section is empty.\n"), section->name); |
| 5930 | return 0; |
| 5931 | } |
| 5932 | |
| 5933 | if (is_rnglists) |
| 5934 | { |
| 5935 | dwarf_vma initial_length; |
| 5936 | unsigned int initial_length_size; |
| 5937 | unsigned char segment_selector_size; |
| 5938 | unsigned int offset_size, offset_entry_count; |
| 5939 | unsigned short version; |
| 5940 | |
| 5941 | /* Get and check the length of the block. */ |
| 5942 | SAFE_BYTE_GET_AND_INC (initial_length, start, 4, finish); |
| 5943 | |
| 5944 | if (initial_length == 0xffffffff) |
| 5945 | { |
| 5946 | /* This section is 64-bit DWARF 3. */ |
| 5947 | SAFE_BYTE_GET_AND_INC (initial_length, start, 8, finish); |
| 5948 | offset_size = 8; |
| 5949 | initial_length_size = 12; |
| 5950 | } |
| 5951 | else |
| 5952 | { |
| 5953 | offset_size = 4; |
| 5954 | initial_length_size = 4; |
| 5955 | } |
| 5956 | |
| 5957 | if (initial_length + initial_length_size > section->size) |
| 5958 | { |
| 5959 | /* If the length field has a relocation against it, then we should |
| 5960 | not complain if it is inaccurate (and probably negative). |
| 5961 | It is copied from .debug_line handling code. */ |
| 5962 | if (reloc_at (section, (start - section->start) - offset_size)) |
| 5963 | { |
| 5964 | initial_length = (finish - start) - initial_length_size; |
| 5965 | } |
| 5966 | else |
| 5967 | { |
| 5968 | warn (_("The length field (0x%lx) in the debug_rnglists header is wrong - the section is too small\n"), |
| 5969 | (long) initial_length); |
| 5970 | return 0; |
| 5971 | } |
| 5972 | } |
| 5973 | |
| 5974 | /* Get and check the version number. */ |
| 5975 | SAFE_BYTE_GET_AND_INC (version, start, 2, finish); |
| 5976 | |
| 5977 | if (version != 5) |
| 5978 | { |
| 5979 | warn (_("Only DWARF version 5 debug_rnglists info " |
| 5980 | "is currently supported.\n")); |
| 5981 | return 0; |
| 5982 | } |
| 5983 | |
| 5984 | SAFE_BYTE_GET_AND_INC (address_size, start, 1, finish); |
| 5985 | |
| 5986 | SAFE_BYTE_GET_AND_INC (segment_selector_size, start, 1, finish); |
| 5987 | if (segment_selector_size != 0) |
| 5988 | { |
| 5989 | warn (_("The %s section contains " |
| 5990 | "unsupported segment selector size: %d.\n"), |
| 5991 | section->name, segment_selector_size); |
| 5992 | return 0; |
| 5993 | } |
| 5994 | |
| 5995 | SAFE_BYTE_GET_AND_INC (offset_entry_count, start, 4, finish); |
| 5996 | if (offset_entry_count != 0) |
| 5997 | { |
| 5998 | warn (_("The %s section contains " |
| 5999 | "unsupported offset entry count: %u.\n"), |
| 6000 | section->name, offset_entry_count); |
| 6001 | return 0; |
| 6002 | } |
| 6003 | } |
| 6004 | |
| 6005 | if (load_debug_info (file) == 0) |
| 6006 | { |
| 6007 | warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), |
| 6008 | section->name); |
| 6009 | return 0; |
| 6010 | } |
| 6011 | |
| 6012 | num_range_list = 0; |
| 6013 | for (i = 0; i < num_debug_info_entries; i++) |
| 6014 | num_range_list += debug_information [i].num_range_lists; |
| 6015 | |
| 6016 | if (num_range_list == 0) |
| 6017 | { |
| 6018 | /* This can happen when the file was compiled with -gsplit-debug |
| 6019 | which removes references to range lists from the primary .o file. */ |
| 6020 | printf (_("No range lists in .debug_info section.\n")); |
| 6021 | return 1; |
| 6022 | } |
| 6023 | |
| 6024 | range_entries = (struct range_entry *) |
| 6025 | xmalloc (sizeof (*range_entries) * num_range_list); |
| 6026 | range_entry_fill = range_entries; |
| 6027 | |
| 6028 | for (i = 0; i < num_debug_info_entries; i++) |
| 6029 | { |
| 6030 | debug_info *debug_info_p = &debug_information[i]; |
| 6031 | unsigned int j; |
| 6032 | |
| 6033 | for (j = 0; j < debug_info_p->num_range_lists; j++) |
| 6034 | { |
| 6035 | range_entry_fill->ranges_offset = debug_info_p->range_lists[j]; |
| 6036 | range_entry_fill->debug_info_p = debug_info_p; |
| 6037 | range_entry_fill++; |
| 6038 | } |
| 6039 | } |
| 6040 | |
| 6041 | qsort (range_entries, num_range_list, sizeof (*range_entries), |
| 6042 | range_entry_compar); |
| 6043 | |
| 6044 | if (dwarf_check != 0 && range_entries[0].ranges_offset != 0) |
| 6045 | warn (_("Range lists in %s section start at 0x%lx\n"), |
| 6046 | section->name, (unsigned long) range_entries[0].ranges_offset); |
| 6047 | |
| 6048 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 6049 | printf (_(" Offset Begin End\n")); |
| 6050 | |
| 6051 | for (i = 0; i < num_range_list; i++) |
| 6052 | { |
| 6053 | struct range_entry *range_entry = &range_entries[i]; |
| 6054 | debug_info *debug_info_p = range_entry->debug_info_p; |
| 6055 | unsigned int pointer_size; |
| 6056 | dwarf_vma offset; |
| 6057 | unsigned char *next; |
| 6058 | dwarf_vma base_address; |
| 6059 | |
| 6060 | pointer_size = (is_rnglists ? address_size : debug_info_p->pointer_size); |
| 6061 | offset = range_entry->ranges_offset; |
| 6062 | next = section_begin + offset; |
| 6063 | base_address = debug_info_p->base_address; |
| 6064 | |
| 6065 | /* PR 17512: file: 001-101485-0.001:0.1. */ |
| 6066 | if (pointer_size < 2 || pointer_size > 8) |
| 6067 | { |
| 6068 | warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"), |
| 6069 | pointer_size, (unsigned long) offset); |
| 6070 | continue; |
| 6071 | } |
| 6072 | |
| 6073 | if (dwarf_check != 0 && i > 0) |
| 6074 | { |
| 6075 | if (start < next) |
| 6076 | warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"), |
| 6077 | (unsigned long) (start - section_begin), |
| 6078 | (unsigned long) (next - section_begin), section->name); |
| 6079 | else if (start > next) |
| 6080 | { |
| 6081 | if (next == last_start) |
| 6082 | continue; |
| 6083 | warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"), |
| 6084 | (unsigned long) (start - section_begin), |
| 6085 | (unsigned long) (next - section_begin), section->name); |
| 6086 | } |
| 6087 | } |
| 6088 | start = next; |
| 6089 | last_start = next; |
| 6090 | |
| 6091 | (is_rnglists ? display_debug_rnglists_list : display_debug_ranges_list) |
| 6092 | (start, finish, pointer_size, offset, base_address); |
| 6093 | } |
| 6094 | putchar ('\n'); |
| 6095 | |
| 6096 | free (range_entries); |
| 6097 | |
| 6098 | return 1; |
| 6099 | } |
| 6100 | |
| 6101 | typedef struct Frame_Chunk |
| 6102 | { |
| 6103 | struct Frame_Chunk *next; |
| 6104 | unsigned char *chunk_start; |
| 6105 | unsigned int ncols; |
| 6106 | /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */ |
| 6107 | short int *col_type; |
| 6108 | int *col_offset; |
| 6109 | char *augmentation; |
| 6110 | unsigned int code_factor; |
| 6111 | int data_factor; |
| 6112 | dwarf_vma pc_begin; |
| 6113 | dwarf_vma pc_range; |
| 6114 | int cfa_reg; |
| 6115 | dwarf_vma cfa_offset; |
| 6116 | unsigned int ra; |
| 6117 | unsigned char fde_encoding; |
| 6118 | unsigned char cfa_exp; |
| 6119 | unsigned char ptr_size; |
| 6120 | unsigned char segment_size; |
| 6121 | } |
| 6122 | Frame_Chunk; |
| 6123 | |
| 6124 | static const char *const *dwarf_regnames; |
| 6125 | static unsigned int dwarf_regnames_count; |
| 6126 | |
| 6127 | /* A marker for a col_type that means this column was never referenced |
| 6128 | in the frame info. */ |
| 6129 | #define DW_CFA_unreferenced (-1) |
| 6130 | |
| 6131 | /* Return 0 if no more space is needed, 1 if more space is needed, |
| 6132 | -1 for invalid reg. */ |
| 6133 | |
| 6134 | static int |
| 6135 | frame_need_space (Frame_Chunk *fc, unsigned int reg) |
| 6136 | { |
| 6137 | unsigned int prev = fc->ncols; |
| 6138 | |
| 6139 | if (reg < (unsigned int) fc->ncols) |
| 6140 | return 0; |
| 6141 | |
| 6142 | if (dwarf_regnames_count |
| 6143 | && reg > dwarf_regnames_count) |
| 6144 | return -1; |
| 6145 | |
| 6146 | fc->ncols = reg + 1; |
| 6147 | /* PR 17512: file: 10450-2643-0.004. |
| 6148 | If reg == -1 then this can happen... */ |
| 6149 | if (fc->ncols == 0) |
| 6150 | return -1; |
| 6151 | |
| 6152 | /* PR 17512: file: 2844a11d. */ |
| 6153 | if (fc->ncols > 1024) |
| 6154 | { |
| 6155 | error (_("Unfeasibly large register number: %u\n"), reg); |
| 6156 | fc->ncols = 0; |
| 6157 | /* FIXME: 1024 is an arbitrary limit. Increase it if |
| 6158 | we ever encounter a valid binary that exceeds it. */ |
| 6159 | return -1; |
| 6160 | } |
| 6161 | |
| 6162 | fc->col_type = (short int *) xcrealloc (fc->col_type, fc->ncols, |
| 6163 | sizeof (short int)); |
| 6164 | fc->col_offset = (int *) xcrealloc (fc->col_offset, fc->ncols, sizeof (int)); |
| 6165 | /* PR 17512: file:002-10025-0.005. */ |
| 6166 | if (fc->col_type == NULL || fc->col_offset == NULL) |
| 6167 | { |
| 6168 | error (_("Out of memory allocating %u columns in dwarf frame arrays\n"), |
| 6169 | fc->ncols); |
| 6170 | fc->ncols = 0; |
| 6171 | return -1; |
| 6172 | } |
| 6173 | |
| 6174 | while (prev < fc->ncols) |
| 6175 | { |
| 6176 | fc->col_type[prev] = DW_CFA_unreferenced; |
| 6177 | fc->col_offset[prev] = 0; |
| 6178 | prev++; |
| 6179 | } |
| 6180 | return 1; |
| 6181 | } |
| 6182 | |
| 6183 | static const char *const dwarf_regnames_i386[] = |
| 6184 | { |
| 6185 | "eax", "ecx", "edx", "ebx", /* 0 - 3 */ |
| 6186 | "esp", "ebp", "esi", "edi", /* 4 - 7 */ |
| 6187 | "eip", "eflags", NULL, /* 8 - 10 */ |
| 6188 | "st0", "st1", "st2", "st3", /* 11 - 14 */ |
| 6189 | "st4", "st5", "st6", "st7", /* 15 - 18 */ |
| 6190 | NULL, NULL, /* 19 - 20 */ |
| 6191 | "xmm0", "xmm1", "xmm2", "xmm3", /* 21 - 24 */ |
| 6192 | "xmm4", "xmm5", "xmm6", "xmm7", /* 25 - 28 */ |
| 6193 | "mm0", "mm1", "mm2", "mm3", /* 29 - 32 */ |
| 6194 | "mm4", "mm5", "mm6", "mm7", /* 33 - 36 */ |
| 6195 | "fcw", "fsw", "mxcsr", /* 37 - 39 */ |
| 6196 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, /* 40 - 47 */ |
| 6197 | "tr", "ldtr", /* 48 - 49 */ |
| 6198 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 50 - 57 */ |
| 6199 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 58 - 65 */ |
| 6200 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 66 - 73 */ |
| 6201 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 74 - 81 */ |
| 6202 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 82 - 89 */ |
| 6203 | NULL, NULL, NULL, /* 90 - 92 */ |
| 6204 | "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" /* 93 - 100 */ |
| 6205 | }; |
| 6206 | |
| 6207 | static const char *const dwarf_regnames_iamcu[] = |
| 6208 | { |
| 6209 | "eax", "ecx", "edx", "ebx", /* 0 - 3 */ |
| 6210 | "esp", "ebp", "esi", "edi", /* 4 - 7 */ |
| 6211 | "eip", "eflags", NULL, /* 8 - 10 */ |
| 6212 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 11 - 18 */ |
| 6213 | NULL, NULL, /* 19 - 20 */ |
| 6214 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 21 - 28 */ |
| 6215 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 29 - 36 */ |
| 6216 | NULL, NULL, NULL, /* 37 - 39 */ |
| 6217 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, /* 40 - 47 */ |
| 6218 | "tr", "ldtr", /* 48 - 49 */ |
| 6219 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 50 - 57 */ |
| 6220 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 58 - 65 */ |
| 6221 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 66 - 73 */ |
| 6222 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 74 - 81 */ |
| 6223 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 82 - 89 */ |
| 6224 | NULL, NULL, NULL, /* 90 - 92 */ |
| 6225 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL /* 93 - 100 */ |
| 6226 | }; |
| 6227 | |
| 6228 | void |
| 6229 | init_dwarf_regnames_i386 (void) |
| 6230 | { |
| 6231 | dwarf_regnames = dwarf_regnames_i386; |
| 6232 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386); |
| 6233 | } |
| 6234 | |
| 6235 | void |
| 6236 | init_dwarf_regnames_iamcu (void) |
| 6237 | { |
| 6238 | dwarf_regnames = dwarf_regnames_iamcu; |
| 6239 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_iamcu); |
| 6240 | } |
| 6241 | |
| 6242 | static const char *const dwarf_regnames_x86_64[] = |
| 6243 | { |
| 6244 | "rax", "rdx", "rcx", "rbx", |
| 6245 | "rsi", "rdi", "rbp", "rsp", |
| 6246 | "r8", "r9", "r10", "r11", |
| 6247 | "r12", "r13", "r14", "r15", |
| 6248 | "rip", |
| 6249 | "xmm0", "xmm1", "xmm2", "xmm3", |
| 6250 | "xmm4", "xmm5", "xmm6", "xmm7", |
| 6251 | "xmm8", "xmm9", "xmm10", "xmm11", |
| 6252 | "xmm12", "xmm13", "xmm14", "xmm15", |
| 6253 | "st0", "st1", "st2", "st3", |
| 6254 | "st4", "st5", "st6", "st7", |
| 6255 | "mm0", "mm1", "mm2", "mm3", |
| 6256 | "mm4", "mm5", "mm6", "mm7", |
| 6257 | "rflags", |
| 6258 | "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, |
| 6259 | "fs.base", "gs.base", NULL, NULL, |
| 6260 | "tr", "ldtr", |
| 6261 | "mxcsr", "fcw", "fsw", |
| 6262 | "xmm16", "xmm17", "xmm18", "xmm19", |
| 6263 | "xmm20", "xmm21", "xmm22", "xmm23", |
| 6264 | "xmm24", "xmm25", "xmm26", "xmm27", |
| 6265 | "xmm28", "xmm29", "xmm30", "xmm31", |
| 6266 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 83 - 90 */ |
| 6267 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 91 - 98 */ |
| 6268 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 99 - 106 */ |
| 6269 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 107 - 114 */ |
| 6270 | NULL, NULL, NULL, /* 115 - 117 */ |
| 6271 | "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" |
| 6272 | }; |
| 6273 | |
| 6274 | void |
| 6275 | init_dwarf_regnames_x86_64 (void) |
| 6276 | { |
| 6277 | dwarf_regnames = dwarf_regnames_x86_64; |
| 6278 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64); |
| 6279 | } |
| 6280 | |
| 6281 | static const char *const dwarf_regnames_aarch64[] = |
| 6282 | { |
| 6283 | "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", |
| 6284 | "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", |
| 6285 | "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", |
| 6286 | "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp", |
| 6287 | NULL, "elr", NULL, NULL, NULL, NULL, NULL, NULL, |
| 6288 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
| 6289 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
| 6290 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
| 6291 | "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", |
| 6292 | "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", |
| 6293 | "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", |
| 6294 | "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", |
| 6295 | }; |
| 6296 | |
| 6297 | void |
| 6298 | init_dwarf_regnames_aarch64 (void) |
| 6299 | { |
| 6300 | dwarf_regnames = dwarf_regnames_aarch64; |
| 6301 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_aarch64); |
| 6302 | } |
| 6303 | |
| 6304 | static const char *const dwarf_regnames_s390[] = |
| 6305 | { |
| 6306 | /* Avoid saying "r5 (r5)", so omit the names of r0-r15. */ |
| 6307 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
| 6308 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
| 6309 | "f0", "f2", "f4", "f6", "f1", "f3", "f5", "f7", |
| 6310 | "f8", "f10", "f12", "f14", "f9", "f11", "f13", "f15", |
| 6311 | "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", |
| 6312 | "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", "cr15", |
| 6313 | "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", |
| 6314 | "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", |
| 6315 | "pswm", "pswa", |
| 6316 | NULL, NULL, |
| 6317 | "v16", "v18", "v20", "v22", "v17", "v19", "v21", "v23", |
| 6318 | "v24", "v26", "v28", "v30", "v25", "v27", "v29", "v31", |
| 6319 | }; |
| 6320 | |
| 6321 | void |
| 6322 | init_dwarf_regnames_s390 (void) |
| 6323 | { |
| 6324 | dwarf_regnames = dwarf_regnames_s390; |
| 6325 | dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_s390); |
| 6326 | } |
| 6327 | |
| 6328 | void |
| 6329 | init_dwarf_regnames (unsigned int e_machine) |
| 6330 | { |
| 6331 | switch (e_machine) |
| 6332 | { |
| 6333 | case EM_386: |
| 6334 | init_dwarf_regnames_i386 (); |
| 6335 | break; |
| 6336 | |
| 6337 | case EM_IAMCU: |
| 6338 | init_dwarf_regnames_iamcu (); |
| 6339 | break; |
| 6340 | |
| 6341 | case EM_X86_64: |
| 6342 | case EM_L1OM: |
| 6343 | case EM_K1OM: |
| 6344 | init_dwarf_regnames_x86_64 (); |
| 6345 | break; |
| 6346 | |
| 6347 | case EM_AARCH64: |
| 6348 | init_dwarf_regnames_aarch64 (); |
| 6349 | break; |
| 6350 | |
| 6351 | case EM_S390: |
| 6352 | init_dwarf_regnames_s390 (); |
| 6353 | break; |
| 6354 | |
| 6355 | default: |
| 6356 | break; |
| 6357 | } |
| 6358 | } |
| 6359 | |
| 6360 | static const char * |
| 6361 | regname (unsigned int regno, int row) |
| 6362 | { |
| 6363 | static char reg[64]; |
| 6364 | if (dwarf_regnames |
| 6365 | && regno < dwarf_regnames_count |
| 6366 | && dwarf_regnames [regno] != NULL) |
| 6367 | { |
| 6368 | if (row) |
| 6369 | return dwarf_regnames [regno]; |
| 6370 | snprintf (reg, sizeof (reg), "r%d (%s)", regno, |
| 6371 | dwarf_regnames [regno]); |
| 6372 | } |
| 6373 | else |
| 6374 | snprintf (reg, sizeof (reg), "r%d", regno); |
| 6375 | return reg; |
| 6376 | } |
| 6377 | |
| 6378 | static void |
| 6379 | frame_display_row (Frame_Chunk *fc, int *need_col_headers, unsigned int *max_regs) |
| 6380 | { |
| 6381 | unsigned int r; |
| 6382 | char tmp[100]; |
| 6383 | |
| 6384 | if (*max_regs != fc->ncols) |
| 6385 | *max_regs = fc->ncols; |
| 6386 | |
| 6387 | if (*need_col_headers) |
| 6388 | { |
| 6389 | static const char *sloc = " LOC"; |
| 6390 | |
| 6391 | *need_col_headers = 0; |
| 6392 | |
| 6393 | printf ("%-*s CFA ", eh_addr_size * 2, sloc); |
| 6394 | |
| 6395 | for (r = 0; r < *max_regs; r++) |
| 6396 | if (fc->col_type[r] != DW_CFA_unreferenced) |
| 6397 | { |
| 6398 | if (r == fc->ra) |
| 6399 | printf ("ra "); |
| 6400 | else |
| 6401 | printf ("%-5s ", regname (r, 1)); |
| 6402 | } |
| 6403 | |
| 6404 | printf ("\n"); |
| 6405 | } |
| 6406 | |
| 6407 | print_dwarf_vma (fc->pc_begin, eh_addr_size); |
| 6408 | if (fc->cfa_exp) |
| 6409 | strcpy (tmp, "exp"); |
| 6410 | else |
| 6411 | sprintf (tmp, "%s%+d", regname (fc->cfa_reg, 1), (int) fc->cfa_offset); |
| 6412 | printf ("%-8s ", tmp); |
| 6413 | |
| 6414 | for (r = 0; r < fc->ncols; r++) |
| 6415 | { |
| 6416 | if (fc->col_type[r] != DW_CFA_unreferenced) |
| 6417 | { |
| 6418 | switch (fc->col_type[r]) |
| 6419 | { |
| 6420 | case DW_CFA_undefined: |
| 6421 | strcpy (tmp, "u"); |
| 6422 | break; |
| 6423 | case DW_CFA_same_value: |
| 6424 | strcpy (tmp, "s"); |
| 6425 | break; |
| 6426 | case DW_CFA_offset: |
| 6427 | sprintf (tmp, "c%+d", fc->col_offset[r]); |
| 6428 | break; |
| 6429 | case DW_CFA_val_offset: |
| 6430 | sprintf (tmp, "v%+d", fc->col_offset[r]); |
| 6431 | break; |
| 6432 | case DW_CFA_register: |
| 6433 | sprintf (tmp, "%s", regname (fc->col_offset[r], 0)); |
| 6434 | break; |
| 6435 | case DW_CFA_expression: |
| 6436 | strcpy (tmp, "exp"); |
| 6437 | break; |
| 6438 | case DW_CFA_val_expression: |
| 6439 | strcpy (tmp, "vexp"); |
| 6440 | break; |
| 6441 | default: |
| 6442 | strcpy (tmp, "n/a"); |
| 6443 | break; |
| 6444 | } |
| 6445 | printf ("%-5s ", tmp); |
| 6446 | } |
| 6447 | } |
| 6448 | printf ("\n"); |
| 6449 | } |
| 6450 | |
| 6451 | #define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end) |
| 6452 | #define LEB() read_uleb128 (start, & length_return, end); start += length_return |
| 6453 | #define SLEB() read_sleb128 (start, & length_return, end); start += length_return |
| 6454 | |
| 6455 | static unsigned char * |
| 6456 | read_cie (unsigned char *start, unsigned char *end, |
| 6457 | Frame_Chunk **p_cie, int *p_version, |
| 6458 | unsigned long *p_aug_len, unsigned char **p_aug) |
| 6459 | { |
| 6460 | int version; |
| 6461 | Frame_Chunk *fc; |
| 6462 | unsigned int length_return; |
| 6463 | unsigned char *augmentation_data = NULL; |
| 6464 | unsigned long augmentation_data_len = 0; |
| 6465 | |
| 6466 | * p_cie = NULL; |
| 6467 | /* PR 17512: file: 001-228113-0.004. */ |
| 6468 | if (start >= end) |
| 6469 | return end; |
| 6470 | |
| 6471 | fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); |
| 6472 | memset (fc, 0, sizeof (Frame_Chunk)); |
| 6473 | |
| 6474 | fc->col_type = (short int *) xmalloc (sizeof (short int)); |
| 6475 | fc->col_offset = (int *) xmalloc (sizeof (int)); |
| 6476 | |
| 6477 | version = *start++; |
| 6478 | |
| 6479 | fc->augmentation = (char *) start; |
| 6480 | /* PR 17512: file: 001-228113-0.004. |
| 6481 | Skip past augmentation name, but avoid running off the end of the data. */ |
| 6482 | while (start < end) |
| 6483 | if (* start ++ == '\0') |
| 6484 | break; |
| 6485 | if (start == end) |
| 6486 | { |
| 6487 | warn (_("No terminator for augmentation name\n")); |
| 6488 | return start; |
| 6489 | } |
| 6490 | |
| 6491 | if (strcmp (fc->augmentation, "eh") == 0) |
| 6492 | start += eh_addr_size; |
| 6493 | |
| 6494 | if (version >= 4) |
| 6495 | { |
| 6496 | GET (fc->ptr_size, 1); |
| 6497 | if (fc->ptr_size < 1 || fc->ptr_size > 8) |
| 6498 | { |
| 6499 | warn (_("Invalid pointer size (%d) in CIE data\n"), fc->ptr_size); |
| 6500 | return end; |
| 6501 | } |
| 6502 | |
| 6503 | GET (fc->segment_size, 1); |
| 6504 | /* PR 17512: file: e99d2804. */ |
| 6505 | if (fc->segment_size > 8 || fc->segment_size + fc->ptr_size > 8) |
| 6506 | { |
| 6507 | warn (_("Invalid segment size (%d) in CIE data\n"), fc->segment_size); |
| 6508 | return end; |
| 6509 | } |
| 6510 | |
| 6511 | eh_addr_size = fc->ptr_size; |
| 6512 | } |
| 6513 | else |
| 6514 | { |
| 6515 | fc->ptr_size = eh_addr_size; |
| 6516 | fc->segment_size = 0; |
| 6517 | } |
| 6518 | fc->code_factor = LEB (); |
| 6519 | fc->data_factor = SLEB (); |
| 6520 | if (version == 1) |
| 6521 | { |
| 6522 | GET (fc->ra, 1); |
| 6523 | } |
| 6524 | else |
| 6525 | { |
| 6526 | fc->ra = LEB (); |
| 6527 | } |
| 6528 | |
| 6529 | if (fc->augmentation[0] == 'z') |
| 6530 | { |
| 6531 | augmentation_data_len = LEB (); |
| 6532 | augmentation_data = start; |
| 6533 | start += augmentation_data_len; |
| 6534 | /* PR 17512: file: 11042-2589-0.004. */ |
| 6535 | if (start > end) |
| 6536 | { |
| 6537 | warn (_("Augmentation data too long: 0x%lx\n"), augmentation_data_len); |
| 6538 | return end; |
| 6539 | } |
| 6540 | } |
| 6541 | |
| 6542 | if (augmentation_data_len) |
| 6543 | { |
| 6544 | unsigned char *p; |
| 6545 | unsigned char *q; |
| 6546 | unsigned char *qend; |
| 6547 | |
| 6548 | p = (unsigned char *) fc->augmentation + 1; |
| 6549 | q = augmentation_data; |
| 6550 | qend = q + augmentation_data_len; |
| 6551 | |
| 6552 | /* PR 17531: file: 015adfaa. */ |
| 6553 | if (qend < q) |
| 6554 | { |
| 6555 | warn (_("Negative augmentation data length: 0x%lx"), augmentation_data_len); |
| 6556 | augmentation_data_len = 0; |
| 6557 | } |
| 6558 | |
| 6559 | while (p < end && q < augmentation_data + augmentation_data_len) |
| 6560 | { |
| 6561 | if (*p == 'L') |
| 6562 | q++; |
| 6563 | else if (*p == 'P') |
| 6564 | q += 1 + size_of_encoded_value (*q); |
| 6565 | else if (*p == 'R') |
| 6566 | fc->fde_encoding = *q++; |
| 6567 | else if (*p == 'S') |
| 6568 | ; |
| 6569 | else |
| 6570 | break; |
| 6571 | p++; |
| 6572 | } |
| 6573 | /* Note - it is OK if this loop terminates with q < qend. |
| 6574 | Padding may have been inserted to align the end of the CIE. */ |
| 6575 | } |
| 6576 | |
| 6577 | *p_cie = fc; |
| 6578 | if (p_version) |
| 6579 | *p_version = version; |
| 6580 | if (p_aug_len) |
| 6581 | { |
| 6582 | *p_aug_len = augmentation_data_len; |
| 6583 | *p_aug = augmentation_data; |
| 6584 | } |
| 6585 | return start; |
| 6586 | } |
| 6587 | |
| 6588 | static int |
| 6589 | display_debug_frames (struct dwarf_section *section, |
| 6590 | void *file ATTRIBUTE_UNUSED) |
| 6591 | { |
| 6592 | unsigned char *start = section->start; |
| 6593 | unsigned char *end = start + section->size; |
| 6594 | unsigned char *section_start = start; |
| 6595 | Frame_Chunk *chunks = 0, *forward_refs = 0; |
| 6596 | Frame_Chunk *remembered_state = 0; |
| 6597 | Frame_Chunk *rs; |
| 6598 | int is_eh = strcmp (section->name, ".eh_frame") == 0; |
| 6599 | unsigned int length_return; |
| 6600 | unsigned int max_regs = 0; |
| 6601 | const char *bad_reg = _("bad register: "); |
| 6602 | unsigned int saved_eh_addr_size = eh_addr_size; |
| 6603 | |
| 6604 | printf (_("Contents of the %s section:\n"), section->name); |
| 6605 | |
| 6606 | while (start < end) |
| 6607 | { |
| 6608 | unsigned char *saved_start; |
| 6609 | unsigned char *block_end; |
| 6610 | dwarf_vma length; |
| 6611 | dwarf_vma cie_id; |
| 6612 | Frame_Chunk *fc; |
| 6613 | Frame_Chunk *cie; |
| 6614 | int need_col_headers = 1; |
| 6615 | unsigned char *augmentation_data = NULL; |
| 6616 | unsigned long augmentation_data_len = 0; |
| 6617 | unsigned int encoded_ptr_size = saved_eh_addr_size; |
| 6618 | unsigned int offset_size; |
| 6619 | unsigned int initial_length_size; |
| 6620 | bfd_boolean all_nops; |
| 6621 | |
| 6622 | saved_start = start; |
| 6623 | |
| 6624 | SAFE_BYTE_GET_AND_INC (length, start, 4, end); |
| 6625 | |
| 6626 | if (length == 0) |
| 6627 | { |
| 6628 | printf ("\n%08lx ZERO terminator\n\n", |
| 6629 | (unsigned long)(saved_start - section_start)); |
| 6630 | /* Skip any zero terminators that directly follow. |
| 6631 | A corrupt section size could have loaded a whole |
| 6632 | slew of zero filled memory bytes. eg |
| 6633 | PR 17512: file: 070-19381-0.004. */ |
| 6634 | while (start < end && * start == 0) |
| 6635 | ++ start; |
| 6636 | continue; |
| 6637 | } |
| 6638 | |
| 6639 | if (length == 0xffffffff) |
| 6640 | { |
| 6641 | SAFE_BYTE_GET_AND_INC (length, start, 8, end); |
| 6642 | offset_size = 8; |
| 6643 | initial_length_size = 12; |
| 6644 | } |
| 6645 | else |
| 6646 | { |
| 6647 | offset_size = 4; |
| 6648 | initial_length_size = 4; |
| 6649 | } |
| 6650 | |
| 6651 | block_end = saved_start + length + initial_length_size; |
| 6652 | if (block_end > end || block_end < start) |
| 6653 | { |
| 6654 | warn ("Invalid length 0x%s in FDE at %#08lx\n", |
| 6655 | dwarf_vmatoa_1 (NULL, length, offset_size), |
| 6656 | (unsigned long) (saved_start - section_start)); |
| 6657 | block_end = end; |
| 6658 | } |
| 6659 | |
| 6660 | SAFE_BYTE_GET_AND_INC (cie_id, start, offset_size, end); |
| 6661 | |
| 6662 | if (is_eh ? (cie_id == 0) : ((offset_size == 4 && cie_id == DW_CIE_ID) |
| 6663 | || (offset_size == 8 && cie_id == DW64_CIE_ID))) |
| 6664 | { |
| 6665 | int version; |
| 6666 | unsigned int mreg; |
| 6667 | |
| 6668 | start = read_cie (start, end, &cie, &version, |
| 6669 | &augmentation_data_len, &augmentation_data); |
| 6670 | /* PR 17512: file: 027-135133-0.005. */ |
| 6671 | if (cie == NULL) |
| 6672 | break; |
| 6673 | |
| 6674 | fc = cie; |
| 6675 | fc->next = chunks; |
| 6676 | chunks = fc; |
| 6677 | fc->chunk_start = saved_start; |
| 6678 | mreg = max_regs > 0 ? max_regs - 1 : 0; |
| 6679 | if (mreg < fc->ra) |
| 6680 | mreg = fc->ra; |
| 6681 | if (frame_need_space (fc, mreg) < 0) |
| 6682 | break; |
| 6683 | if (fc->fde_encoding) |
| 6684 | encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); |
| 6685 | |
| 6686 | printf ("\n%08lx ", (unsigned long) (saved_start - section_start)); |
| 6687 | print_dwarf_vma (length, fc->ptr_size); |
| 6688 | print_dwarf_vma (cie_id, offset_size); |
| 6689 | |
| 6690 | if (do_debug_frames_interp) |
| 6691 | { |
| 6692 | printf ("CIE \"%s\" cf=%d df=%d ra=%d\n", fc->augmentation, |
| 6693 | fc->code_factor, fc->data_factor, fc->ra); |
| 6694 | } |
| 6695 | else |
| 6696 | { |
| 6697 | printf ("CIE\n"); |
| 6698 | printf (" Version: %d\n", version); |
| 6699 | printf (" Augmentation: \"%s\"\n", fc->augmentation); |
| 6700 | if (version >= 4) |
| 6701 | { |
| 6702 | printf (" Pointer Size: %u\n", fc->ptr_size); |
| 6703 | printf (" Segment Size: %u\n", fc->segment_size); |
| 6704 | } |
| 6705 | printf (" Code alignment factor: %u\n", fc->code_factor); |
| 6706 | printf (" Data alignment factor: %d\n", fc->data_factor); |
| 6707 | printf (" Return address column: %d\n", fc->ra); |
| 6708 | |
| 6709 | if (augmentation_data_len) |
| 6710 | { |
| 6711 | unsigned long i; |
| 6712 | |
| 6713 | printf (" Augmentation data: "); |
| 6714 | for (i = 0; i < augmentation_data_len; ++i) |
| 6715 | /* FIXME: If do_wide is FALSE, then we should |
| 6716 | add carriage returns at 80 columns... */ |
| 6717 | printf (" %02x", augmentation_data[i]); |
| 6718 | putchar ('\n'); |
| 6719 | } |
| 6720 | putchar ('\n'); |
| 6721 | } |
| 6722 | } |
| 6723 | else |
| 6724 | { |
| 6725 | unsigned char *look_for; |
| 6726 | static Frame_Chunk fde_fc; |
| 6727 | unsigned long segment_selector; |
| 6728 | |
| 6729 | if (is_eh) |
| 6730 | { |
| 6731 | dwarf_vma sign = (dwarf_vma) 1 << (offset_size * 8 - 1); |
| 6732 | look_for = start - 4 - ((cie_id ^ sign) - sign); |
| 6733 | } |
| 6734 | else |
| 6735 | look_for = section_start + cie_id; |
| 6736 | |
| 6737 | if (look_for <= saved_start) |
| 6738 | { |
| 6739 | for (cie = chunks; cie ; cie = cie->next) |
| 6740 | if (cie->chunk_start == look_for) |
| 6741 | break; |
| 6742 | } |
| 6743 | else |
| 6744 | { |
| 6745 | for (cie = forward_refs; cie ; cie = cie->next) |
| 6746 | if (cie->chunk_start == look_for) |
| 6747 | break; |
| 6748 | if (!cie) |
| 6749 | { |
| 6750 | unsigned int off_size; |
| 6751 | unsigned char *cie_scan; |
| 6752 | |
| 6753 | cie_scan = look_for; |
| 6754 | off_size = 4; |
| 6755 | SAFE_BYTE_GET_AND_INC (length, cie_scan, 4, end); |
| 6756 | if (length == 0xffffffff) |
| 6757 | { |
| 6758 | SAFE_BYTE_GET_AND_INC (length, cie_scan, 8, end); |
| 6759 | off_size = 8; |
| 6760 | } |
| 6761 | if (length != 0) |
| 6762 | { |
| 6763 | dwarf_vma c_id; |
| 6764 | |
| 6765 | SAFE_BYTE_GET_AND_INC (c_id, cie_scan, off_size, end); |
| 6766 | if (is_eh |
| 6767 | ? c_id == 0 |
| 6768 | : ((off_size == 4 && c_id == DW_CIE_ID) |
| 6769 | || (off_size == 8 && c_id == DW64_CIE_ID))) |
| 6770 | { |
| 6771 | int version; |
| 6772 | unsigned int mreg; |
| 6773 | |
| 6774 | read_cie (cie_scan, end, &cie, &version, |
| 6775 | &augmentation_data_len, &augmentation_data); |
| 6776 | /* PR 17512: file: 3450-2098-0.004. */ |
| 6777 | if (cie == NULL) |
| 6778 | { |
| 6779 | warn (_("Failed to read CIE information\n")); |
| 6780 | break; |
| 6781 | } |
| 6782 | cie->next = forward_refs; |
| 6783 | forward_refs = cie; |
| 6784 | cie->chunk_start = look_for; |
| 6785 | mreg = max_regs > 0 ? max_regs - 1 : 0; |
| 6786 | if (mreg < cie->ra) |
| 6787 | mreg = cie->ra; |
| 6788 | if (frame_need_space (cie, mreg) < 0) |
| 6789 | { |
| 6790 | warn (_("Invalid max register\n")); |
| 6791 | break; |
| 6792 | } |
| 6793 | if (cie->fde_encoding) |
| 6794 | encoded_ptr_size |
| 6795 | = size_of_encoded_value (cie->fde_encoding); |
| 6796 | } |
| 6797 | } |
| 6798 | } |
| 6799 | } |
| 6800 | |
| 6801 | fc = &fde_fc; |
| 6802 | memset (fc, 0, sizeof (Frame_Chunk)); |
| 6803 | |
| 6804 | if (!cie) |
| 6805 | { |
| 6806 | warn ("Invalid CIE pointer 0x%s in FDE at %#08lx\n", |
| 6807 | dwarf_vmatoa_1 (NULL, cie_id, offset_size), |
| 6808 | (unsigned long) (saved_start - section_start)); |
| 6809 | fc->ncols = 0; |
| 6810 | fc->col_type = (short int *) xmalloc (sizeof (short int)); |
| 6811 | fc->col_offset = (int *) xmalloc (sizeof (int)); |
| 6812 | if (frame_need_space (fc, max_regs > 0 ? max_regs - 1 : 0) < 0) |
| 6813 | { |
| 6814 | warn (_("Invalid max register\n")); |
| 6815 | break; |
| 6816 | } |
| 6817 | cie = fc; |
| 6818 | fc->augmentation = ""; |
| 6819 | fc->fde_encoding = 0; |
| 6820 | fc->ptr_size = eh_addr_size; |
| 6821 | fc->segment_size = 0; |
| 6822 | } |
| 6823 | else |
| 6824 | { |
| 6825 | fc->ncols = cie->ncols; |
| 6826 | fc->col_type = (short int *) xcmalloc (fc->ncols, sizeof (short int)); |
| 6827 | fc->col_offset = (int *) xcmalloc (fc->ncols, sizeof (int)); |
| 6828 | memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int)); |
| 6829 | memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int)); |
| 6830 | fc->augmentation = cie->augmentation; |
| 6831 | fc->ptr_size = cie->ptr_size; |
| 6832 | eh_addr_size = cie->ptr_size; |
| 6833 | fc->segment_size = cie->segment_size; |
| 6834 | fc->code_factor = cie->code_factor; |
| 6835 | fc->data_factor = cie->data_factor; |
| 6836 | fc->cfa_reg = cie->cfa_reg; |
| 6837 | fc->cfa_offset = cie->cfa_offset; |
| 6838 | fc->ra = cie->ra; |
| 6839 | if (frame_need_space (fc, max_regs > 0 ? max_regs - 1: 0) < 0) |
| 6840 | { |
| 6841 | warn (_("Invalid max register\n")); |
| 6842 | break; |
| 6843 | } |
| 6844 | fc->fde_encoding = cie->fde_encoding; |
| 6845 | } |
| 6846 | |
| 6847 | if (fc->fde_encoding) |
| 6848 | encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); |
| 6849 | |
| 6850 | segment_selector = 0; |
| 6851 | if (fc->segment_size) |
| 6852 | { |
| 6853 | if (fc->segment_size > sizeof (segment_selector)) |
| 6854 | { |
| 6855 | /* PR 17512: file: 9e196b3e. */ |
| 6856 | warn (_("Probably corrupt segment size: %d - using 4 instead\n"), fc->segment_size); |
| 6857 | fc->segment_size = 4; |
| 6858 | } |
| 6859 | SAFE_BYTE_GET_AND_INC (segment_selector, start, fc->segment_size, end); |
| 6860 | } |
| 6861 | |
| 6862 | fc->pc_begin = get_encoded_value (&start, fc->fde_encoding, section, end); |
| 6863 | |
| 6864 | /* FIXME: It appears that sometimes the final pc_range value is |
| 6865 | encoded in less than encoded_ptr_size bytes. See the x86_64 |
| 6866 | run of the "objcopy on compressed debug sections" test for an |
| 6867 | example of this. */ |
| 6868 | SAFE_BYTE_GET_AND_INC (fc->pc_range, start, encoded_ptr_size, end); |
| 6869 | |
| 6870 | if (cie->augmentation[0] == 'z') |
| 6871 | { |
| 6872 | augmentation_data_len = LEB (); |
| 6873 | augmentation_data = start; |
| 6874 | start += augmentation_data_len; |
| 6875 | /* PR 17512: file: 722-8446-0.004. */ |
| 6876 | if (start >= end || ((signed long) augmentation_data_len) < 0) |
| 6877 | { |
| 6878 | warn (_("Corrupt augmentation data length: %lx\n"), |
| 6879 | augmentation_data_len); |
| 6880 | start = end; |
| 6881 | augmentation_data = NULL; |
| 6882 | augmentation_data_len = 0; |
| 6883 | } |
| 6884 | } |
| 6885 | |
| 6886 | printf ("\n%08lx %s %s FDE cie=%08lx pc=", |
| 6887 | (unsigned long)(saved_start - section_start), |
| 6888 | dwarf_vmatoa_1 (NULL, length, fc->ptr_size), |
| 6889 | dwarf_vmatoa_1 (NULL, cie_id, offset_size), |
| 6890 | (unsigned long)(cie->chunk_start - section_start)); |
| 6891 | |
| 6892 | if (fc->segment_size) |
| 6893 | printf ("%04lx:", segment_selector); |
| 6894 | |
| 6895 | printf ("%s..%s\n", |
| 6896 | dwarf_vmatoa_1 (NULL, fc->pc_begin, fc->ptr_size), |
| 6897 | dwarf_vmatoa_1 (NULL, fc->pc_begin + fc->pc_range, fc->ptr_size)); |
| 6898 | |
| 6899 | if (! do_debug_frames_interp && augmentation_data_len) |
| 6900 | { |
| 6901 | unsigned long i; |
| 6902 | |
| 6903 | printf (" Augmentation data: "); |
| 6904 | for (i = 0; i < augmentation_data_len; ++i) |
| 6905 | printf (" %02x", augmentation_data[i]); |
| 6906 | putchar ('\n'); |
| 6907 | putchar ('\n'); |
| 6908 | } |
| 6909 | } |
| 6910 | |
| 6911 | /* At this point, fc is the current chunk, cie (if any) is set, and |
| 6912 | we're about to interpret instructions for the chunk. */ |
| 6913 | /* ??? At present we need to do this always, since this sizes the |
| 6914 | fc->col_type and fc->col_offset arrays, which we write into always. |
| 6915 | We should probably split the interpreted and non-interpreted bits |
| 6916 | into two different routines, since there's so much that doesn't |
| 6917 | really overlap between them. */ |
| 6918 | if (1 || do_debug_frames_interp) |
| 6919 | { |
| 6920 | /* Start by making a pass over the chunk, allocating storage |
| 6921 | and taking note of what registers are used. */ |
| 6922 | unsigned char *tmp = start; |
| 6923 | |
| 6924 | while (start < block_end) |
| 6925 | { |
| 6926 | unsigned int reg, op, opa; |
| 6927 | unsigned long temp; |
| 6928 | unsigned char * new_start; |
| 6929 | |
| 6930 | op = *start++; |
| 6931 | opa = op & 0x3f; |
| 6932 | if (op & 0xc0) |
| 6933 | op &= 0xc0; |
| 6934 | |
| 6935 | /* Warning: if you add any more cases to this switch, be |
| 6936 | sure to add them to the corresponding switch below. */ |
| 6937 | switch (op) |
| 6938 | { |
| 6939 | case DW_CFA_advance_loc: |
| 6940 | break; |
| 6941 | case DW_CFA_offset: |
| 6942 | LEB (); |
| 6943 | if (frame_need_space (fc, opa) >= 0) |
| 6944 | fc->col_type[opa] = DW_CFA_undefined; |
| 6945 | break; |
| 6946 | case DW_CFA_restore: |
| 6947 | if (frame_need_space (fc, opa) >= 0) |
| 6948 | fc->col_type[opa] = DW_CFA_undefined; |
| 6949 | break; |
| 6950 | case DW_CFA_set_loc: |
| 6951 | start += encoded_ptr_size; |
| 6952 | break; |
| 6953 | case DW_CFA_advance_loc1: |
| 6954 | start += 1; |
| 6955 | break; |
| 6956 | case DW_CFA_advance_loc2: |
| 6957 | start += 2; |
| 6958 | break; |
| 6959 | case DW_CFA_advance_loc4: |
| 6960 | start += 4; |
| 6961 | break; |
| 6962 | case DW_CFA_offset_extended: |
| 6963 | case DW_CFA_val_offset: |
| 6964 | reg = LEB (); LEB (); |
| 6965 | if (frame_need_space (fc, reg) >= 0) |
| 6966 | fc->col_type[reg] = DW_CFA_undefined; |
| 6967 | break; |
| 6968 | case DW_CFA_restore_extended: |
| 6969 | reg = LEB (); |
| 6970 | if (frame_need_space (fc, reg) >= 0) |
| 6971 | fc->col_type[reg] = DW_CFA_undefined; |
| 6972 | break; |
| 6973 | case DW_CFA_undefined: |
| 6974 | reg = LEB (); |
| 6975 | if (frame_need_space (fc, reg) >= 0) |
| 6976 | fc->col_type[reg] = DW_CFA_undefined; |
| 6977 | break; |
| 6978 | case DW_CFA_same_value: |
| 6979 | reg = LEB (); |
| 6980 | if (frame_need_space (fc, reg) >= 0) |
| 6981 | fc->col_type[reg] = DW_CFA_undefined; |
| 6982 | break; |
| 6983 | case DW_CFA_register: |
| 6984 | reg = LEB (); LEB (); |
| 6985 | if (frame_need_space (fc, reg) >= 0) |
| 6986 | fc->col_type[reg] = DW_CFA_undefined; |
| 6987 | break; |
| 6988 | case DW_CFA_def_cfa: |
| 6989 | LEB (); LEB (); |
| 6990 | break; |
| 6991 | case DW_CFA_def_cfa_register: |
| 6992 | LEB (); |
| 6993 | break; |
| 6994 | case DW_CFA_def_cfa_offset: |
| 6995 | LEB (); |
| 6996 | break; |
| 6997 | case DW_CFA_def_cfa_expression: |
| 6998 | temp = LEB (); |
| 6999 | new_start = start + temp; |
| 7000 | if (new_start < start) |
| 7001 | { |
| 7002 | warn (_("Corrupt CFA_def expression value: %lu\n"), temp); |
| 7003 | start = block_end; |
| 7004 | } |
| 7005 | else |
| 7006 | start = new_start; |
| 7007 | break; |
| 7008 | case DW_CFA_expression: |
| 7009 | case DW_CFA_val_expression: |
| 7010 | reg = LEB (); |
| 7011 | temp = LEB (); |
| 7012 | new_start = start + temp; |
| 7013 | if (new_start < start) |
| 7014 | { |
| 7015 | /* PR 17512: file:306-192417-0.005. */ |
| 7016 | warn (_("Corrupt CFA expression value: %lu\n"), temp); |
| 7017 | start = block_end; |
| 7018 | } |
| 7019 | else |
| 7020 | start = new_start; |
| 7021 | if (frame_need_space (fc, reg) >= 0) |
| 7022 | fc->col_type[reg] = DW_CFA_undefined; |
| 7023 | break; |
| 7024 | case DW_CFA_offset_extended_sf: |
| 7025 | case DW_CFA_val_offset_sf: |
| 7026 | reg = LEB (); SLEB (); |
| 7027 | if (frame_need_space (fc, reg) >= 0) |
| 7028 | fc->col_type[reg] = DW_CFA_undefined; |
| 7029 | break; |
| 7030 | case DW_CFA_def_cfa_sf: |
| 7031 | LEB (); SLEB (); |
| 7032 | break; |
| 7033 | case DW_CFA_def_cfa_offset_sf: |
| 7034 | SLEB (); |
| 7035 | break; |
| 7036 | case DW_CFA_MIPS_advance_loc8: |
| 7037 | start += 8; |
| 7038 | break; |
| 7039 | case DW_CFA_GNU_args_size: |
| 7040 | LEB (); |
| 7041 | break; |
| 7042 | case DW_CFA_GNU_negative_offset_extended: |
| 7043 | reg = LEB (); LEB (); |
| 7044 | if (frame_need_space (fc, reg) >= 0) |
| 7045 | fc->col_type[reg] = DW_CFA_undefined; |
| 7046 | break; |
| 7047 | default: |
| 7048 | break; |
| 7049 | } |
| 7050 | } |
| 7051 | start = tmp; |
| 7052 | } |
| 7053 | |
| 7054 | all_nops = TRUE; |
| 7055 | |
| 7056 | /* Now we know what registers are used, make a second pass over |
| 7057 | the chunk, this time actually printing out the info. */ |
| 7058 | |
| 7059 | while (start < block_end) |
| 7060 | { |
| 7061 | unsigned char * tmp; |
| 7062 | unsigned op, opa; |
| 7063 | unsigned long ul, reg, roffs; |
| 7064 | dwarf_vma l; |
| 7065 | dwarf_vma ofs; |
| 7066 | dwarf_vma vma; |
| 7067 | const char *reg_prefix = ""; |
| 7068 | |
| 7069 | op = *start++; |
| 7070 | opa = op & 0x3f; |
| 7071 | if (op & 0xc0) |
| 7072 | op &= 0xc0; |
| 7073 | |
| 7074 | /* Make a note if something other than DW_CFA_nop happens. */ |
| 7075 | if (op != DW_CFA_nop) |
| 7076 | all_nops = FALSE; |
| 7077 | |
| 7078 | /* Warning: if you add any more cases to this switch, be |
| 7079 | sure to add them to the corresponding switch above. */ |
| 7080 | switch (op) |
| 7081 | { |
| 7082 | case DW_CFA_advance_loc: |
| 7083 | if (do_debug_frames_interp) |
| 7084 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 7085 | else |
| 7086 | printf (" DW_CFA_advance_loc: %d to %s\n", |
| 7087 | opa * fc->code_factor, |
| 7088 | dwarf_vmatoa_1 (NULL, |
| 7089 | fc->pc_begin + opa * fc->code_factor, |
| 7090 | fc->ptr_size)); |
| 7091 | fc->pc_begin += opa * fc->code_factor; |
| 7092 | break; |
| 7093 | |
| 7094 | case DW_CFA_offset: |
| 7095 | roffs = LEB (); |
| 7096 | if (opa >= (unsigned int) fc->ncols) |
| 7097 | reg_prefix = bad_reg; |
| 7098 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7099 | printf (" DW_CFA_offset: %s%s at cfa%+ld\n", |
| 7100 | reg_prefix, regname (opa, 0), |
| 7101 | roffs * fc->data_factor); |
| 7102 | if (*reg_prefix == '\0') |
| 7103 | { |
| 7104 | fc->col_type[opa] = DW_CFA_offset; |
| 7105 | fc->col_offset[opa] = roffs * fc->data_factor; |
| 7106 | } |
| 7107 | break; |
| 7108 | |
| 7109 | case DW_CFA_restore: |
| 7110 | if (opa >= (unsigned int) fc->ncols) |
| 7111 | reg_prefix = bad_reg; |
| 7112 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7113 | printf (" DW_CFA_restore: %s%s\n", |
| 7114 | reg_prefix, regname (opa, 0)); |
| 7115 | if (*reg_prefix != '\0') |
| 7116 | break; |
| 7117 | |
| 7118 | if (opa >= (unsigned int) cie->ncols |
| 7119 | || (do_debug_frames_interp |
| 7120 | && cie->col_type[opa] == DW_CFA_unreferenced)) |
| 7121 | { |
| 7122 | fc->col_type[opa] = DW_CFA_undefined; |
| 7123 | fc->col_offset[opa] = 0; |
| 7124 | } |
| 7125 | else |
| 7126 | { |
| 7127 | fc->col_type[opa] = cie->col_type[opa]; |
| 7128 | fc->col_offset[opa] = cie->col_offset[opa]; |
| 7129 | } |
| 7130 | break; |
| 7131 | |
| 7132 | case DW_CFA_set_loc: |
| 7133 | vma = get_encoded_value (&start, fc->fde_encoding, section, block_end); |
| 7134 | if (do_debug_frames_interp) |
| 7135 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 7136 | else |
| 7137 | printf (" DW_CFA_set_loc: %s\n", |
| 7138 | dwarf_vmatoa_1 (NULL, vma, fc->ptr_size)); |
| 7139 | fc->pc_begin = vma; |
| 7140 | break; |
| 7141 | |
| 7142 | case DW_CFA_advance_loc1: |
| 7143 | SAFE_BYTE_GET_AND_INC (ofs, start, 1, end); |
| 7144 | if (do_debug_frames_interp) |
| 7145 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 7146 | else |
| 7147 | printf (" DW_CFA_advance_loc1: %ld to %s\n", |
| 7148 | (unsigned long) (ofs * fc->code_factor), |
| 7149 | dwarf_vmatoa_1 (NULL, |
| 7150 | fc->pc_begin + ofs * fc->code_factor, |
| 7151 | fc->ptr_size)); |
| 7152 | fc->pc_begin += ofs * fc->code_factor; |
| 7153 | break; |
| 7154 | |
| 7155 | case DW_CFA_advance_loc2: |
| 7156 | SAFE_BYTE_GET_AND_INC (ofs, start, 2, block_end); |
| 7157 | if (do_debug_frames_interp) |
| 7158 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 7159 | else |
| 7160 | printf (" DW_CFA_advance_loc2: %ld to %s\n", |
| 7161 | (unsigned long) (ofs * fc->code_factor), |
| 7162 | dwarf_vmatoa_1 (NULL, |
| 7163 | fc->pc_begin + ofs * fc->code_factor, |
| 7164 | fc->ptr_size)); |
| 7165 | fc->pc_begin += ofs * fc->code_factor; |
| 7166 | break; |
| 7167 | |
| 7168 | case DW_CFA_advance_loc4: |
| 7169 | SAFE_BYTE_GET_AND_INC (ofs, start, 4, block_end); |
| 7170 | if (do_debug_frames_interp) |
| 7171 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 7172 | else |
| 7173 | printf (" DW_CFA_advance_loc4: %ld to %s\n", |
| 7174 | (unsigned long) (ofs * fc->code_factor), |
| 7175 | dwarf_vmatoa_1 (NULL, |
| 7176 | fc->pc_begin + ofs * fc->code_factor, |
| 7177 | fc->ptr_size)); |
| 7178 | fc->pc_begin += ofs * fc->code_factor; |
| 7179 | break; |
| 7180 | |
| 7181 | case DW_CFA_offset_extended: |
| 7182 | reg = LEB (); |
| 7183 | roffs = LEB (); |
| 7184 | if (reg >= (unsigned int) fc->ncols) |
| 7185 | reg_prefix = bad_reg; |
| 7186 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7187 | printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n", |
| 7188 | reg_prefix, regname (reg, 0), |
| 7189 | roffs * fc->data_factor); |
| 7190 | if (*reg_prefix == '\0') |
| 7191 | { |
| 7192 | fc->col_type[reg] = DW_CFA_offset; |
| 7193 | fc->col_offset[reg] = roffs * fc->data_factor; |
| 7194 | } |
| 7195 | break; |
| 7196 | |
| 7197 | case DW_CFA_val_offset: |
| 7198 | reg = LEB (); |
| 7199 | roffs = LEB (); |
| 7200 | if (reg >= (unsigned int) fc->ncols) |
| 7201 | reg_prefix = bad_reg; |
| 7202 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7203 | printf (" DW_CFA_val_offset: %s%s is cfa%+ld\n", |
| 7204 | reg_prefix, regname (reg, 0), |
| 7205 | roffs * fc->data_factor); |
| 7206 | if (*reg_prefix == '\0') |
| 7207 | { |
| 7208 | fc->col_type[reg] = DW_CFA_val_offset; |
| 7209 | fc->col_offset[reg] = roffs * fc->data_factor; |
| 7210 | } |
| 7211 | break; |
| 7212 | |
| 7213 | case DW_CFA_restore_extended: |
| 7214 | reg = LEB (); |
| 7215 | if (reg >= (unsigned int) fc->ncols) |
| 7216 | reg_prefix = bad_reg; |
| 7217 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7218 | printf (" DW_CFA_restore_extended: %s%s\n", |
| 7219 | reg_prefix, regname (reg, 0)); |
| 7220 | if (*reg_prefix != '\0') |
| 7221 | break; |
| 7222 | |
| 7223 | if (reg >= (unsigned int) cie->ncols) |
| 7224 | { |
| 7225 | fc->col_type[reg] = DW_CFA_undefined; |
| 7226 | fc->col_offset[reg] = 0; |
| 7227 | } |
| 7228 | else |
| 7229 | { |
| 7230 | fc->col_type[reg] = cie->col_type[reg]; |
| 7231 | fc->col_offset[reg] = cie->col_offset[reg]; |
| 7232 | } |
| 7233 | break; |
| 7234 | |
| 7235 | case DW_CFA_undefined: |
| 7236 | reg = LEB (); |
| 7237 | if (reg >= (unsigned int) fc->ncols) |
| 7238 | reg_prefix = bad_reg; |
| 7239 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7240 | printf (" DW_CFA_undefined: %s%s\n", |
| 7241 | reg_prefix, regname (reg, 0)); |
| 7242 | if (*reg_prefix == '\0') |
| 7243 | { |
| 7244 | fc->col_type[reg] = DW_CFA_undefined; |
| 7245 | fc->col_offset[reg] = 0; |
| 7246 | } |
| 7247 | break; |
| 7248 | |
| 7249 | case DW_CFA_same_value: |
| 7250 | reg = LEB (); |
| 7251 | if (reg >= (unsigned int) fc->ncols) |
| 7252 | reg_prefix = bad_reg; |
| 7253 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7254 | printf (" DW_CFA_same_value: %s%s\n", |
| 7255 | reg_prefix, regname (reg, 0)); |
| 7256 | if (*reg_prefix == '\0') |
| 7257 | { |
| 7258 | fc->col_type[reg] = DW_CFA_same_value; |
| 7259 | fc->col_offset[reg] = 0; |
| 7260 | } |
| 7261 | break; |
| 7262 | |
| 7263 | case DW_CFA_register: |
| 7264 | reg = LEB (); |
| 7265 | roffs = LEB (); |
| 7266 | if (reg >= (unsigned int) fc->ncols) |
| 7267 | reg_prefix = bad_reg; |
| 7268 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7269 | { |
| 7270 | printf (" DW_CFA_register: %s%s in ", |
| 7271 | reg_prefix, regname (reg, 0)); |
| 7272 | puts (regname (roffs, 0)); |
| 7273 | } |
| 7274 | if (*reg_prefix == '\0') |
| 7275 | { |
| 7276 | fc->col_type[reg] = DW_CFA_register; |
| 7277 | fc->col_offset[reg] = roffs; |
| 7278 | } |
| 7279 | break; |
| 7280 | |
| 7281 | case DW_CFA_remember_state: |
| 7282 | if (! do_debug_frames_interp) |
| 7283 | printf (" DW_CFA_remember_state\n"); |
| 7284 | rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); |
| 7285 | rs->cfa_offset = fc->cfa_offset; |
| 7286 | rs->cfa_reg = fc->cfa_reg; |
| 7287 | rs->ra = fc->ra; |
| 7288 | rs->cfa_exp = fc->cfa_exp; |
| 7289 | rs->ncols = fc->ncols; |
| 7290 | rs->col_type = (short int *) xcmalloc (rs->ncols, |
| 7291 | sizeof (* rs->col_type)); |
| 7292 | rs->col_offset = (int *) xcmalloc (rs->ncols, sizeof (* rs->col_offset)); |
| 7293 | memcpy (rs->col_type, fc->col_type, rs->ncols * sizeof (* fc->col_type)); |
| 7294 | memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (* fc->col_offset)); |
| 7295 | rs->next = remembered_state; |
| 7296 | remembered_state = rs; |
| 7297 | break; |
| 7298 | |
| 7299 | case DW_CFA_restore_state: |
| 7300 | if (! do_debug_frames_interp) |
| 7301 | printf (" DW_CFA_restore_state\n"); |
| 7302 | rs = remembered_state; |
| 7303 | if (rs) |
| 7304 | { |
| 7305 | remembered_state = rs->next; |
| 7306 | fc->cfa_offset = rs->cfa_offset; |
| 7307 | fc->cfa_reg = rs->cfa_reg; |
| 7308 | fc->ra = rs->ra; |
| 7309 | fc->cfa_exp = rs->cfa_exp; |
| 7310 | if (frame_need_space (fc, rs->ncols - 1) < 0) |
| 7311 | { |
| 7312 | warn (_("Invalid column number in saved frame state\n")); |
| 7313 | fc->ncols = 0; |
| 7314 | break; |
| 7315 | } |
| 7316 | memcpy (fc->col_type, rs->col_type, rs->ncols * sizeof (* rs->col_type)); |
| 7317 | memcpy (fc->col_offset, rs->col_offset, |
| 7318 | rs->ncols * sizeof (* rs->col_offset)); |
| 7319 | free (rs->col_type); |
| 7320 | free (rs->col_offset); |
| 7321 | free (rs); |
| 7322 | } |
| 7323 | else if (do_debug_frames_interp) |
| 7324 | printf ("Mismatched DW_CFA_restore_state\n"); |
| 7325 | break; |
| 7326 | |
| 7327 | case DW_CFA_def_cfa: |
| 7328 | fc->cfa_reg = LEB (); |
| 7329 | fc->cfa_offset = LEB (); |
| 7330 | fc->cfa_exp = 0; |
| 7331 | if (! do_debug_frames_interp) |
| 7332 | printf (" DW_CFA_def_cfa: %s ofs %d\n", |
| 7333 | regname (fc->cfa_reg, 0), (int) fc->cfa_offset); |
| 7334 | break; |
| 7335 | |
| 7336 | case DW_CFA_def_cfa_register: |
| 7337 | fc->cfa_reg = LEB (); |
| 7338 | fc->cfa_exp = 0; |
| 7339 | if (! do_debug_frames_interp) |
| 7340 | printf (" DW_CFA_def_cfa_register: %s\n", |
| 7341 | regname (fc->cfa_reg, 0)); |
| 7342 | break; |
| 7343 | |
| 7344 | case DW_CFA_def_cfa_offset: |
| 7345 | fc->cfa_offset = LEB (); |
| 7346 | if (! do_debug_frames_interp) |
| 7347 | printf (" DW_CFA_def_cfa_offset: %d\n", (int) fc->cfa_offset); |
| 7348 | break; |
| 7349 | |
| 7350 | case DW_CFA_nop: |
| 7351 | if (! do_debug_frames_interp) |
| 7352 | printf (" DW_CFA_nop\n"); |
| 7353 | break; |
| 7354 | |
| 7355 | case DW_CFA_def_cfa_expression: |
| 7356 | ul = LEB (); |
| 7357 | if (start >= block_end || ul > (unsigned long) (block_end - start)) |
| 7358 | { |
| 7359 | printf (_(" DW_CFA_def_cfa_expression: <corrupt len %lu>\n"), ul); |
| 7360 | break; |
| 7361 | } |
| 7362 | if (! do_debug_frames_interp) |
| 7363 | { |
| 7364 | printf (" DW_CFA_def_cfa_expression ("); |
| 7365 | decode_location_expression (start, eh_addr_size, 0, -1, |
| 7366 | ul, 0, section); |
| 7367 | printf (")\n"); |
| 7368 | } |
| 7369 | fc->cfa_exp = 1; |
| 7370 | start += ul; |
| 7371 | break; |
| 7372 | |
| 7373 | case DW_CFA_expression: |
| 7374 | reg = LEB (); |
| 7375 | ul = LEB (); |
| 7376 | if (reg >= (unsigned int) fc->ncols) |
| 7377 | reg_prefix = bad_reg; |
| 7378 | /* PR 17512: file: 069-133014-0.006. */ |
| 7379 | /* PR 17512: file: 98c02eb4. */ |
| 7380 | tmp = start + ul; |
| 7381 | if (start >= block_end || tmp > block_end || tmp < start) |
| 7382 | { |
| 7383 | printf (_(" DW_CFA_expression: <corrupt len %lu>\n"), ul); |
| 7384 | break; |
| 7385 | } |
| 7386 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7387 | { |
| 7388 | printf (" DW_CFA_expression: %s%s (", |
| 7389 | reg_prefix, regname (reg, 0)); |
| 7390 | decode_location_expression (start, eh_addr_size, 0, -1, |
| 7391 | ul, 0, section); |
| 7392 | printf (")\n"); |
| 7393 | } |
| 7394 | if (*reg_prefix == '\0') |
| 7395 | fc->col_type[reg] = DW_CFA_expression; |
| 7396 | start = tmp; |
| 7397 | break; |
| 7398 | |
| 7399 | case DW_CFA_val_expression: |
| 7400 | reg = LEB (); |
| 7401 | ul = LEB (); |
| 7402 | if (reg >= (unsigned int) fc->ncols) |
| 7403 | reg_prefix = bad_reg; |
| 7404 | tmp = start + ul; |
| 7405 | if (start >= block_end || tmp > block_end || tmp < start) |
| 7406 | { |
| 7407 | printf (" DW_CFA_val_expression: <corrupt len %lu>\n", ul); |
| 7408 | break; |
| 7409 | } |
| 7410 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7411 | { |
| 7412 | printf (" DW_CFA_val_expression: %s%s (", |
| 7413 | reg_prefix, regname (reg, 0)); |
| 7414 | decode_location_expression (start, eh_addr_size, 0, -1, |
| 7415 | ul, 0, section); |
| 7416 | printf (")\n"); |
| 7417 | } |
| 7418 | if (*reg_prefix == '\0') |
| 7419 | fc->col_type[reg] = DW_CFA_val_expression; |
| 7420 | start = tmp; |
| 7421 | break; |
| 7422 | |
| 7423 | case DW_CFA_offset_extended_sf: |
| 7424 | reg = LEB (); |
| 7425 | l = SLEB (); |
| 7426 | if (frame_need_space (fc, reg) < 0) |
| 7427 | reg_prefix = bad_reg; |
| 7428 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7429 | printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n", |
| 7430 | reg_prefix, regname (reg, 0), |
| 7431 | (long)(l * fc->data_factor)); |
| 7432 | if (*reg_prefix == '\0') |
| 7433 | { |
| 7434 | fc->col_type[reg] = DW_CFA_offset; |
| 7435 | fc->col_offset[reg] = l * fc->data_factor; |
| 7436 | } |
| 7437 | break; |
| 7438 | |
| 7439 | case DW_CFA_val_offset_sf: |
| 7440 | reg = LEB (); |
| 7441 | l = SLEB (); |
| 7442 | if (frame_need_space (fc, reg) < 0) |
| 7443 | reg_prefix = bad_reg; |
| 7444 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7445 | printf (" DW_CFA_val_offset_sf: %s%s is cfa%+ld\n", |
| 7446 | reg_prefix, regname (reg, 0), |
| 7447 | (long)(l * fc->data_factor)); |
| 7448 | if (*reg_prefix == '\0') |
| 7449 | { |
| 7450 | fc->col_type[reg] = DW_CFA_val_offset; |
| 7451 | fc->col_offset[reg] = l * fc->data_factor; |
| 7452 | } |
| 7453 | break; |
| 7454 | |
| 7455 | case DW_CFA_def_cfa_sf: |
| 7456 | fc->cfa_reg = LEB (); |
| 7457 | fc->cfa_offset = SLEB (); |
| 7458 | fc->cfa_offset = fc->cfa_offset * fc->data_factor; |
| 7459 | fc->cfa_exp = 0; |
| 7460 | if (! do_debug_frames_interp) |
| 7461 | printf (" DW_CFA_def_cfa_sf: %s ofs %d\n", |
| 7462 | regname (fc->cfa_reg, 0), (int) fc->cfa_offset); |
| 7463 | break; |
| 7464 | |
| 7465 | case DW_CFA_def_cfa_offset_sf: |
| 7466 | fc->cfa_offset = SLEB (); |
| 7467 | fc->cfa_offset *= fc->data_factor; |
| 7468 | if (! do_debug_frames_interp) |
| 7469 | printf (" DW_CFA_def_cfa_offset_sf: %d\n", (int) fc->cfa_offset); |
| 7470 | break; |
| 7471 | |
| 7472 | case DW_CFA_MIPS_advance_loc8: |
| 7473 | SAFE_BYTE_GET_AND_INC (ofs, start, 8, block_end); |
| 7474 | if (do_debug_frames_interp) |
| 7475 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 7476 | else |
| 7477 | printf (" DW_CFA_MIPS_advance_loc8: %ld to %s\n", |
| 7478 | (unsigned long) (ofs * fc->code_factor), |
| 7479 | dwarf_vmatoa_1 (NULL, |
| 7480 | fc->pc_begin + ofs * fc->code_factor, |
| 7481 | fc->ptr_size)); |
| 7482 | fc->pc_begin += ofs * fc->code_factor; |
| 7483 | break; |
| 7484 | |
| 7485 | case DW_CFA_GNU_window_save: |
| 7486 | if (! do_debug_frames_interp) |
| 7487 | printf (" DW_CFA_GNU_window_save\n"); |
| 7488 | break; |
| 7489 | |
| 7490 | case DW_CFA_GNU_args_size: |
| 7491 | ul = LEB (); |
| 7492 | if (! do_debug_frames_interp) |
| 7493 | printf (" DW_CFA_GNU_args_size: %ld\n", ul); |
| 7494 | break; |
| 7495 | |
| 7496 | case DW_CFA_GNU_negative_offset_extended: |
| 7497 | reg = LEB (); |
| 7498 | l = - LEB (); |
| 7499 | if (frame_need_space (fc, reg) < 0) |
| 7500 | reg_prefix = bad_reg; |
| 7501 | if (! do_debug_frames_interp || *reg_prefix != '\0') |
| 7502 | printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n", |
| 7503 | reg_prefix, regname (reg, 0), |
| 7504 | (long)(l * fc->data_factor)); |
| 7505 | if (*reg_prefix == '\0') |
| 7506 | { |
| 7507 | fc->col_type[reg] = DW_CFA_offset; |
| 7508 | fc->col_offset[reg] = l * fc->data_factor; |
| 7509 | } |
| 7510 | break; |
| 7511 | |
| 7512 | default: |
| 7513 | if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user) |
| 7514 | printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op); |
| 7515 | else |
| 7516 | warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op); |
| 7517 | start = block_end; |
| 7518 | } |
| 7519 | } |
| 7520 | |
| 7521 | /* Interpret the CFA - as long as it is not completely full of NOPs. */ |
| 7522 | if (do_debug_frames_interp && ! all_nops) |
| 7523 | frame_display_row (fc, &need_col_headers, &max_regs); |
| 7524 | |
| 7525 | start = block_end; |
| 7526 | eh_addr_size = saved_eh_addr_size; |
| 7527 | } |
| 7528 | |
| 7529 | printf ("\n"); |
| 7530 | |
| 7531 | return 1; |
| 7532 | } |
| 7533 | |
| 7534 | #undef GET |
| 7535 | #undef LEB |
| 7536 | #undef SLEB |
| 7537 | |
| 7538 | static int |
| 7539 | display_gdb_index (struct dwarf_section *section, |
| 7540 | void *file ATTRIBUTE_UNUSED) |
| 7541 | { |
| 7542 | unsigned char *start = section->start; |
| 7543 | uint32_t version; |
| 7544 | uint32_t cu_list_offset, tu_list_offset; |
| 7545 | uint32_t address_table_offset, symbol_table_offset, constant_pool_offset; |
| 7546 | unsigned int cu_list_elements, tu_list_elements; |
| 7547 | unsigned int address_table_size, symbol_table_slots; |
| 7548 | unsigned char *cu_list, *tu_list; |
| 7549 | unsigned char *address_table, *symbol_table, *constant_pool; |
| 7550 | unsigned int i; |
| 7551 | |
| 7552 | /* The documentation for the format of this file is in gdb/dwarf2read.c. */ |
| 7553 | |
| 7554 | printf (_("Contents of the %s section:\n"), section->name); |
| 7555 | |
| 7556 | if (section->size < 6 * sizeof (uint32_t)) |
| 7557 | { |
| 7558 | warn (_("Truncated header in the %s section.\n"), section->name); |
| 7559 | return 0; |
| 7560 | } |
| 7561 | |
| 7562 | version = byte_get_little_endian (start, 4); |
| 7563 | printf (_("Version %ld\n"), (long) version); |
| 7564 | |
| 7565 | /* Prior versions are obsolete, and future versions may not be |
| 7566 | backwards compatible. */ |
| 7567 | if (version < 3 || version > 8) |
| 7568 | { |
| 7569 | warn (_("Unsupported version %lu.\n"), (unsigned long) version); |
| 7570 | return 0; |
| 7571 | } |
| 7572 | if (version < 4) |
| 7573 | warn (_("The address table data in version 3 may be wrong.\n")); |
| 7574 | if (version < 5) |
| 7575 | warn (_("Version 4 does not support case insensitive lookups.\n")); |
| 7576 | if (version < 6) |
| 7577 | warn (_("Version 5 does not include inlined functions.\n")); |
| 7578 | if (version < 7) |
| 7579 | warn (_("Version 6 does not include symbol attributes.\n")); |
| 7580 | /* Version 7 indices generated by Gold have bad type unit references, |
| 7581 | PR binutils/15021. But we don't know if the index was generated by |
| 7582 | Gold or not, so to avoid worrying users with gdb-generated indices |
| 7583 | we say nothing for version 7 here. */ |
| 7584 | |
| 7585 | cu_list_offset = byte_get_little_endian (start + 4, 4); |
| 7586 | tu_list_offset = byte_get_little_endian (start + 8, 4); |
| 7587 | address_table_offset = byte_get_little_endian (start + 12, 4); |
| 7588 | symbol_table_offset = byte_get_little_endian (start + 16, 4); |
| 7589 | constant_pool_offset = byte_get_little_endian (start + 20, 4); |
| 7590 | |
| 7591 | if (cu_list_offset > section->size |
| 7592 | || tu_list_offset > section->size |
| 7593 | || address_table_offset > section->size |
| 7594 | || symbol_table_offset > section->size |
| 7595 | || constant_pool_offset > section->size) |
| 7596 | { |
| 7597 | warn (_("Corrupt header in the %s section.\n"), section->name); |
| 7598 | return 0; |
| 7599 | } |
| 7600 | |
| 7601 | /* PR 17531: file: 418d0a8a. */ |
| 7602 | if (tu_list_offset < cu_list_offset) |
| 7603 | { |
| 7604 | warn (_("TU offset (%x) is less than CU offset (%x)\n"), |
| 7605 | tu_list_offset, cu_list_offset); |
| 7606 | return 0; |
| 7607 | } |
| 7608 | |
| 7609 | cu_list_elements = (tu_list_offset - cu_list_offset) / 8; |
| 7610 | |
| 7611 | if (address_table_offset < tu_list_offset) |
| 7612 | { |
| 7613 | warn (_("Address table offset (%x) is less than TU offset (%x)\n"), |
| 7614 | address_table_offset, tu_list_offset); |
| 7615 | return 0; |
| 7616 | } |
| 7617 | |
| 7618 | tu_list_elements = (address_table_offset - tu_list_offset) / 8; |
| 7619 | |
| 7620 | /* PR 17531: file: 18a47d3d. */ |
| 7621 | if (symbol_table_offset < address_table_offset) |
| 7622 | { |
| 7623 | warn (_("Symbol table offset (%xl) is less then Address table offset (%x)\n"), |
| 7624 | symbol_table_offset, address_table_offset); |
| 7625 | return 0; |
| 7626 | } |
| 7627 | |
| 7628 | address_table_size = symbol_table_offset - address_table_offset; |
| 7629 | |
| 7630 | if (constant_pool_offset < symbol_table_offset) |
| 7631 | { |
| 7632 | warn (_("Constant pool offset (%x) is less than symbol table offset (%x)\n"), |
| 7633 | constant_pool_offset, symbol_table_offset); |
| 7634 | return 0; |
| 7635 | } |
| 7636 | |
| 7637 | symbol_table_slots = (constant_pool_offset - symbol_table_offset) / 8; |
| 7638 | |
| 7639 | cu_list = start + cu_list_offset; |
| 7640 | tu_list = start + tu_list_offset; |
| 7641 | address_table = start + address_table_offset; |
| 7642 | symbol_table = start + symbol_table_offset; |
| 7643 | constant_pool = start + constant_pool_offset; |
| 7644 | |
| 7645 | if (address_table + address_table_size * (2 + 8 + 4) > section->start + section->size) |
| 7646 | { |
| 7647 | warn (_("Address table extends beyond end of section.\n")); |
| 7648 | return 0; |
| 7649 | } |
| 7650 | |
| 7651 | printf (_("\nCU table:\n")); |
| 7652 | for (i = 0; i < cu_list_elements; i += 2) |
| 7653 | { |
| 7654 | uint64_t cu_offset = byte_get_little_endian (cu_list + i * 8, 8); |
| 7655 | uint64_t cu_length = byte_get_little_endian (cu_list + i * 8 + 8, 8); |
| 7656 | |
| 7657 | printf (_("[%3u] 0x%lx - 0x%lx\n"), i / 2, |
| 7658 | (unsigned long) cu_offset, |
| 7659 | (unsigned long) (cu_offset + cu_length - 1)); |
| 7660 | } |
| 7661 | |
| 7662 | printf (_("\nTU table:\n")); |
| 7663 | for (i = 0; i < tu_list_elements; i += 3) |
| 7664 | { |
| 7665 | uint64_t tu_offset = byte_get_little_endian (tu_list + i * 8, 8); |
| 7666 | uint64_t type_offset = byte_get_little_endian (tu_list + i * 8 + 8, 8); |
| 7667 | uint64_t signature = byte_get_little_endian (tu_list + i * 8 + 16, 8); |
| 7668 | |
| 7669 | printf (_("[%3u] 0x%lx 0x%lx "), i / 3, |
| 7670 | (unsigned long) tu_offset, |
| 7671 | (unsigned long) type_offset); |
| 7672 | print_dwarf_vma (signature, 8); |
| 7673 | printf ("\n"); |
| 7674 | } |
| 7675 | |
| 7676 | printf (_("\nAddress table:\n")); |
| 7677 | for (i = 0; i < address_table_size && i <= address_table_size - (2 * 8 + 4); |
| 7678 | i += 2 * 8 + 4) |
| 7679 | { |
| 7680 | uint64_t low = byte_get_little_endian (address_table + i, 8); |
| 7681 | uint64_t high = byte_get_little_endian (address_table + i + 8, 8); |
| 7682 | uint32_t cu_index = byte_get_little_endian (address_table + i + 16, 4); |
| 7683 | |
| 7684 | print_dwarf_vma (low, 8); |
| 7685 | print_dwarf_vma (high, 8); |
| 7686 | printf (_("%lu\n"), (unsigned long) cu_index); |
| 7687 | } |
| 7688 | |
| 7689 | printf (_("\nSymbol table:\n")); |
| 7690 | for (i = 0; i < symbol_table_slots; ++i) |
| 7691 | { |
| 7692 | uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4); |
| 7693 | uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4); |
| 7694 | uint32_t num_cus, cu; |
| 7695 | |
| 7696 | if (name_offset != 0 |
| 7697 | || cu_vector_offset != 0) |
| 7698 | { |
| 7699 | unsigned int j; |
| 7700 | unsigned char * adr; |
| 7701 | |
| 7702 | adr = constant_pool + name_offset; |
| 7703 | /* PR 17531: file: 5b7b07ad. */ |
| 7704 | if (adr < constant_pool || adr >= section->start + section->size) |
| 7705 | { |
| 7706 | printf (_("[%3u] <corrupt offset: %x>"), i, name_offset); |
| 7707 | warn (_("Corrupt name offset of 0x%x found for symbol table slot %d\n"), |
| 7708 | name_offset, i); |
| 7709 | } |
| 7710 | else |
| 7711 | printf ("[%3u] %.*s:", i, |
| 7712 | (int) (section->size - (constant_pool_offset + name_offset)), |
| 7713 | constant_pool + name_offset); |
| 7714 | |
| 7715 | adr = constant_pool + cu_vector_offset; |
| 7716 | if (adr < constant_pool || adr >= section->start + section->size - 3) |
| 7717 | { |
| 7718 | printf (_("<invalid CU vector offset: %x>\n"), cu_vector_offset); |
| 7719 | warn (_("Corrupt CU vector offset of 0x%x found for symbol table slot %d\n"), |
| 7720 | cu_vector_offset, i); |
| 7721 | continue; |
| 7722 | } |
| 7723 | |
| 7724 | num_cus = byte_get_little_endian (adr, 4); |
| 7725 | |
| 7726 | adr = constant_pool + cu_vector_offset + 4 + num_cus * 4; |
| 7727 | if (num_cus * 4 < num_cus |
| 7728 | || adr >= section->start + section->size |
| 7729 | || adr < constant_pool) |
| 7730 | { |
| 7731 | printf ("<invalid number of CUs: %d>\n", num_cus); |
| 7732 | warn (_("Invalid number of CUs (0x%x) for symbol table slot %d\n"), |
| 7733 | num_cus, i); |
| 7734 | continue; |
| 7735 | } |
| 7736 | |
| 7737 | if (num_cus > 1) |
| 7738 | printf ("\n"); |
| 7739 | |
| 7740 | for (j = 0; j < num_cus; ++j) |
| 7741 | { |
| 7742 | int is_static; |
| 7743 | gdb_index_symbol_kind kind; |
| 7744 | |
| 7745 | cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4); |
| 7746 | is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu); |
| 7747 | kind = GDB_INDEX_SYMBOL_KIND_VALUE (cu); |
| 7748 | cu = GDB_INDEX_CU_VALUE (cu); |
| 7749 | /* Convert to TU number if it's for a type unit. */ |
| 7750 | if (cu >= cu_list_elements / 2) |
| 7751 | printf ("%cT%lu", num_cus > 1 ? '\t' : ' ', |
| 7752 | (unsigned long) (cu - cu_list_elements / 2)); |
| 7753 | else |
| 7754 | printf ("%c%lu", num_cus > 1 ? '\t' : ' ', (unsigned long) cu); |
| 7755 | |
| 7756 | printf (" [%s, %s]", |
| 7757 | is_static ? _("static") : _("global"), |
| 7758 | get_gdb_index_symbol_kind_name (kind)); |
| 7759 | if (num_cus > 1) |
| 7760 | printf ("\n"); |
| 7761 | } |
| 7762 | if (num_cus <= 1) |
| 7763 | printf ("\n"); |
| 7764 | } |
| 7765 | } |
| 7766 | |
| 7767 | return 1; |
| 7768 | } |
| 7769 | |
| 7770 | /* Pre-allocate enough space for the CU/TU sets needed. */ |
| 7771 | |
| 7772 | static void |
| 7773 | prealloc_cu_tu_list (unsigned int nshndx) |
| 7774 | { |
| 7775 | if (shndx_pool == NULL) |
| 7776 | { |
| 7777 | shndx_pool_size = nshndx; |
| 7778 | shndx_pool_used = 0; |
| 7779 | shndx_pool = (unsigned int *) xcmalloc (shndx_pool_size, |
| 7780 | sizeof (unsigned int)); |
| 7781 | } |
| 7782 | else |
| 7783 | { |
| 7784 | shndx_pool_size = shndx_pool_used + nshndx; |
| 7785 | shndx_pool = (unsigned int *) xcrealloc (shndx_pool, shndx_pool_size, |
| 7786 | sizeof (unsigned int)); |
| 7787 | } |
| 7788 | } |
| 7789 | |
| 7790 | static void |
| 7791 | add_shndx_to_cu_tu_entry (unsigned int shndx) |
| 7792 | { |
| 7793 | if (shndx_pool_used >= shndx_pool_size) |
| 7794 | { |
| 7795 | error (_("Internal error: out of space in the shndx pool.\n")); |
| 7796 | return; |
| 7797 | } |
| 7798 | shndx_pool [shndx_pool_used++] = shndx; |
| 7799 | } |
| 7800 | |
| 7801 | static void |
| 7802 | end_cu_tu_entry (void) |
| 7803 | { |
| 7804 | if (shndx_pool_used >= shndx_pool_size) |
| 7805 | { |
| 7806 | error (_("Internal error: out of space in the shndx pool.\n")); |
| 7807 | return; |
| 7808 | } |
| 7809 | shndx_pool [shndx_pool_used++] = 0; |
| 7810 | } |
| 7811 | |
| 7812 | /* Return the short name of a DWARF section given by a DW_SECT enumerator. */ |
| 7813 | |
| 7814 | static const char * |
| 7815 | get_DW_SECT_short_name (unsigned int dw_sect) |
| 7816 | { |
| 7817 | static char buf[16]; |
| 7818 | |
| 7819 | switch (dw_sect) |
| 7820 | { |
| 7821 | case DW_SECT_INFO: |
| 7822 | return "info"; |
| 7823 | case DW_SECT_TYPES: |
| 7824 | return "types"; |
| 7825 | case DW_SECT_ABBREV: |
| 7826 | return "abbrev"; |
| 7827 | case DW_SECT_LINE: |
| 7828 | return "line"; |
| 7829 | case DW_SECT_LOC: |
| 7830 | return "loc"; |
| 7831 | case DW_SECT_STR_OFFSETS: |
| 7832 | return "str_off"; |
| 7833 | case DW_SECT_MACINFO: |
| 7834 | return "macinfo"; |
| 7835 | case DW_SECT_MACRO: |
| 7836 | return "macro"; |
| 7837 | default: |
| 7838 | break; |
| 7839 | } |
| 7840 | |
| 7841 | snprintf (buf, sizeof (buf), "%d", dw_sect); |
| 7842 | return buf; |
| 7843 | } |
| 7844 | |
| 7845 | /* Process a CU or TU index. If DO_DISPLAY is true, print the contents. |
| 7846 | These sections are extensions for Fission. |
| 7847 | See http://gcc.gnu.org/wiki/DebugFissionDWP. */ |
| 7848 | |
| 7849 | static int |
| 7850 | process_cu_tu_index (struct dwarf_section *section, int do_display) |
| 7851 | { |
| 7852 | unsigned char *phdr = section->start; |
| 7853 | unsigned char *limit = phdr + section->size; |
| 7854 | unsigned char *phash; |
| 7855 | unsigned char *pindex; |
| 7856 | unsigned char *ppool; |
| 7857 | unsigned int version; |
| 7858 | unsigned int ncols = 0; |
| 7859 | unsigned int nused; |
| 7860 | unsigned int nslots; |
| 7861 | unsigned int i; |
| 7862 | unsigned int j; |
| 7863 | dwarf_vma signature_high; |
| 7864 | dwarf_vma signature_low; |
| 7865 | char buf[64]; |
| 7866 | |
| 7867 | /* PR 17512: file: 002-168123-0.004. */ |
| 7868 | if (phdr == NULL) |
| 7869 | { |
| 7870 | warn (_("Section %s is empty\n"), section->name); |
| 7871 | return 0; |
| 7872 | } |
| 7873 | /* PR 17512: file: 002-376-0.004. */ |
| 7874 | if (section->size < 24) |
| 7875 | { |
| 7876 | warn (_("Section %s is too small to contain a CU/TU header\n"), |
| 7877 | section->name); |
| 7878 | return 0; |
| 7879 | } |
| 7880 | |
| 7881 | SAFE_BYTE_GET (version, phdr, 4, limit); |
| 7882 | if (version >= 2) |
| 7883 | SAFE_BYTE_GET (ncols, phdr + 4, 4, limit); |
| 7884 | SAFE_BYTE_GET (nused, phdr + 8, 4, limit); |
| 7885 | SAFE_BYTE_GET (nslots, phdr + 12, 4, limit); |
| 7886 | |
| 7887 | phash = phdr + 16; |
| 7888 | pindex = phash + nslots * 8; |
| 7889 | ppool = pindex + nslots * 4; |
| 7890 | |
| 7891 | /* PR 17531: file: 45d69832. */ |
| 7892 | if (pindex < phash || ppool < phdr || (pindex == phash && nslots != 0)) |
| 7893 | { |
| 7894 | warn (_("Section %s is too small for %d slots\n"), |
| 7895 | section->name, nslots); |
| 7896 | return 0; |
| 7897 | } |
| 7898 | |
| 7899 | if (do_display) |
| 7900 | { |
| 7901 | printf (_("Contents of the %s section:\n\n"), section->name); |
| 7902 | printf (_(" Version: %d\n"), version); |
| 7903 | if (version >= 2) |
| 7904 | printf (_(" Number of columns: %d\n"), ncols); |
| 7905 | printf (_(" Number of used entries: %d\n"), nused); |
| 7906 | printf (_(" Number of slots: %d\n\n"), nslots); |
| 7907 | } |
| 7908 | |
| 7909 | if (ppool > limit || ppool < phdr) |
| 7910 | { |
| 7911 | warn (_("Section %s too small for %d hash table entries\n"), |
| 7912 | section->name, nslots); |
| 7913 | return 0; |
| 7914 | } |
| 7915 | |
| 7916 | if (version == 1) |
| 7917 | { |
| 7918 | if (!do_display) |
| 7919 | prealloc_cu_tu_list ((limit - ppool) / 4); |
| 7920 | for (i = 0; i < nslots; i++) |
| 7921 | { |
| 7922 | unsigned char *shndx_list; |
| 7923 | unsigned int shndx; |
| 7924 | |
| 7925 | SAFE_BYTE_GET64 (phash, &signature_high, &signature_low, limit); |
| 7926 | if (signature_high != 0 || signature_low != 0) |
| 7927 | { |
| 7928 | SAFE_BYTE_GET (j, pindex, 4, limit); |
| 7929 | shndx_list = ppool + j * 4; |
| 7930 | /* PR 17531: file: 705e010d. */ |
| 7931 | if (shndx_list < ppool) |
| 7932 | { |
| 7933 | warn (_("Section index pool located before start of section\n")); |
| 7934 | return 0; |
| 7935 | } |
| 7936 | |
| 7937 | if (do_display) |
| 7938 | printf (_(" [%3d] Signature: 0x%s Sections: "), |
| 7939 | i, dwarf_vmatoa64 (signature_high, signature_low, |
| 7940 | buf, sizeof (buf))); |
| 7941 | for (;;) |
| 7942 | { |
| 7943 | if (shndx_list >= limit) |
| 7944 | { |
| 7945 | warn (_("Section %s too small for shndx pool\n"), |
| 7946 | section->name); |
| 7947 | return 0; |
| 7948 | } |
| 7949 | SAFE_BYTE_GET (shndx, shndx_list, 4, limit); |
| 7950 | if (shndx == 0) |
| 7951 | break; |
| 7952 | if (do_display) |
| 7953 | printf (" %d", shndx); |
| 7954 | else |
| 7955 | add_shndx_to_cu_tu_entry (shndx); |
| 7956 | shndx_list += 4; |
| 7957 | } |
| 7958 | if (do_display) |
| 7959 | printf ("\n"); |
| 7960 | else |
| 7961 | end_cu_tu_entry (); |
| 7962 | } |
| 7963 | phash += 8; |
| 7964 | pindex += 4; |
| 7965 | } |
| 7966 | } |
| 7967 | else if (version == 2) |
| 7968 | { |
| 7969 | unsigned int val; |
| 7970 | unsigned int dw_sect; |
| 7971 | unsigned char *ph = phash; |
| 7972 | unsigned char *pi = pindex; |
| 7973 | unsigned char *poffsets = ppool + ncols * 4; |
| 7974 | unsigned char *psizes = poffsets + nused * ncols * 4; |
| 7975 | unsigned char *pend = psizes + nused * ncols * 4; |
| 7976 | bfd_boolean is_tu_index; |
| 7977 | struct cu_tu_set *this_set = NULL; |
| 7978 | unsigned int row; |
| 7979 | unsigned char *prow; |
| 7980 | |
| 7981 | is_tu_index = strcmp (section->name, ".debug_tu_index") == 0; |
| 7982 | |
| 7983 | /* PR 17531: file: 0dd159bf. |
| 7984 | Check for wraparound with an overlarge ncols value. */ |
| 7985 | if (poffsets < ppool || (unsigned int) ((poffsets - ppool) / 4) != ncols) |
| 7986 | { |
| 7987 | warn (_("Overlarge number of columns: %x\n"), ncols); |
| 7988 | return 0; |
| 7989 | } |
| 7990 | |
| 7991 | if (pend > limit) |
| 7992 | { |
| 7993 | warn (_("Section %s too small for offset and size tables\n"), |
| 7994 | section->name); |
| 7995 | return 0; |
| 7996 | } |
| 7997 | |
| 7998 | if (do_display) |
| 7999 | { |
| 8000 | printf (_(" Offset table\n")); |
| 8001 | printf (" slot %-16s ", |
| 8002 | is_tu_index ? _("signature") : _("dwo_id")); |
| 8003 | } |
| 8004 | else |
| 8005 | { |
| 8006 | if (is_tu_index) |
| 8007 | { |
| 8008 | tu_count = nused; |
| 8009 | tu_sets = xcalloc2 (nused, sizeof (struct cu_tu_set)); |
| 8010 | this_set = tu_sets; |
| 8011 | } |
| 8012 | else |
| 8013 | { |
| 8014 | cu_count = nused; |
| 8015 | cu_sets = xcalloc2 (nused, sizeof (struct cu_tu_set)); |
| 8016 | this_set = cu_sets; |
| 8017 | } |
| 8018 | } |
| 8019 | |
| 8020 | if (do_display) |
| 8021 | { |
| 8022 | for (j = 0; j < ncols; j++) |
| 8023 | { |
| 8024 | SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); |
| 8025 | printf (" %8s", get_DW_SECT_short_name (dw_sect)); |
| 8026 | } |
| 8027 | printf ("\n"); |
| 8028 | } |
| 8029 | |
| 8030 | for (i = 0; i < nslots; i++) |
| 8031 | { |
| 8032 | SAFE_BYTE_GET64 (ph, &signature_high, &signature_low, limit); |
| 8033 | |
| 8034 | SAFE_BYTE_GET (row, pi, 4, limit); |
| 8035 | if (row != 0) |
| 8036 | { |
| 8037 | /* PR 17531: file: a05f6ab3. */ |
| 8038 | if (row > nused) |
| 8039 | { |
| 8040 | warn (_("Row index (%u) is larger than number of used entries (%u)\n"), |
| 8041 | row, nused); |
| 8042 | return 0; |
| 8043 | } |
| 8044 | |
| 8045 | if (!do_display) |
| 8046 | memcpy (&this_set[row - 1].signature, ph, sizeof (uint64_t)); |
| 8047 | |
| 8048 | prow = poffsets + (row - 1) * ncols * 4; |
| 8049 | /* PR 17531: file: b8ce60a8. */ |
| 8050 | if (prow < poffsets || prow > limit) |
| 8051 | { |
| 8052 | warn (_("Row index (%u) * num columns (%u) > space remaining in section\n"), |
| 8053 | row, ncols); |
| 8054 | return 0; |
| 8055 | } |
| 8056 | |
| 8057 | if (do_display) |
| 8058 | printf (_(" [%3d] 0x%s"), |
| 8059 | i, dwarf_vmatoa64 (signature_high, signature_low, |
| 8060 | buf, sizeof (buf))); |
| 8061 | for (j = 0; j < ncols; j++) |
| 8062 | { |
| 8063 | SAFE_BYTE_GET (val, prow + j * 4, 4, limit); |
| 8064 | if (do_display) |
| 8065 | printf (" %8d", val); |
| 8066 | else |
| 8067 | { |
| 8068 | SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); |
| 8069 | |
| 8070 | /* PR 17531: file: 10796eb3. */ |
| 8071 | if (dw_sect >= DW_SECT_MAX) |
| 8072 | warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect); |
| 8073 | else |
| 8074 | this_set [row - 1].section_offsets [dw_sect] = val; |
| 8075 | } |
| 8076 | } |
| 8077 | |
| 8078 | if (do_display) |
| 8079 | printf ("\n"); |
| 8080 | } |
| 8081 | ph += 8; |
| 8082 | pi += 4; |
| 8083 | } |
| 8084 | |
| 8085 | ph = phash; |
| 8086 | pi = pindex; |
| 8087 | if (do_display) |
| 8088 | { |
| 8089 | printf ("\n"); |
| 8090 | printf (_(" Size table\n")); |
| 8091 | printf (" slot %-16s ", |
| 8092 | is_tu_index ? _("signature") : _("dwo_id")); |
| 8093 | } |
| 8094 | |
| 8095 | for (j = 0; j < ncols; j++) |
| 8096 | { |
| 8097 | SAFE_BYTE_GET (val, ppool + j * 4, 4, limit); |
| 8098 | if (do_display) |
| 8099 | printf (" %8s", get_DW_SECT_short_name (val)); |
| 8100 | } |
| 8101 | |
| 8102 | if (do_display) |
| 8103 | printf ("\n"); |
| 8104 | |
| 8105 | for (i = 0; i < nslots; i++) |
| 8106 | { |
| 8107 | SAFE_BYTE_GET64 (ph, &signature_high, &signature_low, limit); |
| 8108 | |
| 8109 | SAFE_BYTE_GET (row, pi, 4, limit); |
| 8110 | if (row != 0) |
| 8111 | { |
| 8112 | prow = psizes + (row - 1) * ncols * 4; |
| 8113 | |
| 8114 | if (do_display) |
| 8115 | printf (_(" [%3d] 0x%s"), |
| 8116 | i, dwarf_vmatoa64 (signature_high, signature_low, |
| 8117 | buf, sizeof (buf))); |
| 8118 | |
| 8119 | for (j = 0; j < ncols; j++) |
| 8120 | { |
| 8121 | SAFE_BYTE_GET (val, prow + j * 4, 4, limit); |
| 8122 | if (do_display) |
| 8123 | printf (" %8d", val); |
| 8124 | else |
| 8125 | { |
| 8126 | SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); |
| 8127 | if (dw_sect >= DW_SECT_MAX) |
| 8128 | warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect); |
| 8129 | else |
| 8130 | this_set [row - 1].section_sizes [dw_sect] = val; |
| 8131 | } |
| 8132 | } |
| 8133 | |
| 8134 | if (do_display) |
| 8135 | printf ("\n"); |
| 8136 | } |
| 8137 | |
| 8138 | ph += 8; |
| 8139 | pi += 4; |
| 8140 | } |
| 8141 | } |
| 8142 | else if (do_display) |
| 8143 | printf (_(" Unsupported version (%d)\n"), version); |
| 8144 | |
| 8145 | if (do_display) |
| 8146 | printf ("\n"); |
| 8147 | |
| 8148 | return 1; |
| 8149 | } |
| 8150 | |
| 8151 | /* Load the CU and TU indexes if present. This will build a list of |
| 8152 | section sets that we can use to associate a .debug_info.dwo section |
| 8153 | with its associated .debug_abbrev.dwo section in a .dwp file. */ |
| 8154 | |
| 8155 | static bfd_boolean |
| 8156 | load_cu_tu_indexes (void *file) |
| 8157 | { |
| 8158 | static int cu_tu_indexes_read = -1; /* Tri-state variable. */ |
| 8159 | |
| 8160 | /* If we have already loaded (or tried to load) the CU and TU indexes |
| 8161 | then do not bother to repeat the task. */ |
| 8162 | if (cu_tu_indexes_read == -1) |
| 8163 | { |
| 8164 | cu_tu_indexes_read = TRUE; |
| 8165 | |
| 8166 | if (load_debug_section (dwp_cu_index, file)) |
| 8167 | if (! process_cu_tu_index (&debug_displays [dwp_cu_index].section, 0)) |
| 8168 | cu_tu_indexes_read = FALSE; |
| 8169 | |
| 8170 | if (load_debug_section (dwp_tu_index, file)) |
| 8171 | if (! process_cu_tu_index (&debug_displays [dwp_tu_index].section, 0)) |
| 8172 | cu_tu_indexes_read = FALSE; |
| 8173 | } |
| 8174 | |
| 8175 | return (bfd_boolean) cu_tu_indexes_read; |
| 8176 | } |
| 8177 | |
| 8178 | /* Find the set of sections that includes section SHNDX. */ |
| 8179 | |
| 8180 | unsigned int * |
| 8181 | find_cu_tu_set (void *file, unsigned int shndx) |
| 8182 | { |
| 8183 | unsigned int i; |
| 8184 | |
| 8185 | if (! load_cu_tu_indexes (file)) |
| 8186 | return NULL; |
| 8187 | |
| 8188 | /* Find SHNDX in the shndx pool. */ |
| 8189 | for (i = 0; i < shndx_pool_used; i++) |
| 8190 | if (shndx_pool [i] == shndx) |
| 8191 | break; |
| 8192 | |
| 8193 | if (i >= shndx_pool_used) |
| 8194 | return NULL; |
| 8195 | |
| 8196 | /* Now backup to find the first entry in the set. */ |
| 8197 | while (i > 0 && shndx_pool [i - 1] != 0) |
| 8198 | i--; |
| 8199 | |
| 8200 | return shndx_pool + i; |
| 8201 | } |
| 8202 | |
| 8203 | /* Display a .debug_cu_index or .debug_tu_index section. */ |
| 8204 | |
| 8205 | static int |
| 8206 | display_cu_index (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) |
| 8207 | { |
| 8208 | return process_cu_tu_index (section, 1); |
| 8209 | } |
| 8210 | |
| 8211 | static int |
| 8212 | display_debug_not_supported (struct dwarf_section *section, |
| 8213 | void *file ATTRIBUTE_UNUSED) |
| 8214 | { |
| 8215 | printf (_("Displaying the debug contents of section %s is not yet supported.\n"), |
| 8216 | section->name); |
| 8217 | |
| 8218 | return 1; |
| 8219 | } |
| 8220 | |
| 8221 | /* Like malloc, but takes two parameters like calloc. |
| 8222 | Verifies that the first parameter is not too large. |
| 8223 | Note: does *not* initialise the allocated memory to zero. */ |
| 8224 | void * |
| 8225 | cmalloc (size_t nmemb, size_t size) |
| 8226 | { |
| 8227 | /* Check for overflow. */ |
| 8228 | if (nmemb >= ~(size_t) 0 / size) |
| 8229 | return NULL; |
| 8230 | |
| 8231 | return xmalloc (nmemb * size); |
| 8232 | } |
| 8233 | |
| 8234 | /* Like xmalloc, but takes two parameters like calloc. |
| 8235 | Verifies that the first parameter is not too large. |
| 8236 | Note: does *not* initialise the allocated memory to zero. */ |
| 8237 | void * |
| 8238 | xcmalloc (size_t nmemb, size_t size) |
| 8239 | { |
| 8240 | /* Check for overflow. */ |
| 8241 | if (nmemb >= ~(size_t) 0 / size) |
| 8242 | { |
| 8243 | fprintf (stderr, |
| 8244 | _("Attempt to allocate an array with an excessive number of elements: 0x%lx\n"), |
| 8245 | (long) nmemb); |
| 8246 | xexit (1); |
| 8247 | } |
| 8248 | |
| 8249 | return xmalloc (nmemb * size); |
| 8250 | } |
| 8251 | |
| 8252 | /* Like xrealloc, but takes three parameters. |
| 8253 | Verifies that the second parameter is not too large. |
| 8254 | Note: does *not* initialise any new memory to zero. */ |
| 8255 | void * |
| 8256 | xcrealloc (void *ptr, size_t nmemb, size_t size) |
| 8257 | { |
| 8258 | /* Check for overflow. */ |
| 8259 | if (nmemb >= ~(size_t) 0 / size) |
| 8260 | { |
| 8261 | fprintf (stderr, |
| 8262 | _("Attempt to re-allocate an array with an excessive number of elements: 0x%lx\n"), |
| 8263 | (long) nmemb); |
| 8264 | xexit (1); |
| 8265 | } |
| 8266 | |
| 8267 | return xrealloc (ptr, nmemb * size); |
| 8268 | } |
| 8269 | |
| 8270 | /* Like xcalloc, but verifies that the first parameter is not too large. */ |
| 8271 | void * |
| 8272 | xcalloc2 (size_t nmemb, size_t size) |
| 8273 | { |
| 8274 | /* Check for overflow. */ |
| 8275 | if (nmemb >= ~(size_t) 0 / size) |
| 8276 | { |
| 8277 | fprintf (stderr, |
| 8278 | _("Attempt to allocate a zero'ed array with an excessive number of elements: 0x%lx\n"), |
| 8279 | (long) nmemb); |
| 8280 | xexit (1); |
| 8281 | } |
| 8282 | |
| 8283 | return xcalloc (nmemb, size); |
| 8284 | } |
| 8285 | |
| 8286 | void |
| 8287 | free_debug_memory (void) |
| 8288 | { |
| 8289 | unsigned int i; |
| 8290 | |
| 8291 | free_abbrevs (); |
| 8292 | |
| 8293 | for (i = 0; i < max; i++) |
| 8294 | free_debug_section ((enum dwarf_section_display_enum) i); |
| 8295 | |
| 8296 | if (debug_information != NULL) |
| 8297 | { |
| 8298 | if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE) |
| 8299 | { |
| 8300 | for (i = 0; i < num_debug_info_entries; i++) |
| 8301 | { |
| 8302 | if (!debug_information [i].max_loc_offsets) |
| 8303 | { |
| 8304 | free (debug_information [i].loc_offsets); |
| 8305 | free (debug_information [i].have_frame_base); |
| 8306 | } |
| 8307 | if (!debug_information [i].max_range_lists) |
| 8308 | free (debug_information [i].range_lists); |
| 8309 | } |
| 8310 | } |
| 8311 | free (debug_information); |
| 8312 | debug_information = NULL; |
| 8313 | alloc_num_debug_info_entries = num_debug_info_entries = 0; |
| 8314 | } |
| 8315 | } |
| 8316 | |
| 8317 | void |
| 8318 | dwarf_select_sections_by_names (const char *names) |
| 8319 | { |
| 8320 | typedef struct |
| 8321 | { |
| 8322 | const char * option; |
| 8323 | int * variable; |
| 8324 | int val; |
| 8325 | } |
| 8326 | debug_dump_long_opts; |
| 8327 | |
| 8328 | static const debug_dump_long_opts opts_table [] = |
| 8329 | { |
| 8330 | /* Please keep this table alpha- sorted. */ |
| 8331 | { "Ranges", & do_debug_ranges, 1 }, |
| 8332 | { "abbrev", & do_debug_abbrevs, 1 }, |
| 8333 | { "addr", & do_debug_addr, 1 }, |
| 8334 | { "aranges", & do_debug_aranges, 1 }, |
| 8335 | { "cu_index", & do_debug_cu_index, 1 }, |
| 8336 | { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED }, |
| 8337 | { "frames", & do_debug_frames, 1 }, |
| 8338 | { "frames-interp", & do_debug_frames_interp, 1 }, |
| 8339 | /* The special .gdb_index section. */ |
| 8340 | { "gdb_index", & do_gdb_index, 1 }, |
| 8341 | { "info", & do_debug_info, 1 }, |
| 8342 | { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility. */ |
| 8343 | { "loc", & do_debug_loc, 1 }, |
| 8344 | { "macro", & do_debug_macinfo, 1 }, |
| 8345 | { "pubnames", & do_debug_pubnames, 1 }, |
| 8346 | { "pubtypes", & do_debug_pubtypes, 1 }, |
| 8347 | /* This entry is for compatibility |
| 8348 | with earlier versions of readelf. */ |
| 8349 | { "ranges", & do_debug_aranges, 1 }, |
| 8350 | { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, |
| 8351 | { "str", & do_debug_str, 1 }, |
| 8352 | /* These trace_* sections are used by Itanium VMS. */ |
| 8353 | { "trace_abbrev", & do_trace_abbrevs, 1 }, |
| 8354 | { "trace_aranges", & do_trace_aranges, 1 }, |
| 8355 | { "trace_info", & do_trace_info, 1 }, |
| 8356 | { NULL, NULL, 0 } |
| 8357 | }; |
| 8358 | |
| 8359 | const char *p; |
| 8360 | |
| 8361 | p = names; |
| 8362 | while (*p) |
| 8363 | { |
| 8364 | const debug_dump_long_opts * entry; |
| 8365 | |
| 8366 | for (entry = opts_table; entry->option; entry++) |
| 8367 | { |
| 8368 | size_t len = strlen (entry->option); |
| 8369 | |
| 8370 | if (strncmp (p, entry->option, len) == 0 |
| 8371 | && (p[len] == ',' || p[len] == '\0')) |
| 8372 | { |
| 8373 | * entry->variable |= entry->val; |
| 8374 | |
| 8375 | /* The --debug-dump=frames-interp option also |
| 8376 | enables the --debug-dump=frames option. */ |
| 8377 | if (do_debug_frames_interp) |
| 8378 | do_debug_frames = 1; |
| 8379 | |
| 8380 | p += len; |
| 8381 | break; |
| 8382 | } |
| 8383 | } |
| 8384 | |
| 8385 | if (entry->option == NULL) |
| 8386 | { |
| 8387 | warn (_("Unrecognized debug option '%s'\n"), p); |
| 8388 | p = strchr (p, ','); |
| 8389 | if (p == NULL) |
| 8390 | break; |
| 8391 | } |
| 8392 | |
| 8393 | if (*p == ',') |
| 8394 | p++; |
| 8395 | } |
| 8396 | } |
| 8397 | |
| 8398 | void |
| 8399 | dwarf_select_sections_by_letters (const char *letters) |
| 8400 | { |
| 8401 | unsigned int lindex = 0; |
| 8402 | |
| 8403 | while (letters[lindex]) |
| 8404 | switch (letters[lindex++]) |
| 8405 | { |
| 8406 | case 'i': |
| 8407 | do_debug_info = 1; |
| 8408 | break; |
| 8409 | |
| 8410 | case 'a': |
| 8411 | do_debug_abbrevs = 1; |
| 8412 | break; |
| 8413 | |
| 8414 | case 'l': |
| 8415 | do_debug_lines |= FLAG_DEBUG_LINES_RAW; |
| 8416 | break; |
| 8417 | |
| 8418 | case 'L': |
| 8419 | do_debug_lines |= FLAG_DEBUG_LINES_DECODED; |
| 8420 | break; |
| 8421 | |
| 8422 | case 'p': |
| 8423 | do_debug_pubnames = 1; |
| 8424 | break; |
| 8425 | |
| 8426 | case 't': |
| 8427 | do_debug_pubtypes = 1; |
| 8428 | break; |
| 8429 | |
| 8430 | case 'r': |
| 8431 | do_debug_aranges = 1; |
| 8432 | break; |
| 8433 | |
| 8434 | case 'R': |
| 8435 | do_debug_ranges = 1; |
| 8436 | break; |
| 8437 | |
| 8438 | case 'F': |
| 8439 | do_debug_frames_interp = 1; |
| 8440 | /* Fall through. */ |
| 8441 | case 'f': |
| 8442 | do_debug_frames = 1; |
| 8443 | break; |
| 8444 | |
| 8445 | case 'm': |
| 8446 | do_debug_macinfo = 1; |
| 8447 | break; |
| 8448 | |
| 8449 | case 's': |
| 8450 | do_debug_str = 1; |
| 8451 | break; |
| 8452 | |
| 8453 | case 'o': |
| 8454 | do_debug_loc = 1; |
| 8455 | break; |
| 8456 | |
| 8457 | default: |
| 8458 | warn (_("Unrecognized debug option '%s'\n"), letters); |
| 8459 | break; |
| 8460 | } |
| 8461 | } |
| 8462 | |
| 8463 | void |
| 8464 | dwarf_select_sections_all (void) |
| 8465 | { |
| 8466 | do_debug_info = 1; |
| 8467 | do_debug_abbrevs = 1; |
| 8468 | do_debug_lines = FLAG_DEBUG_LINES_RAW; |
| 8469 | do_debug_pubnames = 1; |
| 8470 | do_debug_pubtypes = 1; |
| 8471 | do_debug_aranges = 1; |
| 8472 | do_debug_ranges = 1; |
| 8473 | do_debug_frames = 1; |
| 8474 | do_debug_macinfo = 1; |
| 8475 | do_debug_str = 1; |
| 8476 | do_debug_loc = 1; |
| 8477 | do_gdb_index = 1; |
| 8478 | do_trace_info = 1; |
| 8479 | do_trace_abbrevs = 1; |
| 8480 | do_trace_aranges = 1; |
| 8481 | do_debug_addr = 1; |
| 8482 | do_debug_cu_index = 1; |
| 8483 | } |
| 8484 | |
| 8485 | struct dwarf_section_display debug_displays[] = |
| 8486 | { |
| 8487 | { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8488 | display_debug_abbrev, &do_debug_abbrevs, FALSE }, |
| 8489 | { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8490 | display_debug_aranges, &do_debug_aranges, TRUE }, |
| 8491 | { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8492 | display_debug_frames, &do_debug_frames, TRUE }, |
| 8493 | { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0, abbrev, NULL, 0, NULL }, |
| 8494 | display_debug_info, &do_debug_info, TRUE }, |
| 8495 | { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8496 | display_debug_lines, &do_debug_lines, TRUE }, |
| 8497 | { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8498 | display_debug_pubnames, &do_debug_pubnames, FALSE }, |
| 8499 | { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8500 | display_debug_gnu_pubnames, &do_debug_pubnames, FALSE }, |
| 8501 | { { ".eh_frame", "", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8502 | display_debug_frames, &do_debug_frames, TRUE }, |
| 8503 | { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8504 | display_debug_macinfo, &do_debug_macinfo, FALSE }, |
| 8505 | { { ".debug_macro", ".zdebug_macro", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8506 | display_debug_macro, &do_debug_macinfo, TRUE }, |
| 8507 | { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8508 | display_debug_str, &do_debug_str, FALSE }, |
| 8509 | { { ".debug_line_str", ".zdebug_line_str", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8510 | display_debug_str, &do_debug_str, FALSE }, |
| 8511 | { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8512 | display_debug_loc, &do_debug_loc, TRUE }, |
| 8513 | { { ".debug_loclists", ".zdebug_loclists", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8514 | display_debug_loc, &do_debug_loc, TRUE }, |
| 8515 | { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8516 | display_debug_pubnames, &do_debug_pubtypes, FALSE }, |
| 8517 | { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8518 | display_debug_gnu_pubnames, &do_debug_pubtypes, FALSE }, |
| 8519 | { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8520 | display_debug_ranges, &do_debug_ranges, TRUE }, |
| 8521 | { { ".debug_rnglists", ".zdebug_rnglists", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8522 | display_debug_ranges, &do_debug_ranges, TRUE }, |
| 8523 | { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8524 | display_debug_not_supported, NULL, FALSE }, |
| 8525 | { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8526 | display_debug_not_supported, NULL, FALSE }, |
| 8527 | { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0, abbrev, NULL, 0, NULL }, |
| 8528 | display_debug_types, &do_debug_info, TRUE }, |
| 8529 | { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8530 | display_debug_not_supported, NULL, FALSE }, |
| 8531 | { { ".gdb_index", "", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8532 | display_gdb_index, &do_gdb_index, FALSE }, |
| 8533 | { { ".trace_info", "", NULL, NULL, 0, 0, trace_abbrev, NULL, 0, NULL }, |
| 8534 | display_trace_info, &do_trace_info, TRUE }, |
| 8535 | { { ".trace_abbrev", "", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8536 | display_debug_abbrev, &do_trace_abbrevs, FALSE }, |
| 8537 | { { ".trace_aranges", "", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8538 | display_debug_aranges, &do_trace_aranges, FALSE }, |
| 8539 | { { ".debug_info.dwo", ".zdebug_info.dwo", NULL, NULL, 0, 0, abbrev_dwo, NULL, 0, NULL }, |
| 8540 | display_debug_info, &do_debug_info, TRUE }, |
| 8541 | { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8542 | display_debug_abbrev, &do_debug_abbrevs, FALSE }, |
| 8543 | { { ".debug_types.dwo", ".zdebug_types.dwo", NULL, NULL, 0, 0, abbrev_dwo, NULL, 0, NULL }, |
| 8544 | display_debug_types, &do_debug_info, TRUE }, |
| 8545 | { { ".debug_line.dwo", ".zdebug_line.dwo", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8546 | display_debug_lines, &do_debug_lines, TRUE }, |
| 8547 | { { ".debug_loc.dwo", ".zdebug_loc.dwo", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8548 | display_debug_loc, &do_debug_loc, TRUE }, |
| 8549 | { { ".debug_macro.dwo", ".zdebug_macro.dwo", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8550 | display_debug_macro, &do_debug_macinfo, TRUE }, |
| 8551 | { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8552 | display_debug_macinfo, &do_debug_macinfo, FALSE }, |
| 8553 | { { ".debug_str.dwo", ".zdebug_str.dwo", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8554 | display_debug_str, &do_debug_str, TRUE }, |
| 8555 | { { ".debug_str_offsets", ".zdebug_str_offsets", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8556 | display_debug_str_offsets, NULL, FALSE }, |
| 8557 | { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8558 | display_debug_str_offsets, NULL, FALSE }, |
| 8559 | { { ".debug_addr", ".zdebug_addr", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8560 | display_debug_addr, &do_debug_addr, TRUE }, |
| 8561 | { { ".debug_cu_index", "", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8562 | display_cu_index, &do_debug_cu_index, FALSE }, |
| 8563 | { { ".debug_tu_index", "", NULL, NULL, 0, 0, 0, NULL, 0, NULL }, |
| 8564 | display_cu_index, &do_debug_cu_index, FALSE }, |
| 8565 | }; |