Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
2001-09-04  Ulrich Drepper  <drepper@redhat.com>

	Correct very misleading message for error in failed runtime relocation.
	* elf/dl-error.c (_dl_signal_error): Take extra parameter to describe
	place of the error.
	(_dl_signal_cerror): Likewise.
	* sysdeps/generic/ldsodefs.h: Adjust prototypes.
	* elf/dl-close.c: Likewise.
	* elf/dl-deps.c: Likewise.
	* elf/dl-load.c: Likewise.
	* elf/dl-lookup.c: Likewise.
	* elf/dl-open.c: Likewise.
	* elf/dl-reloc.c: Likewise.
	* elf/dl-sym.c: Likewise.
	* elf/dl-version.c: Likewise.
	* sysdeps/generic/dl-sysdep.c: Likewise.
  • Loading branch information
Ulrich Drepper committed Sep 5, 2001
1 parent 71ce28f commit 407fe3b
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 50 deletions.
17 changes: 17 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2001-09-04 Ulrich Drepper <drepper@redhat.com>

Correct very misleading message for error in failed runtime relocation.
* elf/dl-error.c (_dl_signal_error): Take extra parameter to describe
place of the error.
(_dl_signal_cerror): Likewise.
* sysdeps/generic/ldsodefs.h: Adjust prototypes.
* elf/dl-close.c: Likewise.
* elf/dl-deps.c: Likewise.
* elf/dl-load.c: Likewise.
* elf/dl-lookup.c: Likewise.
* elf/dl-open.c: Likewise.
* elf/dl-reloc.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-version.c: Likewise.
* sysdeps/generic/dl-sysdep.c: Likewise.

2001-09-04 Jakub Jelinek <jakub@redhat.com>

* iconv/strtab.c (strtabinit): Initialize null Strent.
Expand Down
2 changes: 1 addition & 1 deletion elf/dl-close.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _dl_close (void *_map)
return;

if (__builtin_expect (map->l_opencount, 1) == 0)
_dl_signal_error (0, map->l_name, N_("shared object not open"));
_dl_signal_error (0, map->l_name, NULL, N_("shared object not open"));

/* Acquire the lock. */
__libc_lock_lock_recursive (_dl_load_lock);
Expand Down
14 changes: 6 additions & 8 deletions elf/dl-deps.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct list
\
/* DST must not appear in SUID/SGID programs. */ \
if (__libc_enable_secure) \
_dl_signal_error (0, __str, \
_dl_signal_error (0, __str, NULL, \
N_("DST not allowed in SUID/SGID programs")); \
\
__newp = (char *) alloca (DL_DST_REQUIRED (l, __str, strlen (__str), \
Expand All @@ -110,7 +110,7 @@ struct list
/* The replacement for the DST is not known. We can't \
processed. */ \
if (fatal) \
_dl_signal_error (0, __str, N_("\
_dl_signal_error (0, __str, NULL, N_("\
empty dynamics string token substitution")); \
else \
{ \
Expand Down Expand Up @@ -450,7 +450,7 @@ _dl_map_object_deps (struct link_map *map,

l->l_initfini = malloc (nneeded * sizeof needed[0]);
if (l->l_initfini == NULL)
_dl_signal_error (ENOMEM, map->l_name,
_dl_signal_error (ENOMEM, map->l_name, NULL,
N_("cannot allocate dependency list"));
memcpy (l->l_initfini, needed, nneeded * sizeof needed[0]);
}
Expand Down Expand Up @@ -480,7 +480,7 @@ _dl_map_object_deps (struct link_map *map,
(struct link_map **) malloc ((2 * nlist + 1)
* sizeof (struct link_map *));
if (map->l_initfini == NULL)
_dl_signal_error (ENOMEM, map->l_name,
_dl_signal_error (ENOMEM, map->l_name, NULL,
N_("cannot allocate symbol search list"));


Expand Down Expand Up @@ -527,7 +527,7 @@ _dl_map_object_deps (struct link_map *map,
if (runp != NULL)
{
while (*runp != NULL)
if (*runp == l)
if (__builtin_expect (*runp++ == l, 0))
{
struct link_map *here = map->l_initfini[k];

Expand All @@ -539,8 +539,6 @@ _dl_map_object_deps (struct link_map *map,

break;
}
else
++runp;
}
}
}
Expand All @@ -549,5 +547,5 @@ _dl_map_object_deps (struct link_map *map,

if (errno_reason)
_dl_signal_error (errno_reason == -1 ? 0 : errno_reason,
objname, errstring);
objname, NULL, errstring);
}
12 changes: 6 additions & 6 deletions elf/dl-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ static receiver_fct receiver;

void
internal_function
_dl_signal_error (int errcode, const char *objname, const char *errstring)
_dl_signal_error (int errcode, const char *objname, const char *occation,
const char *errstring)
{
struct catch *lcatch;

Expand Down Expand Up @@ -99,9 +100,9 @@ _dl_signal_error (int errcode, const char *objname, const char *errstring)
{
/* Lossage while resolving the program's own symbols is always fatal. */
char buffer[1024];
_dl_fatal_printf ("\
%s: error while loading shared libraries: %s%s%s%s%s\n",
_dl_fatal_printf ("%s: %s: %s%s%s%s%s\n",
_dl_argv[0] ?: "<program name unknown>",
occation ?: N_("error while loading shared libraries"),
objname, *objname ? ": " : "",
errstring, errcode ? ": " : "",
(errcode
Expand All @@ -113,8 +114,7 @@ _dl_signal_error (int errcode, const char *objname, const char *errstring)

void
internal_function
_dl_signal_cerror (int errcode,
const char *objname,
_dl_signal_cerror (int errcode, const char *objname, const char *occation,
const char *errstring)
{
if (receiver)
Expand All @@ -125,7 +125,7 @@ _dl_signal_cerror (int errcode,
(*receiver) (errcode, objname, errstring);
}
else
_dl_signal_error (errcode, objname, errstring);
_dl_signal_error (errcode, objname, occation, errstring);
}


Expand Down
33 changes: 20 additions & 13 deletions elf/dl-load.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ add_name_to_object (struct link_map *l, const char *name)
if (newname == NULL)
{
/* No more memory. */
_dl_signal_error (ENOMEM, name, N_("cannot allocate name record"));
_dl_signal_error (ENOMEM, name, NULL, N_("cannot allocate name record"));
return;
}
/* The object should have a libname set from _dl_new_object. */
Expand Down Expand Up @@ -452,7 +452,7 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
malloc (sizeof (*dirp) + ncapstr * sizeof (enum r_dir_status)
+ where_len + len + 1);
if (dirp == NULL)
_dl_signal_error (ENOMEM, NULL,
_dl_signal_error (ENOMEM, NULL, NULL,
N_("cannot create cache for search path"));

dirp->dirname = ((char *) dirp + sizeof (*dirp)
Expand Down Expand Up @@ -521,7 +521,7 @@ decompose_rpath (struct r_search_path_struct *sps,
result = (struct r_search_path_elem **)
malloc (sizeof (*result));
if (result == NULL)
_dl_signal_error (ENOMEM, NULL,
_dl_signal_error (ENOMEM, NULL, NULL,
N_("cannot create cache for search path"));
result[0] = NULL;

Expand All @@ -537,7 +537,8 @@ decompose_rpath (struct r_search_path_struct *sps,
string tokens. */
copy = expand_dynamic_string_token (l, rpath);
if (copy == NULL)
_dl_signal_error (ENOMEM, NULL, N_("cannot create RUNPATH/RPATH copy"));
_dl_signal_error (ENOMEM, NULL, NULL,
N_("cannot create RUNPATH/RPATH copy"));

/* Count the number of necessary elements in the result array. */
nelems = 0;
Expand All @@ -550,7 +551,8 @@ decompose_rpath (struct r_search_path_struct *sps,
result = (struct r_search_path_elem **) malloc ((nelems + 1 + 1)
* sizeof (*result));
if (result == NULL)
_dl_signal_error (ENOMEM, NULL, N_("cannot create cache for search path"));
_dl_signal_error (ENOMEM, NULL, NULL,
N_("cannot create cache for search path"));

fillin_rpath (copy, result, ":", 0, what, where);

Expand Down Expand Up @@ -587,7 +589,8 @@ _dl_init_paths (const char *llp)
aelem = rtld_search_dirs.dirs = (struct r_search_path_elem **)
malloc ((nsystem_dirs_len + 1) * sizeof (struct r_search_path_elem *));
if (rtld_search_dirs.dirs == NULL)
_dl_signal_error (ENOMEM, NULL, N_("cannot create search path array"));
_dl_signal_error (ENOMEM, NULL, NULL,
N_("cannot create search path array"));

round_size = ((2 * sizeof (struct r_search_path_elem) - 1
+ ncapstr * sizeof (enum r_dir_status))
Expand All @@ -597,7 +600,8 @@ _dl_init_paths (const char *llp)
malloc ((sizeof (system_dirs) / sizeof (system_dirs[0]))
* round_size * sizeof (struct r_search_path_elem));
if (rtld_search_dirs.dirs[0] == NULL)
_dl_signal_error (ENOMEM, NULL, N_("cannot create cache for search path"));
_dl_signal_error (ENOMEM, NULL, NULL,
N_("cannot create cache for search path"));

rtld_search_dirs.malloced = 0;
pelem = _dl_all_dirs = rtld_search_dirs.dirs[0];
Expand Down Expand Up @@ -689,7 +693,7 @@ _dl_init_paths (const char *llp)
env_path_list.dirs = (struct r_search_path_elem **)
malloc ((nllp + 1) * sizeof (struct r_search_path_elem *));
if (env_path_list.dirs == NULL)
_dl_signal_error (ENOMEM, NULL,
_dl_signal_error (ENOMEM, NULL, NULL,
N_("cannot create cache for search path"));

(void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;",
Expand Down Expand Up @@ -741,7 +745,7 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l,
free (l);
}
free (realname);
_dl_signal_error (code, name, msg);
_dl_signal_error (code, name, NULL, msg);
}


Expand Down Expand Up @@ -819,7 +823,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
if (_dl_zerofd == -1)
{
__close (fd);
_dl_signal_error (errno, NULL, N_("cannot open zero fill device"));
_dl_signal_error (errno, NULL, NULL,
N_("cannot open zero fill device"));
}
}
#endif
Expand Down Expand Up @@ -1101,7 +1106,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,

free (l);

_dl_signal_error (0, name, N_("shared object cannot be dlopen()ed"));
_dl_signal_error (0, name, NULL,
N_("shared object cannot be dlopen()ed"));
}

if (l->l_info[DT_HASH])
Expand Down Expand Up @@ -1720,7 +1726,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
/* Enter the new object in the list of loaded objects. */
if ((name_copy = local_strdup (name)) == NULL
|| (l = _dl_new_object (name_copy, name, type, loader)) == NULL)
_dl_signal_error (ENOMEM, name,
_dl_signal_error (ENOMEM, name, NULL,
N_("cannot create shared object descriptor"));
/* Signal that this is a faked entry. */
l->l_faked = 1;
Expand All @@ -1734,7 +1740,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
return l;
}
else
_dl_signal_error (errno, name, N_("cannot open shared object file"));
_dl_signal_error (errno, name, NULL,
N_("cannot open shared object file"));
}

return _dl_map_object_from_fd (name, fd, &fb, realname, loader, type, mode);
Expand Down
8 changes: 6 additions & 2 deletions elf/dl-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
02111-1307 USA. */

#include <alloca.h>
#include <libintl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Expand Down Expand Up @@ -236,6 +237,7 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map,
_dl_signal_cerror (0, (reference_name && reference_name[0]
? reference_name
: (_dl_argv[0] ?: "<main program>")),
N_("relocation error"),
make_string (undefined_msg, undef_name));
*ref = NULL;
return 0;
Expand Down Expand Up @@ -419,6 +421,7 @@ _dl_lookup_versioned_symbol (const char *undef_name,
_dl_signal_cerror (0, (reference_name && reference_name[0]
? reference_name
: (_dl_argv[0] ?: "<main program>")),
N_("relocation error"),
make_string ("symbol ", undef_name, ", version ",
version->name,
" not defined in file ",
Expand All @@ -441,7 +444,7 @@ _dl_lookup_versioned_symbol (const char *undef_name,
/* XXX We cannot translate the message. */
_dl_signal_cerror (0, (reference_name && reference_name[0]
? reference_name
: (_dl_argv[0] ?: "<main program>")),
: (_dl_argv[0] ?: "<main program>")), NULL,
make_string (undefined_msg, undef_name,
", version ",
version->name ?: NULL));
Expand Down Expand Up @@ -537,7 +540,8 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
/* XXX We cannot translate the messages. */
_dl_signal_cerror (0, (reference_name && reference_name[0]
? reference_name
: (_dl_argv[0] ?: "<main program>")), buf);
: (_dl_argv[0] ?: "<main program>")),
NULL, buf);
}
*ref = NULL;
return 0;
Expand Down
10 changes: 5 additions & 5 deletions elf/dl-open.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ add_to_global (struct link_map *new)
{
_dl_global_scope_alloc = 0;
nomem:
_dl_signal_error (ENOMEM, new->l_libname->name,
_dl_signal_error (ENOMEM, new->l_libname->name, NULL,
N_("cannot extend global scope"));
return 1;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ dl_open_worker (void *a)
/* DSTs must not appear in SUID/SGID programs. */
if (__libc_enable_secure)
/* This is an error. */
_dl_signal_error (0, "dlopen",
_dl_signal_error (0, "dlopen", NULL,
N_("DST not allowed in SUID/SGID programs"));

/* We have to find out from which object the caller is calling. */
Expand Down Expand Up @@ -206,7 +206,7 @@ dl_open_worker (void *a)

/* If the substitution failed don't try to load. */
if (*new_file == '\0')
_dl_signal_error (0, "dlopen",
_dl_signal_error (0, "dlopen", NULL,
N_("empty dynamic string token substitution"));

/* Now we have a new file name. */
Expand Down Expand Up @@ -337,7 +337,7 @@ _dl_open (const char *file, int mode, const void *caller)

if ((mode & RTLD_BINDING_MASK) == 0)
/* One of the flags must be set. */
_dl_signal_error (EINVAL, file, N_("invalid mode for dlopen()"));
_dl_signal_error (EINVAL, file, NULL, N_("invalid mode for dlopen()"));

/* Make sure we are alone. */
__libc_lock_lock_recursive (_dl_load_lock);
Expand Down Expand Up @@ -396,7 +396,7 @@ _dl_open (const char *file, int mode, const void *caller)
free ((char *) errstring);

/* Reraise the error. */
_dl_signal_error (errcode, objname, local_errstring);
_dl_signal_error (errcode, objname, NULL, local_errstring);
}

#ifndef SHARED
Expand Down
8 changes: 4 additions & 4 deletions elf/dl-reloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
& ~(_dl_pagesize - 1)));
if (__builtin_expect (__mprotect (mapstart, mapend - mapstart,
PROT_READ|PROT_WRITE), 0) < 0)
_dl_signal_error (errno, l->l_name, N_("\
_dl_signal_error (errno, l->l_name, NULL, N_("\
cannot make segment writable for relocation"));
}
}
Expand Down Expand Up @@ -177,7 +177,7 @@ cannot make segment writable for relocation"));

if (__builtin_expect (__mprotect (mapstart, mapend - mapstart,
prot), 0) < 0)
_dl_signal_error (errno, l->l_name,
_dl_signal_error (errno, l->l_name, NULL,
N_("can't restore segment prot after reloc"));

#ifdef CLEAR_CACHE
Expand All @@ -201,14 +201,14 @@ _dl_reloc_bad_type (struct link_map *map, uint_fast8_t type, int plt)
static char msg[] = "unexpected PLT reloc type 0x??";
msg[sizeof msg - 3] = DIGIT(type >> 4);
msg[sizeof msg - 2] = DIGIT(type);
_dl_signal_error (0, map->l_name, msg);
_dl_signal_error (0, map->l_name, NULL, msg);
}
else
{
/* XXX We cannot translate the message. */
static char msg[] = "unexpected reloc type 0x??";
msg[sizeof msg - 3] = DIGIT(type >> 4);
msg[sizeof msg - 2] = DIGIT(type);
_dl_signal_error (0, map->l_name, msg);
_dl_signal_error (0, map->l_name, NULL, msg);
}
}
Loading

0 comments on commit 407fe3b

Please sign in to comment.