mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-09 23:00:07 +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>
|
||||
|
||||
* 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-deps.c: Likewise.
|
||||
* elf/dl-fini.c: Likewise.
|
||||
|
@ -354,7 +354,8 @@ save_cache (const char *cache_name)
|
||||
temp_name);
|
||||
|
||||
/* 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)
|
||||
error (EXIT_FAILURE, errno, _("Can't create temporary cache file %s"),
|
||||
temp_name);
|
||||
@ -385,9 +386,10 @@ save_cache (const char *cache_name)
|
||||
close (fd);
|
||||
|
||||
/* 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,
|
||||
_("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. */
|
||||
if (rename (temp_name, cache_name))
|
||||
|
@ -261,7 +261,7 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
|
||||
#else
|
||||
# define EXTRA_FLAGS
|
||||
#endif
|
||||
fd = __open (filename, O_RDWR | O_CREAT EXTRA_FLAGS, 0666);
|
||||
fd = __open (filename, O_RDWR | O_CREAT EXTRA_FLAGS, DEFFILEMODE);
|
||||
if (fd == -1)
|
||||
{
|
||||
/* 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 <unistd.h>
|
||||
#include <sys/mman.h> /* Check if MAP_ANON is defined. */
|
||||
#include <sys/stat.h>
|
||||
#include <ldsodefs.h>
|
||||
#include <stdio-common/_itoa.h>
|
||||
#include <entry.h>
|
||||
@ -51,7 +52,7 @@ enum mode { normal, list, verify, trace };
|
||||
/* Process all environments variables the dynamic linker must recognize.
|
||||
Since all of them start with `LD_' we are a bit smarter while finding
|
||||
all the entries. */
|
||||
static void process_envvars (enum mode *modep, int *lazyp);
|
||||
static void process_envvars (enum mode *modep);
|
||||
|
||||
int _dl_argc;
|
||||
char **_dl_argv;
|
||||
@ -65,7 +66,7 @@ struct r_search_path *_dl_search_paths;
|
||||
const char *_dl_profile;
|
||||
const char *_dl_profile_output;
|
||||
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
|
||||
behavior (it has to do with librt). Until we get DSO groups implemented
|
||||
we have to make this the default. Bummer. --drepper */
|
||||
@ -384,7 +385,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
||||
#endif
|
||||
|
||||
/* 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. */
|
||||
_dl_starting_up = 1;
|
||||
@ -914,7 +915,8 @@ of this helper program; chances are you did not intend to run this program.\n\
|
||||
}
|
||||
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. */
|
||||
struct relocate_args args;
|
||||
@ -989,7 +991,8 @@ of this helper program; chances are you did not intend to run this program.\n\
|
||||
"=> ", NULL);
|
||||
|
||||
if (needed != NULL
|
||||
&& match_version (strtab+aux->vna_name, needed))
|
||||
&& match_version (strtab + aux->vna_name,
|
||||
needed))
|
||||
fname = needed->l_name;
|
||||
|
||||
_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
|
||||
all the entries. */
|
||||
static void
|
||||
process_envvars (enum mode *modep, int *lazyp)
|
||||
process_envvars (enum mode *modep)
|
||||
{
|
||||
char **runp = NULL;
|
||||
char *envline;
|
||||
enum mode mode = normal;
|
||||
int bind_now = 0;
|
||||
char *debug_output = NULL;
|
||||
|
||||
/* This is the default place for profiling data file. */
|
||||
@ -1357,7 +1359,7 @@ process_envvars (enum mode *modep, int *lazyp)
|
||||
/* Do we bind early? */
|
||||
if (memcmp (&envline[3], "BIND_NOW", 8) == 0)
|
||||
{
|
||||
bind_now = envline[12] != '\0';
|
||||
_dl_lazy = envline[12] == '\0';
|
||||
break;
|
||||
}
|
||||
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
|
||||
variables. */
|
||||
if (__libc_enable_secure)
|
||||
if (__builtin_expect (__libc_enable_secure, 0))
|
||||
{
|
||||
static const char *unsecure_envvars[] =
|
||||
{
|
||||
@ -1486,19 +1488,12 @@ process_envvars (enum mode *modep, int *lazyp)
|
||||
*--startp = '.';
|
||||
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)
|
||||
/* We use standard output if opening the file failed. */
|
||||
_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;
|
||||
}
|
||||
|
||||
|
119
elf/sln.c
119
elf/sln.c
@ -1,5 +1,5 @@
|
||||
/* `sln' program to create symboblic links between files.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
/* `sln' program to create symbolic links between files.
|
||||
Copyright (C) 1998, 1999, 2001 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
|
||||
@ -17,6 +17,8 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <error.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
@ -26,7 +28,7 @@
|
||||
#include <string.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)
|
||||
#endif
|
||||
|
||||
@ -39,11 +41,11 @@ main (int argc, char **argv)
|
||||
switch (argc)
|
||||
{
|
||||
case 2:
|
||||
return makesymlinks (argv [1]) == 0 ? 0 : 1;
|
||||
return makesymlinks (argv [1]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return makesymlink (argv [1], argv [2]) == 0 ? 0 : 1;
|
||||
return makesymlink (argv [1], argv [2]);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -60,70 +62,69 @@ makesymlinks (file)
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4095
|
||||
#endif
|
||||
char buffer [PATH_MAX * 4];
|
||||
int i, ret, len;
|
||||
char *buffer = NULL;
|
||||
size_t bufferlen = 0;
|
||||
int ret;
|
||||
int lineno;
|
||||
const char *src;
|
||||
const char *dest;
|
||||
const char *error;
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen (file, "r");
|
||||
if (fp == NULL)
|
||||
if (strcmp (file, "-") == 0)
|
||||
fp = stdin;
|
||||
else
|
||||
{
|
||||
error = strerror (errno);
|
||||
fprintf (stderr, "%s: file open error: %s\n", file, error);
|
||||
return -1;
|
||||
fp = fopen (file, "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
fprintf (stderr, "%s: file open error: %m\n", file);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
lineno = 0;
|
||||
while (fgets (buffer, sizeof (buffer) - 1, fp))
|
||||
while (!feof_unlocked (fp))
|
||||
{
|
||||
lineno++;
|
||||
src = dest = NULL;
|
||||
buffer [sizeof (buffer) - 1] = '\0';
|
||||
len = strlen (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;
|
||||
}
|
||||
ssize_t n = getline (&buffer, &bufferlen, fp);
|
||||
char *src;
|
||||
char *dest;
|
||||
char *cp = buffer;
|
||||
|
||||
src = &buffer [i];
|
||||
for (; i < len && !isspace (buffer [i]); i++);
|
||||
if (i < len)
|
||||
if (n < 0)
|
||||
break;
|
||||
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';
|
||||
for (; i < len && isspace (buffer [i]); i++);
|
||||
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--;
|
||||
fprintf (stderr, "No target in line %d\n", lineno);
|
||||
ret = 1;
|
||||
continue;
|
||||
}
|
||||
dest = cp;
|
||||
|
||||
if (makesymlink (src, dest))
|
||||
{
|
||||
fprintf (stderr, "Failed to make link from \"%s\" to \"%s\" in line %d\n",
|
||||
src, dest, lineno);
|
||||
ret--;
|
||||
}
|
||||
do
|
||||
++cp;
|
||||
while (*cp != '\0' && ! isspace (*cp));
|
||||
if (*cp != '\0')
|
||||
*cp++ = '\0';
|
||||
|
||||
ret |= makesymlink (src, dest);
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
@ -145,13 +146,13 @@ makesymlink (src, dest)
|
||||
{
|
||||
fprintf (stderr, "%s: destination must not be a directory\n",
|
||||
dest);
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
else if (unlink (dest) && errno != ENOENT)
|
||||
{
|
||||
fprintf (stderr, "%s: failed to remove the old destination\n",
|
||||
dest);
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (errno != ENOENT)
|
||||
@ -174,7 +175,7 @@ makesymlink (src, dest)
|
||||
unlink (dest);
|
||||
fprintf (stderr, "Invalid link from \"%s\" to \"%s\": %s\n",
|
||||
src, dest, error);
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -183,6 +184,6 @@ makesymlink (src, dest)
|
||||
error = strerror (errno);
|
||||
fprintf (stderr, "Invalid link from \"%s\" to \"%s\": %s\n",
|
||||
src, dest, error);
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user