diff options
author | ru <ru@FreeBSD.org> | 2003-03-13 11:47:31 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2003-03-13 11:47:31 +0000 |
commit | b90d854c5fb6c36b8eda669f20407dcf5436de9d (patch) | |
tree | d369f8683e0797d7b0532009e9f01a16c93b5aef /usr.sbin/crunch | |
parent | 857cde93f507f254aef33555c1eb12f59735ecd9 (diff) | |
download | FreeBSD-src-b90d854c5fb6c36b8eda669f20407dcf5436de9d.zip FreeBSD-src-b90d854c5fb6c36b8eda669f20407dcf5436de9d.tar.gz |
Complete the endianness support -- sparc64 can now do i386.
Tested on: sparc64 -> i386, i386 -> sparc64
Debugged by: elfdump(1)
Diffstat (limited to 'usr.sbin/crunch')
-rw-r--r-- | usr.sbin/crunch/crunchide/exec_elf32.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c index d21fc12..aa3b86d 100644 --- a/usr.sbin/crunch/crunchide/exec_elf32.c +++ b/usr.sbin/crunch/crunchide/exec_elf32.c @@ -59,9 +59,11 @@ __FBSDID("$FreeBSD$"); #if (ELFSIZE == 32) #include <sys/elf32.h> #define xewtoh(x) ((data == ELFDATA2MSB) ? be32toh(x) : le32toh(x)) +#define htoxew(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)) #endif #include <sys/elf_generic.h> @@ -339,14 +341,10 @@ ELFNAMEEND(hide)(int fd, const char *fn) Elf_Rela *relap = tmpl->mem; for (ewi = 0; ewi < xewtoh(tmpl->size) / sizeof(*relap); ewi++) { - relap[ewi].r_info = -#if (ELFSIZE == 32) /* XXX */ - symfwmap[ELF_R_SYM(xe32toh(relap[ewi].r_info))] << 8 | - ELF_R_TYPE(xe32toh(relap[ewi].r_info)); -#elif (ELFSIZE == 64) /* XXX */ - symfwmap[ELF_R_SYM(xewtoh(relap[ewi].r_info))] << 32 | - ELF_R_TYPE(xewtoh(relap[ewi].r_info)); -#endif /* XXX */ + relap[ewi].r_info = htoxew(ELF_R_INFO( + symfwmap[ELF_R_SYM(xewtoh(relap[ewi].r_info))], + ELF_R_TYPE(xewtoh(relap[ewi].r_info)) + )); } } @@ -355,14 +353,10 @@ ELFNAMEEND(hide)(int fd, const char *fn) Elf_Rel *relp = tmpl->mem; for (ewi = 0; ewi < xewtoh(tmpl->size) / sizeof *relp; ewi++) { - relp[ewi].r_info = -#if (ELFSIZE == 32) /* XXX */ - symfwmap[ELF_R_SYM(xe32toh(relp[ewi].r_info))] << 8 | - ELF_R_TYPE(xe32toh(relp[ewi].r_info)); -#elif (ELFSIZE == 64) /* XXX */ - symfwmap[ELF_R_SYM(xewtoh(relp[ewi].r_info))] << 32 | - ELF_R_TYPE(xewtoh(relp[ewi].r_info)); -#endif /* XXX */ + relp[ewi].r_info = htoxew(ELF_R_INFO( + symfwmap[ELF_R_SYM(xewtoh(relp[ewi].r_info))], + ELF_R_TYPE(xewtoh(relp[ewi].r_info)) + )); } } |