/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* SPARC relocation code.
*/
#include <sys/sysmacros.h>
#include <sys/bootconf.h>
#include <sys/kobj_impl.h>
#include <sys/tnf_probe.h>
/*
* Probe discovery support
*/
/*
* The kernel run-time linker calls this to try to resolve a reference
* it can't otherwise resolve. We see if it's marking a probe control
* block or a probe tag block; if so, we do the resolution and return 0.
* If not, we return 1 to show that we can't resolve it, either.
*/
static int
long offset,
{
*addend_p = 0;
return (0);
}
*addend_p = 0;
return (0);
}
return (1);
}
static int
{
/*
* The "statically defined tracing" (SDT) provider for DTrace uses
* a mechanism similar to TNF, but somewhat simpler. (Surprise,
* surprise.) The SDT mechanism works by replacing calls to the
* undefined routine __dtrace_probe_[name] with nop instructions.
* The relocations are logged, and SDT itself will later patch the
* running binary appropriately.
*/
return (1);
/*
* This isn't an offset -- it's an absolute value. (This is
* typically only true for "unix".) We need to convert the
* value into an offset from mp->text.
*/
}
/*
* If the next instruction is a restore (any variant), then the probe
* point is being tail-called. Instead of patching the call to be a
* NOP, we must patch it to be a ret. If the next instruction is
* writing to %o7, it must be a tail call from a leaf; we must patch
* the instruction to be a retl.
*/
} else {
}
return (0);
}
int
/* ARGSUSED2 */
char *reltbl,
int nreloc,
int relocsize,
{
int symnum;
int err = 0;
#ifdef KOBJ_DEBUG
if (kobj_debug & D_RELOCATIONS) {
" symbol\n");
}
#endif
/*
* If this machine is loading a module through an alternate address
* we need to compute the spot where the actual relocation will
* take place.
*/
if (mp->destination) {
int i;
break;
}
}
}
symnum = -1;
/* loop through relocations */
symnum++;
"do_relocate: bad strndx %d\n", symnum);
return (-1);
}
rtype);
err = 1;
continue;
}
#ifdef KOBJ_DEBUG
if (kobj_debug & D_RELOCATIONS) {
}
#endif
if (rtype == R_SPARC_NONE)
continue;
off += destination;
/*
* if R_SPARC_RELATIVE, simply add base addr
* to reloc location
*/
if (rtype == R_SPARC_RELATIVE) {
} else {
/*
* get symbol table entry - if symbol is local
* value is base address of this object
*/
/* *** this is different for .o and .so */
} else {
/*
* It's global. Allow weak references. If
* the symbol is undefined, give TNF (the
* kernel probes facility) a chance to see
* if it's a probe site, and fix it up if so.
*/
continue;
!= STB_WEAK) {
"not found: %s\n",
err = 1;
}
continue;
} else { /* symbol found - relocate */
/*
* calculate location of definition
* - symbol value plus base address of
* containing shared object
*/
} /* end else symbol found */
}
} /* end not R_SPARC_RELATIVE */
if (IS_EXTOFFSET(rtype)) {
value +=
}
/*
* calculate final value -
* if PC-relative, subtract ref addr
*/
if (IS_PC_RELATIVE(rtype)) {
if (mp->destination)
else
}
#ifdef KOBJ_DEBUG
if (kobj_debug & D_RELOCATIONS) {
}
#endif
err = 1;
} /* end of while loop */
if (err)
return (-1);
return (0);
}
int
{
/* do the relocations */
return (-1);
}
continue;
return (-1);
}
goto bad;
}
/* get the section header that this reloc table refers to */
/*
* Do not relocate any section that isn't loaded into memory.
* Most commonly this will skip over the .rela.stab* sections
*/
continue;
#ifdef KOBJ_DEBUG
if (kobj_debug & D_RELOCATIONS) {
}
#endif
"do_relocations: %s do_relocate failed\n",
goto bad;
}
}
return (0);
bad:
return (-1);
}