Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1C9OjY-00027r-Ia for mharc-grub-devel@gnu.org; Mon, 20 Sep 2004 10:01:36 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C9OjW-00026e-MD for grub-devel@gnu.org; Mon, 20 Sep 2004 10:01:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C9OjU-00025B-L7 for grub-devel@gnu.org; Mon, 20 Sep 2004 10:01:34 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C9OjU-000256-EZ for grub-devel@gnu.org; Mon, 20 Sep 2004 10:01:32 -0400 Received: from [192.47.44.103] (helo=zanshin.gniibe.org) by monty-python.gnu.org with esmtp (TLSv1:RC4-SHA:128) (Exim 4.34) id 1C9OdA-0005jj-B0 for grub-devel@gnu.org; Mon, 20 Sep 2004 09:55:00 -0400 Received: from ac97.ade3.point.ne.jp ([210.168.162.97] helo=localhost) by zanshin.gniibe.org with asmtp (Exim 4.34) id 1C9Ocz-0004ZS-OA; Mon, 20 Sep 2004 22:54:49 +0900 Date: Mon, 20 Sep 2004 22:55:59 +0900 From: NIIBE Yutaka To: The development of GRUB 2 Message-Id: <20040920225559.2d9cb989.gniibe@m17n.org> In-Reply-To: <87vfeal9r2.fsf@marco.marco-g.com> References: <87vfeal9r2.fsf@marco.marco-g.com> Organization: Free Software Initiative of Japan X-Mailer: Sylpheed version 0.9.12-gtk2-20040617 (GTK+ 2.4.10; i386-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: Dynamic loader 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, 20 Sep 2004 14:01:35 -0000 On Sun, 19 Sep 2004 12:32:33 +0000 Marco Gerards wrote: > In `grub_dl_resolve_symbols' the following things are done: > > In the case STT_FUNC the `sym->st_value' has a valid pointer. After > that the following thing happens: > > sym->st_value += (Elf_Addr) grub_dl_get_section_addr (mod, > sym->st_shndx); > > Another (valid) pointer gets added. This results in an invalid > pointer which is used afterwards. Not checking the ELF specification, here's what I think. There are four values: (1) section address specified in the object file (load module of GRUB2) (2) symbol address specified in the object file (load module of GRUB2) (3) section address in memory (4) symbol address in memory Here, we calculate the value of (4), using the value of (2) and (3). Note that grub_dl_get_section_addr returns (3). In i386, (1) is zero. So, the expression you quoted works fine. In general cases where we cannot assume section address in the object file always starts at zero, it doesn't work. Simple hack would be changing the line of grub_dl_load_segments seg->addr = addr; into seg->addr = addr - s->sh_addr; I think it works. You could try. But it seems for me that this hack is not good, because the name of grub_dl_get_section_addr mismatches. Perhaps, we need to record the value of (1) in the member of struct grub_dl_segment, and use it for the calculation of symbol address. Hope this helps, --