Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2002 19:37:46 -0700 (PDT)
From:      Jake Burkholder <jake@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 10500 for review
Message-ID:  <200204300237.g3U2bkZ71381@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=10500

Change 10500 by jake@jake_sparc64 on 2002/04/29 19:37:29

	Backout ELF_CRC32 changes.  These should either be committed or
	forgotten about, I'm tired of the diffs.

Affected files ...

... //depot/projects/sparc64/sys/boot/common/bootstrap.h#7 edit
... //depot/projects/sparc64/sys/boot/common/load_elf.c#12 edit
... //depot/projects/sparc64/sys/boot/sparc64/loader/main.c#25 edit

Differences ...

==== //depot/projects/sparc64/sys/boot/common/bootstrap.h#7 (text+ko) ====

@@ -274,10 +274,6 @@
     /* Read from file to module address space, same semantics as read() */
     ssize_t	(*arch_readin)(const int fd, vm_offset_t dest,
 			       const size_t len);
-#ifdef ELF_CRC32
-    /* Compute a CRC32 checksum of data in the module address space. */
-    u_int32_t	(*arch_crc32)(u_int32_t sum, vm_offset_t start, size_t size);
-#endif
     /* Perform ISA byte port I/O (only for systems with ISA) */
     int		(*arch_isainb)(int port);
     void	(*arch_isaoutb)(int port, int value);

==== //depot/projects/sparc64/sys/boot/common/load_elf.c#12 (text+ko) ====

@@ -214,59 +214,7 @@
     return(err);
 }
 
-#ifdef ELF_CRC32
-struct crcinfo {
-	u_int32_t	ci_start;
-	u_int32_t	ci_size;
-	u_int32_t	ci_sum;
-};
-
-#define	CKSUM_SECT	"cksum"
-#define	SHSTR(off, tab)	(&((tab)[(off)]))
-
 /*
- * Extract CRC info so that the PT_LOAD checksums can be verified. Note that
- * this does not work for gzipped kernels; those have their own checksums in
- * the gzip format, though.
- */
-static int
-elf_cksum_init(elf_file_t ef, Elf_Ehdr *ehdr, Elf_Shdr *shdr, struct crcinfo **ci)
-{
-    char *shstrt;
-    int rv = -1;
-    int stt;
-    int i;
-
-    /* Get the section name string table section. */
-    stt = ehdr->e_shstrndx;
-    if (stt == SHN_UNDEF || shdr[stt].sh_type != SHT_STRTAB)
-	return (-1);
-    if ((shstrt = malloc(shdr[stt].sh_size)) == NULL)
-	return (-1);
-    if (lseek(ef->fd, shdr[stt].sh_offset, SEEK_SET) == -1)
-	return (-1);
-    if (read(ef->fd, shstrt, shdr[stt].sh_size) == -1)
-	return (-1);
-
-    /* Try to find the checksum section. */
-    for (i = 0; i < ehdr->e_shnum; i++) {
-	if (strcmp(SHSTR(shdr[i].sh_name, shstrt), CKSUM_SECT) == 0) {
-	    rv = shdr[i].sh_size;
-	    if ((*ci = malloc(rv)) == NULL)
-		return (-1);
-	    if (lseek(ef->fd, shdr[i].sh_offset, SEEK_SET) == -1)
-		return (-1);
-	    if (read(ef->fd, *ci, rv) == -1)
-		return (-1);
-	    rv /= sizeof(struct crcinfo);
-	    break;
-	}
-    }
-    return (rv);
-}
-#endif
-
-/*
  * With the file (fd) open on the image, and (ehdr) containing
  * the Elf header, load the image at (off)
  */
@@ -292,11 +240,6 @@
     int		symtabindex;
     long	size;
     u_int	fpcopy;
-#ifdef ELF_CRC32
-    struct crcinfo	*crctab;
-    int		ncrc, checked, k;
-    u_int32_t	crc;
-#endif
 
     dp = NULL;
     shdr = NULL;
@@ -308,7 +251,6 @@
 	off = - (off & 0xff000000u);	/* i386 relocates after locore */
 #else
 	off = 0;		/* alpha is direct mapped for kernels */
-				/* sparc64's MD part maps on demand. */
 #endif
     }
     ef->off = off;
@@ -319,30 +261,6 @@
     }
     phdr = (Elf_Phdr *)(ef->firstpage + ehdr->e_phoff);
 
-    /* Try to load the section header (see comments in the symtab code below) */
-    chunk = ehdr->e_shnum * ehdr->e_shentsize;
-    if (chunk == 0 || ehdr->e_shoff == 0)
-	goto noshdr;
-    shdr = malloc(chunk);
-    if (shdr == NULL)
-	goto noshdr;
-    if (lseek(ef->fd, (off_t)ehdr->e_shoff, SEEK_SET) == -1) {
-	printf("\nelf_loadimage: cannot lseek() to section headers");
-	shdr = NULL;
-	goto noshdr;
-    }
-    result = read(ef->fd, shdr, chunk);
-    if (result < 0 || (size_t)result != chunk) {
-	printf("\nelf_loadimage: read section headers failed");
-	shdr = NULL;
-	goto noshdr;
-    }
-
-#ifdef ELF_CRC32
-    ncrc = elf_cksum_init(ef, ehdr, shdr, &crctab);
-#endif
-
-noshdr:
     for (i = 0; i < ehdr->e_phnum; i++) {
 	/* We want to load PT_LOAD segments only.. */
 	if (phdr[i].p_type != PT_LOAD)
@@ -406,28 +324,6 @@
 	    }
 	    free(buf);
 	}
-#ifdef ELF_CRC32
-	if (archsw.arch_crc32 != NULL) {
-	    crc = archsw.arch_crc32(0, phdr[i].p_vaddr + off,
-		phdr[i].p_filesz);
-	    printf("crc32=%lu", (u_long)crc);
-	    checked = 0;
-	    for (k = 0; k < ncrc; k++) {
-		if (crctab[k].ci_start == phdr[i].p_offset &&
-		  crctab[k].ci_size == phdr[i].p_filesz) {
-		    checked = 1;
-		    if (crc == crctab[k].ci_sum)
-			printf("[OK] ");
-		    else {
-			panic("Bad checksum (%lu vs %lu)!", (u_long)crc,
-			  (u_long)crctab[k].ci_sum);
-		    }
-		}
-	    }
-	    if (!checked)
-		printf("[unchecked] ");
-	}
-#endif
 #ifdef ELF_VERBOSE
 	printf("\n");
 #endif
@@ -445,8 +341,21 @@
      * strip a file to remove symbols before gzipping it so that we do not
      * try to lseek() on it.
      */
+    chunk = ehdr->e_shnum * ehdr->e_shentsize;
+    if (chunk == 0 || ehdr->e_shoff == 0)
+	goto nosyms;
+    shdr = malloc(chunk);
     if (shdr == NULL)
 	goto nosyms;
+    if (lseek(ef->fd, (off_t)ehdr->e_shoff, SEEK_SET) == -1) {
+	printf("\nelf_loadimage: cannot lseek() to section headers");
+	goto nosyms;
+    }
+    result = read(ef->fd, shdr, chunk);
+    if (result < 0 || (size_t)result != chunk) {
+	printf("\nelf_loadimage: read section headers failed");
+	goto nosyms;
+    }
     symtabindex = -1;
     symstrindex = -1;
     for (i = 0; i < ehdr->e_shnum; i++) {

==== //depot/projects/sparc64/sys/boot/sparc64/loader/main.c#25 (text+ko) ====

@@ -28,17 +28,12 @@
 #include <machine/atomic.h>
 #include <machine/cpufunc.h>
 #include <machine/elf.h>
-#include <machine/frame.h>
 #include <machine/lsu.h>
 #include <machine/metadata.h>
 #include <machine/smp.h>
 #include <machine/tte.h>
 #include <machine/upa.h>
 
-#ifdef ELF_CRC32
-#include <zlib.h>
-#endif
-
 #include "bootstrap.h"
 #include "libofw.h"
 #include "dev_net.h"
@@ -212,14 +207,6 @@
 	return len;
 }
 
-#ifdef ELF_CRC32
-static u_int32_t
-sparc64_crc32(u_int32_t sum, vm_offset_t start, size_t size)
-{
-	return (crc32(sum, (char *)start, size));
-}
-#endif
-
 /*
  * other MD functions
  */

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204300237.g3U2bkZ71381>