summaryrefslogtreecommitdiffstats
path: root/usr.sbin/crunch
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2003-08-08 15:44:17 +0000
committerru <ru@FreeBSD.org>2003-08-08 15:44:17 +0000
commitee1d0e21ba586e4cadff3693f9d5f0436e74b04c (patch)
tree138f855c4d7e02c12d41792749e9ba64425b28de /usr.sbin/crunch
parent1cee0842b20a7ebe3bc95edbe01b79f98421e775 (diff)
downloadFreeBSD-src-ee1d0e21ba586e4cadff3693f9d5f0436e74b04c.zip
FreeBSD-src-ee1d0e21ba586e4cadff3693f9d5f0436e74b04c.tar.gz
Fix a bug that caused i386 to produce broken binaries for big-endian
64-bit platforms. (size_t is 32bit on i386, but Elf_Shdr.sh_size is 64bit on SPARC64.)
Diffstat (limited to 'usr.sbin/crunch')
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf32.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c
index 363dd0c..72dbdc9 100644
--- a/usr.sbin/crunch/crunchide/exec_elf32.c
+++ b/usr.sbin/crunch/crunchide/exec_elf32.c
@@ -222,8 +222,8 @@ ELFNAMEEND(hide)(int fd, const char *fn)
if (tmpl == NULL)
goto bad;
tmpl->mem = NULL;
- tmpl->file = shdrp[i].sh_offset;
- tmpl->size = shdrp[i].sh_size;
+ tmpl->file = xewtoh(shdrp[i].sh_offset);
+ tmpl->size = xewtoh(shdrp[i].sh_size);
tmpl->next = relalist;
relalist = tmpl;
break;
@@ -232,8 +232,8 @@ ELFNAMEEND(hide)(int fd, const char *fn)
if (tmpl == NULL)
goto bad;
tmpl->mem = NULL;
- tmpl->file = shdrp[i].sh_offset;
- tmpl->size = shdrp[i].sh_size;
+ tmpl->file = xewtoh(shdrp[i].sh_offset);
+ tmpl->size = xewtoh(shdrp[i].sh_size);
tmpl->next = rellist;
rellist = tmpl;
break;
@@ -270,21 +270,21 @@ ELFNAMEEND(hide)(int fd, const char *fn)
/* any rela tables */
for (tmpl = relalist; tmpl != NULL; tmpl = tmpl->next) {
- if ((tmpl->mem = xmalloc(xewtoh(tmpl->size), fn, "rela table"))
+ if ((tmpl->mem = xmalloc(tmpl->size, fn, "rela table"))
== NULL)
goto bad;
- if (xreadatoff(fd, tmpl->mem, xewtoh(tmpl->file),
- xewtoh(tmpl->size), fn) != xewtoh(tmpl->size))
+ if (xreadatoff(fd, tmpl->mem, tmpl->file,
+ tmpl->size, fn) != tmpl->size)
goto bad;
}
/* any rel tables */
for (tmpl = rellist; tmpl != NULL; tmpl = tmpl->next) {
- if ((tmpl->mem = xmalloc(xewtoh(tmpl->size), fn, "rel table"))
+ if ((tmpl->mem = xmalloc(tmpl->size, fn, "rel table"))
== NULL)
goto bad;
- if (xreadatoff(fd, tmpl->mem, xewtoh(tmpl->file),
- xewtoh(tmpl->size), fn) != xewtoh(tmpl->size))
+ if (xreadatoff(fd, tmpl->mem, tmpl->file,
+ tmpl->size, fn) != tmpl->size)
goto bad;
}
@@ -348,7 +348,7 @@ ELFNAMEEND(hide)(int fd, const char *fn)
for (tmpl = relalist; tmpl != NULL; tmpl = tmpl->next) {
Elf_Rela *relap = tmpl->mem;
- for (ewi = 0; ewi < xewtoh(tmpl->size) / sizeof(*relap); ewi++) {
+ for (ewi = 0; ewi < tmpl->size / sizeof(*relap); ewi++) {
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))
@@ -360,7 +360,7 @@ ELFNAMEEND(hide)(int fd, const char *fn)
for (tmpl = rellist; tmpl != NULL; tmpl = tmpl->next) {
Elf_Rel *relp = tmpl->mem;
- for (ewi = 0; ewi < xewtoh(tmpl->size) / sizeof *relp; ewi++) {
+ for (ewi = 0; ewi < tmpl->size / sizeof *relp; ewi++) {
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))
@@ -378,13 +378,13 @@ ELFNAMEEND(hide)(int fd, const char *fn)
xewtoh(symtabshdr->sh_size), fn) != xewtoh(symtabshdr->sh_size))
goto bad;
for (tmpl = relalist; tmpl != NULL; tmpl = tmpl->next) {
- if (xwriteatoff(fd, tmpl->mem, xewtoh(tmpl->file),
- xewtoh(tmpl->size), fn) != xewtoh(tmpl->size))
+ if (xwriteatoff(fd, tmpl->mem, tmpl->file,
+ tmpl->size, fn) != tmpl->size)
goto bad;
}
for (tmpl = rellist; tmpl != NULL; tmpl = tmpl->next) {
- if (xwriteatoff(fd, tmpl->mem, xewtoh(tmpl->file),
- xewtoh(tmpl->size), fn) != xewtoh(tmpl->size))
+ if (xwriteatoff(fd, tmpl->mem, tmpl->file,
+ tmpl->size, fn) != tmpl->size)
goto bad;
}
OpenPOWER on IntegriCloud