17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55aefb655Srie * Common Development and Distribution License (the "License"). 65aefb655Srie * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 215aefb655Srie 227c478bd9Sstevel@tonic-gate /* 23*f3324781Sab196087 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * x86 relocation code. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/types.h> 347c478bd9Sstevel@tonic-gate #include <sys/param.h> 357c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 367c478bd9Sstevel@tonic-gate #include <sys/systm.h> 377c478bd9Sstevel@tonic-gate #include <sys/user.h> 387c478bd9Sstevel@tonic-gate #include <sys/bootconf.h> 397c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 407c478bd9Sstevel@tonic-gate #include <sys/elf.h> 417c478bd9Sstevel@tonic-gate #include <sys/kobj.h> 427c478bd9Sstevel@tonic-gate #include <sys/kobj_impl.h> 437c478bd9Sstevel@tonic-gate #include <sys/tnf.h> 447c478bd9Sstevel@tonic-gate #include <sys/tnf_probe.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #include "reloc.h" 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Probe Discovery 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #define PROBE_MARKER_SYMBOL "__tnf_probe_version_1" 547c478bd9Sstevel@tonic-gate #define TAG_MARKER_SYMBOL "__tnf_tag_version_1" 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate extern int tnf_splice_probes(int, tnf_probe_control_t *, tnf_tag_data_t *); 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * The kernel run-time linker calls this to try to resolve a reference 607c478bd9Sstevel@tonic-gate * it can't otherwise resolve. We see if it's marking a probe control 617c478bd9Sstevel@tonic-gate * block; if so, we do the resolution and return 0. If not, we return 627c478bd9Sstevel@tonic-gate * 1 to show that we can't resolve it, either. 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate static int 657c478bd9Sstevel@tonic-gate tnf_reloc_resolve(char *symname, 667c478bd9Sstevel@tonic-gate Addr *value_p, 677c478bd9Sstevel@tonic-gate long offset, 687c478bd9Sstevel@tonic-gate tnf_probe_control_t **probelist, 697c478bd9Sstevel@tonic-gate tnf_tag_data_t **taglist) 707c478bd9Sstevel@tonic-gate { 717c478bd9Sstevel@tonic-gate if (strcmp(symname, PROBE_MARKER_SYMBOL) == 0) { 727c478bd9Sstevel@tonic-gate ((tnf_probe_control_t *)offset)->next = *probelist; 737c478bd9Sstevel@tonic-gate *probelist = (tnf_probe_control_t *)offset; 747c478bd9Sstevel@tonic-gate return (0); 757c478bd9Sstevel@tonic-gate } 767c478bd9Sstevel@tonic-gate if (strcmp(symname, TAG_MARKER_SYMBOL) == 0) { 777c478bd9Sstevel@tonic-gate *value_p = (Addr)*taglist; 787c478bd9Sstevel@tonic-gate *taglist = (tnf_tag_data_t *)offset; 797c478bd9Sstevel@tonic-gate return (0); 807c478bd9Sstevel@tonic-gate } 817c478bd9Sstevel@tonic-gate return (1); 827c478bd9Sstevel@tonic-gate } 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate #define SDT_NOP 0x90 857c478bd9Sstevel@tonic-gate #define SDT_NOPS 5 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate static int 887c478bd9Sstevel@tonic-gate sdt_reloc_resolve(struct module *mp, char *symname, uint8_t *instr) 897c478bd9Sstevel@tonic-gate { 907c478bd9Sstevel@tonic-gate sdt_probedesc_t *sdp; 917c478bd9Sstevel@tonic-gate int i; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * The "statically defined tracing" (SDT) provider for DTrace uses 957c478bd9Sstevel@tonic-gate * a mechanism similar to TNF, but somewhat simpler. (Surprise, 967c478bd9Sstevel@tonic-gate * surprise.) The SDT mechanism works by replacing calls to the 977c478bd9Sstevel@tonic-gate * undefined routine __dtrace_probe_[name] with nop instructions. 987c478bd9Sstevel@tonic-gate * The relocations are logged, and SDT itself will later patch the 997c478bd9Sstevel@tonic-gate * running binary appropriately. 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate if (strncmp(symname, sdt_prefix, strlen(sdt_prefix)) != 0) 1027c478bd9Sstevel@tonic-gate return (1); 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate symname += strlen(sdt_prefix); 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate sdp = kobj_alloc(sizeof (sdt_probedesc_t), KM_WAIT); 1077c478bd9Sstevel@tonic-gate sdp->sdpd_name = kobj_alloc(strlen(symname) + 1, KM_WAIT); 1087c478bd9Sstevel@tonic-gate bcopy(symname, sdp->sdpd_name, strlen(symname) + 1); 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate sdp->sdpd_offset = (uintptr_t)instr; 1117c478bd9Sstevel@tonic-gate sdp->sdpd_next = mp->sdt_probes; 1127c478bd9Sstevel@tonic-gate mp->sdt_probes = sdp; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate for (i = 0; i < SDT_NOPS; i++) 1157c478bd9Sstevel@tonic-gate instr[i - 1] = SDT_NOP; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate return (0); 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate int 1217c478bd9Sstevel@tonic-gate /* ARGSUSED2 */ 1227c478bd9Sstevel@tonic-gate do_relocate(struct module *mp, char *reltbl, Word relshtype, int nreloc, 1237c478bd9Sstevel@tonic-gate int relocsize, Addr baseaddr) 1247c478bd9Sstevel@tonic-gate { 1257c478bd9Sstevel@tonic-gate unsigned long stndx; 1267c478bd9Sstevel@tonic-gate unsigned long off; /* can't be register for tnf_reloc_resolve() */ 1277c478bd9Sstevel@tonic-gate register unsigned long reladdr, rend; 1287c478bd9Sstevel@tonic-gate register unsigned int rtype; 1297c478bd9Sstevel@tonic-gate long value; 1307c478bd9Sstevel@tonic-gate Sym *symref; 1317c478bd9Sstevel@tonic-gate int err = 0; 1327c478bd9Sstevel@tonic-gate tnf_probe_control_t *probelist = NULL; 1337c478bd9Sstevel@tonic-gate tnf_tag_data_t *taglist = NULL; 1347c478bd9Sstevel@tonic-gate int symnum; 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate reladdr = (unsigned long)reltbl; 1377c478bd9Sstevel@tonic-gate rend = reladdr + nreloc * relocsize; 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate #ifdef KOBJ_DEBUG 1407c478bd9Sstevel@tonic-gate if (kobj_debug & D_RELOCATIONS) { 1417c478bd9Sstevel@tonic-gate _kobj_printf(ops, "krtld:\ttype\t\t\toffset symbol\n"); 1427c478bd9Sstevel@tonic-gate _kobj_printf(ops, "krtld:\t\t\t\t\t value\n"); 1437c478bd9Sstevel@tonic-gate } 1447c478bd9Sstevel@tonic-gate #endif 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate symnum = -1; 1477c478bd9Sstevel@tonic-gate /* loop through relocations */ 1487c478bd9Sstevel@tonic-gate while (reladdr < rend) { 1497c478bd9Sstevel@tonic-gate symnum++; 1507c478bd9Sstevel@tonic-gate rtype = ELF32_R_TYPE(((Rel *)reladdr)->r_info); 1517c478bd9Sstevel@tonic-gate off = ((Rel *)reladdr)->r_offset; 1527c478bd9Sstevel@tonic-gate stndx = ELF32_R_SYM(((Rel *)reladdr)->r_info); 1537c478bd9Sstevel@tonic-gate if (stndx >= mp->nsyms) { 1547c478bd9Sstevel@tonic-gate _kobj_printf(ops, "do_relocate: bad strndx %d\n", 1557c478bd9Sstevel@tonic-gate symnum); 1567c478bd9Sstevel@tonic-gate return (-1); 1577c478bd9Sstevel@tonic-gate } 158d326b23bSrie if ((rtype > R_386_NUM) || IS_TLS_INS(rtype)) { 1597c478bd9Sstevel@tonic-gate _kobj_printf(ops, "krtld: invalid relocation type %d", 1607c478bd9Sstevel@tonic-gate rtype); 1617c478bd9Sstevel@tonic-gate _kobj_printf(ops, " at 0x%llx:", off); 1627c478bd9Sstevel@tonic-gate _kobj_printf(ops, " file=%s\n", mp->filename); 1637c478bd9Sstevel@tonic-gate err = 1; 1647c478bd9Sstevel@tonic-gate continue; 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate reladdr += relocsize; 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate if (rtype == R_386_NONE) 1727c478bd9Sstevel@tonic-gate continue; 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate #ifdef KOBJ_DEBUG 1757c478bd9Sstevel@tonic-gate if (kobj_debug & D_RELOCATIONS) { 1767c478bd9Sstevel@tonic-gate Sym * symp; 1777c478bd9Sstevel@tonic-gate symp = (Sym *) 1787c478bd9Sstevel@tonic-gate (mp->symtbl+(stndx * mp->symhdr->sh_entsize)); 1797c478bd9Sstevel@tonic-gate _kobj_printf(ops, "krtld:\t%s", 1805aefb655Srie conv_reloc_386_type(rtype)); 1817c478bd9Sstevel@tonic-gate _kobj_printf(ops, "\t0x%8x", off); 1827c478bd9Sstevel@tonic-gate _kobj_printf(ops, " %s\n", 1837c478bd9Sstevel@tonic-gate (const char *)mp->strings + symp->st_name); 1847c478bd9Sstevel@tonic-gate } 1857c478bd9Sstevel@tonic-gate #endif 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate if (!(mp->flags & KOBJ_EXEC)) 1887c478bd9Sstevel@tonic-gate off += baseaddr; 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate /* 1917c478bd9Sstevel@tonic-gate * if R_386_RELATIVE, simply add base addr 1927c478bd9Sstevel@tonic-gate * to reloc location 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate if (rtype == R_386_RELATIVE) { 1967c478bd9Sstevel@tonic-gate value = baseaddr; 1977c478bd9Sstevel@tonic-gate } else { 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate * get symbol table entry - if symbol is local 2007c478bd9Sstevel@tonic-gate * value is base address of this object 2017c478bd9Sstevel@tonic-gate */ 2027c478bd9Sstevel@tonic-gate symref = (Sym *) 2037c478bd9Sstevel@tonic-gate (mp->symtbl+(stndx * mp->symhdr->sh_entsize)); 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate if (ELF32_ST_BIND(symref->st_info) == STB_LOCAL) { 2067c478bd9Sstevel@tonic-gate /* *** this is different for .o and .so */ 2077c478bd9Sstevel@tonic-gate value = symref->st_value; 2087c478bd9Sstevel@tonic-gate } else { 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * It's global. Allow weak references. If 2117c478bd9Sstevel@tonic-gate * the symbol is undefined, give TNF (the 2127c478bd9Sstevel@tonic-gate * kernel probes facility) a chance to see 2137c478bd9Sstevel@tonic-gate * if it's a probe site, and fix it up if so. 2147c478bd9Sstevel@tonic-gate */ 2157c478bd9Sstevel@tonic-gate if (symref->st_shndx == SHN_UNDEF && 2167c478bd9Sstevel@tonic-gate sdt_reloc_resolve(mp, mp->strings + 2177c478bd9Sstevel@tonic-gate symref->st_name, (uint8_t *)off) == 0) 2187c478bd9Sstevel@tonic-gate continue; 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate if (symref->st_shndx == SHN_UNDEF && 2217c478bd9Sstevel@tonic-gate tnf_reloc_resolve(mp->strings + 2227c478bd9Sstevel@tonic-gate symref->st_name, &symref->st_value, 223*f3324781Sab196087 off, &probelist, &taglist) != 0) { 2247c478bd9Sstevel@tonic-gate if (ELF32_ST_BIND(symref->st_info) 2257c478bd9Sstevel@tonic-gate != STB_WEAK) { 2267c478bd9Sstevel@tonic-gate _kobj_printf(ops, 2277c478bd9Sstevel@tonic-gate "not found: %s\n", 2287c478bd9Sstevel@tonic-gate mp->strings + 2297c478bd9Sstevel@tonic-gate symref->st_name); 2307c478bd9Sstevel@tonic-gate err = 1; 2317c478bd9Sstevel@tonic-gate } 2327c478bd9Sstevel@tonic-gate continue; 2337c478bd9Sstevel@tonic-gate } else { /* symbol found - relocate */ 2347c478bd9Sstevel@tonic-gate /* 2357c478bd9Sstevel@tonic-gate * calculate location of definition 2367c478bd9Sstevel@tonic-gate * - symbol value plus base address of 2377c478bd9Sstevel@tonic-gate * containing shared object 2387c478bd9Sstevel@tonic-gate */ 2397c478bd9Sstevel@tonic-gate value = symref->st_value; 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate } /* end else symbol found */ 2427c478bd9Sstevel@tonic-gate } /* end global or weak */ 2437c478bd9Sstevel@tonic-gate } /* end not R_386_RELATIVE */ 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate /* 2467c478bd9Sstevel@tonic-gate * calculate final value - 2477c478bd9Sstevel@tonic-gate * if PC-relative, subtract ref addr 2487c478bd9Sstevel@tonic-gate */ 2497c478bd9Sstevel@tonic-gate if (IS_PC_RELATIVE(rtype)) 2507c478bd9Sstevel@tonic-gate value -= off; 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate #ifdef KOBJ_DEBUG 2537c478bd9Sstevel@tonic-gate if (kobj_debug & D_RELOCATIONS) { 2547c478bd9Sstevel@tonic-gate _kobj_printf(ops, "krtld:\t\t\t\t0x%8x", off); 2557c478bd9Sstevel@tonic-gate _kobj_printf(ops, " 0x%8x\n", value); 2567c478bd9Sstevel@tonic-gate } 2577c478bd9Sstevel@tonic-gate #endif 2587c478bd9Sstevel@tonic-gate 259*f3324781Sab196087 if (do_reloc_krtld(rtype, (unsigned char *)off, (Word *)&value, 2607c478bd9Sstevel@tonic-gate (const char *)mp->strings + symref->st_name, 261*f3324781Sab196087 mp->filename) == 0) 2627c478bd9Sstevel@tonic-gate err = 1; 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate } /* end of while loop */ 2657c478bd9Sstevel@tonic-gate if (err) 2667c478bd9Sstevel@tonic-gate return (-1); 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate if (tnf_splice_probes(mp->flags & KOBJ_PRIM, probelist, taglist)) 2697c478bd9Sstevel@tonic-gate mp->flags |= KOBJ_TNF_PROBE; 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate return (0); 2727c478bd9Sstevel@tonic-gate } 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate int 2757c478bd9Sstevel@tonic-gate do_relocations(struct module *mp) 2767c478bd9Sstevel@tonic-gate { 2777c478bd9Sstevel@tonic-gate uint_t shn; 2787c478bd9Sstevel@tonic-gate Shdr *shp, *rshp; 2797c478bd9Sstevel@tonic-gate uint_t nreloc; 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate /* do the relocations */ 2827c478bd9Sstevel@tonic-gate for (shn = 1; shn < mp->hdr.e_shnum; shn++) { 2837c478bd9Sstevel@tonic-gate rshp = (Shdr *) 2847c478bd9Sstevel@tonic-gate (mp->shdrs + shn * mp->hdr.e_shentsize); 2857c478bd9Sstevel@tonic-gate if (rshp->sh_type == SHT_RELA) { 2867c478bd9Sstevel@tonic-gate _kobj_printf(ops, "%s can't process type SHT_RELA\n", 2877c478bd9Sstevel@tonic-gate mp->filename); 2887c478bd9Sstevel@tonic-gate return (-1); 2897c478bd9Sstevel@tonic-gate } 2907c478bd9Sstevel@tonic-gate if (rshp->sh_type != SHT_REL) 2917c478bd9Sstevel@tonic-gate continue; 2927c478bd9Sstevel@tonic-gate if (rshp->sh_link != mp->symtbl_section) { 2937c478bd9Sstevel@tonic-gate _kobj_printf(ops, "%s reloc for non-default symtab\n", 2947c478bd9Sstevel@tonic-gate mp->filename); 2957c478bd9Sstevel@tonic-gate return (-1); 2967c478bd9Sstevel@tonic-gate } 2977c478bd9Sstevel@tonic-gate if (rshp->sh_info >= mp->hdr.e_shnum) { 2987c478bd9Sstevel@tonic-gate _kobj_printf(ops, "do_relocations: %s sh_info ", 2997c478bd9Sstevel@tonic-gate mp->filename); 3007c478bd9Sstevel@tonic-gate _kobj_printf(ops, "out of range %d\n", shn); 3017c478bd9Sstevel@tonic-gate goto bad; 3027c478bd9Sstevel@tonic-gate } 3037c478bd9Sstevel@tonic-gate nreloc = rshp->sh_size / rshp->sh_entsize; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate /* get the section header that this reloc table refers to */ 3067c478bd9Sstevel@tonic-gate shp = (Shdr *) 3077c478bd9Sstevel@tonic-gate (mp->shdrs + rshp->sh_info * mp->hdr.e_shentsize); 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate /* 3107c478bd9Sstevel@tonic-gate * Do not relocate any section that isn't loaded into memory. 3117c478bd9Sstevel@tonic-gate * Most commonly this will skip over the .rela.stab* sections 3127c478bd9Sstevel@tonic-gate */ 3137c478bd9Sstevel@tonic-gate if (!(shp->sh_flags & SHF_ALLOC)) 3147c478bd9Sstevel@tonic-gate continue; 3157c478bd9Sstevel@tonic-gate #ifdef KOBJ_DEBUG 3167c478bd9Sstevel@tonic-gate if (kobj_debug & D_RELOCATIONS) { 3177c478bd9Sstevel@tonic-gate _kobj_printf(ops, "krtld: relocating: file=%s ", 3187c478bd9Sstevel@tonic-gate mp->filename); 3197c478bd9Sstevel@tonic-gate _kobj_printf(ops, "section=%d\n", shn); 3207c478bd9Sstevel@tonic-gate } 3217c478bd9Sstevel@tonic-gate #endif 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate if (do_relocate(mp, (char *)rshp->sh_addr, rshp->sh_type, 3247c478bd9Sstevel@tonic-gate nreloc, rshp->sh_entsize, shp->sh_addr) < 0) { 3257c478bd9Sstevel@tonic-gate _kobj_printf(ops, 3267c478bd9Sstevel@tonic-gate "do_relocations: %s do_relocate failed\n", 3277c478bd9Sstevel@tonic-gate mp->filename); 3287c478bd9Sstevel@tonic-gate goto bad; 3297c478bd9Sstevel@tonic-gate } 3307c478bd9Sstevel@tonic-gate kobj_free((void *)rshp->sh_addr, rshp->sh_size); 3317c478bd9Sstevel@tonic-gate rshp->sh_addr = 0; 3327c478bd9Sstevel@tonic-gate } 3337c478bd9Sstevel@tonic-gate mp->flags |= KOBJ_RELOCATED; 3347c478bd9Sstevel@tonic-gate return (0); 3357c478bd9Sstevel@tonic-gate bad: 3367c478bd9Sstevel@tonic-gate kobj_free((void *)rshp->sh_addr, rshp->sh_size); 3377c478bd9Sstevel@tonic-gate rshp->sh_addr = 0; 3387c478bd9Sstevel@tonic-gate return (-1); 3397c478bd9Sstevel@tonic-gate } 340