mirror of
git://sourceware.org/git/glibc.git
synced 2025-02-17 13:00:43 +08:00
Update.
1998-09-01 17:53 Ulrich Drepper <drepper@cygnus.com> * elf/dl-load.c (add_name_to_object): Change return type to void and make NAME parameter const. Allocate room for NAME in same memory block used for l_libname entry. (_dl_map_object_from_fd): Don't free NAME on failure. (map_segment): Pass SONAME to add_name_to_object, not a copy. (_dl_map_object): Don't create copy of NAME. Pass NAME to _dl_map_object_from_fd. * elf/dl-object.c (dl_new_object): Allocate room for NAME in same memory block used for l_libname entry. * elf/dl-close.c: Adjust free()ing for this change.
This commit is contained in:
parent
a8a1269d88
commit
76156ea152
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
1998-09-01 17:53 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* elf/dl-load.c (add_name_to_object): Change return type to void and
|
||||
make NAME parameter const. Allocate room for NAME in same memory
|
||||
block used for l_libname entry.
|
||||
(_dl_map_object_from_fd): Don't free NAME on failure.
|
||||
(map_segment): Pass SONAME to add_name_to_object, not a copy.
|
||||
(_dl_map_object): Don't create copy of NAME. Pass NAME to
|
||||
_dl_map_object_from_fd.
|
||||
* elf/dl-object.c (dl_new_object): Allocate room for NAME in same
|
||||
memory block used for l_libname entry.
|
||||
* elf/dl-close.c: Adjust free()ing for this change.
|
||||
|
||||
1998-09-01 15:36 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* malloc/Makefile: Include Makeconfig before testing config-sysdirs.
|
||||
|
@ -148,11 +148,11 @@ _dl_close (struct link_map *map)
|
||||
lnp = imap->l_libname;
|
||||
do
|
||||
{
|
||||
free (lnp->name);
|
||||
struct libname_list *this = lnp;
|
||||
lnp = lnp->next;
|
||||
free (this);
|
||||
}
|
||||
while (lnp != NULL);
|
||||
free (imap->l_libname);
|
||||
|
||||
free (imap);
|
||||
}
|
||||
|
@ -240,43 +240,33 @@ expand_dynamic_string_token (struct link_map *l, const char *s)
|
||||
`name' is expected to have been allocated with malloc and will
|
||||
be freed if the shared object already has this name.
|
||||
Returns false if the object already had this name. */
|
||||
static int
|
||||
static void
|
||||
internal_function
|
||||
add_name_to_object (struct link_map *l, char *name)
|
||||
add_name_to_object (struct link_map *l, const char *name)
|
||||
{
|
||||
struct libname_list *lnp, *lastp;
|
||||
struct libname_list *newname;
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
/* No more memory. */
|
||||
_dl_signal_error (ENOMEM, NULL, "could not allocate name string");
|
||||
return 0;
|
||||
}
|
||||
size_t name_len;
|
||||
|
||||
lastp = NULL;
|
||||
for (lnp = l->l_libname; lnp != NULL; lastp = lnp, lnp = lnp->next)
|
||||
if (strcmp (name, lnp->name) == 0)
|
||||
{
|
||||
free (name);
|
||||
return 0;
|
||||
}
|
||||
return;
|
||||
|
||||
newname = malloc (sizeof *newname);
|
||||
name_len = strlen (name) + 1;
|
||||
newname = malloc (sizeof *newname + name_len);
|
||||
if (newname == NULL)
|
||||
{
|
||||
/* No more memory. */
|
||||
_dl_signal_error (ENOMEM, name, "cannot allocate name record");
|
||||
free (name);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
/* The object should have a libname set from _dl_new_object. */
|
||||
assert (lastp != NULL);
|
||||
|
||||
newname->name = name;
|
||||
newname->name = memcpy (newname + 1, name, name_len);
|
||||
newname->next = NULL;
|
||||
lastp->next = newname;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* All known directories in sorted order. */
|
||||
@ -639,8 +629,6 @@ _dl_map_object_from_fd (char *name, int fd, char *realname,
|
||||
}
|
||||
free (realname);
|
||||
_dl_signal_error (code, name, msg);
|
||||
free (name); /* Hmmm. Can this leak memory? Better
|
||||
than a segfault, anyway. */
|
||||
}
|
||||
|
||||
inline caddr_t map_segment (ElfW(Addr) mapstart, size_t len,
|
||||
@ -1175,7 +1163,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
|
||||
continue;
|
||||
|
||||
/* We have a match on a new name -- cache it. */
|
||||
add_name_to_object (l, local_strdup (soname));
|
||||
add_name_to_object (l, soname);
|
||||
}
|
||||
|
||||
/* We have a match -- bump the reference count and return it. */
|
||||
@ -1277,16 +1265,6 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
|
||||
}
|
||||
}
|
||||
|
||||
if (fd != -1)
|
||||
{
|
||||
name_copy = local_strdup (name);
|
||||
if (name_copy == NULL)
|
||||
{
|
||||
__close (fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
if (trace_mode)
|
||||
@ -1316,5 +1294,5 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
|
||||
_dl_signal_error (errno, name, "cannot open shared object file");
|
||||
}
|
||||
|
||||
return _dl_map_object_from_fd (name_copy, fd, realname, loader, type);
|
||||
return _dl_map_object_from_fd (name, fd, realname, loader, type);
|
||||
}
|
||||
|
@ -35,14 +35,14 @@ struct link_map *
|
||||
internal_function
|
||||
_dl_new_object (char *realname, const char *libname, int type, int find_origin)
|
||||
{
|
||||
struct link_map *new = malloc (sizeof *new);
|
||||
struct libname_list *newname = malloc (sizeof *newname);
|
||||
size_t libname_len = strlen (libname) + 1;
|
||||
struct link_map *new = calloc (sizeof *new, 1);
|
||||
struct libname_list *newname = malloc (sizeof *newname + libname_len);
|
||||
if (! new || ! newname)
|
||||
return NULL;
|
||||
|
||||
memset (new, 0, sizeof *new);
|
||||
new->l_name = realname;
|
||||
newname->name = libname;
|
||||
newname->name = memcpy (newname + 1, libname, libname_len);
|
||||
newname->next = NULL;
|
||||
new->l_libname = newname;
|
||||
new->l_type = type;
|
||||
|
Loading…
Reference in New Issue
Block a user