From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Kcmwo-0001AY-6H for mharc-grub-devel@gnu.org; Mon, 08 Sep 2008 16:02:54 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kcmwm-0001A8-Gr for grub-devel@gnu.org; Mon, 08 Sep 2008 16:02:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kcmwl-00019X-TF for grub-devel@gnu.org; Mon, 08 Sep 2008 16:02:52 -0400 Received: from [199.232.76.173] (port=37152 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kcmwl-00019S-QY for grub-devel@gnu.org; Mon, 08 Sep 2008 16:02:51 -0400 Received: from aybabtu.com ([69.60.117.155]:53909) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kcmwl-00007f-Df for grub-devel@gnu.org; Mon, 08 Sep 2008 16:02:51 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Kcmlv-0001xs-HE; Mon, 08 Sep 2008 21:51:40 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1KcmvC-0000n5-Ch; Mon, 08 Sep 2008 22:01:14 +0200 Date: Mon, 8 Sep 2008 22:01:14 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20080908200114.GA2863@thorin> References: <20080812164829.GD23213@tazenda.kollasch.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="PmA2V3Z32TCmWXqI" Content-Disposition: inline In-Reply-To: <20080812164829.GD23213@tazenda.kollasch.net> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Cc: "Jonathan A. Kollasch" Subject: Re: multiboot ELF section header table info passing missing in grub2? X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Sep 2008 20:02:52 -0000 --PmA2V3Z32TCmWXqI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Aug 12, 2008 at 04:48:29PM +0000, Jonathan A. Kollasch wrote: > hi, > > Robert noted that I should mention this: > > The ELF section header table MBI seems to not be implemented in grub2. > NetBSD/i386 uses this to find symbol names in it's kernel debugger. For the record (Jonathan already knows), I made this patch, which is supposed to implement it using code from GRUB Legacy. It needs some cleanup, but since I have no readily available testcase (NetBSD's kernel seems to have some trouble involving MBI corruption), I can't finish it yet. I'm sending it here for reference. -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." --PmA2V3Z32TCmWXqI Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mb_elf_sym.diff" diff -ur grub2.old/include/grub/multiboot.h grub2/include/grub/multiboot.h --- grub2.old/include/grub/multiboot.h 2008-09-07 19:02:04.000000000 +0200 +++ grub2/include/grub/multiboot.h 2008-09-08 15:35:44.000000000 +0200 @@ -1,7 +1,7 @@ /* multiboot.h - multiboot header file with grub definitions. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2000,2003,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,8 +73,27 @@ grub_uint32_t mods_count; grub_uint32_t mods_addr; - grub_uint32_t syms[4]; - + union + { + struct + { + /* a.out payload symbol table info */ + grub_uint32_t tabsize; + grub_uint32_t strsize; + grub_uint32_t addr; + grub_uint32_t pad; + } aout; + + struct + { + /* ELF payload section header table */ + grub_uint32_t num; + grub_uint32_t size; + grub_uint32_t addr; + grub_uint32_t shndx; + } elf; + } syms; + /* Memory Mapping buffer */ grub_uint32_t mmap_length; grub_uint32_t mmap_addr; diff -ur grub2.old/loader/i386/pc/multiboot.c grub2/loader/i386/pc/multiboot.c --- grub2.old/loader/i386/pc/multiboot.c 2008-09-07 19:03:20.000000000 +0200 +++ grub2/loader/i386/pc/multiboot.c 2008-09-08 15:35:44.000000000 +0200 @@ -21,7 +21,7 @@ * FIXME: The following features from the Multiboot specification still * need to be implemented: * - VBE support - * - symbol table + * - a.out symbol table * - drives table * - ROM configuration table * - APM table @@ -204,6 +204,60 @@ #undef phdr + mbi->syms.elf.num = ehdr->e_shnum; + mbi->syms.elf.size = ehdr->e_shentsize; + mbi->syms.elf.shndx = ehdr->e_shstrndx; + + grub_file_seek (file, ehdr->e_shoff); + + /* FIXME: move to the relocatable block */ + mbi->syms.elf.addr = (grub_uint32_t) grub_malloc (sizeof (Elf32_Shdr) * ehdr->e_shnum); + + /* FIXME: get rid of cur_addr; use proper types? */ + grub_uint32_t cur_addr = mbi->syms.elf.addr; + + grub_file_read (file, (void *) cur_addr, ehdr->e_shentsize * ehdr->e_shnum); + cur_addr += ehdr->e_shentsize * ehdr->e_shnum; + + /* FIXME: does this belong here? */ + grub_printf (", shtab=0x%x\n", cur_addr); + + Elf32_Shdr *shdr = (Elf32_Shdr *) mbi->syms.elf.addr; + + for (i = 0; i < ehdr->e_shnum; i++) + { + /* This section is a loaded section, so we don't care. */ + if (shdr[i].sh_addr != 0) + continue; + + /* This section is empty, so we don't care. */ + if (shdr[i].sh_size == 0) + continue; + + /* Align the section to a sh_addralign bits boundary. */ + cur_addr = ((cur_addr + shdr[i].sh_addralign) & + - (int) shdr[i].sh_addralign); + + grub_file_seek (file, shdr[i].sh_offset); + + /* FIXME: is this useful? */ +#if 0 + if (! (memcheck (cur_addr, shdr[i].sh_size) + && (grub_read ((char *) RAW_ADDR (cur_addr), + shdr[i].sh_size) + == shdr[i].sh_size))) + { + symtab_err = 1; + break; + } +#endif + + shdr[i].sh_addr = cur_addr; + cur_addr += shdr[i].sh_size; + } + + mbi->flags |= MULTIBOOT_INFO_ELF_SHDR; + return grub_errno; } --PmA2V3Z32TCmWXqI--