mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 00:10:10 +00:00
Update.
* elf/rtld.c: Little optimizations in handling _dl_lazy. * elf/cache.c (save_cache): Portability changes. * elf/dl-profile.c (_dl_start_profile): Likewise. * elf/sln.c: Cleanups. Remove arbitrary limits.
This commit is contained in:
parent
b76a75de25
commit
ba9fcb3f41
@ -1,5 +1,12 @@
|
|||||||
2001-02-27 Ulrich Drepper <drepper@redhat.com>
|
2001-02-27 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* elf/rtld.c: Little optimizations in handling _dl_lazy.
|
||||||
|
|
||||||
|
* elf/cache.c (save_cache): Portability changes.
|
||||||
|
* elf/dl-profile.c (_dl_start_profile): Likewise.
|
||||||
|
|
||||||
|
* elf/sln.c: Cleanups. Remove arbitrary limits.
|
||||||
|
|
||||||
* elf/dl-close.c: Replace _dl_debug_* variables with _dl_debug_mask.
|
* elf/dl-close.c: Replace _dl_debug_* variables with _dl_debug_mask.
|
||||||
* elf/dl-deps.c: Likewise.
|
* elf/dl-deps.c: Likewise.
|
||||||
* elf/dl-fini.c: Likewise.
|
* elf/dl-fini.c: Likewise.
|
||||||
|
@ -354,7 +354,8 @@ save_cache (const char *cache_name)
|
|||||||
temp_name);
|
temp_name);
|
||||||
|
|
||||||
/* Create file. */
|
/* Create file. */
|
||||||
fd = open (temp_name, O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW, 0644);
|
fd = open (temp_name, O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW,
|
||||||
|
S_IROTH|S_IRGRP|S_IRUSR|S_IWUSR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
error (EXIT_FAILURE, errno, _("Can't create temporary cache file %s"),
|
error (EXIT_FAILURE, errno, _("Can't create temporary cache file %s"),
|
||||||
temp_name);
|
temp_name);
|
||||||
@ -385,9 +386,10 @@ save_cache (const char *cache_name)
|
|||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
/* Make sure user can always read cache file */
|
/* Make sure user can always read cache file */
|
||||||
if (chmod (temp_name, 0644))
|
if (chmod (temp_name, S_IROTH|S_IRGRP|S_IRUSR|S_IWUSR))
|
||||||
error (EXIT_FAILURE, errno,
|
error (EXIT_FAILURE, errno,
|
||||||
_("Changing access rights of %s to 0644 failed"), temp_name);
|
_("Changing access rights of %s to %#o failed"), temp_name,
|
||||||
|
S_IROTH|S_IRGRP|S_IRUSR|S_IWUSR);
|
||||||
|
|
||||||
/* Move temporary to its final location. */
|
/* Move temporary to its final location. */
|
||||||
if (rename (temp_name, cache_name))
|
if (rename (temp_name, cache_name))
|
||||||
|
@ -261,7 +261,7 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
|
|||||||
#else
|
#else
|
||||||
# define EXTRA_FLAGS
|
# define EXTRA_FLAGS
|
||||||
#endif
|
#endif
|
||||||
fd = __open (filename, O_RDWR | O_CREAT EXTRA_FLAGS, 0666);
|
fd = __open (filename, O_RDWR | O_CREAT EXTRA_FLAGS, DEFFILEMODE);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
/* We cannot write the profiling data so don't do anything. */
|
/* We cannot write the profiling data so don't do anything. */
|
||||||
|
29
elf/rtld.c
29
elf/rtld.c
@ -22,6 +22,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h> /* Check if MAP_ANON is defined. */
|
#include <sys/mman.h> /* Check if MAP_ANON is defined. */
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <ldsodefs.h>
|
#include <ldsodefs.h>
|
||||||
#include <stdio-common/_itoa.h>
|
#include <stdio-common/_itoa.h>
|
||||||
#include <entry.h>
|
#include <entry.h>
|
||||||
@ -51,7 +52,7 @@ enum mode { normal, list, verify, trace };
|
|||||||
/* Process all environments variables the dynamic linker must recognize.
|
/* Process all environments variables the dynamic linker must recognize.
|
||||||
Since all of them start with `LD_' we are a bit smarter while finding
|
Since all of them start with `LD_' we are a bit smarter while finding
|
||||||
all the entries. */
|
all the entries. */
|
||||||
static void process_envvars (enum mode *modep, int *lazyp);
|
static void process_envvars (enum mode *modep);
|
||||||
|
|
||||||
int _dl_argc;
|
int _dl_argc;
|
||||||
char **_dl_argv;
|
char **_dl_argv;
|
||||||
@ -65,7 +66,7 @@ struct r_search_path *_dl_search_paths;
|
|||||||
const char *_dl_profile;
|
const char *_dl_profile;
|
||||||
const char *_dl_profile_output;
|
const char *_dl_profile_output;
|
||||||
struct link_map *_dl_profile_map;
|
struct link_map *_dl_profile_map;
|
||||||
int _dl_lazy;
|
int _dl_lazy = 1;
|
||||||
/* XXX I know about at least one case where we depend on the old weak
|
/* XXX I know about at least one case where we depend on the old weak
|
||||||
behavior (it has to do with librt). Until we get DSO groups implemented
|
behavior (it has to do with librt). Until we get DSO groups implemented
|
||||||
we have to make this the default. Bummer. --drepper */
|
we have to make this the default. Bummer. --drepper */
|
||||||
@ -384,7 +385,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Process the environment variable which control the behaviour. */
|
/* Process the environment variable which control the behaviour. */
|
||||||
process_envvars (&mode, &_dl_lazy);
|
process_envvars (&mode);
|
||||||
|
|
||||||
/* Set up a flag which tells we are just starting. */
|
/* Set up a flag which tells we are just starting. */
|
||||||
_dl_starting_up = 1;
|
_dl_starting_up = 1;
|
||||||
@ -914,7 +915,8 @@ of this helper program; chances are you did not intend to run this program.\n\
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_dl_lazy >= 0)
|
/* Unless LD_WARN is set warn do not about undefined symbols. */
|
||||||
|
if (_dl_lazy >= 0 && !_dl_verbose)
|
||||||
{
|
{
|
||||||
/* We have to do symbol dependency testing. */
|
/* We have to do symbol dependency testing. */
|
||||||
struct relocate_args args;
|
struct relocate_args args;
|
||||||
@ -989,7 +991,8 @@ of this helper program; chances are you did not intend to run this program.\n\
|
|||||||
"=> ", NULL);
|
"=> ", NULL);
|
||||||
|
|
||||||
if (needed != NULL
|
if (needed != NULL
|
||||||
&& match_version (strtab+aux->vna_name, needed))
|
&& match_version (strtab + aux->vna_name,
|
||||||
|
needed))
|
||||||
fname = needed->l_name;
|
fname = needed->l_name;
|
||||||
|
|
||||||
_dl_sysdep_message (fname ?: "not found", "\n",
|
_dl_sysdep_message (fname ?: "not found", "\n",
|
||||||
@ -1298,12 +1301,11 @@ a filename can be specified using the LD_DEBUG_OUTPUT environment variable.\n",
|
|||||||
Since all of them start with `LD_' we are a bit smarter while finding
|
Since all of them start with `LD_' we are a bit smarter while finding
|
||||||
all the entries. */
|
all the entries. */
|
||||||
static void
|
static void
|
||||||
process_envvars (enum mode *modep, int *lazyp)
|
process_envvars (enum mode *modep)
|
||||||
{
|
{
|
||||||
char **runp = NULL;
|
char **runp = NULL;
|
||||||
char *envline;
|
char *envline;
|
||||||
enum mode mode = normal;
|
enum mode mode = normal;
|
||||||
int bind_now = 0;
|
|
||||||
char *debug_output = NULL;
|
char *debug_output = NULL;
|
||||||
|
|
||||||
/* This is the default place for profiling data file. */
|
/* This is the default place for profiling data file. */
|
||||||
@ -1357,7 +1359,7 @@ process_envvars (enum mode *modep, int *lazyp)
|
|||||||
/* Do we bind early? */
|
/* Do we bind early? */
|
||||||
if (memcmp (&envline[3], "BIND_NOW", 8) == 0)
|
if (memcmp (&envline[3], "BIND_NOW", 8) == 0)
|
||||||
{
|
{
|
||||||
bind_now = envline[12] != '\0';
|
_dl_lazy = envline[12] == '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (memcmp (&envline[3], "BIND_NOT", 8) == 0)
|
if (memcmp (&envline[3], "BIND_NOT", 8) == 0)
|
||||||
@ -1432,7 +1434,7 @@ process_envvars (enum mode *modep, int *lazyp)
|
|||||||
|
|
||||||
/* Extra security for SUID binaries. Remove all dangerous environment
|
/* Extra security for SUID binaries. Remove all dangerous environment
|
||||||
variables. */
|
variables. */
|
||||||
if (__libc_enable_secure)
|
if (__builtin_expect (__libc_enable_secure, 0))
|
||||||
{
|
{
|
||||||
static const char *unsecure_envvars[] =
|
static const char *unsecure_envvars[] =
|
||||||
{
|
{
|
||||||
@ -1486,19 +1488,12 @@ process_envvars (enum mode *modep, int *lazyp)
|
|||||||
*--startp = '.';
|
*--startp = '.';
|
||||||
startp = memcpy (startp - name_len, debug_output, name_len);
|
startp = memcpy (startp - name_len, debug_output, name_len);
|
||||||
|
|
||||||
_dl_debug_fd = __open (startp, flags, 0666);
|
_dl_debug_fd = __open (startp, flags, DEFFILEMODE);
|
||||||
if (_dl_debug_fd == -1)
|
if (_dl_debug_fd == -1)
|
||||||
/* We use standard output if opening the file failed. */
|
/* We use standard output if opening the file failed. */
|
||||||
_dl_debug_fd = STDOUT_FILENO;
|
_dl_debug_fd = STDOUT_FILENO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LAZY is determined by the environment variable LD_WARN and
|
|
||||||
LD_BIND_NOW if we trace the binary. */
|
|
||||||
if (__builtin_expect (mode, normal) == trace)
|
|
||||||
*lazyp = _dl_verbose ? !bind_now : -1;
|
|
||||||
else
|
|
||||||
*lazyp = !bind_now;
|
|
||||||
|
|
||||||
*modep = mode;
|
*modep = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
119
elf/sln.c
119
elf/sln.c
@ -1,5 +1,5 @@
|
|||||||
/* `sln' program to create symboblic links between files.
|
/* `sln' program to create symbolic links between files.
|
||||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -17,6 +17,8 @@
|
|||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include <error.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -26,7 +28,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
#if !defined S_ISDIR && defined S_IFDIR
|
||||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -39,11 +41,11 @@ main (int argc, char **argv)
|
|||||||
switch (argc)
|
switch (argc)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
return makesymlinks (argv [1]) == 0 ? 0 : 1;
|
return makesymlinks (argv [1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
return makesymlink (argv [1], argv [2]) == 0 ? 0 : 1;
|
return makesymlink (argv [1], argv [2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -60,70 +62,69 @@ makesymlinks (file)
|
|||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
#define PATH_MAX 4095
|
#define PATH_MAX 4095
|
||||||
#endif
|
#endif
|
||||||
char buffer [PATH_MAX * 4];
|
char *buffer = NULL;
|
||||||
int i, ret, len;
|
size_t bufferlen = 0;
|
||||||
|
int ret;
|
||||||
int lineno;
|
int lineno;
|
||||||
const char *src;
|
|
||||||
const char *dest;
|
|
||||||
const char *error;
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
fp = fopen (file, "r");
|
if (strcmp (file, "-") == 0)
|
||||||
if (fp == NULL)
|
fp = stdin;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
error = strerror (errno);
|
fp = fopen (file, "r");
|
||||||
fprintf (stderr, "%s: file open error: %s\n", file, error);
|
if (fp == NULL)
|
||||||
return -1;
|
{
|
||||||
|
fprintf (stderr, "%s: file open error: %m\n", file);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
lineno = 0;
|
lineno = 0;
|
||||||
while (fgets (buffer, sizeof (buffer) - 1, fp))
|
while (!feof_unlocked (fp))
|
||||||
{
|
{
|
||||||
lineno++;
|
ssize_t n = getline (&buffer, &bufferlen, fp);
|
||||||
src = dest = NULL;
|
char *src;
|
||||||
buffer [sizeof (buffer) - 1] = '\0';
|
char *dest;
|
||||||
len = strlen (buffer);
|
char *cp = buffer;
|
||||||
for (i = 0; i < len && isspace (buffer [i]); i++);
|
|
||||||
if (i >= len)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Fail to parse line %d: \"%s\"\n", lineno,
|
|
||||||
buffer);
|
|
||||||
ret--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
src = &buffer [i];
|
if (n < 0)
|
||||||
for (; i < len && !isspace (buffer [i]); i++);
|
break;
|
||||||
if (i < len)
|
if (buffer[n - 1] == '\n')
|
||||||
|
buffer[n - 1] = '\0';
|
||||||
|
|
||||||
|
++lineno;
|
||||||
|
while (isspace (*cp))
|
||||||
|
++cp;
|
||||||
|
if (*cp == '\0')
|
||||||
|
/* Ignore empty lines. */
|
||||||
|
continue;
|
||||||
|
src = cp;
|
||||||
|
|
||||||
|
do
|
||||||
|
++cp;
|
||||||
|
while (*cp != '\0' && ! isspace (*cp));
|
||||||
|
if (*cp != '\0')
|
||||||
|
*cp++ = '\0';
|
||||||
|
|
||||||
|
while (isspace (*cp))
|
||||||
|
++cp;
|
||||||
|
if (*cp == '\0')
|
||||||
{
|
{
|
||||||
buffer [i++] = '\0';
|
fprintf (stderr, "No target in line %d\n", lineno);
|
||||||
for (; i < len && isspace (buffer [i]); i++);
|
ret = 1;
|
||||||
if (i >= len)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "No target in line %d: \"%s\"\n", lineno,
|
|
||||||
buffer);
|
|
||||||
ret--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
dest = &buffer [i];
|
|
||||||
for (; i < len && !isspace (buffer [i]); i++);
|
|
||||||
buffer [i] = '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (stderr, "No target in line %d: \"%s\"\n", lineno,
|
|
||||||
buffer);
|
|
||||||
ret--;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
dest = cp;
|
||||||
|
|
||||||
if (makesymlink (src, dest))
|
do
|
||||||
{
|
++cp;
|
||||||
fprintf (stderr, "Failed to make link from \"%s\" to \"%s\" in line %d\n",
|
while (*cp != '\0' && ! isspace (*cp));
|
||||||
src, dest, lineno);
|
if (*cp != '\0')
|
||||||
ret--;
|
*cp++ = '\0';
|
||||||
}
|
|
||||||
|
ret |= makesymlink (src, dest);
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
@ -145,13 +146,13 @@ makesymlink (src, dest)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "%s: destination must not be a directory\n",
|
fprintf (stderr, "%s: destination must not be a directory\n",
|
||||||
dest);
|
dest);
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (unlink (dest) && errno != ENOENT)
|
else if (unlink (dest) && errno != ENOENT)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: failed to remove the old destination\n",
|
fprintf (stderr, "%s: failed to remove the old destination\n",
|
||||||
dest);
|
dest);
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (errno != ENOENT)
|
else if (errno != ENOENT)
|
||||||
@ -174,7 +175,7 @@ makesymlink (src, dest)
|
|||||||
unlink (dest);
|
unlink (dest);
|
||||||
fprintf (stderr, "Invalid link from \"%s\" to \"%s\": %s\n",
|
fprintf (stderr, "Invalid link from \"%s\" to \"%s\": %s\n",
|
||||||
src, dest, error);
|
src, dest, error);
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -183,6 +184,6 @@ makesymlink (src, dest)
|
|||||||
error = strerror (errno);
|
error = strerror (errno);
|
||||||
fprintf (stderr, "Invalid link from \"%s\" to \"%s\": %s\n",
|
fprintf (stderr, "Invalid link from \"%s\" to \"%s\": %s\n",
|
||||||
src, dest, error);
|
src, dest, error);
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user