Received: from eggs.gnu.org ([140.186.70.92]:50853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvU95-0006ya-9M for qemu-devel@nongnu.org; Thu, 09 Feb 2012 08:34:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvU8z-0007Do-2h for qemu-devel@nongnu.org; Thu, 09 Feb 2012 08:34:43 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:46287) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvTjE-0000oz-HT for qemu-devel@nongnu.org; Thu, 09 Feb 2012 08:08:01 -0500 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate01.web.de (Postfix) with ESMTP id 67EA81AA011E9 for ; Thu, 9 Feb 2012 14:07:58 +0100 (CET) From: Goswin von Brederlow References: <87y5sdejnb.fsf@frosties.localnet> <201202090035.12216.paul@codesourcery.com> Date: Thu, 09 Feb 2012 14:07:56 +0100 In-Reply-To: <201202090035.12216.paul@codesourcery.com> (Paul Brook's message of "Thu, 9 Feb 2012 00:35:11 +0000") Message-ID: <87liocqhn7.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: >> > 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. > The bootloader variant only needs enough information to get the loadable > sections into memory. We don't care about non-resident clutter like debug > info or symbols. Anything that cares about those will be using the full elf64 > image. > > This is all standard practice. I don't think I've never actually used a > system where the image loaded by the target is the same file as the one that > comes out of the linker and is used by the debugger. > >> Yes, this is why I asked about support in other software. If each >> bootloader implements a different custom method then it will be a pain >> to run your binary on real hardware in the future. It's worth at >> least checking their source first - maybe there is already a similar >> code path that we can be compatible with, hence making life easier for >> developers who want to play with 64-bit payloads in multiboot >> executables. > > The whole idea of entering a 64-bit image in 32-bit mode seems distinctly > sketchy. Surely it'd make more sense to define a 64-bit multiboot variant and > do the job properly. > > Paul That will happen in multiboot2 format and is a much larger patch, including a complete new boot rom actualy. I do have patches for that too but there aren't complete yet. I only support the bare minimum of the multiboot2 specs so far. MfG Goswin