From 2b1f76f34301952d06facb48bd46410010da2cf5 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Fri, 20 Feb 2004 17:16:55 +0000 Subject: [PATCH] handle .rodata.cst4, generate HAVE_gen_op_XXX for compile-time detection of synthetic instruction generators available. --- SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen.c | 26 ++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen.c b/SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen.c index 793dd064..17374b52 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen.c +++ b/SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen.c @@ -709,6 +709,7 @@ void gen_code(const char *name, const char *demangled_name, } fprintf(outfile, "))\n"); fprintf(outfile, "#ifdef DYNGEN_IMPL\n"); + fprintf(outfile, "#define HAVE_gen_%s\n", func_name); fprintf(outfile, "{\n"); print_code(outfile, name, p_start + start_offset - offset, copy_size); @@ -1208,6 +1209,9 @@ int load_elf(const char *filename, FILE *outfile, int out_type) elf_shdr *data_sec; uint8_t *data; int data_shndx; + elf_shdr *rodata_cst4_sec; + uint8_t *rodata_cst4 = NULL; + int rodata_cst4_shndx; elf_shdr *rodata_cst16_sec; uint8_t *rodata_cst16 = NULL; int rodata_cst16_shndx; @@ -1281,7 +1285,12 @@ int load_elf(const char *filename, FILE *outfile, int out_type) data_shndx = data_sec - shdr; data = sdata[data_shndx]; - /* data section */ + /* rodata sections */ + rodata_cst4_sec = find_elf_section(shdr, ehdr.e_shnum, shstr, ".rodata.cst4"); + if (rodata_cst4_sec) { + rodata_cst4_shndx = rodata_cst4_sec - shdr; + rodata_cst4 = sdata[rodata_cst4_shndx]; + } rodata_cst16_sec = find_elf_section(shdr, ehdr.e_shnum, shstr, ".rodata.cst16"); if (rodata_cst16_sec) { rodata_cst16_shndx = rodata_cst16_sec - shdr; @@ -1363,11 +1372,18 @@ int load_elf(const char *filename, FILE *outfile, int out_type) } /* emit local symbols */ else if (strstart(name, ".LC", NULL)) { - if (sym->st_shndx != (rodata_cst16_sec - shdr)) + if (sym->st_shndx == (rodata_cst16_sec - shdr)) { + fprintf(outfile, "#ifdef DYNGEN_IMPL\n"); + do_print_code(outfile, gen_dot_prefix(name), rodata_cst16 + sym->st_value, 16); + fprintf(outfile, "#endif\n"); + } + else if (sym->st_shndx == (rodata_cst4_sec - shdr)) { + fprintf(outfile, "#ifdef DYNGEN_IMPL\n"); + do_print_code(outfile, gen_dot_prefix(name), rodata_cst4 + sym->st_value, 4); + fprintf(outfile, "#endif\n"); + } + else error("invalid section for local data %s (%x)\n", name, sym->st_shndx); - fprintf(outfile, "#ifdef DYNGEN_IMPL\n"); - do_print_code(outfile, gen_dot_prefix(name), rodata_cst16 + sym->st_value, 16); - fprintf(outfile, "#endif\n"); } else { /* demangle C++ symbols */