object.c revision 56deab0745753336570f5c63c3b5fa565eaab8f1
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Object file dependent suport for ELF objects.
*/
#include <stdio.h>
#include <unistd.h>
#include <libelf.h>
#include <string.h>
#include <dlfcn.h>
#include <debug.h>
#include <libld.h>
#include "_rtld.h"
#include "_audit.h"
#include "_elf.h"
/*
* Process a relocatable object. The static object link map pointer is used as
* a flag to determine whether a concatenation is already in progress (ie. an
* LD_PRELOAD may specify a list of objects). The link map returned simply
* specifies an `object' flag which the caller can interpret and thus call
* elf_obj_fini() to complete the concatenation.
*/
static Rt_map *
{
const char *name;
/*
* Allocate the name of this object, as the original name may be
* associated with a data buffer that can be reused to load the
* dependencies needed to processes this object.
*/
return (NULL);
/*
* Initialize an output file descriptor and the entrance criteria.
*/
return (NULL);
/*
* As ent_setup() will effectively lazy load the necessary support
* libraries, make sure ld.so.1 is initialized for plt relocations.
* Then configure libld.so to process objects of the desired target
* type (this is the first call to libld.so, which will effectively
* lazyload it).
*/
return (NULL);
}
/*
* Obtain a generic set of entrance criteria, and generate a link map
* place holder and use the ELFPRV() element to maintain the output
* file descriptor.
*/
return (NULL);
}
/*
* Initialize string tables.
*/
return (NULL);
}
/*
* Assign the output file name to be the initial object that got us
* here. This name is being used for diagnostic purposes only as we
* don't actually generate an output file unless debugging is enabled.
*/
return (olmp);
}
/*
* Define a structure to retain the mapping information of the original
* relocatable object. Typically, mmapobj(2) maps a relocatable object into one
* mapping. However, if padding has been enabled by a debugger, then additional
* padding segments may have been added. elf_obj_file() needs to know which
* segment is the relocatable objects data, and retain the initial segment and
* the associated segment number for unmapping this object later (see
* elf_obj_fini()). Note, even if padding is enabled, the final shared object
* that is created by the link-editor for this relocatable object will have no
* associated padding, as ld(1) has no capabilities to provide padding.
*/
typedef struct {
} Mmap_desc;
/*
* Initial processing of a relocatable object. If this is the first object
* encountered we need to initialize some structures, then simply call the
* link-edit functionality to provide the initial processing of the file (ie.
* reads in sections and symbols, performs symbol resolution if more that one
* object file have been specified, and assigns input sections to output
* sections).
*/
Rt_map *
{
/*
* If this is the first relocatable object (LD_PRELOAD could provide a
* list of objects), initialize an input file descriptor and a link map.
*/
return (NULL);
/*
* Keep track of the input image, as this must be free'd after all ELF
* processing is completed.
*/
AL_CNT_MPOBJS) == NULL) {
return (NULL);
}
/*
* Pass the object mapping to the link-editor to commence processing the
* file.
*/
return (NULL);
}
return (olmp);
}
/*
* Finish relocatable object processing. Having already initially processed one
* or more objects, complete the generation of a shared object image by calling
*/
Rt_map *
{
int mnum;
return (NULL);
return (NULL);
/*
* At this point, all input section processing is complete. If any
* hardware or software capabilities have been established, ensure that
* they are appropriate for this platform.
*/
}
return (NULL);
}
}
return (NULL);
}
/*
* Finish creating the output file.
*/
return (NULL);
return (NULL);
return (NULL);
return (NULL);
/*
* At this point we have a memory image of the shared object. The link
* editor would normally simply write this to the required output file.
* If we're debugging generate a standard temporary output file.
*/
/*
* Allocate a mapping array to retain mapped segment information.
*/
sizeof (mmapobj_result_t))) == NULL)
return (NULL);
continue;
mnum++;
}
/*
* Generate a new link map representing the memory image created.
*/
return (NULL);
/*
* Replace the original (temporary) link map with the new link map.
*/
/* LINTED */
} else {
}
}
/*
* Reassign any original handles to the new link-map.
*/
break;
}
}
}
olmp = 0;
/*
* Unmap the original relocatable object.
*/
}
/*
* Now that we've allocated our permanent link map structure, expand the
* PATHNAME() and insert this path name into the FullPathNode AVL tree.
*/
return (NULL);
/*
* If we're being audited tell the audit library of the file we've just
* opened.
*/
return (NULL);
}
return (nlmp);
}