kobj_boot.c revision e498729e15e121c426eb82534224f2cce4b2e020
0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License (the "License"). 0N/A * You may not use this file except in compliance with the License. 0N/A * See the License for the specific language governing permissions 0N/A * and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 0N/A * If applicable, add the following below this CDDL HEADER, with the 0N/A * fields enclosed by brackets "[]" replaced with your own identifying 0N/A * information: Portions Copyright [yyyy] [name of copyright owner] 0N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 0N/A * Use is subject to license terms. 0N/A#
pragma ident "%Z%%M% %I% %E% SMI" 0N/A * We don't use the global offset table, but 0N/A * ld may throw in an UNDEFINED reference in 0N/A * We -do- use the global offset table, but only by 0N/A * accident -- when you tell gcc to emit PIC code, 0N/A * it -always- generates a reference to the GOT in 0N/A * a register, even if the compilation unit never 0N/A * Rumoured to be fixed in a later version of gcc.. 0N/A#
define IN_RANGE(v, n) ((-(
1<<((n)-
1))) <= (v) && (v) < (
1<<((n)-
1)))
0N/A * Boot transfers control here. At this point, 0N/A * we haven't relocated our own symbols, so the 0N/A * world (as we know it) is pretty small right now. 0N/A * Check the bootstrap vector. 0N/A * Now the aux vector. 0N/A * Build cache table for section addresses. 0N/A * Find the end of data 0N/A * Find the symbol table, and then loop 0N/A * through the symbols adjusting their 0N/A * values to reflect where the sections 0N/A * Assign the addresses for COMMON 0N/A * symbols even though we haven't 0N/A * actually allocated bss yet. 0N/A * Squirrel it away for later. 0N/A * Symbol's new address. * Allocate bss for COMMON, if any. * Update the size of data. * Relocate our own symbols. We'll handle the * undefined symbols later. for (i =
1; i <
sh_num; i++) {
* Get the section being relocated * Loop through relocations. * add base addr to reloc location * Check for bad symbol index. * Just bind our own symbols at this point. * If PC-relative, subtract ref addr. * insert value calculated at reference point * 2 cases - normal byte order aligned, normal byte * For now, ignore GOT references ... * We only need to do it once. * Done relocating all of our *defined* * symbols, so we hand off.