xref: /openbmc/qemu/contrib/elf2dmp/qemu_elf.h (revision bf616ce4)
1 /*
2  * Copyright (c) 2018 Virtuozzo International GmbH
3  *
4  * This work is licensed under the terms of the GNU GPL, version 2 or later.
5  */
6 
7 #ifndef ELF2DMP_QEMU_ELF_H
8 #define ELF2DMP_QEMU_ELF_H
9 
10 #include "elf.h"
11 
12 typedef struct QEMUCPUSegment {
13     uint32_t selector;
14     uint32_t limit;
15     uint32_t flags;
16     uint32_t pad;
17     uint64_t base;
18 } QEMUCPUSegment;
19 
20 typedef struct QEMUCPUState {
21     uint32_t version;
22     uint32_t size;
23     uint64_t rax, rbx, rcx, rdx, rsi, rdi, rsp, rbp;
24     uint64_t r8, r9, r10, r11, r12, r13, r14, r15;
25     uint64_t rip, rflags;
26     QEMUCPUSegment cs, ds, es, fs, gs, ss;
27     QEMUCPUSegment ldt, tr, gdt, idt;
28     uint64_t cr[5];
29     uint64_t kernel_gs_base;
30 } QEMUCPUState;
31 
32 int is_system(QEMUCPUState *s);
33 
34 typedef struct QEMU_Elf {
35 #ifndef CONFIG_LINUX
36     GMappedFile *gmf;
37 #endif
38     size_t size;
39     void *map;
40     QEMUCPUState **state;
41     size_t state_nr;
42     int has_kernel_gs_base;
43 } QEMU_Elf;
44 
45 bool QEMU_Elf_init(QEMU_Elf *qe, const char *filename);
46 void QEMU_Elf_exit(QEMU_Elf *qe);
47 
48 Elf64_Phdr *elf64_getphdr(void *map);
49 Elf64_Half elf_getphdrnum(void *map);
50 
51 #endif /* ELF2DMP_QEMU_ELF_H */
52