diff options
author | obrien <obrien@FreeBSD.org> | 2004-06-22 17:05:39 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2004-06-22 17:05:39 +0000 |
commit | 8abf9484aa165999b93d86ff28183b14db4f75ab (patch) | |
tree | 7bef17e1bb35905304837cdda361107602d3e91a /usr.sbin/kgzip/kgzcmp.c | |
parent | 2a386317a161ac67a3e2c58e2c191647c1567fbb (diff) | |
download | FreeBSD-src-8abf9484aa165999b93d86ff28183b14db4f75ab.zip FreeBSD-src-8abf9484aa165999b93d86ff28183b14db4f75ab.tar.gz |
Adjust the system endian and a.out headers to be more MI and cross-building
friendly. Use the systems headers rather than local versions.
Reviewed by: ru
Diffstat (limited to 'usr.sbin/kgzip/kgzcmp.c')
-rw-r--r-- | usr.sbin/kgzip/kgzcmp.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/usr.sbin/kgzip/kgzcmp.c b/usr.sbin/kgzip/kgzcmp.c index e873b11..0ea4f0e 100644 --- a/usr.sbin/kgzip/kgzcmp.c +++ b/usr.sbin/kgzip/kgzcmp.c @@ -26,6 +26,9 @@ * $FreeBSD$ */ +#define _KERNEL +#include <sys/param.h> +#undef _KERNEL #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> @@ -36,11 +39,10 @@ #include <stdlib.h> #include <unistd.h> -#include "i386_a.out.h" +#include <a.out.h> #include "aouthdr.h" #include "elfhdr.h" -#include "endian.h" #include "kgzip.h" static void mk_data(const struct iodesc *i, const struct iodesc *, @@ -48,7 +50,7 @@ static void mk_data(const struct iodesc *i, const struct iodesc *, static int ld_elf(const struct iodesc *, const struct iodesc *, struct kgz_hdr *, const Elf32_Ehdr *); static int ld_aout(const struct iodesc *, const struct iodesc *, - struct kgz_hdr *, const struct i386_exec *); + struct kgz_hdr *, const struct exec *); /* * Compress executable and output it in relocatable object format. @@ -88,18 +90,18 @@ kgzcmp(struct kgz_hdr *kh, const char *f1, const char *f2) xwrite(&ido, &ahdr0, sizeof(ahdr0)); } else { struct kgz_elfhdr ehdr = elfhdr; - ehdr.st[KGZ_ST_KGZ_NDATA].st_size = HTOLE32(kh->nsize); + ehdr.st[KGZ_ST_KGZ_NDATA].st_size = htole32(kh->nsize); ehdr.sh[KGZ_SH_DATA].sh_size = - HTOLE32(LE32TOH(ehdr.sh[KGZ_SH_DATA].sh_size) + kh->nsize); + htole32(le32toh(ehdr.sh[KGZ_SH_DATA].sh_size) + kh->nsize); xseek(&ido, 0); xwrite(&ido, &ehdr, sizeof(ehdr)); } khle = *kh; - khle.dload = HTOLE32(khle.dload); - khle.dsize = HTOLE32(khle.dsize); - khle.isize = HTOLE32(khle.isize); - khle.entry = HTOLE32(khle.entry); - khle.nsize = HTOLE32(khle.nsize); + khle.dload = htole32(khle.dload); + khle.dsize = htole32(khle.dsize); + khle.isize = htole32(khle.isize); + khle.entry = htole32(khle.entry); + khle.nsize = htole32(khle.nsize); xwrite(&ido, &khle, sizeof(khle)); xclose(&ido); xclose(&idi); @@ -113,7 +115,7 @@ mk_data(const struct iodesc * idi, const struct iodesc * ido, struct kgz_hdr * kh, size_t off) { union { - struct i386_exec ex; + struct exec ex; Elf32_Ehdr ee; } hdr; struct stat sb; @@ -127,7 +129,7 @@ mk_data(const struct iodesc * idi, const struct iodesc * ido, fmt = 0; if (n >= sizeof(hdr.ee) && IS_ELF(hdr.ee)) fmt = F_ELF; - else if (n >= sizeof(hdr.ex) && I386_N_GETMAGIC(hdr.ex) == ZMAGIC) + else if (n >= sizeof(hdr.ex) && N_GETMAGIC(hdr.ex) == ZMAGIC) fmt = F_AOUT; if (!fmt) errx(1, "%s: Format not supported", idi->fname); @@ -216,20 +218,20 @@ ld_elf(const struct iodesc * idi, const struct iodesc * ido, */ static int ld_aout(const struct iodesc * idi, const struct iodesc * ido, - struct kgz_hdr * kh, const struct i386_exec * a) + struct kgz_hdr * kh, const struct exec * a) { size_t load, addr; - load = addr = I386_N_TXTADDR(*a); - xcopy(idi, ido, LE32TOH(a->a_text), I386_N_TXTOFF(*a)); - addr += LE32TOH(a->a_text); - if (I386_N_DATADDR(*a) != addr) + load = addr = N_TXTADDR(*a); + xcopy(idi, ido, le32toh(a->a_text), N_TXTOFF(*a)); + addr += le32toh(a->a_text); + if (N_DATADDR(*a) != addr) return -1; - xcopy(idi, ido, LE32TOH(a->a_data), I386_N_DATOFF(*a)); - addr += LE32TOH(a->a_data); + xcopy(idi, ido, le32toh(a->a_data), N_DATOFF(*a)); + addr += le32toh(a->a_data); kh->dload = load; kh->dsize = addr - load; - kh->isize = kh->dsize + LE32TOH(a->a_bss); - kh->entry = LE32TOH(a->a_entry); + kh->isize = kh->dsize + le32toh(a->a_bss); + kh->entry = le32toh(a->a_entry); return 0; } |