Lines Matching +full:- +full:lh
2 Copyright (C) 1994-2022 Free Software Foundation, Inc.
29 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
30 MA 02110-1301, USA. */
36 #include "elf-bfd.h"
87 This is a fairly standard radix-256 trie, used to quickly locate which
100 So for a 64-bit address like 0x1234567abcd, we would start at the root and go
101 down child[0x00]->child[0x00]->child[0x01]->child[0x23]->child[0x45] etc.,
104 interior node if possible.) This gives us near-constant lookup times;
106 within a single 256-byte segment of the binary, in which case we have to
114 /* Experiments have shown 16 to be a memory-efficient default leaf size.
151 leaf->head.num_room_in_leaf = TRIE_LEAF_SIZE; in alloc_trie_leaf()
152 return &leaf->head; in alloc_trie_leaf()
245 /* Per-file stuff. */
250 valid - it saves having to possibly dereference the gnu_debuglink each
377 /* DWARF format version for this unit - from unit header. */
380 /* Address size for this unit - from unit header. */
383 /* Offset size for this unit - from unit header. */
386 /* Base address for this unit - from DW_AT_low_pc attribute of
495 == debug_max + 1 ? 1 : -1];
504 /* Variable and function hash tables. This is used to speed up look-up
554 ret->head = NULL; in info_hash_table_newfunc()
573 if (!bfd_hash_table_init (&hash_table->base, info_hash_table_newfunc, in create_info_hash_table()
597 entry = (struct info_hash_entry*) bfd_hash_lookup (&hash_table->base, in insert_info_hash_table()
602 node = (struct info_list_node *) bfd_hash_allocate (&hash_table->base, in insert_info_hash_table()
607 node->info = info; in insert_info_hash_table()
608 node->next = entry->head; in insert_info_hash_table()
609 entry->head = node; in insert_info_hash_table()
622 entry = (struct info_hash_entry*) bfd_hash_lookup (&hash_table->base, key, in lookup_info_hash_table()
624 return entry ? entry->head : NULL; in lookup_info_hash_table()
641 const char *section_name = sec->uncompressed_name; in read_section()
654 section_name = sec->compressed_name; in read_section()
660 sec->uncompressed_name); in read_section()
680 /* Paranoia - alloc one extra so that we can make sure a string in read_section()
685 /* Paranoia - this should never happen. */ in read_section()
708 /* xgettext: c-format */ in read_section()
726 if (end - buf < n) in read_n_bytes()
745 if (end - buf < 1) in read_1_signed_byte()
797 if (size > (size_t) (end - buf)) in read_blk()
800 block->data = NULL; in read_blk()
801 block->size = 0; in read_blk()
806 block->data = buf; in read_blk()
807 block->size = size; in read_blk()
827 if (str == buf - 1) in read_string()
851 struct dwarf2_debug *stash = unit->stash; in read_indirect_string()
852 struct dwarf2_debug_file *file = unit->file; in read_indirect_string()
855 if (unit->offset_size > (size_t) (buf_end - *ptr)) in read_indirect_string()
861 if (unit->offset_size == 4) in read_indirect_string()
862 offset = read_4_bytes (unit->abfd, ptr, buf_end); in read_indirect_string()
864 offset = read_8_bytes (unit->abfd, ptr, buf_end); in read_indirect_string()
866 if (! read_section (unit->abfd, &stash->debug_sections[debug_str], in read_indirect_string()
867 file->syms, offset, in read_indirect_string()
868 &file->dwarf_str_buffer, &file->dwarf_str_size)) in read_indirect_string()
871 str = (char *) file->dwarf_str_buffer + offset; in read_indirect_string()
885 struct dwarf2_debug *stash = unit->stash; in read_indirect_line_string()
886 struct dwarf2_debug_file *file = unit->file; in read_indirect_line_string()
889 if (unit->offset_size > (size_t) (buf_end - *ptr)) in read_indirect_line_string()
895 if (unit->offset_size == 4) in read_indirect_line_string()
896 offset = read_4_bytes (unit->abfd, ptr, buf_end); in read_indirect_line_string()
898 offset = read_8_bytes (unit->abfd, ptr, buf_end); in read_indirect_line_string()
900 if (! read_section (unit->abfd, &stash->debug_sections[debug_line_str], in read_indirect_line_string()
901 file->syms, offset, in read_indirect_line_string()
902 &file->dwarf_line_str_buffer, in read_indirect_line_string()
903 &file->dwarf_line_str_size)) in read_indirect_line_string()
906 str = (char *) file->dwarf_line_str_buffer + offset; in read_indirect_line_string()
922 struct dwarf2_debug *stash = unit->stash; in read_alt_indirect_string()
925 if (unit->offset_size > (size_t) (buf_end - *ptr)) in read_alt_indirect_string()
931 if (unit->offset_size == 4) in read_alt_indirect_string()
932 offset = read_4_bytes (unit->abfd, ptr, buf_end); in read_alt_indirect_string()
934 offset = read_8_bytes (unit->abfd, ptr, buf_end); in read_alt_indirect_string()
936 if (stash->alt.bfd_ptr == NULL) in read_alt_indirect_string()
939 char *debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR); in read_alt_indirect_string()
955 stash->alt.bfd_ptr = debug_bfd; in read_alt_indirect_string()
958 if (! read_section (unit->stash->alt.bfd_ptr, in read_alt_indirect_string()
959 stash->debug_sections + debug_str_alt, in read_alt_indirect_string()
960 stash->alt.syms, offset, in read_alt_indirect_string()
961 &stash->alt.dwarf_str_buffer, in read_alt_indirect_string()
962 &stash->alt.dwarf_str_size)) in read_alt_indirect_string()
965 str = (char *) stash->alt.dwarf_str_buffer + offset; in read_alt_indirect_string()
979 struct dwarf2_debug *stash = unit->stash; in read_alt_indirect_ref()
981 if (stash->alt.bfd_ptr == NULL) in read_alt_indirect_ref()
984 char *debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR); in read_alt_indirect_ref()
1000 stash->alt.bfd_ptr = debug_bfd; in read_alt_indirect_ref()
1003 if (! read_section (unit->stash->alt.bfd_ptr, in read_alt_indirect_ref()
1004 stash->debug_sections + debug_info_alt, in read_alt_indirect_ref()
1005 stash->alt.syms, offset, in read_alt_indirect_ref()
1006 &stash->alt.dwarf_info_buffer, in read_alt_indirect_ref()
1007 &stash->alt.dwarf_info_size)) in read_alt_indirect_ref()
1010 return stash->alt.dwarf_info_buffer + offset; in read_alt_indirect_ref()
1019 if (bfd_get_flavour (unit->abfd) == bfd_target_elf_flavour) in read_address()
1020 signed_vma = get_elf_backend_data (unit->abfd)->sign_extend_vma; in read_address()
1022 if (unit->addr_size > (size_t) (buf_end - buf)) in read_address()
1028 *ptr = buf + unit->addr_size; in read_address()
1031 switch (unit->addr_size) in read_address()
1034 return bfd_get_signed_64 (unit->abfd, buf); in read_address()
1036 return bfd_get_signed_32 (unit->abfd, buf); in read_address()
1038 return bfd_get_signed_16 (unit->abfd, buf); in read_address()
1045 switch (unit->addr_size) in read_address()
1048 return bfd_get_64 (unit->abfd, buf); in read_address()
1050 return bfd_get_32 (unit->abfd, buf); in read_address()
1052 return bfd_get_16 (unit->abfd, buf); in read_address()
1072 if (abbrev->number == number) in lookup_abbrev()
1075 abbrev = abbrev->next; in lookup_abbrev()
1095 return htab_hash_pointer ((void *) ent->offset); in hash_abbrev()
1103 return a->offset == b->offset; in eq_abbrev()
1110 struct abbrev_info **abbrevs = ent->abbrevs; in del_abbrev()
1119 free (abbrev->attrs); in del_abbrev()
1120 abbrev = abbrev->next; in del_abbrev()
1148 slot = htab_find_slot (file->abbrev_offsets, &ent, INSERT); in read_abbrevs()
1152 return ((struct abbrev_offset_entry *) (*slot))->abbrevs; in read_abbrevs()
1154 if (! read_section (abfd, &stash->debug_sections[debug_abbrev], in read_abbrevs()
1155 file->syms, offset, in read_abbrevs()
1156 &file->dwarf_abbrev_buffer, in read_abbrevs()
1157 &file->dwarf_abbrev_size)) in read_abbrevs()
1165 abbrev_ptr = file->dwarf_abbrev_buffer + offset; in read_abbrevs()
1166 abbrev_end = file->dwarf_abbrev_buffer + file->dwarf_abbrev_size; in read_abbrevs()
1179 cur_abbrev->number = abbrev_number; in read_abbrevs()
1180 cur_abbrev->tag = (enum dwarf_tag) in read_abbrevs()
1183 cur_abbrev->has_children = read_1_byte (abfd, &abbrev_ptr, abbrev_end); in read_abbrevs()
1189 bfd_vma implicit_const = -1; in read_abbrevs()
1201 if ((cur_abbrev->num_attrs % ATTR_ALLOC_CHUNK) == 0) in read_abbrevs()
1205 amt = cur_abbrev->num_attrs + ATTR_ALLOC_CHUNK; in read_abbrevs()
1207 tmp = (struct attr_abbrev *) bfd_realloc (cur_abbrev->attrs, amt); in read_abbrevs()
1210 cur_abbrev->attrs = tmp; in read_abbrevs()
1213 cur_abbrev->attrs[cur_abbrev->num_attrs].name in read_abbrevs()
1215 cur_abbrev->attrs[cur_abbrev->num_attrs].form in read_abbrevs()
1217 cur_abbrev->attrs[cur_abbrev->num_attrs].implicit_const in read_abbrevs()
1219 ++cur_abbrev->num_attrs; in read_abbrevs()
1223 cur_abbrev->next = abbrevs[hash_number]; in read_abbrevs()
1233 if ((size_t) (abbrev_ptr - file->dwarf_abbrev_buffer) in read_abbrevs()
1234 >= file->dwarf_abbrev_size) in read_abbrevs()
1260 free (abbrev->attrs); in read_abbrevs()
1261 abbrev = abbrev->next; in read_abbrevs()
1274 switch (attr->form) in is_str_form()
1297 switch (attr->form) in is_int_form()
1330 /* Returns true if the form is strx[1-4]. */
1342 /* Return true if the form is addrx[1-4]. */
1359 struct dwarf2_debug *stash = unit->stash; in read_indexed_address()
1360 struct dwarf2_debug_file *file = unit->file; in read_indexed_address()
1367 if (!read_section (unit->abfd, &stash->debug_sections[debug_addr], in read_indexed_address()
1368 file->syms, 0, in read_indexed_address()
1369 &file->dwarf_addr_buffer, &file->dwarf_addr_size)) in read_indexed_address()
1372 if (_bfd_mul_overflow (idx, unit->offset_size, &offset)) in read_indexed_address()
1375 offset += unit->dwarf_addr_offset; in read_indexed_address()
1376 if (offset < unit->dwarf_addr_offset in read_indexed_address()
1377 || offset > file->dwarf_addr_size in read_indexed_address()
1378 || file->dwarf_addr_size - offset < unit->offset_size) in read_indexed_address()
1381 info_ptr = file->dwarf_addr_buffer + offset; in read_indexed_address()
1383 if (unit->offset_size == 4) in read_indexed_address()
1384 return bfd_get_32 (unit->abfd, info_ptr); in read_indexed_address()
1385 else if (unit->offset_size == 8) in read_indexed_address()
1386 return bfd_get_64 (unit->abfd, info_ptr); in read_indexed_address()
1396 struct dwarf2_debug *stash = unit->stash; in read_indexed_string()
1397 struct dwarf2_debug_file *file = unit->file; in read_indexed_string()
1405 if (!read_section (unit->abfd, &stash->debug_sections[debug_str], in read_indexed_string()
1406 file->syms, 0, in read_indexed_string()
1407 &file->dwarf_str_buffer, &file->dwarf_str_size)) in read_indexed_string()
1410 if (!read_section (unit->abfd, &stash->debug_sections[debug_str_offsets], in read_indexed_string()
1411 file->syms, 0, in read_indexed_string()
1412 &file->dwarf_str_offsets_buffer, in read_indexed_string()
1413 &file->dwarf_str_offsets_size)) in read_indexed_string()
1416 if (_bfd_mul_overflow (idx, unit->offset_size, &offset)) in read_indexed_string()
1419 offset += unit->dwarf_str_offset; in read_indexed_string()
1420 if (offset < unit->dwarf_str_offset in read_indexed_string()
1421 || offset > file->dwarf_str_offsets_size in read_indexed_string()
1422 || file->dwarf_str_offsets_size - offset < unit->offset_size) in read_indexed_string()
1425 info_ptr = file->dwarf_str_offsets_buffer + offset; in read_indexed_string()
1427 if (unit->offset_size == 4) in read_indexed_string()
1428 str_offset = bfd_get_32 (unit->abfd, info_ptr); in read_indexed_string()
1429 else if (unit->offset_size == 8) in read_indexed_string()
1430 str_offset = bfd_get_64 (unit->abfd, info_ptr); in read_indexed_string()
1434 if (str_offset >= file->dwarf_str_size) in read_indexed_string()
1436 return (const char *) file->dwarf_str_buffer + str_offset; in read_indexed_string()
1451 bfd *abfd = unit->abfd; in read_attribute_value()
1461 attr->form = (enum dwarf_form) form; in read_attribute_value()
1466 attr->u.val = 1; in read_attribute_value()
1471 if (unit->version >= 3) in read_attribute_value()
1473 if (unit->offset_size == 4) in read_attribute_value()
1474 attr->u.val = read_4_bytes (unit->abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1476 attr->u.val = read_8_bytes (unit->abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1481 attr->u.val = read_address (unit, &info_ptr, info_ptr_end); in read_attribute_value()
1485 if (unit->offset_size == 4) in read_attribute_value()
1486 attr->u.val = read_4_bytes (unit->abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1488 attr->u.val = read_8_bytes (unit->abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1492 attr->u.blk = read_blk (abfd, &info_ptr, info_ptr_end, amt); in read_attribute_value()
1493 if (attr->u.blk == NULL) in read_attribute_value()
1498 attr->u.blk = read_blk (abfd, &info_ptr, info_ptr_end, amt); in read_attribute_value()
1499 if (attr->u.blk == NULL) in read_attribute_value()
1505 attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1508 attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1511 if (unit->dwarf_addr_offset != 0) in read_attribute_value()
1512 attr->u.val = read_indexed_address (attr->u.val, unit); in read_attribute_value()
1516 attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1519 attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1520 if (unit->dwarf_addr_offset != 0) in read_attribute_value()
1521 attr->u.val = read_indexed_address (attr->u.val, unit); in read_attribute_value()
1524 attr->u.val = read_3_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1525 if (unit->dwarf_addr_offset != 0) in read_attribute_value()
1526 attr->u.val = read_indexed_address(attr->u.val, unit); in read_attribute_value()
1530 attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1533 attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1534 if (unit->dwarf_addr_offset != 0) in read_attribute_value()
1535 attr->u.val = read_indexed_address (attr->u.val, unit); in read_attribute_value()
1540 attr->u.val = read_8_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1543 attr->u.str = read_string (&info_ptr, info_ptr_end); in read_attribute_value()
1546 attr->u.str = read_indirect_string (unit, &info_ptr, info_ptr_end); in read_attribute_value()
1549 attr->u.str = read_indirect_line_string (unit, &info_ptr, info_ptr_end); in read_attribute_value()
1552 attr->u.str = read_alt_indirect_string (unit, &info_ptr, info_ptr_end); in read_attribute_value()
1555 attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1558 if (unit->dwarf_str_offset != 0) in read_attribute_value()
1559 attr->u.str = (char *) read_indexed_string (attr->u.val, unit); in read_attribute_value()
1561 attr->u.str = NULL; in read_attribute_value()
1564 attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1565 if (unit->dwarf_str_offset != 0) in read_attribute_value()
1566 attr->u.str = (char *) read_indexed_string (attr->u.val, unit); in read_attribute_value()
1568 attr->u.str = NULL; in read_attribute_value()
1571 attr->u.val = read_3_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1572 if (unit->dwarf_str_offset != 0) in read_attribute_value()
1573 attr->u.str = (char *) read_indexed_string (attr->u.val, unit); in read_attribute_value()
1575 attr->u.str = NULL; in read_attribute_value()
1578 attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); in read_attribute_value()
1579 if (unit->dwarf_str_offset != 0) in read_attribute_value()
1580 attr->u.str = (char *) read_indexed_string (attr->u.val, unit); in read_attribute_value()
1582 attr->u.str = NULL; in read_attribute_value()
1585 attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, in read_attribute_value()
1587 if (unit->dwarf_str_offset != 0) in read_attribute_value()
1588 attr->u.str = (char *) read_indexed_string (attr->u.val, unit); in read_attribute_value()
1590 attr->u.str = NULL; in read_attribute_value()
1596 attr->u.blk = read_blk (abfd, &info_ptr, info_ptr_end, amt); in read_attribute_value()
1597 if (attr->u.blk == NULL) in read_attribute_value()
1602 attr->u.blk = read_blk (abfd, &info_ptr, info_ptr_end, amt); in read_attribute_value()
1603 if (attr->u.blk == NULL) in read_attribute_value()
1607 attr->u.sval = _bfd_safe_read_leb128 (abfd, &info_ptr, in read_attribute_value()
1616 attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, in read_attribute_value()
1620 attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, in read_attribute_value()
1622 if (unit->dwarf_addr_offset != 0) in read_attribute_value()
1623 attr->u.val = read_indexed_address (attr->u.val, unit); in read_attribute_value()
1635 attr->form = DW_FORM_sdata; in read_attribute_value()
1636 attr->u.sval = implicit_const; in read_attribute_value()
1641 attr->u.blk = read_blk (abfd, &info_ptr, info_ptr_end, 16); in read_attribute_value()
1642 if (attr->u.blk == NULL) in read_attribute_value()
1664 attr->name = abbrev->name; in read_attribute()
1665 info_ptr = read_attribute_value (attr, abbrev->form, abbrev->implicit_const, in read_attribute()
1817 return (new_line->address > line->address in new_line_sorts_after()
1818 || (new_line->address == line->address in new_line_sorts_after()
1819 && new_line->op_index > line->op_index)); in new_line_sorts_after()
1826 line_info->prev_line always accesses an equal or smaller VMA. */
1839 struct line_sequence* seq = table->sequences; in add_line_info()
1840 struct line_info* info = (struct line_info *) bfd_alloc (table->abfd, amt); in add_line_info()
1846 info->prev_line = NULL; in add_line_info()
1847 info->address = address; in add_line_info()
1848 info->op_index = op_index; in add_line_info()
1849 info->line = line; in add_line_info()
1850 info->column = column; in add_line_info()
1851 info->discriminator = discriminator; in add_line_info()
1852 info->end_sequence = end_sequence; in add_line_info()
1856 info->filename = (char *) bfd_alloc (table->abfd, strlen (filename) + 1); in add_line_info()
1857 if (info->filename == NULL) in add_line_info()
1859 strcpy (info->filename, filename); in add_line_info()
1862 info->filename = NULL; in add_line_info()
1873 Note: table->lcl_head is used to head an *actual* or *possible* in add_line_info()
1874 sub-sequence within the list (such as a...j) that is not directly in add_line_info()
1875 headed by table->last_line in add_line_info()
1880 && seq->last_line->address == address in add_line_info()
1881 && seq->last_line->op_index == op_index in add_line_info()
1882 && seq->last_line->end_sequence == end_sequence) in add_line_info()
1886 if (table->lcl_head == seq->last_line) in add_line_info()
1887 table->lcl_head = info; in add_line_info()
1888 info->prev_line = seq->last_line->prev_line; in add_line_info()
1889 seq->last_line = info; in add_line_info()
1891 else if (!seq || seq->last_line->end_sequence) in add_line_info()
1898 seq->low_pc = address; in add_line_info()
1899 seq->prev_sequence = table->sequences; in add_line_info()
1900 seq->last_line = info; in add_line_info()
1901 table->lcl_head = info; in add_line_info()
1902 table->sequences = seq; in add_line_info()
1903 table->num_sequences++; in add_line_info()
1905 else if (info->end_sequence in add_line_info()
1906 || new_line_sorts_after (info, seq->last_line)) in add_line_info()
1909 info->prev_line = seq->last_line; in add_line_info()
1910 seq->last_line = info; in add_line_info()
1913 if (!table->lcl_head) in add_line_info()
1914 table->lcl_head = info; in add_line_info()
1916 else if (!new_line_sorts_after (info, table->lcl_head) in add_line_info()
1917 && (!table->lcl_head->prev_line in add_line_info()
1918 || new_line_sorts_after (info, table->lcl_head->prev_line))) in add_line_info()
1921 info->prev_line = table->lcl_head->prev_line; in add_line_info()
1922 table->lcl_head->prev_line = info; in add_line_info()
1928 struct line_info* li2 = seq->last_line; /* Always non-NULL. */ in add_line_info()
1929 struct line_info* li1 = li2->prev_line; in add_line_info()
1937 li2 = li1; /* always non-NULL */ in add_line_info()
1938 li1 = li1->prev_line; in add_line_info()
1940 table->lcl_head = li2; in add_line_info()
1941 info->prev_line = table->lcl_head->prev_line; in add_line_info()
1942 table->lcl_head->prev_line = info; in add_line_info()
1943 if (address < seq->low_pc) in add_line_info()
1944 seq->low_pc = address; in add_line_info()
1958 if (table == NULL || file - 1 >= table->num_files) in concat_filename()
1967 filename = table->files[file - 1].name; in concat_filename()
1978 if (table->files[file - 1].dir in concat_filename()
1980 && table->files[file - 1].dir <= table->num_dirs in concat_filename()
1982 && table->dirs != NULL) in concat_filename()
1983 subdir_name = table->dirs[table->files[file - 1].dir - 1]; in concat_filename()
1986 dir_name = table->comp_dir; in concat_filename()
2053 in case of a leaf-to-interior conversion, or expansion of a leaf, it may be
2071 if (trie->num_room_in_leaf > 0) in insert_arange_in_trie()
2076 for (i = 0; i < leaf->num_stored_in_leaf; ++i) in insert_arange_in_trie()
2078 if (leaf->ranges[i].unit == unit in insert_arange_in_trie()
2080 leaf->ranges[i].low_pc, in insert_arange_in_trie()
2081 leaf->ranges[i].high_pc)) in insert_arange_in_trie()
2083 if (low_pc < leaf->ranges[i].low_pc) in insert_arange_in_trie()
2084 leaf->ranges[i].low_pc = low_pc; in insert_arange_in_trie()
2085 if (high_pc > leaf->ranges[i].high_pc) in insert_arange_in_trie()
2086 leaf->ranges[i].high_pc = high_pc; in insert_arange_in_trie()
2091 is_full_leaf = leaf->num_stored_in_leaf == trie->num_room_in_leaf; in insert_arange_in_trie()
2109 for (i = 0; i < leaf->num_stored_in_leaf; ++i) in insert_arange_in_trie()
2112 leaf->ranges[i].unit, leaf->ranges[i].low_pc, in insert_arange_in_trie()
2113 leaf->ranges[i].high_pc)) in insert_arange_in_trie()
2123 unsigned int new_room_in_leaf = trie->num_room_in_leaf * 2; in insert_arange_in_trie()
2126 + ((new_room_in_leaf - TRIE_LEAF_SIZE) in insert_arange_in_trie()
2127 * sizeof (leaf->ranges[0]))); in insert_arange_in_trie()
2129 new_leaf->head.num_room_in_leaf = new_room_in_leaf; in insert_arange_in_trie()
2130 new_leaf->num_stored_in_leaf = leaf->num_stored_in_leaf; in insert_arange_in_trie()
2132 memcpy (new_leaf->ranges, in insert_arange_in_trie()
2133 leaf->ranges, in insert_arange_in_trie()
2134 leaf->num_stored_in_leaf * sizeof (leaf->ranges[0])); in insert_arange_in_trie()
2135 trie = &new_leaf->head; in insert_arange_in_trie()
2142 if (trie->num_room_in_leaf > 0) in insert_arange_in_trie()
2146 unsigned int i = leaf->num_stored_in_leaf++; in insert_arange_in_trie()
2147 leaf->ranges[i].unit = unit; in insert_arange_in_trie()
2148 leaf->ranges[i].low_pc = low_pc; in insert_arange_in_trie()
2149 leaf->ranges[i].high_pc = high_pc; in insert_arange_in_trie()
2162 trie_pc + ((bfd_vma) -1 >> trie_pc_bits); /* Inclusive. */ in insert_arange_in_trie()
2170 from_ch = (clamped_low_pc >> (VMA_BITS - trie_pc_bits - 8)) & 0xff; in insert_arange_in_trie()
2171 to_ch = ((clamped_high_pc - 1) >> (VMA_BITS - trie_pc_bits - 8)) & 0xff; in insert_arange_in_trie()
2175 struct trie_node *child = interior->children[ch]; in insert_arange_in_trie()
2183 bfd_vma bucket = (bfd_vma) ch << (VMA_BITS - trie_pc_bits - 8); in insert_arange_in_trie()
2194 interior->children[ch] = child; in insert_arange_in_trie()
2213 *trie_root = insert_arange_in_trie (unit->file->bfd_ptr, in arange_add()
2225 if (first_arange->high == 0) in arange_add()
2227 first_arange->low = low_pc; in arange_add()
2228 first_arange->high = high_pc; in arange_add()
2236 if (low_pc == arange->high) in arange_add()
2238 arange->high = high_pc; in arange_add()
2241 if (high_pc == arange->low) in arange_add()
2243 arange->low = low_pc; in arange_add()
2246 arange = arange->next; in arange_add()
2252 arange = (struct arange *) bfd_alloc (unit->abfd, sizeof (*arange)); in arange_add()
2255 arange->low = low_pc; in arange_add()
2256 arange->high = high_pc; in arange_add()
2257 arange->next = first_arange->next; in arange_add()
2258 first_arange->next = arange; in arange_add()
2271 if (seq1->low_pc < seq2->low_pc) in compare_sequences()
2272 return -1; in compare_sequences()
2273 if (seq1->low_pc > seq2->low_pc) in compare_sequences()
2278 if (seq1->last_line->address < seq2->last_line->address) in compare_sequences()
2280 if (seq1->last_line->address > seq2->last_line->address) in compare_sequences()
2281 return -1; in compare_sequences()
2283 if (seq1->last_line->op_index < seq2->last_line->op_index) in compare_sequences()
2285 if (seq1->last_line->op_index > seq2->last_line->op_index) in compare_sequences()
2286 return -1; in compare_sequences()
2289 if (seq1->num_lines < seq2->num_lines) in compare_sequences()
2290 return -1; in compare_sequences()
2291 if (seq1->num_lines > seq2->num_lines) in compare_sequences()
2308 if (seq->line_info_lookup != NULL) in build_line_info_table()
2316 for (each_line = seq->last_line; each_line; each_line = each_line->prev_line) in build_line_info_table()
2319 seq->num_lines = num_lines; in build_line_info_table()
2325 line_info_lookup = (struct line_info**) bfd_alloc (table->abfd, amt); in build_line_info_table()
2326 seq->line_info_lookup = line_info_lookup; in build_line_info_table()
2332 for (each_line = seq->last_line; each_line; each_line = each_line->prev_line) in build_line_info_table()
2333 line_info_lookup[--line_index] = each_line; in build_line_info_table()
2348 unsigned int num_sequences = table->num_sequences; in sort_line_sequences()
2356 sequences = (struct line_sequence *) bfd_alloc (table->abfd, amt); in sort_line_sequences()
2361 seq = table->sequences; in sort_line_sequences()
2367 sequences[n].low_pc = seq->low_pc; in sort_line_sequences()
2369 sequences[n].last_line = seq->last_line; in sort_line_sequences()
2372 seq = seq->prev_sequence; in sort_line_sequences()
2379 /* Make the list binary-searchable by trimming overlapping entries in sort_line_sequences()
2382 last_high_pc = sequences[0].last_line->address; in sort_line_sequences()
2383 for (n = 1; n < table->num_sequences; n++) in sort_line_sequences()
2387 if (sequences[n].last_line->address <= last_high_pc) in sort_line_sequences()
2394 last_high_pc = sequences[n].last_line->address; in sort_line_sequences()
2404 table->sequences = sequences; in sort_line_sequences()
2405 table->num_sequences = num_sequences; in sort_line_sequences()
2414 if ((table->num_dirs % DIR_ALLOC_CHUNK) == 0) in line_info_add_include_dir()
2419 amt = table->num_dirs + DIR_ALLOC_CHUNK; in line_info_add_include_dir()
2422 tmp = (char **) bfd_realloc (table->dirs, amt); in line_info_add_include_dir()
2425 table->dirs = tmp; in line_info_add_include_dir()
2428 table->dirs[table->num_dirs++] = cur_dir; in line_info_add_include_dir()
2448 if ((table->num_files % FILE_ALLOC_CHUNK) == 0) in line_info_add_file_name()
2453 amt = table->num_files + FILE_ALLOC_CHUNK; in line_info_add_file_name()
2456 tmp = (struct fileinfo *) bfd_realloc (table->files, amt); in line_info_add_file_name()
2459 table->files = tmp; in line_info_add_file_name()
2462 table->files[table->num_files].name = cur_file; in line_info_add_file_name()
2463 table->files[table->num_files].dir = dir; in line_info_add_file_name()
2464 table->files[table->num_files].time = xtime; in line_info_add_file_name()
2465 table->files[table->num_files].size = size; in line_info_add_file_name()
2466 table->num_files++; in line_info_add_file_name()
2484 bfd *abfd = unit->abfd; in read_formatted_entries()
2508 if (data_count > (bfd_vma) (buf_end - buf)) in read_formatted_entries()
2601 bfd *abfd = unit->abfd; in decode_line_info()
2602 struct dwarf2_debug *stash = unit->stash; in decode_line_info()
2603 struct dwarf2_debug_file *file = unit->file; in decode_line_info()
2607 struct line_head lh; in decode_line_info() local
2614 if (unit->line_offset == 0 && file->line_table) in decode_line_info()
2615 return file->line_table; in decode_line_info()
2617 if (! read_section (abfd, &stash->debug_sections[debug_line], in decode_line_info()
2618 file->syms, unit->line_offset, in decode_line_info()
2619 &file->dwarf_line_buffer, &file->dwarf_line_size)) in decode_line_info()
2622 if (file->dwarf_line_size < 16) in decode_line_info()
2626 (int64_t) file->dwarf_line_size); in decode_line_info()
2630 line_ptr = file->dwarf_line_buffer + unit->line_offset; in decode_line_info()
2631 line_end = file->dwarf_line_buffer + file->dwarf_line_size; in decode_line_info()
2634 lh.total_length = read_4_bytes (abfd, &line_ptr, line_end); in decode_line_info()
2636 if (lh.total_length == 0xffffffff) in decode_line_info()
2638 lh.total_length = read_8_bytes (abfd, &line_ptr, line_end); in decode_line_info()
2641 else if (lh.total_length == 0 && unit->addr_size == 8) in decode_line_info()
2643 /* Handle (non-standard) 64-bit DWARF2 formats. */ in decode_line_info()
2644 lh.total_length = read_4_bytes (abfd, &line_ptr, line_end); in decode_line_info()
2648 if (lh.total_length > (size_t) (line_end - line_ptr)) in decode_line_info()
2651 /* xgettext: c-format */ in decode_line_info()
2654 (uint64_t) lh.total_length, (unsigned long) (line_end - line_ptr)); in decode_line_info()
2659 line_end = line_ptr + lh.total_length; in decode_line_info()
2661 lh.version = read_2_bytes (abfd, &line_ptr, line_end); in decode_line_info()
2662 if (lh.version < 2 || lh.version > 5) in decode_line_info()
2665 (_("DWARF error: unhandled .debug_line version %d"), lh.version); in decode_line_info()
2670 if (line_ptr + offset_size + (lh.version >= 5 ? 8 : (lh.version >= 4 ? 6 : 5)) in decode_line_info()
2679 if (lh.version >= 5) in decode_line_info()
2698 lh.prologue_length = read_4_bytes (abfd, &line_ptr, line_end); in decode_line_info()
2700 lh.prologue_length = read_8_bytes (abfd, &line_ptr, line_end); in decode_line_info()
2702 lh.minimum_instruction_length = read_1_byte (abfd, &line_ptr, line_end); in decode_line_info()
2704 if (lh.version >= 4) in decode_line_info()
2705 lh.maximum_ops_per_insn = read_1_byte (abfd, &line_ptr, line_end); in decode_line_info()
2707 lh.maximum_ops_per_insn = 1; in decode_line_info()
2709 if (lh.maximum_ops_per_insn == 0) in decode_line_info()
2717 lh.default_is_stmt = read_1_byte (abfd, &line_ptr, line_end); in decode_line_info()
2718 lh.line_base = read_1_signed_byte (abfd, &line_ptr, line_end); in decode_line_info()
2719 lh.line_range = read_1_byte (abfd, &line_ptr, line_end); in decode_line_info()
2720 lh.opcode_base = read_1_byte (abfd, &line_ptr, line_end); in decode_line_info()
2722 if (line_ptr + (lh.opcode_base - 1) >= line_end) in decode_line_info()
2729 amt = lh.opcode_base * sizeof (unsigned char); in decode_line_info()
2730 lh.standard_opcode_lengths = (unsigned char *) bfd_alloc (abfd, amt); in decode_line_info()
2732 lh.standard_opcode_lengths[0] = 1; in decode_line_info()
2734 for (i = 1; i < lh.opcode_base; ++i) in decode_line_info()
2735 lh.standard_opcode_lengths[i] = read_1_byte (abfd, &line_ptr, line_end); in decode_line_info()
2741 table->abfd = abfd; in decode_line_info()
2742 table->comp_dir = unit->comp_dir; in decode_line_info()
2744 table->num_files = 0; in decode_line_info()
2745 table->files = NULL; in decode_line_info()
2747 table->num_dirs = 0; in decode_line_info()
2748 table->dirs = NULL; in decode_line_info()
2750 table->num_sequences = 0; in decode_line_info()
2751 table->sequences = NULL; in decode_line_info()
2753 table->lcl_head = NULL; in decode_line_info()
2755 if (lh.version >= 5) in decode_line_info()
2796 char * filename = table->num_files ? concat_filename (table, 1) : NULL; in decode_line_info()
2800 int is_stmt = lh.default_is_stmt; in decode_line_info()
2806 for ia64-Linux). Thus, to determine the low and high in decode_line_info()
2808 bfd_vma low_pc = (bfd_vma) -1; in decode_line_info()
2816 if (op_code >= lh.opcode_base) in decode_line_info()
2819 adj_opcode = op_code - lh.opcode_base; in decode_line_info()
2820 if (lh.line_range == 0) in decode_line_info()
2822 if (lh.maximum_ops_per_insn == 1) in decode_line_info()
2823 address += (adj_opcode / lh.line_range in decode_line_info()
2824 * lh.minimum_instruction_length); in decode_line_info()
2827 address += ((op_index + adj_opcode / lh.line_range) in decode_line_info()
2828 / lh.maximum_ops_per_insn in decode_line_info()
2829 * lh.minimum_instruction_length); in decode_line_info()
2830 op_index = ((op_index + adj_opcode / lh.line_range) in decode_line_info()
2831 % lh.maximum_ops_per_insn); in decode_line_info()
2833 line += lh.line_base + (adj_opcode % lh.line_range); in decode_line_info()
2863 if (!arange_add (unit, &unit->arange, &unit->file->trie_root, in decode_line_info()
2888 line_ptr += exop_len - 1; in decode_line_info()
2910 if (lh.maximum_ops_per_insn == 1) in decode_line_info()
2911 address += (lh.minimum_instruction_length in decode_line_info()
2918 address = ((op_index + adjust) / lh.maximum_ops_per_insn in decode_line_info()
2919 * lh.minimum_instruction_length); in decode_line_info()
2920 op_index = (op_index + adjust) % lh.maximum_ops_per_insn; in decode_line_info()
2949 if (lh.line_range == 0) in decode_line_info()
2951 if (lh.maximum_ops_per_insn == 1) in decode_line_info()
2952 address += (lh.minimum_instruction_length in decode_line_info()
2953 * ((255 - lh.opcode_base) / lh.line_range)); in decode_line_info()
2956 bfd_vma adjust = ((255 - lh.opcode_base) / lh.line_range); in decode_line_info()
2957 address += (lh.minimum_instruction_length in decode_line_info()
2959 / lh.maximum_ops_per_insn)); in decode_line_info()
2960 op_index = (op_index + adjust) % lh.maximum_ops_per_insn; in decode_line_info()
2969 for (i = 0; i < lh.standard_opcode_lengths[op_code]; i++) in decode_line_info()
2979 if (unit->line_offset == 0) in decode_line_info()
2980 file->line_table = table; in decode_line_info()
2985 while (table->sequences != NULL) in decode_line_info()
2987 struct line_sequence* seq = table->sequences; in decode_line_info()
2988 table->sequences = table->sequences->prev_sequence; in decode_line_info()
2991 free (table->files); in decode_line_info()
2992 free (table->dirs); in decode_line_info()
3014 high = table->num_sequences; in lookup_address_in_line_info_table()
3018 seq = &table->sequences[mid]; in lookup_address_in_line_info_table()
3019 if (addr < seq->low_pc) in lookup_address_in_line_info_table()
3021 else if (addr >= seq->last_line->address) in lookup_address_in_line_info_table()
3028 if (!seq || addr < seq->low_pc || addr >= seq->last_line->address) in lookup_address_in_line_info_table()
3036 high = seq->num_lines; in lookup_address_in_line_info_table()
3041 info = seq->line_info_lookup[mid]; in lookup_address_in_line_info_table()
3042 if (addr < info->address) in lookup_address_in_line_info_table()
3044 else if (addr >= seq->line_info_lookup[mid + 1]->address) in lookup_address_in_line_info_table()
3052 && addr >= info->address in lookup_address_in_line_info_table()
3053 && addr < seq->line_info_lookup[mid + 1]->address in lookup_address_in_line_info_table()
3054 && !(info->end_sequence || info == seq->last_line)) in lookup_address_in_line_info_table()
3056 *filename_ptr = info->filename; in lookup_address_in_line_info_table()
3057 *linenumber_ptr = info->line; in lookup_address_in_line_info_table()
3059 *discriminator_ptr = info->discriminator; in lookup_address_in_line_info_table()
3073 struct dwarf2_debug *stash = unit->stash; in read_debug_ranges()
3074 struct dwarf2_debug_file *file = unit->file; in read_debug_ranges()
3076 return read_section (unit->abfd, &stash->debug_sections[debug_ranges], in read_debug_ranges()
3077 file->syms, 0, in read_debug_ranges()
3078 &file->dwarf_ranges_buffer, &file->dwarf_ranges_size); in read_debug_ranges()
3086 struct dwarf2_debug *stash = unit->stash; in read_debug_rnglists()
3087 struct dwarf2_debug_file *file = unit->file; in read_debug_rnglists()
3089 return read_section (unit->abfd, &stash->debug_sections[debug_rnglists], in read_debug_rnglists()
3090 file->syms, 0, in read_debug_rnglists()
3091 &file->dwarf_rnglists_buffer, &file->dwarf_rnglists_size); in read_debug_rnglists()
3102 if (lookup1->low_addr < lookup2->low_addr) in compare_lookup_funcinfos()
3103 return -1; in compare_lookup_funcinfos()
3104 if (lookup1->low_addr > lookup2->low_addr) in compare_lookup_funcinfos()
3106 if (lookup1->high_addr < lookup2->high_addr) in compare_lookup_funcinfos()
3107 return -1; in compare_lookup_funcinfos()
3108 if (lookup1->high_addr > lookup2->high_addr) in compare_lookup_funcinfos()
3111 if (lookup1->idx < lookup2->idx) in compare_lookup_funcinfos()
3112 return -1; in compare_lookup_funcinfos()
3113 if (lookup1->idx > lookup2->idx) in compare_lookup_funcinfos()
3121 struct lookup_funcinfo *lookup_funcinfo_table = unit->lookup_funcinfo_table; in build_lookup_funcinfo_table()
3122 unsigned int number_of_functions = unit->number_of_functions; in build_lookup_funcinfo_table()
3140 for (each = unit->function_table; each; each = each->prev_func) in build_lookup_funcinfo_table()
3142 entry = &lookup_funcinfo_table[--func_index]; in build_lookup_funcinfo_table()
3143 entry->funcinfo = each; in build_lookup_funcinfo_table()
3144 entry->idx = func_index; in build_lookup_funcinfo_table()
3147 low_addr = entry->funcinfo->arange.low; in build_lookup_funcinfo_table()
3148 high_addr = entry->funcinfo->arange.high; in build_lookup_funcinfo_table()
3150 for (range = entry->funcinfo->arange.next; range; range = range->next) in build_lookup_funcinfo_table()
3152 if (range->low < low_addr) in build_lookup_funcinfo_table()
3153 low_addr = range->low; in build_lookup_funcinfo_table()
3154 if (range->high > high_addr) in build_lookup_funcinfo_table()
3155 high_addr = range->high; in build_lookup_funcinfo_table()
3158 entry->low_addr = low_addr; in build_lookup_funcinfo_table()
3159 entry->high_addr = high_addr; in build_lookup_funcinfo_table()
3175 if (entry->high_addr > high_addr) in build_lookup_funcinfo_table()
3176 high_addr = entry->high_addr; in build_lookup_funcinfo_table()
3178 entry->high_addr = high_addr; in build_lookup_funcinfo_table()
3181 unit->lookup_funcinfo_table = lookup_funcinfo_table; in build_lookup_funcinfo_table()
3195 unsigned int number_of_functions = unit->number_of_functions; in lookup_address_in_function_table()
3209 if (unit->lookup_funcinfo_table[number_of_functions - 1].high_addr < addr) in lookup_address_in_function_table()
3220 lookup_funcinfo = &unit->lookup_funcinfo_table[mid]; in lookup_address_in_function_table()
3221 if (addr < lookup_funcinfo->low_addr) in lookup_address_in_function_table()
3223 else if (addr >= lookup_funcinfo->high_addr) in lookup_address_in_function_table()
3236 if (addr < unit->lookup_funcinfo_table[first].low_addr) in lookup_address_in_function_table()
3238 funcinfo = unit->lookup_funcinfo_table[first].funcinfo; in lookup_address_in_function_table()
3240 for (arange = &funcinfo->arange; arange; arange = arange->next) in lookup_address_in_function_table()
3242 if (addr < arange->low || addr >= arange->high) in lookup_address_in_function_table()
3246 || arange->high - arange->low < best_fit_len in lookup_address_in_function_table()
3250 || (arange->high - arange->low == best_fit_len in lookup_address_in_function_table()
3254 best_fit_len = arange->high - arange->low; in lookup_address_in_function_table()
3285 for (each_func = unit->function_table; in lookup_symbol_in_function_table()
3287 each_func = each_func->prev_func) in lookup_symbol_in_function_table()
3289 for (arange = &each_func->arange; in lookup_symbol_in_function_table()
3291 arange = arange->next) in lookup_symbol_in_function_table()
3293 if ((!each_func->sec || each_func->sec == sec) in lookup_symbol_in_function_table()
3294 && addr >= arange->low in lookup_symbol_in_function_table()
3295 && addr < arange->high in lookup_symbol_in_function_table()
3296 && each_func->name in lookup_symbol_in_function_table()
3297 && strcmp (name, each_func->name) == 0 in lookup_symbol_in_function_table()
3299 || arange->high - arange->low < best_fit_len)) in lookup_symbol_in_function_table()
3302 best_fit_len = arange->high - arange->low; in lookup_symbol_in_function_table()
3309 best_fit->sec = sec; in lookup_symbol_in_function_table()
3310 *filename_ptr = best_fit->file; in lookup_symbol_in_function_table()
3311 *linenumber_ptr = best_fit->line; in lookup_symbol_in_function_table()
3334 for (each = unit->variable_table; each; each = each->prev_var) in lookup_symbol_in_variable_table()
3335 if (! each->stack in lookup_symbol_in_variable_table()
3336 && each->file != NULL in lookup_symbol_in_variable_table()
3337 && each->name != NULL in lookup_symbol_in_variable_table()
3338 && each->addr == addr in lookup_symbol_in_variable_table()
3339 && (!each->sec || each->sec == sec) in lookup_symbol_in_variable_table()
3340 && strcmp (name, each->name) == 0) in lookup_symbol_in_variable_table()
3345 each->sec = sec; in lookup_symbol_in_variable_table()
3346 *filename_ptr = each->file; in lookup_symbol_in_variable_table()
3347 *linenumber_ptr = each->line; in lookup_symbol_in_variable_table()
3367 bfd *abfd = unit->abfd; in find_abstract_instance()
3372 uint64_t die_ref = attr_ptr->u.val; in find_abstract_instance()
3386 if (attr_ptr->form == DW_FORM_ref_addr) in find_abstract_instance()
3400 sections at non-zero VMAs (see place_sections), and read in find_abstract_instance()
3405 info_ptr = unit->file->dwarf_info_buffer; in find_abstract_instance()
3406 info_ptr_end = info_ptr + unit->file->dwarf_info_size; in find_abstract_instance()
3407 total = info_ptr_end - info_ptr; in find_abstract_instance()
3419 else if (attr_ptr->form == DW_FORM_GNU_ref_alt) in find_abstract_instance()
3421 bool first_time = unit->stash->alt.dwarf_info_buffer == NULL; in find_abstract_instance()
3425 unit->stash->alt.info_ptr = unit->stash->alt.dwarf_info_buffer; in find_abstract_instance()
3434 info_ptr_end = (unit->stash->alt.dwarf_info_buffer in find_abstract_instance()
3435 + unit->stash->alt.dwarf_info_size); in find_abstract_instance()
3436 if (unit->stash->alt.all_comp_units) in find_abstract_instance()
3437 unit = unit->stash->alt.all_comp_units; in find_abstract_instance()
3440 if (attr_ptr->form == DW_FORM_ref_addr in find_abstract_instance()
3441 || attr_ptr->form == DW_FORM_GNU_ref_alt) in find_abstract_instance()
3444 if (info_ptr >= unit->info_ptr_unit && info_ptr < unit->end_ptr) in find_abstract_instance()
3445 info_ptr_end = unit->end_ptr; in find_abstract_instance()
3451 for (u = unit->prev_unit; u != NULL; u = u->prev_unit) in find_abstract_instance()
3452 if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) in find_abstract_instance()
3456 for (u = unit->next_unit; u != NULL; u = u->next_unit) in find_abstract_instance()
3457 if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) in find_abstract_instance()
3460 if (attr_ptr->form == DW_FORM_ref_addr) in find_abstract_instance()
3463 u = stash_comp_unit (unit->stash, &unit->stash->f); in find_abstract_instance()
3466 if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) in find_abstract_instance()
3471 if (attr_ptr->form == DW_FORM_GNU_ref_alt) in find_abstract_instance()
3474 u = stash_comp_unit (unit->stash, &unit->stash->alt); in find_abstract_instance()
3477 if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) in find_abstract_instance()
3491 info_ptr_end = unit->end_ptr; in find_abstract_instance()
3501 info_ptr = unit->info_ptr_unit; in find_abstract_instance()
3502 info_ptr_end = unit->end_ptr; in find_abstract_instance()
3503 total = info_ptr_end - info_ptr; in find_abstract_instance()
3518 abbrev = lookup_abbrev (abbrev_number, unit->abbrevs); in find_abstract_instance()
3528 for (i = 0; i < abbrev->num_attrs; ++i) in find_abstract_instance()
3530 info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, in find_abstract_instance()
3542 if (non_mangled (unit->lang)) in find_abstract_instance()
3556 non-string forms into these attributes. */ in find_abstract_instance()
3567 *filename_ptr = concat_filename (unit->line_table, in find_abstract_instance()
3590 bfd_vma base_address = unit->base_address; in read_ranges()
3592 if (! unit->file->dwarf_ranges_buffer) in read_ranges()
3598 if (offset > unit->file->dwarf_ranges_size) in read_ranges()
3600 ranges_ptr = unit->file->dwarf_ranges_buffer + offset; in read_ranges()
3601 ranges_end = unit->file->dwarf_ranges_buffer + unit->file->dwarf_ranges_size; in read_ranges()
3609 if (2u * unit->addr_size > (size_t) (ranges_end - ranges_ptr)) in read_ranges()
3617 if (low_pc == -1UL && high_pc != -1UL) in read_ranges()
3635 bfd_vma base_address = unit->base_address; in read_rnglists()
3638 bfd *abfd = unit->abfd; in read_rnglists()
3640 if (! unit->file->dwarf_rnglists_buffer) in read_rnglists()
3646 rngs_ptr = unit->file->dwarf_rnglists_buffer + offset; in read_rnglists()
3647 if (rngs_ptr < unit->file->dwarf_rnglists_buffer) in read_rnglists()
3649 rngs_end = unit->file->dwarf_rnglists_buffer; in read_rnglists()
3650 rngs_end += unit->file->dwarf_rnglists_size; in read_rnglists()
3667 if (unit->addr_size > (size_t) (rngs_end - rngs_ptr)) in read_rnglists()
3673 if (unit->addr_size > (size_t) (rngs_end - rngs_ptr)) in read_rnglists()
3691 if (2u * unit->addr_size > (size_t) (rngs_end - rngs_ptr)) in read_rnglists()
3697 /* TODO x-variants need .debug_addr support used for split-dwarf. */ in read_rnglists()
3714 if (unit->version <= 4) in read_rangelist()
3723 for (; table != NULL; table = table->prev_func) in lookup_func_by_offset()
3724 if (table->unit_offset == offset) in lookup_func_by_offset()
3734 if (table->unit_offset == offset) in lookup_var_by_offset()
3736 table = table->prev_var; in lookup_var_by_offset()
3753 temp = head->prev_func; in reverse_funcinfo_list()
3754 head->prev_func = rhead; in reverse_funcinfo_list()
3768 temp = head->prev_var; in reverse_varinfo_list()
3769 head->prev_var = rhead; in reverse_varinfo_list()
3781 bfd *abfd = unit->abfd; in scan_unit_for_symbols()
3782 bfd_byte *info_ptr = unit->first_child_die_ptr; in scan_unit_for_symbols()
3783 bfd_byte *info_ptr_end = unit->end_ptr; in scan_unit_for_symbols()
3793 /* Maintain a stack of in-scope functions and inlined functions, which we in scan_unit_for_symbols()
3818 current_offset = info_ptr - unit->info_ptr_unit; in scan_unit_for_symbols()
3823 nesting_level--; in scan_unit_for_symbols()
3827 abbrev = lookup_abbrev (abbrev_number, unit->abbrevs); in scan_unit_for_symbols()
3830 static unsigned int previous_failed_abbrev = -1U; in scan_unit_for_symbols()
3844 if (abbrev->tag == DW_TAG_subprogram in scan_unit_for_symbols()
3845 || abbrev->tag == DW_TAG_entry_point in scan_unit_for_symbols()
3846 || abbrev->tag == DW_TAG_inlined_subroutine) in scan_unit_for_symbols()
3854 func->tag = abbrev->tag; in scan_unit_for_symbols()
3855 func->prev_func = unit->function_table; in scan_unit_for_symbols()
3856 func->unit_offset = current_offset; in scan_unit_for_symbols()
3857 unit->function_table = func; in scan_unit_for_symbols()
3858 unit->number_of_functions++; in scan_unit_for_symbols()
3859 BFD_ASSERT (!unit->cached); in scan_unit_for_symbols()
3861 if (func->tag == DW_TAG_inlined_subroutine) in scan_unit_for_symbols()
3862 for (i = nesting_level; i-- != 0; ) in scan_unit_for_symbols()
3865 func->caller_func = nested_funcs[i].func; in scan_unit_for_symbols()
3873 if (abbrev->tag == DW_TAG_variable in scan_unit_for_symbols()
3874 || abbrev->tag == DW_TAG_member) in scan_unit_for_symbols()
3881 var->tag = abbrev->tag; in scan_unit_for_symbols()
3882 var->stack = true; in scan_unit_for_symbols()
3883 var->prev_var = unit->variable_table; in scan_unit_for_symbols()
3884 unit->variable_table = var; in scan_unit_for_symbols()
3885 var->unit_offset = current_offset; in scan_unit_for_symbols()
3896 for (i = 0; i < abbrev->num_attrs; ++i) in scan_unit_for_symbols()
3900 info_ptr = read_attribute (&attr, &abbrev->attrs[i], in scan_unit_for_symbols()
3906 if (abbrev->has_children) in scan_unit_for_symbols()
3926 unit->function_table = reverse_funcinfo_list (unit->function_table); in scan_unit_for_symbols()
3927 unit->variable_table = reverse_varinfo_list (unit->variable_table); in scan_unit_for_symbols()
3930 info_ptr = unit->first_child_die_ptr; in scan_unit_for_symbols()
3952 current_offset = info_ptr - unit->info_ptr_unit; in scan_unit_for_symbols()
3957 nesting_level--; in scan_unit_for_symbols()
3961 abbrev = lookup_abbrev (abbrev_number, unit->abbrevs); in scan_unit_for_symbols()
3967 if (abbrev->tag == DW_TAG_subprogram in scan_unit_for_symbols()
3968 || abbrev->tag == DW_TAG_entry_point in scan_unit_for_symbols()
3969 || abbrev->tag == DW_TAG_inlined_subroutine) in scan_unit_for_symbols()
3972 && last_func->prev_func in scan_unit_for_symbols()
3973 && last_func->prev_func->unit_offset == current_offset) in scan_unit_for_symbols()
3974 func = last_func->prev_func; in scan_unit_for_symbols()
3976 func = lookup_func_by_offset (current_offset, unit->function_table); in scan_unit_for_symbols()
3983 else if (abbrev->tag == DW_TAG_variable in scan_unit_for_symbols()
3984 || abbrev->tag == DW_TAG_member) in scan_unit_for_symbols()
3987 && last_var->prev_var in scan_unit_for_symbols()
3988 && last_var->prev_var->unit_offset == current_offset) in scan_unit_for_symbols()
3989 var = last_var->prev_var; in scan_unit_for_symbols()
3991 var = lookup_var_by_offset (current_offset, unit->variable_table); in scan_unit_for_symbols()
3999 for (i = 0; i < abbrev->num_attrs; ++i) in scan_unit_for_symbols()
4001 info_ptr = read_attribute (&attr, &abbrev->attrs[i], in scan_unit_for_symbols()
4012 func->caller_file = concat_filename (unit->line_table, in scan_unit_for_symbols()
4018 func->caller_line = attr.u.val; in scan_unit_for_symbols()
4025 &func->name, in scan_unit_for_symbols()
4026 &func->is_linkage, in scan_unit_for_symbols()
4027 &func->file, in scan_unit_for_symbols()
4028 &func->line)) in scan_unit_for_symbols()
4035 if (func->name == NULL && is_str_form (&attr)) in scan_unit_for_symbols()
4037 func->name = attr.u.str; in scan_unit_for_symbols()
4038 if (non_mangled (unit->lang)) in scan_unit_for_symbols()
4039 func->is_linkage = true; in scan_unit_for_symbols()
4046 non-string forms into these attributes. */ in scan_unit_for_symbols()
4049 func->name = attr.u.str; in scan_unit_for_symbols()
4050 func->is_linkage = true; in scan_unit_for_symbols()
4069 && !read_rangelist (unit, &func->arange, in scan_unit_for_symbols()
4070 &unit->file->trie_root, attr.u.val)) in scan_unit_for_symbols()
4076 func->file = concat_filename (unit->line_table, in scan_unit_for_symbols()
4082 func->line = attr.u.val; in scan_unit_for_symbols()
4099 unit->variable_table); in scan_unit_for_symbols()
4109 if (var->name == NULL) in scan_unit_for_symbols()
4110 var->name = spec_var->name; in scan_unit_for_symbols()
4111 if (var->file == NULL && spec_var->file != NULL) in scan_unit_for_symbols()
4112 var->file = strdup (spec_var->file); in scan_unit_for_symbols()
4113 if (var->line == 0) in scan_unit_for_symbols()
4114 var->line = spec_var->line; in scan_unit_for_symbols()
4115 if (var->sec == NULL) in scan_unit_for_symbols()
4116 var->sec = spec_var->sec; in scan_unit_for_symbols()
4122 var->name = attr.u.str; in scan_unit_for_symbols()
4127 var->file = concat_filename (unit->line_table, in scan_unit_for_symbols()
4133 var->line = attr.u.val; in scan_unit_for_symbols()
4138 var->stack = false; in scan_unit_for_symbols()
4149 if (attr.u.blk->data != NULL in scan_unit_for_symbols()
4150 && *attr.u.blk->data == DW_OP_addr) in scan_unit_for_symbols()
4152 var->stack = false; in scan_unit_for_symbols()
4160 if (attr.u.blk->size == unit->addr_size + 1U) in scan_unit_for_symbols()
4161 var->addr = bfd_get (unit->addr_size * 8, in scan_unit_for_symbols()
4162 unit->abfd, in scan_unit_for_symbols()
4163 attr.u.blk->data + 1); in scan_unit_for_symbols()
4178 if (abbrev->has_children) in scan_unit_for_symbols()
4186 if (!arange_add (unit, &func->arange, &unit->file->trie_root, in scan_unit_for_symbols()
4192 unit->function_table = reverse_funcinfo_list (unit->function_table); in scan_unit_for_symbols()
4193 unit->variable_table = reverse_varinfo_list (unit->variable_table); in scan_unit_for_symbols()
4213 if (is_strx_form (attr->form)) in reread_attribute()
4214 attr->u.str = (char *) read_indexed_string (attr->u.val, unit); in reread_attribute()
4215 if (is_addrx_form (attr->form)) in reread_attribute()
4216 attr->u.val = read_indexed_address (attr->u.val, unit); in reread_attribute()
4218 switch (attr->name) in reread_attribute()
4221 unit->stmtlist = 1; in reread_attribute()
4222 unit->line_offset = attr->u.val; in reread_attribute()
4227 unit->name = attr->u.str; in reread_attribute()
4231 *low_pc = attr->u.val; in reread_attribute()
4233 unit->base_address = *low_pc; in reread_attribute()
4237 *high_pc = attr->u.val; in reread_attribute()
4238 *high_pc_relative = attr->form != DW_FORM_addr; in reread_attribute()
4242 if (!read_rangelist (unit, &unit->arange, in reread_attribute()
4243 &unit->file->trie_root, attr->u.val)) in reread_attribute()
4249 char *comp_dir = attr->u.str; in reread_attribute()
4255 "with a non-string form")); in reread_attribute()
4263 if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/') in reread_attribute()
4266 unit->comp_dir = comp_dir; in reread_attribute()
4271 unit->lang = attr->u.val; in reread_attribute()
4298 unsigned int addr_size = -1; in parse_comp_unit()
4307 bfd *abfd = file->bfd_ptr; in parse_comp_unit()
4361 /* xgettext: c-format */ in parse_comp_unit()
4408 unit->abfd = abfd; in parse_comp_unit()
4409 unit->version = version; in parse_comp_unit()
4410 unit->addr_size = addr_size; in parse_comp_unit()
4411 unit->offset_size = offset_size; in parse_comp_unit()
4412 unit->abbrevs = abbrevs; in parse_comp_unit()
4413 unit->end_ptr = end_ptr; in parse_comp_unit()
4414 unit->stash = stash; in parse_comp_unit()
4415 unit->file = file; in parse_comp_unit()
4416 unit->info_ptr_unit = info_ptr_unit; in parse_comp_unit()
4418 if (abbrev->tag == DW_TAG_compile_unit) in parse_comp_unit()
4421 for (i = 0; i < abbrev->num_attrs; ++i) in parse_comp_unit()
4423 info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr, end_ptr); in parse_comp_unit()
4430 if ((unit->dwarf_str_offset == 0 && is_strx_form (attr.form)) in parse_comp_unit()
4431 || (unit->dwarf_addr_offset == 0 && is_addrx_form (attr.form))) in parse_comp_unit()
4453 unit->stmtlist = 1; in parse_comp_unit()
4454 unit->line_offset = attr.u.val; in parse_comp_unit()
4460 unit->name = attr.u.str; in parse_comp_unit()
4471 unit->base_address = low_pc; in parse_comp_unit()
4485 && !read_rangelist (unit, &unit->arange, in parse_comp_unit()
4486 &unit->file->trie_root, attr.u.val)) in parse_comp_unit()
4498 (_("DWARF error: DW_AT_comp_dir attribute encountered with a non-string form")); in parse_comp_unit()
4508 if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/') in parse_comp_unit()
4511 unit->comp_dir = comp_dir; in parse_comp_unit()
4517 unit->lang = attr.u.val; in parse_comp_unit()
4521 unit->dwarf_addr_offset = attr.u.val; in parse_comp_unit()
4525 unit->dwarf_str_offset = attr.u.val; in parse_comp_unit()
4541 if (!arange_add (unit, &unit->arange, &unit->file->trie_root, in parse_comp_unit()
4546 unit->first_child_die_ptr = info_ptr; in parse_comp_unit()
4552 unit->error = 1; in parse_comp_unit()
4568 if (unit->error) in comp_unit_contains_address()
4571 arange = &unit->arange; in comp_unit_contains_address()
4574 if (addr >= arange->low && addr < arange->high) in comp_unit_contains_address()
4576 arange = arange->next; in comp_unit_contains_address()
4603 if (func_p && (*function_ptr)->tag == DW_TAG_inlined_subroutine) in comp_unit_find_nearest_line()
4604 unit->stash->inliner_chain = *function_ptr; in comp_unit_find_nearest_line()
4606 line_p = lookup_address_in_line_info_table (unit->line_table, addr, in comp_unit_find_nearest_line()
4620 if (unit->error) in comp_unit_maybe_decode_line_info()
4623 if (! unit->line_table) in comp_unit_maybe_decode_line_info()
4625 if (! unit->stmtlist) in comp_unit_maybe_decode_line_info()
4627 unit->error = 1; in comp_unit_maybe_decode_line_info()
4631 unit->line_table = decode_line_info (unit); in comp_unit_maybe_decode_line_info()
4633 if (! unit->line_table) in comp_unit_maybe_decode_line_info()
4635 unit->error = 1; in comp_unit_maybe_decode_line_info()
4639 if (unit->first_child_die_ptr < unit->end_ptr in comp_unit_maybe_decode_line_info()
4642 unit->error = 1; in comp_unit_maybe_decode_line_info()
4668 if (sym->flags & BSF_FUNCTION) in comp_unit_find_line()
4692 BFD_ASSERT (stash->info_hash_status != STASH_INFO_HASH_DISABLED); in comp_unit_hash_info()
4697 BFD_ASSERT (!unit->cached); in comp_unit_hash_info()
4701 bi-directional use quite a bit of extra memory. So we reverse in comp_unit_hash_info()
4704 unit->function_table = reverse_funcinfo_list (unit->function_table); in comp_unit_hash_info()
4705 for (each_func = unit->function_table; in comp_unit_hash_info()
4707 each_func = each_func->prev_func) in comp_unit_hash_info()
4710 if (each_func->name) in comp_unit_hash_info()
4714 okay = insert_info_hash_table (funcinfo_hash_table, each_func->name, in comp_unit_hash_info()
4717 unit->function_table = reverse_funcinfo_list (unit->function_table); in comp_unit_hash_info()
4722 unit->variable_table = reverse_varinfo_list (unit->variable_table); in comp_unit_hash_info()
4723 for (each_var = unit->variable_table; in comp_unit_hash_info()
4725 each_var = each_var->prev_var) in comp_unit_hash_info()
4728 if (! each_var->stack in comp_unit_hash_info()
4729 && each_var->file != NULL in comp_unit_hash_info()
4730 && each_var->name != NULL) in comp_unit_hash_info()
4734 okay = insert_info_hash_table (varinfo_hash_table, each_var->name, in comp_unit_hash_info()
4738 unit->variable_table = reverse_varinfo_list (unit->variable_table); in comp_unit_hash_info()
4739 unit->cached = true; in comp_unit_hash_info()
4774 for (msec = abfd->sections; msec != NULL; msec = msec->next) in find_debug_info()
4775 if (startswith (msec->name, GNU_LINKONCE_INFO)) in find_debug_info()
4781 for (msec = after_sec->next; msec != NULL; msec = msec->next) in find_debug_info()
4784 if (strcmp (msec->name, look) == 0) in find_debug_info()
4788 if (look != NULL && strcmp (msec->name, look) == 0) in find_debug_info()
4791 if (startswith (msec->name, GNU_LINKONCE_INFO)) in find_debug_info()
4805 for (s = orig_bfd->sections, d = debug_bfd->sections; in set_debug_vma()
4807 s = s->next, d = d->next) in set_debug_vma()
4809 if ((d->flags & SEC_DEBUGGING) != 0) in set_debug_vma()
4811 /* ??? Assumes 1-1 correspondence between sections in the in set_debug_vma()
4813 if (strcmp (s->name, d->name) == 0) in set_debug_vma()
4815 d->output_section = s->output_section; in set_debug_vma()
4816 d->output_offset = s->output_offset; in set_debug_vma()
4817 d->vma = s->vma; in set_debug_vma()
4830 if (stash->f.bfd_ptr != abfd) in _bfd_dwarf2_stash_syms()
4836 *syms = stash->f.syms; in _bfd_dwarf2_stash_syms()
4840 for (s = abfd->sections, d = stash->f.bfd_ptr->sections; in _bfd_dwarf2_stash_syms()
4842 s = s->next, d = d->next) in _bfd_dwarf2_stash_syms()
4844 if ((d->flags & SEC_DEBUGGING) != 0) in _bfd_dwarf2_stash_syms()
4847 && strcmp (s->name, d->name) == 0) in _bfd_dwarf2_stash_syms()
4850 *syms = stash->f.syms; in _bfd_dwarf2_stash_syms()
4865 i = stash->adjusted_section_count; in unset_sections()
4866 p = stash->adjusted_sections; in unset_sections()
4867 for (; i > 0; i--, p++) in unset_sections()
4868 p->section->vma = 0; in unset_sections()
4889 if (stash->adjusted_section_count != 0) in place_sections()
4891 i = stash->adjusted_section_count; in place_sections()
4892 p = stash->adjusted_sections; in place_sections()
4893 for (; i > 0; i--, p++) in place_sections()
4894 p->section->vma = p->adj_vma; in place_sections()
4898 debug_info_name = stash->debug_sections[debug_info].uncompressed_name; in place_sections()
4905 for (sect = abfd->sections; sect != NULL; sect = sect->next) in place_sections()
4909 if ((sect->output_section != NULL in place_sections()
4910 && sect->output_section != sect in place_sections()
4911 && (sect->flags & SEC_DEBUGGING) == 0) in place_sections()
4912 || sect->vma != 0) in place_sections()
4915 is_debug_info = (strcmp (sect->name, debug_info_name) == 0 in place_sections()
4916 || startswith (sect->name, GNU_LINKONCE_INFO)); in place_sections()
4918 if (!((sect->flags & SEC_ALLOC) != 0 && abfd == orig_bfd) in place_sections()
4924 if (abfd == stash->f.bfd_ptr) in place_sections()
4926 abfd = stash->f.bfd_ptr; in place_sections()
4930 stash->adjusted_section_count = -1; in place_sections()
4940 stash->adjusted_sections = p; in place_sections()
4941 stash->adjusted_section_count = i; in place_sections()
4948 for (sect = abfd->sections; sect != NULL; sect = sect->next) in place_sections()
4953 if ((sect->output_section != NULL in place_sections()
4954 && sect->output_section != sect in place_sections()
4955 && (sect->flags & SEC_DEBUGGING) == 0) in place_sections()
4956 || sect->vma != 0) in place_sections()
4959 is_debug_info = (strcmp (sect->name, debug_info_name) == 0 in place_sections()
4960 || startswith (sect->name, GNU_LINKONCE_INFO)); in place_sections()
4962 if (!((sect->flags & SEC_ALLOC) != 0 && abfd == orig_bfd) in place_sections()
4966 sz = sect->rawsize ? sect->rawsize : sect->size; in place_sections()
4970 BFD_ASSERT (sect->alignment_power == 0); in place_sections()
4971 sect->vma = last_dwarf; in place_sections()
4979 + ~(-((bfd_vma) 1 << sect->alignment_power))) in place_sections()
4980 & (-((bfd_vma) 1 << sect->alignment_power))); in place_sections()
4981 sect->vma = last_vma; in place_sections()
4985 p->section = sect; in place_sections()
4986 p->adj_vma = sect->vma; in place_sections()
4989 if (abfd == stash->f.bfd_ptr) in place_sections()
4991 abfd = stash->f.bfd_ptr; in place_sections()
4995 if (orig_bfd != stash->f.bfd_ptr) in place_sections()
4996 set_debug_vma (orig_bfd, stash->f.bfd_ptr); in place_sections()
5024 node = node->next) in info_hash_lookup_funcinfo()
5026 each_func = (struct funcinfo *) node->info; in info_hash_lookup_funcinfo()
5027 for (arange = &each_func->arange; in info_hash_lookup_funcinfo()
5029 arange = arange->next) in info_hash_lookup_funcinfo()
5031 if ((!each_func->sec || each_func->sec == sec) in info_hash_lookup_funcinfo()
5032 && addr >= arange->low in info_hash_lookup_funcinfo()
5033 && addr < arange->high in info_hash_lookup_funcinfo()
5035 || arange->high - arange->low < best_fit_len)) in info_hash_lookup_funcinfo()
5038 best_fit_len = arange->high - arange->low; in info_hash_lookup_funcinfo()
5045 best_fit->sec = sec; in info_hash_lookup_funcinfo()
5046 *filename_ptr = best_fit->file; in info_hash_lookup_funcinfo()
5047 *linenumber_ptr = best_fit->line; in info_hash_lookup_funcinfo()
5074 node = node->next) in info_hash_lookup_varinfo()
5076 each = (struct varinfo *) node->info; in info_hash_lookup_varinfo()
5077 if (each->addr == addr in info_hash_lookup_varinfo()
5078 && (!each->sec || each->sec == sec)) in info_hash_lookup_varinfo()
5080 each->sec = sec; in info_hash_lookup_varinfo()
5081 *filename_ptr = each->file; in info_hash_lookup_varinfo()
5082 *linenumber_ptr = each->line; in info_hash_lookup_varinfo()
5099 /* Exit if hash tables are up-to-date. */ in stash_maybe_update_info_hash_tables()
5100 if (stash->f.all_comp_units == stash->hash_units_head) in stash_maybe_update_info_hash_tables()
5103 if (stash->hash_units_head) in stash_maybe_update_info_hash_tables()
5104 each = stash->hash_units_head->prev_unit; in stash_maybe_update_info_hash_tables()
5106 each = stash->f.last_comp_unit; in stash_maybe_update_info_hash_tables()
5110 if (!comp_unit_hash_info (stash, each, stash->funcinfo_hash_table, in stash_maybe_update_info_hash_tables()
5111 stash->varinfo_hash_table)) in stash_maybe_update_info_hash_tables()
5113 stash->info_hash_status = STASH_INFO_HASH_DISABLED; in stash_maybe_update_info_hash_tables()
5116 each = each->prev_unit; in stash_maybe_update_info_hash_tables()
5119 stash->hash_units_head = stash->f.all_comp_units; in stash_maybe_update_info_hash_tables()
5134 for (each_unit = stash->f.all_comp_units; in stash_verify_info_hash_table()
5136 each_unit = each_unit->next_unit) in stash_verify_info_hash_table()
5138 for (each_func = each_unit->function_table; in stash_verify_info_hash_table()
5140 each_func = each_func->prev_func) in stash_verify_info_hash_table()
5142 if (!each_func->name) in stash_verify_info_hash_table()
5144 node = lookup_info_hash_table (stash->funcinfo_hash_table, in stash_verify_info_hash_table()
5145 each_func->name); in stash_verify_info_hash_table()
5150 found = node->info == each_func; in stash_verify_info_hash_table()
5151 node = node->next; in stash_verify_info_hash_table()
5156 for (each_var = each_unit->variable_table; in stash_verify_info_hash_table()
5158 each_var = each_var->prev_var) in stash_verify_info_hash_table()
5160 if (!each_var->name || !each_var->file || each_var->stack) in stash_verify_info_hash_table()
5162 node = lookup_info_hash_table (stash->varinfo_hash_table, in stash_verify_info_hash_table()
5163 each_var->name); in stash_verify_info_hash_table()
5168 found = node->info == each_var; in stash_verify_info_hash_table()
5169 node = node->next; in stash_verify_info_hash_table()
5184 BFD_ASSERT (stash->info_hash_status == STASH_INFO_HASH_OFF); in stash_maybe_enable_info_hash_tables()
5186 if (stash->info_hash_count++ < STASH_INFO_HASH_TRIGGER) in stash_maybe_enable_info_hash_tables()
5193 stash->funcinfo_hash_table = create_info_hash_table (abfd); in stash_maybe_enable_info_hash_tables()
5194 stash->varinfo_hash_table = create_info_hash_table (abfd); in stash_maybe_enable_info_hash_tables()
5195 if (!stash->funcinfo_hash_table || !stash->varinfo_hash_table) in stash_maybe_enable_info_hash_tables()
5198 stash->info_hash_status = STASH_INFO_HASH_DISABLED; in stash_maybe_enable_info_hash_tables()
5205 stash->info_hash_status = STASH_INFO_HASH_ON; in stash_maybe_enable_info_hash_tables()
5220 BFD_ASSERT (stash->info_hash_status == STASH_INFO_HASH_ON); in stash_find_line_fast()
5222 if (sym->flags & BSF_FUNCTION) in stash_find_line_fast()
5223 return info_hash_lookup_funcinfo (stash->funcinfo_hash_table, sym, addr, in stash_find_line_fast()
5225 return info_hash_lookup_varinfo (stash->varinfo_hash_table, sym, addr, in stash_find_line_fast()
5237 if (abfd->section_count == 0) in save_section_vma()
5239 stash->sec_vma = bfd_malloc (sizeof (*stash->sec_vma) * abfd->section_count); in save_section_vma()
5240 if (stash->sec_vma == NULL) in save_section_vma()
5242 stash->sec_vma_count = abfd->section_count; in save_section_vma()
5243 for (i = 0, s = abfd->sections; in save_section_vma()
5244 s != NULL && i < abfd->section_count; in save_section_vma()
5245 i++, s = s->next) in save_section_vma()
5247 if (s->output_section != NULL) in save_section_vma()
5248 stash->sec_vma[i] = s->output_section->vma + s->output_offset; in save_section_vma()
5250 stash->sec_vma[i] = s->vma; in save_section_vma()
5271 if (abfd->section_count != stash->sec_vma_count) in section_vma_same()
5274 for (i = 0, s = abfd->sections; in section_vma_same()
5275 s != NULL && i < abfd->section_count; in section_vma_same()
5276 i++, s = s->next) in section_vma_same()
5280 if (s->output_section != NULL) in section_vma_same()
5281 vma = s->output_section->vma + s->output_offset; in section_vma_same()
5283 vma = s->vma; in section_vma_same()
5284 if (vma != stash->sec_vma[i]) in section_vma_same()
5309 if (stash->orig_bfd == abfd in _bfd_dwarf2_slurp_debug_info()
5314 if (stash->f.bfd_ptr != NULL) in _bfd_dwarf2_slurp_debug_info()
5332 stash->orig_bfd = abfd; in _bfd_dwarf2_slurp_debug_info()
5333 stash->debug_sections = debug_sections; in _bfd_dwarf2_slurp_debug_info()
5334 stash->f.syms = symbols; in _bfd_dwarf2_slurp_debug_info()
5338 stash->f.abbrev_offsets = htab_create_alloc (10, hash_abbrev, eq_abbrev, in _bfd_dwarf2_slurp_debug_info()
5340 if (!stash->f.abbrev_offsets) in _bfd_dwarf2_slurp_debug_info()
5343 stash->alt.abbrev_offsets = htab_create_alloc (10, hash_abbrev, eq_abbrev, in _bfd_dwarf2_slurp_debug_info()
5345 if (!stash->alt.abbrev_offsets) in _bfd_dwarf2_slurp_debug_info()
5348 stash->f.trie_root = alloc_trie_leaf (abfd); in _bfd_dwarf2_slurp_debug_info()
5349 if (!stash->f.trie_root) in _bfd_dwarf2_slurp_debug_info()
5352 stash->alt.trie_root = alloc_trie_leaf (abfd); in _bfd_dwarf2_slurp_debug_info()
5353 if (!stash->alt.trie_root) in _bfd_dwarf2_slurp_debug_info()
5384 debug_bfd->flags |= BFD_DECOMPRESS; in _bfd_dwarf2_slurp_debug_info()
5395 stash->f.syms = symbols; in _bfd_dwarf2_slurp_debug_info()
5396 stash->close_on_cleanup = true; in _bfd_dwarf2_slurp_debug_info()
5398 stash->f.bfd_ptr = debug_bfd; in _bfd_dwarf2_slurp_debug_info()
5408 large stash. We do this in two passes - in the first pass we in _bfd_dwarf2_slurp_debug_info()
5418 total_size = msec->size; in _bfd_dwarf2_slurp_debug_info()
5419 if (! read_section (debug_bfd, &stash->debug_sections[debug_info], in _bfd_dwarf2_slurp_debug_info()
5421 &stash->f.dwarf_info_buffer, &total_size)) in _bfd_dwarf2_slurp_debug_info()
5432 if (total_size + msec->size < total_size in _bfd_dwarf2_slurp_debug_info()
5433 || total_size + msec->size < msec->size) in _bfd_dwarf2_slurp_debug_info()
5438 total_size += msec->size; in _bfd_dwarf2_slurp_debug_info()
5441 stash->f.dwarf_info_buffer = (bfd_byte *) bfd_malloc (total_size); in _bfd_dwarf2_slurp_debug_info()
5442 if (stash->f.dwarf_info_buffer == NULL) in _bfd_dwarf2_slurp_debug_info()
5452 size = msec->size; in _bfd_dwarf2_slurp_debug_info()
5457 (debug_bfd, msec, stash->f.dwarf_info_buffer + total_size, in _bfd_dwarf2_slurp_debug_info()
5465 stash->f.info_ptr = stash->f.dwarf_info_buffer; in _bfd_dwarf2_slurp_debug_info()
5466 stash->f.dwarf_info_size = total_size; in _bfd_dwarf2_slurp_debug_info()
5470 /* Parse the next DWARF2 compilation unit at FILE->INFO_PTR. */
5477 bfd_byte *info_ptr_unit = file->info_ptr; in stash_comp_unit()
5478 bfd_byte *info_ptr_end = file->dwarf_info_buffer + file->dwarf_info_size; in stash_comp_unit()
5480 if (file->info_ptr >= info_ptr_end) in stash_comp_unit()
5483 length = read_4_bytes (file->bfd_ptr, &file->info_ptr, info_ptr_end); in stash_comp_unit()
5485 we use 64-bit offsets, instead of 32-bit offsets. */ in stash_comp_unit()
5489 length = read_8_bytes (file->bfd_ptr, &file->info_ptr, info_ptr_end); in stash_comp_unit()
5491 /* A zero length is the IRIX way of indicating 64-bit offsets, in stash_comp_unit()
5492 mostly because the 64-bit length will generally fit in 32 in stash_comp_unit()
5497 length = read_4_bytes (file->bfd_ptr, &file->info_ptr, info_ptr_end); in stash_comp_unit()
5499 /* In the absence of the hints above, we assume 32-bit DWARF2 in stash_comp_unit()
5500 offsets even for targets with 64-bit addresses, because: in stash_comp_unit()
5502 more than 2Gb of debug info and so will not need 64-bit in stash_comp_unit()
5505 b) if they do use 64-bit offsets but they are not using in stash_comp_unit()
5512 && length <= (size_t) (info_ptr_end - file->info_ptr)) in stash_comp_unit()
5515 file->info_ptr, length, in stash_comp_unit()
5519 if (file->all_comp_units) in stash_comp_unit()
5520 file->all_comp_units->prev_unit = each; in stash_comp_unit()
5522 file->last_comp_unit = each; in stash_comp_unit()
5524 each->next_unit = file->all_comp_units; in stash_comp_unit()
5525 file->all_comp_units = each; in stash_comp_unit()
5527 if (each->arange.high == 0) in stash_comp_unit()
5529 each->next_unit_without_ranges = file->all_comp_units_without_ranges; in stash_comp_unit()
5530 file->all_comp_units_without_ranges = each->next_unit_without_ranges; in stash_comp_unit()
5533 file->info_ptr += length; in stash_comp_unit()
5540 file->info_ptr = info_ptr_end; in stash_comp_unit()
5550 return htab_hash_string (asym->name); in hash_asymbol()
5560 return strcmp (sa->name, sb->name) == 0; in eq_asymbol()
5588 if (sym->flags & BSF_FUNCTION && sym->section != NULL) in _bfd_dwarf2_find_symbol_bias()
5595 for (unit = stash->f.all_comp_units; unit; unit = unit->next_unit) in _bfd_dwarf2_find_symbol_bias()
5601 for (func = unit->function_table; func != NULL; func = func->prev_func) in _bfd_dwarf2_find_symbol_bias()
5602 if (func->name && func->arange.low) in _bfd_dwarf2_find_symbol_bias()
5609 search.name = func->name; in _bfd_dwarf2_find_symbol_bias()
5613 result = func->arange.low - (sym->value + sym->section->vma); in _bfd_dwarf2_find_symbol_bias()
5656 a pointer to the next un-read compilation unit. Check the in _bfd_dwarf2_find_nearest_line()
5675 (abfd->flags & (EXEC_P | DYNAMIC)) == 0)) in _bfd_dwarf2_find_nearest_line()
5685 addr = symbol->value; in _bfd_dwarf2_find_nearest_line()
5705 if (symbols != NULL && (section->flags & SEC_CODE) == 0) in _bfd_dwarf2_find_nearest_line()
5710 if ((*tmp)->the_bfd == abfd in _bfd_dwarf2_find_nearest_line()
5711 && (*tmp)->section == section in _bfd_dwarf2_find_nearest_line()
5712 && (*tmp)->value == offset in _bfd_dwarf2_find_nearest_line()
5713 && ((*tmp)->flags & BSF_SECTION_SYM) == 0) in _bfd_dwarf2_find_nearest_line()
5719 if ((symbol->flags & BSF_GLOBAL) != 0) in _bfd_dwarf2_find_nearest_line()
5725 if (section->output_section) in _bfd_dwarf2_find_nearest_line()
5726 addr += section->output_section->vma + section->output_offset; in _bfd_dwarf2_find_nearest_line()
5728 addr += section->vma; in _bfd_dwarf2_find_nearest_line()
5732 if (! stash->f.info_ptr) in _bfd_dwarf2_find_nearest_line()
5735 stash->inliner_chain = NULL; in _bfd_dwarf2_find_nearest_line()
5743 if (stash->info_hash_status == STASH_INFO_HASH_OFF) in _bfd_dwarf2_find_nearest_line()
5748 if (stash->info_hash_status == STASH_INFO_HASH_ON) in _bfd_dwarf2_find_nearest_line()
5751 if (stash->info_hash_status == STASH_INFO_HASH_ON) in _bfd_dwarf2_find_nearest_line()
5761 for (each = stash->f.all_comp_units; each; each = each->next_unit) in _bfd_dwarf2_find_nearest_line()
5762 if ((symbol->flags & BSF_FUNCTION) == 0 in _bfd_dwarf2_find_nearest_line()
5763 || each->arange.high == 0 in _bfd_dwarf2_find_nearest_line()
5775 struct trie_node *trie = stash->f.trie_root; in _bfd_dwarf2_find_nearest_line()
5776 unsigned int bits = VMA_BITS - 8; in _bfd_dwarf2_find_nearest_line()
5780 while (trie && trie->num_room_in_leaf == 0) in _bfd_dwarf2_find_nearest_line()
5783 trie = ((struct trie_interior *) trie)->children[ch]; in _bfd_dwarf2_find_nearest_line()
5784 bits -= 8; in _bfd_dwarf2_find_nearest_line()
5792 for (i = 0; i < leaf->num_stored_in_leaf; ++i) in _bfd_dwarf2_find_nearest_line()
5793 leaf->ranges[i].unit->mark = false; in _bfd_dwarf2_find_nearest_line()
5795 for (i = 0; i < leaf->num_stored_in_leaf; ++i) in _bfd_dwarf2_find_nearest_line()
5797 struct comp_unit *unit = leaf->ranges[i].unit; in _bfd_dwarf2_find_nearest_line()
5798 if (unit->mark in _bfd_dwarf2_find_nearest_line()
5799 || addr < leaf->ranges[i].low_pc in _bfd_dwarf2_find_nearest_line()
5800 || addr >= leaf->ranges[i].high_pc) in _bfd_dwarf2_find_nearest_line()
5802 unit->mark = true; in _bfd_dwarf2_find_nearest_line()
5817 prev_each = &stash->f.all_comp_units_without_ranges; in _bfd_dwarf2_find_nearest_line()
5818 for (each = *prev_each; each; each = each->next_unit_without_ranges) in _bfd_dwarf2_find_nearest_line()
5820 if (each->arange.high != 0) in _bfd_dwarf2_find_nearest_line()
5822 *prev_each = each->next_unit_without_ranges; in _bfd_dwarf2_find_nearest_line()
5833 prev_each = &each->next_unit_without_ranges; in _bfd_dwarf2_find_nearest_line()
5838 while ((each = stash_comp_unit (stash, &stash->f)) != NULL) in _bfd_dwarf2_find_nearest_line()
5842 unit->high == 0), we need to consult the line info table in _bfd_dwarf2_find_nearest_line()
5846 found = (((symbol->flags & BSF_FUNCTION) == 0 in _bfd_dwarf2_find_nearest_line()
5847 || each->arange.high == 0 in _bfd_dwarf2_find_nearest_line()
5852 found = ((each->arange.high == 0 in _bfd_dwarf2_find_nearest_line()
5865 if (functionname_ptr && function && function->is_linkage) in _bfd_dwarf2_find_nearest_line()
5867 *functionname_ptr = function->name; in _bfd_dwarf2_find_nearest_line()
5873 || (function && !function->is_linkage))) in _bfd_dwarf2_find_nearest_line()
5887 if (function && !function->is_linkage) in _bfd_dwarf2_find_nearest_line()
5891 sec_vma = section->vma; in _bfd_dwarf2_find_nearest_line()
5892 if (section->output_section != NULL) in _bfd_dwarf2_find_nearest_line()
5893 sec_vma = section->output_section->vma + section->output_offset; in _bfd_dwarf2_find_nearest_line()
5895 *functionname_ptr = function->name; in _bfd_dwarf2_find_nearest_line()
5896 else if (fun->value + sec_vma == function->arange.low) in _bfd_dwarf2_find_nearest_line()
5897 function->name = *functionname_ptr; in _bfd_dwarf2_find_nearest_line()
5900 function->is_linkage = true; in _bfd_dwarf2_find_nearest_line()
5904 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) in _bfd_dwarf2_find_nearest_line()
5922 struct funcinfo *func = stash->inliner_chain; in _bfd_dwarf2_find_inliner_info()
5924 if (func && func->caller_func) in _bfd_dwarf2_find_inliner_info()
5926 *filename_ptr = func->caller_file; in _bfd_dwarf2_find_inliner_info()
5927 *functionname_ptr = func->caller_func->name; in _bfd_dwarf2_find_inliner_info()
5928 *linenumber_ptr = func->caller_line; in _bfd_dwarf2_find_inliner_info()
5929 stash->inliner_chain = func->caller_func; in _bfd_dwarf2_find_inliner_info()
5947 if (stash->varinfo_hash_table) in _bfd_dwarf2_cleanup_debug_info()
5948 bfd_hash_table_free (&stash->varinfo_hash_table->base); in _bfd_dwarf2_cleanup_debug_info()
5949 if (stash->funcinfo_hash_table) in _bfd_dwarf2_cleanup_debug_info()
5950 bfd_hash_table_free (&stash->funcinfo_hash_table->base); in _bfd_dwarf2_cleanup_debug_info()
5952 file = &stash->f; in _bfd_dwarf2_cleanup_debug_info()
5955 for (each = file->all_comp_units; each; each = each->next_unit) in _bfd_dwarf2_cleanup_debug_info()
5957 struct funcinfo *function_table = each->function_table; in _bfd_dwarf2_cleanup_debug_info()
5958 struct varinfo *variable_table = each->variable_table; in _bfd_dwarf2_cleanup_debug_info()
5960 if (each->line_table && each->line_table != file->line_table) in _bfd_dwarf2_cleanup_debug_info()
5962 free (each->line_table->files); in _bfd_dwarf2_cleanup_debug_info()
5963 free (each->line_table->dirs); in _bfd_dwarf2_cleanup_debug_info()
5966 free (each->lookup_funcinfo_table); in _bfd_dwarf2_cleanup_debug_info()
5967 each->lookup_funcinfo_table = NULL; in _bfd_dwarf2_cleanup_debug_info()
5971 free (function_table->file); in _bfd_dwarf2_cleanup_debug_info()
5972 function_table->file = NULL; in _bfd_dwarf2_cleanup_debug_info()
5973 free (function_table->caller_file); in _bfd_dwarf2_cleanup_debug_info()
5974 function_table->caller_file = NULL; in _bfd_dwarf2_cleanup_debug_info()
5975 function_table = function_table->prev_func; in _bfd_dwarf2_cleanup_debug_info()
5980 free (variable_table->file); in _bfd_dwarf2_cleanup_debug_info()
5981 variable_table->file = NULL; in _bfd_dwarf2_cleanup_debug_info()
5982 variable_table = variable_table->prev_var; in _bfd_dwarf2_cleanup_debug_info()
5986 if (file->line_table) in _bfd_dwarf2_cleanup_debug_info()
5988 free (file->line_table->files); in _bfd_dwarf2_cleanup_debug_info()
5989 free (file->line_table->dirs); in _bfd_dwarf2_cleanup_debug_info()
5991 htab_delete (file->abbrev_offsets); in _bfd_dwarf2_cleanup_debug_info()
5993 free (file->dwarf_line_str_buffer); in _bfd_dwarf2_cleanup_debug_info()
5994 free (file->dwarf_str_buffer); in _bfd_dwarf2_cleanup_debug_info()
5995 free (file->dwarf_ranges_buffer); in _bfd_dwarf2_cleanup_debug_info()
5996 free (file->dwarf_line_buffer); in _bfd_dwarf2_cleanup_debug_info()
5997 free (file->dwarf_abbrev_buffer); in _bfd_dwarf2_cleanup_debug_info()
5998 free (file->dwarf_info_buffer); in _bfd_dwarf2_cleanup_debug_info()
5999 if (file == &stash->alt) in _bfd_dwarf2_cleanup_debug_info()
6001 file = &stash->alt; in _bfd_dwarf2_cleanup_debug_info()
6003 free (stash->sec_vma); in _bfd_dwarf2_cleanup_debug_info()
6004 free (stash->adjusted_sections); in _bfd_dwarf2_cleanup_debug_info()
6005 if (stash->close_on_cleanup) in _bfd_dwarf2_cleanup_debug_info()
6006 bfd_close (stash->f.bfd_ptr); in _bfd_dwarf2_cleanup_debug_info()
6007 if (stash->alt.bfd_ptr) in _bfd_dwarf2_cleanup_debug_info()
6008 bfd_close (stash->alt.bfd_ptr); in _bfd_dwarf2_cleanup_debug_info()
6036 cache = elf_tdata (abfd)->elf_find_function_cache; in _bfd_elf_find_function()
6040 elf_tdata (abfd)->elf_find_function_cache = cache; in _bfd_elf_find_function()
6044 if (cache->last_section != section in _bfd_elf_find_function()
6045 || cache->func == NULL in _bfd_elf_find_function()
6046 || offset < cache->func->value in _bfd_elf_find_function()
6047 || offset >= cache->func->value + cache->func_size) in _bfd_elf_find_function()
6057 ld -r doesn't do this. So, for ld -r output, it is possible to in _bfd_elf_find_function()
6066 cache->filename = NULL; in _bfd_elf_find_function()
6067 cache->func = NULL; in _bfd_elf_find_function()
6068 cache->func_size = 0; in _bfd_elf_find_function()
6069 cache->last_section = section; in _bfd_elf_find_function()
6077 if ((sym->flags & BSF_FILE) != 0) in _bfd_elf_find_function()
6085 size = bed->maybe_function_sym (sym, section, &code_off); in _bfd_elf_find_function()
6090 && size > cache->func_size))) in _bfd_elf_find_function()
6092 cache->func = sym; in _bfd_elf_find_function()
6093 cache->func_size = size; in _bfd_elf_find_function()
6094 cache->filename = NULL; in _bfd_elf_find_function()
6097 && ((sym->flags & BSF_LOCAL) != 0 in _bfd_elf_find_function()
6099 cache->filename = bfd_asymbol_name (file); in _bfd_elf_find_function()
6106 if (cache->func == NULL) in _bfd_elf_find_function()
6110 *filename_ptr = cache->filename; in _bfd_elf_find_function()
6112 *functionname_ptr = bfd_asymbol_name (cache->func); in _bfd_elf_find_function()
6114 return cache->func; in _bfd_elf_find_function()