xref: /openbmc/qemu/contrib/elf2dmp/qemu_elf.h (revision 709395f8)
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 
8 #ifndef ELF2DMP_ELF_H
9 #define ELF2DMP_ELF_H
10 
11 #include "elf.h"
12 
13 typedef struct QEMUCPUSegment {
14     uint32_t selector;
15     uint32_t limit;
16     uint32_t flags;
17     uint32_t pad;
18     uint64_t base;
19 } QEMUCPUSegment;
20 
21 typedef struct QEMUCPUState {
22     uint32_t version;
23     uint32_t size;
24     uint64_t rax, rbx, rcx, rdx, rsi, rdi, rsp, rbp;
25     uint64_t r8, r9, r10, r11, r12, r13, r14, r15;
26     uint64_t rip, rflags;
27     QEMUCPUSegment cs, ds, es, fs, gs, ss;
28     QEMUCPUSegment ldt, tr, gdt, idt;
29     uint64_t cr[5];
30     uint64_t kernel_gs_base;
31 } QEMUCPUState;
32 
33 int is_system(QEMUCPUState *s);
34 
35 typedef struct QEMU_Elf {
36     GMappedFile *gmf;
37     size_t size;
38     void *map;
39     QEMUCPUState **state;
40     size_t state_nr;
41     int has_kernel_gs_base;
42 } QEMU_Elf;
43 
44 int QEMU_Elf_init(QEMU_Elf *qe, const char *filename);
45 void QEMU_Elf_exit(QEMU_Elf *qe);
46 
47 Elf64_Phdr *elf64_getphdr(void *map);
48 Elf64_Half elf_getphdrnum(void *map);
49 
50 #endif /* ELF2DMP_ELF_H */
51