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) ||
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to