]> sourceware.org Git - glibc.git/blob - elf/dl-object.c
ca4e785be308a8e0043c6a7187381808e5390df2
[glibc.git] / elf / dl-object.c
1 /* Storage management for the chain of loaded shared objects.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, 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. */
27 struct link_map *_dl_loaded;
28
29 /* Tail of that list which were loaded at startup. */
30 struct 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
35 struct 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)
40 _dl_signal_error (ENOMEM, libname,
41 "cannot allocate shared object descriptor");
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.037313 seconds and 5 git commands to generate.