kobj_boot.c revision 986fd29a0dc13f7608ef7f508f6e700bd7bc2720
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License, Version 1.0 only 2N/A * (the "License"). You may not use this file except in compliance 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * We don't use the global offset table, but 2N/A * ld may throw in an UNDEFINED reference in 2N/A#
define IN_RANGE(v, n) ((-(
1l<<((n)-
1l))) <= (v) && (v) < (
1l<<((n)-
1l)))
2N/A * Note: doflush() must be inlined, since we call it before we 2N/A * have relocated ourselves. 2N/A * Boot transfers control here. At this point, 2N/A * we haven't relocated our own symbols, so the 2N/A * world (as we know it) is pretty small right now. 2N/A * Check the bootstrap vector. 2N/A * Now the aux vector. 2N/A * Build cache table for section addresses. 2N/A * Find the end of data 2N/A * Find the symbol table, and then loop 2N/A * through the symbols adjusting their 2N/A * values to reflect where the sections 2N/A * Assign the addresses for COMMON 2N/A * symbols even though we haven't 2N/A * actually allocated bss yet. 2N/A * Squirrel it away for later. 2N/A * Symbol's new address. 2N/A * Allocate bss for COMMON, if any. 2N/A * Update the size of data. 2N/A * Relocate our own symbols. We'll handle the 2N/A * undefined symbols later. 2N/A * Get the section being relocated 2N/A * and the symbol table. 2N/A * Loop through relocations. 2N/A * if R_SPARC_RELATIVE, simply add base addr 2N/A * Check for bad symbol index. 2N/A * Just bind our own symbols at this point. 2N/A * If PC-relative, subtract ref addr. 2N/A * insert value calculated at reference point 2N/A * 3 cases - normal byte order aligned, normal byte 2N/A * order unaligned, and byte swapped 2N/A * for the swapped and unaligned cases we insert value 2N/A * This isn't a real relocation type. 2N/A * It just confuses the compiler 2N/A * sufficiently that it can't generate 2N/A * a jump table -- tee hee 2N/A * 7/19/89 rmk adding current value of 2N/A * *offptr to value. Should not be needed, 2N/A * since this is a RELA type and *offptr 2N/A * should be in addend 2N/A * We only need to do it once. 2N/A * Done relocating all of our *defined* 2N/A * symbols, so we hand off.