Lines Matching refs:qe
58 static bool init_states(QEMU_Elf *qe) in init_states() argument
60 Elf64_Phdr *phdr = elf64_getphdr(qe->map); in init_states()
74 qe->has_kernel_gs_base = 1; in init_states()
79 end_offset > qe->size) { in init_states()
80 end_offset = qe->size; in init_states()
84 nhdr = (void *)((uint8_t *)qe->map + offset); in init_states()
90 name = (char *)qe->map + offset; in init_states()
96 state = (void *)((uint8_t *)qe->map + offset); in init_states()
113 qe->has_kernel_gs_base = 0; in init_states()
121 qe->state_nr = states->len; in init_states()
122 qe->state = (void *)g_ptr_array_free(states, FALSE); in init_states()
127 static void exit_states(QEMU_Elf *qe) in exit_states() argument
129 g_free(qe->state); in exit_states()
132 static bool check_ehdr(QEMU_Elf *qe) in check_ehdr() argument
134 Elf64_Ehdr *ehdr = qe->map; in check_ehdr()
137 if (sizeof(Elf64_Ehdr) > qe->size) { in check_ehdr()
179 phendoff > qe->size) { in check_ehdr()
187 static bool QEMU_Elf_map(QEMU_Elf *qe, const char *filename) in QEMU_Elf_map() argument
206 qe->size = st.st_size; in QEMU_Elf_map()
208 qe->map = mmap(NULL, qe->size, PROT_READ | PROT_WRITE, in QEMU_Elf_map()
210 if (qe->map == MAP_FAILED) { in QEMU_Elf_map()
222 qe->gmf = g_mapped_file_new(filename, TRUE, &gerr); in QEMU_Elf_map()
229 qe->map = g_mapped_file_get_contents(qe->gmf); in QEMU_Elf_map()
230 qe->size = g_mapped_file_get_length(qe->gmf); in QEMU_Elf_map()
236 static void QEMU_Elf_unmap(QEMU_Elf *qe) in QEMU_Elf_unmap() argument
239 munmap(qe->map, qe->size); in QEMU_Elf_unmap()
241 g_mapped_file_unref(qe->gmf); in QEMU_Elf_unmap()
245 bool QEMU_Elf_init(QEMU_Elf *qe, const char *filename) in QEMU_Elf_init() argument
247 if (!QEMU_Elf_map(qe, filename)) { in QEMU_Elf_init()
251 if (!check_ehdr(qe)) { in QEMU_Elf_init()
253 QEMU_Elf_unmap(qe); in QEMU_Elf_init()
257 if (!init_states(qe)) { in QEMU_Elf_init()
259 QEMU_Elf_unmap(qe); in QEMU_Elf_init()
266 void QEMU_Elf_exit(QEMU_Elf *qe) in QEMU_Elf_exit() argument
268 exit_states(qe); in QEMU_Elf_exit()
269 QEMU_Elf_unmap(qe); in QEMU_Elf_exit()