From 143e2b96c94c3fd5a2c618db0bad094ce659e743 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 2 Sep 1998 12:58:42 +0000 Subject: Update. 1998-09-02 Ulrich Drepper * elf/dl-load.c (fillin_rpath): Handle "/" as RPATH correctly. (_dl_map_object_from_fd): Make NAME argument const. Remove last parameter in _dl_new_object call. (print_search_path): Correct construction of composed path name. (_dl_map_object): Prevent looking at RPATH of the main map twice. Remove last parameter in _dl_new_object call. * elf/dl-object.c: Remove last parameter. Determine whether create origin entry based on empty realname. Handle file in root directory correctly. * elf/ldsodefs.h: Adjust prototype for _dl_new_object. * elf/rtld.c (dl_main): Add comment describing reason for memory leak. Remove last parameter in _dl_new_object call. * sysdeps/generic/dl-origin.h: Handle file in root directory correctly. * sysdeps/unix/sysv/linux/dl-origin.h: Likewise. --- elf/dl-object.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'elf/dl-object.c') diff --git a/elf/dl-object.c b/elf/dl-object.c index 97edd8189c..db6e81c11e 100644 --- a/elf/dl-object.c +++ b/elf/dl-object.c @@ -33,7 +33,7 @@ struct link_map *_dl_default_scope[5]; struct link_map * internal_function -_dl_new_object (char *realname, const char *libname, int type, int find_origin) +_dl_new_object (char *realname, const char *libname, int type) { size_t libname_len = strlen (libname) + 1; struct link_map *new = calloc (sizeof *new, 1); @@ -63,7 +63,7 @@ _dl_new_object (char *realname, const char *libname, int type, int find_origin) } /* Don't try to find the origin for the main map. */ - if (! find_origin) + if (realname[0] == '\0') new->l_origin = NULL; else { @@ -117,9 +117,16 @@ _dl_new_object (char *realname, const char *libname, int type, int find_origin) } if (origin != (char *) -1) - /* Now remove the filename and the slash. Do this even if the - string is something like "/foo" which leaves an empty string. */ - *strrchr (origin, '/') = '\0'; + { + /* Now remove the filename and the slash. Do this even if the + string is something like "/foo" which leaves an empty string. */ + char *last = strrchr (origin, '/'); + + if (last == origin) + origin[1] = '\0'; + else + *last = '\0'; + } new->l_origin = origin; } -- cgit v1.2.3