diff options
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-load.c | 22 | ||||
-rw-r--r-- | elf/dl-lookup.c | 4 | ||||
-rw-r--r-- | elf/dl-minimal.c | 43 | ||||
-rw-r--r-- | elf/rtld.c | 20 |
4 files changed, 66 insertions, 23 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c index cc94d7b510..c93446a737 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -123,11 +123,11 @@ add_name_to_object (struct link_map *l, char *name) struct libname_list *newname; if (name == NULL) - { - /* No more memory. */ - _dl_signal_error (ENOMEM, NULL, _("could not allocate name string")); - return 0; - } + { + /* No more memory. */ + _dl_signal_error (ENOMEM, NULL, "could not allocate name string"); + return 0; + } lastp = NULL; for (lnp = l->l_libname; lnp != NULL; lastp = lnp, lnp = lnp->next) @@ -139,12 +139,12 @@ add_name_to_object (struct link_map *l, char *name) newname = malloc (sizeof *newname); if (newname == NULL) - { - /* No more memory. */ - _dl_signal_error (ENOMEM, name, _("cannot allocate name record")); - free(name); - return 0; - } + { + /* No more memory. */ + _dl_signal_error (ENOMEM, name, "cannot allocate name record"); + free (name); + return 0; + } /* The object should have a libname set from _dl_new_object. */ assert (lastp != NULL); diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index 6da708109e..6c1c04b5f5 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -1,5 +1,5 @@ /* Look up a symbol in the loaded objects. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -51,7 +51,7 @@ struct sym_val \ cp = result = alloca (len); \ for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt) \ - cp = stpcpy (cp, all[cnt]); \ + cp = __stpcpy (cp, all[cnt]); \ \ result; \ }) diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c index 088c2331f6..da9c33f099 100644 --- a/elf/dl-minimal.c +++ b/elf/dl-minimal.c @@ -24,6 +24,7 @@ #include <string.h> #include <link.h> #include <stdio-common/_itoa.h> +#include <errno.h> /* Minimal `malloc' allocator for use while loading shared libraries. Only small blocks are allocated, and none are ever freed. */ @@ -123,15 +124,47 @@ longjmp (jmp_buf env, int val) __longjmp (env[0].__jmpbuf, val); } -/* Define our own stub for the localization function used by strerror. - English-only in the dynamic linker keeps it smaller. */ +/* Define our own version of the internal function used by strerror. We + only provide the messages for some common errors. This avoids pulling + in the whole error list. */ char * weak_function -__dcgettext (const char *domainname, const char *msgid, int category) +_strerror_internal (int errnum, char *buf, size_t buflen) { - return (char *) msgid; + char *msg; + + switch (errnum) + { + case ENOMEM: + msg = (char *) "Cannot allocate memory"; + break; + case EINVAL: + msg = (char *) "Invalid argument"; + break; + case ENOENT: + msg = (char *) "No such file or directory"; + break; + case EPERM: + msg = (char *) "Operation not permitted"; + break; + case EIO: + msg = (char *) "Input/output error"; + break; + case EACCES: + msg = (char *) "Permission denied"; + break; + default: + /* No need to check buffer size, all calls in the dynamic linker + provide enough space. */ + buf[buflen - 1] = '\0'; + msg = _itoa_word (errnum, buf + buflen - 1, 10, 0); + msg = memcpy (msg - (sizeof ("Error ") - 1), "Error ", + sizeof ("Error ") - 1); + break; + } + + return msg; } -weak_alias (__dcgettext, dcgettext) #ifndef NDEBUG diff --git a/elf/rtld.c b/elf/rtld.c index 2ca1692584..dd79a81124 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -264,7 +264,6 @@ dl_main (const ElfW(Phdr) *phdr, size_t file_size; char *file; int has_interp = 0; - const char *library_path = NULL; /* Overwrites LD_LIBRARY_PATH if given. */ /* Test whether we want to see the content of the auxiliary array passed up from the kernel. */ @@ -323,6 +322,9 @@ dl_main (const ElfW(Phdr) *phdr, ourselves). This is an easy way to test a new ld.so before installing it. */ + /* Overwrites LD_LIBRARY_PATH if given. */ + const char *library_path = NULL; + /* Note the place where the dynamic linker actually came from. */ _dl_rtld_map.l_name = _dl_argv[0]; @@ -378,6 +380,10 @@ of this helper program; chances are you did not intend to run this program.\n", --_dl_argc; ++_dl_argv; + /* Initialize the data structures for the search paths for shared + objects. */ + _dl_init_paths (library_path); + if (mode == verify) { char *err_str = NULL; @@ -412,12 +418,20 @@ of this helper program; chances are you did not intend to run this program.\n", main_map->l_phnum = phent; main_map->l_entry = *user_entry; main_map->l_opencount = 1; + + /* Initialize the data structures for the search paths for shared + objects. */ + _dl_init_paths (NULL); } /* Scan the program header table for the dynamic section. */ for (ph = phdr; ph < &phdr[phent]; ++ph) switch (ph->p_type) { + case PT_PHDR: + /* Find out the load address. */ + main_map->l_addr = (ElfW(Addr)) phdr - ph->p_vaddr; + break; case PT_DYNAMIC: /* This tells us where to find the dynamic section, which tells us everything we need to do. */ @@ -492,10 +506,6 @@ of this helper program; chances are you did not intend to run this program.\n", preloads = NULL; npreloads = 0; - /* Initialize the data structures for the search paths for shared - objects. */ - _dl_init_paths (library_path); - preloadlist = getenv ("LD_PRELOAD"); if (preloadlist) { |