summaryrefslogtreecommitdiffstats
path: root/sys/ia64
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-04-03 07:24:12 +0000
committermarcel <marcel@FreeBSD.org>2002-04-03 07:24:12 +0000
commit0dbbe50955903ed143bea85061e98780e7fb4da4 (patch)
treeb6dcb5afbd5f2f972055f768371369118ac773e8 /sys/ia64
parent8d96cdfea385d755723b1d9b0f2d33d9b3a368a5 (diff)
downloadFreeBSD-src-0dbbe50955903ed143bea85061e98780e7fb4da4.zip
FreeBSD-src-0dbbe50955903ed143bea85061e98780e7fb4da4.tar.gz
Make the kernel dump header endianness invariant by always dumping
in dump byte order (=network byte order). Swap blocksize and dumptime to avoid extraneous padding on 64-bit architectures. Use CTASSERT instead of runtime checks to make sure the header is 512 bytes large. Various style(9) fixes. Reviewed by: phk, bde, mike
Diffstat (limited to 'sys/ia64')
-rw-r--r--sys/ia64/ia64/dump_machdep.c23
-rw-r--r--sys/ia64/ia64/ia64dump.c23
2 files changed, 22 insertions, 24 deletions
diff --git a/sys/ia64/ia64/dump_machdep.c b/sys/ia64/ia64/dump_machdep.c
index d49265d..a86754e 100644
--- a/sys/ia64/ia64/dump_machdep.c
+++ b/sys/ia64/ia64/dump_machdep.c
@@ -38,6 +38,8 @@
#include <machine/elf.h>
#include <machine/md_var.h>
+CTASSERT(sizeof(struct kerneldumpheader) == 512);
+
#define MD_ALIGN(x) (((off_t)(x) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK)
typedef int callback_t(EFI_MEMORY_DESCRIPTOR*, int, void*);
@@ -55,21 +57,14 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
uint32_t blksz)
{
- if (sizeof(*kdh) != DEV_BSIZE) {
- printf(
- "Compiled struct kerneldumpheader is %d, not %d bytes\n",
- sizeof(*kdh), DEV_BSIZE);
- return;
- }
-
bzero(kdh, sizeof(*kdh));
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
- kdh->version = KERNELDUMPVERSION;
- kdh->architectureversion = archver;
- kdh->dumplength = dumplen;
- kdh->blocksize = blksz;
- kdh->dumptime = time_second;
+ kdh->version = htod32(KERNELDUMPVERSION);
+ kdh->architectureversion = htod32(archver);
+ kdh->dumplength = htod64(dumplen);
+ kdh->dumptime = htod64(time_second);
+ kdh->blocksize = htod32(blksz);
strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
@@ -217,7 +212,11 @@ dumpsys(struct dumperinfo *di)
ehdr.e_ident[EI_MAG2] = ELFMAG2;
ehdr.e_ident[EI_MAG3] = ELFMAG3;
ehdr.e_ident[EI_CLASS] = ELFCLASS64;
+#if BYTE_ORDER == LITTLE_ENDIAN
ehdr.e_ident[EI_DATA] = ELFDATA2LSB;
+#else
+ ehdr.e_ident[EI_DATA] = ELFDATA2MSB;
+#endif
ehdr.e_ident[EI_VERSION] = EV_CURRENT;
ehdr.e_ident[EI_OSABI] = ELFOSABI_STANDALONE; /* XXX big picture? */
ehdr.e_type = ET_CORE;
diff --git a/sys/ia64/ia64/ia64dump.c b/sys/ia64/ia64/ia64dump.c
index d49265d..a86754e 100644
--- a/sys/ia64/ia64/ia64dump.c
+++ b/sys/ia64/ia64/ia64dump.c
@@ -38,6 +38,8 @@
#include <machine/elf.h>
#include <machine/md_var.h>
+CTASSERT(sizeof(struct kerneldumpheader) == 512);
+
#define MD_ALIGN(x) (((off_t)(x) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK)
typedef int callback_t(EFI_MEMORY_DESCRIPTOR*, int, void*);
@@ -55,21 +57,14 @@ mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
uint32_t blksz)
{
- if (sizeof(*kdh) != DEV_BSIZE) {
- printf(
- "Compiled struct kerneldumpheader is %d, not %d bytes\n",
- sizeof(*kdh), DEV_BSIZE);
- return;
- }
-
bzero(kdh, sizeof(*kdh));
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
- kdh->version = KERNELDUMPVERSION;
- kdh->architectureversion = archver;
- kdh->dumplength = dumplen;
- kdh->blocksize = blksz;
- kdh->dumptime = time_second;
+ kdh->version = htod32(KERNELDUMPVERSION);
+ kdh->architectureversion = htod32(archver);
+ kdh->dumplength = htod64(dumplen);
+ kdh->dumptime = htod64(time_second);
+ kdh->blocksize = htod32(blksz);
strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
@@ -217,7 +212,11 @@ dumpsys(struct dumperinfo *di)
ehdr.e_ident[EI_MAG2] = ELFMAG2;
ehdr.e_ident[EI_MAG3] = ELFMAG3;
ehdr.e_ident[EI_CLASS] = ELFCLASS64;
+#if BYTE_ORDER == LITTLE_ENDIAN
ehdr.e_ident[EI_DATA] = ELFDATA2LSB;
+#else
+ ehdr.e_ident[EI_DATA] = ELFDATA2MSB;
+#endif
ehdr.e_ident[EI_VERSION] = EV_CURRENT;
ehdr.e_ident[EI_OSABI] = ELFOSABI_STANDALONE; /* XXX big picture? */
ehdr.e_type = ET_CORE;
OpenPOWER on IntegriCloud