coredump:support coredump aligned access registers

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-01-31 21:45:26 +08:00 committed by Xiang Xiao
parent aee17d6cc2
commit 5f4c1721ff
2 changed files with 34 additions and 3 deletions

View File

@ -423,9 +423,34 @@ static void elf_emit_memory(FAR struct elf_dumpinfo_s *cinfo, int memsegs)
for (i = 0; i < memsegs; i++)
{
elf_emit(cinfo, (FAR void *)cinfo->regions[i].start,
cinfo->regions[i].end -
cinfo->regions[i].start);
if (cinfo->regions[i].flags & PF_REGISTER)
{
FAR uintptr_t *start = (FAR uintptr_t *)cinfo->regions[i].start;
FAR uintptr_t *end = (FAR uintptr_t *)cinfo->regions[i].end;
uintptr_t buf[64];
size_t offset = 0;
while (start < end)
{
buf[offset++] = *start++;
if (offset % (sizeof(buf) / sizeof(uintptr_t)) == 0)
{
elf_emit(cinfo, buf, sizeof(buf));
offset = 0;
}
}
if (offset != 0)
{
elf_emit(cinfo, buf, offset * sizeof(uintptr_t));
}
}
else
{
elf_emit(cinfo, (FAR void *)cinfo->regions[i].start,
cinfo->regions[i].end - cinfo->regions[i].start);
}
/* Align to page */

View File

@ -233,6 +233,12 @@
#define PF_X 1 /* Execute */
#define PF_W 2 /* Write */
#define PF_R 4 /* Read */
#define PF_MASKOS 0x0ff00000 /* All bits included in the PF_MASKOS
* mask are reserved for operating system-specific
* semantics.
*/
#define PF_REGISTER 0x00100000 /* Register, need pointer aligned access */
#define PF_MASKPROC 0xf0000000 /* Unspecified */
/* Figure 5-10: Dynamic Array Tags, d_tag */