diff --git a/binfmt/libelf/libelf_coredump.c b/binfmt/libelf/libelf_coredump.c index 725992a9ae..f5f5ccd2c4 100644 --- a/binfmt/libelf/libelf_coredump.c +++ b/binfmt/libelf/libelf_coredump.c @@ -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 */ diff --git a/include/elf.h b/include/elf.h index fbd8e5391a..5de67bf2f2 100644 --- a/include/elf.h +++ b/include/elf.h @@ -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 */