From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmFDj-0006p5-6L for qemu-devel@nongnu.org; Tue, 03 Jul 2012 22:21:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmFDh-0006MZ-7u for qemu-devel@nongnu.org; Tue, 03 Jul 2012 22:21:34 -0400 Received: from [222.73.24.84] (port=36795 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmFDg-0006MI-Qj for qemu-devel@nongnu.org; Tue, 03 Jul 2012 22:21:33 -0400 Message-ID: <4FF3A9AF.4070001@cn.fujitsu.com> Date: Wed, 04 Jul 2012 10:25:51 +0800 From: Wen Congyang MIME-Version: 1.0 References: <1340213303-596-1-git-send-email-rabin@rab.in> <1340213303-596-3-git-send-email-rabin@rab.in> In-Reply-To: <1340213303-596-3-git-send-email-rabin@rab.in> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] [PATCH 3/4] dump: extract out get note size function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Rabin Vincent Cc: qemu-devel@nongnu.org At 06/21/2012 01:28 AM, Rabin Vincent Wrote: > Extract out the ELF note size function from i386 so we can use it from > other targets. > > Signed-off-by: Rabin Vincent This patch looks fine to me. Thanks Wen Congyang > --- > dump.c | 15 +++++++++++++++ > dump.h | 2 ++ > target-i386/arch_dump.c | 14 ++------------ > 3 files changed, 19 insertions(+), 12 deletions(-) > > diff --git a/dump.c b/dump.c > index be96c6c..d3ca953 100644 > --- a/dump.c > +++ b/dump.c > @@ -468,6 +468,21 @@ static target_phys_addr_t get_offset(target_phys_addr_t phys_addr, > return -1; > } > > +size_t dump_get_note_size(int class, const char *name, size_t descsz) > +{ > + int name_size = strlen(name) + 1; > + int note_head_size; > + > + if (class == ELFCLASS32) { > + note_head_size = sizeof(Elf32_Nhdr); > + } else { > + note_head_size = sizeof(Elf64_Nhdr); > + } > + > + return ((note_head_size + 3) / 4 + (name_size + 3) / 4 > + + (descsz + 3) / 4) * 4; > +} > + > int dump_write_elf_note(int class, const char *name, uint32_t type, > void *desc, size_t descsz, > write_core_dump_function f, void *opaque) > diff --git a/dump.h b/dump.h > index b07816a..a06b149 100644 > --- a/dump.h > +++ b/dump.h > @@ -36,4 +36,6 @@ int dump_write_elf_note(int class, const char *name, uint32_t type, void *desc, > size_t descsz, write_core_dump_function f, > void *opaque); > > +size_t dump_get_note_size(int class, const char *name, size_t descsz); > + > #endif > diff --git a/target-i386/arch_dump.c b/target-i386/arch_dump.c > index dbc94bc..e2d18a0 100644 > --- a/target-i386/arch_dump.c > +++ b/target-i386/arch_dump.c > @@ -305,18 +305,10 @@ int cpu_get_dump_info(ArchDumpInfo *info) > > ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) > { > - int name_size = 5; /* "CORE" or "QEMU" */ > size_t elf_note_size = 0; > size_t qemu_note_size = 0; > int elf_desc_size = 0; > int qemu_desc_size = 0; > - int note_head_size; > - > - if (class == ELFCLASS32) { > - note_head_size = sizeof(Elf32_Nhdr); > - } else { > - note_head_size = sizeof(Elf64_Nhdr); > - } > > if (machine == EM_386) { > elf_desc_size = sizeof(x86_elf_prstatus); > @@ -328,10 +320,8 @@ ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) > #endif > qemu_desc_size = sizeof(QEMUCPUState); > > - elf_note_size = ((note_head_size + 3) / 4 + (name_size + 3) / 4 + > - (elf_desc_size + 3) / 4) * 4; > - qemu_note_size = ((note_head_size + 3) / 4 + (name_size + 3) / 4 + > - (qemu_desc_size + 3) / 4) * 4; > + elf_note_size = dump_get_note_size(class, "CORE", elf_desc_size); > + qemu_note_size = dump_get_note_size(class, "QEMU", qemu_desc_size); > > return (elf_note_size + qemu_note_size) * nr_cpus; > }