aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-01-15 11:06:33 +0000
committerMike Frysinger <vapier@gentoo.org>2010-01-15 11:06:33 +0000
commit2ff9be8bbe8abc7bd07cbf1d91d8315f7494ef57 (patch)
treece7a04731f3738cf2ab9c7de648fc338afd6a71c
parentconvert core pointers to void* to avoid ugly casts and gcc alignment warnings... (diff)
downloadpax-utils-2ff9be8bbe8abc7bd07cbf1d91d8315f7494ef57.tar.gz
pax-utils-2ff9be8bbe8abc7bd07cbf1d91d8315f7494ef57.tar.bz2
pax-utils-2ff9be8bbe8abc7bd07cbf1d91d8315f7494ef57.zip
touchup a few more ->data void points and casts
-rw-r--r--dumpelf.c8
-rw-r--r--paxelf.c14
-rw-r--r--paxelf.h4
-rw-r--r--paxmacho.c8
-rw-r--r--scanmacho.c17
5 files changed, 25 insertions, 26 deletions
diff --git a/dumpelf.c b/dumpelf.c
index 79fdb31..33ab6fd 100644
--- a/dumpelf.c
+++ b/dumpelf.c
@@ -1,13 +1,13 @@
/*
* Copyright 2005-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/dumpelf.c,v 1.26 2010/01/15 10:29:17 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/dumpelf.c,v 1.27 2010/01/15 11:06:33 vapier Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
*/
-static const char *rcsid = "$Id: dumpelf.c,v 1.26 2010/01/15 10:29:17 vapier Exp $";
+static const char *rcsid = "$Id: dumpelf.c,v 1.27 2010/01/15 11:06:33 vapier Exp $";
const char * const argv0 = "dumpelf";
#include "paxinc.h"
@@ -98,7 +98,7 @@ static void dumpelf(const char *filename, long file_cnt)
uint16_t shnum = EGET(ehdr->e_shnum); \
for (i = 0; i < shnum; ++i) { \
if (i) printf(",\n"); \
- dump_shdr(elf, shdr, i, (char*)(elf->data + offset + EGET(shdr->sh_name))); \
+ dump_shdr(elf, shdr, i, elf->vdata + offset + EGET(shdr->sh_name)); \
++shdr; \
} }
DUMP_SHDRS(32)
@@ -195,7 +195,7 @@ static void dump_shdr(elfobj *elf, void *shdr_void, long shdr_cnt, char *name)
printf("\t.sh_addralign = %-10li ,\n", (long)EGET(shdr->sh_addralign)); \
printf("\t.sh_entsize = %-10li\n", (long)EGET(shdr->sh_entsize)); \
if (size && be_verbose) { \
- void *vdata = elf->data + EGET(shdr->sh_offset); \
+ void *vdata = elf->vdata + EGET(shdr->sh_offset); \
unsigned char *data = vdata; \
switch (type) { \
case SHT_PROGBITS: { \
diff --git a/paxelf.c b/paxelf.c
index b8e50c4..bba445b 100644
--- a/paxelf.c
+++ b/paxelf.c
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.67 2009/12/01 10:14:30 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.68 2010/01/15 11:06:33 vapier Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -461,7 +461,7 @@ const char *get_elfshntype(int type)
((buff[EI_CLASS] == ELFCLASS32 || buff[EI_CLASS] == ELFCLASS64) && \
(buff[EI_DATA] == ELFDATA2LSB || buff[EI_DATA] == ELFDATA2MSB) && \
(buff[EI_VERSION] == EV_CURRENT))
-elfobj *readelf_buffer(const char *filename, char *buffer, size_t buffer_len)
+elfobj *readelf_buffer(const char *filename, void *buffer, size_t buffer_len)
{
elfobj *elf;
@@ -502,7 +502,7 @@ free_elf_and_return:
elf->base_filename = elf->base_filename + 1;
elf->elf_class = elf->data[EI_CLASS];
do_reverse_endian = (ELF_DATA != elf->data[EI_DATA]);
- elf->ehdr = (void*)elf->data;
+ elf->ehdr = elf->vdata;
#define READELF_HEADER(B) \
if (elf->elf_class == ELFCLASS ## B) { \
@@ -516,7 +516,7 @@ free_elf_and_return:
else if (EGET(ehdr->e_phentsize) != sizeof(Elf ## B ## _Phdr)) \
invalid = 3; \
else { \
- elf->phdr = elf->data + EGET(ehdr->e_phoff); \
+ elf->phdr = elf->vdata + EGET(ehdr->e_phoff); \
size = EGET(ehdr->e_phnum) * EGET(ehdr->e_phentsize); \
if (elf->phdr < elf->ehdr || /* check overflow */ \
elf->phdr + size < elf->phdr || /* before start of mem */ \
@@ -534,7 +534,7 @@ free_elf_and_return:
else if (EGET(ehdr->e_shentsize) != sizeof(Elf ## B ## _Shdr)) \
invalid = 3; \
else { \
- elf->shdr = elf->data + EGET(ehdr->e_shoff); \
+ elf->shdr = elf->vdata + EGET(ehdr->e_shoff); \
size = EGET(ehdr->e_shnum) * EGET(ehdr->e_shentsize); \
if (elf->shdr < elf->ehdr || /* check overflow */ \
elf->shdr + size < elf->shdr || /* before start of mem */ \
@@ -611,7 +611,7 @@ close_fd_and_return:
/* undo the readelf() stuff */
void unreadelf(elfobj *elf)
{
- if (elf->is_mmap) munmap(elf->data, elf->len);
+ if (elf->is_mmap) munmap(elf->vdata, elf->len);
if (elf->fd != -1) close(elf->fd);
free(elf);
}
@@ -746,7 +746,7 @@ void *elf_findsecbyname(elfobj *elf, const char *name)
if (EGET(shdr[i].sh_offset) >= elf->len - EGET(ehdr->e_shentsize)) continue; \
offset = EGET(strtbl->sh_offset) + EGET(shdr[i].sh_name); \
if (offset >= (Elf ## B ## _Off)elf->len) continue; \
- shdr_name = (char*)(elf->data + offset); \
+ shdr_name = elf->data + offset; \
if (!strcmp(shdr_name, name)) { \
if (ret) warnf("Multiple '%s' sections !?", name); \
ret = (void*)&(shdr[i]); \
diff --git a/paxelf.h b/paxelf.h
index ee353b6..e89fcab 100644
--- a/paxelf.h
+++ b/paxelf.h
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.53 2010/01/15 10:29:17 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.54 2010/01/15 11:06:33 vapier Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -44,7 +44,7 @@ typedef struct {
extern char *pax_short_hf_flags(unsigned long flags);
extern char *pax_short_pf_flags(unsigned long flags);
extern char *gnu_short_stack_flags(unsigned long flags);
-extern elfobj *readelf_buffer(const char *filename, char *buffer, size_t buffer_len);
+extern elfobj *readelf_buffer(const char *filename, void *buffer, size_t buffer_len);
extern elfobj *_readelf_fd(const char *filename, int fd, size_t len, int read_only);
#define readelf_fd(filename, fd, len) _readelf_fd(filename, fd, len, 1)
extern elfobj *_readelf(const char *filename, int read_only);
diff --git a/paxmacho.c b/paxmacho.c
index ea7ce0a..cfa7ef3 100644
--- a/paxmacho.c
+++ b/paxmacho.c
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxmacho.c,v 1.16 2010/01/15 10:29:17 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxmacho.c,v 1.17 2010/01/15 11:06:33 vapier Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -248,7 +248,7 @@ fatobj *readmacho_buffer(const char *filename, char *buffer, size_t buffer_len)
if (ret->len <= sizeof(struct fat_header))
return NULL;
- fhdr = (struct fat_header *)ret->data;
+ fhdr = ret->data;
/* Check what kind of file this is. Unfortunately we don't have
* configure, so we don't know if we're on big or little endian, so
* we cannot check if the fat_header is in bigendian like it should.
@@ -328,7 +328,7 @@ loadcmd *firstloadcmd(fatobj *fobj)
loadcmd *ret = xmalloc(sizeof(*ret));
ret->data = fobj->mhdata +
(fobj->ismach64 ? sizeof(struct mach_header_64) : sizeof(struct mach_header));
- ret->lcmd = (struct load_command *)ret->data;
+ ret->lcmd = ret->data;
ret->cleft = MOBJGET(fobj, mhdr.hdr32->ncmds); /* 32 and 64 bits are aligned here */
ret->align = (fobj->ismach64 ? 8 : 4);
ret->swapped = fobj->swapped;
@@ -360,7 +360,7 @@ int nextloadcmd(loadcmd *lcmd)
size += lcmd->align - (size % lcmd->align);
}
lcmd->data += size;
- lcmd->lcmd = (struct load_command *)lcmd->data;
+ lcmd->lcmd = lcmd->data;
return 1;
}
diff --git a/scanmacho.c b/scanmacho.c
index 187cd99..7c137a8 100644
--- a/scanmacho.c
+++ b/scanmacho.c
@@ -1,7 +1,7 @@
/*
* Copyright 2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.16 2009/12/20 20:37:09 grobian Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.17 2010/01/15 11:06:33 vapier Exp $
*
* based on scanelf by:
* Copyright 2003-2007 Ned Ludd - <solar@gentoo.org>
@@ -10,7 +10,7 @@
* 2008 Fabian Groffen - <grobian@gentoo.org>
*/
-static const char *rcsid = "$Id: scanmacho.c,v 1.16 2009/12/20 20:37:09 grobian Exp $";
+static const char *rcsid = "$Id: scanmacho.c,v 1.17 2010/01/15 11:06:33 vapier Exp $";
const char * const argv0 = "scanmacho";
#include "paxinc.h"
@@ -72,9 +72,9 @@ static const char *macho_file_needed_lib(
do {
if (lcmd->lcmd->cmd == lc_load_dylib) {
- struct dylib_command *dlcmd = (struct dylib_command*)lcmd->data;
+ struct dylib_command *dlcmd = lcmd->data;
char *needed;
- needed = (char *)(lcmd->data + MGET(fobj->swapped, dlcmd->dylib.name.offset));
+ needed = lcmd->data + MGET(fobj->swapped, dlcmd->dylib.name.offset);
if (op == 0) {
if (!be_wewy_wewy_quiet) {
if (*found_needed)
@@ -113,10 +113,9 @@ static char *macho_file_interp(fatobj *fobj, char *found_interp)
do {
if (lcmd->lcmd->cmd == lc_load_dylinker) {
- struct dylinker_command *dlcmd =
- (struct dylinker_command*)lcmd->data;
+ struct dylinker_command *dlcmd = lcmd->data;
char *dylinker;
- dylinker = (char *)(lcmd->data + MGET(fobj->swapped, dlcmd->name.offset));
+ dylinker = lcmd->data + MGET(fobj->swapped, dlcmd->name.offset);
*found_interp = 1;
free(lcmd);
return (be_wewy_wewy_quiet ? NULL : dylinker);
@@ -139,9 +138,9 @@ static char *macho_file_soname(fatobj *fobj, char *found_soname)
do {
if (lcmd->lcmd->cmd == lc_id_dylib) {
- struct dylib_command *dlcmd = (struct dylib_command*)lcmd->data;
+ struct dylib_command *dlcmd = lcmd->data;
char *soname;
- soname = (char *)(lcmd->data + MGET(fobj->swapped, dlcmd->dylib.name.offset));
+ soname = lcmd->data + MGET(fobj->swapped, dlcmd->dylib.name.offset);
*found_soname = 1;
free(lcmd);
return (be_wewy_wewy_quiet ? NULL : soname);