|
|
689258 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
689258 |
From: Keith Seitz <keiths@redhat.com>
|
|
|
689258 |
Date: Fri, 11 Jan 2019 17:02:13 -0500
|
|
|
689258 |
Subject: gdb-rhbz1187581-power8-regs-not-in-8.2-03of15.patch
|
|
|
689258 |
|
|
|
689258 |
;; Zero-initialize linux note sections
|
|
|
689258 |
;; Pedro Franco de Carvalho, RH BZ 1187581
|
|
|
689258 |
|
|
|
689258 |
Zero-initialize linux note sections
|
|
|
689258 |
|
|
|
689258 |
This patches changes linux-tdep.c so that the buffer used to write
|
|
|
689258 |
note sections when generating a core file is zero-initialized. This
|
|
|
689258 |
way, bytes that are not collected won't contain random
|
|
|
689258 |
data (e.g. padding bytes).
|
|
|
689258 |
|
|
|
689258 |
gdb/ChangeLog:
|
|
|
689258 |
2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
|
|
689258 |
|
|
|
689258 |
* linux-tdep.c (linux_collect_regset_section_cb): Use
|
|
|
689258 |
std::vector<gdb_byte> instead of char * and malloc for buf.
|
|
|
689258 |
Remove xfree.
|
|
|
689258 |
|
|
|
689258 |
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
|
|
|
689258 |
--- a/gdb/linux-tdep.c
|
|
|
689258 |
+++ b/gdb/linux-tdep.c
|
|
|
689258 |
@@ -1584,7 +1584,6 @@ linux_collect_regset_section_cb (const char *sect_name, int supply_size,
|
|
|
689258 |
int collect_size, const struct regset *regset,
|
|
|
689258 |
const char *human_name, void *cb_data)
|
|
|
689258 |
{
|
|
|
689258 |
- char *buf;
|
|
|
689258 |
struct linux_collect_regset_section_cb_data *data
|
|
|
689258 |
= (struct linux_collect_regset_section_cb_data *) cb_data;
|
|
|
689258 |
bool variable_size_section = (regset != NULL
|
|
|
689258 |
@@ -1598,19 +1597,22 @@ linux_collect_regset_section_cb (const char *sect_name, int supply_size,
|
|
|
689258 |
|
|
|
689258 |
gdb_assert (regset && regset->collect_regset);
|
|
|
689258 |
|
|
|
689258 |
- buf = (char *) xmalloc (collect_size);
|
|
|
689258 |
- regset->collect_regset (regset, data->regcache, -1, buf, collect_size);
|
|
|
689258 |
+ /* This is intentionally zero-initialized by using std::vector, so
|
|
|
689258 |
+ that any padding bytes in the core file will show as 0. */
|
|
|
689258 |
+ std::vector<gdb_byte> buf (collect_size);
|
|
|
689258 |
+
|
|
|
689258 |
+ regset->collect_regset (regset, data->regcache, -1, buf.data (),
|
|
|
689258 |
+ collect_size);
|
|
|
689258 |
|
|
|
689258 |
/* PRSTATUS still needs to be treated specially. */
|
|
|
689258 |
if (strcmp (sect_name, ".reg") == 0)
|
|
|
689258 |
data->note_data = (char *) elfcore_write_prstatus
|
|
|
689258 |
(data->obfd, data->note_data, data->note_size, data->lwp,
|
|
|
689258 |
- gdb_signal_to_host (data->stop_signal), buf);
|
|
|
689258 |
+ gdb_signal_to_host (data->stop_signal), buf.data ());
|
|
|
689258 |
else
|
|
|
689258 |
data->note_data = (char *) elfcore_write_register_note
|
|
|
689258 |
(data->obfd, data->note_data, data->note_size,
|
|
|
689258 |
- sect_name, buf, collect_size);
|
|
|
689258 |
- xfree (buf);
|
|
|
689258 |
+ sect_name, buf.data (), collect_size);
|
|
|
689258 |
|
|
|
689258 |
if (data->note_data == NULL)
|
|
|
689258 |
data->abort_iteration = 1;
|