diff options
| author | Ulrich Drepper <drepper@redhat.com> | 2000-06-10 04:01:36 +0000 |
|---|---|---|
| committer | Ulrich Drepper <drepper@redhat.com> | 2000-06-10 04:01:36 +0000 |
| commit | 8e17ea58173d35e2e5dabfeb9fa5abf2609cfc51 (patch) | |
| tree | de81e2ebf2b5b32510d511caa07c2496e3d540ba | |
| parent | f3863621f617b040c66d635109203c29f35f7331 (diff) | |
| download | glibc-8e17ea58173d35e2e5dabfeb9fa5abf2609cfc51.tar.xz glibc-8e17ea58173d35e2e5dabfeb9fa5abf2609cfc51.zip | |
Update.
2000-06-09 Ulrich Drepper <drepper@redhat.com>
Rewrite error message handling.
* elf/dl-deps.c (_dl_map_object_deps): Pass new parameter to
_dl_catch_error.
* elf/dl-error (struct catch): Add objname member.
(_dl_signal_error): Take new parameter with object name. When
passing message on simply store object name and duplicate error
message.
(_dl_catch_error): Take new parameter. Store object name in the
place pointed to.
* include/dlfcn.h: Adjust _dl_catch_error prototype.
* sysdeps/generic/ldsodefs.h: Adjust _dl_signal_error prototype.
* elf/dl-libc.c (dlerror_run): Pass new parameter to _dl_catch_error.
* elf/dl-open.c (_dl_open): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/dl-close.c: Mark error messages with N_().
* elf/dl-deps.c: Likewise.
* elf/dl-error.c: Likewise.
* elf/dl-load.c: Likewise.
* elf/dl-open.c: Likewise.
* elf/dl-reloc.c: Likewise.
* elf/dl-support.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-version.c: Likewise.
* elf/dl-lookup.c: Add comments about problems with error message
translations.
* elf/dl-reloc.c: Likewise.
* elf/dl-version.c: Likewise.
| -rw-r--r-- | ChangeLog | 30 | ||||
| -rw-r--r-- | elf/dl-close.c | 5 | ||||
| -rw-r--r-- | elf/dl-deps.c | 18 | ||||
| -rw-r--r-- | elf/dl-error.c | 34 | ||||
| -rw-r--r-- | elf/dl-libc.c | 9 | ||||
| -rw-r--r-- | elf/dl-load.c | 80 | ||||
| -rw-r--r-- | elf/dl-lookup.c | 4 | ||||
| -rw-r--r-- | elf/dl-open.c | 17 | ||||
| -rw-r--r-- | elf/dl-reloc.c | 13 | ||||
| -rw-r--r-- | elf/dl-support.c | 3 | ||||
| -rw-r--r-- | elf/dl-sym.c | 4 | ||||
| -rw-r--r-- | elf/dl-version.c | 8 | ||||
| -rw-r--r-- | elf/rtld.c | 9 | ||||
| -rw-r--r-- | include/dlfcn.h | 7 | ||||
| -rw-r--r-- | sysdeps/generic/ldsodefs.h | 3 |
15 files changed, 146 insertions, 98 deletions
@@ -1,3 +1,33 @@ +2000-06-09 Ulrich Drepper <drepper@redhat.com> + + Rewrite error message handling. + * elf/dl-deps.c (_dl_map_object_deps): Pass new parameter to + _dl_catch_error. + * elf/dl-error (struct catch): Add objname member. + (_dl_signal_error): Take new parameter with object name. When + passing message on simply store object name and duplicate error + message. + (_dl_catch_error): Take new parameter. Store object name in the + place pointed to. + * include/dlfcn.h: Adjust _dl_catch_error prototype. + * sysdeps/generic/ldsodefs.h: Adjust _dl_signal_error prototype. + * elf/dl-libc.c (dlerror_run): Pass new parameter to _dl_catch_error. + * elf/dl-open.c (_dl_open): Likewise. + * elf/rtld.c (dl_main): Likewise. + * elf/dl-close.c: Mark error messages with N_(). + * elf/dl-deps.c: Likewise. + * elf/dl-error.c: Likewise. + * elf/dl-load.c: Likewise. + * elf/dl-open.c: Likewise. + * elf/dl-reloc.c: Likewise. + * elf/dl-support.c: Likewise. + * elf/dl-sym.c: Likewise. + * elf/dl-version.c: Likewise. + * elf/dl-lookup.c: Add comments about problems with error message + translations. + * elf/dl-reloc.c: Likewise. + * elf/dl-version.c: Likewise. + 2000-06-09 David Mosberger-Tang <davidm@hpl.hp.com> * sysdeps/unix/sysv/linux/ia64/__longjmp.S: new file diff --git a/elf/dl-close.c b/elf/dl-close.c index d6f00008b1..ec563ed8d0 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -19,6 +19,7 @@ #include <assert.h> #include <dlfcn.h> +#include <libintl.h> #include <stdlib.h> #include <string.h> #include <bits/libc-lock.h> @@ -36,8 +37,6 @@ typedef void (*fini_t) (void); protect `dlopen' and `dlclose' in dlclose.c. */ __libc_lock_define (extern, _dl_load_lock) -#define LOSE(s) _dl_signal_error (0, map->l_name, s) - void internal_function _dl_close (void *_map) @@ -50,7 +49,7 @@ _dl_close (void *_map) unsigned int i; if (map->l_opencount == 0) - LOSE ("shared object not open"); + _dl_signal_error (0, map->l_name, N_("shared object not open")); /* Acquire the lock. */ __libc_lock_lock (_dl_load_lock); diff --git a/elf/dl-deps.c b/elf/dl-deps.c index 670b9df8d4..7c7b4b6672 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -20,6 +20,7 @@ #include <assert.h> #include <dlfcn.h> #include <errno.h> +#include <libintl.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -102,7 +103,7 @@ struct list /* DST must not appear in SUID/SGID programs. */ \ if (__libc_enable_secure) \ _dl_signal_error (0, __str, \ - "DST not allowed in SUID/SGID programs"); \ + N_("DST not allowed in SUID/SGID programs")); \ \ __newp = (char *) alloca (DL_DST_REQUIRED (l, __str, strlen (__str), \ __cnt)); \ @@ -114,8 +115,8 @@ struct list /* The replacement for the DST is not known. We can't \ processed. */ \ if (fatal) \ - _dl_signal_error (0, __str, \ - "empty dynamics string token substitution"); \ + _dl_signal_error (0, __str, N_("\ +empty dynamics string token substitution")); \ else \ { \ /* This is for DT_AUXILIARY. */ \ @@ -265,7 +266,8 @@ _dl_map_object_deps (struct link_map *map, } else if (d->d_tag == DT_AUXILIARY || d->d_tag == DT_FILTER) { - char *errstring; + const char *objname; + const char *errstring; struct list *newp; /* Object name. */ const char *name; @@ -289,11 +291,11 @@ _dl_map_object_deps (struct link_map *map, /* We must be prepared that the addressed shared object is not available. */ - if (_dl_catch_error (&errstring, openaux, &args)) + if (_dl_catch_error (&objname, &errstring, openaux, &args)) { /* We are not interested in the error message. */ assert (errstring != NULL); - free (errstring); + free ((char *) errstring); /* Simply ignore this error and continue the work. */ continue; @@ -452,7 +454,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, - "cannot allocate dependency list"); + N_("cannot allocate dependency list")); memcpy (l->l_initfini, needed, nneeded * sizeof needed[0]); } @@ -470,7 +472,7 @@ _dl_map_object_deps (struct link_map *map, * sizeof (struct link_map *)); if (map->l_searchlist.r_list == NULL) _dl_signal_error (ENOMEM, map->l_name, - "cannot allocate symbol search list"); + N_("cannot allocate symbol search list")); map->l_searchlist.r_nlist = nlist; for (nlist = 0, runp = known; runp; runp = runp->unique) diff --git a/elf/dl-error.c b/elf/dl-error.c index fbf5fce04f..88ab8e9519 100644 --- a/elf/dl-error.c +++ b/elf/dl-error.c @@ -17,6 +17,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <libintl.h> #include <setjmp.h> #include <stdlib.h> #include <string.h> @@ -28,7 +29,8 @@ _dl_signal_error. */ struct catch { - char *errstring; /* Error detail filled in here. */ + const char *objname; /* Object/File name. */ + const char *errstring; /* Error detail filled in here. */ jmp_buf env; /* longjmp here on error. */ }; @@ -55,34 +57,21 @@ 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 *errstring) { struct catch *lcatch; if (! errstring) - errstring = "DYNAMIC LINKER BUG!!!"; + errstring = N_("DYNAMIC LINKER BUG!!!"); lcatch = tsd_getspecific (); if (lcatch != NULL) { /* We are inside _dl_catch_error. Return to it. We have to duplicate the error string since it might be allocated on the - stack. */ - size_t objname_len = objname ? strlen (objname) + 2 : 0; - size_t errstring_len = strlen (errstring) + 1; - lcatch->errstring = malloc (objname_len + errstring_len); - if (lcatch->errstring != NULL) - { - char *cp = lcatch->errstring; - if (objname_len > 0) - { - cp = __mempcpy (cp, objname, objname_len - 2); - cp = __mempcpy (cp, ": ", 2); - } - memcpy (cp, errstring, errstring_len); - } + stack. The object name is always a string constant. */ + lcatch->objname = objname; + lcatch->errstring = strdup (errstring); longjmp (lcatch->env, errcode ?: -1); } else @@ -120,9 +109,8 @@ _dl_signal_cerror (int errcode, int internal_function -_dl_catch_error (char **errstring, - void (*operate) (void *), - void *args) +_dl_catch_error (const char **objname, const char **errstring, + void (*operate) (void *), void *args) { int errcode; struct catch *volatile old; @@ -141,12 +129,14 @@ _dl_catch_error (char **errstring, tsd_setspecific (&c); (*operate) (args); tsd_setspecific (old); + *objname = NULL; *errstring = NULL; return 0; } /* We get here only if we longjmp'd out of OPERATE. */ tsd_setspecific (old); + *objname = c.objname; *errstring = c.errstring; return errcode == -1 ? 0 : errcode; } diff --git a/elf/dl-libc.c b/elf/dl-libc.c index c95935ff75..38774e50a0 100644 --- a/elf/dl-libc.c +++ b/elf/dl-libc.c @@ -1,5 +1,5 @@ /* Handle loading and unloading shared objects for internal libc purposes. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.columbia.edu>, 1999. @@ -35,14 +35,15 @@ static int internal_function dlerror_run (void (*operate) (void *), void *args) { - char *last_errstring = NULL; + const char *objname; + const char *last_errstring = NULL; int result; - (void) _dl_catch_error (&last_errstring, operate, args); + (void) _dl_catch_error (&objname, &last_errstring, operate, args); result = last_errstring != NULL; if (result) - free (last_errstring); + free ((char *) last_errstring); return result; } diff --git a/elf/dl-load.c b/elf/dl-load.c index 17ce562ddd..2c506b55c1 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -20,6 +20,7 @@ #include <elf.h> #include <errno.h> #include <fcntl.h> +#include <libintl.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -62,10 +63,8 @@ #include <endian.h> #if BYTE_ORDER == BIG_ENDIAN # define byteorder ELFDATA2MSB -# define byteorder_name "big-endian" #elif BYTE_ORDER == LITTLE_ENDIAN # define byteorder ELFDATA2LSB -# define byteorder_name "little-endian" #else # error "Unknown BYTE_ORDER " BYTE_ORDER # define byteorder ELFDATANONE @@ -315,7 +314,7 @@ add_name_to_object (struct link_map *l, const char *name) if (newname == NULL) { /* No more memory. */ - _dl_signal_error (ENOMEM, name, "cannot allocate name record"); + _dl_signal_error (ENOMEM, name, N_("cannot allocate name record")); return; } /* The object should have a libname set from _dl_new_object. */ @@ -414,7 +413,7 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep, malloc (sizeof (*dirp) + ncapstr * sizeof (enum r_dir_status)); if (dirp == NULL) _dl_signal_error (ENOMEM, NULL, - "cannot create cache for search path"); + N_("cannot create cache for search path")); dirp->dirname = cp; dirp->dirnamelen = len; @@ -475,7 +474,7 @@ decompose_rpath (const char *rpath, struct link_map *l, const char *what) malloc (sizeof (*result)); if (result == NULL) _dl_signal_error (ENOMEM, NULL, - "cannot create cache for search path"); + N_("cannot create cache for search path")); result[0] = NULL; return result; @@ -487,7 +486,7 @@ decompose_rpath (const char *rpath, struct link_map *l, const char *what) string tokens. */ copy = expand_dynamic_string_token (l, rpath); if (copy == NULL) - _dl_signal_error (ENOMEM, NULL, "cannot create RUNPATH/RPATH copy"); + _dl_signal_error (ENOMEM, NULL, N_("cannot create RUNPATH/RPATH copy")); /* Count the number of necessary elements in the result array. */ nelems = 0; @@ -500,7 +499,7 @@ decompose_rpath (const char *rpath, struct link_map *l, const char *what) result = (struct r_search_path_elem **) malloc ((nelems + 1 + 1) * sizeof (*result)); if (result == NULL) - _dl_signal_error (ENOMEM, NULL, "cannot create cache for search path"); + _dl_signal_error (ENOMEM, NULL, N_("cannot create cache for search path")); return fillin_rpath (copy, result, ":", 0, what, where); } @@ -530,7 +529,7 @@ _dl_init_paths (const char *llp) malloc ((sizeof (system_dirs_len) / sizeof (system_dirs_len[0]) + 1) * sizeof (struct r_search_path_elem *)); if (rtld_search_dirs == NULL) - _dl_signal_error (ENOMEM, NULL, "cannot create search path array"); + _dl_signal_error (ENOMEM, NULL, N_("cannot create search path array")); round_size = ((2 * sizeof (struct r_search_path_elem) - 1 + ncapstr * sizeof (enum r_dir_status)) @@ -540,7 +539,7 @@ _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[0] == NULL) - _dl_signal_error (ENOMEM, NULL, "cannot create cache for search path"); + _dl_signal_error (ENOMEM, NULL, N_("cannot create cache for search path")); pelem = all_dirs = rtld_search_dirs[0]; strp = system_dirs; @@ -632,7 +631,7 @@ _dl_init_paths (const char *llp) malloc ((nllp + 1) * sizeof (struct r_search_path_elem *)); if (env_path_list == NULL) _dl_signal_error (ENOMEM, NULL, - "cannot create cache for search path"); + N_("cannot create cache for search path")); (void) fillin_rpath (local_strdup (llp), env_path_list, ":;", __libc_enable_secure, "LD_LIBRARY_PATH", NULL); @@ -720,7 +719,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, fixed|MAP_COPY|MAP_FILE, fd, offset); if (mapat == MAP_FAILED) - LOSE (errno, "failed to map segment from shared object"); + LOSE (errno, N_("failed to map segment from shared object")); return mapat; } @@ -735,7 +734,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, /* Get file information. */ if (__fxstat (_STAT_VER, fd, &st) < 0) - LOSE (errno, "cannot stat shared object"); + LOSE (errno, N_("cannot stat shared object")); /* Look again to see if the real name matched another already loaded. */ for (l = _dl_loaded; l; l = l->l_next) @@ -761,7 +760,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, readbuf = alloca (_dl_pagesize); readlength = __libc_read (fd, readbuf, _dl_pagesize); if (readlength < (ssize_t) sizeof (*header)) - LOSE (errno, "cannot read file data"); + LOSE (errno, N_("cannot read file data")); header = (void *) readbuf; /* Check the header for basic validity. */ @@ -782,29 +781,39 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, (ELFMAG3 << (EI_MAG0 * 8))) #endif ) - LOSE (0, "invalid ELF header"); + LOSE (0, N_("invalid ELF header")); if (header->e_ident[EI_CLASS] != ELFW(CLASS)) - LOSE (0, "ELF file class not " STRING(__ELF_NATIVE_CLASS) "-bit"); + { + if (__ELF_NATIVE_CLASS == 32) + LOSE (0, N_("ELF file class not 32-bit")); + else + LOSE (0, N_("ELF file class not 64-bit")); + } if (header->e_ident[EI_DATA] != byteorder) - LOSE (0, "ELF file data encoding not " byteorder_name); + { + if (BYTE_ORDER == BIG_ENDIAN) + LOSE (0, "ELF file data encoding not big-endian"); + else + LOSE (0, "ELF file data encoding not little-endian"); + } if (header->e_ident[EI_VERSION] != EV_CURRENT) - LOSE (0, "ELF file version ident not " STRING(EV_CURRENT)); + LOSE (0, N_("ELF file version ident does not match current one")); /* XXX We should be able so set system specific versions which are allowed here. */ if (!VALID_ELF_OSABI (header->e_ident[EI_OSABI])) - LOSE (0, "ELF file OS ABI invalid."); + LOSE (0, N_("ELF file OS ABI invalid.")); if (!VALID_ELF_ABIVERSION (header->e_ident[EI_ABIVERSION])) - LOSE (0, "ELF file ABI version invalid."); - LOSE (0, "internal error"); + LOSE (0, N_("ELF file ABI version invalid.")); + LOSE (0, N_("internal error")); } if (__builtin_expect (header->e_version, EV_CURRENT) != EV_CURRENT) - LOSE (0, "ELF file version not " STRING(EV_CURRENT)); + LOSE (0, N_("ELF file version does not not match current one")); if (! __builtin_expect (elf_machine_matches_host (header->e_machine), 1)) - LOSE (0, "ELF file machine architecture not " ELF_MACHINE_NAME); + LOSE (0, N_("ELF file machine architecture does not match")); if (__builtin_expect (header->e_phentsize, sizeof (ElfW(Phdr))) != sizeof (ElfW(Phdr))) - LOSE (0, "ELF file's phentsize not the expected size"); + LOSE (0, N_("ELF file's phentsize not the expected size")); #ifndef MAP_ANON # define MAP_ANON 0 @@ -814,7 +823,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, if (_dl_zerofd == -1) { __close (fd); - _dl_signal_error (errno, NULL, "cannot open zero fill device"); + _dl_signal_error (errno, NULL, N_("cannot open zero fill device")); } } #endif @@ -822,7 +831,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, /* Enter the new object in the list of loaded objects. */ l = _dl_new_object (realname, name, l_type, loader); if (__builtin_expect (! l, 0)) - LOSE (ENOMEM, "cannot create shared object descriptor"); + LOSE (ENOMEM, N_("cannot create shared object descriptor")); l->l_opencount = 1; /* Extract the remaining details we need from the ELF header @@ -839,7 +848,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, phdr = alloca (maplength); __lseek (fd, SEEK_SET, header->e_phoff); if (__libc_read (fd, (void *) phdr, maplength) != maplength) - LOSE (errno, "cannot read file data"); + LOSE (errno, N_("cannot read file data")); } { @@ -874,9 +883,10 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, /* A load command tells us to map in part of the file. We record the load commands and process them all later. */ if (ph->p_align % _dl_pagesize != 0) - LOSE (0, "ELF load command alignment not page-aligned"); + LOSE (0, N_("ELF load command alignment not page-aligned")); if ((ph->p_vaddr - ph->p_offset) % ph->p_align) - LOSE (0, "ELF load command address/offset not properly aligned"); + LOSE (0, + N_("ELF load command address/offset not properly aligned")); { struct loadcmd *c = &loadcmds[nloadcmds++]; c->mapstart = ph->p_vaddr & ~(ph->p_align - 1); @@ -993,7 +1003,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, /* Dag nab it. */ if (__mprotect ((caddr_t) (zero & ~(_dl_pagesize - 1)), _dl_pagesize, c->prot|PROT_WRITE) < 0) - LOSE (errno, "cannot change memory protections"); + LOSE (errno, N_("cannot change memory protections")); } memset ((void *) zero, 0, zeropage - zero); if ((c->prot & PROT_WRITE) == 0) @@ -1009,7 +1019,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, c->prot, MAP_ANON|MAP_PRIVATE|MAP_FIXED, ANONFD, 0); if (mapat == MAP_FAILED) - LOSE (errno, "cannot map zero-fill pages"); + LOSE (errno, N_("cannot map zero-fill pages")); } } @@ -1024,7 +1034,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, ElfW(Phdr) *newp = (ElfW(Phdr) *) malloc (header->e_phnum * sizeof (ElfW(Phdr))); if (newp == NULL) - LOSE (ENOMEM, "cannot allocate memory for program header"); + LOSE (ENOMEM, N_("cannot allocate memory for program header")); l->l_phdr = memcpy (newp, phdr, (header->e_phnum * sizeof (ElfW(Phdr)))); @@ -1044,7 +1054,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, if (l->l_ld == 0) { if (type == ET_DYN) - LOSE (0, "object file has no dynamic section"); + LOSE (0, N_("object file has no dynamic section")); } else (ElfW(Addr)) l->l_ld += l->l_addr; @@ -1099,7 +1109,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, (struct link_map **) malloc (sizeof (struct link_map *)); if (l->l_symbolic_searchlist.r_list == NULL) - LOSE (ENOMEM, "cannot create searchlist"); + LOSE (ENOMEM, N_("cannot create searchlist")); l->l_symbolic_searchlist.r_list[0] = l; l->l_symbolic_searchlist.r_nlist = 1; @@ -1475,7 +1485,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, if ((name_copy = local_strdup (name)) == NULL || (l = _dl_new_object (name_copy, name, type, loader)) == NULL) _dl_signal_error (ENOMEM, name, - "cannot create shared object descriptor"); + N_("cannot create shared object descriptor")); /* We use an opencount of 0 as a sign for the faked entry. Since the descriptor is initialized with zero we do not have do this here. @@ -1488,7 +1498,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, return l; } else - _dl_signal_error (errno, name, "cannot open shared object file"); + _dl_signal_error (errno, name, N_("cannot open shared object file")); } return _dl_map_object_from_fd (name, fd, realname, loader, type); diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index d01fdaa648.. |
