analyze.c revision c174926f3ba44d30fdb24cfb4d93ae3fce579601
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 1988 AT&T
* All Rights Reserved
*
*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "_synonyms.h"
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <dlfcn.h>
#include <errno.h>
#include <link.h>
#include "_rtld.h"
#include "_audit.h"
#include "_elf.h"
#include "msg.h"
#include "debug.h"
#include "conv.h"
&elf_fct,
#ifdef A_OUT
&aout_fct,
#endif
0
};
/*
* If a load filter flag is in effect, and this object is a filter, trigger the
* loading of all its filtees. The load filter flag is in effect when creating
* configuration files, or when under the control of ldd(1), or the LD_LOADFLTR
* environment variable is set, or this object was built with the -zloadfltr
* flag. Otherwise, filtee loading is deferred until triggered by a relocation.
*/
static void
{
(rtld_flags & RT_FL_NOAUXFLTR)))
continue;
}
}
}
/*
* Analyze one or more link-maps of a link map control list. This routine is
* called at startup to continue the processing of the main executable. It is
* also called each time a new set of objects are loaded, ie. from filters,
* lazy-loaded objects, or dlopen().
*
* In each instance we traverse the link-map control list starting with the
* initial object. As dependencies are analyzed they are added to the link-map
* control list. Thus the list grows as we traverse it - this results in the
* breadth first ordering of all needed objects.
*/
int
{
int ret = 1;
/*
* If this link-map control list is being analyzed, return. The object
* that has just been added will be picked up by the existing analysis
* thread. Note, this is only really meaningful during process init-
* ialization, as objects are added to the main link-map control list.
* Following this initialization, each family of objects that are loaded
* are added to a new link-map control list.
*/
/* LINTED */
return (1);
/*
* If this object doesn't belong to the present link-map control list
* then it must already have been analyzed, or it is in the process of
* being analyzed prior to us recursing into this analysis. In either
* case, ignore the object as it's already being taken care of.
*/
return (1);
continue;
/*
* Indicate that analyzing is under way.
*/
/*
* If this link map represents a relocatable object, then we
* need to finish the link-editing of the object at this point.
*/
continue;
ret = 0;
break;
}
}
/*
* Establish any dependencies this object requires.
*/
continue;
ret = 0;
break;
}
/*
* If we're building a configuration file, determine if this
* object is a filter and if so load its filtees. This
* traversal is only necessary for crle(1), as typical use of
* an object will load filters as part of relocation processing.
*/
/*
* If an interposer has been added, it will have been inserted
* in the link-map before the link we're presently analyzing.
* Break out of this analysis loop and return to the head of
* the link-map control list to analyze the interposer. Note
* that this rescan preserves the breadth first loading of
* dependencies.
*/
/* LINTED */
}
}
/* LINTED */
return (ret);
}
/*
* Copy relocation test. If the symbol definition is within .bss, then it's
* zero filled, and as the destination is within .bss, we can skip copying
* zero's to zero's. However, if the destination object has a MOVE table, it's
* .bss might contain non-zero data, in which case copy it regardless.
*/
static int
{
return (1);
}
}
return (0);
}
/*
* Relocate an individual object.
*/
static int
{
/*
* If we're running under ldd(1), and haven't been asked to trace any
* warnings, skip any actual relocation processing.
*/
if (relocated)
(*relocated)++;
return (0);
}
return (1);
}
/*
* Relocate the objects on a link-map control list.
*/
static int
{
/*
* If this object has already been relocated, we're done. If
* this object is being deleted, skip it, there's probably a
* relocation error somewhere that's causing this deletion.
*/
continue;
/*
* Indicate that relocation processing is under way.
*/
/*
* Relocate the object.
*/
return (0);
/*
* Indicate that the objects relocation is complete.
*/
/*
* Mark this object's init is available for harvesting. Under
* ldd(1) this marking is necessary for -i (tsort) gathering.
*/
/*
* None of the following processing is necessary under ldd().
*/
/*
* Process any move data.
*/
/*
* Process any DT_SUNW_RTLDINFO information now the
* object is relocated, and remove the RTLDINFO
* infrastructure as it won't be needed anymore.
*
* We wait until lmp == lm_info_lmp, as it's at this
* stage we know the object contributing RTLDINFO has
* been properly relocated.
*/
Lc_interface ** funcs;
lml->lm_rtldinfo = 0;
}
}
/*
* Determine if this object is a filter, and if a load filter
* flag is in effect, trigger the loading of all its filtees.
*/
}
/*
* Perform special copy relocations. These are only meaningful for
* dynamic executables (fixed and head of their link-map list). If
* this ever has to change then the infrastructure of COPY() has to
* change as presently this element is used to capture both receiver
* and supplier of copy data.
*/
/* XX64 don't need this once the compilers are fixed */
if (elf_copy_gen(nlmp) == 0)
return (0);
#endif
return (1);
(((rtld_flags & RT_FL_SILENCERR) == 0) ||
tracing = 1;
else
tracing = 0;
DBG_CALL(Dbg_util_nl());
int zero;
/*
* Only copy the bits if it's from non-zero
* filled memory.
*/
if (zero)
continue;
FL1_RT_DISPREL) == 0))
continue;
}
}
DBG_CALL(Dbg_util_nl());
}
return (1);
}
int
{
/*
* If this link-map control list is being relocated, return. The object
* that has just been added will be picked up by the existing relocation
* thread. Note, this is only really meaningful during process init-
* ialization, as objects are added to the main link-map control list.
* Following this initialization, each family of objects that are loaded
* are added to a new link-map control list.
*/
/* LINTED */
return (1);
/*
* Relocate one or more link-maps of a link map control list. If this
* object doesn't belong to the present link-map control list then it
* must already have been relocated, or it is in the process of being
* relocated prior to us recursing into this relocation. In either
* case, ignore the object as it's already being taken care of, however,
* fall through and capture any relocation promotions that might have
* been established from the reference mode of this object.
*
* If we're generating a configuration file using crle(1), two passes
* may be involved. Under the first pass, RTLD_CONFGEN is set. Under
* this pass, crle() loads objects into the process address space. No
* relocation is necessary at this point, we simply need to analyze the
* objects to insure any directly bound dependencies, filtees, etc.
* get loaded. Although we skip the relocation, fall through to insure
* any control lists are maintained appropriately.
*
* If objects are to be dldump(3c)'ed, crle(1) makes a second pass,
* using RTLD_NOW and RTLD_CONFGEN. The RTLD_NOW effectively carries
* out the relocations of all loaded objects.
*/
int relocated = 0;
/*
* Determine whether the initial link-map control list has
* started relocation. From this point, should any interposing
* objects be added to this link-map control list, the objects
* are demoted to standard objects. Their interposition can't
* be guaranteed once relocations have been carried out.
*/
/*
* Relocate the link-map control list.
*/
/*
* At this point we've completed the addition of a new group of
* objects, either the initial objects that start the process
* (called from setup()), a group added through lazy loading or
* filters, or from a dlopen() request. Indicate to the
* debuggers that new objects have been added.
*/
}
/*
* Determine the new, and previous link-map control lists.
*/
/* LINTED */
} else {
/* LINTED */
}
/*
* Having completed this control list of objects, they can now be bound
* to from other objects. Move this control list to the control list
* that precedes it. Although this control list may have only bound to
* controls lists much higher up the control list stack, it must only
* be moved up one control list so as to preserve the link-map order
* that may have already been traversed in search of symbols.
*/
/*
* Determine whether existing objects that have already been relocated,
* need any additional relocations performed. This can occur when new
* objects are loaded with RTLD_NOW, and these new objects have
* dependencies on objects that are already loaded. Note, that we peel
* any relocation promotions off of one control list at a time. This
* prevents relocations from being bound to objects that might yet fail
* to relocate themselves.
*/
/*
* Remove the relocation promotion list, as performing more
* relocations may result in discovering more objects that need
* promotion.
*/
/*
* If the original relocation of the link-map control
* list failed, or one of the relocation promotions of
* this loop has failed, demote any pending objects
* relocation mode.
*/
continue;
}
/*
* If a relocation fails, save the error condition.
* It's possible that all new objects on the original
* link-map control list have been relocated
* successfully, but if the user request requires
* promoting objects that have already been loaded, we
* have to indicate that this operation couldn't be
* performed. The unrelocated objects are in use on
* another control list, and may continue to be used.
* If the .plt that resulted in the error is called,
* then the process will receive a fatal error at that
* time. But, the .plt may never be called.
*/
pret = 0;
}
/*
* Having promoted any objects, determine whether additional
* dependencies were added, and if so move them to the previous
* link-map control list.
*/
/* LINTED */
/* LINTED */
}
/*
* Indicate that relocations are no longer active for this control list.
*/
/* LINTED */
return (1);
else
return (0);
}
/*
* Inherit the first rejection message for possible later diagnostics.
*
* Any attempt to process a file that is unsuccessful, should be accompanied
* with an error diagnostic. However, some operations like searching for a
* simple filename, involve trying numerous paths, and an error message for each
* lookup is not required. Although a multiple search can fail, it's possible
* that a file was found, but was rejected because it was the wrong type.
* To satisfy these possibilities, the first failure is recorded as a rejection
* message, and this message is used later for a more specific diagnostic.
*
* File searches are focused at load_one(), and from here a rejection descriptor
* is passed down to various child routines. If these child routines can
* process multiple files, then they will maintain their own rejection desc-
* riptor. This is filled in for any failures, and a diagnostic produced to
* reflect the failure. The child routines then employ rejection_inherit() to
* pass the first rejection message back to load_one().
*
* Note that the name, and rejection string must be duplicated, as the name
* buffer and error string buffer (see conv_ routines) may be reused for
* additional processing or rejection messages.
*
* As this routine is called to clean up after a failed open, remove any
* resolved pathname that might have been allocated as the file was processed.
*/
void
{
}
}
}
}
/*
* Determine the object type of a file.
*/
Fct *
{
int i;
char *maddr = 0;
/*
* If this is a directory (which can't be mmap()'ed) generate a precise
* error message.
*/
return (0);
}
/*
* Map in the first page of the file. When this buffer is first used,
* the mapping is a single system page. This is typically enough to
* inspect the ehdr and phdrs of the file, and can be reused for each
* file that get loaded. If a larger mapping is required to read the
* ehdr and phdrs, a new mapping is created (see elf_map_it()). This
* new mapping is again used for each new file loaded. Some objects,
* such as filters, only take up one page, and in this case this mapping
* will suffice for the file.
*/
#if defined(MAP_ALIGN)
/*
* If the mapping failed, and we used MAP_ALIGN, assume we're
* on a system that doesn't support this option. Try again
* without MAP_ALIGN.
*/
fmap_setup();
}
}
#endif
if (maddr == MAP_FAILED) {
return (0);
}
/*
* From now on we will re-use fmap->fm_maddr as the mapping address
* so we augment the flags with MAP_FIXED and drop any MAP_ALIGN.
*/
#if defined(MAP_ALIGN)
#endif
/*
* Search through the object vectors to determine what kind of
* object we have.
*/
for (i = 0; vector[i]; i++) {
return (vector[i]);
/*
* If this object is an explicitly defined shared
* object under inspection by ldd, and contains a
* incompatible hardware capabilities requirement, then
* inform the user, but continue processing.
*
* XXXX - ldd -v for any rej failure.
*/
return (vector[i]);
}
return (0);
}
}
/*
* Unknown file type.
*/
return (0);
}
/*
* Function that determines whether a file name has already been loaded; if so,
* returns a pointer to its link map structure; else returns a NULL pointer.
*/
static int
{
const char *_str;
_str++;
else
}
static Rt_map *
{
const char **cpp;
/*
* Typically, dependencies are specified as simple file names
* (DT_NEEDED == libc.so.1), which are expanded to full pathnames to
* open the file. The full pathname is NAME(), and the original name
* is maintained on the ALIAS() list. Look through the ALIAS list first,
* as this is most likely to match other dependency uses.
*/
return (lmp);
}
/*
* Finally compare full paths, this is sometimes useful for catching
* filter names, or for those that dlopen() the dynamic executable.
*/
return (lmp);
return (lmp);
}
return (0);
}
Rt_map *
{
const char *_name;
/*
* If we've been asked to do a basename search, first determine if
* the pathname is registered in the FullpathNode AVL tree.
*/
return (lmp);
/*
* If we've been asked to do a basename search reduce the input name
* to its basename.
*/
_name++;
else
/*
* Loop through the callers link-map lists.
*/
continue;
return (lmp);
}
}
return ((Rt_map *)0);
}
/*
* Tracing is enabled by the LD_TRACE_LOADED_OPTIONS environment variable which
* is normally set from ldd(1). For each link map we load, print the load name
* and the full pathname of the shared object.
*/
/* ARGSUSED4 */
static void
{
/*
* The first time through trace_so() will only have lddstub on the
* link-map list and the preloaded shared object is supplied as "path".
* As we don't want to print this shared object as a dependency, but
* instead inspect *its* dependencies, return.
*/
return;
/*
* Without any rejection info, this is a supplied not-found condition.
*/
return;
}
/*
* If rejection information exists then establish what object was
* found and the reason for its rejection.
*/
if (rej) {
/* LINTED */
/*
* Was an alternative pathname defined (from a configuration
* file).
*/
} else {
if (alter)
}
/*
* If the load name isn't a full pathname print its associated pathname
* together with all the other information we've gathered.
*/
if (*name == '/')
else
}
/*
* Establish a link-map mode, initializing it if it has just been loaded, or
* potentially updating it if it already exists.
*/
int
{
int pmode = 0;
/*
* A newly loaded object hasn't had its mode set yet. Modes are used to
* load dependencies, so don't propagate any parent or no-load flags, as
* these would adversely affect this objects ability to load any of its
* dependencies that aren't already loaded. RTLD_FIRST is applicable to
* this objects handle creation only, and should not be propagated.
*/
return (1);
}
/*
* Establish any new overriding modes. RTLD_LAZY and RTLD_NOW should be
* represented individually (this is historic, as these two flags were
* the only flags originally available to dlopen()). Other flags are
* accumulative, but have a hierarchy of preference.
*/
}
if (pmode) {
}
/*
* If this load is an RTLD_NOW request and the object has already been
* loaded non-RTLD_NOW, append this object to the relocation-now list
* of the objects associated control list. Note, if the object hasn't
* yet been relocated, setting its MODE() to RTLD_NOW will establish
* full relocation processing when it eventually gets relocated.
*/
/* LINTED */
}
#ifdef SIEBEL_DISABLE
/*
* For patch backward compatibility the following .init collection
* is disabled.
*/
if (rtld_flags & RT_FL_DISFIX_1)
return (pmode);
#endif
/*
* If this objects .init has been collected but has not yet been called,
* it may be necessary to reevaluate the object using tsort(). For
* example, a new dlopen() hierarchy may bind to uninitialized objects
* that are already loaded, or a dlopen(RTLD_NOW) can establish new
* bindings between already loaded objects that require the tsort()
* information be recomputed. If however, no new objects have been
* added to the process, and this object hasn't been promoted, don't
* bother reevaluating the .init. The present tsort() information is
* probably as accurate as necessary, and by not establishing a parallel
* tsort() we can help reduce the amount of recursion possible between
* .inits.
*/
}
return (pmode);
}
/*
* Determine whether an alias name already exists, and if not create one. This
* is typically used to retain dependency names, such as "libc.so.1", which
* would have been expanded to full path names when they were loaded. The
* full path names (NAME() and possibly PATHNAME()) are maintained as Fullpath
* AVL nodes, and thus would have been matched by fpavl_loaded() during
* file_open().
*/
int
{
/*
* Determine if this filename is already on the alias list.
*/
return (1);
}
/*
* This is a new alias, append it to the alias list.
*/
return (0);
AL_CNT_ALIAS) == 0) {
return (0);
}
if (added)
*added = 1;
return (1);
}
/*
* Determine whether a file is already loaded by comparing device and inode
* values.
*/
static Rt_map *
{
/*
* If this is an auditor, it will have been opened on a new link-map.
* To prevent multiple occurrances of the same auditor on multiple
* link-maps, search the head of each link-map list and see if this
* object is already loaded as an auditor.
*/
if (flags & FLG_RT_AUDIT) {
return (nlmp);
}
return ((Rt_map *)0);
}
/*
* If the file has been found determine from the new files status
* information if this file is actually linked to one we already have
* mapped. This catches symlink names not caught by is_so_loaded().
*/
continue;
continue;
if (*name == '/')
else
}
return (nlmp);
}
}
return ((Rt_map *)0);
}
/*
* Generate any error messages indicating a file could not be found. When
* preloading or auditing a secure application, it can be a little more helpful
* to indicate that a search of secure directories has failed, so adjust the
* messages accordingly.
*/
void
{
int secure = 0;
if ((rtld_flags & RT_FL_SECURE) &&
secure++;
/*
* Under ldd(1), auxiliary filtees that can't be loaded are
* ignored, unless verbose errors are requested.
*/
if ((rtld_flags & RT_FL_SILENCERR) &&
return;
if (secure)
else
return;
}
return;
}
if (secure)
else
}
static int
{
/*
* If we're dealing with a full pathname, determine whether this
* pathname is already known. Other pathnames fall through to the
* one previously used, the process may have changed directory.
*/
return (1);
}
}
/*
* If this path has been constructed as part of expanding a
* HWCAP directory, ignore any subdirectories. For any other
* reference that expands to a directory, fall through to
* contruct a meaningful rejection message.
*/
if ((flags & FLG_RT_HWCAP) &&
return (0);
/*
* Resolve the filename and determine whether the resolved name
* is already known. Typically, the previous fpavl_loaded()
* will have caught this, as both NAME() and PATHNAME() for a
* link-map are recorded in the FullNode AVL tree. However,
* instances exist where a file can be replaced (loop-back
* mounts, bfu, etc.), and reference is made to the original
* file through a symbolic link. By checking the pathname here,
* that a new file should be loaded.
*/
if ((nlmp =
added = 0;
&added) == 0)
return (0);
if (added)
return (1);
}
/*
* If this pathname hasn't been loaded, save
* the resolved pathname so that it doesn't
* have to be recomputed as part of fullpath()
* processing.
*/
return (0);
} else {
/*
* If the resolved name doesn't differ from the
* original, save it without duplication.
* Having fd_pname set indicates that no further
* resolvepath processing is necessary.
*/
}
}
added = 0;
return (0);
if (added) {
return (0);
}
return (1);
}
/*
* As the file must exist for the previous stat() to
* have succeeded, record the error condition.
*/
} else {
/*
* Trace that this open has succeeded.
*/
}
return (1);
}
}
/*
* If the open() failed for anything other than the file not
* existing, record the error condition.
*/
}
/*
* Indicate any rejection.
*/
}
return (0);
}
/*
* Find a full pathname (it contains a "/").
*/
int
{
int err = 0;
/*
* If directory configuration exists determine if this path is known.
*/
if (rtld_flags & RT_FL_DIRCFG) {
const char *aname;
0, &aname)) != 0) {
/*
* If the configuration file states that this path is a
* directory, or the path is explicitly defined as
* non-existent (ie. a unused platform specific
* library), then go no further.
*/
(RTC_OBJ_NOEXIST | RTC_OBJ_ALTER)) ==
int ret;
/*
* Attempt to open the alternative path. If
* this fails, and the alternative is flagged
* as optional, fall through to open the
* original path.
*/
return (ret);
}
}
}
}
/*
* Find a simple filename (it doesn't contain a "/").
*/
static int
{
}
/*
* If we're being audited tell the audit library of the file we're about
* to go search for. The audit library may offer an alternative
* dependency, or indicate that this dependency should be ignored.
*/
if (aname == 0)
return (0);
}
}
static int
{
return (0);
return (0);
} else
dobj = 0;
/*
* combination exists.
*/
if ((rtld_flags & RT_FL_DIRCFG) &&
const char *alt = 0;
/*
* If this pnode has not yet been searched for in the
* configuration file go find it.
*/
if (dobj == 0) {
if (dobj == 0)
RTC_OBJ_ALTER)) == RTC_OBJ_NOEXIST)
return (0);
}
/*
* If we found a directory search for the file.
*/
if (*strhash == 0)
/*
* If this object specifically does not exist, or the
* object can't be found in a know-all-entries
* directory, continue looking. If the object does
* exist determine if an alternative object exists.
*/
if (fobj == 0) {
return (0);
} else {
RTC_OBJ_ALTER)) == RTC_OBJ_NOEXIST)
return (0);
(rtld_flags & RT_FL_OBJALT) &&
int ret;
/*
* Attempt to open the alternative path.
* If this fails, and the alternative is
* flagged as optional, fall through to
* open the original path.
*/
RTC_OBJ_OPTINAL) == 0))
return (ret);
}
}
}
}
/*
* Protect ourselves from building an invalid pathname.
*/
return (0);
}
return (0);
}
/*
* A unique file has been opened. Create a link-map to represent it, and
* process the various names by which it can be referenced.
*/
static Rt_map *
{
/*
* Typically we call fct_map_so() with the full pathname of the opened
* file (nname) and the name that started the search (oname), thus for
* libc.so.1 (DT_NEEDED). The original name is maintained on an ALIAS
* list for comparison when bringing in new dependencies. If the user
* specified name as a full path (from a dlopen() for example) then
* there's no need to create an ALIAS.
*/
oname = 0;
/*
* A new file has been opened, now map it into the process. Close the
* original file so as not to accumulate file descriptors.
*/
if (nlmp == 0)
return (0);
/*
*/
/*
* Insert the names of this link-map into the FullpathNode AVL tree.
* Save both the NAME() and PATHNAME() is they differ.
*
* If this is an OBJECT file, don't insert it yet as this is only a
* temporary link-map. During elf_obj_fini() the final link-map is
* created, and its names will be inserted in the FullpathNode AVL
* tree at that time.
*/
/*
* Update the objects full path information if necessary.
* Note, with pathname expansion in effect, the fd_pname will
* be used as PATHNAME(). This allocated string will be freed
* should this object be deleted. However, without pathname
* expansion, the fd_name should be freed now, as it is no
* longer referenced.
*/
return (0);
}
return (0);
}
}
/*
* If we're processing an alternative object reset the original name
* for possible $ORIGIN processing.
*/
const char *odir;
char *ndir;
/*
* If we were given a pathname containing a slash then the
* original name is still in oname. Otherwise the original
* directory is in dir->p_name (which is all we need for
* $ORIGIN).
*/
char *ofil;
} else {
}
return (0);
}
}
/*
* Identify this as a new object.
*/
/*
* Report module loads to TLS module activity.
*/
if (nlmp)
return (nlmp);
}
/*
* This function loads the named file and returns a pointer to its link map.
* It is assumed that the caller has already checked that the file is not
* already loaded before calling this function (refer is_so_loaded()).
* Find and open the file, map it into memory, add it to the end of the list
* of link maps and return a pointer to the new link map. Return 0 on error.
*/
static Rt_map *
{
char *name;
/*
* If the file is the run time linker then it's already loaded.
*/
/*
* If this isn't a hardware capabilites pathname, which is already a
* full, duplicated pathname, determine whether the pathname contains
* a slash, and if not determine the input filename (for max path
* length verification).
*/
if ((flags & FLG_RT_HWCAP) == 0) {
const char *str;
if (*str == '/') {
slash++;
break;
}
}
if (slash == 0)
}
/*
* If we are passed a 'null' link-map this means that this is the first
* object to be loaded on this link-map list. In that case we set the
* link-map to ld.so.1's link-map.
*
* This link-map is referenced to determine what lookup rules to use
* when searching for files. By using ld.so.1's we are defaulting to
* ELF look-up rules.
*
* Note: This case happens when loading the first object onto
* the plt_tracing link-map.
*/
if (clmp == 0)
/*
* If this path resulted from a $HWCAP specification, then the best
* hardware capability object has already been establish, and is
* available in the calling file descriptor. Perform some minor book-
* keeping so that we can fall through into common code.
*/
if (flags & FLG_RT_HWCAP) {
/*
* Restablish the Fmap structure to reflect this objects
* original initial page mapping. Make sure any present Fmap
* mapping is removed before overwriting the structure.
*/
#if defined(MAP_ALIGN)
#else
#endif
/*
* Obtain the avl index for this object.
*/
&(fdesc.fd_avlwhere));
} else {
/*
* If this object is already loaded, we're done.
*/
}
} else if (slash) {
return (0);
}
/*
* If this object is already loaded, we're done.
*/
} else {
/*
* No '/' - for each directory on list, make a pathname using
* that directory and filename and try to open that file.
*/
#if !defined(ISSOLOAD_BASENAME_DISABLED)
return (nlmp);
#endif
/*
* Make sure we clear the file descriptor new name in case the
* following directory search doesn't provide any directories
* (odd, but this can be forced with a -znodefaultlib test).
*/
/*
* Try and locate this file. Make sure to clean up
* any rejection information should the file have
* been found, but not appropriate.
*/
continue;
}
/*
* If this object is already loaded, we're done.
*/
break;
}
/*
* If the file couldn't be loaded, do another comparison of
* loaded files using just the basename. This catches folks
* who may have loaded multiple full pathname files (possibly
* from setxid applications) to satisfy dependency relationships
* (i.e., a file might have a dependency on foo.so.1 which has
* already been opened using its full pathname).
*/
}
/*
* Duplicate the file name so that NAME() is available in core files.
* Note, that hardware capability names are already duplicated, but
* they get duplicated once more to insure consistent cleanup in the
* event of an error condition.
*/
return (0);
}
else
/*
* Finish mapping the file and return the link-map descriptor. Note,
* if this request originated from a HWCAP request, re-establish the
* fdesc information. For single paged objects, such as filters, the
* original mapping may have been sufficient to capture the file, thus
* this mapping needs to be reset to insure it doesn't mistakenly get
* unmapped as part of HWCAP cleanup.
*/
if (flags & FLG_RT_HWCAP) {
}
return (nlmp);
}
/*
* Trace an attempt to load an object.
*/
const char *
{
/*
* First generate any ldd(1) diagnostics.
*/
/*
* If we're being audited tell the audit library of the file we're
* about to go search for.
*/
char *_name;
/*
* The auditor can indicate that this object should be ignored.
*/
return (0);
}
/*
* The auditor can provide an alternative name.
*/
}
}
return (name);
}
/*
* Having loaded an object and created a link-map to describe it, finish
* processing this stage, including verifying any versioning requirements,
* updating the objects mode, creating a handle if necessary, and adding this
* object to existing handles if required.
*/
static int
{
int promote;
/*
* If this dependency is associated with a required version insure that
* the version is present in the loaded file.
*/
if (((rtld_flags & RT_FL_NOVERSION) == 0) &&
return (0);
/*
* If this object has indicated that it should be isolated as a group
* (DT_FLAGS_1 contains DF_1_GROUP - object was built with -B group),
* or if the callers direct bindings indicate it should be isolated as
* a group (DYNINFO flags contains FLG_DI_GROUP - dependency followed
* -zgroupperm), establish the appropriate mode.
*
* The intent of an object defining itself as a group is to isolate the
* relocation of the group within its own members, however, unless
* opened through dlopen(), in which case we assume dlsym() will be used
* to located symbols in the new object, we still need to associate it
* with the caller for it to be bound with. This is equivalent to a
* dlopen(RTLD_GROUP) and dlsym() using the returned handle.
*/
nmode &= ~RTLD_WORLD;
nmode |= RTLD_GROUP;
/*
* If the object wasn't explicitly dlopen()'ed associate it with
* the parent.
*/
if (flags != FLG_RT_HANDLE)
nmode |= RTLD_PARENT;
}
/*
* Establish new mode and flags.
*
* For patch backward compatibility, the following use of update_mode()
* is disabled.
*/
#ifdef SIEBEL_DISABLE
if (rtld_flags & RT_FL_DISFIX_1)
else
#endif
/*
* If we've been asked to establish a handle create one for this object.
* Or, if this object has already been analyzed, but this reference
* requires that the mode of the object be promoted, also create a
* handle to propagate the new modes to all this objects dependencies.
*/
if (nmode & RTLD_PARENT)
hflags |= GPH_PARENT;
if (nmode & RTLD_FIRST)
/*
* Now that a handle is being created, remove this state from
* the object so that it doesn't mistakenly get inherited by
* a dependency.
*/
return (0);
/*
* Add any dependencies that are already loaded, to the handle.
*/
return (0);
if (hdl)
/*
* If we were asked to create a handle, we're done. Otherwise,
* remove the handle. The handle was only used to establish this
* objects dependencies and promote any modes, so we don't want
* this handle preventing the objects deletion. Fall through to
* carry out any group processing.
*/
return (1);
}
/*
* If the caller isn't part of a group we're done.
*/
return (1);
/*
* Determine if our caller is already associated with a handle, if so
* we need to add this object to any handles that already exist.
* Traverse the list of groups our caller is a member of and add this
* new link-map to those groups.
*/
int exist;
/*
* If the caller doesn't indicate that its dependencies should
* be added to a handle, ignore it. This case identifies a
* parent of a dlopen(RTLD_PARENT) request.
*/
break;
}
continue;
(GPD_AVAIL | GPD_ADDEPS))) == 0)
return (0);
/*
* If this member already exists then its dependencies will
* have already been processed.
*/
if (exist == ALE_EXISTS)
continue;
/*
* If the object we've added has just been opened, it will not
* yet have been processed for its dependencies, these will be
* added on later calls to load_one(). If it doesn't have any
* dependencies we're also done.
*/
continue;
/*
* Otherwise, this object exists and has dependencies, so add
* all of its dependencies to the handle were operating on.
*/
AL_CNT_DEPCLCT) == 0)
return (0);
/*
* Add any dependencies of this dependency to the
* dynamic dependency list so they can be further
* processed.
*/
continue;
AL_CNT_DEPCLCT) == 0) {
return (0);
}
}
continue;
(GPD_AVAIL | GPD_ADDEPS))) != 0) {
if (exist == ALE_CREATE)
nmode);
continue;
}
return (0);
}
}
return (1);
}
/*
* The central routine for loading shared objects. Insures ldd() diagnostics,
* handles and any other related additions are all done in one place.
*/
Rt_map *
{
if ((nmode & RTLD_NOLOAD) == 0) {
/*
* If this isn't a noload request attempt to load the file.
*/
return (0);
return (0);
/*
* If we've loaded a library which identifies itself as not
* being dlopen()'able catch it here. Let non-dlopen()'able
* objects through under RTLD_CONFGEN as they're only being
* mapped to be dldump()'ed.
*/
((nmode & RTLD_CONFGEN) == 0)) {
return (0);
}
} else {
/*
* If it's a NOLOAD request - check to see if the object
* has already been loaded.
*/
/* LINTED */
if (*name == '/')
else
}
} else {
return (0);
}
}
/*
* Finish processing this loaded object.
*/
/*
* If this object has already been analyzed, then it is in use,
* so even though this operation has failed, it should not be
* torn down.
*/
return (0);
}
/*
* If this object is new, and we're being audited, tell the audit
* library of the file we've just opened. Note, if the new link-map
* requires local auditing of its dependencies we also register its
* opening.
*/
return (0);
}
}
}
return (nlmp);
}
/*
* Load one object from a possible list of objects. Typically, for requests
* such as NEEDED's, only one object is specified. However, this object could
* be specified using $ISALIST or $HWCAP, in which case only the first object
* that can be loaded is used (ie. the best).
*/
Rt_map *
{
const char *name;
/*
* A Hardware capabilities requirement can itself expand into
* a number of candidates.
*/
remove_rej(&rej);
return (tlmp);
}
} else {
remove_rej(&rej);
return (tlmp);
}
}
}
/*
* If this pathname originated from an expanded token, use the original
* for any diagnostic output.
*/
remove_rej(&rej);
return (0);
}
/*
* While processing direct or group bindings, determine whether the object to
* which we've bound can be interposed upon. In this context, copy relocations
* are a form of interposition.
*/
static Sym *
{
/*
* If we've bound to a copy relocation definition then we need to assign
* this binding to the original copy reference. Fabricate an inter-
* position diagnostic, as this is a legitimate form of interposition.
*/
*binfo |=
}
}
}
return ((Sym *)0);
/*
* Traverse the list of known interposers to determine whether any
* offer the same symbol. Note, the head of the link-map could be
* identified as an interposer. If it is, make sure we only look for
* symbol definitions. Otherwise, skip the head of the link-map, so
* that we don't bind to any .plt references, or copy-relocations
* unintentionally.
*/
else
continue;
break;
*binfo |= DBG_BINFO_INTERPOSE;
return (sym);
}
}
}
return ((Sym *)0);
}
/*
* If an object specifies direct bindings (it contains a syminfo structure
* describing where each binding was established during link-editing, and the
* object was built -Bdirect), then look for the symbol in the specific object.
*/
static Sym *
{
/*
* If a direct binding resolves to the definition of a copy relocated
* variable, it must be redirected to the copy (in the executable) that
* will eventually be made. Typically, this redirection occurs in
* lookup_sym_interpose(). But, there's an edge condition. If a
* directly bound executable contains pic code, there may be a
* reference to a definition that will eventually have a copy made.
* However, this copy relocation may not yet have occurred, because
* the relocation making this reference comes before the relocation
* that will create the copy.
* Under direct bindings, the syminfo indicates that a copy will be
* taken (SYMINFO_FLG_COPY). This can only be set in an executable.
* Thus, the caller must be the executable, so bind to the destination
* of the copy within the executable.
*/
return (sym);
}
/*
* If we need to direct bind to our parent start looking in each caller
* link map.
*/
sym = 0;
break;
}
} else {
/*
* If we need to direct bind to anything else look in the
* link map associated with this symbol reference.
*/
else
if (lmp)
}
if (sym)
*binfo |= DBG_BINFO_DIRECT;
/*
* If we've bound to an object, determine whether that object can be
* interposed upon for this symbol.
*/
return (isym);
}
return (sym);
}
static Sym *
{
/*
* Copy relocations should start their search after the head of the
* main link-map control list.
*/
else
return (sym);
}
}
return (0);
}
static Sym *
{
continue;
return (sym);
}
}
return (0);
}
/*
* Symbol lookup routine. Takes an ELF symbol name, and a list of link maps to
* search (if the flag indicates LKUP_FIRST only the first link map of the list
* is searched ie. we've been called from dlsym()).
* If successful, return a pointer to the symbol table entry and a pointer to
* the link map of the enclosing object. Else return a null pointer.
*
* To improve elf performance, we first compute the elf hash value and pass
* it to each find_sym() routine. The elf function will use this value to
* locate the symbol, the a.out function will simply ignore it.
*/
Sym *
{
*binfo = 0;
/*
* Search the initial link map for the required symbol (this category is
* selected by dlsym(), where individual link maps are searched for a
* required symbol. Therefore, we know we have permission to look at
* the link map).
*/
if (flags & LKUP_FIRST)
/*
* Determine whether this lookup can be satisfied by an objects direct,
* or lazy binding information. This is triggered by a relocation from
* the object (hence rsymndx is set).
*/
/*
* Find the corresponding Syminfo entry for the original
* referencing symbol.
*/
/* LINTED */
/*
* If the symbol information indicates a direct binding,
* determine the link map that is required to satisfy the
* binding. Note, if the dependency can not be found, but a
* direct binding isn't required, we will still fall through
* to perform any default symbol search.
*/
lmp = 0;
if (bound < SYMINFO_BT_LOWRESERVE)
/*
* If direct bindings have been disabled, and this isn't
* a translator, skip any direct binding now that we've
* insured the resolving object has been loaded.
*
* If we need to direct bind to anything, we look in
* ourselves, our parent, or in the link map we've just
* loaded. Otherwise, even though we may have lazily
* loaded an object we still continue to search for
* symbols from the head of the link map list.
*/
/*
* If this direct binding has been disabled
* (presumably because the symbol definition has
* been changed since the referring object was
* built), fall back to a standard symbol
* search.
*/
if ((*binfo & BINFO_DIRECTDIS) == 0)
return (sym);
}
}
}
/*
* If the referencing object has the DF_SYMBOLIC flag set, look in the
* referencing object for the symbol first. Failing that, fall back to
* our generic search.
*/
return (sym);
}
/*
* If this lookup originates from a standard relocation, then traverse
* all link-map lists inspecting any object that is available to this
* caller. Otherwise, traverse the link-map list associate with the
* caller.
*/
if (flags & LKUP_ALLCNTLIST) {
sym = 0;
break;
}
} else
/*
* To allow transitioning into a world of lazy loading dependencies see
* if this link map contains objects that have lazy dependencies still
* outstanding. If so, and we haven't been able to locate a non-weak
* symbol reference, start bringing in any lazy dependencies to see if
* the reference can be satisfied. Use of dlsym(RTLD_PROBE) sets the
* LKUP_NOFALBACK flag, and this flag disables this fall back.
*/
return ((Sym *)0);
/*
* If this request originated from a dlsym(RTLD_NEXT) then start
* looking for dependencies from the caller, otherwise use the
* initial link-map.
*/
else {
break;
}
}
}
/*
* If the caller is restricted to a symbol search within its group,
* determine if it is necessary to follow a binding from outside of
* the group.
*/
sym)) != 0)
return (isym);
}
return (sym);
}
/*
* Associate a binding descriptor with a caller and its dependency, or update
* an existing descriptor.
*/
int
{
int found = ALE_CREATE;
/*
* Determine whether a binding descriptor already exists between the
* two objects.
*/
found = ALE_EXISTS;
break;
}
}
if (found == ALE_CREATE) {
/*
* Create a new binding descriptor.
*/
return (0);
/*
* Append the binding descriptor to the caller and the
* dependency.
*/
sizeof (Bnd_desc *), AL_CNT_DEPENDS) == 0)
return (0);
sizeof (Bnd_desc *), AL_CNT_CALLERS) == 0)
return (0);
}
}
return (found);
}
/*
* Cleanup after relocation processing.
*/
int
{
/*
* Establish bindings to all objects that have been bound to.
*/
if (bound) {
if (ret) {
ret = 0;
break;
}
}
}
}
/*
* If we write enabled the text segment to perform these relocations
* re-protect by disabling writes.
*/
if (textrel)
return (ret);
}