Received: from [140.186.70.92] (port=58304 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjFeg-0007R1-54 for qemu-devel@nongnu.org; Wed, 11 Aug 2010 14:04:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjFeb-0003M2-CG for qemu-devel@nongnu.org; Wed, 11 Aug 2010 14:03:57 -0400 Received: from moutng.kundenserver.de ([212.227.17.9]:58672) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjFeb-0003LA-1C for qemu-devel@nongnu.org; Wed, 11 Aug 2010 14:03:53 -0400 Message-ID: <4C62E605.5070000@mail.berlios.de> Date: Wed, 11 Aug 2010 20:03:49 +0200 From: Stefan Weil MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] elf: Calculate symbol size if needed References: <1281365033-6893-1-git-send-email-weil@mail.berlios.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: QEMU Developers Am 11.08.2010 18:21, schrieb Blue Swirl: > On Mon, Aug 9, 2010 at 2:43 PM, Stefan Weil wrote: > >> Symbols with a size of 0 are unusable for the disassembler. >> >> Example: >> >> While running an arm linux kernel, no symbolic names are >> used in qemu.log when the cpu is executing an assembler function. >> > That is a problem of the assembler function, it should use '.size' > directive like what happens when C code is compiled. And why just ARM? > It's not just ARM. ARM is just an example. But I stumbled upon this problem when running the linux start code from arch/arm/kernel/head.S. >> Assume that the size of such symbols is the difference to the >> next symbol value. >> >> Signed-off-by: Stefan Weil >> --- >> hw/elf_ops.h | 5 +++++ >> 1 files changed, 5 insertions(+), 0 deletions(-) >> >> diff --git a/hw/elf_ops.h b/hw/elf_ops.h >> index 27d1ab9..0bd7235 100644 >> --- a/hw/elf_ops.h >> +++ b/hw/elf_ops.h >> @@ -153,6 +153,11 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab, >> syms = qemu_realloc(syms, nsyms * sizeof(*syms)); >> >> qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ)); >> + for (i = 0; i< nsyms - 1; i++) { >> + if (syms[i].st_size == 0) { >> + syms[i].st_size = syms[i + 1].st_value - syms[i].st_value; >> + } >> + } >> > The size of the last symbol is not guesstimated, it could be assumed > to be _etext - syms[nsyms].st_value. > Or better syms[nsyms - 1].st_size = _etext - syms[nsyms - 1].st_value Even that would be wrong if the last symbol is not in the text segment but data. Programming that special case just to get perhaps one last symbol size seems too much perfectionism. Most symbols have a size != 0, so let's hope the last symbol has one, too :-)