qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH v5 4/4] free the memory malloced by load_at(


From: Stuart Yoder
Subject: Re: [Qemu-devel] [RFC PATCH v5 4/4] free the memory malloced by load_at()
Date: Wed, 21 Nov 2012 12:39:52 -0600

On Wed, Nov 21, 2012 at 8:38 AM, Olivia Yin <address@hidden> wrote:
> Signed-off-by: Olivia Yin <address@hidden>
> ---
>  hw/elf_ops.h |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/hw/elf_ops.h b/hw/elf_ops.h
> index b346861..9c76a75 100644
> --- a/hw/elf_ops.h
> +++ b/hw/elf_ops.h
> @@ -178,6 +178,8 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, 
> int fd, int must_swab,
>      s->disas_strtab = str;
>      s->next = syminfos;
>      syminfos = s;
> +    g_free(syms);
> +    g_free(str);
>      g_free(shdr_table);
>      return 0;
>   fail:

Olivia, as Alex pointed out there are references to syms and str in
the struct "s"....so you can't just free those I don't think.

The problem that leaves us with is that on every reset when we call
load_elf() that we re-load and re-malloc space for the symbols.

I think the solution may be to factor out the call to load_symbols()
from load_elf().   It looks like what load_symbols does in the end is
set the variable syminfos to point to the loaded symbol info.

If you factor load_symbols() out then in load_elf_32/64() you would do
something like:
      elf_phy_loader_32/64()
      load_symbols_32/64().

We don't need to be reloading symbols on every reset.

Alex, does that make sense?

Stuart



reply via email to

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