[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic loader

From: NIIBE Yutaka
Subject: Re: Dynamic loader
Date: Mon, 20 Sep 2004 22:55:59 +0900

On Sun, 19 Sep 2004 12:32:33 +0000
        Marco Gerards <address@hidden> 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;
              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, 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]