This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v12 25/32] Verify the build-id
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 21 Aug 2015 23:23:29 +0200
- Subject: [PATCH v12 25/32] Verify the build-id
- Authentication-results: sourceware.org; auth=none
- References: <20150821212006 dot 6673 dot 35100 dot stgit at host1 dot jankratochvil dot net>
Hi,
now it is possible to filter-out from openp() search files with non-matching
build-id.
Jan
gdb/ChangeLog
2015-08-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* source.c: Include build-id.h.
(file_location_from_filename): Call build_id_verify for the build-id
parameters.
---
0 files changed
diff --git a/gdb/source.c b/gdb/source.c
index 9a38df4..e5684da 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -29,6 +29,7 @@
#include "filestuff.h"
#include "inferior.h"
#include "gdb/fileio.h"
+#include "build-id.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -848,7 +849,7 @@ file_location_from_filename (const char *filename, enum openp_flags opts,
}
}
- if ((opts & OPF_IS_BFD) == 0)
+ if ((build_idsz == 0 || !validate_build_id) && (opts & OPF_IS_BFD) == 0)
{
discard_cleanups (back_to);
return file;
@@ -908,6 +909,27 @@ file_location_from_filename (const char *filename, enum openp_flags opts,
return file;
}
+ if (build_idsz == 0 || !validate_build_id)
+ {
+ gdb_assert ((opts & OPF_IS_BFD) != 0);
+ discard_cleanups (back_to);
+ return file;
+ }
+
+ if (!build_id_verify (file.abfd, build_idsz, build_id))
+ {
+ do_cleanups (back_to);
+ file_location_enoent (&file);
+ return file;
+ }
+
+ if ((opts & OPF_IS_BFD) == 0)
+ {
+ gdb_bfd_unref (file.abfd);
+ file.abfd = NULL;
+ gdb_assert (file.fd != -1);
+ }
+
discard_cleanups (back_to);
return file;
}