Start mass upgrade
[dragora.git] / patches / binutils / 2.35 / binutils-dwarf-type-sign-2.patch
blobce600d4ce5e66f6100594c149c76864390a16ac7
1 --- binutils.orig/binutils/dwarf.c 2020-11-03 17:10:15.182386267 +0000
2 +++ binutils-2.35.1/binutils/dwarf.c 2020-11-03 17:14:38.660411672 +0000
3 @@ -876,6 +876,7 @@ typedef struct abbrev_list
5 abbrev_entry * first_abbrev;
6 abbrev_entry * last_abbrev;
7 + dwarf_vma abbrev_base;
8 dwarf_vma abbrev_offset;
9 struct abbrev_list * next;
10 unsigned char * start_of_next_abbrevs;
11 @@ -955,10 +956,11 @@ free_all_abbrevs (void)
14 static abbrev_list *
15 -new_abbrev_list (dwarf_vma abbrev_offset)
16 +new_abbrev_list (dwarf_vma abbrev_base, dwarf_vma abbrev_offset)
18 abbrev_list * list = (abbrev_list *) xcalloc (sizeof * list, 1);
20 + list->abbrev_base = abbrev_base;
21 list->abbrev_offset = abbrev_offset;
23 list->next = abbrev_lists;
24 @@ -968,12 +970,14 @@ new_abbrev_list (dwarf_vma abbrev_offset
27 static abbrev_list *
28 -find_abbrev_list_by_abbrev_offset (dwarf_vma abbrev_offset)
29 +find_abbrev_list_by_abbrev_offset (dwarf_vma abbrev_base,
30 + dwarf_vma abbrev_offset)
32 abbrev_list * list;
34 for (list = abbrev_lists; list != NULL; list = list->next)
35 - if (list->abbrev_offset == abbrev_offset)
36 + if (list->abbrev_base == abbrev_base
37 + && list->abbrev_offset == abbrev_offset)
38 return list;
40 return NULL;
41 @@ -2415,10 +2419,10 @@ read_and_display_attr_value (unsigned lo
42 case DW_FORM_ref_addr:
43 if (dwarf_version == 2)
44 SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);
45 - else if (dwarf_version == 3 || dwarf_version == 4)
46 + else if (dwarf_version > 2)
47 SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
48 else
49 - error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
50 + error (_("Internal error: DW_FORM_ref_addr is not supported in DWARF version 1.\n"));
51 break;
53 case DW_FORM_addr:
54 @@ -3455,6 +3459,8 @@ process_debug_info (struct dwarf_section
56 DWARF2_Internal_CompUnit compunit;
57 unsigned char * hdrptr;
58 + dwarf_vma abbrev_base;
59 + size_t abbrev_size;
60 dwarf_vma cu_offset;
61 unsigned int offset_size;
62 unsigned int initial_length_size;
63 @@ -3499,25 +3505,25 @@ process_debug_info (struct dwarf_section
65 SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end);
67 - list = find_abbrev_list_by_abbrev_offset (compunit.cu_abbrev_offset);
68 + if (this_set == NULL)
69 + {
70 + abbrev_base = 0;
71 + abbrev_size = debug_displays [abbrev_sec].section.size;
72 + }
73 + else
74 + {
75 + abbrev_base = this_set->section_offsets [DW_SECT_ABBREV];
76 + abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];
77 + }
79 + list = find_abbrev_list_by_abbrev_offset (abbrev_base,
80 + compunit.cu_abbrev_offset);
81 if (list == NULL)
83 - dwarf_vma abbrev_base;
84 - size_t abbrev_size;
85 unsigned char * next;
87 - if (this_set == NULL)
88 - {
89 - abbrev_base = 0;
90 - abbrev_size = debug_displays [abbrev_sec].section.size;
91 - }
92 - else
93 - {
94 - abbrev_base = this_set->section_offsets [DW_SECT_ABBREV];
95 - abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];
96 - }
98 - list = new_abbrev_list (compunit.cu_abbrev_offset);
99 + list = new_abbrev_list (abbrev_base,
100 + compunit.cu_abbrev_offset);
101 next = process_abbrev_set
102 (((unsigned char *) debug_displays [abbrev_sec].section.start
103 + abbrev_base + compunit.cu_abbrev_offset),
104 @@ -3734,12 +3740,14 @@ process_debug_info (struct dwarf_section
105 (unsigned long) debug_displays [abbrev_sec].section.size);
106 else
108 - list = find_abbrev_list_by_abbrev_offset (compunit.cu_abbrev_offset);
109 + list = find_abbrev_list_by_abbrev_offset (abbrev_base,
110 + compunit.cu_abbrev_offset);
111 if (list == NULL)
113 unsigned char * next;
115 - list = new_abbrev_list (compunit.cu_abbrev_offset);
116 + list = new_abbrev_list (abbrev_base,
117 + compunit.cu_abbrev_offset);
118 next = process_abbrev_set
119 (((unsigned char *) debug_displays [abbrev_sec].section.start
120 + abbrev_base + compunit.cu_abbrev_offset),
121 @@ -5304,7 +5312,7 @@ display_debug_lines_decoded (struct dwar
122 else
124 newFileName = (char *) xmalloc (fileNameLength + 1);
125 - strcpy (newFileName, fileName);
126 + strncpy (newFileName, fileName, fileNameLength + 1);
129 if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH))
130 @@ -6029,10 +6037,10 @@ display_debug_abbrev (struct dwarf_secti
131 dwarf_vma offset;
133 offset = start - section->start;
134 - list = find_abbrev_list_by_abbrev_offset (offset);
135 + list = find_abbrev_list_by_abbrev_offset (0, offset);
136 if (list == NULL)
138 - list = new_abbrev_list (offset);
139 + list = new_abbrev_list (0, offset);
140 start = process_abbrev_set (start, end, list);
141 list->start_of_next_abbrevs = start;