xref: /onnv-gate/usr/src/uts/intel/amd64/krtld/kobj_boot.c (revision 580:70dfd36fd02c)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*580Swesolows  * Common Development and Distribution License (the "License").
6*580Swesolows  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*580Swesolows  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * Bootstrap the linker/loader.
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/types.h>
330Sstevel@tonic-gate #include <sys/bootconf.h>
340Sstevel@tonic-gate #include <sys/link.h>
350Sstevel@tonic-gate #include <sys/auxv.h>
360Sstevel@tonic-gate #include <sys/kobj.h>
370Sstevel@tonic-gate #include <sys/elf.h>
380Sstevel@tonic-gate #include <sys/bootsvcs.h>
390Sstevel@tonic-gate #include <sys/kobj_impl.h>
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #if !defined(__GNUC__)
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * We don't use the global offset table, but
450Sstevel@tonic-gate  * ld may throw in an UNDEFINED reference in
460Sstevel@tonic-gate  * our symbol table.
470Sstevel@tonic-gate  */
480Sstevel@tonic-gate #if !defined(_KERNEL)
490Sstevel@tonic-gate #pragma weak _GLOBAL_OFFSET_TABLE_
500Sstevel@tonic-gate #endif
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #else
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /*
550Sstevel@tonic-gate  * We -do- use the global offset table, but only by
560Sstevel@tonic-gate  * accident -- when you tell gcc to emit PIC code,
570Sstevel@tonic-gate  * it -always- generates a reference to the GOT in
580Sstevel@tonic-gate  * a register, even if the compilation unit never
590Sstevel@tonic-gate  * uses it.
600Sstevel@tonic-gate  *
610Sstevel@tonic-gate  * Rumoured to be fixed in a later version of gcc..
620Sstevel@tonic-gate  */
630Sstevel@tonic-gate 
640Sstevel@tonic-gate long	_GLOBAL_OFFSET_TABLE_[1];
650Sstevel@tonic-gate 
660Sstevel@tonic-gate #endif
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #define	roundup		ALIGN
690Sstevel@tonic-gate 
700Sstevel@tonic-gate #define	MAXSECT		64	/* max # of sects. */
710Sstevel@tonic-gate 
720Sstevel@tonic-gate #define	HIBITS		0xffffffff80000000	/* upper 32 bits */
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * Boot transfers control here. At this point,
760Sstevel@tonic-gate  * we haven't relocated our own symbols, so the
770Sstevel@tonic-gate  * world (as we know it) is pretty small right now.
780Sstevel@tonic-gate  */
790Sstevel@tonic-gate void
800Sstevel@tonic-gate _kobj_boot(
810Sstevel@tonic-gate 	struct boot_syscalls *syscallp,
820Sstevel@tonic-gate 	void *dvec,
830Sstevel@tonic-gate 	struct bootops *bootops,
840Sstevel@tonic-gate 	Boot *ebp)
850Sstevel@tonic-gate {
860Sstevel@tonic-gate 	Shdr *section[MAXSECT];	/* cache */
870Sstevel@tonic-gate 	val_t bootaux[BA_NUM];
880Sstevel@tonic-gate 	struct bootops *bop;
890Sstevel@tonic-gate 	Phdr *phdr;
900Sstevel@tonic-gate 	auxv_t *auxv = NULL;
910Sstevel@tonic-gate 	Shdr *sh;
920Sstevel@tonic-gate 	Half sh_num;
930Sstevel@tonic-gate 	ulong_t end, edata = 0;
940Sstevel@tonic-gate 	int i;
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 	bop = (dvec) ? *(struct bootops **)bootops : bootops;
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 	for (i = 0; i < BA_NUM; i++)
990Sstevel@tonic-gate 		bootaux[i].ba_val = NULL;
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate 	/*
1020Sstevel@tonic-gate 	 * Check the bootstrap vector.
1030Sstevel@tonic-gate 	 */
1040Sstevel@tonic-gate 	for (; ebp->eb_tag != EB_NULL; ebp++) {
1050Sstevel@tonic-gate 		switch (ebp->eb_tag) {
1060Sstevel@tonic-gate 		case EB_AUXV:
1070Sstevel@tonic-gate 			auxv = (auxv_t *)ebp->eb_un.eb_ptr;
1080Sstevel@tonic-gate 			break;
1090Sstevel@tonic-gate 		case EB_DYNAMIC:
1100Sstevel@tonic-gate 			bootaux[BA_DYNAMIC].ba_ptr = (void *)ebp->eb_un.eb_ptr;
1110Sstevel@tonic-gate 			break;
1120Sstevel@tonic-gate 		default:
1130Sstevel@tonic-gate 			break;
1140Sstevel@tonic-gate 		}
1150Sstevel@tonic-gate 	}
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate 	if (auxv == NULL)
1180Sstevel@tonic-gate 		return;
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate 	/*
1210Sstevel@tonic-gate 	 * Now the aux vector.
1220Sstevel@tonic-gate 	 */
1230Sstevel@tonic-gate 	for (; auxv->a_type != AT_NULL; auxv++) {
1240Sstevel@tonic-gate 		switch (auxv->a_type) {
1250Sstevel@tonic-gate 		case AT_PHDR:
1260Sstevel@tonic-gate 			bootaux[BA_PHDR].ba_ptr = auxv->a_un.a_ptr;
1270Sstevel@tonic-gate 			break;
1280Sstevel@tonic-gate 		case AT_PHENT:
1290Sstevel@tonic-gate 			bootaux[BA_PHENT].ba_val = auxv->a_un.a_val;
1300Sstevel@tonic-gate 			break;
1310Sstevel@tonic-gate 		case AT_PHNUM:
1320Sstevel@tonic-gate 			bootaux[BA_PHNUM].ba_val = auxv->a_un.a_val;
1330Sstevel@tonic-gate 			break;
1340Sstevel@tonic-gate 		case AT_PAGESZ:
1350Sstevel@tonic-gate 			bootaux[BA_PAGESZ].ba_val = auxv->a_un.a_val;
1360Sstevel@tonic-gate 			break;
1370Sstevel@tonic-gate 		case AT_SUN_LDELF:
1380Sstevel@tonic-gate 			bootaux[BA_LDELF].ba_ptr = auxv->a_un.a_ptr;
1390Sstevel@tonic-gate 			break;
1400Sstevel@tonic-gate 		case AT_SUN_LDSHDR:
1410Sstevel@tonic-gate 			bootaux[BA_LDSHDR].ba_ptr = auxv->a_un.a_ptr;
1420Sstevel@tonic-gate 			break;
1430Sstevel@tonic-gate 		case AT_SUN_LDNAME:
1440Sstevel@tonic-gate 			bootaux[BA_LDNAME].ba_ptr = auxv->a_un.a_ptr;
1450Sstevel@tonic-gate 			break;
1460Sstevel@tonic-gate 		case AT_SUN_LPAGESZ:
1470Sstevel@tonic-gate 			bootaux[BA_LPAGESZ].ba_val = auxv->a_un.a_val;
1480Sstevel@tonic-gate 			break;
1490Sstevel@tonic-gate 		case AT_SUN_CPU:
1500Sstevel@tonic-gate 			bootaux[BA_CPU].ba_ptr = auxv->a_un.a_ptr;
1510Sstevel@tonic-gate 			break;
1520Sstevel@tonic-gate 		case AT_SUN_MMU:
1530Sstevel@tonic-gate 			bootaux[BA_MMU].ba_ptr = auxv->a_un.a_ptr;
1540Sstevel@tonic-gate 			break;
1550Sstevel@tonic-gate 		case AT_ENTRY:
1560Sstevel@tonic-gate 			bootaux[BA_ENTRY].ba_ptr = auxv->a_un.a_ptr;
1570Sstevel@tonic-gate 			break;
1580Sstevel@tonic-gate 		default:
1590Sstevel@tonic-gate 			break;
1600Sstevel@tonic-gate 		}
1610Sstevel@tonic-gate 	}
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate 	sh = (Shdr *)bootaux[BA_LDSHDR].ba_ptr;
1650Sstevel@tonic-gate 	sh_num = ((Ehdr *)bootaux[BA_LDELF].ba_ptr)->e_shnum;
1660Sstevel@tonic-gate 	/*
1670Sstevel@tonic-gate 	 * Make sure we won't overflow stack allocated cache
1680Sstevel@tonic-gate 	 */
1690Sstevel@tonic-gate 	if (sh_num >= MAXSECT)
1700Sstevel@tonic-gate 		return;
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate 	/*
1730Sstevel@tonic-gate 	 * Build cache table for section addresses.
1740Sstevel@tonic-gate 	 */
1750Sstevel@tonic-gate 	for (i = 0; i < sh_num; i++) {
1760Sstevel@tonic-gate 		section[i] = sh++;
1770Sstevel@tonic-gate 	}
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate 	/*
1800Sstevel@tonic-gate 	 * Find the end of data
1810Sstevel@tonic-gate 	 * (to allocate bss)
1820Sstevel@tonic-gate 	 */
1830Sstevel@tonic-gate 	phdr = (Phdr *)bootaux[BA_PHDR].ba_ptr;
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate 	for (i = 0; i < bootaux[BA_PHNUM].ba_val; i++) {
1860Sstevel@tonic-gate 		if (phdr->p_type == PT_LOAD &&
1870Sstevel@tonic-gate 		    (phdr->p_flags & PF_W) && (phdr->p_flags & PF_X)) {
1880Sstevel@tonic-gate 			edata = end = phdr->p_vaddr + phdr->p_memsz;
1890Sstevel@tonic-gate 			break;
1900Sstevel@tonic-gate 		}
1910Sstevel@tonic-gate 		phdr = (Phdr *)((ulong_t)phdr + bootaux[BA_PHENT].ba_val);
1920Sstevel@tonic-gate 	}
1930Sstevel@tonic-gate 	if (edata == NULL)
1940Sstevel@tonic-gate 		return;
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate 	/*
1970Sstevel@tonic-gate 	 * Find the symbol table, and then loop
1980Sstevel@tonic-gate 	 * through the symbols adjusting their
1990Sstevel@tonic-gate 	 * values to reflect where the sections
2000Sstevel@tonic-gate 	 * were loaded.
2010Sstevel@tonic-gate 	 */
2020Sstevel@tonic-gate 	for (i = 1; i < sh_num; i++) {
2030Sstevel@tonic-gate 		Shdr *shp;
2040Sstevel@tonic-gate 		Sym *sp;
2050Sstevel@tonic-gate 		ulong_t off;
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate 		shp = section[i];
2080Sstevel@tonic-gate 		if (shp->sh_type != SHT_SYMTAB)
2090Sstevel@tonic-gate 			continue;
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate 		for (off = 0; off < shp->sh_size; off += shp->sh_entsize) {
2120Sstevel@tonic-gate 			sp = (Sym *)(shp->sh_addr + off);
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate 			if (sp->st_shndx == SHN_ABS ||
2150Sstevel@tonic-gate 			    sp->st_shndx == SHN_UNDEF)
2160Sstevel@tonic-gate 				continue;
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate 			/*
2190Sstevel@tonic-gate 			 * Assign the addresses for COMMON
2200Sstevel@tonic-gate 			 * symbols even though we haven't
2210Sstevel@tonic-gate 			 * actually allocated bss yet.
2220Sstevel@tonic-gate 			 */
2230Sstevel@tonic-gate 			if (sp->st_shndx == SHN_COMMON) {
2240Sstevel@tonic-gate 				end = ALIGN(end, sp->st_value);
2250Sstevel@tonic-gate 				sp->st_value = end;
2260Sstevel@tonic-gate 				/*
2270Sstevel@tonic-gate 				 * Squirrel it away for later.
2280Sstevel@tonic-gate 				 */
2290Sstevel@tonic-gate 				if (bootaux[BA_BSS].ba_val == 0)
2300Sstevel@tonic-gate 					bootaux[BA_BSS].ba_val = end;
2310Sstevel@tonic-gate 				end += sp->st_size;
2320Sstevel@tonic-gate 				continue;
2330Sstevel@tonic-gate 			} else if (sp->st_shndx > (Half)sh_num) {
2340Sstevel@tonic-gate 				BSVC_PUTCHAR(syscallp, '>');
2350Sstevel@tonic-gate 				return;
2360Sstevel@tonic-gate 			}
2370Sstevel@tonic-gate 
2380Sstevel@tonic-gate 			/*
2390Sstevel@tonic-gate 			 * Symbol's new address.
2400Sstevel@tonic-gate 			 */
2410Sstevel@tonic-gate 			sp->st_value += section[sp->st_shndx]->sh_addr;
2420Sstevel@tonic-gate 		}
2430Sstevel@tonic-gate 	}
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate 	/*
2460Sstevel@tonic-gate 	 * Allocate bss for COMMON, if any.
2470Sstevel@tonic-gate 	 */
2480Sstevel@tonic-gate 	if (end > edata) {
2490Sstevel@tonic-gate 		unsigned long va, bva;
2500Sstevel@tonic-gate 		unsigned long asize;
2510Sstevel@tonic-gate 		unsigned long align;
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate 		if (bootaux[BA_LPAGESZ].ba_val) {
2540Sstevel@tonic-gate 			asize = bootaux[BA_LPAGESZ].ba_val;
2550Sstevel@tonic-gate 			align = bootaux[BA_LPAGESZ].ba_val;
2560Sstevel@tonic-gate 		} else {
2570Sstevel@tonic-gate 			asize = bootaux[BA_PAGESZ].ba_val;
2580Sstevel@tonic-gate 			align = BO_NO_ALIGN;
2590Sstevel@tonic-gate 		}
2600Sstevel@tonic-gate 		va = roundup(edata, asize);
2610Sstevel@tonic-gate 		bva = roundup(end, asize);
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate 		if (bva > va) {
2640Sstevel@tonic-gate 			bva = (unsigned long)BOP_ALLOC(bop, (caddr_t)va,
2650Sstevel@tonic-gate 				bva - va, align);
2660Sstevel@tonic-gate 			if (bva == NULL)
2670Sstevel@tonic-gate 				return;
2680Sstevel@tonic-gate 		}
2690Sstevel@tonic-gate 		/*
2700Sstevel@tonic-gate 		 * Zero it.
2710Sstevel@tonic-gate 		 */
2720Sstevel@tonic-gate 		for (va = edata; va < end; va++)
2730Sstevel@tonic-gate 			*(char *)va = 0;
2740Sstevel@tonic-gate 		/*
2750Sstevel@tonic-gate 		 * Update the size of data.
2760Sstevel@tonic-gate 		 */
2770Sstevel@tonic-gate 		phdr->p_memsz += (end - edata);
2780Sstevel@tonic-gate 	}
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate 	/*
2810Sstevel@tonic-gate 	 * Relocate our own symbols.  We'll handle the
2820Sstevel@tonic-gate 	 * undefined symbols later.
2830Sstevel@tonic-gate 	 */
2840Sstevel@tonic-gate 	for (i = 1; i < sh_num; i++) {
2850Sstevel@tonic-gate 		Shdr *rshp, *shp, *ssp;
2860Sstevel@tonic-gate 		unsigned long baseaddr, reladdr, rend;
2870Sstevel@tonic-gate 		long relocsize;
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate 		rshp = section[i];
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate 		if (rshp->sh_type != SHT_RELA)
2920Sstevel@tonic-gate 			continue;
2930Sstevel@tonic-gate 		/*
2940Sstevel@tonic-gate 		 * Get the section being relocated
2950Sstevel@tonic-gate 		 * and the symbol table.
2960Sstevel@tonic-gate 		 */
2970Sstevel@tonic-gate 		shp = section[rshp->sh_info];
2980Sstevel@tonic-gate 		ssp = section[rshp->sh_link];
2990Sstevel@tonic-gate 
3000Sstevel@tonic-gate 		/*
3010Sstevel@tonic-gate 		 * Only perform relocations against allocatable
3020Sstevel@tonic-gate 		 * sections.
3030Sstevel@tonic-gate 		 */
3040Sstevel@tonic-gate 		if ((shp->sh_flags & SHF_ALLOC) == 0)
3050Sstevel@tonic-gate 			continue;
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate 		reladdr = rshp->sh_addr;
3080Sstevel@tonic-gate 		baseaddr = shp->sh_addr;
3090Sstevel@tonic-gate 		rend = reladdr + rshp->sh_size;
3100Sstevel@tonic-gate 		relocsize = rshp->sh_entsize;
3110Sstevel@tonic-gate 		/*
3120Sstevel@tonic-gate 		 * Loop through relocations.
3130Sstevel@tonic-gate 		 */
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate 		while (reladdr < rend) {
3160Sstevel@tonic-gate 			Sym *symref;
3170Sstevel@tonic-gate 			Rela *reloc;
3180Sstevel@tonic-gate 			unsigned long stndx;
3190Sstevel@tonic-gate 			unsigned long off, *offptr;
3200Sstevel@tonic-gate 			long addend, value;
3210Sstevel@tonic-gate 			unsigned long symoff, symsize;
3220Sstevel@tonic-gate 			int rtype;
3230Sstevel@tonic-gate 
3240Sstevel@tonic-gate 			reloc = (Rela *)reladdr;
3250Sstevel@tonic-gate 			off = reloc->r_offset;
3260Sstevel@tonic-gate 			addend = (long)reloc->r_addend;
3270Sstevel@tonic-gate 			rtype = ELF_R_TYPE(reloc->r_info);
3280Sstevel@tonic-gate 			stndx = ELF_R_SYM(reloc->r_info);
3290Sstevel@tonic-gate 
3300Sstevel@tonic-gate 			reladdr += relocsize;
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate 			if (rtype == R_AMD64_NONE)
3330Sstevel@tonic-gate 				continue;
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate 			off += baseaddr;
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate 			symsize = ssp->sh_entsize;
3380Sstevel@tonic-gate 			symoff = stndx * symsize;
3390Sstevel@tonic-gate 
3400Sstevel@tonic-gate 			/*
3410Sstevel@tonic-gate 			 * Check for bad symbol index.
3420Sstevel@tonic-gate 			 */
3430Sstevel@tonic-gate 			if (symoff > ssp->sh_size)
3440Sstevel@tonic-gate 				return;
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate 			symref = (Sym *)(ssp->sh_addr + symoff);
3470Sstevel@tonic-gate 
3480Sstevel@tonic-gate 
3490Sstevel@tonic-gate 			/*
3500Sstevel@tonic-gate 			 * Just bind our own symbols at this point.
3510Sstevel@tonic-gate 			 */
3520Sstevel@tonic-gate 			if (symref->st_shndx == SHN_UNDEF)
3530Sstevel@tonic-gate 				continue;
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate 			value = symref->st_value;
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate 			if ((rtype == R_AMD64_PC32) ||
3580Sstevel@tonic-gate 			    (rtype == R_AMD64_PLT32))
3590Sstevel@tonic-gate 				/*
3600Sstevel@tonic-gate 				 * If PC-relative, subtract ref addr.
3610Sstevel@tonic-gate 				 */
3620Sstevel@tonic-gate 				value -= off;
3630Sstevel@tonic-gate 			else if (rtype == R_AMD64_32) {
3640Sstevel@tonic-gate 				/*
3650Sstevel@tonic-gate 				 * It's illegal to have any HIBITS
3660Sstevel@tonic-gate 				 * set for R_AMD64_32 reloc.
3670Sstevel@tonic-gate 				 */
3680Sstevel@tonic-gate 				if (value & HIBITS) {
3690Sstevel@tonic-gate 					BSVC_PUTCHAR(syscallp, 'h');
3700Sstevel@tonic-gate 					return;
3710Sstevel@tonic-gate 				}
3720Sstevel@tonic-gate 			} else if (rtype == R_AMD64_32S) {
3730Sstevel@tonic-gate 				/*
3740Sstevel@tonic-gate 				 * All HIBITS for R_AMD64_32S
3750Sstevel@tonic-gate 				 * *must* be set.
3760Sstevel@tonic-gate 				 */
3770Sstevel@tonic-gate 				if ((value & HIBITS) != HIBITS) {
3780Sstevel@tonic-gate 					BSVC_PUTCHAR(syscallp, 'H');
3790Sstevel@tonic-gate 					return;
3800Sstevel@tonic-gate 				}
3810Sstevel@tonic-gate 			}
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate 			offptr = (unsigned long *)off;
3840Sstevel@tonic-gate 			/*
3850Sstevel@tonic-gate 			 * insert value calculated at reference point
3860Sstevel@tonic-gate 			 * 2 cases - normal byte order aligned, normal byte
3870Sstevel@tonic-gate 			 * order unaligned.
3880Sstevel@tonic-gate 			 */
3890Sstevel@tonic-gate 			switch (rtype) {
3900Sstevel@tonic-gate 			case R_AMD64_64:
3910Sstevel@tonic-gate 				*(unsigned long *)offptr = value + addend;
3920Sstevel@tonic-gate 				break;
3930Sstevel@tonic-gate 			case R_AMD64_PC32:
3940Sstevel@tonic-gate 			case R_AMD64_32S:
3950Sstevel@tonic-gate 			case R_AMD64_PLT32:
3960Sstevel@tonic-gate 				*(uint_t *)offptr = (uint_t)(value + addend);
3970Sstevel@tonic-gate 				break;
3980Sstevel@tonic-gate 			case R_AMD64_GOT32:
3990Sstevel@tonic-gate 				BSVC_PUTCHAR(syscallp, 'G');
4000Sstevel@tonic-gate 				return;
4010Sstevel@tonic-gate 			case R_AMD64_32:
4020Sstevel@tonic-gate 				return;
4030Sstevel@tonic-gate 			default:
4040Sstevel@tonic-gate 				BSVC_PUTCHAR(syscallp, 'R');
4050Sstevel@tonic-gate 				return;
4060Sstevel@tonic-gate 			}
4070Sstevel@tonic-gate 			/*
4080Sstevel@tonic-gate 			 * We only need to do it once.
4090Sstevel@tonic-gate 			 */
4100Sstevel@tonic-gate 			reloc->r_info = ELF_R_INFO(stndx, R_AMD64_NONE);
4110Sstevel@tonic-gate 		} /* while */
4120Sstevel@tonic-gate 	}
4130Sstevel@tonic-gate 
4140Sstevel@tonic-gate 	/*
4150Sstevel@tonic-gate 	 * Done relocating all of our *defined*
4160Sstevel@tonic-gate 	 * symbols, so we hand off.
4170Sstevel@tonic-gate 	 */
4180Sstevel@tonic-gate 	kobj_init(syscallp, dvec, bootops, bootaux);
4190Sstevel@tonic-gate }
420