aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-02-03 19:39:52 +0000
committerUlrich Drepper <drepper@redhat.com>2002-02-03 19:39:52 +0000
commit9710f75d4a4d57fa86f20e011c6dc6e66c590080 (patch)
tree371793321e7797f93456cf680abb268d8607e25c /elf
parent654a7a0c299f2f5beca8745a35efd4334f361140 (diff)
downloadglibc-9710f75d4a4d57fa86f20e011c6dc6e66c590080.zip
glibc-9710f75d4a4d57fa86f20e011c6dc6e66c590080.tar.gz
glibc-9710f75d4a4d57fa86f20e011c6dc6e66c590080.tar.bz2
Update.
2002-02-03 Andreas Schwab <schwab@suse.de> * sysdeps/posix/readv.c: Use ssize_t for bytes_read. * sysdeps/posix/writev.c: Use ssize_t for bytes_written. Fix comment. 2002-02-03 Thorsten Kukuk <kukuk@suse.de> * sysdeps/posix/writev.c: Check for ssize_t overflow, don't use alloca if the memory reqirements are too high. 2002-02-03 Ulrich Drepper <drepper@redhat.com> * elf/dl-load.c (decompose_rpath): Avoid using strstr. * elf/dl-minimal.c (_strerror_r): Use _itoa instead of _itoa_word since the former is available anyway and speed isn't important here. * elf/dl-misc.c (_dl_debug_vdprintf): Likewise. * elf/dl-version.c (match_symbol): Likewise. (_dl_check_map_versions): Likewise. * elf/rtld.c (process_envvars): Likewise. (print_statistics): Likewise. * sysdeps/generic/dl-sysdep.c (_dl_show_auxv): Likewise. * elf/dl-minimal.c (_itoa): Always define it. Make it work for all bases. Add assert to catch uses of unimplemented features. (__strsep): Add assert to catch uses of unimplemented features. * elf/dl-object.c (_dl_new_object): Don't use rawmemchr. Use strchr and avoid inline optimization. * elf/rtld.c (process_envvars): Likewise. * elf/dl-open.c: Don't include <stdio-common/_itoa.h>. * elf/dl-profile.c (_dl_start_profile): Help compiler to avoid ffs. * elf/rtld.c (dl_main): Avoid strsep inline optimization. * stdio-common/_itoa.h: Minor simplifications of the code. * stdio-common/_itoa.c: Likewise. * elf/dl-reloc.c (_dl_relocate_object): Use _dl_debug_printf instead of _dl_printf for debugging info output. * sysdeps/mips/atomicity.h (exchange_and_add): Use branch likely.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-load.c22
-rw-r--r--elf/dl-minimal.c21
-rw-r--r--elf/dl-misc.c4
-rw-r--r--elf/dl-object.c7
-rw-r--r--elf/dl-open.c1
-rw-r--r--elf/dl-profile.c21
-rw-r--r--elf/dl-reloc.c6
-rw-r--r--elf/dl-version.c8
-rw-r--r--elf/rtld.c20
9 files changed, 70 insertions, 40 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 574d4da..cf64ebc 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -496,12 +496,19 @@ decompose_rpath (struct r_search_path_struct *sps,
if (__builtin_expect (GL(dl_inhibit_rpath) != NULL, 0)
&& !__libc_enable_secure)
{
- const char *found = strstr (GL(dl_inhibit_rpath), where);
- if (found != NULL)
+ const char *inhp = GL(dl_inhibit_rpath);
+
+ do
{
- size_t len = strlen (where);
- if ((found == GL(dl_inhibit_rpath) || found[-1] == ':')
- && (found[len] == '\0' || found[len] == ':'))
+ const char *wp = where;
+
+ while (*inhp == *wp && *wp != '\0')
+ {
+ ++inhp;
+ ++wp;
+ }
+
+ if (*wp == '\0' && (*inhp == '\0' || *inhp == ':'))
{
/* This object is on the list of objects for which the
RUNPATH and RPATH must not be used. */
@@ -522,7 +529,12 @@ decompose_rpath (struct r_search_path_struct *sps,
return;
}
+
+ while (*inhp != '\0')
+ if (*inhp++ == ':')
+ break;
}
+ while (*inhp != '\0');
}
/* Make a writable copy. At the same time expand possible dynamic
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
index efdc26d..cd899bf 100644
--- a/elf/dl-minimal.c
+++ b/elf/dl-minimal.c
@@ -171,7 +171,7 @@ __strerror_r (int errnum, char *buf, size_t buflen)
/* 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 = _itoa (errnum, buf + buflen - 1, 10, 0);
msg = memcpy (msg - (sizeof ("Error ") - 1), "Error ",
sizeof ("Error ") - 1);
break;
@@ -270,9 +270,9 @@ __strtoul_internal (const char *nptr, char **endptr, int base, int group)
}
-#if HP_TIMING_AVAIL && ULONG_MAX <= 4294967295UL
-/* We need this function to print the cycle count. On 64-bit machines the
- _itoa_word function should be used. */
+/* We always use _itoa instead of _itoa_word in ld.so since the former
+ also has to be present and it is never about speed when these
+ functions are used. */
char *
_itoa (value, buflim, base, upper_case)
unsigned long long int value;
@@ -280,17 +280,16 @@ _itoa (value, buflim, base, upper_case)
unsigned int base;
int upper_case;
{
- char *bp = buflim;
+ extern const char _itoa_lower_digits[];
- assert (base == 10);
+ assert (! upper_case);
do
- *--bp = '0' + value % 10;
- while ((value /= 10) != 0);
+ *--buflim = _itoa_lower_digits[value % base];
+ while ((value /= base) != 0);
- return bp;
+ return buflim;
}
-#endif
/* The following is not a complete strsep implementation. It cannot
@@ -303,6 +302,8 @@ __strsep (char **stringp, const char *delim)
{
char *begin;
+ assert (delim[0] != '\0');
+
begin = *stringp;
if (begin != NULL)
{
diff --git a/elf/dl-misc.c b/elf/dl-misc.c
index 0a37b59..ab883ac 100644
--- a/elf/dl-misc.c
+++ b/elf/dl-misc.c
@@ -105,7 +105,7 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
char *p;
pid = __getpid ();
assert (pid >= 0 && pid < 100000);
- p = _itoa_word (pid, &pidbuf[5], 10, 0);
+ p = _itoa (pid, &pidbuf[5], 10, 0);
while (p > pidbuf)
*--p = '0';
pidbuf[5] = ':';
@@ -185,7 +185,7 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
having more than one integer formatting in a call. */
char *buf = (char *) alloca (3 * sizeof (unsigned long int));
char *endp = &buf[3 * sizeof (unsigned long int)];
- char *cp = _itoa_word (num, endp, *fmt == 'x' ? 16 : 10, 0);
+ char *cp = _itoa (num, endp, *fmt == 'x' ? 16 : 10, 0);
/* Pad to the width the user specified. */
if (width != -1)
diff --git a/elf/dl-object.c b/elf/dl-object.c
index 398628a..6196cd7 100644
--- a/elf/dl-object.c
+++ b/elf/dl-object.c
@@ -142,9 +142,10 @@ _dl_new_object (char *realname, const char *libname, int type,
goto out;
}
- /* Find the end of the path and see whether we have to add
- a slash. */
- cp = __rawmemchr (origin, '\0');
+ /* Find the end of the path and see whether we have to add a
+ slash. We could use rawmemchr but this need not be
+ fast. */
+ cp = (strchr) (origin, '\0');
if (cp[-1] != '/')
*cp++ = '/';
}
diff --git a/elf/dl-open.c b/elf/dl-open.c
index e5f7ac8..253f7b9 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -31,7 +31,6 @@
#include <bp-sym.h>
#include <dl-dst.h>
-#include <stdio-common/_itoa.h>
extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
diff --git a/elf/dl-profile.c b/elf/dl-profile.c
index 83e8495..19d1865 100644
--- a/elf/dl-profile.c
+++ b/elf/dl-profile.c
@@ -19,6 +19,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
@@ -217,9 +218,23 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
kcountsize = textsize / HISTFRACTION;
hashfraction = HASHFRACTION;
if ((HASHFRACTION & (HASHFRACTION - 1)) == 0)
- /* If HASHFRACTION is a power of two, mcount can use shifting
- instead of integer division. Precompute shift amount. */
- log_hashfraction = __ffs (hashfraction * sizeof (*froms)) - 1;
+ {
+ /* If HASHFRACTION is a power of two, mcount can use shifting
+ instead of integer division. Precompute shift amount.
+
+ This is a constant but the compiler cannot compile the
+ expression away since the __ffs implementation is not known
+ to the compiler. Help the compiler by precomputing the
+ usual cases. */
+ assert (hashfraction == 2);
+
+ if (sizeof (*froms) == 8)
+ log_hashfraction = 4;
+ else if (sizeof (*froms) == 16)
+ log_hashfraction = 5;
+ else
+ log_hashfraction = __ffs (hashfraction * sizeof (*froms)) - 1;
+ }
else
log_hashfraction = -1;
tossize = textsize / HASHFRACTION;
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index 67a47aa..1c0c18d 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -59,9 +59,9 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
lazy = 0;
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_RELOC, 0))
- _dl_printf ("\nrelocation processing: %s%s\n",
- l->l_name[0] ? l->l_name : _dl_argv[0],
- lazy ? " (lazy)" : "");
+ INT(_dl_debug_printf) ("\nrelocation processing: %s%s\n",
+ l->l_name[0] ? l->l_name : _dl_argv[0],
+ lazy ? " (lazy)" : "");
/* DT_TEXTREL is now in level 2 and might phase out at some time.
But we rewrite the DT_FLAGS entry to a DT_TEXTREL entry to make
diff --git a/elf/dl-version.c b/elf/dl-version.c
index 9ba91b2..f9fd3ba 100644
--- a/elf/dl-version.c
+++ b/elf/dl-version.c
@@ -121,8 +121,8 @@ no version information available (required by ", name, ")");
buf[sizeof (buf) - 1] = '\0';
/* XXX We cannot translate the message. */
errstring = make_string ("unsupported version ",
- _itoa_word (def->vd_version,
- &buf[sizeof (buf) - 1], 10, 0),
+ _itoa (def->vd_version,
+ &buf[sizeof (buf) - 1], 10, 0),
" of Verdef record");
result = 1;
goto call_cerror;
@@ -210,8 +210,8 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode)
buf[sizeof (buf) - 1] = '\0';
/* XXX We cannot translate the message. */
errstring = make_string ("unsupported version ",
- _itoa_word (ent->vn_version,
- &buf[sizeof (buf) - 1], 10, 0),
+ _itoa (ent->vn_version,
+ &buf[sizeof (buf) - 1], 10, 0),
" of Verneed record\n");
call_error:
INT(_dl_signal_error) (errval, (*map->l_name
diff --git a/elf/rtld.c b/elf/rtld.c
index 4dd288b..b49d110 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -697,7 +697,8 @@ of this helper program; chances are you did not intend to run this program.\n\
HP_TIMING_NOW (start);
- while ((p = strsep (&list, " :")) != NULL)
+ /* Prevent optimizing strsep. Speed is not important here. */
+ while ((p = (strsep) (&list, " :")) != NULL)
if (p[0] != '\0'
&& (__builtin_expect (! __libc_enable_secure, 1)
|| strchr (p, '/') == NULL))
@@ -1063,8 +1064,8 @@ of this helper program; chances are you did not intend to run this program.\n\
{
ElfW(Lib) *liblist, *liblistend;
struct link_map **r_list, **r_listend, *l;
- const char *strtab = (const void *)
- D_PTR (GL(dl_loaded), l_info[DT_STRTAB]);
+ const char *strtab = (const void *) D_PTR (GL(dl_loaded),
+ l_info[DT_STRTAB]);
assert (GL(dl_loaded)->l_info [VALIDX (DT_GNU_LIBLISTSZ)] != NULL);
liblist = (ElfW(Lib) *)
@@ -1550,7 +1551,8 @@ process_envvars (enum mode *modep)
do
{
unsetenv (nextp);
- nextp = (char *) rawmemchr (nextp, '\0') + 1;
+ /* We could use rawmemchr but this need not be fast. */
+ nextp = (char *) (strchr) (nextp, '\0') + 1;
}
while (*nextp != '\0');
@@ -1572,7 +1574,7 @@ process_envvars (enum mode *modep)
char *startp;
buf[name_len + 11] = '\0';
- startp = _itoa_word (__getpid (), &buf[name_len + 11], 10, 0);
+ startp = _itoa (__getpid (), &buf[name_len + 11], 10, 0);
*--startp = '.';
startp = memcpy (startp - name_len, debug_output, name_len);
@@ -1607,8 +1609,8 @@ print_statistics (void)
{
char pbuf[30];
HP_TIMING_PRINT (buf, sizeof (buf), relocate_time);
- cp = _itoa_word ((1000ULL * relocate_time) / rtld_total_time,
- pbuf + sizeof (pbuf), 10, 0);
+ cp = _itoa ((1000ULL * relocate_time) / rtld_total_time,
+ pbuf + sizeof (pbuf), 10, 0);
wp = pbuf;
switch (pbuf + sizeof (pbuf) - cp)
{
@@ -1637,8 +1639,8 @@ print_statistics (void)
{
char pbuf[30];
HP_TIMING_PRINT (buf, sizeof (buf), load_time);
- cp = _itoa_word ((1000ULL * load_time) / rtld_total_time,
- pbuf + sizeof (pbuf), 10, 0);
+ cp = _itoa ((1000ULL * load_time) / rtld_total_time,
+ pbuf + sizeof (pbuf), 10, 0);
wp = pbuf;
switch (pbuf + sizeof (pbuf) - cp)
{