Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D2b8k-0008Mh-93 for qemu-devel@nongnu.org; Sat, 19 Feb 2005 15:23:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D2b8Y-0008FS-1o for qemu-devel@nongnu.org; Sat, 19 Feb 2005 15:23:35 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D2b8X-0008DI-Id for qemu-devel@nongnu.org; Sat, 19 Feb 2005 15:23:33 -0500 Received: from [157.193.204.1] (helo=trappist.elis.UGent.be) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D2am0-0005d6-DO for qemu-devel@nongnu.org; Sat, 19 Feb 2005 15:00:16 -0500 Received: from [157.193.206.33] (bigmac.elis.UGent.be [157.193.206.33]) by trappist.elis.UGent.be (8.11.6/8.11.6) with ESMTP id j1JK0C419333 for ; Sat, 19 Feb 2005 21:00:12 +0100 Mime-Version: 1.0 (Apple Message framework v619.2) In-Reply-To: <6a3c367237141a46e9d50c2806a212c0@elis.ugent.be> References: <6a3c367237141a46e9d50c2806a212c0@elis.ugent.be> Content-Type: multipart/mixed; boundary=Apple-Mail-3--460490491 Message-Id: <67020f2e144efbf20ea9d0eb09315239@elis.ugent.be> From: Jonas Maebe Subject: Re: [Qemu-devel] Patch to fix Mac OS X compilation Date: Sat, 19 Feb 2005 21:00:11 +0100 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Apple-Mail-3--460490491 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 13 feb 2005, at 15:30, Jonas Maebe wrote: > Here's a better patch, there were still some errors in my fixes to the > calculation of the relocations. And again a more improved patch (I think). This one includes a special case/hack for Mac OS X for __op_gen_label. Now qemu doesn't crash anymore when trying to boot freedos, but it doesn't show anything either. I just get a black screen. The same goes for reactos, so I guess it's some endless loop while emulating the bios or so. Jonas PS: this patch also contains a (temporary) check to make sure the displacement of the generated jumps for the __op_gen_label stuff isn't > 24 bits, but I haven't seen it getting triggered yet. --Apple-Mail-3--460490491 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="qemu-macosx3.patch" Content-Disposition: attachment; filename=qemu-macosx3.patch Index: dyngen.c =================================================================== RCS file: /cvsroot/qemu/qemu/dyngen.c,v retrieving revision 1.37 diff -u -r1.37 dyngen.c --- dyngen.c 23 Jan 2005 20:42:06 -0000 1.37 +++ dyngen.c 19 Feb 2005 19:54:26 -0000 @@ -996,11 +996,11 @@ switch(rel->r_type) { - case PPC_RELOC_LO16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset & 0xffff); + case PPC_RELOC_LO16: fetch_next_pair_value(rel+1, &other_half); sectoffset |= (other_half << 16); break; - case PPC_RELOC_HI16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (other_half & 0xffff); + case PPC_RELOC_HI16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset << 16) | (uint16_t)(other_half & 0xffff); break; - case PPC_RELOC_HA16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (other_half & 0xffff); + case PPC_RELOC_HA16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset << 16) + (int16_t)(other_half & 0xffff); break; case PPC_RELOC_BR24: sectoffset = ( *(uint32_t *)(text + rel->r_address) & 0x03fffffc ); @@ -1146,13 +1146,11 @@ /* Now transform the symtab, to an extended version, with the sym size, and the C name */ for(i = 0, sym = symtab, syment = symtab_std; i < nb_syms; i++, sym++, syment++) { - const char *name; struct nlist *sym_follow, *sym_next = 0; unsigned int j; - name = find_str_by_index(sym->n_un.n_strx); memset(sym, 0, sizeof(*sym)); - if ( sym->n_type & N_STAB ) /* Debug symbols are skipped */ + if ( syment->n_type & N_STAB ) /* Debug symbols are skipped */ continue; memcpy(sym, syment, sizeof(*syment)); @@ -1848,11 +1846,17 @@ sym_name); switch(type) { case PPC_RELOC_BR24: - fprintf(outfile, "{\n"); - fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide); - 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", + if (!strstart(sym_name,"__op_gen_label",&p)) { + fprintf(outfile, "{\n"); + fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide); + 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", slide, slide, name, sslide ); - fprintf(outfile, "}\n"); + fprintf(outfile, "}\n"); + } else { + fprintf(outfile, " if ( ((((long)%s - (long)gen_code_ptr) + %d) < -(1<<24)) && ((((long)%s - (long)gen_code_ptr) + %d) > ((1<<24) - 1))) { printf(\"relocation > 24 bits\\n\"); }",final_sym_name,sslide,final_sym_name,sslide); + fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | ((((long)%s - (long)gen_code_ptr) + %d) & 0x03fffffc);\n", + slide, slide, final_sym_name, sslide ); + } break; case PPC_RELOC_HI16: fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d) >> 16;\n", Index: osdep.c =================================================================== RCS file: /cvsroot/qemu/qemu/osdep.c,v retrieving revision 1.7 diff -u -r1.7 osdep.c --- osdep.c 10 Feb 2005 21:59:15 -0000 1.7 +++ osdep.c 19 Feb 2005 19:54:26 -0000 @@ -273,7 +273,7 @@ #else -#include +#include int qemu_write(int fd, const void *buf, size_t n) { --Apple-Mail-3--460490491--