Commit 91aa5d4975eeb996a2d4263e94479f85df124660

Authored by bellard
1 parent 6f2f2b24

Mac OS X fix (Jonas Maebe)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1303 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 13 additions and 10 deletions
dyngen.c
... ... @@ -996,11 +996,11 @@ static const char * get_reloc_name(EXE_RELOC * rel, int * sslide)
996 996  
997 997 switch(rel->r_type)
998 998 {
999   - case PPC_RELOC_LO16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset & 0xffff);
  999 + case PPC_RELOC_LO16: fetch_next_pair_value(rel+1, &other_half); sectoffset |= (other_half << 16);
1000 1000 break;
1001   - case PPC_RELOC_HI16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (other_half & 0xffff);
  1001 + case PPC_RELOC_HI16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset << 16) | (uint16_t)(other_half & 0xffff);
1002 1002 break;
1003   - case PPC_RELOC_HA16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (other_half & 0xffff);
  1003 + case PPC_RELOC_HA16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset << 16) + (int16_t)(other_half & 0xffff);
1004 1004 break;
1005 1005 case PPC_RELOC_BR24:
1006 1006 sectoffset = ( *(uint32_t *)(text + rel->r_address) & 0x03fffffc );
... ... @@ -1146,13 +1146,11 @@ int load_object(const char *filename)
1146 1146  
1147 1147 /* Now transform the symtab, to an extended version, with the sym size, and the C name */
1148 1148 for(i = 0, sym = symtab, syment = symtab_std; i < nb_syms; i++, sym++, syment++) {
1149   - const char *name;
1150 1149 struct nlist *sym_follow, *sym_next = 0;
1151 1150 unsigned int j;
1152   - name = find_str_by_index(sym->n_un.n_strx);
1153 1151 memset(sym, 0, sizeof(*sym));
1154 1152  
1155   - if ( sym->n_type & N_STAB ) /* Debug symbols are skipped */
  1153 + if ( syment->n_type & N_STAB ) /* Debug symbols are skipped */
1156 1154 continue;
1157 1155  
1158 1156 memcpy(sym, syment, sizeof(*syment));
... ... @@ -1848,11 +1846,16 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
1848 1846 sym_name);
1849 1847 switch(type) {
1850 1848 case PPC_RELOC_BR24:
1851   - fprintf(outfile, "{\n");
1852   - fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide);
1853   - 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",
  1849 + if (!strstart(sym_name,"__op_gen_label",&p)) {
  1850 + fprintf(outfile, "{\n");
  1851 + fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide);
  1852 + 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",
1854 1853 slide, slide, name, sslide );
1855   - fprintf(outfile, "}\n");
  1854 + fprintf(outfile, "}\n");
  1855 + } else {
  1856 + fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | (((long)%s - (long)gen_code_ptr - %d) & 0x03fffffc);\n",
  1857 + slide, slide, final_sym_name, slide);
  1858 + }
1856 1859 break;
1857 1860 case PPC_RELOC_HI16:
1858 1861 fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d) >> 16;\n",
... ...