public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix CFI interpretation for locations on DW_CFA_*_loc boundaries
@ 2018-11-01  8:49 Milian Wolff
  2018-11-01  9:12 ` Milian Wolff
  0 siblings, 1 reply; 3+ messages in thread
From: Milian Wolff @ 2018-11-01  8:49 UTC (permalink / raw)
  To: elfutils-devel; +Cc: mark, Milian Wolff

According to the DWARF v3 standard §6.4.3 3., all call frame
instructions up to L1 <= L2 should be interpreted for an FDE.
Elfutils currently only interprets L1 < L2, potentially missing
some instructions when L1 directly points at a DW_CFA_*_loc boundary.

This patch changes the behavior and makes elfutils behave like
libunwind in that regard.
---
 libdw/cfi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libdw/cfi.c b/libdw/cfi.c
index 341e055b..332c6b8b 100644
--- a/libdw/cfi.c
+++ b/libdw/cfi.c
@@ -125,7 +125,7 @@ execute_cfi (Dwarf_CFI *cache,
     fs->regs[regno].value = (r_value);			\
   } while (0)
 
-  while (program < end)
+  while (program <= end)
     {
       uint8_t opcode = *program++;
       Dwarf_Word regno;
-- 
2.19.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix CFI interpretation for locations on DW_CFA_*_loc boundaries
  2018-11-01  8:49 [PATCH] Fix CFI interpretation for locations on DW_CFA_*_loc boundaries Milian Wolff
@ 2018-11-01  9:12 ` Milian Wolff
  2018-11-01 12:32   ` Milian Wolff
  0 siblings, 1 reply; 3+ messages in thread
From: Milian Wolff @ 2018-11-01  9:12 UTC (permalink / raw)
  To: elfutils-devel; +Cc: mark

[-- Attachment #1: Type: text/plain, Size: 1317 bytes --]

Please ignore this patch for now - I only looked at one specific case where 
this changed the behavior to be in line with libunwind. Sadly, it breaks other 
previously working situations. I need to look at this in more detail.

Cheers

On Donnerstag, 1. November 2018 09:48:18 CET Milian Wolff wrote:
> According to the DWARF v3 standard §6.4.3 3., all call frame
> instructions up to L1 <= L2 should be interpreted for an FDE.
> Elfutils currently only interprets L1 < L2, potentially missing
> some instructions when L1 directly points at a DW_CFA_*_loc boundary.
> 
> This patch changes the behavior and makes elfutils behave like
> libunwind in that regard.
> ---
>  libdw/cfi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libdw/cfi.c b/libdw/cfi.c
> index 341e055b..332c6b8b 100644
> --- a/libdw/cfi.c
> +++ b/libdw/cfi.c
> @@ -125,7 +125,7 @@ execute_cfi (Dwarf_CFI *cache,
>      fs->regs[regno].value = (r_value);			\
>    } while (0)
> 
> -  while (program < end)
> +  while (program <= end)
>      {
>        uint8_t opcode = *program++;
>        Dwarf_Word regno;


-- 
Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3826 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix CFI interpretation for locations on DW_CFA_*_loc boundaries
  2018-11-01  9:12 ` Milian Wolff
@ 2018-11-01 12:32   ` Milian Wolff
  0 siblings, 0 replies; 3+ messages in thread
From: Milian Wolff @ 2018-11-01 12:32 UTC (permalink / raw)
  To: elfutils-devel; +Cc: mark

[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]

On Donnerstag, 1. November 2018 10:12:41 CET Milian Wolff wrote:
> Please ignore this patch for now - I only looked at one specific case where
> this changed the behavior to be in line with libunwind. Sadly, it breaks
> other previously working situations. I need to look at this in more detail.

Yep, that patch is indeed utterly broken - please ignore it and excuse the 
noise.

I was apparently very confused by the different access patterns in libunwind 
vs. elfutils. Elfutils is validating every location referenced in the FDE (cf. 
frame_unwind.c:501). Libunwind on the other hand doesn't do this - it only 
accesses the memory to read the location referenced by the return address 
register.

Cheers

> On Donnerstag, 1. November 2018 09:48:18 CET Milian Wolff wrote:
> > According to the DWARF v3 standard §6.4.3 3., all call frame
> > instructions up to L1 <= L2 should be interpreted for an FDE.
> > Elfutils currently only interprets L1 < L2, potentially missing
> > some instructions when L1 directly points at a DW_CFA_*_loc boundary.
> > 
> > This patch changes the behavior and makes elfutils behave like
> > libunwind in that regard.
> > ---
> > 
> >  libdw/cfi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libdw/cfi.c b/libdw/cfi.c
> > index 341e055b..332c6b8b 100644
> > --- a/libdw/cfi.c
> > +++ b/libdw/cfi.c
> > @@ -125,7 +125,7 @@ execute_cfi (Dwarf_CFI *cache,
> > 
> >      fs->regs[regno].value = (r_value);			\
> >    
> >    } while (0)
> > 
> > -  while (program < end)
> > +  while (program <= end)
> > 
> >      {
> >      
> >        uint8_t opcode = *program++;
> >        Dwarf_Word regno;


-- 
Milian Wolff
mail@milianw.de
http://milianw.de

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-01 12:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01  8:49 [PATCH] Fix CFI interpretation for locations on DW_CFA_*_loc boundaries Milian Wolff
2018-11-01  9:12 ` Milian Wolff
2018-11-01 12:32   ` Milian Wolff

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).