* [BUG Report] objdump on mingw64 does not display debug_rnglists properly
@ 2021-11-28 23:34 Neeraj Singh
2021-11-30 13:21 ` Nick Clifton
2021-11-30 13:36 ` Johannes Schindelin
0 siblings, 2 replies; 5+ messages in thread
From: Neeraj Singh @ 2021-11-28 23:34 UTC (permalink / raw)
To: binutils; +Cc: Johannes Schindelin
Hi binutils community,
I'm attempting to use objdump against a git.exe built by the mingw64
toolset using gcc-11.2. The git executable is shared at
https://drive.google.com/file/d/1dp85IqRX8n5ieoB6rLUvOd0Mbo4_AfoV/view?usp=sharing.
There's one minor problem that I was able to address:
binutils\dwarf.c:display_debug_ranges and
display_debug_rnglists_list/display_debug_ranges_list should be using
dwarf_vma for base_address rather than unsigned long. The size of
these two types differ on LLP64 platforms, like mingw64.
There's another problem that I didn't understand: in
display_debug_ranges we use the .debug_rnglists header to compute
"initial_length" and set "finish" to "start+initial_length". That
logic doesn't seem right for an executable which has a .debug_rnglists
containing ranges from multiple compile units. I'm not sure how this
works correctly on ELF platforms (thought it seems like it does). I
think the right fix is to just leave "finish" set to the end of the
section rather than using the value from the debug_rnglists header.
Thanks,
Neeraj Singh
Windows Core Filesystems.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG Report] objdump on mingw64 does not display debug_rnglists properly
2021-11-28 23:34 [BUG Report] objdump on mingw64 does not display debug_rnglists properly Neeraj Singh
@ 2021-11-30 13:21 ` Nick Clifton
2021-11-30 13:36 ` Johannes Schindelin
1 sibling, 0 replies; 5+ messages in thread
From: Nick Clifton @ 2021-11-30 13:21 UTC (permalink / raw)
To: Neeraj Singh, binutils; +Cc: Johannes Schindelin
[-- Attachment #1: Type: text/plain, Size: 798 bytes --]
Hi Neeraj,
> There's one minor problem that I was able to address:
> binutils\dwarf.c:display_debug_ranges and
> display_debug_rnglists_list/display_debug_ranges_list should be using
> dwarf_vma for base_address rather than unsigned long. The size of
> these two types differ on LLP64 platforms, like mingw64.
Thanks for raising this issue. I have checked in a patch (attached) to
fix the problem in the display_debug_rnglists_list and other, similar
functions in dwarf.c
> There's another problem that I didn't understand: in
> display_debug_ranges we use the .debug_rnglists header to compute
> "initial_length" and set "finish" to "start+initial_length".
Which version of the sources are you examining ? In the version I
have finish is set to section start + section size.
Cheers
Nick
[-- Attachment #2: dwarf-vma.patch --]
[-- Type: text/x-patch, Size: 6929 bytes --]
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index ce54813a076..6f2a49b48c2 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -5574,7 +5574,7 @@ display_debug_lines (struct dwarf_section *section, void *file)
}
static debug_info *
-find_debug_info_for_offset (unsigned long offset)
+find_debug_info_for_offset (dwarf_vma offset)
{
unsigned int i;
@@ -6330,11 +6330,10 @@ display_loc_list (struct dwarf_section *section,
{
unsigned char *start = *start_ptr, *vstart = *vstart_ptr;
unsigned char *section_end = section->start + section->size;
- unsigned long cu_offset;
+ dwarf_vma cu_offset;
unsigned int pointer_size;
unsigned int offset_size;
int dwarf_version;
-
dwarf_vma begin;
dwarf_vma end;
unsigned short length;
@@ -6371,7 +6370,8 @@ display_loc_list (struct dwarf_section *section,
break;
}
- printf (" %8.8lx ", (unsigned long) off);
+ printf (" ");
+ print_dwarf_vma (off, 4);
SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end);
SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end);
@@ -6475,7 +6475,7 @@ display_loclists_list (struct dwarf_section *section,
{
unsigned char *start = *start_ptr, *vstart = *vstart_ptr;
unsigned char *section_end = section->start + section->size;
- unsigned long cu_offset;
+ dwarf_vma cu_offset;
unsigned int pointer_size;
unsigned int offset_size;
int dwarf_version;
@@ -6518,7 +6518,8 @@ display_loclists_list (struct dwarf_section *section,
break;
}
- printf (" %8.8lx ", (unsigned long) off);
+ printf (" ");
+ print_dwarf_vma (off, 4);
SAFE_BYTE_GET_AND_INC (llet, start, 1, section_end);
@@ -6661,7 +6662,7 @@ display_loc_list_dwo (struct dwarf_section *section,
{
unsigned char *start = *start_ptr, *vstart = *vstart_ptr;
unsigned char *section_end = section->start + section->size;
- unsigned long cu_offset;
+ dwarf_vma cu_offset;
unsigned int pointer_size;
unsigned int offset_size;
int dwarf_version;
@@ -6691,7 +6692,8 @@ display_loc_list_dwo (struct dwarf_section *section,
while (1)
{
- printf (" %8.8lx ", (unsigned long) (offset + (start - *start_ptr)));
+ printf (" ");
+ print_dwarf_vma (offset + (start - *start_ptr), 4);
if (start >= section_end)
{
@@ -6829,11 +6831,11 @@ static int
display_debug_loc (struct dwarf_section *section, void *file)
{
unsigned char *start = section->start, *vstart = NULL;
- unsigned long bytes;
+ dwarf_vma bytes;
unsigned char *section_begin = start;
unsigned int num_loc_list = 0;
- unsigned long last_offset = 0;
- unsigned long last_view = 0;
+ dwarf_vma last_offset = 0;
+ dwarf_vma last_view = 0;
unsigned int first = 0;
unsigned int i;
unsigned int j;
@@ -7105,7 +7107,7 @@ display_debug_str (struct dwarf_section *section,
void *file ATTRIBUTE_UNUSED)
{
unsigned char *start = section->start;
- unsigned long bytes = section->size;
+ dwarf_vma bytes = section->size;
dwarf_vma addr = section->address;
if (bytes == 0)
@@ -7196,9 +7198,9 @@ display_debug_aranges (struct dwarf_section *section,
unsigned char *addr_ranges;
dwarf_vma length;
dwarf_vma address;
- unsigned long sec_off;
+ dwarf_vma sec_off;
unsigned char address_size;
- unsigned int offset_size;
+ unsigned int offset_size;
unsigned char *end_ranges;
hdrptr = start;
@@ -7217,7 +7219,7 @@ display_debug_aranges (struct dwarf_section *section,
{
warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"),
section->name,
- sec_off,
+ (unsigned long) sec_off,
dwarf_vmatoa ("x", arange.ar_length));
break;
}
@@ -7556,9 +7558,11 @@ range_entry_compar (const void *ap, const void *bp)
}
static void
-display_debug_ranges_list (unsigned char *start, unsigned char *finish,
- unsigned int pointer_size, unsigned long offset,
- unsigned long base_address)
+display_debug_ranges_list (unsigned char * start,
+ unsigned char * finish,
+ unsigned int pointer_size,
+ dwarf_vma offset,
+ dwarf_vma base_address)
{
while (start < finish)
{
@@ -7570,7 +7574,8 @@ display_debug_ranges_list (unsigned char *start, unsigned char *finish,
break;
SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
- printf (" %8.8lx ", offset);
+ printf (" ");
+ print_dwarf_vma (offset, 4);
if (begin == 0 && end == 0)
{
@@ -7602,27 +7607,30 @@ display_debug_ranges_list (unsigned char *start, unsigned char *finish,
}
static void
-display_debug_rnglists_list (unsigned char *start, unsigned char *finish,
- unsigned int pointer_size, unsigned long offset,
- unsigned long base_address)
+display_debug_rnglists_list (unsigned char * start,
+ unsigned char * finish,
+ unsigned int pointer_size,
+ dwarf_vma offset,
+ dwarf_vma base_address)
{
unsigned char *next = start;
while (1)
{
- unsigned long off = offset + (start - next);
+ dwarf_vma off = offset + (start - next);
enum dwarf_range_list_entry rlet;
/* Initialize it due to a false compiler warning. */
dwarf_vma begin = -1, length, end = -1;
if (start >= finish)
{
- warn (_("Range list starting at offset 0x%lx is not terminated.\n"),
- offset);
+ warn (_("Range list starting at offset 0x%s is not terminated.\n"),
+ dwarf_vmatoa ("x", offset));
break;
}
- printf (" %8.8lx ", off);
+ printf (" ");
+ print_dwarf_vma (off, 4);
SAFE_BYTE_GET_AND_INC (rlet, start, 1, finish);
@@ -7682,17 +7690,18 @@ static int
display_debug_ranges (struct dwarf_section *section,
void *file ATTRIBUTE_UNUSED)
{
- unsigned char *start = section->start;
- unsigned char *last_start = start;
- unsigned long bytes = section->size;
- unsigned char *section_begin = start;
- unsigned char *finish = start + bytes;
- unsigned int num_range_list, i;
- struct range_entry *range_entries, *range_entry_fill;
- int is_rnglists = strstr (section->name, "debug_rnglists") != NULL;
+ unsigned char * start = section->start;
+ unsigned char * last_start = start;
+ dwarf_vma bytes = section->size;
+ unsigned char * section_begin = start;
+ unsigned char * finish = start + bytes;
+ unsigned int num_range_list, i;
+ struct range_entry * range_entries;
+ struct range_entry * range_entry_fill;
+ int is_rnglists = strstr (section->name, "debug_rnglists") != NULL;
/* Initialize it due to a false compiler warning. */
- unsigned char address_size = 0;
- dwarf_vma last_offset = 0;
+ unsigned char address_size = 0;
+ dwarf_vma last_offset = 0;
if (bytes == 0)
{
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG Report] objdump on mingw64 does not display debug_rnglists properly
2021-11-28 23:34 [BUG Report] objdump on mingw64 does not display debug_rnglists properly Neeraj Singh
2021-11-30 13:21 ` Nick Clifton
@ 2021-11-30 13:36 ` Johannes Schindelin
2021-11-30 17:39 ` Nick Clifton
1 sibling, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2021-11-30 13:36 UTC (permalink / raw)
To: Neeraj Singh; +Cc: binutils
Hi Neeraj,
I believe that the binutils team prefers bug reports via
https://sourceware.org/bugzilla/, as per
https://www.gnu.org/software/binutils/.
Would you mind opening a ticket there?
Thank you,
Dscho
On Sun, 28 Nov 2021, Neeraj Singh wrote:
> Hi binutils community,
> I'm attempting to use objdump against a git.exe built by the mingw64
> toolset using gcc-11.2. The git executable is shared at
> https://drive.google.com/file/d/1dp85IqRX8n5ieoB6rLUvOd0Mbo4_AfoV/view?usp=sharing.
>
> There's one minor problem that I was able to address:
> binutils\dwarf.c:display_debug_ranges and
> display_debug_rnglists_list/display_debug_ranges_list should be using
> dwarf_vma for base_address rather than unsigned long. The size of
> these two types differ on LLP64 platforms, like mingw64.
>
> There's another problem that I didn't understand: in
> display_debug_ranges we use the .debug_rnglists header to compute
> "initial_length" and set "finish" to "start+initial_length". That
> logic doesn't seem right for an executable which has a .debug_rnglists
> containing ranges from multiple compile units. I'm not sure how this
> works correctly on ELF platforms (thought it seems like it does). I
> think the right fix is to just leave "finish" set to the end of the
> section rather than using the value from the debug_rnglists header.
>
> Thanks,
> Neeraj Singh
> Windows Core Filesystems.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG Report] objdump on mingw64 does not display debug_rnglists properly
2021-11-30 13:36 ` Johannes Schindelin
@ 2021-11-30 17:39 ` Nick Clifton
2021-11-30 19:21 ` Neeraj Singh
0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2021-11-30 17:39 UTC (permalink / raw)
To: Johannes Schindelin, Neeraj Singh; +Cc: binutils
Hi Johannes,
> I believe that the binutils team prefers bug reports via
> https://sourceware.org/bugzilla/, as per
> https://www.gnu.org/software/binutils/.
We do - and I really should have said this myself. Thanks for reminding us.
> Would you mind opening a ticket there?
As it happens I have already checked in a patch to fix the problem, but Neeraj
does file a ticket I will update it with a link to the commit.
Cheers
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG Report] objdump on mingw64 does not display debug_rnglists properly
2021-11-30 17:39 ` Nick Clifton
@ 2021-11-30 19:21 ` Neeraj Singh
0 siblings, 0 replies; 5+ messages in thread
From: Neeraj Singh @ 2021-11-30 19:21 UTC (permalink / raw)
To: Nick Clifton; +Cc: Johannes Schindelin, binutils
On Tue, Nov 30, 2021 at 9:40 AM Nick Clifton <nickc@redhat.com> wrote:
>
> Hi Johannes,
>
> > I believe that the binutils team prefers bug reports via
> > https://sourceware.org/bugzilla/, as per
> > https://www.gnu.org/software/binutils/.
>
> We do - and I really should have said this myself. Thanks for reminding us.
>
> > Would you mind opening a ticket there?
>
> As it happens I have already checked in a patch to fix the problem, but Neeraj
> does file a ticket I will update it with a link to the commit.
>
> Cheers
> Nick
>
I just sent mail to the overseers to get bugzilla access. Automated
account creation is currently disabled over there. If and when I get
an account, I can file a proper bug.
It looks like the display_debug_ranges issue with initial_length was
already fixed with
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=e7f024765a48fba4452535a5fc006a7e858730fd.
The bug exists in the 2.37 release of binutils.
Thanks,
Neeraj
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-30 19:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-28 23:34 [BUG Report] objdump on mingw64 does not display debug_rnglists properly Neeraj Singh
2021-11-30 13:21 ` Nick Clifton
2021-11-30 13:36 ` Johannes Schindelin
2021-11-30 17:39 ` Nick Clifton
2021-11-30 19:21 ` Neeraj Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).