Zero-initialize linux note sections
This patches changes linux-tdep.c so that the buffer used to write note sections when generating a core file is zero-initialized. This way, bytes that are not collected won't contain random data (e.g. padding bytes). gdb/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * linux-tdep.c (linux_collect_regset_section_cb): Use std::vector<gdb_byte> instead of char * and malloc for buf. Remove xfree.
This commit is contained in:
parent
b971899198
commit
afde3032dd
|
@ -1,3 +1,9 @@
|
||||||
|
2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||||
|
|
||||||
|
* linux-tdep.c (linux_collect_regset_section_cb): Use
|
||||||
|
std::vector<gdb_byte> instead of char * and malloc for buf.
|
||||||
|
Remove xfree.
|
||||||
|
|
||||||
2018-10-26 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
|
2018-10-26 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
|
||||||
|
|
||||||
* xcoffread.c (read_xcoff_symtab): Pass deduced language to
|
* xcoffread.c (read_xcoff_symtab): Pass deduced language to
|
||||||
|
|
|
@ -1584,7 +1584,6 @@ linux_collect_regset_section_cb (const char *sect_name, int supply_size,
|
||||||
int collect_size, const struct regset *regset,
|
int collect_size, const struct regset *regset,
|
||||||
const char *human_name, void *cb_data)
|
const char *human_name, void *cb_data)
|
||||||
{
|
{
|
||||||
char *buf;
|
|
||||||
struct linux_collect_regset_section_cb_data *data
|
struct linux_collect_regset_section_cb_data *data
|
||||||
= (struct linux_collect_regset_section_cb_data *) cb_data;
|
= (struct linux_collect_regset_section_cb_data *) cb_data;
|
||||||
bool variable_size_section = (regset != NULL
|
bool variable_size_section = (regset != NULL
|
||||||
|
@ -1598,19 +1597,22 @@ linux_collect_regset_section_cb (const char *sect_name, int supply_size,
|
||||||
|
|
||||||
gdb_assert (regset && regset->collect_regset);
|
gdb_assert (regset && regset->collect_regset);
|
||||||
|
|
||||||
buf = (char *) xmalloc (collect_size);
|
/* This is intentionally zero-initialized by using std::vector, so
|
||||||
regset->collect_regset (regset, data->regcache, -1, buf, collect_size);
|
that any padding bytes in the core file will show as 0. */
|
||||||
|
std::vector<gdb_byte> buf (collect_size);
|
||||||
|
|
||||||
|
regset->collect_regset (regset, data->regcache, -1, buf.data (),
|
||||||
|
collect_size);
|
||||||
|
|
||||||
/* PRSTATUS still needs to be treated specially. */
|
/* PRSTATUS still needs to be treated specially. */
|
||||||
if (strcmp (sect_name, ".reg") == 0)
|
if (strcmp (sect_name, ".reg") == 0)
|
||||||
data->note_data = (char *) elfcore_write_prstatus
|
data->note_data = (char *) elfcore_write_prstatus
|
||||||
(data->obfd, data->note_data, data->note_size, data->lwp,
|
(data->obfd, data->note_data, data->note_size, data->lwp,
|
||||||
gdb_signal_to_host (data->stop_signal), buf);
|
gdb_signal_to_host (data->stop_signal), buf.data ());
|
||||||
else
|
else
|
||||||
data->note_data = (char *) elfcore_write_register_note
|
data->note_data = (char *) elfcore_write_register_note
|
||||||
(data->obfd, data->note_data, data->note_size,
|
(data->obfd, data->note_data, data->note_size,
|
||||||
sect_name, buf, collect_size);
|
sect_name, buf.data (), collect_size);
|
||||||
xfree (buf);
|
|
||||||
|
|
||||||
if (data->note_data == NULL)
|
if (data->note_data == NULL)
|
||||||
data->abort_iteration = 1;
|
data->abort_iteration = 1;
|
||||||
|
|
Loading…
Reference in New Issue