From 9e20e8426ff5e81d0d1e3b5aaddf2e906eaf82ce Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Fri, 19 Jan 2007 15:05:20 +0000 Subject: [PATCH] [TOOLS] Avoid void* arithmetic when parsing elf notes. Signed-off-by: Keir Fraser --- tools/libxc/xc_load_elf.c | 10 +++++----- tools/xcutils/readnotes.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/libxc/xc_load_elf.c b/tools/libxc/xc_load_elf.c index 4d7d9823a5..e94a45f977 100644 --- a/tools/libxc/xc_load_elf.c +++ b/tools/libxc/xc_load_elf.c @@ -177,7 +177,7 @@ static unsigned long long xen_guest_numeric( /* * Interface to the Xen ELF notes. */ -#define ELFNOTE_NAME(_n_) ((const void*)(_n_) + sizeof(*(_n_))) +#define ELFNOTE_NAME(_n_) ((const char*)(_n_) + sizeof(*(_n_))) #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3)) #define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3)) @@ -190,7 +190,7 @@ static int is_xen_elfnote_section(const char *image, const Elf_Shdr *shdr) for ( note = (const Elf_Note *)(image + shdr->sh_offset); note < (const Elf_Note *)(image + shdr->sh_offset + shdr->sh_size); - note = ELFNOTE_NEXT(note) ) + note = (const Elf_Note *)ELFNOTE_NEXT(note) ) { if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) ) return 1; @@ -209,7 +209,7 @@ static const Elf_Note *xen_elfnote_lookup( for ( note = (const Elf_Note *)dsi->__elfnote_section; note < (const Elf_Note *)dsi->__elfnote_section_end; - note = ELFNOTE_NEXT(note) ) + note = (const Elf_Note *)ELFNOTE_NEXT(note) ) { if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) ) continue; @@ -338,9 +338,9 @@ static int parseelfimage(const char *image, image + ehdr->e_shoff + (h*ehdr->e_shentsize)); if ( !is_xen_elfnote_section(image, shdr) ) continue; - dsi->__elfnote_section = (const void *)image + shdr->sh_offset; + dsi->__elfnote_section = (const char *)image + shdr->sh_offset; dsi->__elfnote_section_end = - (const void *)image + shdr->sh_offset + shdr->sh_size; + (const char *)image + shdr->sh_offset + shdr->sh_size; break; } diff --git a/tools/xcutils/readnotes.c b/tools/xcutils/readnotes.c index cbd177a88f..f42ce6e622 100644 --- a/tools/xcutils/readnotes.c +++ b/tools/xcutils/readnotes.c @@ -13,7 +13,7 @@ #include -#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_))) +#define ELFNOTE_NAME(_n_) ((char*)(_n_) + sizeof(*(_n_))) #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->n_namesz+3)&~3)) #define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->n_descsz+3)&~3)) -- 2.30.2