xref: /openbmc/qemu/contrib/elf2dmp/qemu_elf.h (revision 1c268991b3fe699fee16b1cbb9c6025d334c5b25)
13fa2d384SViktor Prutyanov /*
23fa2d384SViktor Prutyanov  * Copyright (c) 2018 Virtuozzo International GmbH
33fa2d384SViktor Prutyanov  *
43fa2d384SViktor Prutyanov  * This work is licensed under the terms of the GNU GPL, version 2 or later.
53fa2d384SViktor Prutyanov  */
63fa2d384SViktor Prutyanov 
737677d7dSMarkus Armbruster #ifndef ELF2DMP_QEMU_ELF_H
837677d7dSMarkus Armbruster #define ELF2DMP_QEMU_ELF_H
93fa2d384SViktor Prutyanov 
10e53f3466SViktor Prutyanov #include "elf.h"
113fa2d384SViktor Prutyanov 
123fa2d384SViktor Prutyanov typedef struct QEMUCPUSegment {
133fa2d384SViktor Prutyanov     uint32_t selector;
143fa2d384SViktor Prutyanov     uint32_t limit;
153fa2d384SViktor Prutyanov     uint32_t flags;
163fa2d384SViktor Prutyanov     uint32_t pad;
173fa2d384SViktor Prutyanov     uint64_t base;
183fa2d384SViktor Prutyanov } QEMUCPUSegment;
193fa2d384SViktor Prutyanov 
203fa2d384SViktor Prutyanov typedef struct QEMUCPUState {
213fa2d384SViktor Prutyanov     uint32_t version;
223fa2d384SViktor Prutyanov     uint32_t size;
233fa2d384SViktor Prutyanov     uint64_t rax, rbx, rcx, rdx, rsi, rdi, rsp, rbp;
243fa2d384SViktor Prutyanov     uint64_t r8, r9, r10, r11, r12, r13, r14, r15;
253fa2d384SViktor Prutyanov     uint64_t rip, rflags;
263fa2d384SViktor Prutyanov     QEMUCPUSegment cs, ds, es, fs, gs, ss;
273fa2d384SViktor Prutyanov     QEMUCPUSegment ldt, tr, gdt, idt;
283fa2d384SViktor Prutyanov     uint64_t cr[5];
293fa2d384SViktor Prutyanov     uint64_t kernel_gs_base;
303fa2d384SViktor Prutyanov } QEMUCPUState;
313fa2d384SViktor Prutyanov 
323fa2d384SViktor Prutyanov int is_system(QEMUCPUState *s);
333fa2d384SViktor Prutyanov 
343fa2d384SViktor Prutyanov typedef struct QEMU_Elf {
35df7a7556SViktor Prutyanov #ifndef CONFIG_LINUX
36bd4d0da7SViktor Prutyanov     GMappedFile *gmf;
37df7a7556SViktor Prutyanov #endif
383fa2d384SViktor Prutyanov     size_t size;
393fa2d384SViktor Prutyanov     void *map;
403fa2d384SViktor Prutyanov     QEMUCPUState **state;
413fa2d384SViktor Prutyanov     size_t state_nr;
423fa2d384SViktor Prutyanov     int has_kernel_gs_base;
433fa2d384SViktor Prutyanov } QEMU_Elf;
443fa2d384SViktor Prutyanov 
45*49760ccfSAkihiko Odaki bool QEMU_Elf_init(QEMU_Elf *qe, const char *filename);
463fa2d384SViktor Prutyanov void QEMU_Elf_exit(QEMU_Elf *qe);
473fa2d384SViktor Prutyanov 
483fa2d384SViktor Prutyanov Elf64_Phdr *elf64_getphdr(void *map);
493fa2d384SViktor Prutyanov Elf64_Half elf_getphdrnum(void *map);
503fa2d384SViktor Prutyanov 
5158ea30f5SMarkus Armbruster #endif /* ELF2DMP_QEMU_ELF_H */
52