]> sourceware.org Git - glibc.git/blame - elf/dl-object.c
Sat May 6 11:06:47 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
[glibc.git] / elf / dl-object.c
CommitLineData
d66e34cd
RM
1/* Storage management for the chain of loaded shared objects.
2Copyright (C) 1995 Free Software Foundation, Inc.
3This file is part of the GNU C Library.
4
5The GNU C Library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Library General Public License as
7published by the Free Software Foundation; either version 2 of the
8License, or (at your option) any later version.
9
10The GNU C Library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Library General Public License for more details.
14
15You should have received a copy of the GNU Library General Public
16License along with the GNU C Library; see the file COPYING.LIB. If
17not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18Cambridge, MA 02139, USA. */
19
20#include <link.h>
21#include <assert.h>
22#include <string.h>
23#include <stdlib.h>
24
25
26/* List of objects currently loaded. */
27struct link_map *_dl_loaded;
28
29/* Tail of that list which were loaded at startup. */
30struct link_map *_dl_startup_loaded;
31
32/* Allocate a `struct link_map' for a new object being loaded,
33 and enter it into the _dl_loaded list. */
34
35struct link_map *
36_dl_new_object (char *realname, const char *libname, int type)
37{
38 struct link_map *new = malloc (sizeof *new);
39 if (! new)
421f82e5
RM
40 _dl_signal_error (ENOMEM, libname,
41 "cannot allocate shared object descriptor");
d66e34cd
RM
42
43 memset (new, 0, sizeof *new);
44 new->l_name = realname;
45 new->l_libname = libname;
46 new->l_type = type;
47
48 if (_dl_loaded == NULL)
49 {
50 new->l_prev = new->l_next = NULL;
51 _dl_loaded = new;
52 }
53 else
54 {
55 struct link_map *l = _dl_loaded;
56 while (l->l_next)
57 l = l->l_next;
58 new->l_prev = l;
59 new->l_next = NULL;
60 l->l_next = new;
61 }
62
63 return new;
64}
This page took 0.033019 seconds and 5 git commands to generate.