From e0cb02569e7caf5ca09b647d6e27dff54ee0eec3 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 5 Jan 2016 16:02:34 +0700 Subject: [PATCH] remove unused tcg_register_jit() and related code --- qemu/tcg/i386/tcg-target.c | 76 ----------- qemu/tcg/tcg.c | 271 ------------------------------------- qemu/translate-all.c | 1 - 3 files changed, 348 deletions(-) diff --git a/qemu/tcg/i386/tcg-target.c b/qemu/tcg/i386/tcg-target.c index cc086497..c6719497 100644 --- a/qemu/tcg/i386/tcg-target.c +++ b/qemu/tcg/i386/tcg-target.c @@ -2331,79 +2331,3 @@ static void tcg_target_init(TCGContext *s) tcg_add_target_add_op_defs(s, x86_op_defs); } - -typedef struct { - DebugFrameHeader h; - uint8_t fde_def_cfa[4]; - uint8_t fde_reg_ofs[14]; -} DebugFrame; - -/* We're expecting a 2 byte uleb128 encoded value. */ -QEMU_BUILD_BUG_ON(FRAME_SIZE >= (1 << 14)); - -#if !defined(__ELF__) - /* Host machine without ELF. */ -#elif TCG_TARGET_REG_BITS == 64 -#define ELF_HOST_MACHINE EM_X86_64 -static const DebugFrame debug_frame = { - .h.cie.len = sizeof(DebugFrameCIE)-4, /* length after .len member */ - .h.cie.id = -1, - .h.cie.version = 1, - .h.cie.code_align = 1, - .h.cie.data_align = 0x78, /* sleb128 -8 */ - .h.cie.return_column = 16, - - /* Total FDE size does not include the "len" member. */ - .h.fde.len = sizeof(DebugFrame) - offsetof(DebugFrame, h.fde.cie_offset), - - .fde_def_cfa = { - 12, 7, /* DW_CFA_def_cfa %rsp, ... */ - (FRAME_SIZE & 0x7f) | 0x80, /* ... uleb128 FRAME_SIZE */ - (FRAME_SIZE >> 7) - }, - .fde_reg_ofs = { - 0x90, 1, /* DW_CFA_offset, %rip, -8 */ - /* The following ordering must match tcg_target_callee_save_regs. */ - 0x86, 2, /* DW_CFA_offset, %rbp, -16 */ - 0x83, 3, /* DW_CFA_offset, %rbx, -24 */ - 0x8c, 4, /* DW_CFA_offset, %r12, -32 */ - 0x8d, 5, /* DW_CFA_offset, %r13, -40 */ - 0x8e, 6, /* DW_CFA_offset, %r14, -48 */ - 0x8f, 7, /* DW_CFA_offset, %r15, -56 */ - } -}; -#else -#define ELF_HOST_MACHINE EM_386 -static const DebugFrame debug_frame = { - .h.cie.len = sizeof(DebugFrameCIE)-4, /* length after .len member */ - .h.cie.id = -1, - .h.cie.version = 1, - .h.cie.code_align = 1, - .h.cie.data_align = 0x7c, /* sleb128 -4 */ - .h.cie.return_column = 8, - - /* Total FDE size does not include the "len" member. */ - .h.fde.len = sizeof(DebugFrame) - offsetof(DebugFrame, h.fde.cie_offset), - - .fde_def_cfa = { - 12, 4, /* DW_CFA_def_cfa %esp, ... */ - (FRAME_SIZE & 0x7f) | 0x80, /* ... uleb128 FRAME_SIZE */ - (FRAME_SIZE >> 7) - }, - .fde_reg_ofs = { - 0x88, 1, /* DW_CFA_offset, %eip, -4 */ - /* The following ordering must match tcg_target_callee_save_regs. */ - 0x85, 2, /* DW_CFA_offset, %ebp, -8 */ - 0x83, 3, /* DW_CFA_offset, %ebx, -12 */ - 0x86, 4, /* DW_CFA_offset, %esi, -16 */ - 0x87, 5, /* DW_CFA_offset, %edi, -20 */ - } -}; -#endif - -#if defined(ELF_HOST_MACHINE) -void tcg_register_jit(void *buf, size_t buf_size) -{ - tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); -} -#endif diff --git a/qemu/tcg/tcg.c b/qemu/tcg/tcg.c index f7958553..ee340d36 100644 --- a/qemu/tcg/tcg.c +++ b/qemu/tcg/tcg.c @@ -2685,274 +2685,3 @@ void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf) cpu_fprintf(f, "[TCG profiler not compiled]\n"); } #endif - -#ifdef ELF_HOST_MACHINE -/* In order to use this feature, the backend needs to do three things: - - (1) Define ELF_HOST_MACHINE to indicate both what value to - put into the ELF image and to indicate support for the feature. - - (2) Define tcg_register_jit. This should create a buffer containing - the contents of a .debug_frame section that describes the post- - prologue unwind info for the tcg machine. - - (3) Call tcg_register_jit_int, with the constructed .debug_frame. -*/ - -/* Begin GDB interface. THE FOLLOWING MUST MATCH GDB DOCS. */ -typedef enum { - JIT_NOACTION = 0, - JIT_REGISTER_FN, - JIT_UNREGISTER_FN -} jit_actions_t; - -struct jit_code_entry { - struct jit_code_entry *next_entry; - struct jit_code_entry *prev_entry; - const void *symfile_addr; - uint64_t symfile_size; -}; - -struct jit_descriptor { - uint32_t version; - uint32_t action_flag; - struct jit_code_entry *relevant_entry; - struct jit_code_entry *first_entry; -}; - -void __jit_debug_register_code(void) __attribute__((noinline)); -void __jit_debug_register_code(void) -{ - asm(""); -} - -/* Must statically initialize the version, because GDB may check - the version before we can set it. */ -struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 }; - -/* End GDB interface. */ - -static int find_string(const char *strtab, const char *str) -{ - const char *p = strtab + 1; - - while (1) { - if (strcmp(p, str) == 0) { - return p - strtab; - } - p += strlen(p) + 1; - } -} - -static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, - const void *debug_frame, - size_t debug_frame_size) -{ - struct __attribute__((packed)) DebugInfo { - uint32_t len; - uint16_t version; - uint32_t abbrev; - uint8_t ptr_size; - uint8_t cu_die; - uint16_t cu_lang; - uintptr_t cu_low_pc; - uintptr_t cu_high_pc; - uint8_t fn_die; - char fn_name[16]; - uintptr_t fn_low_pc; - uintptr_t fn_high_pc; - uint8_t cu_eoc; - }; - - struct ElfImage { - ElfW(Ehdr) ehdr; - ElfW(Phdr) phdr; - ElfW(Shdr) shdr[7]; - ElfW(Sym) sym[2]; - struct DebugInfo di; - uint8_t da[24]; - char str[80]; - }; - - struct ElfImage *img; - - static const struct ElfImage img_template = { - .ehdr = { - .e_ident[EI_MAG0] = ELFMAG0, - .e_ident[EI_MAG1] = ELFMAG1, - .e_ident[EI_MAG2] = ELFMAG2, - .e_ident[EI_MAG3] = ELFMAG3, - .e_ident[EI_CLASS] = ELF_CLASS, - .e_ident[EI_DATA] = ELF_DATA, - .e_ident[EI_VERSION] = EV_CURRENT, - .e_type = ET_EXEC, - .e_machine = ELF_HOST_MACHINE, - .e_version = EV_CURRENT, - .e_phoff = offsetof(struct ElfImage, phdr), - .e_shoff = offsetof(struct ElfImage, shdr), - .e_ehsize = sizeof(ElfW(Shdr)), - .e_phentsize = sizeof(ElfW(Phdr)), - .e_phnum = 1, - .e_shentsize = sizeof(ElfW(Shdr)), - .e_shnum = ARRAY_SIZE(img->shdr), - .e_shstrndx = ARRAY_SIZE(img->shdr) - 1, -#ifdef ELF_HOST_FLAGS - .e_flags = ELF_HOST_FLAGS, -#endif -#ifdef ELF_OSABI - .e_ident[EI_OSABI] = ELF_OSABI, -#endif - }, - .phdr = { - .p_type = PT_LOAD, - .p_flags = PF_X, - }, - .shdr = { - [0] = { .sh_type = SHT_NULL }, - /* Trick: The contents of code_gen_buffer are not present in - this fake ELF file; that got allocated elsewhere. Therefore - we mark .text as SHT_NOBITS (similar to .bss) so that readers - will not look for contents. We can record any address. */ - [1] = { /* .text */ - .sh_type = SHT_NOBITS, - .sh_flags = SHF_EXECINSTR | SHF_ALLOC, - }, - [2] = { /* .debug_info */ - .sh_type = SHT_PROGBITS, - .sh_offset = offsetof(struct ElfImage, di), - .sh_size = sizeof(struct DebugInfo), - }, - [3] = { /* .debug_abbrev */ - .sh_type = SHT_PROGBITS, - .sh_offset = offsetof(struct ElfImage, da), - .sh_size = sizeof(img->da), - }, - [4] = { /* .debug_frame */ - .sh_type = SHT_PROGBITS, - .sh_offset = sizeof(struct ElfImage), - }, - [5] = { /* .symtab */ - .sh_type = SHT_SYMTAB, - .sh_offset = offsetof(struct ElfImage, sym), - .sh_size = sizeof(img->sym), - .sh_info = 1, - .sh_link = ARRAY_SIZE(img->shdr) - 1, - .sh_entsize = sizeof(ElfW(Sym)), - }, - [6] = { /* .strtab */ - .sh_type = SHT_STRTAB, - .sh_offset = offsetof(struct ElfImage, str), - .sh_size = sizeof(img->str), - } - }, - .sym = { - [1] = { /* code_gen_buffer */ - .st_info = ELF_ST_INFO(STB_GLOBAL, STT_FUNC), - .st_shndx = 1, - } - }, - .di = { - .len = sizeof(struct DebugInfo) - 4, - .version = 2, - .ptr_size = sizeof(void *), - .cu_die = 1, - .cu_lang = 0x8001, /* DW_LANG_Mips_Assembler */ - .fn_die = 2, - .fn_name = "code_gen_buffer" - }, - .da = { - 1, /* abbrev number (the cu) */ - 0x11, 1, /* DW_TAG_compile_unit, has children */ - 0x13, 0x5, /* DW_AT_language, DW_FORM_data2 */ - 0x11, 0x1, /* DW_AT_low_pc, DW_FORM_addr */ - 0x12, 0x1, /* DW_AT_high_pc, DW_FORM_addr */ - 0, 0, /* end of abbrev */ - 2, /* abbrev number (the fn) */ - 0x2e, 0, /* DW_TAG_subprogram, no children */ - 0x3, 0x8, /* DW_AT_name, DW_FORM_string */ - 0x11, 0x1, /* DW_AT_low_pc, DW_FORM_addr */ - 0x12, 0x1, /* DW_AT_high_pc, DW_FORM_addr */ - 0, 0, /* end of abbrev */ - 0 /* no more abbrev */ - }, - .str = "\0" ".text\0" ".debug_info\0" ".debug_abbrev\0" - ".debug_frame\0" ".symtab\0" ".strtab\0" "code_gen_buffer", - }; - - /* We only need a single jit entry; statically allocate it. */ - static struct jit_code_entry one_entry; - - uintptr_t buf = (uintptr_t)buf_ptr; - size_t img_size = sizeof(struct ElfImage) + debug_frame_size; - DebugFrameHeader *dfh; - - img = g_malloc(img_size); - *img = img_template; - - img->phdr.p_vaddr = buf; - img->phdr.p_paddr = buf; - img->phdr.p_memsz = buf_size; - - img->shdr[1].sh_name = find_string(img->str, ".text"); - img->shdr[1].sh_addr = buf; - img->shdr[1].sh_size = buf_size; - - img->shdr[2].sh_name = find_string(img->str, ".debug_info"); - img->shdr[3].sh_name = find_string(img->str, ".debug_abbrev"); - - img->shdr[4].sh_name = find_string(img->str, ".debug_frame"); - img->shdr[4].sh_size = debug_frame_size; - - img->shdr[5].sh_name = find_string(img->str, ".symtab"); - img->shdr[6].sh_name = find_string(img->str, ".strtab"); - - img->sym[1].st_name = find_string(img->str, "code_gen_buffer"); - img->sym[1].st_value = buf; - img->sym[1].st_size = buf_size; - - img->di.cu_low_pc = buf; - img->di.cu_high_pc = buf + buf_size; - img->di.fn_low_pc = buf; - img->di.fn_high_pc = buf + buf_size; - - dfh = (DebugFrameHeader *)(img + 1); - memcpy(dfh, debug_frame, debug_frame_size); - dfh->fde.func_start = buf; - dfh->fde.func_len = buf_size; - -#ifdef DEBUG_JIT - /* Enable this block to be able to debug the ELF image file creation. - One can use readelf, objdump, or other inspection utilities. */ - { - FILE *f = fopen("/tmp/qemu.jit", "w+b"); - if (f) { - if (fwrite(img, img_size, 1, f) != img_size) { - /* Avoid stupid unused return value warning for fwrite. */ - } - fclose(f); - } - } -#endif - - one_entry.symfile_addr = img; - one_entry.symfile_size = img_size; - - __jit_debug_descriptor.action_flag = JIT_REGISTER_FN; - __jit_debug_descriptor.relevant_entry = &one_entry; - __jit_debug_descriptor.first_entry = &one_entry; - __jit_debug_register_code(); -} -#else -/* No support for the feature. Provide the entry point expected by exec.c, - and implement the internal function we declared earlier. */ - -static void tcg_register_jit_int(void *buf, size_t size, - const void *debug_frame, - size_t debug_frame_size) -{ -} - -void tcg_register_jit(void *buf, size_t buf_size) -{ -} -#endif /* ELF_HOST_MACHINE */ diff --git a/qemu/translate-all.c b/qemu/translate-all.c index 088e7b40..11bbb07b 100644 --- a/qemu/translate-all.c +++ b/qemu/translate-all.c @@ -723,7 +723,6 @@ void tcg_exec_init(struct uc_struct *uc, unsigned long tb_size) tcg_ctx = uc->tcg_ctx; tcg_ctx->code_gen_ptr = tcg_ctx->code_gen_buffer; tcg_ctx->uc = uc; - tcg_register_jit(tcg_ctx->code_gen_buffer, tcg_ctx->code_gen_buffer_size); page_init(); #if !defined(CONFIG_USER_ONLY) || !defined(CONFIG_USE_GUEST_BASE) /* There's no guest base to take into account, so go ahead and