/*
* 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
*/
/*
*/
#ifndef _RELOC_DOT_H
#define _RELOC_DOT_H
#if defined(_KERNEL)
#include <sys/bootconf.h>
#include <sys/kobj_impl.h>
#else
#include <rtld.h>
#include <conv.h>
#endif /* _KERNEL */
#include "reloc_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Global include file for relocation common code.
*/
/*
* In user land, redefine the relocation table and relocation engine to be
* reside within a single instance of libld.
*/
#if !defined(_KERNEL)
#if defined(DO_RELOC_LIBLD)
#endif
#if defined(DO_RELOC_LIBLD_X86)
#define DO_RELOC_LIBLD
#if defined(_ELF64)
#else
#endif
#elif defined(DO_RELOC_LIBLD_SPARC)
#define DO_RELOC_LIBLD
#if defined(_ELF64)
#else
#endif
#else /* rtld */
#if defined(_ELF64)
#else
#endif
#endif
#endif /* !_KERNEL */
/*
* Relocation table and macros for testing relocation table flags.
*/
extern const Rel_entry reloc_table[];
/*
* Relocation engine.
*
* The do_reloc() code is used in three different places: The kernel,
* the link-editor, and the runtime linker. All three convey the same
* basic information with the first 5 arguments:
*
* 1) Relocation type. The kernel and runtime linker pass this as
* an integer value, while the link-editor passes it as a Rel_desc
* descriptor. The relocation engine only looks at the rel_rtype
* field of this descriptor, and does not examine the other fields,
* which are explicitly allowed to contain garbage.
* 2) Address of offset
* 3) Address of value
* 4) Name of symbol associated with the relocation, used if it is
* necessary to report an error. The kernel and runtime linker pass
* directly as a string pointer. The link-editor passes the address
* of a rel_desc_sname_func_t function, which can be called by do_reloc(),
* passing it the Rel_desc pointer (argument 1, above), to obtain the
* string pointer.
* 5) String giving the source file for the relocation.
*
* In addition:
* - The linker and rtld want a link map pointer argument
* - The linker wants to pass a byte swap argument that tells
* the relocation engine that the data it is relocating
* has the opposite byte order of the system running the
* linker.
* - The linker is a cross-linker, meaning that it can examine
* relocation records for target hosts other than that of
* the currently running system. This means that multiple
* versions of the relocation code must be able to reside
* in a single program, without namespace clashes.
*
* To ensure that there is never any confusion about which version is
* being linked to, we give each variant a different name, even though
* each one is generated from the same source code.
*
* do_reloc_krtld()
* The kernel version is provided if the _KERNEL macro is defined.
*
* do_reloc_ld()
* The ld version is provided if the DO_RELOC_LIBLD_ macro is defined.
*
* do_reloc_rtld()
* The rtld version is provided if neither _KERNEL or DO_RELOC_LIBLD
* are defined.
*
* Implementations of do_reloc() should use these same macros to
* conditionalize any code not used by all three versions.
*/
#if defined(_KERNEL)
const char *);
#elif defined(DO_RELOC_LIBLD)
rel_desc_sname_func_t, const char *, int, void *);
#else
const char *, void *);
#endif
#if defined(_KERNEL)
/*
* These are macro's that are only needed for krtld. Many of these are already
*/
/*
* Message strings used by doreloc().
*/
/*
* Provide a macro to select the appropriate conversion routine for this
* architecture.
*/
#if defined(__amd64)
extern const char *conv_reloc_amd64_type(Word);
extern const char *conv_reloc_386_type(Word);
extern const char *conv_reloc_SPARC_type(Word);
#else
#endif
/*
* Note: dlerror() only keeps track of a single error string, and therefore
* must have errors reported through a single eprintf() call. The kernel's
* _kobj_printf is somewhat more limited, and must receive messages with only
* one argument to the format string. The following macros account for these
* differences, as krtld and rtld share the same do_reloc() source.
*/
#else /* !_KERNEL */
extern const char *demangle(const char *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _RELOC_DOT_H */