mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
elf: Split _dl_lookup_map, _dl_map_new_object from _dl_map_object
So that they can eventually be called separately from dlopen.
This commit is contained in:
@@ -1887,24 +1887,14 @@ open_path (const char *name, size_t namelen, int mode,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map in the shared object file NAME. */
|
|
||||||
|
|
||||||
struct link_map *
|
struct link_map *
|
||||||
_dl_map_object (struct link_map *loader, const char *name,
|
_dl_lookup_map (Lmid_t nsid, const char *name)
|
||||||
int type, int trace_mode, int mode, Lmid_t nsid)
|
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
const char *origname = NULL;
|
|
||||||
char *realname;
|
|
||||||
char *name_copy;
|
|
||||||
struct link_map *l;
|
|
||||||
struct filebuf fb;
|
|
||||||
|
|
||||||
assert (nsid >= 0);
|
assert (nsid >= 0);
|
||||||
assert (nsid < GL(dl_nns));
|
assert (nsid < GL(dl_nns));
|
||||||
|
|
||||||
/* Look for this name among those already loaded. */
|
/* Look for this name among those already loaded. */
|
||||||
for (l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next)
|
for (struct link_map *l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next)
|
||||||
{
|
{
|
||||||
/* If the requested name matches the soname of a loaded object,
|
/* If the requested name matches the soname of a loaded object,
|
||||||
use that object. Elide this check for names that have not
|
use that object. Elide this check for names that have not
|
||||||
@@ -1933,6 +1923,22 @@ _dl_map_object (struct link_map *loader, const char *name,
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map in the shared object file NAME. */
|
||||||
|
|
||||||
|
struct link_map *
|
||||||
|
_dl_map_new_object (struct link_map *loader, const char *name,
|
||||||
|
int type, int trace_mode, int mode, Lmid_t nsid)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
const char *origname = NULL;
|
||||||
|
char *realname;
|
||||||
|
char *name_copy;
|
||||||
|
struct link_map *l;
|
||||||
|
struct filebuf fb;
|
||||||
|
|
||||||
/* Display information if we are debugging. */
|
/* Display information if we are debugging. */
|
||||||
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)
|
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)
|
||||||
&& loader != NULL)
|
&& loader != NULL)
|
||||||
@@ -2183,6 +2189,17 @@ _dl_map_object (struct link_map *loader, const char *name,
|
|||||||
type, mode, &stack_end, nsid);
|
type, mode, &stack_end, nsid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct link_map *
|
||||||
|
_dl_map_object (struct link_map *loader, const char *name,
|
||||||
|
int type, int trace_mode, int mode, Lmid_t nsid)
|
||||||
|
{
|
||||||
|
struct link_map *l = _dl_lookup_map (nsid, name);
|
||||||
|
if (l != NULL)
|
||||||
|
return l;
|
||||||
|
return _dl_map_new_object (loader, name, type, trace_mode, mode, nsid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct add_path_state
|
struct add_path_state
|
||||||
{
|
{
|
||||||
bool counting;
|
bool counting;
|
||||||
|
@@ -885,6 +885,11 @@ int _dl_catch_exception (struct dl_exception *exception,
|
|||||||
void (*operate) (void *), void *args);
|
void (*operate) (void *), void *args);
|
||||||
rtld_hidden_proto (_dl_catch_exception)
|
rtld_hidden_proto (_dl_catch_exception)
|
||||||
|
|
||||||
|
/* Search NSID for a map with NAME. If no such map is already loaded,
|
||||||
|
return NULL. */
|
||||||
|
struct link_map *_dl_lookup_map (Lmid_t nsid, const char *name)
|
||||||
|
attribute_hidden;
|
||||||
|
|
||||||
/* Open the shared object NAME and map in its segments.
|
/* Open the shared object NAME and map in its segments.
|
||||||
LOADER's DT_RPATH is used in searching for NAME.
|
LOADER's DT_RPATH is used in searching for NAME.
|
||||||
If the object is already opened, returns its existing map. */
|
If the object is already opened, returns its existing map. */
|
||||||
@@ -893,6 +898,14 @@ extern struct link_map *_dl_map_object (struct link_map *loader,
|
|||||||
int type, int trace_mode, int mode,
|
int type, int trace_mode, int mode,
|
||||||
Lmid_t nsid) attribute_hidden;
|
Lmid_t nsid) attribute_hidden;
|
||||||
|
|
||||||
|
/* Like _dl_map_object, but assumes that NAME has not been loaded yet
|
||||||
|
(_dl_lookup_map returned NULL). */
|
||||||
|
struct link_map *_dl_map_new_object (struct link_map *loader,
|
||||||
|
const char *name,
|
||||||
|
int type, int trace_mode, int mode,
|
||||||
|
Lmid_t nsid) attribute_hidden;
|
||||||
|
|
||||||
|
|
||||||
/* Call _dl_map_object on the dependencies of MAP, and set up
|
/* Call _dl_map_object on the dependencies of MAP, and set up
|
||||||
MAP->l_searchlist. PRELOADS points to a vector of NPRELOADS previously
|
MAP->l_searchlist. PRELOADS points to a vector of NPRELOADS previously
|
||||||
loaded objects that will be inserted into MAP->l_searchlist after MAP
|
loaded objects that will be inserted into MAP->l_searchlist after MAP
|
||||||
|
Reference in New Issue
Block a user