b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * CDDL HEADER START
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * The contents of this file are subject to the terms of the
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Common Development and Distribution License (the "License").
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * You may not use this file except in compliance with the License.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * See the License for the specific language governing permissions
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * and limitations under the License.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * When distributing Covered Code, include this CDDL HEADER in each
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * If applicable, add the following below this CDDL HEADER, with the
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * fields enclosed by brackets "[]" replaced with your own identifying
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * information: Portions Copyright [yyyy] [name of copyright owner]
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * CDDL HEADER END
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Use is subject to license terms.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Tool to inspect a sun4u bootable module for a symbol table size
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * that will trigger a fatal error on older versions of OBP.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * The failure mode when booting is recorded in CR 6828121
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * and appears as follows:
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Executing last command: boot
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Boot device: /pci@1f,0/pci@1/scsi@8/disk@0,0:a File and args: kmdb
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Error in Fcode execution !!!
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Evaluating: to load-base init-program
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Out of memory
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Warning: Fcode sequence resulted in a net stack depth change of 1
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Error in Fcode execution !!!
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Evaluating: to load-base init-program
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Evaluating: to load-base init-program
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * The file just loaded does not appear to be executable.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * The OBP bug is CR 4777088, fixed in OBP versions 4.12.1 and forward.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * The OBP memory allocator for the memory into which the module's
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * symbol table is read fails for a specific memory range on
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * each page, where the size &= 0x1fff is > 0x1fe1 && <= 0x1ff0.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Note the symbol table size is the size of both the SYMTAB
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * and the STRTAB ELF sections.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * To prevent this problem on a given machine, update or patch the OBP.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * If this tool reports that a module has a symbol table size in
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * the failing range, that build will not boot on any machine with
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * this OBP problem. The only known work-around is to make some
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * source change to add or remove symbols to adjust the symbol table
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * size outside the triggering range.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Each sun4u bootable module is in theory affected by this, including
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * cprboot, bootlst, and each unix module. Although the serengeti
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * (Sun-Fire) and opl (SPARC-Enterprise) OBP implementations never
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * included this bug. The bug only occurs for allocations
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * pagesize or greater, and the only such OBP allocation is for a
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * module's symbol table, for the sum of the SYMTAB and STRTAB
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * sections. The wanboot and inetboot binaries do not include
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * these sections and are therefore also unaffected.
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "platform/SUNW,Ultra-Enterprise-10000/kernel/sparcv9/unix",
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "platform/SUNW,Sun-Fire-15000/kernel/sparcv9/unix",
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliamstatic int nsun4ubootables = sizeof (sun4u_bootables) / sizeof (char *);
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * size check should be:
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * size &= 0x1fff, size > 0x1fe1 && size <= 0x1ff0
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam * Tag each error message so it shows up in the build summary mail
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "ERROR: This binary will not boot on any machine with an older\n"
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "ERROR: version of OBP. See CR 4777088 and 6828121 for more details.\n"
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "ERROR: No work-around is possible other than making changes to\n"
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "ERROR: add/remove symbols from the module to move the symbol\n"
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "ERROR: table size outside the toxic range.\n";
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam (void) snprintf(path, sizeof (path), "%s", binary);
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam (void) snprintf(path, sizeof (path), "%s/%s", root, binary);
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam while ((symscn = elf_nextscn(elf, symscn)) != NULL) {
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam err = (off >= toxic_start && off <= toxic_end);
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam (void) printf("%s: ERROR: %s\n", whoami, binary);
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam (void) printf("ERROR: symbol table size 0x%llx is "
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "in toxic range (0x%x - 0x%x)!\n",
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "not in toxic range (0x%x - 0x%x)\n",
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "(0x%llx, 0x%llx)\n", total, (total & ~pagemask),
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "%s: %s - no symtab or strtab section found\n",
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "%s: %s - no symtab section found\n",
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "%s: %s - no strtab section found\n",
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "usage: %s [-n] [-v] [-r <root>] [<binary>] ...\n", whoami);
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam " -n: exit with 0 even with an error detected to allow\n");
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam " a build to succeed even with a failing binary\n");
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam "The default list of binaries checked if none supplied is:\n");
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam for (i = 0; i < nsun4ubootables; i++) {
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam (void) fprintf(stderr, " %s\n", sun4u_bootables[i]);
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam while ((i = getopt(argc, argv, "enr:R:v")) != -1) {
b31b5de1357c915fe7dab4d9646d9d84f9fe69bcJerry Gilliam for (i = 0; i < nsun4ubootables; i++) {