/*
* 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
*
*/
/*
* Copyright (c) 2014 by Delphix. All rights reserved.
*/
/*
* Utility routines for run-time linker. some are duplicated here from libc
* (with different names) to avoid name space collisions.
*/
#include <sys/systeminfo.h>
#include <stdio.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <dlfcn.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include <debug.h>
#include <conv.h>
#include "_rtld.h"
#include "_audit.h"
#include "_elf.h"
#include "msg.h"
/*
* Null function used as place where a debugger can set a breakpoint.
*/
void
{
}
/*
* Null function used as place where debugger can set a pre .init
* processing breakpoint.
*/
void
{
}
/*
* Null function used as place where debugger can set a post .init
* processing breakpoint.
*/
void
{
}
/*
* Debugger Event Notification
*
* This function centralizes all debugger event notification (ala rtld_db).
*
* There's a simple intent, focused on insuring the primary link-map control
* list (or each link-map list) is consistent, and the indication that objects
* have been added or deleted from this list. Although an RD_ADD and RD_DELETE
* event are posted for each of these, most debuggers don't care, as their
* view is that these events simply convey an "inconsistent" state.
*
* enter ld.so.1.
*
* required later (RT_FL_DBNOTIF):
*
* i. the first time we add or delete an object to the primary link-map
* control list.
* ii. the first time we move a secondary link-map control list to the primary
* link-map control list (effectively, this is like adding a group of
* objects to the primary link-map control list).
*
* Set an RD_CONSISTENT event when it is required (RT_FL_DBNOTIF is set):
*
* i. each time we leave the runtime linker.
*/
void
{
switch (event) {
case RD_PREINIT:
break;
case RD_POSTINIT:
break;
case RD_DLACTIVITY:
switch (state) {
case RT_CONSISTENT:
/*
* Do we need to send a notification?
*/
if ((rtld_flags & RT_FL_DBNOTIF) == 0)
return;
rtld_flags &= ~RT_FL_DBNOTIF;
break;
case RT_ADD:
case RT_DELETE:
/*
* If we are already in an inconsistent state, no
* notification is required.
*/
if (rtld_flags & RT_FL_DBNOTIF)
return;
break;
};
break;
default:
/*
* RD_NONE - do nothing
*/
break;
};
/*
* Set event state and call 'notification' function.
*
* The debugging clients have previously been told about these
* notification functions and have set breakpoints on them if they
* are interested in the notification.
*/
}
/*
* Stack Cleanup.
*
* This function is invoked to 'remove' arguments that were passed in on the
* stack. This is most likely if ld.so.1 was invoked directly. In that case
* we want to remove ld.so.1 as well as it's arguments from the argv[] array.
* Which means we then need to slide everything above it on the stack down
* accordingly.
*
* While the stack layout is platform specific - it just so happens that __x86,
* and __sparc platforms share the following initial stack layout.
*
* !_______________________! high addresses
* ! !
* ! Information !
* ! Block !
* ! (size varies) !
* !_______________________!
* ! 0 word !
* !_______________________!
* ! Auxiliary !
* ! vector !
* ! 2 word entries !
* ! !
* !_______________________!
* ! 0 word !
* !_______________________!
* ! Environment !
* ! pointers !
* ! ... !
* ! (one word each) !
* !_______________________!
* ! 0 word !
* !_______________________!
* ! Argument ! low addresses
* ! pointers !
* ! Argc words !
* !_______________________!
* ! !
* ! Argc !
* !_______________________!
* ! ... !
*
*/
static void
{
int ndx;
long *argc;
/*
* Slide ARGV[] and update argc. The argv pointer remains the same,
* however slide the applications arguments over the arguments to
* ld.so.1.
*/
/*
* Slide ENVP[], and update the environment array pointer.
*/
ndx++;
/*
* Slide AUXV[], and update the aux vector pointer.
*/
ndx++;
}
#else
/*
* Verify that the above routine is appropriate for any new platforms.
*/
#endif
/*
* Compare function for PathNode AVL tree.
*/
static int
{
int rc;
return (1);
return (-1);
if (rc > 0)
return (1);
if (rc < 0)
return (-1);
return (0);
}
/*
* Create an AVL tree.
*/
static avl_tree_t *
{
return (NULL);
return (avlt);
}
/*
* Determine whether a PathNode is recorded.
*/
int
{
/*
* Create the avl tree if required.
*/
return (0);
return (0);
return (1);
}
/*
* Determine if a pathname has already been recorded on the full path name
* AVL tree. This tree maintains a node for each path name that ld.so.1 has
* successfully loaded. If the path name does not exist in this AVL tree, then
* the next insertion point is deposited in "where". This value can be used by
* fpavl_insert() to expedite the insertion.
*/
Rt_map *
{
/*
* Create the avl tree if required.
*/
return (NULL);
return (NULL);
}
/*
* Insert a name into the FullPathNode AVL tree for the link-map list. The
* objects NAME() is the path that would have originally been searched for, and
* is therefore the name to associate with any "where" value. If the object has
* a different PATHNAME(), perhaps because it has resolved to a different file
* (see fullpath()), then this name will be recorded as a separate FullPathNode
* (see load_file()).
*/
int
{
if (where == 0) {
/* LINTED */
/*
* We better not get a hit now, we do not want duplicates in
* the tree.
*/
}
/*
* Insert new node in tree.
*/
return (0);
return (0);
}
return (1);
}
/*
* Remove an object from the FullPathNode AVL tree.
*/
void
{
}
}
/*
* Insert a path name into the not-found AVL tree.
*
* This tree maintains a node for each path name that ld.so.1 has explicitly
* inspected, but has failed to load during a single ld.so.1 operation. If the
* path name does not exist in this AVL tree, then the next insertion point is
* deposited in "where". This value can be used by nfavl_insert() to expedite
* the insertion.
*/
void
{
if (where == 0) {
/* LINTED */
/*
* We better not get a hit now, we do not want duplicates in
* the tree.
*/
}
/*
* Insert new node in tree.
*/
}
}
/*
* Insert the directory name, of a full path name, into the secure path AVL
* tree.
*
* This tree is used to maintain a list of directories in which the dependencies
* of a secure process have been found. This list provides a fall-back in the
* case that a $ORIGIN expansion is deemed insecure, when the expansion results
* in a path name that has already provided dependencies.
*/
void
{
/*
* Separate the directory name from the path name.
*/
size = 1;
else
/*
* Determine whether this directory name is already recorded, or if
* not, 'where" will provide the insertion point for the new string.
*/
return;
/*
* Insert new node in tree.
*/
}
}
/*
* Inspect the generic string AVL tree for the given string. If the string is
* not present, duplicate it, and insert the string in the AVL tree. Return the
* duplicated string to the caller.
*
* These strings are maintained for the life of ld.so.1 and represent path
* names, file names, and search paths. All other AVL trees that maintain
* FullPathNode and not-found path names use the same string pointer
* established for this string.
*/
const char *
{
/*
* Create the avl tree if required.
*/
return (NULL);
/*
* Determine the string size if not provided by the caller.
*/
if (nsize == 0)
else if (substr) {
/*
* The string passed to us may be a multiple path string for
* which we only need the first component. Using the provided
* size, strip out the required string.
*/
}
/*
* Allocate a PathNode buffer if one doesn't exist, or any existing
* buffer has been used up.
*/
MAP_PRIVATE)) == MAP_FAILED)
return (NULL);
}
/*
* Determine whether this string already exists.
*/
/*
* Allocate a string buffer if one does not exist, or if there is
* insufficient space for the new string in any existing buffer.
*/
MAP_PRIVATE)) == MAP_FAILED)
return (NULL);
}
pnbuf++;
}
/*
* Prior to calling an object, either via a .plt or through dlsym(), make sure
* its .init has fired. Through topological sorting, ld.so.1 attempts to fire
* init's in the correct order, however, this order is typically based on needed
* dependencies and non-lazy relocation bindings. Lazy relocations (.plts) can
* still occur and result in bindings that were not captured during topological
* sorting. This routine compensates for this lack of binding information, and
* provides for dynamic .init firing.
*/
void
{
/*
* If the caller is an auditor, and the destination isn't, then don't
* run any .inits (see comments in load_completion()).
*/
return;
return;
(FLG_RT_RELOCED | FLG_RT_INITCALL)) {
(void) enter(0);
}
return;
}
}
/*
* Execute .{preinit|init|fini}array sections
*/
void
{
return;
/*
* initarray & preinitarray are walked from beginning to end - while
* finiarray is walked from end to beginning.
*/
if (shtype == SHT_FINI_ARRAY) {
} else {
start = 0;
incr = 1;
}
/*
* Call the .*array[] entries
*/
(*fptr)();
(void) enter(0);
}
}
/*
* Execute any .init sections. These are passed to us in an lmp array which
* (by default) will have been sorted.
*/
void
{
/*
* If we're in the middle of an INITFIRST, this must complete before
* any new init's are fired. In this case add the object list to the
* pending queue and return. We'll pick up the queue after any
* INITFIRST objects have their init's fired.
*/
if (rtld_flags & RT_FL_INITFIRST) {
return;
}
/*
* Traverse the tobj array firing each objects init.
*/
continue;
/*
* Establish an initfirst state if necessary - no other inits
* will be fired (because of additional relocation bindings)
* when in this state.
*/
if (iptr) {
(*iptr)();
(void) enter(0);
}
/*
* Set the initdone flag regardless of whether this object
* actually contains an .init section. This flag prevents us
* from processing this section again for an .init and also
* signifies that a .fini must be called should it exist.
* Clear the sort field for use in later .fini processing.
*/
/*
* If we're firing an INITFIRST object, and other objects must
* be fired which are not INITFIRST, make sure we grab any
* pending objects that might have been delayed as this
* INITFIRST was processed.
*/
if ((rtld_flags & RT_FL_INITFIRST) &&
}
}
}
}
/*
* Call .fini sections for the topologically sorted list of objects. This
* routine is called from remove_hdl() for any objects being torn down as part
* of a dlclose() operation, and from atexit() processing for all the remaining
* objects within the process.
*/
void
{
/*
* Only fire a .fini if the objects corresponding .init has
* completed. We collect all .fini sections of objects that
* had their .init collected, but that doesn't mean that at
* the time of collection, that the .init had completed.
*/
if (fptr) {
(*fptr)();
(void) enter(0);
}
}
/*
* Skip main, this is explicitly called last in atexit_fini().
*/
continue;
/*
* This object has exercised its last instructions (regardless
* of whether it will be unmapped or not). Audit this closure.
*/
}
}
/*
* Function called by atexit(3C). Calls all .fini sections within the objects
* that make up the process. As .fini processing is the last opportunity for
* any new bindings to be established, this is also a convenient location to
* check for unused objects.
*/
void
{
(void) enter(0);
/*
* Reverse topologically sort the main link-map for .fini execution.
*/
/*
* Now that all .fini code has been run, see what unreferenced objects
* remain.
*/
/*
* Traverse any alternative link-map lists, looking for non-auditors.
*/
/*
* Ignore the base-link-map list, which has already been
* processed, the runtime linkers link-map list, which is
* processed last, and any auditors.
*/
continue;
/*
* Reverse topologically sort the link-map for .fini execution.
*/
}
/*
* Add an explicit close to main and ld.so.1. Although main's .fini is
* collected in call_fini() to provide for FINITARRAY processing, its
* audit_objclose is explicitly skipped. This provides for it to be
* called last, here. This is the reverse of the explicit calls to
* audit_objopen() made in setup().
*/
}
/*
* Traverse any alternative link-map lists, looking for non-auditors.
*/
/*
* Ignore the base-link-map list, which has already been
* processed, the runtime linkers link-map list, which is
* processed last, and any non-auditors.
*/
continue;
/*
* Reverse topologically sort the link-map for .fini execution.
*/
}
/*
* Finally reverse topologically sort the runtime linkers link-map for
* .fini execution.
*/
}
/*
* This routine is called to complete any runtime linker activity which may have
* resulted in objects being loaded. This is called from all user entry points
* and from any internal dl*() requests.
*/
void
{
/*
* Establish any .init processing. Note, in a world of lazy loading,
* objects may have been loaded regardless of whether the users request
* was fulfilled (i.e., a dlsym() request may have failed to find a
* symbol but objects might have been loaded during its search). Thus,
* any tsorting starts from the nlmp (new link-maps) pointer and not
* necessarily from the link-map that may have satisfied the request.
*
* Note, the primary link-map has an initialization phase where dynamic
* .init firing is suppressed. This provides for a simple and clean
* handshake with the primary link-maps libc, which is important for
* establishing uberdata. In addition, auditors often obtain handles
* to primary link-map objects as the objects are loaded, so as to
* inspect the link-map for symbols. This inspection is allowed without
* running any code on the primary link-map, as running this code may
* reenter the auditor, who may not yet have finished its own
* initialization.
*/
if (nlmp)
}
/*
* Make sure any alternative link-map retrieves any external interfaces
* and initializes threads.
*/
}
/*
* Traverse the list of new link-maps and register any dynamic TLS.
* This storage is established for any objects not on the primary
* link-map, and for any objects added to the primary link-map after
* static TLS has been registered.
*/
}
}
/*
* Fire any .init's.
*/
if (tobj)
}
/*
* Append an item to the specified link map control list.
*/
void
{
/*
* Indicate that this link-map list has a new object.
*/
/*
* If we're about to add a new object to the main link-map control
* list, alert the debuggers. Additions of individual objects to the
* main link-map control list occur during initial setup as the
* applications immediate dependencies are loaded. Additional objects
* are loaded on the main link-map control list after they have been
* fully initialized on an alternative link-map control list. See
* lm_move().
*/
if (lmco == ALIST_OFF_DATA)
/* LINTED */
/*
* A link-map list header points to one of more link-map control lists
* the list of relocated objects. Other lists maintain objects that
* are still being analyzed or relocated. This list provides the core
* link-map list information used by all ld.so.1 routines.
*/
/*
* If this is the first link-map for the given control list,
* initialize the list.
*/
add = 0;
/*
* If this is an interposer then append the link-map following
* any other interposers (these are objects that have been
* previously preloaded, or were identified with -z interpose).
* Interposers can only be inserted on the first link-map
* control list, as once relocation has started, interposition
* from new interposers can't be guaranteed.
*
* NOTE: We do not interpose on the head of a list. This model
* evolved because dynamic executables have already been fully
* relocated within themselves and thus can't be interposed on.
* Nowadays it's possible to have shared objects at the head of
* a list, which conceptually means they could be interposed on.
* But, shared objects can be created via dldump() and may only
* be partially relocated (just relatives), in which case they
* are interposable, but are marked as fixed (ET_EXEC).
*
* Thus we really don't have a clear method of deciding when the
* head of a link-map is interposable. So, to be consistent,
* for now only add interposers after the link-map lists head
* object.
*/
continue;
/*
* Insert the new link-map before this non-interposer,
* and indicate an interposer is found.
*/
add = 0;
break;
}
}
/*
* Fall through to appending the new link map to the tail of the list.
* If we're processing the initial objects of this link-map list, add
* them to the backward compatibility list.
*/
if (add) {
}
/*
* Having added this link-map to a control list, indicate which control
* list the link-map belongs to. Note, control list information is
* always maintained as an offset, as the Alist can be reallocated.
*/
/*
* Indicate if an interposer is found. Note that the first object on a
* link-map can be explicitly defined as an interposer so that it can
* provide interposition over direct binding requests.
*/
/*
* For backward compatibility with debuggers, the link-map list contains
* pointers to the main control list.
*/
if (lmco == ALIST_OFF_DATA) {
}
}
/*
* Delete an item from the specified link map control list.
*/
void
{
/*
* If the control list pointer hasn't been initialized, this object
* never got added to a link-map list.
*/
return;
/*
* If we're about to delete an object from the main link-map control
* list, alert the debuggers.
*/
/*
* If we're being audited tell the audit library that we're
* about to go deleting dependencies.
*/
if (clmp && (aud_activity ||
/* LINTED */
else
else
/*
* For backward compatibility with debuggers, the link-map list contains
* pointers to the main control list.
*/
}
/*
* Indicate we have one less object on this control list.
*/
}
/*
* Move a link-map control list to another. Objects that are being relocated
* are maintained on secondary control lists. Once their relocation is
* complete, the entire list is appended to the previous control list, as this
* list must have been the trigger for generating the new control list.
*/
void
{
/*
* If we're about to add a new family of objects to the main link-map
* control list, alert the debuggers. Additions of object families to
* the main link-map control list occur during lazy loading, filtering
* and dlopen().
*/
if (plmco == ALIST_OFF_DATA)
/*
* Indicate each new link-map has been moved to the previous link-map
* control list.
*/
/*
* If these objects are being added to the main link-map
* control list, indicate that there are init's available
* for harvesting.
*/
if (plmco == ALIST_OFF_DATA) {
}
}
/*
* Move the new link-map control list, to the callers link-map control
* list.
*/
} else {
}
/*
* For backward compatibility with debuggers, the link-map list contains
* pointers to the main control list.
*/
if (plmco == ALIST_OFF_DATA) {
}
}
/*
* Create, or assign a link-map control list. Each link-map list contains a
* main control list, which has an Alist offset of ALIST_OFF_DATA (see the
* process, objects are added to this main control list. This control list is
* never deleted, unless an alternate link-map list has been requested (say for
* auditors), and the associated objects could not be loaded or relocated.
*
* Once relocation has started, any lazy loadable objects, or filtees, are
* processed on a new, temporary control list. Only when these objects have
* been fully relocated, are they moved to the main link-map control list.
* Once the objects are moved, this temporary control list is deleted (see
* remove_cntl()).
*
* A dlopen() always requires a new temporary link-map control list.
* Typically, a dlopen() occurs on a link-map list that had already started
* relocation, however, auditors can dlopen() objects on the main link-map
* list while under initial construction, before any relocation has begun.
* Hence, dlopen() requests are explicitly flagged.
*/
{
/*
* If the head link-map object has already been relocated, create a
* new, temporary, control list.
*/
AL_CNT_LMLISTS)) == NULL)
return (NULL);
}
return (ALIST_OFF_DATA);
}
/*
* Environment variables can have a variety of defined permutations, and thus
* the following infrastructure exists to allow this variety and to select the
* required definition.
*
* Environment variables can be defined as 32- or 64-bit specific, and if so
* they will take precedence over any instruction set neutral form. Typically
* this is only useful when the environment value is an informational string.
*
* Environment variables may be obtained from the standard user environment or
* from a configuration file. The latter provides a fallback if no user
* environment setting is found, and can take two forms:
*
* - a replaceable definition - this will be used if no user environment
* setting has been seen, or
*
* - an permanent definition - this will be used no matter what user
* environment setting is seen. In the case of list variables it will be
* appended to any process environment setting seen.
*
* Environment variables can be defined without a value (ie. LD_XXXX=) so as to
* override any replaceable environment variables from a configuration file.
*/
/* variables */
/* variables */
/* variables */
/* variables */
/* variables */
/* specific variables */
/*
* Classify an environment variables type.
*/
/* the wrong ISA */
/* config file */
/*
* Identify all environment variables.
*/
/*
* Pattern match an LD_XXXX environment variable. s1 points to the XXXX part
* and len specifies its length (comparing a strings length before the string
* itself speed things up). s2 points to the token itself which has already
* had any leading white-space removed.
*/
static void
{
const char **str;
/*
* Determine whether we're dealing with a replaceable or permanent
* string.
*/
if (env_flags & ENV_TYP_PERMANT) {
/*
* If the string is from a configuration file and defined as
* permanent, assign it as permanent.
*/
select |= SEL_PERMANT;
} else
select |= SEL_REPLACE;
/*
* Parse the variable given.
*
* The LD_AUDIT family.
*/
if (*s1 == 'A') {
/*
* Replaceable and permanent audit objects can exist.
*/
select |= SEL_ACT_STR;
} else if ((len == MSG_LD_AUDIT_ARGS_SIZE) &&
MSG_LD_AUDIT_ARGS_SIZE) == 0)) {
/*
* A specialized variable for plt_exit() use, not
* documented for general use.
*/
select |= SEL_ACT_SPEC_2;
}
}
/*
* The LD_BIND family.
*/
else if (*s1 == 'B') {
MSG_LD_BIND_LAZY_SIZE) == 0)) {
select |= SEL_ACT_RT2;
select |= SEL_ACT_RT2;
/*
* Another trick, enabled to help debug AOUT
* applications under BCP, but not documented for
* general use.
*/
select |= SEL_ACT_RT;
val = RT_FL_NOBIND;
/*
* This variable is simply for backward compatibility.
* If this and LD_DEBUG are both specified, only one of
* the strings is going to get processed.
*/
select |= SEL_ACT_SPEC_2;
}
}
/*
* LD_CAP_FILES and LD_CONFIG family.
*/
else if (*s1 == 'C') {
select |= SEL_ACT_STR;
/*
* This variable is not documented for general use.
* Although originaly designed for internal use with
* crle(1), this variable is in use by the Studio
* auditing tools. Hence, it can't be removed.
*/
select |= SEL_ACT_SPEC_2;
/*
* Secure applications must use a default configuration
* file. A setting from a configuration file doesn't
* make sense (given we must be reading a configuration
* file to have gotten this).
*/
if ((rtld_flags & RT_FL_SECURE) ||
(env_flags & ENV_TYP_CONFIG))
return;
select |= SEL_ACT_STR;
}
}
/*
* The LD_DEBUG family, LD_DEFERRED (internal, used by ldd(1)), and
* LD_DEMANGLE.
*/
else if (*s1 == 'D') {
select |= SEL_ACT_STR;
MSG_LD_DEBUG_OUTPUT_SIZE) == 0)) {
select |= SEL_ACT_STR;
select |= SEL_ACT_RT;
select |= SEL_ACT_RT;
}
}
/*
* LD_FLAGS - collect the best variable definition. On completion of
* environment variable processing pass the result to ld_flags_env()
* where they'll be decomposed and passed back to this routine.
*/
else if (*s1 == 'F') {
select |= SEL_ACT_SPEC_1;
}
}
/*
* LD_HWCAP.
*/
else if (*s1 == 'H') {
select |= SEL_ACT_STR;
}
}
/*
* LD_INIT (internal, used by ldd(1)).
*/
else if (*s1 == 'I') {
select |= SEL_ACT_LML;
}
}
/*
* The LD_LIBRARY_PATH and LD_LOAD families.
*/
else if (*s1 == 'L') {
select |= SEL_ACT_SPEC_1;
/*
* This variable is not documented for general use.
* Although originaly designed for internal use with
* crle(1), this variable is in use by the Studio
* auditing tools. Hence, it can't be removed.
*/
select |= SEL_ACT_LML;
select |= SEL_ACT_SPEC_2;
}
}
/*
* LD_MACHCAP.
*/
else if (*s1 == 'M') {
select |= SEL_ACT_STR;
&rpl_machcap : &prm_machcap;
}
}
/*
* The LD_NO family.
*/
else if (*s1 == 'N') {
select |= SEL_ACT_RT;
val = RT_FL_NOAUDIT;
select |= SEL_ACT_RT;
select |= SEL_ACT_RT;
val = RT_FL_NOBAPLT;
select |= SEL_ACT_RT;
val = RT_FL_NOCFG;
MSG_LD_NODIRCONFIG_SIZE) == 0)) {
select |= SEL_ACT_RT;
select |= SEL_ACT_LMLT;
MSG_LD_NOENVCONFIG_SIZE) == 0)) {
select |= SEL_ACT_RT;
MSG_LD_NOFLTCONFIG_SIZE) == 0)) {
select |= SEL_ACT_RT2;
select |= SEL_ACT_LMLT;
MSG_LD_NOOBJALTER_SIZE) == 0)) {
select |= SEL_ACT_RT;
select |= SEL_ACT_RT;
MSG_LD_NOUNRESWEAK_SIZE) == 0)) {
/*
* LD_NOUNRESWEAK (internal, used by ldd(1)).
*/
select |= SEL_ACT_LML;
select |= SEL_ACT_LML;
/*
* LD_NOENVIRON can only be set with ld.so.1 -e.
*/
select |= SEL_ACT_RT;
}
}
/*
* LD_PLATCAP, LD_PRELOAD and LD_PROFILE family.
*/
else if (*s1 == 'P') {
select |= SEL_ACT_STR;
&rpl_platcap : &prm_platcap;
select |= SEL_ACT_STR;
/*
* Only one user library can be profiled at a time.
*/
select |= SEL_ACT_SPEC_2;
MSG_LD_PROFILE_OUTPUT_SIZE) == 0)) {
/*
* Only one user library can be profiled at a time.
*/
select |= SEL_ACT_STR;
str = &profile_out;
}
}
/*
* LD_SFCAP and LD_SIGNAL.
*/
else if (*s1 == 'S') {
select |= SEL_ACT_STR;
} else if ((len == MSG_LD_SIGNAL_SIZE) &&
MSG_LD_SIGNAL_SIZE) == 0) &&
((rtld_flags & RT_FL_SECURE) == 0)) {
select |= SEL_ACT_SPEC_2;
}
}
/*
* The LD_TRACE family (internal, used by ldd(1)). This definition is
* the key to enabling all other ldd(1) specific environment variables.
* In case an auditor is called, which in turn might exec(2) a
* subprocess, this variable is disabled, so that any subprocess
* escapes ldd(1) processing.
*/
else if (*s1 == 'T') {
if (((len == MSG_LD_TRACE_OBJS_SIZE) &&
MSG_LD_TRACE_OBJS_SIZE) == 0)) ||
((len == MSG_LD_TRACE_OBJS_E_SIZE) &&
MSG_LD_TRACE_OBJS_E_SIZE) == 0) && !aout) ||
MSG_LD_TRACE_OBJS_A_SIZE) == 0) && aout)))) {
select |= SEL_ACT_SPEC_2;
/*
* The simplest way to "disable" this variable is to
* truncate this string to "LD_'\0'". This string is
* ignored by any ld.so.1 environment processing.
* Use of such interfaces as unsetenv(3c) are overkill,
* and would drag too much libc implementation detail
* into ld.so.1.
*/
*s0 = '\0';
#else
/*
* Verify that the above write is appropriate for any new platforms.
*/
#endif
MSG_LD_TRACE_PTHS_SIZE) == 0)) {
select |= SEL_ACT_LML;
}
}
/*
* LD_UNREF and LD_UNUSED (internal, used by ldd(1)).
*/
else if (*s1 == 'U') {
select |= SEL_ACT_LML;
select |= SEL_ACT_LML;
}
}
/*
* LD_VERBOSE (internal, used by ldd(1)).
*/
else if (*s1 == 'V') {
select |= SEL_ACT_LML;
}
}
/*
* LD_WARN (internal, used by ldd(1)).
*/
else if (*s1 == 'W') {
select |= SEL_ACT_LML;
}
}
if (variable == 0)
return;
/*
* If the variable is already processed with and ISA specific variable,
* no further processing is needed.
*/
return;
/*
* If this variable has already been set via the command line, then
* ignore this variable. The command line, -e, takes precedence.
*/
if (env_flags & ENV_TYP_ISA) {
return;
if (env_flags & ENV_TYP_CMDLINE)
} else {
return;
if (env_flags & ENV_TYP_CMDLINE)
}
/*
* Mark the appropriate variables.
*/
if (env_flags & ENV_TYP_ISA) {
/*
* This is an ISA setting.
*/
if (select & SEL_REPLACE) {
return;
} else {
}
} else {
/*
* This is a non-ISA setting.
*/
if (select & SEL_REPLACE) {
return;
} else
}
/*
* Now perform the setting.
*/
if (select & SEL_ACT_RT) {
if (s2)
rtld_flags |= val;
else
rtld_flags &= ~val;
} else if (select & SEL_ACT_RT2) {
if (s2)
rtld_flags2 |= val;
else
rtld_flags2 &= ~val;
} else if (select & SEL_ACT_STR) {
if (env_flags & ENV_TYP_NULL)
else
} else if (select & SEL_ACT_LML) {
if (s2)
else
} else if (select & SEL_ACT_LMLT) {
if (s2)
else
} else if (select & SEL_ACT_SPEC_1) {
/*
* variable is either ENV_FLG_FLAGS or ENV_FLG_LIBPATH
*/
if (env_flags & ENV_TYP_NULL)
else
if (s2) {
if (variable == ENV_FLG_FLAGS)
else
} else {
if (variable == ENV_FLG_FLAGS)
env_info &= ~ENV_INF_FLAGCFG;
else
env_info &= ~ENV_INF_PATHCFG;
}
}
} else if (select & SEL_ACT_SPEC_2) {
/*
* variables can be: ENV_FLG_
* AUDIT_ARGS, BINDING, CONFGEN, LOADFLTR, PROFILE,
* SIGNAL, TRACE_OBJS
*/
switch (variable) {
case ENV_FLG_AUDIT_ARGS:
if (s2) {
} else
audit_argcnt = 0;
break;
case ENV_FLG_BINDINGS:
if (s2)
else
break;
case ENV_FLG_CONFGEN:
if (s2) {
*lmflags |= LML_FLG_IGNRELERR;
} else {
rtld_flags &= ~RT_FL_CONFGEN;
*lmflags &= ~LML_FLG_IGNRELERR;
}
break;
case ENV_FLG_LOADFLTR:
if (s2) {
if (*s2 == '2')
} else {
*lmtflags &= ~LML_TFLG_LOADFLTR;
rtld_flags &= ~RT_FL_WARNFLTR;
}
break;
case ENV_FLG_PROFILE:
profile_name = s2;
if (s2) {
return;
}
/* BEGIN CSTYLED */
if (rtld_flags & RT_FL_SECURE) {
#if defined(_ELF64)
#else
#endif
} else {
#if defined(_ELF64)
#else
#endif
}
/* END CSTYLED */
} else
profile_lib = NULL;
break;
case ENV_FLG_SIGNAL:
break;
case ENV_FLG_TRACE_OBJS:
if (s2) {
if (*s2 == '2')
} else
*lmflags &=
break;
}
}
}
/*
* Determine whether we have an architecture specific environment variable.
* If we do, and we're the wrong architecture, it'll just get ignored.
* Otherwise the variable is processed in it's architecture neutral form.
*/
static int
{
#if defined(_ELF64)
return (ENV_TYP_IGNORE);
#else
return (ENV_TYP_ISA);
#endif
}
#if defined(_ELF64)
return (ENV_TYP_ISA);
#else
return (ENV_TYP_IGNORE);
#endif
}
}
return (0);
}
/*
* Process an LD_FLAGS environment variable. The value can be a comma
* separated set of tokens, which are sent (in upper case) into the generic
* LD_XXXX environment variable engine. For example:
*
* LD_FLAGS=bind_now= -> LD_BIND_NOW=
* LD_FLAGS=bind_now -> LD_BIND_NOW=1
* LD_FLAGS=library_path= -> LD_LIBRARY_PATH=
* LD_FLAGS=library_path=/foo:. -> LD_LIBRARY_PATH=/foo:.
* LD_FLAGS=debug=files:detail -> LD_DEBUG=files:detail
* or
* LD_FLAGS=bind_now,library_path=/foo:.,debug=files:detail
*/
static int
{
return (0);
/*
* Create a new string as we're going to transform the token(s) into
* uppercase and separate tokens with nulls.
*/
return (1);
int flags = 0;
if (*sstr == '=')
else {
/*
* Translate token to uppercase. Don't
* use toupper(3C) as including this
* code doubles the size of ld.so.1.
*/
}
}
continue;
}
*sstr = '\0';
/*
* Have we discovered an "=" string.
*/
if (estr) {
/*
* If this is an unqualified "=", then this variable
* is intended to ensure a feature is disabled.
*/
} else {
/*
* If there is no "=" found, fabricate a boolean
* definition for any unqualified variable. Thus,
* LD_FLAGS=bind_now is represented as BIND_NOW=1.
* The value "1" is sufficient to assert any boolean
* variables. Setting of ENV_TYP_NULL ensures any
* string usage is reset to a NULL string, thus
* LD_FLAGS=library_path is equivalent to
* LIBRARY_PATH='\0'.
*/
flags |= ENV_TYP_NULL;
}
/*
* Determine whether the environment variable is 32- or 64-bit
* specific. The length, len, will reflect the architecture
* neutral portion of the string.
*/
}
if (len == 0)
break;
}
return (0);
}
/*
* Variant of getopt(), intended for use when ld.so.1 is invoked directly
* from the command line. The only command line option allowed is -e followed
* by a runtime linker environment variable.
*/
int
{
int ndx;
char *str;
break;
ndx++;
break;
}
return (1);
ndx++;
return (1);
} else
/*
* If the environment variable starts with LD_, strip the LD_.
* Otherwise, take things as is. Indicate that this variable
* originates from the command line, as these variables take
* precedence over any environment variables, or configuration
* file variables.
*/
str += 3;
return (1);
}
/*
* Make sure an object file has been specified.
*/
return (1);
/*
* Having gotten the arguments, clean ourselves off of the stack.
* This results in a process that looks as if it was executed directly
* from the application.
*/
return (0);
}
/*
* Process a single LD_XXXX string.
*/
static void
int aout)
{
const char *s2;
int flags;
/*
* In a branded process we must ignore all LD_XXXX variables because
* they are intended for the brand's linker. To affect the native
* linker, use LD_BRAND_XXXX instead.
*/
if (rtld_flags2 & RT_FL2_BRANDED) {
MSG_LD_BRAND_PREFIX_SIZE) != 0)
return;
}
/*
* Variables with no value (ie. LD_XXXX=) turn a capability off.
*/
} else if (*++s2 == '\0') {
} else {
while (conv_strproc_isspace(*s2))
s2++;
}
/*
* Determine whether the environment variable is 32-bit or 64-bit
* specific. The length, len, will reflect the architecture neutral
* portion of the string.
*/
return;
}
/*
* Internal getenv routine. Called immediately after ld.so.1 initializes
* itself to process any locale specific environment variables, and collect
* any LD_XXXX variables for later processing.
*/
int
{
char *locale;
const char *s1;
int loc = 0;
const char *s2;
if (*s1++ != 'L')
continue;
/*
* See if we have any locale environment settings. These
* environment variables have a precedence, LC_ALL is higher
* than LC_MESSAGES which is higher than LANG.
*/
MSG_LC_ALL_SIZE) == 0) {
s2 += MSG_LC_ALL_SIZE;
(char *)s2;
}
MSG_LC_MESSAGES_SIZE) == 0) {
(char *)s2;
}
}
continue;
}
continue;
}
/*
* Pick off any LD_XXXX environment variables.
*/
return (1);
}
}
/*
* If we have a locale setting make sure it's worth processing further.
* C and POSIX locales don't need any processing. In addition, to
* the locale to contain a segment that leads upward in the file system
* hierarchy (i.e. no '..' segments). Given that we'll be confined to
* validate the mode or ownership of any message file (as libc's
* generic handling of message files does), or be concerned with
* symbolic links that might otherwise send us elsewhere. Duplicate
* the string so that new locale setting can generically cleanup any
* previous locales.
*/
else
}
return (0);
}
/*
* Process any LD_XXXX environment variables collected by readenv_user().
*/
int
{
const char *s1;
/*
* Having collected the best representation of any LD_FLAGS, process
* these strings.
*/
if (rpl_ldflags) {
return (1);
rpl_ldflags = NULL;
}
/*
* Don't allow environment controlled auditing when tracing or if
* explicitly disabled. Trigger all tracing modes from
* LML_FLG_TRC_ENABLE.
*/
if ((*lmflags & LML_FLG_TRC_ENABLE) == 0)
*lmflags &= ~LML_MSK_TRC;
/*
* If both LD_BIND_NOW and LD_BIND_LAZY are specified, the former wins.
*/
/*
* When using ldd(1) -r or -d against an executable, assert -p.
*/
if ((*lmflags &
return (0);
}
/*
* Configuration environment processing. Called after the a.out has been
* processed (as the a.out can specify its own configuration file).
*/
int
{
return (0);
envtbl++;
}
/*
* Having collected the best representation of any LD_FLAGS, process
* these strings.
*/
return (1);
aout) == 1)
return (1);
/*
* Don't allow environment controlled auditing when tracing or if
* explicitly disabled. Trigger all tracing modes from
* LML_FLG_TRC_ENABLE.
*/
if ((*lmflags & LML_FLG_TRC_ENABLE) == 0)
*lmflags &= ~LML_MSK_TRC;
return (0);
}
int
{
/*
* We do not have a valid file descriptor, so we are unable
* to flush the buffer.
*/
return (0);
return (1);
}
/*
* Simplified printing. The following conversion specifications are supported:
*
* % [#] [-] [min field width] [. precision] s|d|x|c
*
*
* dorprf takes the output buffer in the form of Prfbuf which permits
* the verification of the output buffer size and the concatenation
* of data to an already existing output buffer. The Prfbuf
* structure contains the following:
*
* pr_buf pointer to the beginning of the output buffer.
* pr_cur pointer to the next available byte in the output buffer. By
* setting pr_cur ahead of pr_buf you can append to an already
* existing buffer.
* pr_len the size of the output buffer. By setting pr_len to '0' you
* disable protection from overflows in the output buffer.
* pr_fd a pointer to the file-descriptor the buffer will eventually be
* output to. If pr_fd is set to '-1' then it's assumed there is
* no output buffer, and doprf() will return with an error to
* indicate an output buffer overflow. If pr_fd is > -1 then when
* the output buffer is filled it will be flushed to pr_fd and will
* then be available for additional data.
*/
/*
* This macro is for use from within doprf only. It is to be used for checking
* the output buffer size and placing characters into the buffer.
*/
#define PUTC(c) \
{ \
char tmpc; \
\
tmpc = (c); \
return (0); \
} \
}
/*
* Define a local buffer size for building a numeric value - large enough to
* hold a 64-bit value.
*/
{
char c;
while ((c = *format++) != '\0') {
if (c != '%') {
PUTC(c);
} else {
char *_s;
int ls = 0;
c = *format++;
switch (c) {
case '-':
flag |= FLG_UT_MINUS;
goto again;
case '#':
flag |= FLG_UT_SHARP;
goto again;
case '.':
flag |= FLG_UT_DOTSEEN;
goto again;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (flag & FLG_UT_DOTSEEN)
else
goto again;
case 'x':
case 'X':
base = 16;
break;
case 'd':
case 'D':
case 'u':
base = 10;
flag &= ~FLG_UT_SHARP;
break;
case 'l':
base = 10;
ls++; /* number of l's (long or long long) */
if ((*format == 'l') ||
goto again;
break;
case 'o':
case 'O':
base = 8;
break;
case 'c':
PUTC(c);
}
}
PUTC(c);
}
break;
case 's':
/* LINTED */
if (!prec)
/* LINTED */
while (_n-- > 0)
PUTC(' ');
}
PUTC(c);
}
while (_n-- > 0)
PUTC(' ');
}
break;
case '%':
PUTC('%');
break;
default:
break;
}
/*
* Numeric processing
*/
if (base) {
const char *string =
const char *prefix =
switch (ls) {
case 0: /* int */
num = (u_longlong_t)
break;
case 1: /* long */
num = (u_longlong_t)
break;
case 2: /* long long */
break;
}
if (flag & FLG_UT_SHARP) {
if (base == 16) {
psize = 2;
} else {
psize = 1;
}
}
}
/*
* Convert the numeric value into a local
* string (stored in reverse order).
*/
do {
ssize++;
} while (num);
/*
* Provide any precision or width padding.
*/
if (prec) {
/* LINTED */
while ((_n-- > 0) &&
*_s++ = '0';
ssize++;
}
}
/* LINTED */
while (_n-- > 0) {
PUTC(' ');
}
}
/*
* Print any prefix and the numeric string
*/
while (*prefix)
do {
/*
* Provide any width padding.
*/
/* LINTED */
while (_n-- > 0)
PUTC(' ');
}
}
}
}
PUTC('\0');
return (1);
}
static int
{
return (0);
/* LINTED */
}
/* VARARGS2 */
int
{
int len;
/*
* sprintf() return value excludes the terminating null byte.
*/
return (len - 1);
}
/* VARARGS3 */
int
{
int len;
return (len);
}
/* VARARGS2 */
int
{
int len;
return (len);
}
/*PRINTFLIKE1*/
int
{
/*
* Trim trailing '\0' form buffer
*/
}
/*
* All error messages go through eprintf(). During process initialization,
* these messages are directed to the standard error, however once control has
* been passed to the applications code these messages are stored in an internal
* buffer for use with dlerror(). Note, fatal error conditions that may occur
* while running the application will still cause a standard error message, see
* rtldexit() in this file for details.
* The RT_FL_APPLIC flag serves to indicate the transition between process
* initialization and when the applications code is running.
*/
void
{
int overflow = 0;
static int lock = 0;
return;
/*
* Note: this lock is here to prevent the same thread from recursively
* entering itself during a eprintf. ie: during eprintf malloc() fails
* and we try and call eprintf ... and then malloc() fails ....
*/
lock = 1;
/*
* If we have completed startup initialization, all error messages
* must be saved. These are reported through dlerror(). If we're
* still in the initialization stage, output the error directly and
* add a newline.
*/
if ((rtld_flags & RT_FL_APPLIC) == 0)
else
error = ERR_WARNING;
switch (error) {
case ERR_WARNING_NF:
break;
case ERR_WARNING:
break;
case ERR_GUIDANCE:
break;
case ERR_FATAL:
break;
case ERR_ELF:
break;
}
if (procname) {
overflow = 1;
} else {
overflow = 1;
}
if (overflow == 0) {
/*
* Remove the terminating '\0'.
*/
}
}
overflow = 1;
/*
* If this is an ELF error, it will have been generated by a support
* object that has a dependency on libelf. ld.so.1 doesn't generate any
* ELF error messages as it doesn't interact with libelf. Determine the
* ELF error string.
*/
static int (*elfeno)() = 0;
static const char *(*elfemg)();
const char *emsg;
elfeno = 0;
}
/*
* Lookup the message; equivalent to elf_errmsg(elf_errno()).
*/
emsg) == 0)
overflow = 1;
}
}
/*
* Push out any message that's been built. Note, in the case of an
* overflow condition, this message may be incomplete, in which case
* make sure any partial string is null terminated.
*/
}
if (overflow)
/*
* Determine if there was insufficient space left in the buffer to
* complete the message. If so, we'll have printed out as much as had
* been processed if we're not yet executing the application.
* Otherwise, there will be some debugging diagnostic indicating
* as much of the error message as possible. Write out a final buffer
* overflow diagnostic - unlocalized, so we don't chance more errors.
*/
if (overflow) {
if ((rtld_flags & RT_FL_SILENCERR) == 0) {
if ((rtld_flags & RT_FL_APPLIC) == 0) {
}
}
lock = 0;
return;
}
/*
* If the application has started, then error messages are being saved
* for retrieval by dlerror(), or possible flushing from rtldexit() in
* the case of a fatal error. In this case, establish the next error
* pointer. If we haven't started the application, the whole message
* buffer can be reused.
*/
if ((rtld_flags & RT_FL_SILENCERR) == 0) {
/*
* Note, should we encounter an error such as ENOMEM, there may
* be a number of the same error messages (ie. an operation
* fails with ENOMEM, and then the attempts to construct the
* error message itself, which incurs additional ENOMEM errors).
* Compare any previous error message with the one we've just
* created to prevent any duplication clutter.
*/
if ((rtld_flags & RT_FL_APPLIC) &&
*nextptr = '\0';
}
}
lock = 0;
}
/*PRINTFLIKE3*/
void
{
}
/*
* details.
*/
int
assfail(const char *a, const char *f, int l)
{
(void) printf("assertion failed: %s, file: %s, line: %d\n", a, f, l);
return (0);
}
void
const char *f, int l)
{
(void) printf("assertion failed: %s (0x%llx %s 0x%llx), "
(unsigned long long)b, f, l);
}
/*
* Exit. If we arrive here with a non zero status it's because of a fatal
* error condition (most commonly a relocation error). If the application has
* already had control, then the actual fatal error message will have been
* recorded in the dlerror() message buffer. Print the message before really
* exiting.
*/
void
{
if (status) {
if (rtld_flags & RT_FL_APPLIC) {
/*
* If the error buffer has been used, write out all
* pending messages - lasterr is simply a pointer to
* the last message in this buffer. However, if the
* buffer couldn't be created at all, lasterr points
* to a constant error message string.
*/
if (*errbuf) {
}
}
}
}
}
}
/*
* Map anonymous memory via MAP_ANON (added in Solaris 8).
*/
void *
{
return (MAP_FAILED);
}
return (va);
}
void *
{
int err;
if (nu_fd == FD_UNAVAIL) {
O_RDONLY)) == FD_UNAVAIL) {
return (MAP_FAILED);
}
}
MAP_FAILED) {
}
return (va);
}
/*
* Generic entry point from user code - simply grabs a lock, and bumps the
* entrance count.
*/
int
{
if (!thr_flg_nolock)
(void) rt_mutex_lock(&rtldlock);
if (rtld_flags & RT_FL_OPERATION) {
ld_entry_cnt++;
/*
* Reset the diagnostic time information for each new
* "operation". Thus timing diagnostics are relative
* to entering ld.so.1.
*/
if (DBG_ISTIME() &&
DBG_ONRESET();
}
}
return (1);
}
return (0);
}
/*
* Determine whether a search path has been used.
*/
static void
{
continue;
/*
* If this pathname originated from an expanded token, use the
* original for any diagnostic output.
*/
if (unref == 0) {
if ((*nl)++ == 0)
continue;
}
else
} else {
else
}
} else
continue;
if ((*nl)++ == 0)
}
}
/*
* Generate diagnostics as to whether an object has been used. A symbolic
* reference that gets bound to an object marks it as used. Dependencies that
* are unused when RTLD_NOW is in effect should be removed from future builds
* of an object. Dependencies that are unused without RTLD_NOW in effect are
* candidates for lazy-loading.
*
* Unreferenced objects identify objects that are defined as dependencies but
* are unreferenced by the caller. These unreferenced objects may however be
* referenced by other objects within the process, and therefore don't qualify
* as completely unused. They are still an unnecessary overhead.
*
* Unreferenced runpaths are also captured under ldd -U, or "unused,detail"
* debugging.
*/
void
{
int nl = 0;
/*
* If we're not tracing unused references or dependencies, or debugging
* there's nothing to do.
*/
return;
/*
* Detect unused global search paths.
*/
if (rpl_libdirs)
if (prm_libdirs)
nl = 0;
/*
* Traverse the link-maps looking for unreferenced or unused
* dependencies. Ignore the first object on a link-map list, as this
* is always used.
*/
nl = 0;
/*
* Determine if this object contains any runpaths that have
* not been used.
*/
/*
* If tracing unreferenced objects, or under debugging,
* determine whether any of this objects callers haven't
* referenced it.
*/
if (unref || DBG_ENABLED) {
continue;
continue;
/* BEGIN CSTYLED */
if (nl++ == 0) {
if (unref)
else
DBG_NL_STD));
}
if (unref)
else
/* END CSTYLED */
}
}
/*
* If tracing unused objects simply display those objects that
* haven't been referenced by anyone.
*/
continue;
if (nl++ == 0) {
else
}
else
} else {
else
}
}
}
/*
* Generic cleanup routine called prior to returning control to the user.
* Ensures that any ld.so.1 specific file descriptors or temporary mapping are
* released, and any locks dropped.
*/
void
{
/*
* Alert the debuggers that the link-maps are consistent.
*/
/*
* Alert any auditors that the link-maps are consistent.
*/
}
if (nu_fd != FD_UNAVAIL) {
nu_fd = FD_UNAVAIL;
}
/*
* Reinitialize error message pointer, and any overflow indication.
*/
/*
* Defragment any freed memory.
*/
if (aplist_nitems(free_alp))
defrag();
/*
* Don't drop our lock if we are running on our link-map list as
* there's little point in doing so since we are single-threaded.
*
* LML_FLG_HOLDLOCK is set for:
* - The ld.so.1's link-map list.
* - The auditor's link-map if the environment is pre-UPM.
*/
return;
if (rt_bind_clear(0) & THR_FLG_RTLD) {
if (!thr_flg_nolock)
(void) rt_mutex_unlock(&rtldlock);
}
}
int
{
/*
* An object can always find symbols within itself.
*/
return (1);
/*
* The search for a singleton must look in every loaded object.
*/
if (slflags & LKUP_SINGLETON)
return (1);
/*
* Don't allow an object to bind to an object that is being deleted
* unless the binder is also being deleted.
*/
return (0);
/*
* An object with world access can always bind to an object with global
* visibility.
*/
return (1);
/*
* An object with local access can only bind to an object that is a
* member of the same group.
*/
return (0);
/*
* Traverse the list of groups the caller is a part of.
*/
/*
* If we're testing for the ability of two objects to bind to
* each other regardless of a specific group, ignore that group.
*/
continue;
/*
* Traverse the list of groups the destination is a part of.
*/
continue;
/*
* Make sure the relationship between the destination
* and the caller provide symbols for relocation.
* Parents are maintained as callers, but unless the
* destination object was opened with RTLD_PARENT, the
* parent doesn't provide symbols for the destination
* to relocate against.
*/
continue;
return (1);
}
}
}
return (0);
}
/*
* Initialize the environ symbol. Traditionally this is carried out by the crt
* code prior to jumping to main. However, init sections get fired before this
* variable is initialized, so ld.so.1 sets this directly from the AUX vector
* information. In addition, a process may have multiple link-maps (ld.so.1's
* debugging and preloading objects), and link auditing, and each may need an
* environ variable set.
*
* This routine is called after a relocation() pass, and thus provides for:
*
* - setting environ on the main link-map after the initial application and
* its dependencies have been established. Typically environ lives in the
* application (provided by its crt), but in older applications it might
* be in libc. Who knows what's expected of applications not built on
* Solaris.
*
* - after loading a new shared object. We can add shared objects to various
* link-maps, and any link-map dependencies requiring getopt() require
* their own environ. In addition, lazy loading might bring in the
* supplier of environ (libc used to be a lazy loading candidate) after
* the link-map has been established and other objects are present.
*
* This routine handles all these scenarios, without adding unnecessary overhead
* to ld.so.1.
*/
void
{
/*
* Initialize the symbol lookup, and symbol result, data structures.
*/
ld_entry_cnt, 0, 0, 0, 0, LKUP_WEAK);
lml->lm_environ =
}
}
/*
* Determine whether we have a secure executable. Uid and gid information
* can be passed to us via the aux vector, however if these values are -1
* then use the appropriate system call to obtain them.
*
* - If the user is the root they can do anything
*
* - If the real and effective uid's don't match, or the real and
* effective gid's don't match then this is determined to be a `secure'
* application.
*
* This function is called prior to any dependency processing (see _setup.c).
* Any secure setting will remain in effect for the life of the process.
*/
void
{
if (auxflags != -1) {
if ((auxflags & AF_SUN_SETUGID) != 0)
return;
}
if (uid) {
else {
}
}
}
/*
* Determine whether ld.so.1 itself is owned by root and has its mode setuid.
*/
int
{
const char *name;
if (rtld_flags2 & RT_FL2_SETUID)
return (1);
else
return (1);
}
return (0);
}
/*
* Determine that systems platform name. Normally, this name is provided from
* the AT_SUN_PLATFORM aux vector from the kernel. This routine provides a
* fall back.
*/
void
{
return;
return;
}
}
/*
* Determine that systems machine name. Normally, this name is provided from
* the AT_SUN_MACHINE aux vector from the kernel. This routine provides a
* fall back.
*/
void
{
return;
return;
}
}
/*
* _REENTRANT code gets errno redefined to a function so provide for return
* of the thread errno if applicable. This has no meaning in ld.so.1 which
* is basically singled threaded. Provide the interface for our dependencies.
*/
int *
___errno()
{
extern int errno;
return (&errno);
}
/*
* Determine whether a symbol name should be demangled.
*/
const char *
{
if (rtld_flags & RT_FL_DEMANGLE)
return (conv_demangle_name(name));
else
return (name);
}
#ifndef _LP64
/*
* Wrappers on stat() and fstat() for 32-bit rtld that uses stat64()
* underneath while preserving the object size limits of a non-largefile
* enabled 32-bit process. The purpose of this is to prevent large inode
* values from causing stat() to fail.
*/
inline static int
{
extern int errno;
/*
* Although we used a 64-bit capable stat(), the 32-bit rtld
* can only handle objects < 2GB in size. If this object is
* too big, turn the success into an overflow error.
*/
return (-1);
}
/*
* Transfer the information needed by rtld into a rtld_stat_t
* structure that preserves the non-largile types for everything
* except inode.
*/
#ifdef sparc
#endif
return (r);
}
int
{
int r;
if (r != -1)
return (r);
}
int
{
int r;
if (r != -1)
return (r);
}
#endif