[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

aboot update for etch



hey Steve, Helge,
  I've put together an updated etch aboot package that includes the
fix for booting >= 2.6.23 kernels (e.g., the etchnhalf kernel) and
also fixes a few other issues that affect build reproducibility.
I'd like to get your take on this as a potential update for
stable.

I've tested this version of aboot with the sarge 2.6.8, etch 2.6.18
and the 2.6.24 queued for etchnhalf and didn't notice any problems.
However, I only have one machine/config for testing, so I'd appreciate
any additional testing from users on these lists.

Prebuilt packages are here, debdiff follows:

  http://dannf.org/aboot/

(And apologies in advance for any late replies, I'll be offline for
 the next few days)

diff -u aboot-0.9b/debian/changelog aboot-0.9b/debian/changelog
--- aboot-0.9b/debian/changelog
+++ aboot-0.9b/debian/changelog
@@ -1,3 +1,30 @@
+aboot (0.9b-3+etchnhalf.1) stable; urgency=low
+
+  * Fix unrepreducible build issue.
+    Though etch's aboot successfully built on etch/alpha, it was not producing
+    the same set of binaries - i.e., it was building aboot-cross instead of
+    aboot. This was corrected in 1.0~pre20040408-1 with the following change,
+    originally from Steve Langasek:
+    - Update debian/rules to use DEB_HOST_GNU_CPU instead of
+      DEB_HOST_GNU_TYPE, to fix a misbuild in unstable.
+  * Correcting the above creates two new FTBFS issues, likely due to the
+    use of the newer gcc in etch (the aboot that shipped with etch was the
+    same binary package that shipped in sarge):
+    - error: conflicting types for 'dispatch'
+      - Drop duplicate definition of dispatch() from cons.c
+    - net.c: In function 'load_kernel':
+      net.c:129: error: invalid lvalue in assignment      
+      - Change assignment to move casting to rvalue
+  * Add support for booting >= 2.6.23 kernels, needed for etchnhalf. This
+    was corrected in 1.0~pre20040408-1 with the following change, originally
+    from Steve Langasek:
+    - Update bootlx to ignore ELF header sections not of type PT_LOAD when
+      loading the kernel, so that the new PT_NOTE sections in 2.6.23rc1 and
+      above don't cause load failures.  Thanks to Richard Henderson for the
+      patch.
+
+ -- dann frazier <dannf@debian.org>  Wed, 14 May 2008 02:38:35 -0600
+
 aboot (0.9b-3) unstable; urgency=low
 
   * Synced man pages with upstream: aboot.conf.sgml, aboot.sgml,
diff -u aboot-0.9b/aboot.c aboot-0.9b/aboot.c
--- aboot-0.9b/aboot.c
+++ aboot-0.9b/aboot.c
@@ -19,14 +19,13 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/elf.h>
 #include <linux/kernel.h>
 #include <linux/version.h>
-
 #include <asm/console.h>
 #include <asm/hwrpb.h>
 #include <asm/system.h>
 
+#include <elf.h>
 #include <alloca.h>
 #include <errno.h>
 
@@ -38,14 +37,4 @@
 #include "string.h"
 
-#ifndef elf_check_arch
-# define aboot_elf_check_arch(e)	1
-#else
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-#  define aboot_elf_check_arch(e)        elf_check_arch(e)
-# else
-#  define aboot_elf_check_arch(e)        elf_check_arch(e->e_machine)
-# endif
-#endif
-
 struct bootfs *	bfs = 0;		/* filesystem to boot from */
 char *		dest_addr = 0;
@@ -83,77 +72,101 @@
 long
 first_block (const char *buf, long blocksize)
 {
-	struct elfhdr *elf;
-	struct elf_phdr *phdrs;
+	Elf64_Ehdr *elf;
+	Elf64_Phdr *phdrs;
+	int i, j;
 
-	elf  = (struct elfhdr *) buf;
+	elf  = (Elf64_Ehdr *) buf;
 	
-	if (elf->e_ident[0] == 0x7f
-	    && strncmp(elf->e_ident + 1, "ELF", 3) == 0)
+	if (elf->e_ident[0] != 0x7f
+	    || elf->e_ident[1] != 'E'
+	    || elf->e_ident[2] != 'L'
+	    || elf->e_ident[3] != 'F')
 	{
-		int i;
-		/* looks like an ELF binary: */
-		if (elf->e_type != ET_EXEC) {
-			printf("aboot: not an executable ELF file\n");
-			return -1;
-		}
-		if (!aboot_elf_check_arch(elf)) {
-			printf("aboot: ELF executable not for this machine\n");
-			return -1;
-		}
-		if (elf->e_phoff + elf->e_phnum * sizeof(*phdrs) > (unsigned) blocksize) {
-			printf("aboot: "
-			       "ELF program headers not in first block (%ld)\n",
-			       (long) elf->e_phoff);
-			return -1;
-		}
-		phdrs = (struct elf_phdr *) (buf + elf->e_phoff);
-		chunks = malloc(sizeof(struct segment) * elf->e_phnum);
-		nchunks = elf->e_phnum;
-		start_addr = phdrs[0].p_vaddr; /* assume they are sorted */
-		entry_addr = elf->e_entry;
+		/* Fail silently, it might be a compressed file */
+		return -1;
+	}
+	if (elf->e_ident[EI_CLASS] != ELFCLASS64
+	    || elf->e_ident[EI_DATA] != ELFDATA2LSB
+	    || elf->e_machine != EM_ALPHA)
+	{
+		printf("aboot: ELF executable not for this machine\n");
+		return -1;
+	}
+
+	/* Looks like an ELF binary. */
+	if (elf->e_type != ET_EXEC) {
+		printf("aboot: not an executable ELF file\n");
+		return -1;
+	}
+
+	if (elf->e_phoff + elf->e_phnum * sizeof(*phdrs) > (unsigned) blocksize)
+	{
+		printf("aboot: "
+		       "ELF program headers not in first block (%ld)\n",
+		       (long) elf->e_phoff);
+		return -1;
+	}
+
+	phdrs = (struct elf_phdr *) (buf + elf->e_phoff);
+	chunks = malloc(sizeof(struct segment) * elf->e_phnum);
+	start_addr = phdrs[0].p_vaddr; /* assume they are sorted */
+	entry_addr = elf->e_entry;
+
 #ifdef DEBUG
-		printf("aboot: %d program headers, start address %#lx, entry %#lx\n",
-		       nchunks, start_addr, entry_addr);
+	printf("aboot: %d program headers, start address %#lx, entry %#lx\n",
+	       elf->e_phnum, start_addr, entry_addr);
 #endif
-		for (i = 0; i < elf->e_phnum; ++i) {
-			int status;
 
-			chunks[i].addr   = phdrs[i].p_vaddr;
-			chunks[i].offset = phdrs[i].p_offset;
-			chunks[i].size   = phdrs[i].p_filesz;
+	for (i = j = 0; i < elf->e_phnum; ++i) {
+		int status;
+
+		if (phdrs[i].p_type != PT_LOAD)
+			continue;
+
+		chunks[j].addr   = phdrs[i].p_vaddr;
+		chunks[j].offset = phdrs[i].p_offset;
+		chunks[j].size   = phdrs[i].p_filesz;
+
 #ifdef DEBUG
-			printf("aboot: segment %d vaddr %#lx offset %#lx size %#lx\n",
-			       i, chunks[i].addr, chunks[i].offset, chunks[i].size);
+		printf("aboot: PHDR %d vaddr %#lx offset %#lx size %#lx\n",
+		       i, chunks[j].addr, chunks[j].offset, chunks[j].size);
 #endif
 
 #ifndef TESTING
-			status = check_memory(chunks[i].addr, chunks[i].size);
-			if (status) {
+		status = check_memory(chunks[j].addr, chunks[j].size);
+		if (status) {
+			printf("aboot: Can't load kernel.\n"
+			       "  Memory at %lx - %lx (PHDR %i) "
+			         "is %s\n",
+			       chunks[j].addr,
+			       chunks[j].addr + chunks[j].size - 1,
+			       i,
+			       (status == -ENOMEM) ?
+			          "Not Found" :
+				  "Busy (Reserved)");
+			return -1;
+		}
+#endif
+
+		if (phdrs[i].p_memsz > phdrs[i].p_filesz) {
+			if (bss_size > 0) {
 				printf("aboot: Can't load kernel.\n"
-				       "  Memory at %lx - %lx (chunk %i) "
-				         "is %s\n",
-				       chunks[i].addr,
-				       chunks[i].addr + chunks[i].size - 1,
-				       i,
-				       (status == -ENOMEM) ?
-				          "Not Found" :
-					  "Busy (Reserved)");
+				       "  Multiple BSS segments"
+				       " (PHDR %d)\n", i);
 				return -1;
 			}
-#endif
+			bss_start = (char *) (phdrs[i].p_vaddr +
+				              phdrs[i].p_filesz);
+			bss_size = (phdrs[i].p_memsz - phdrs[i].p_filesz);
 		}
-		bss_start = (char *) (phdrs[elf->e_phnum - 1].p_vaddr +
-				      phdrs[elf->e_phnum - 1].p_filesz);
-		bss_size = (phdrs[elf->e_phnum - 1].p_memsz -
-			    phdrs[elf->e_phnum - 1].p_filesz);
+
+		j++;
+	}
+	nchunks = j;
 #ifdef DEBUG
-		printf("aboot: bss at 0x%p, size %#lx\n", bss_start, bss_size);
+	printf("aboot: bss at 0x%p, size %#lx\n", bss_start, bss_size);
 #endif
-	} else {
-		/* Fail silently, it might be a compressed file */
-		return -1;
-	}
 
 	return 0;
 }
diff -u aboot-0.9b/cons.c aboot-0.9b/cons.c
--- aboot-0.9b/cons.c
+++ aboot-0.9b/cons.c
@@ -20,7 +20,6 @@
 #endif
 
 long cons_dev;			/* console device */
-extern long int dispatch();	/* Need the full 64 bit return here...*/
 
 long
 cons_puts(const char *str, long len)
diff -u aboot-0.9b/net.c aboot-0.9b/net.c
--- aboot-0.9b/net.c
+++ aboot-0.9b/net.c
@@ -126,7 +126,7 @@
 
 	//Move kernel to safe place before uncompression
 	src = (char*)free_mem_ptr - align_pagesize(kern_size);
-	(char*)free_mem_ptr = src;
+	free_mem_ptr = (unsigned long)src;
 	memcpy(src, kern_src, kern_size);
 
 	uncompress_kernel(-1);
diff -u aboot-0.9b/debian/rules aboot-0.9b/debian/rules
--- aboot-0.9b/debian/rules
+++ aboot-0.9b/debian/rules
@@ -9,7 +9,7 @@
 # This has to be exported to make some magic below work.
 export DH_OPTIONS
 
-DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_HOST_GNU_CPU  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
 
 export CPPFLAGS
 CPPFLAGS = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
@@ -25,7 +25,7 @@
       INSTALL_PROGRAM += -s
 endif
  
-ifeq (alpha-linux,$(DEB_HOST_GNU_TYPE))
+ifeq (alpha,$(DEB_HOST_GNU_CPU))
 build: build-aboot build-aboot-base
     # We do nothing here
 else
@@ -139,7 +139,7 @@
 
 	touch install-aboot-cross-stamp
 
-ifneq (alpha-linux,$(DEB_HOST_GNU_TYPE))
+ifneq (alpha,$(DEB_HOST_GNU_CPU))
 # Don't try to build our "arch-indep" package on other archs -- it won't
 # work anyway.
 binary-indep: 
@@ -161,7 +161,7 @@
 endif
 
 # Build architecture-dependent files here.
-ifeq (alpha-linux,$(DEB_HOST_GNU_TYPE))
+ifeq (alpha,$(DEB_HOST_GNU_CPU))
 binary-arch: DH_OPTIONS=-a -Naboot-cross
 binary-arch: build-aboot install-aboot
 else
only in patch2:
unchanged:
--- aboot-0.9b.orig/aboot.lds
+++ aboot-0.9b/aboot.lds
@@ -1,22 +1,25 @@
 OUTPUT_FORMAT("elf64-alpha")
 ENTRY(__start)
+PHDRS { kernel PT_LOAD; }
 SECTIONS
 {
   . = 0x20000000;
-  .text : { *(.text) }
+  .text : { *(.text) } :kernel
   _etext = .;
   PROVIDE (etext = .);
-  .rodata : { *(.rodata) }
-  .data : { *(.data) CONSTRUCTORS }
-  .got : { *(.got) }
-  .sdata : { *(.sdata) }
+  .rodata : { *(.rodata) } :kernel
+  .data : { *(.data) } :kernel
+  .got : { *(.got) } :kernel
+  .sdata : { *(.sdata) } :kernel
   _edata = .;
   PROVIDE (edata = .);
-  .sbss : { *(.sbss) *(.scommon) }
-  .bss : { *(.bss) *(COMMON) }
+  .sbss : { *(.sbss) *(.scommon) } :kernel
+  .bss : { *(.bss) *(COMMON) } :kernel
   _end = . ;
   PROVIDE (end = .);
 
+  /DISCARD/ : { *(.eh_frame) }
+
   .mdebug 0 : { *(.mdebug) }
   .note 0 : { *(.note) }
   .comment 0 : { *(.comment) }


Reply to: