Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Aug 2010 14:16:57 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211222 - head/usr.sbin/crunch/crunchide
Message-ID:  <201008121416.o7CEGvEl002947@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Thu Aug 12 14:16:57 2010
New Revision: 211222
URL: http://svn.freebsd.org/changeset/base/211222

Log:
  Fix crunchide to work on sparc64 and perhaps other 64 bit platforms.
  
  I used the wrong type when setting st_name in the symbol table entry
  struct. It's an Elf64_Word which is defined as an unsigned 32 bit int
  on both 32 and 64 bit platforms.
  
  To make things sensible, define some new macros to use as "word" macros
  and use those, rather than simply using the explicit 32 bit macros.

Modified:
  head/usr.sbin/crunch/crunchide/exec_elf32.c

Modified: head/usr.sbin/crunch/crunchide/exec_elf32.c
==============================================================================
--- head/usr.sbin/crunch/crunchide/exec_elf32.c	Thu Aug 12 13:58:46 2010	(r211221)
+++ head/usr.sbin/crunch/crunchide/exec_elf32.c	Thu Aug 12 14:16:57 2010	(r211222)
@@ -60,10 +60,15 @@ __FBSDID("$FreeBSD$");
 #include <sys/elf32.h>
 #define	xewtoh(x)	((data == ELFDATA2MSB) ? be32toh(x) : le32toh(x))
 #define	htoxew(x)	((data == ELFDATA2MSB) ? htobe32(x) : htole32(x))
+#define	wewtoh(x)	((data == ELFDATA2MSB) ? be32toh(x) : le32toh(x))
+#define	htowew(x)	((data == ELFDATA2MSB) ? htobe32(x) : htole32(x))
 #elif (ELFSIZE == 64)
 #include <sys/elf64.h>
 #define	xewtoh(x)	((data == ELFDATA2MSB) ? be64toh(x) : le64toh(x))
 #define	htoxew(x)	((data == ELFDATA2MSB) ? htobe64(x) : htole64(x))
+/* elf64 Elf64_Word are 32 bits */
+#define	wewtoh(x)	((data == ELFDATA2MSB) ? be32toh(x) : le32toh(x))
+#define	htowew(x)	((data == ELFDATA2MSB) ? htobe32(x) : htole32(x))
 #endif
 #include <sys/elf_generic.h>
 
@@ -345,7 +350,7 @@ ELFNAMEEND(hide)(int fd, const char *fn)
 				goto bad;
 		}
 
-		sp->st_name = htoxew(nstrtab_nextoff);
+		sp->st_name = htowew(nstrtab_nextoff);
 
 		/* if it's a keeper or is undefined, don't rename it. */
 		if (in_keep_list(symname) ||



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008121416.o7CEGvEl002947>