Commit a029baa4065c9a08c7118a8f96edf84e7d3fcfe1

Authored by ths
1 parent b6783839

Restore OS X build (plus code reformatting).


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3081 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 83 additions and 84 deletions
dyngen.c
@@ -2005,91 +2005,90 @@ void gen_code(const char *name, host_ulong offset, host_ulong size, @@ -2005,91 +2005,90 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
2005 } 2005 }
2006 } 2006 }
2007 #elif defined(CONFIG_FORMAT_MACH) 2007 #elif defined(CONFIG_FORMAT_MACH)
2008 - struct scattered_relocation_info *scarel;  
2009 - struct relocation_info * rel;  
2010 - char final_sym_name[256];  
2011 - const char *sym_name;  
2012 - const char *p;  
2013 - int slide, sslide;  
2014 - int i;  
2015 -  
2016 - for(i = 0, rel = relocs; i < nb_relocs; i++, rel++) {  
2017 - unsigned int offset, length, value = 0;  
2018 - unsigned int type, pcrel, isym = 0;  
2019 - unsigned int usesym = 0;  
2020 -  
2021 - if(R_SCATTERED & rel->r_address) {  
2022 - scarel = (struct scattered_relocation_info*)rel;  
2023 - offset = (unsigned int)scarel->r_address;  
2024 - length = scarel->r_length;  
2025 - pcrel = scarel->r_pcrel;  
2026 - type = scarel->r_type;  
2027 - value = scarel->r_value;  
2028 - } else {  
2029 - value = isym = rel->r_symbolnum;  
2030 - usesym = (rel->r_extern);  
2031 - offset = rel->r_address;  
2032 - length = rel->r_length;  
2033 - pcrel = rel->r_pcrel;  
2034 - type = rel->r_type;  
2035 - }  
2036 -  
2037 - slide = offset - start_offset;  
2038 -  
2039 - if (!(offset >= start_offset && offset < start_offset + size))  
2040 - continue; /* not in our range */  
2041 -  
2042 - sym_name = get_reloc_name(rel, &sslide);  
2043 -  
2044 - if(usesym && symtab[isym].n_type & N_STAB)  
2045 - continue; /* don't handle STAB (debug sym) */  
2046 -  
2047 - if (sym_name && strstart(sym_name, "__op_jmp", &p)) {  
2048 - int n;  
2049 - n = strtol(p, NULL, 10);  
2050 - fprintf(outfile, " jmp_offsets[%d] = %d + (gen_code_ptr - gen_code_buf);\n",  
2051 - n, slide);  
2052 - continue; /* Nothing more to do */  
2053 - }  
2054 -  
2055 - if(!sym_name)  
2056 - {  
2057 - fprintf(outfile, "/* #warning relocation not handled in %s (value 0x%x, %s, offset 0x%x, length 0x%x, %s, type 0x%x) */\n",  
2058 - relname, value, usesym ? "use sym" : "don't use sym", offset, length, pcrel ? "pcrel":"", type);  
2059 - continue; /* dunno how to handle without final_sym_name */  
2060 - }  
2061 -  
2062 - get_reloc_expr(final_sym_name, sizeof(final_sym_name),  
2063 - sym_name);  
2064 - switch(type) {  
2065 - case PPC_RELOC_BR24:  
2066 - if (!strstart(sym_name,"__op_gen_label",&p)) {  
2067 - fprintf(outfile, "{\n");  
2068 - fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide);  
2069 - fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | ((imm + ((long)%s - (long)gen_code_ptr) + %d) & 0x03fffffc);\n",  
2070 - slide, slide, relname, sslide );  
2071 - fprintf(outfile, "}\n");  
2072 - } else {  
2073 - fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | (((long)%s - (long)gen_code_ptr - %d) & 0x03fffffc);\n",  
2074 - slide, slide, final_sym_name, slide);  
2075 - }  
2076 - break;  
2077 - case PPC_RELOC_HI16:  
2078 - fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d) >> 16;\n",  
2079 - slide, final_sym_name, sslide);  
2080 - break;  
2081 - case PPC_RELOC_LO16:  
2082 - fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d);\n",  
2083 - slide, final_sym_name, sslide); 2008 + struct scattered_relocation_info *scarel;
  2009 + struct relocation_info * rel;
  2010 + char final_sym_name[256];
  2011 + const char *sym_name;
  2012 + const char *p;
  2013 + int slide, sslide;
  2014 + int i;
  2015 +
  2016 + for(i = 0, rel = relocs; i < nb_relocs; i++, rel++) {
  2017 + unsigned int offset, length, value = 0;
  2018 + unsigned int type, pcrel, isym = 0;
  2019 + unsigned int usesym = 0;
  2020 +
  2021 + if(R_SCATTERED & rel->r_address) {
  2022 + scarel = (struct scattered_relocation_info*)rel;
  2023 + offset = (unsigned int)scarel->r_address;
  2024 + length = scarel->r_length;
  2025 + pcrel = scarel->r_pcrel;
  2026 + type = scarel->r_type;
  2027 + value = scarel->r_value;
  2028 + } else {
  2029 + value = isym = rel->r_symbolnum;
  2030 + usesym = (rel->r_extern);
  2031 + offset = rel->r_address;
  2032 + length = rel->r_length;
  2033 + pcrel = rel->r_pcrel;
  2034 + type = rel->r_type;
  2035 + }
  2036 +
  2037 + slide = offset - start_offset;
  2038 +
  2039 + if (!(offset >= start_offset && offset < start_offset + size))
  2040 + continue; /* not in our range */
  2041 +
  2042 + sym_name = get_reloc_name(rel, &sslide);
  2043 +
  2044 + if(usesym && symtab[isym].n_type & N_STAB)
  2045 + continue; /* don't handle STAB (debug sym) */
  2046 +
  2047 + if (sym_name && strstart(sym_name, "__op_jmp", &p)) {
  2048 + int n;
  2049 + n = strtol(p, NULL, 10);
  2050 + fprintf(outfile, " jmp_offsets[%d] = %d + (gen_code_ptr - gen_code_buf);\n",
  2051 + n, slide);
  2052 + continue; /* Nothing more to do */
  2053 + }
  2054 +
  2055 + if(!sym_name) {
  2056 + fprintf(outfile, "/* #warning relocation not handled in %s (value 0x%x, %s, offset 0x%x, length 0x%x, %s, type 0x%x) */\n",
  2057 + name, value, usesym ? "use sym" : "don't use sym", offset, length, pcrel ? "pcrel":"", type);
  2058 + continue; /* dunno how to handle without final_sym_name */
  2059 + }
  2060 +
  2061 + get_reloc_expr(final_sym_name, sizeof(final_sym_name),
  2062 + sym_name);
  2063 + switch(type) {
  2064 + case PPC_RELOC_BR24:
  2065 + if (!strstart(sym_name,"__op_gen_label",&p)) {
  2066 + fprintf(outfile, "{\n");
  2067 + fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide);
  2068 + fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | ((imm + ((long)%s - (long)gen_code_ptr) + %d) & 0x03fffffc);\n",
  2069 + slide, slide, name, sslide);
  2070 + fprintf(outfile, "}\n");
  2071 + } else {
  2072 + fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | (((long)%s - (long)gen_code_ptr - %d) & 0x03fffffc);\n",
  2073 + slide, slide, final_sym_name, slide);
  2074 + }
2084 break; 2075 break;
2085 - case PPC_RELOC_HA16:  
2086 - fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d + 0x8000) >> 16;\n",  
2087 - slide, final_sym_name, sslide);  
2088 - break;  
2089 - default:  
2090 - error("unsupported powerpc relocation (%d)", type);  
2091 - }  
2092 - } 2076 + case PPC_RELOC_HI16:
  2077 + fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d) >> 16;\n",
  2078 + slide, final_sym_name, sslide);
  2079 + break;
  2080 + case PPC_RELOC_LO16:
  2081 + fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d);\n",
  2082 + slide, final_sym_name, sslide);
  2083 + break;
  2084 + case PPC_RELOC_HA16:
  2085 + fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d + 0x8000) >> 16;\n",
  2086 + slide, final_sym_name, sslide);
  2087 + break;
  2088 + default:
  2089 + error("unsupported powerpc relocation (%d)", type);
  2090 + }
  2091 + }
2093 #else 2092 #else
2094 #error unsupport object format 2093 #error unsupport object format
2095 #endif 2094 #endif