Skip to content

Instantly share code, notes, and snippets.

QEMU

When creating a core dump, QEMU uses the function [vma_dump_size] (https://github.com/qemu/qemu/blob/5134cf9b5d3aee4475fe7e1c1c11b093731073cf/linux-user/elfload.c#L4059-L4082) to decide whether a given memory segment is included in the dump. Which it is at liberty to do since the man page states that such advice is only a hint.

/*
 * Calculate file (dump) size of given memory region.
 */
static size_t vma_dump_size(target_ulong start, target_ulong end,
                            unsigned long flags)
{
 /* The area must be readable. */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <elf.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/procfs.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <linux/elf.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ptrace.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv) {
puts("Hello, World!");
char * first = "/TestUtil";
char * second = "/";
char * third = "xml_pretty_split";
#include <asm/ptrace.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <linux/elf.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <elf.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/procfs.h>