[Bug libdw/26321] Possible bug in dwarf_getlocation
mark at klomp dot org
sourceware-bugzilla@sourceware.org
Thu Jul 30 15:15:47 GMT 2020
https://sourceware.org/bugzilla/show_bug.cgi?id=26321
Mark Wielaard <mark at klomp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mark at klomp dot org
--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
Thanks for reviewing the (existing) code. I had to read the code a couple of
times myself to be convinced it is actually correct. Do the following comments
convince you? Then I'll check them in so the next person doesn't get too
confused:
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index 6fb3ff3d..bca65112 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -162,7 +162,10 @@ dwarf_getlocation_implicit_value (Dwarf_Attribute *attr,
const Dwarf_Op *op,
}
/* DW_AT_data_member_location can be a constant as well as a loclistptr.
- Only data[48] indicate a loclistptr. */
+ Only data[48] indicate a loclistptr. On success returns zero and fills
+ in llbuf (when not NULL) and sets listlen to 1. Returns 1 when this
+ isn't an constant DW_AT_data_member_location offset. Returns -1 and
+ sets dwarf_errno on failure. */
static int
check_constant_offset (Dwarf_Attribute *attr,
Dwarf_Op **llbuf, size_t *listlen)
@@ -667,7 +670,7 @@ dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **llbuf,
size_t *listlen)
int result = check_constant_offset (attr, llbuf, listlen);
if (result != 1)
- return result;
+ return result; /* Either success 0, or -1 to indicate error. */
/* If it has a block form, it's a single location expression.
Except for DW_FORM_data16, which is a 128bit constant. */
@@ -898,6 +901,7 @@ dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr
address,
}
}
+ /* If check_constant_offset is successful, we are done with 1 result. */
int result = check_constant_offset (attr, llbufs, listlens);
if (result != 1)
return result ?: 1;
@@ -989,7 +993,7 @@ dwarf_getlocations (Dwarf_Attribute *attr, ptrdiff_t
offset, Dwarf_Addr *basep,
*endp = -1;
return 1;
}
- return result;
+ return result; /* Something bad, dwarf_errno has been set. */
}
/* We must be looking at a true loclistptr, fetch the initial
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Elfutils-devel
mailing list