|
From: <sv...@va...> - 2012-12-06 16:27:30
|
sewardj 2012-12-06 16:27:18 +0000 (Thu, 06 Dec 2012)
New Revision: 13160
Log:
When looking for a separate debug object, tolerate mismatched phdrs by
instead checking the shdrs:
The separate .debug file has wrong phdrs. This isn't normally fatal
since .debug files are never directly loaded. But since valgrind
uses the phdrs to locate the build-id it will fail. The attached
patch makes it so that the code falls back to using the shdrs to
locate the NOTE sections so that the buildid can be matched anyway.
Fixes #305431. (Mark Wielaard, mj...@re...)
Modified files:
trunk/coregrind/m_debuginfo/readelf.c
Modified: trunk/coregrind/m_debuginfo/readelf.c (+8 -4)
===================================================================
--- trunk/coregrind/m_debuginfo/readelf.c 2012-12-06 16:05:18 +00:00 (rev 13159)
+++ trunk/coregrind/m_debuginfo/readelf.c 2012-12-06 16:27:18 +00:00 (rev 13160)
@@ -902,7 +902,7 @@
* http://fedoraproject.org/wiki/RolandMcGrath/BuildID
*/
static
-HChar *find_buildid(Addr image, UWord n_image, Bool rel_ok)
+HChar *find_buildid(Addr image, UWord n_image, Bool rel_ok, Bool search_shdrs)
{
HChar* buildid = NULL;
__attribute__((unused)) /* on Android, at least */
@@ -944,7 +944,11 @@
}
}
- if (buildid || !rel_ok)
+ /* Normally we would only search shdrs for ET_REL files, but when
+ we search for a separate .debug file phdrs might not be there
+ (they are never loaded) or have been corrupted, so try again
+ against shdrs. */
+ if (buildid || (!rel_ok && !search_shdrs))
return buildid;
for (i = 0; i < ehdr->e_shnum; i++) {
@@ -1088,7 +1092,7 @@
return 0;
if (buildid) {
- HChar* debug_buildid = find_buildid(sr_Res(sres), *size, rel_ok);
+ HChar* debug_buildid = find_buildid(sr_Res(sres), *size, rel_ok, True);
if (debug_buildid == NULL || VG_(strcmp)(buildid, debug_buildid) != 0) {
SysRes res = VG_(am_munmap_valgrind)(sr_Res(sres), *size);
vg_assert(!sr_isError(res));
@@ -2303,7 +2307,7 @@
vg_assert(dimage == 0 && n_dimage == 0);
/* Look for a build-id */
- buildid = find_buildid(oimage, n_oimage, False);
+ buildid = find_buildid(oimage, n_oimage, False, False);
/* Look for a debug image */
if (buildid != NULL || debuglink_img != NULL) {
|