From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvW5N-0001w9-CK for qemu-devel@nongnu.org; Thu, 09 Feb 2012 10:39:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvW5I-0002WG-Ja for qemu-devel@nongnu.org; Thu, 09 Feb 2012 10:39:01 -0500 Received: from fmmailgate04.web.de ([217.72.192.242]:42286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvW5I-0002W5-AL for qemu-devel@nongnu.org; Thu, 09 Feb 2012 10:38:56 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate04.web.de (Postfix) with ESMTP id 1B6F9713FB84 for ; Thu, 9 Feb 2012 16:38:55 +0100 (CET) From: Goswin von Brederlow References: <201202090035.12216.paul@codesourcery.com> <87liocqhn7.fsf@frosties.localnet> <201202091336.36127.paul@codesourcery.com> Date: Thu, 09 Feb 2012 16:38:50 +0100 In-Reply-To: <201202091336.36127.paul@codesourcery.com> (Paul Brook's message of "Thu, 9 Feb 2012 13:36:35 +0000") Message-ID: <87zkcsnhit.fsf@frosties.localnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] Support for multiboot images in elf64 (EM_X86_64) format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, Goswin von Brederlow Paul Brook writes: >> Paul Brook writes: >> >> > starting your own toy kernel is a fun thing to do and there are many >> >> > tutorials out there on how to do it. Unfortunately when one wants to >> >> > write a kernel in 64bit it becomes much harder because one can't >> >> > compile 64bit code as elf32 image and converting a elf64 image to >> >> > elf32 format is a major hassle and looses debug information and >> >> > symbols. >> > >> > So just have two versions of your image: >> > - The elf64 image that has debug info, symbols, etc. Point gdb at this. >> > - An elf32 image that you give to the bootloader (in this case kvm) >> > >> > Generating the latter from the former is a trivial objcopy invocation. >> >> Is it? I tried for a while and couldn't figure it out. I checked how >> linux does it and it does quite a dance to achieve it. > > "objcopy -I elf64-x86-64 -O elf32-i386 64.elf 32.elf" worked for me. > Relocations get a bit confused, but you shouldn't have relocations in your > multiboot images to start with. Why no relocations? Isn't exactly that the advantage of building an elf image, that you can build a relocatable image? I do remeber getting errors because x86_32_RELOC or something couldn't be mapped to elf32-i386 output format. Can't reproduce it now though. Your line above seems to work on my minimal hello-world kernel. > Linux is a bit special because it has its own boot protocol. AFAIK it can't be > used as a regular multiboot image directly, you need to add a wrapper (i.e. a > secondary bootloader). > > Paul I noticed. I quickly gave up using the linux kernel and build system as reference for a simple toy kernel. MfG Goswin