/*
* 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 (c) 1988 AT&T
* All Rights Reserved
*/
#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 <debug.h>
#include <conv.h>
#include "_rtld.h"
#include "_audit.h"
#include "_elf.h"
#include "_a.out.h"
#include "_inline_gen.h"
#include "msg.h"
/*
* 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
{
/*
* Initialize the symbol lookup data structure. Note, no symbol
* name is supplied. This NULL name causes filters to be loaded
* but no symbol to be searched for.
*/
(rtld_flags & RT_FL_NOAUXFLTR)))
continue;
in_nfavl);
}
}
}
/*
* 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.
*
* Return the initial link-map from which analysis starts for relocate_lmc().
*/
Rt_map *
int *in_nfavl)
{
/*
* 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 (nlmp);
/*
* 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 (nlmp);
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;
break;
}
/*
* The original link-map that captured a relocatable
* object is a temporary link-map, that basically acts
* as a place holder in the link-map list. On
* completion of relocatable object processing, a new
* link-map is created, and switched with the place
* holder. Therefore, reassign both the present
* link-map pointer and the return link-map pointer.
* The former resets this routines link-map processing,
* while the latter provides for later functions, like
* relocate_lmc(), to start processing from this new
* link-map.
*/
}
/*
* Establish any dependencies this object requires.
*/
continue;
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 (nlmp);
}
/*
* Determine whether a symbol represents zero, .bss, bits. Most commonly this
* function is used to determine whether the data for a copy relocation refers
* to initialized data or .bss. If the data definition is within .bss, then the
* data is zero filled, and as the copy destination within the executable is
* .bss, we can skip copying zero's to zero's.
*
* However, if the defining object has MOVE data, it's .bss might contain
* non-zero data, in which case copy the definition regardless.
*
* For backward compatibility copy relocation processing, this routine can be
* used to determine precisely if a copy destination is a move record recipient.
*/
static int
{
/*
* Determine the segment that contains the copy definition. Given that
* the copy relocation records have already been captured and verified,
* a segment must be found (but we add an escape clause never the less).
*/
return (1);
/*
* If the definition is not within .bss, indicate this is not zero data.
*/
return (0);
/*
* If the definition is within .bss, make sure the definition isn't the
* recipient of a move record. Note, we don't precisely analyze whether
* the address is a move record recipient, as the infrastructure to
* prepare for, and carry out this analysis, is probably more costly
* than just copying the bytes regardless.
*/
return (1);
/*
* However, for backward compatibility copy relocation processing, we
* can afford to work a little harder. Here, determine precisely
* whether the destination in the executable is a move record recipient.
* See comments in lookup_sym_interpose(), below.
*/
return (0);
return (1);
}
/*
* 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)++;
ret = 0;
/*
* Finally process any move data. Note, this is carried out
* with ldd(1) under relocation processing too, as it can flush
* out move errors, and enables lari(1) to provide a true
* representation of the runtime bindings.
*/
ret = 0;
}
/*
* If a text segment was write enabled to perform any relocations or
* move records, then re-protect the segment by disabling writes.
*/
if (textrel) {
}
return (ret);
}
/*
* Relocate the objects on a link-map control list.
*/
static int
int *in_nfavl)
{
/*
* 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.
*/
/*
* If this object is being relocated on the main link-map list
* indicate that this object's init is available for harvesting.
* Objects that are being collected on other link-map lists
* will have there init availability tagged when the objects
* are move to the main link-map list (ie, after we know they,
* and their dependencies, are fully relocated and ready for
* use).
*
* Note, even under ldd(1) this init identification is necessary
* for -i (tsort) gathering.
*/
if (lmco == ALIST_OFF_DATA) {
}
/*
* 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. Presently, a given link map can only have a receiver or
* supplier of copy data, so a union is used to overlap the storage
* for the COPY_R() and COPY_S() lists. These lists would need to
* be separated.
*/
#if defined(__i386)
if (elf_copy_gen(nlmp) == 0)
return (0);
#endif
return (1);
(((rtld_flags & RT_FL_SILENCERR) == 0) ||
tracing = 1;
else
tracing = 0;
int zero;
/*
* Only copy the data if the data is from
* a non-zero definition (ie. not .bss).
*/
if (zero)
continue;
FL1_RT_DISPREL) == 0))
continue;
}
}
}
return (1);
}
int
int *in_nfavl)
{
/*
* 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 ensure any directly bound dependencies, filtees, etc.
* get loaded. Although we skip the relocation, fall through to ensure
* 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.
*/
if (nlmco == ALIST_OFF_DATA)
/*
* Relocate the link-map control list. Should this relocation
* fail, clean up this link-map list. Relocations within this
* list may have required relocation promotions on other lists,
* so before acting upon these, and possibly adding more objects
* to the present link-map control list, try and clean up any
* failed objects now.
*/
}
/*
* Determine the new, and previous link-map control lists.
*/
/* LINTED */
if (nlmco == ALIST_OFF_DATA) {
} 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 */
}
/*
* If relocations have been successful, indicate that relocations are
* no longer active for this control list. Otherwise, leave the
* relocation flag, as this flag is used to determine the style of
* cleanup (see remove_lmc()).
*/
/* LINTED */
return (1);
}
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.
*/
void
{
}
}
/*
* Helper routine for is_so_matched() that consolidates matching a path name,
* or file name component of a link-map name.
*/
inline static int
{
const char *_str;
_str++;
else
}
/*
* Determine whether a search name matches one of the names associated with a
* link-map. A link-map contains several names:
*
* - a NAME() - this is the basename of the dynamic executable that started
* the process, and the path name of any dependencies used by the process.
* Most executables are received as full path names, as exec() prepends a
* search $PATH to locate the executable. However, simple file names can
* be received from exec() if the file is executed from the present working
* directory. Regardless, ld.so.1 maintains NAME() as the basename, as
* this has always been the name used in diagnostics and error messages.
* Most dependencies are full path names, as the typical search for a
* dependency, say "libx.so.1", results in search paths being prepended to
* path names can be supplied as dependencies, e.g. dlopen("../libx.so.1").
*
* - a PATHNAME() - this is the fully resolved path name of the object. This
* name will differ from NAME() for all dynamic executables, and may differ
* from the NAME() of dependencies, if the dependency is not a full path
* name, or the dependency resolves to a symbolic link.
*
* - an ALIAS() name - these are alternative names by which the object has
* been found, ie. when dependencies are loaded through a variety of
* different symbolic links.
*
* The name pattern matching can differ depending on whether we are looking
* for a full path name (path != 0), or a simple file name (path == 0). Full
* path names typically match NAME() or PATHNAME() entries.
*
* For all full path name searches, the link-map names are taken as is. For
* simple file name searches, only the file name component of any link-map
* names are used for comparison.
*/
inline static Rt_map *
{
const char *cp;
return (lmp);
return (lmp);
}
return (lmp);
}
return (NULL);
}
/*
* Files are opened by ld.so.1 to satisfy dependencies, filtees and dlopen()
* requests. Each request investigates the file based upon the callers
* environment. Once a full path name has been established, the following
* checks are made:
*
* - does the path exist in the link-map lists FullPathNode AVL tree? if
* so, the file is already loaded, and its associated link-map pointer
* is returned.
* - does the path exist in the not-found AVL tree? if so, this path has
* already been determined to not exist, and a failure is returned.
* times through different paths. See file_open().
*
* However, there are cases where a test for an existing file name needs to be
* carried out, such as dlopen(NOLOAD) requests, dldump() requests, and as a
* final fallback to dependency loading. These requests are handled by
* is_so_loaded().
*
* A traversal through the callers link-map list is carried out, and from each
* link-map, a comparison is made against all of the various names by which the
* object has been referenced. is_so_matched() is used to compare the link-map
* names against the name being searched for. Whether the search name is a full
* path name or a simple file name, governs what comparisons are made.
*
* A full path name, which is a fully resolved path name that starts with a "/"
* character, or a relative path name that includes a "/" character, must match
* the link-map names exactly. A simple file name, which is any name *not*
* containing a "/" character, are matched against the file name component of
* any link-map names.
*/
Rt_map *
{
int path = 0;
/*
* If the name is a full path name, first determine if the path name is
* registered on the FullPathNode AVL, or not-found AVL trees.
*/
if (name[0] == '/') {
return (lmp);
/*
* For dlopen() and dlsym() fall backs, indicate that
* a registered not-found path has indicated that this
* object does not exist.
*/
if (in_nfavl)
(*in_nfavl)++;
return (NULL);
}
}
/*
* Determine whether the name is a simple file name, or a path name.
*/
path++;
/*
* Loop through the callers link-map lists.
*/
continue;
return (lmp);
}
}
return (NULL);
}
/*
* 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 associated 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
reject);
}
/*
* 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 */
}
/*
* 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 on the
* FullPathNode AVL tree, and thus would have been matched by fpavl_loaded()
* during file_open().
*/
int
{
const char *cp;
/*
* 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);
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 occurrences 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 (NULL);
}
/*
* 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;
/* BEGIN CSTYLED */
if (*name == '/')
else
/* END CSTYLED */
}
return (nlmp);
}
}
return (NULL);
}
/*
* 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
{
return (0);
/*
* 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);
}
/*
* For dlopen() and dlsym() fall backs, indicate that
* a registered not-found path has indicated that this
* object does not exist. If this path has been
* constructed as part of expanding a CAPABILITY
* directory, this is a silent failure, where no
* rejection message is created.
*/
if (in_nfavl)
(*in_nfavl)++;
return (0);
}
}
/*
* If this path has been constructed as part of expanding a
* CAPABILITY directory, ignore any subdirectories. As this
* is a silent failure, no rejection message is created. For
* any other reference that expands to a directory, fall
* through to construct a meaningful rejection message.
*/
if ((flags & FLG_RT_CAP) &&
return (0);
/*
* If this is a directory (which can't be mmap()'ed) generate a
* precise error message.
*/
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 FullPathNode 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 ((nname[0] == '/') &&
if ((nlmp =
added = 0;
&added) == 0)
return (0);
/* BEGIN CSTYLED */
if (added)
/* END CSTYLED */
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);
}
}
if (flags & FLG_RT_AUDIT) {
/*
* If we've been requested to load an auditor,
* and an auditor of the same name already
* exists, then the original auditor is used.
*/
} else {
/*
* Otherwise, if an alternatively named file
* a new name alias. Insert any alias full path
* name in the FullPathNode AVL tree.
*/
added = 0;
return (0);
if (added) {
if ((nname[0] == '/') &&
nname, 0) == 0))
return (0);
}
}
/*
* Record in the file descriptor the existing object
* that satisfies this open request.
*/
return (1);
}
/*
* As the file must exist for the previous stat() to
* have succeeded, record the error condition.
*/
} else {
/*
* Map the object. A successful return indicates that
* the object is appropriate for ld.so.1 processing.
*/
return (1);
}
}
/*
* If the open() failed for anything other than the file not
* existing, record the error condition.
*/
}
/*
* Regardless of error, duplicate and record any full path names that
* can't be used on the "not-found" AVL tree.
*/
if (nname[0] == '/')
/*
* Indicate any rejection.
*/
}
return (0);
}
/*
* Find a full pathname (it contains a "/").
*/
int
int *in_nfavl)
{
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.
*/
FLG_FD_ALTER));
RTC_OBJ_OPTINAL) == 0))
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.
*/
char *aname;
return (0);
}
}
}
}
static int
{
return (0);
return (0);
} else
/*
* combination exists.
*/
if ((rtld_flags & RT_FL_DIRCFG) &&
/*
* If this object descriptor has not yet been searched for in
* the configuration file go find it.
*/
RTC_OBJ_ALTER)) == RTC_OBJ_NOEXIST)
return (0);
}
/*
* If we found a directory search for the file.
*/
/*
* 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.
*/
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);
}
&elf_fct,
#ifdef A_OUT
&aout_fct,
#endif
0
};
/*
* Remap the first page of a file to provide a better diagnostic as to why
* an mmapobj(2) operation on this file failed. Sadly, mmapobj(), and all
* system calls for that matter, only pass back a generic failure in errno.
* Hopefully one day this will be improved, but in the mean time we repeat
* the kernels ELF verification to try and provide more detailed information.
*/
static int
{
int vnum;
/*
* Use the original file size to determine what to map, and catch the
* obvious error of a zero sized file.
*/
if (fsize == 0) {
return (1);
else
return (0);
/*
* Validate the file against each supported file type. Should a
* characteristic of the file be found invalid for this platform, a
* rejection message will have been recorded.
*/
break;
}
/*
* If no rejection message has been recorded, then this is simply an
* unknown file type.
*/
return (1);
}
/*
* Unmap a file.
*/
void
{
/* LINTED */
}
cnt_unmap++;
}
/*
* Map a file.
*/
Fct *
{
void *padding;
/*
* Allocate an initial mapping array. The initial size should be large
* enough to handle the normal ELF objects we come across.
*/
return (NULL);
}
/*
* If object padding is required, set the necessary flags.
*/
if (r_debug.rtd_objpad) {
} else {
}
/*
* Map the file. If the number of mappings required by this file
* exceeds the present mapping structure, an error indicating the
* return data is too big is returned. Bail on any other error.
*/
/*
* An unsupported error indicates that there's something
* incompatible with this ELF file, and the process that
* is already running. Map the first page of the file
* and see if we can generate a better error message.
*/
return (NULL);
return (NULL);
}
/*
* The mapping requirement exceeds the present mapping
* structure, however the number of mapping required is
* available in the mapping number.
*/
return (NULL);
/*
* With the appropriate mapping structure, try the mapping
* request again.
*/
return (NULL);
}
}
/*
* Traverse the mappings in search of a file type ld.so.1 can process.
* If the file type is verified as one ld.so.1 can process, retain the
* mapping information, and the number of mappings this object uses,
* and clear the static mapping pointer for the next map_obj() use of
* mmapobj().
*/
cnt_map++;
if (flags == MR_HDR_ELF) {
}
#ifdef A_OUT
if (flags == MR_HDR_AOUT) {
}
#endif
if (fptr) {
return (fptr);
}
}
/*
* If the mapped file is inappropriate, indicate that the file type is
* unknown, and free the mapping.
*/
return (NULL);
}
/*
* A unique file has been opened. Create a link-map to represent it, and
* process the various names by which it can be referenced.
*/
Rt_map *
{
/*
* Traverse the mappings for the input file to capture generic mapping
* information, and create a link-map to represent the file.
*/
/*
* Keep track of the first and last mappings that may include
* padding.
*/
/*
* Keep track of the first and last mappings that do not include
* padding.
*/
if (flags != MR_PADDING) {
}
if (flags == MR_HDR_ELF) {
/* LINTED */
} else if (flags == MR_HDR_AOUT)
}
/*
* The only ELF files we can handle are ET_EXEC, ET_DYN, and ET_REL.
*
* ET_REL must be processed by ld(1) to create an in-memory ET_DYN.
* The initial processing carried out by elf_obj_file() creates a
* temporary link-map, that acts as a place holder, until the objects
* processing is finished with elf_obj_fini().
*/
return (nlmp);
} else {
/*
* The size of the total reservation, and the padding range,
* are a historic artifact required by debuggers. Although
* these values express the range of the associated mappings,
* there can be holes between segments (in which small objects
* could be mapped). Anyone who needs to verify offsets
* against segments should analyze all the object mappings,
* rather than relying on these address ranges.
*/
return (NULL);
/*
* Save generic mapping information.
*/
}
/*
* this as a new object.
*/
/*
* If this is ELF relocatable object, we're done for now.
*/
return (nlmp);
/*
* Insert the names of this link-map into the FullPathNode AVL tree.
* Save both the NAME() and PATHNAME() if the names differ.
*/
fdp->fd_avlwhere) == 0)) {
return (NULL);
}
return (NULL);
}
/*
* If this is a secure application, record any full path name directory
* in which this dependency has been found. This directory can be
* deemed safe (as we've already found a dependency here). This
* recording provides a fall-back should another objects $ORIGIN
* definition expands to this directory, an expansion that would
* ordinarily be deemed insecure.
*/
if (rtld_flags & RT_FL_SECURE) {
}
/*
* If we're processing an alternative object reset the original name
* for possible $ORIGIN processing.
*/
/*
* 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 (NULL);
}
}
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 *
{
/*
* If this path name hasn't already been identified as containing a
* slash, check the path name. Most paths have been constructed
* inspected by expand(), and thus have a slash. However, we can
* receive path names via auditors or configuration files, and thus
* an evaluation here catches these instances.
*/
const char *str;
if (*str == '/') {
break;
}
}
}
/*
* 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 $CAPABILITY specification, then the
* best 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_CAP) {
/*
* If this object is already loaded, we're done.
*/
/*
* Obtain the avl index for this object.
*/
&(fdp->fd_avlwhere));
return (NULL);
}
/*
* 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.
*/
int found = 0;
/*
* Traverse the search path lists, creating full pathnames and
* attempt to load each path.
*/
/*
* Under debugging, duplicate path name entries are
* tagged but remain part of the search path list so
* that they can be diagnosed under "unused" processing.
* Skip these entries, as this path would have already
* been attempted.
*/
continue;
/*
* Try and locate this file. Make sure to clean up
* any rejection information should the file have
* been found, but not appropriate.
*/
continue;
}
/*
* Indicate that this search path has been used. If
* this is an LD_LIBRARY_PATH setting, ignore any use
* by ld.so.1 itself.
*/
/*
* If this object is already loaded, we're done.
*/
found = 1;
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).
*/
if (found == 0)
}
/*
* Trace that this successfully opened file is about to be processed.
* Note, as part of processing a family of hardware capabilities filtees
* a number of candidates may have been opened and mapped to determine
* their capability requirements. At this point we've decided which
* of the candidates to use.
*/
}
/*
* Finish mapping the file and return the link-map descriptor.
*/
}
/*
* Trace an attempt to load an object, and seed the originating name.
*/
const char *
{
/*
* First generate any ldd(1) diagnostics.
*/
/*
* Propagate any knowledge of a slash within the path name.
*/
/*
* If we're being audited tell any audit libraries of the file we're
* about to go search for.
*/
if (aud_activity ||
char *aname;
/*
* The auditor can indicate that this object should be ignored.
*/
if ((aname =
return (NULL);
}
}
}
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 ensure that
* the version is present in the loaded file.
*/
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 following
* -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 locate symbols in the new object, we still need to associate the
* new object with the caller so that the caller can bind to this new
* object. 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, in which case a
* handle would have been requested, associate the object with
* the parent.
*/
if ((flags & FLG_RT_PUBHDL) == 0)
nmode |= RTLD_PARENT;
}
/*
* Establish new mode and flags.
*/
/*
* Establish the flags for any referenced dependency descriptors
* (Grp_desc).
*
* - The referenced object is available for dlsym().
* - The referenced object is available to relocate against.
* - The referenced object should have it's dependencies
* added to this handle
*/
/*
* 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, create a private
* handle to propagate the new modes to all this objects dependencies.
*/
/*
* Establish any flags for the handle (Grp_hdl).
*
* - Public handles establish dependencies between objects
* that must be taken into account when dlclose()'ing
* objects. Private handles provide for collecting
* dependencies, but do not affect dlclose(). Note that
* state is set to trigger the required propagation of the
* handle's flags and any dependency gathering.
* - Use of the RTLD_FIRST flag indicates that only the first
* dependency on the handle (the new object) can be used
* to satisfy dlsym() requests.
*/
hflags = GPH_PUBLIC;
else
if (nmode & RTLD_FIRST)
/*
* Establish the flags for this callers dependency descriptor
* (Grp_desc).
*
* - The creation of a public handle creates a descriptor
* for the referenced object and the caller (parent).
* Typically, the handle is created for dlopen() or for
* filtering. A private handle does not need to maintain
* a descriptor to the parent.
* - Use of the RTLD_PARENT flag indicates that the parent
* can be relocated against.
*/
cdflags |= GPD_PARENT;
if (nmode & RTLD_PARENT)
}
/*
* Now that the handle flags have been established, remove any
* handle definition from the referenced object so that the
* definitions don'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 public handle, we're done.
*
* If this is a private handle request, then the handle is left
* intact with a GPH_PRIVATE identifier. This handle is a
* convenience for processing the dependencies of this object,
* but does not affect how this object might be dlclose()'d.
* For a private handle, fall through to carry out any group
* processing.
*/
if (oflags & FLG_RT_PUBHDL)
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 ale;
/*
* 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;
return (0);
/*
* If this member already exists then its dependencies will
* have already been processed.
*/
if (ale == 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.
*/
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;
if ((gdp =
return (0);
}
if (ale == ALE_CREATE)
}
}
return (1);
}
/*
* The central routine for loading shared objects. Insures ldd() diagnostics,
* handle creation, and any other related additions are all done in one place.
*/
Rt_map *
{
if ((nmode & RTLD_NOLOAD) == 0) {
int oin_nfavl;
/*
* Keep track of the number of not-found loads.
*/
if (in_nfavl)
/*
* If this isn't a noload request attempt to load the file.
*/
return (NULL);
/*
* If this file has been found, reset the not-found load count.
* Although a search for this file might have inspected a number
* of non-existent path names, the file has been found so there
* is no need to accumulate a non-found count, as this may
* trigger unnecessary fall back (retry) processing.
*/
if (in_nfavl)
/*
* 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 (NULL);
}
} else {
/*
* If it's a NOLOAD request - check to see if the object
* has already been loaded.
*/
/* LINTED */
/* BEGIN CSTYLED */
if (*name == '/')
else
/* END CSTYLED */
}
} else {
return (NULL);
}
}
/*
* 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 (NULL);
}
/*
* If this object is new, and we're being audited, tell the audit
* libraries 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 (NULL);
}
}
}
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 $CAPABILITY, in which case only the first
* object that can be loaded is used (ie. the best).
*/
Rt_map *
{
const char *name;
/*
* A $CAPABILITY/$HWCAP requirement can expand into a number of
* candidates.
*/
} else {
/*
* Trace the inspection of this file, determine any
* auditor substitution, and seed the file descriptor
* with the originating name.
*/
continue;
/*
* Locate and load the file.
*/
}
if (lmp)
return (lmp);
}
/*
* If no objects can be found, use the first path name from the Alist
* to provide a diagnostic. If this pathname originated from an
* expanded token, use the original name for any diagnostic output.
*/
return (NULL);
}
/*
* Determine whether a symbol is defined as an interposer.
*/
int
{
if (sip) {
/* LINTED */
return (1);
}
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 int
{
/*
* 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 (1);
}
}
}
/*
* If a symbol binding has been established, inspect the link-map list
* of the destination object, otherwise use the link-map list of the
* original caller.
*/
if (osym)
else
/*
* Prior to Solaris 8, external references from an executable that were
* bound to an uninitialized variable (.bss) within a shared object did
* not establish a copy relocation. This was thought to be an
* optimization, to prevent copying zero's to zero's. Typically,
* interposition took its course, with the shared object binding to the
* executables data definition.
*
* This scenario can be broken when this old executable runs against a
* new shared object that is directly bound. With no copy-relocation
* record, ld.so.1 has no data to trigger the normal vectoring of the
* binding to the executable.
*
* Starting with Solaris 8, a DT_FLAGS entry is written to all objects,
* regardless of there being any DF_ flags entries. Therefore, an
* object without this dynamic tag is susceptible to the copy relocation
* issue. If the executable has no DT_FLAGS tag, and contains the same
* .bss symbol definition as has been directly bound to, redirect the
* binding to the executables data definition.
*/
/*
* Initialize a local symbol result descriptor, using the
* original symbol name. Initialize a local symbol lookup
* descriptor, using the original lookup information, and a
* new initial link-map.
*/
/*
* Determine whether the same symbol name exists within the
* executable, that the size and type of symbol are the same,
* and that the symbol is also associated with .bss.
*/
*binfo |=
return (1);
}
}
}
return (NULL);
/*
* 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. Otherwise, skip the head of the
* link-map, so that we don't bind to any .plt references, or
* copy-relocation destinations unintentionally.
*/
continue;
break;
/*
* If we had already bound to this object, there's no point in
* searching it again, we're done.
*/
break;
/*
* If this interposer can be inspected by the caller, look for
* the symbol within the interposer.
*/
/*
* Initialize a local symbol result descriptor, using
* the original symbol name. Initialize a local symbol
* lookup descriptor, using the original lookup
* information, and a new initial link-map.
*/
/*
* If this object provides individual symbol
* interposers, make sure that the symbol we
* have found is tagged as an interposer.
*/
continue;
/*
* Indicate this binding has occurred to an
* interposer, and return the symbol.
*/
*binfo |= DBG_BINFO_INTERPOSE;
return (1);
}
}
}
return (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 int
{
int ret;
/*
* 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 (ret);
}
/*
* If we need to directly bind to our parent, start looking in each
* callers link map.
*/
ret = 0;
/*
* Determine the parent of this explicit dependency from its
* CALLERS()'s list.
*/
goto found;
}
/*
* A caller can also be defined as the parent of a dlopen()
* call. Determine whether this object has any handles. The
* dependencies maintained with the handle represent the
* explicit dependencies of the dlopen()'ed object, and the
* calling parent.
*/
continue;
in_nfavl))
goto found;
}
}
} else {
/*
* If we need to direct bind to anything else look in the
* link map associated with this symbol reference.
*/
else
if (lmp)
}
if (ret)
*binfo |= DBG_BINFO_DIRECT;
/*
* If a reference to a directly bound symbol can't be satisfied, then
* determine whether an interposer can provide the missing symbol. If
* a reference to a directly bound symbol is satisfied, then determine
* whether that object can be interposed upon for this symbol.
*/
return (1);
}
return (ret);
}
static int
{
/*
* Copy relocations should start their search after the head of the
* main link-map control list.
*/
else
(*binfo & BINFO_MSK_TRYAGAIN))
return (1);
}
}
return (0);
}
static int
int *in_nfavl)
{
continue;
return (1);
}
}
return (0);
}
static int
{
int ret;
/*
* 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).
*/
/*
* 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 */
/*
* Identify any EXTERN or PARENT references for ldd(1).
*/
(bound > SYMINFO_BT_LOWRESERVE)) {
if (bound == SYMINFO_BT_PARENT)
if (bound == SYMINFO_BT_EXTERN)
}
/*
* 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
* ensured 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.
*/
/*
* Determine whether this direct binding has
* been rejected. If we've bound to a singleton
* without following a singleton search, then
* return. The caller detects this condition
* and will trigger a new singleton search.
*
* For any other rejection (such as binding to
* a symbol labeled as nodirect - presumably
* because the symbol definition has been
* changed since the referring object was last
* built), fall through to a standard symbol
* search.
*/
if (((*binfo & BINFO_MSK_REJECTED) == 0) ||
(*binfo & BINFO_MSK_TRYAGAIN))
return (ret);
*binfo &= ~BINFO_MSK_REJECTED;
}
}
}
/*
* Duplicate the lookup information, as we'll need to modify this
* information for some of the following searches.
*/
/*
* 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.
*/
/*
* Make sure this symbol hasn't explicitly been defined
* as nodirect.
*/
/* LINTED */
return (1);
}
}
/*
* If this lookup originates from a standard relocation, then traverse
* all link-map control lists, inspecting any object that is available
* to this caller. Otherwise, traverse the link-map control list
* associated with the caller.
*/
ret = 0;
(*binfo & BINFO_MSK_TRYAGAIN))
break;
}
} else
in_nfavl);
/*
* If a symbol binding should be retried, return so that the search can
* be repeated.
*/
if (*binfo & BINFO_MSK_TRYAGAIN)
return (0);
/*
* 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_NOFALLBACK flag, and this flag disables this fall back.
*/
return (NULL);
/*
* If this request originated from a dlsym(RTLD_NEXT) then start
* looking for dependencies from the caller, otherwise use the
* initial link-map.
*/
in_nfavl);
else {
break;
}
}
}
return (ret);
}
/*
* Symbol lookup routine. Takes an ELF symbol name, and a list of link maps to
* search. If successful, return a pointer to the symbol table entry, a
* pointer to the link map of the enclosing object, and information relating
* to the type of binding. Else return a null pointer.
*
* To improve ELF performance, we first compute the ELF hash value and pass
* it to each _lookup_sym() routine. The ELF function will use this value to
* locate the symbol, the a.out function will simply ignore it.
*/
int
{
*binfo = 0;
if (rsym) {
/*
* Symbols that are defined as protected, or hidden, within an
* object usually have any relocation references from within
* the same object bound at link-edit time. Therefore, ld.so.1
* is not involved. However, if a reference is to a
* capabilities symbol, this reference must be resolved at
* runtime. In this case look directly within the calling
* object, and only within the calling object, for these
* symbols. Note, an object may still use dlsym() to search
* externally for a symbol which is defined as protected within
* the same object.
*/
}
/*
* Establish any state that might be associated with a symbol
* reference.
*/
if (vis == STV_SINGLETON)
}
/*
* Establish any lookup state required for this type of relocation.
*/
if (rtype != M_R_JMP_SLOT)
}
/*
* Under ldd -w, any unresolved weak references are diagnosed. Set the
* symbol binding as global to trigger a relocation error if the symbol
* can not be found.
*/
if (rsym) {
}
/*
* Save the callers MODE().
*/
/*
* Carry out an initial symbol search. This search takes into account
* all the modes of the requested search.
*/
(*binfo & BINFO_MSK_TRYAGAIN)) {
/*
* Try the symbol search again. This retry can be necessary if:
*
* - a binding has been rejected because of binding to a
* singleton without going through a singleton search.
* - a group binding has resulted in binding to a symbol
* that indicates no-direct binding.
*
* Reset the lookup data, and try again.
*/
sl.sl_rsymndx = 0;
if (*binfo & BINFO_REJSINGLE)
if (*binfo & BINFO_REJGROUP) {
mode |= RTLD_WORLD;
}
*binfo &= ~BINFO_MSK_REJECTED;
}
/*
* 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.
*/
return (1);
return (ret);
}
/*
* Associate a binding descriptor with a caller and its dependency, or update
* an existing descriptor.
*/
int
{
/*
* 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.
*/
return (0);
return (0);
}
}
return (found);
}
/*
* Cleanup after relocation processing.
*/
int
{
/*
* Establish bindings to all objects that have been bound to.
*/
if (bound) {
/*
* Only create bindings if the callers relocation was
* successful (ret != 0), otherwise the object will eventually
* be torn down. Create these bindings if running under ldd(1)
* with the -U/-u options regardless of relocation errors, as
* the unused processing needs to traverse these bindings to
* diagnose unused objects.
*/
continue;
ret = 0;
break;
}
}
}
return (ret);
}
/*
* Function to correct protection settings. Segments are all mapped initially
* with permissions as given in the segment header. We need to turn on write
* permissions on a text segment if there are any relocations against that
* segment, and then turn write permission back off again before returning
* control to the caller. This function turns the permission on or off
* depending on the value of the permission argument.
*/
int
{
int prot;
/*
* If this is an allocated image (ie. a relocatable object) we can't
* mprotect() anything.
*/
return (1);
if (perm)
else
return (0);
}
return (1);
}