/*
* 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"
/*
* x86 relocation code.
*/
#include <sys/sysmacros.h>
#include <sys/bootconf.h>
#include <sys/kobj_impl.h>
#include <sys/tnf_probe.h>
#include "reloc.h"
/*
* Probe Discovery
*/
/*
* 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; 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
{
int i;
/*
* 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);
for (i = 0; i < SDT_NOPS; i++)
return (0);
}
int
/* ARGSUSED2 */
{
unsigned long stndx;
register unsigned int rtype;
unsigned long value;
int err = 0;
int symnum;
#ifdef KOBJ_DEBUG
if (kobj_debug & D_RELOCATIONS) {
" symbol\n");
}
#endif
symnum = -1;
/* loop through relocations */
symnum++;
symnum);
return (-1);
}
rtype);
err = 1;
continue;
}
if (rtype == R_AMD64_NONE)
continue;
#ifdef KOBJ_DEBUG
if (kobj_debug & D_RELOCATIONS) {
}
#endif
/*
* if R_AMD64_RELATIVE, simply add base addr
* to reloc location
*/
if (rtype == R_AMD64_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 global or weak */
} /* end not R_AMD64_RELATIVE */
/*
* calculate final value -
* if PC-relative, subtract ref addr
*/
if (IS_PC_RELATIVE(rtype))
#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);
}