+2019-01-16 Mark Wielaard <mark@klomp.org>
+
+ * linux-core-attach.c (core_next_thread): Pass desc to ebl_core_note.
+ (core_set_initial_registers): Likewise.
+
2018-10-23 Mark Wielaard <mark@klomp.org>
* relocate.c (relocate_section): Only sanity check mmapped Elf files
const Ebl_Register_Location *reglocs;
size_t nitems;
const Ebl_Core_Item *items;
- if (! ebl_core_note (core_arg->ebl, &nhdr, name,
+ if (! ebl_core_note (core_arg->ebl, &nhdr, name, desc,
®s_offset, &nregloc, ®locs, &nitems, &items))
{
/* This note may be just not recognized, skip it. */
const Ebl_Register_Location *reglocs;
size_t nitems;
const Ebl_Core_Item *items;
- int core_note_err = ebl_core_note (core_arg->ebl, &nhdr, name, ®s_offset,
- &nregloc, ®locs, &nitems, &items);
+ int core_note_err = ebl_core_note (core_arg->ebl, &nhdr, name, desc,
+ ®s_offset, &nregloc, ®locs,
+ &nitems, &items);
/* __libdwfl_attach_state_for_core already verified the note is there. */
assert (core_note_err != 0);
assert (nhdr.n_type == NT_PRSTATUS);
const Ebl_Register_Location *reglocs;
size_t nitems;
const Ebl_Core_Item *items;
- if (! ebl_core_note (ebl, &nhdr, name,
+ if (! ebl_core_note (ebl, &nhdr, name, desc,
®s_offset, &nregloc, ®locs, &nitems, &items))
{
/* This note may be just not recognized, skip it. */
+2019-01-16 Mark Wielaard <mark@klomp.org>
+
+ * libebl.h (ebl_core_note): Add desc as argument.
+ * eblcorenote.c (ebl_core_note): Take desc as an argument, check
+ it contains a zero terminated string if it is an NT_PLATFORM note.
+
2019-01-16 Mark Wielaard <mark@klomp.org>
* eblobjnte.c (ebl_object_note): Check pr_datasz isn't too large.
#include <inttypes.h>
#include <stdio.h>
#include <stddef.h>
+#include <string.h>
#include <libeblP.h>
int
ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, const char *name,
+ const char *desc,
GElf_Word *regs_offset, size_t *nregloc,
const Ebl_Register_Location **reglocs, size_t *nitems,
const Ebl_Core_Item **items)
{
/* The machine specific function did not know this type. */
- *regs_offset = 0;
- *nregloc = 0;
- *reglocs = NULL;
- switch (nhdr->n_type)
+ /* NT_PLATFORM is kind of special since it needs a zero terminated
+ string (other notes often have a fixed size string). */
+ static const Ebl_Core_Item platform[] =
{
-#define ITEMS(type, table) \
- case type: \
- *items = table; \
- *nitems = sizeof table / sizeof table[0]; \
- result = 1; \
- break
+ {
+ .name = "Platform",
+ .type = ELF_T_BYTE, .count = 0, .format = 's'
+ }
+ };
- static const Ebl_Core_Item platform[] =
- {
- {
- .name = "Platform",
- .type = ELF_T_BYTE, .count = 0, .format = 's'
- }
- };
- ITEMS (NT_PLATFORM, platform);
-
-#undef ITEMS
+ if (nhdr->n_type == NT_PLATFORM
+ && memchr (desc, '\0', nhdr->n_descsz) != NULL)
+ {
+ *regs_offset = 0;
+ *nregloc = 0;
+ *reglocs = NULL;
+ *items = platform;
+ *nitems = 1;
+ result = 1;
}
}
/* Describe the format of a core file note with the given header and NAME.
NAME is not guaranteed terminated, it's NHDR->n_namesz raw bytes. */
-extern int ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, const char *name,
+extern int ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr,
+ const char *name, const char *desc,
GElf_Word *regs_offset, size_t *nregloc,
const Ebl_Register_Location **reglocs,
size_t *nitems, const Ebl_Core_Item **items)
+2019-01-16 Mark Wielaard <mark@klomp.org>
+
+ * readelf (handle_core_note): Pass desc to ebl_core_note.
+
2018-11-10 Mark Wielaard <mark@klomp.org>
* elflint.c (check_program_header): Allow PT_GNU_EH_FRAME segment
size_t nitems;
const Ebl_Core_Item *items;
- if (! ebl_core_note (ebl, nhdr, name,
+ if (! ebl_core_note (ebl, nhdr, name, desc,
®s_offset, &nregloc, ®locs, &nitems, &items))
return;