qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Stuart Yoder <b08248@gmail.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	Olivia Yin <hong-hua.yin@freescale.com>
Subject: Re: [Qemu-devel] [RFC PATCH v5 4/4] free the memory malloced by load_at()
Date: Wed, 21 Nov 2012 19:41:34 +0100	[thread overview]
Message-ID: <50AD205E.6070501@suse.de> (raw)
In-Reply-To: <CALRxmdCh+Ny5zwUDNQNvBvUBKMqC317_0Zsb68wjL+6i4Jps_A@mail.gmail.com>

On 11/21/2012 07:39 PM, Stuart Yoder wrote:
> On Wed, Nov 21, 2012 at 8:38 AM, Olivia Yin<hong-hua.yin@freescale.com>  wrote:
>> Signed-off-by: Olivia Yin<hong-hua.yin@freescale.com>
>> ---
>>   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?

We can also mandate the caller of load_symbols to free the respective 
data :)


Alex

  reply	other threads:[~2012-11-21 18:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-21  7:38 [Qemu-devel] [RFC PATCH v5 0/4] reload images from host rootfs once reset to save footprint Olivia Yin
2012-11-21  7:38 ` [Qemu-devel] [RFC PATCH v5 1/4] use image_file_reset to reload initrd image Olivia Yin
2012-11-21  7:38 ` [Qemu-devel] [RFC PATCH v5 2/4] use uimage_reset to reload uimage Olivia Yin
2012-11-21  7:38 ` [Qemu-devel] [RFC PATCH v5 3/4] use elf_reset to reload elf image Olivia Yin
2012-11-21  7:38 ` [Qemu-devel] [RFC PATCH v5 4/4] free the memory malloced by load_at() Olivia Yin
2012-11-21 18:39   ` Stuart Yoder
2012-11-21 18:41     ` Alexander Graf [this message]
2012-11-26  1:53       ` Yin Olivia-R63875
2012-11-26 13:03         ` Alexander Graf
2012-11-27  2:11           ` Yin Olivia-R63875

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50AD205E.6070501@suse.de \
    --to=agraf@suse.de \
    --cc=b08248@gmail.com \
    --cc=hong-hua.yin@freescale.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).