summaryrefslogtreecommitdiffstats
path: root/usr.sbin/crunch
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2010-08-12 14:16:57 +0000
committeradrian <adrian@FreeBSD.org>2010-08-12 14:16:57 +0000
commit16e60f2ae7dae83cc366e00660498e8588bdc5b1 (patch)
treef079bbe24fbbd10fd462be5ee18fe7327dbdb899 /usr.sbin/crunch
parent720b78038050bcb27c01c2db43f261605ece824d (diff)
downloadFreeBSD-src-16e60f2ae7dae83cc366e00660498e8588bdc5b1.zip
FreeBSD-src-16e60f2ae7dae83cc366e00660498e8588bdc5b1.tar.gz
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.
Diffstat (limited to 'usr.sbin/crunch')
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf32.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c
index 61d0241..2b2e27f 100644
--- a/usr.sbin/crunch/crunchide/exec_elf32.c
+++ b/usr.sbin/crunch/crunchide/exec_elf32.c
@@ -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) ||
OpenPOWER on IntegriCloud