binutils/binutils-dwarf-type-sign-2.patch

143 lines
4.8 KiB
Diff
Raw Normal View History

2020-11-03 20:03:31 +00:00
--- binutils.orig/binutils/dwarf.c 2020-11-03 17:10:15.182386267 +0000
+++ binutils-2.35.1/binutils/dwarf.c 2020-11-03 17:14:38.660411672 +0000
@@ -876,6 +876,7 @@ typedef struct abbrev_list
{
abbrev_entry * first_abbrev;
abbrev_entry * last_abbrev;
+ dwarf_vma abbrev_base;
dwarf_vma abbrev_offset;
struct abbrev_list * next;
unsigned char * start_of_next_abbrevs;
@@ -955,10 +956,11 @@ free_all_abbrevs (void)
}
static abbrev_list *
-new_abbrev_list (dwarf_vma abbrev_offset)
+new_abbrev_list (dwarf_vma abbrev_base, dwarf_vma abbrev_offset)
{
abbrev_list * list = (abbrev_list *) xcalloc (sizeof * list, 1);
+ list->abbrev_base = abbrev_base;
list->abbrev_offset = abbrev_offset;
list->next = abbrev_lists;
@@ -968,12 +970,14 @@ new_abbrev_list (dwarf_vma abbrev_offset
}
static abbrev_list *
-find_abbrev_list_by_abbrev_offset (dwarf_vma abbrev_offset)
+find_abbrev_list_by_abbrev_offset (dwarf_vma abbrev_base,
+ dwarf_vma abbrev_offset)
{
abbrev_list * list;
for (list = abbrev_lists; list != NULL; list = list->next)
- if (list->abbrev_offset == abbrev_offset)
+ if (list->abbrev_base == abbrev_base
+ && list->abbrev_offset == abbrev_offset)
return list;
return NULL;
@@ -2415,10 +2419,10 @@ read_and_display_attr_value (unsigned lo
case DW_FORM_ref_addr:
if (dwarf_version == 2)
SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);
- else if (dwarf_version == 3 || dwarf_version == 4)
+ else if (dwarf_version > 2)
SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
else
- error (_("Internal error: DWARF version is not 2, 3 or 4.\n"));
+ error (_("Internal error: DW_FORM_ref_addr is not supported in DWARF version 1.\n"));
break;
case DW_FORM_addr:
@@ -3455,6 +3459,8 @@ process_debug_info (struct dwarf_section
{
DWARF2_Internal_CompUnit compunit;
unsigned char * hdrptr;
+ dwarf_vma abbrev_base;
+ size_t abbrev_size;
dwarf_vma cu_offset;
unsigned int offset_size;
unsigned int initial_length_size;
@@ -3499,25 +3505,25 @@ process_debug_info (struct dwarf_section
SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end);
- list = find_abbrev_list_by_abbrev_offset (compunit.cu_abbrev_offset);
+ if (this_set == NULL)
+ {
+ abbrev_base = 0;
+ abbrev_size = debug_displays [abbrev_sec].section.size;
+ }
+ else
+ {
+ abbrev_base = this_set->section_offsets [DW_SECT_ABBREV];
+ abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];
+ }
+
+ list = find_abbrev_list_by_abbrev_offset (abbrev_base,
+ compunit.cu_abbrev_offset);
if (list == NULL)
{
- dwarf_vma abbrev_base;
- size_t abbrev_size;
unsigned char * next;
- if (this_set == NULL)
- {
- abbrev_base = 0;
- abbrev_size = debug_displays [abbrev_sec].section.size;
- }
- else
- {
- abbrev_base = this_set->section_offsets [DW_SECT_ABBREV];
- abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];
- }
-
- list = new_abbrev_list (compunit.cu_abbrev_offset);
+ list = new_abbrev_list (abbrev_base,
+ compunit.cu_abbrev_offset);
next = process_abbrev_set
(((unsigned char *) debug_displays [abbrev_sec].section.start
+ abbrev_base + compunit.cu_abbrev_offset),
@@ -3734,12 +3740,14 @@ process_debug_info (struct dwarf_section
(unsigned long) debug_displays [abbrev_sec].section.size);
else
{
- list = find_abbrev_list_by_abbrev_offset (compunit.cu_abbrev_offset);
+ list = find_abbrev_list_by_abbrev_offset (abbrev_base,
+ compunit.cu_abbrev_offset);
if (list == NULL)
{
unsigned char * next;
- list = new_abbrev_list (compunit.cu_abbrev_offset);
+ list = new_abbrev_list (abbrev_base,
+ compunit.cu_abbrev_offset);
next = process_abbrev_set
(((unsigned char *) debug_displays [abbrev_sec].section.start
+ abbrev_base + compunit.cu_abbrev_offset),
@@ -5304,7 +5312,7 @@ display_debug_lines_decoded (struct dwar
else
{
newFileName = (char *) xmalloc (fileNameLength + 1);
- strcpy (newFileName, fileName);
+ strncpy (newFileName, fileName, fileNameLength + 1);
}
if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH))
@@ -6029,10 +6037,10 @@ display_debug_abbrev (struct dwarf_secti
dwarf_vma offset;
offset = start - section->start;
- list = find_abbrev_list_by_abbrev_offset (offset);
+ list = find_abbrev_list_by_abbrev_offset (0, offset);
if (list == NULL)
{
- list = new_abbrev_list (offset);
+ list = new_abbrev_list (0, offset);
start = process_abbrev_set (start, end, list);
list->start_of_next_abbrevs = start;
}