* [PATCH] dwarf5: Fix parsing DWARF-5 line number tables
@ 2021-01-23 23:29 H.J. Lu
2021-01-23 23:29 ` H.J. Lu
2021-01-23 23:40 ` [PATCH] dwarf5: Fix parsing " Mark Wielaard
0 siblings, 2 replies; 7+ messages in thread
From: H.J. Lu @ 2021-01-23 23:29 UTC (permalink / raw)
To: binutils; +Cc: Mark Wielaard, Alan Modra, Nick Clifton
Advance rngs_ptr when parsing DW_RLE_offset_pair, which was missing in
commit c3757b583d2448a5996e83e374fb96ac7938da35
Author: Mark Wielaard <mark@klomp.org>
Date: Tue Aug 25 15:33:00 2020 +0100
Fix the linker's handling of DWARF-5 line number tables.
OK for master and 2.36 branch?
H.J.
---
PR binutils/27231
* dwarf2.c (read_rnglists): Advance rngs_ptr after
_bfd_safe_read_leb128 when parsing DW_RLE_offset_pair.
---
bfd/dwarf2.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index d1770ae4fdb..292d60c33d4 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -3265,9 +3265,11 @@ read_rnglists (struct comp_unit *unit, struct arange *arange,
low_pc = base_address;
low_pc += _bfd_safe_read_leb128 (abfd, rngs_ptr, &bytes_read,
FALSE, rngs_end);
+ rngs_ptr += bytes_read;
high_pc = base_address;
high_pc += _bfd_safe_read_leb128 (abfd, rngs_ptr, &bytes_read,
FALSE, rngs_end);
+ rngs_ptr += bytes_read;
break;
case DW_RLE_start_end:
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] dwarf5: Fix parsing DWARF-5 line number tables
2021-01-23 23:29 [PATCH] dwarf5: Fix parsing DWARF-5 line number tables H.J. Lu
@ 2021-01-23 23:29 ` H.J. Lu
2021-01-24 1:34 ` Alan Modra
2021-01-23 23:40 ` [PATCH] dwarf5: Fix parsing " Mark Wielaard
1 sibling, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2021-01-23 23:29 UTC (permalink / raw)
To: binutils; +Cc: Mark Wielaard, Alan Modra, Nick Clifton
Advance rngs_ptr when parsing DW_RLE_offset_pair, which was missing in
commit c3757b583d2448a5996e83e374fb96ac7938da35
Author: Mark Wielaard <mark@klomp.org>
Date: Tue Aug 25 15:33:00 2020 +0100
Fix the linker's handling of DWARF-5 line number tables.
PR binutils/27231
* dwarf2.c (read_rnglists): Advance rngs_ptr after
_bfd_safe_read_leb128 when parsing DW_RLE_offset_pair.
---
bfd/dwarf2.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index d1770ae4fdb..292d60c33d4 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -3265,9 +3265,11 @@ read_rnglists (struct comp_unit *unit, struct arange *arange,
low_pc = base_address;
low_pc += _bfd_safe_read_leb128 (abfd, rngs_ptr, &bytes_read,
FALSE, rngs_end);
+ rngs_ptr += bytes_read;
high_pc = base_address;
high_pc += _bfd_safe_read_leb128 (abfd, rngs_ptr, &bytes_read,
FALSE, rngs_end);
+ rngs_ptr += bytes_read;
break;
case DW_RLE_start_end:
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] dwarf5: Fix parsing DWARF-5 line number tables
2021-01-23 23:29 ` H.J. Lu
@ 2021-01-24 1:34 ` Alan Modra
2021-01-24 4:16 ` [PATCH] DWARF-5: Skip empty range in " H.J. Lu
0 siblings, 1 reply; 7+ messages in thread
From: Alan Modra @ 2021-01-24 1:34 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils, Mark Wielaard, Nick Clifton
On Sat, Jan 23, 2021 at 03:29:35PM -0800, H.J. Lu wrote:
> Advance rngs_ptr when parsing DW_RLE_offset_pair, which was missing in
>
> commit c3757b583d2448a5996e83e374fb96ac7938da35
> Author: Mark Wielaard <mark@klomp.org>
> Date: Tue Aug 25 15:33:00 2020 +0100
>
> Fix the linker's handling of DWARF-5 line number tables.
>
> PR binutils/27231
> * dwarf2.c (read_rnglists): Advance rngs_ptr after
> _bfd_safe_read_leb128 when parsing DW_RLE_offset_pair.
OK everywhere.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] DWARF-5: Skip empty range in DWARF-5 line number tables
2021-01-24 1:34 ` Alan Modra
@ 2021-01-24 4:16 ` H.J. Lu
2021-01-24 11:58 ` H.J. Lu
0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2021-01-24 4:16 UTC (permalink / raw)
To: Alan Modra; +Cc: Binutils, Mark Wielaard, Nick Clifton
On Sat, Jan 23, 2021 at 5:34 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Sat, Jan 23, 2021 at 03:29:35PM -0800, H.J. Lu wrote:
> > Advance rngs_ptr when parsing DW_RLE_offset_pair, which was missing in
> >
> > commit c3757b583d2448a5996e83e374fb96ac7938da35
> > Author: Mark Wielaard <mark@klomp.org>
> > Date: Tue Aug 25 15:33:00 2020 +0100
> >
> > Fix the linker's handling of DWARF-5 line number tables.
> >
> > PR binutils/27231
> > * dwarf2.c (read_rnglists): Advance rngs_ptr after
> > _bfd_safe_read_leb128 when parsing DW_RLE_offset_pair.
>
> OK everywhere.
>
This patch is also needed to skip empty ranges in DWARF-5 line
number tables generated by GCC 11.
OK for master?
--
H.J.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] DWARF-5: Skip empty range in DWARF-5 line number tables
2021-01-24 4:16 ` [PATCH] DWARF-5: Skip empty range in " H.J. Lu
@ 2021-01-24 11:58 ` H.J. Lu
2021-01-24 14:11 ` [PATCH] DWARF-5: Ignore " H.J. Lu
0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2021-01-24 11:58 UTC (permalink / raw)
To: Alan Modra; +Cc: Binutils, Mark Wielaard, Nick Clifton
[-- Attachment #1: Type: text/plain, Size: 897 bytes --]
On Sat, Jan 23, 2021 at 8:16 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sat, Jan 23, 2021 at 5:34 PM Alan Modra <amodra@gmail.com> wrote:
> >
> > On Sat, Jan 23, 2021 at 03:29:35PM -0800, H.J. Lu wrote:
> > > Advance rngs_ptr when parsing DW_RLE_offset_pair, which was missing in
> > >
> > > commit c3757b583d2448a5996e83e374fb96ac7938da35
> > > Author: Mark Wielaard <mark@klomp.org>
> > > Date: Tue Aug 25 15:33:00 2020 +0100
> > >
> > > Fix the linker's handling of DWARF-5 line number tables.
> > >
> > > PR binutils/27231
> > > * dwarf2.c (read_rnglists): Advance rngs_ptr after
> > > _bfd_safe_read_leb128 when parsing DW_RLE_offset_pair.
> >
> > OK everywhere.
> >
>
> This patch is also needed to skip empty ranges in DWARF-5 line
> number tables generated by GCC 11.
>
> OK for master?
Here is the real patch. OK for master and 2.36/2.35 branches?
--
H.J.
[-- Attachment #2: 0001-DWARF-5-Skip-empty-range-in-DWARF-5-line-number-tabl.patch --]
[-- Type: text/x-patch, Size: 1957 bytes --]
From 543a13baa20bf3b567d4c9310524b386b5e850dd Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 23 Jan 2021 20:09:38 -0800
Subject: [PATCH] DWARF-5: Skip empty range in DWARF-5 line number tables
There is nothing special about 0 low or high pc or low_pc == high_pc in
.debug_rnglists. The list termination is DW_RLE_end_of_list. GCC 11
can generate the following entry in DWARF-5 line number tables:
.LLRL174:
.byte 0x5
.quad .LBB2159
.byte 0x4
.uleb128 .LBB2159-.LBB2159
.uleb128 .LBE2159-.LBB2159
.byte 0x4
.uleb128 .LBB2163-.LBB2159
.uleb128 .LBE2163-.LBB2159
.byte 0x4
.uleb128 .LBB2174-.LBB2159
.uleb128 .LBE2174-.LBB2159
.byte 0
for
.LBB2163:
.LBB2161:
.loc 1 7563 17 is_stmt 1 view .LVU1621
.loc 1 7573 3 view .LVU1622
.loc 1 7573 3 is_stmt 0 view .LVU1623
.LBE2161:
.LBE2163:
.loc 1 7787 3 is_stmt 1 view .LVU1624
.LBB2164:
.loc 1 7789 5 view .LVU1625
.loc 1 7790 5 view .LVU1626
.loc 1 7790 21 is_stmt 0 view .LVU1627
movq -312(%rbp), %rax
movq -336(%rbp), %r15
.LBB2165:
.LBB2163 and .LBE2163 have the same address. Skip such empty range when
parsing DWARF-5 line number tables.
PR binutils/27231
* dwarf2.c (read_rnglists): Skip empty range when parsing line
number tables.
---
bfd/dwarf2.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 292d60c33d4..22254abcd59 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -3289,8 +3289,9 @@ read_rnglists (struct comp_unit *unit, struct arange *arange,
return FALSE;
}
- if ((low_pc == 0 && high_pc == 0) || low_pc == high_pc)
- return FALSE;
+ /* NB: Skip the empty range. */
+ if (low_pc == high_pc)
+ continue;
if (!arange_add (unit, arange, low_pc, high_pc))
return FALSE;
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] DWARF-5: Ignore empty range in DWARF-5 line number tables
2021-01-24 11:58 ` H.J. Lu
@ 2021-01-24 14:11 ` H.J. Lu
0 siblings, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2021-01-24 14:11 UTC (permalink / raw)
To: Alan Modra; +Cc: Binutils, Mark Wielaard, Nick Clifton
[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]
On Sun, Jan 24, 2021 at 3:58 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sat, Jan 23, 2021 at 8:16 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Sat, Jan 23, 2021 at 5:34 PM Alan Modra <amodra@gmail.com> wrote:
> > >
> > > On Sat, Jan 23, 2021 at 03:29:35PM -0800, H.J. Lu wrote:
> > > > Advance rngs_ptr when parsing DW_RLE_offset_pair, which was missing in
> > > >
> > > > commit c3757b583d2448a5996e83e374fb96ac7938da35
> > > > Author: Mark Wielaard <mark@klomp.org>
> > > > Date: Tue Aug 25 15:33:00 2020 +0100
> > > >
> > > > Fix the linker's handling of DWARF-5 line number tables.
> > > >
> > > > PR binutils/27231
> > > > * dwarf2.c (read_rnglists): Advance rngs_ptr after
> > > > _bfd_safe_read_leb128 when parsing DW_RLE_offset_pair.
> > >
> > > OK everywhere.
> > >
> >
> > This patch is also needed to skip empty ranges in DWARF-5 line
> > number tables generated by GCC 11.
> >
> > OK for master?
>
> Here is the real patch. OK for master and 2.36/2.35 branches?
>
Here is the patch I am checking in.
--
H.J.
[-- Attachment #2: 0001-DWARF-5-Ignore-empty-range-in-DWARF-5-line-number-ta.patch --]
[-- Type: text/x-patch, Size: 1093 bytes --]
From b9c5c7f2a7b82dae504c0ffc9a00d82162ec4ba2 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 23 Jan 2021 20:09:38 -0800
Subject: [PATCH] DWARF-5: Ignore empty range in DWARF-5 line number tables
The DWARF5 spec does indeed explicitly say: "A bounded range entry whose
beginning and ending address offsets are equal (including zero) indicates
an empty range and may be ignored."
Since arange_add already ignores empty ranges, remove the whole check
should be equivalent to the check plus explicit continue.
PR binutils/27231
* dwarf2.c (read_rnglists): Ignore empty range when parsing line
number tables.
---
bfd/dwarf2.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 292d60c33d4..240138d5982 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -3289,9 +3289,6 @@ read_rnglists (struct comp_unit *unit, struct arange *arange,
return FALSE;
}
- if ((low_pc == 0 && high_pc == 0) || low_pc == high_pc)
- return FALSE;
-
if (!arange_add (unit, arange, low_pc, high_pc))
return FALSE;
}
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] dwarf5: Fix parsing DWARF-5 line number tables
2021-01-23 23:29 [PATCH] dwarf5: Fix parsing DWARF-5 line number tables H.J. Lu
2021-01-23 23:29 ` H.J. Lu
@ 2021-01-23 23:40 ` Mark Wielaard
1 sibling, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2021-01-23 23:40 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils, Alan Modra, Nick Clifton
Hi,
On Sat, Jan 23, 2021 at 03:29:34PM -0800, H.J. Lu wrote:
> Advance rngs_ptr when parsing DW_RLE_offset_pair, which was missing in
>
> commit c3757b583d2448a5996e83e374fb96ac7938da35
> Author: Mark Wielaard <mark@klomp.org>
> Date: Tue Aug 25 15:33:00 2020 +0100
>
> Fix the linker's handling of DWARF-5 line number tables.
>
> OK for master and 2.36 branch?
I cannot approve binutils patches, but it looks ok to me. No idea how
I missed this because the code does it correct for the other cases.
BTW. It would be nice to also get this on the binutils-2_35-branch an
do a 2.35.2 release for those distros that won't immediately upgrade
to binutils 2.36, but have already upgraded to gcc11 (like Fedora).
Thanks,
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-01-24 14:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-23 23:29 [PATCH] dwarf5: Fix parsing DWARF-5 line number tables H.J. Lu
2021-01-23 23:29 ` H.J. Lu
2021-01-24 1:34 ` Alan Modra
2021-01-24 4:16 ` [PATCH] DWARF-5: Skip empty range in " H.J. Lu
2021-01-24 11:58 ` H.J. Lu
2021-01-24 14:11 ` [PATCH] DWARF-5: Ignore " H.J. Lu
2021-01-23 23:40 ` [PATCH] dwarf5: Fix parsing " Mark Wielaard
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).