[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r14969 - in /fsf/trunk/libc: ./ elf/ nss/ resolv/ sysdeps/unix/sysv/linux/
- To: commits@xxxxxxxxxx
- Subject: [commits] r14969 - in /fsf/trunk/libc: ./ elf/ nss/ resolv/ sysdeps/unix/sysv/linux/
- From: eglibc@xxxxxxxxxx
- Date: Thu, 18 Aug 2011 07:02:28 -0000
Author: eglibc
Date: Thu Aug 18 00:02:26 2011
New Revision: 14969
Log:
Import glibc-mainline for 2011-08-18
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/Makeconfig
fsf/trunk/libc/elf/pldd-xx.c
fsf/trunk/libc/elf/pldd.c
fsf/trunk/libc/nss/makedb.c
fsf/trunk/libc/resolv/Makefile
fsf/trunk/libc/sysdeps/unix/sysv/linux/Makefile
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Thu Aug 18 00:02:26 2011
@@ -1,10 +1,34 @@
+2011-08-14 David S. Miller <davem@xxxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/Makefile (CFLAGS-tst-writev.c): The
+ artificual limit depends upon the system page size.
+
+2011-08-17 Ulrich Drepper <drepper@xxxxxxxxx>
+
+ * Makeconfig (override CFLAGS): Add library-specific CFLAGS.
+ * resolv/Makefile: Define CFLAGS-libresolv.
+
+2011-08-17 Andreas Schwab <schwab@xxxxxxxxxx>
+
+ * nss/makedb.c (compute_tables): Make variables used in nested
+ function static.
+
+2011-08-17 Ulrich Drepper <drepper@xxxxxxxxx>
+
+ * elf/pldd-xx.c (r_debug): Explicitly add padding when needed.
+ * elf/pldd.c (get_process_info): Use pread to re-read auxiliary vector
+ if buffer was too small.
+
+ * elf/pldd.c (main): Attach to all threads in the process.
+ Rewrite /proc handling to use *at functions.
+
2011-08-16 Ulrich Drepper <drepper@xxxxxxxxx>
* elf/dl-open.c (_dl_show_scope): Take additional parameter which
specifies first scope to show.
(dl_open_worker): Update callers. Move printing scope of new
object to before the relocation.
- * rtld.c (dl_main): Update _dl_show_scope call.
+ * elf/rtld.c (dl_main): Update _dl_show_scope call.
* sysdeps/generic/ldsodefs.h: Update declaration.
* elf/dl-open.c (_dl_show_scope): Use _dl_debug_printf to generate the
@@ -42,7 +66,7 @@
2011-08-13 Ulrich Drepper <drepper@xxxxxxxxx>
- * elf/dl-open.c: Rename show_scope to _dl_schow_scope and export.
+ * elf/dl-open.c: Rename show_scope to _dl_show_scope and export.
(dl_open_worker): Call _dl_show_scope when DL_DEBUG_SCOPES is set.
* elf/rtld.c (dl_main): Set l_name of vDSO.
Call _dl_show_scope when DL_DEBUG_SCOPES.
Modified: fsf/trunk/libc/Makeconfig
==============================================================================
--- fsf/trunk/libc/Makeconfig (original)
+++ fsf/trunk/libc/Makeconfig Thu Aug 18 00:02:26 2011
@@ -708,7 +708,9 @@
override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) \
$(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
$(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
- $(CFLAGS-$(@F))
+ $(CFLAGS-$(@F)) \
+ $(foreach lib,$(libof-$(basename $(@F))) \
+ $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
override CXXFLAGS = $(c++-sysincludes) \
$(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
$(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
Modified: fsf/trunk/libc/elf/pldd-xx.c
==============================================================================
--- fsf/trunk/libc/elf/pldd-xx.c (original)
+++ fsf/trunk/libc/elf/pldd-xx.c Thu Aug 18 00:02:26 2011
@@ -64,6 +64,9 @@
struct E(r_debug)
{
int r_version;
+#if CLASS == 64
+ int pad;
+#endif
EW(Addr) r_map;
};
#if CLASS == __ELF_NATIVE_CLASS
@@ -75,6 +78,7 @@
static int
+
E(find_maps) (pid_t pid, EW(Ehdr) *ehdr, void *auxv, size_t auxv_size)
{
EW(Addr) phdr = 0;
@@ -97,6 +101,7 @@
default:
break;
}
+ printf("progam header at offset %lu\n", (unsigned long)phdr);
if (phdr == 0 || phnum == 0 || phent == 0)
error (EXIT_FAILURE, 0, gettext ("cannot find program header of process"));
Modified: fsf/trunk/libc/elf/pldd.c
==============================================================================
--- fsf/trunk/libc/elf/pldd.c (original)
+++ fsf/trunk/libc/elf/pldd.c Thu Aug 18 00:02:26 2011
@@ -20,6 +20,8 @@
#include <alloca.h>
#include <argp.h>
+#include <assert.h>
+#include <dirent.h>
#include <elf.h>
#include <errno.h>
#include <error.h>
@@ -83,7 +85,7 @@
static char *exe;
/* Local functions. */
-static int get_process_info (pid_t pid);
+static int get_process_info (int dfd, long int pid);
int
@@ -101,33 +103,96 @@
return 1;
}
+ assert (sizeof (pid_t) == sizeof (int)
+ || sizeof (pid_t) == sizeof (long int));
char *endp;
errno = 0;
- pid_t pid = strtoul (argv[remaining], &endp, 10);
- if ((pid == ULONG_MAX && errno == ERANGE) || *endp != '\0')
+ long int pid = strtol (argv[remaining], &endp, 10);
+ if (pid < 0 || (pid == ULONG_MAX && errno == ERANGE) || *endp != '\0'
+ || (sizeof (pid_t) < sizeof (pid) && pid > INT_MAX))
error (EXIT_FAILURE, 0, gettext ("invalid process ID '%s'"),
argv[remaining]);
/* Determine the program name. */
- char buf[11 + 3 * sizeof (pid)];
- snprintf (buf, sizeof (buf), "/proc/%lu/exe", (unsigned long int) pid);
+ char buf[7 + 3 * sizeof (pid)];
+ snprintf (buf, sizeof (buf), "/proc/%lu", pid);
+ int dfd = open (buf, O_RDONLY | O_DIRECTORY);
+ if (dfd == -1)
+ error (EXIT_FAILURE, errno, gettext ("cannot open %s"), buf);
+
size_t exesize = 1024;
+#ifdef PATH_MAX
+ exesize = PATH_MAX;
+#endif
exe = alloca (exesize);
ssize_t nexe;
- while ((nexe = readlink (buf, exe, exesize)) == exesize)
+ while ((nexe = readlinkat (dfd, "exe", exe, exesize)) == exesize)
extend_alloca (exe, exesize, 2 * exesize);
if (nexe == -1)
exe = (char *) "<program name undetermined>";
else
exe[nexe] = '\0';
- if (ptrace (PTRACE_ATTACH, pid, NULL, NULL) != 0)
- error (EXIT_FAILURE, errno, gettext ("cannot attach to process %lu"),
- (unsigned long int) pid);
-
- int status = get_process_info (pid);
-
- ptrace (PTRACE_DETACH, pid, NULL, NULL);
+ /* Stop all threads since otherwise the list of loaded modules might
+ change while we are reading it. */
+ struct thread_list
+ {
+ pid_t tid;
+ struct thread_list *next;
+ } *thread_list = NULL;
+
+ int taskfd = openat (dfd, "task", O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+ if (taskfd == 1)
+ error (EXIT_FAILURE, errno, gettext ("cannot open %s/task"), buf);
+ DIR *dir = fdopendir (taskfd);
+ if (dir == NULL)
+ error (EXIT_FAILURE, errno, gettext ("cannot prepare reading %s/task"),
+ buf);
+
+ struct dirent64 *d;
+ while ((d = readdir64 (dir)) != NULL)
+ {
+ if (! isdigit (d->d_name[0]))
+ continue;
+
+ errno = 0;
+ long int tid = strtol (d->d_name, &endp, 10);
+ if (tid < 0 || (tid == ULONG_MAX && errno == ERANGE) || *endp != '\0'
+ || (sizeof (pid_t) < sizeof (pid) && tid > INT_MAX))
+ error (EXIT_FAILURE, 0, gettext ("invalid thread ID '%s'"),
+ d->d_name);
+
+ if (ptrace (PTRACE_ATTACH, tid, NULL, NULL) != 0)
+ {
+ /* There might be a race between reading the directory and
+ threads terminating. Ignore errors attaching to unknown
+ threads unless this is the main thread. */
+ if (errno == ESRCH && tid != pid)
+ continue;
+
+ error (EXIT_FAILURE, errno, gettext ("cannot attach to process %lu"),
+ tid);
+ }
+
+ struct thread_list *newp = alloca (sizeof (*newp));
+ newp->tid = tid;
+ newp->next = thread_list;
+ thread_list = newp;
+ }
+
+ closedir (dir);
+
+ int status = get_process_info (dfd, pid);
+
+ assert (thread_list != NULL);
+ do
+ {
+ ptrace (PTRACE_DETACH, thread_list->tid, NULL, NULL);
+ thread_list = thread_list->next;
+ }
+ while (thread_list != NULL);
+
+ close (dfd);
return status;
}
@@ -167,22 +232,18 @@
static int
-get_process_info (pid_t pid)
-{
- char buf[12 + 3 * sizeof (pid)];
-
- snprintf (buf, sizeof (buf), "/proc/%lu/mem", (unsigned long int) pid);
- memfd = open (buf, O_RDONLY);
+get_process_info (int dfd, long int pid)
+{
+ memfd = openat (dfd, "mem", O_RDONLY);
if (memfd == -1)
goto no_info;
- snprintf (buf, sizeof (buf), "/proc/%lu/exe", (unsigned long int) pid);
- int fd = open (buf, O_RDONLY);
+ int fd = openat (dfd, "exe", O_RDONLY);
if (fd == -1)
{
no_info:
error (0, errno, gettext ("cannot get information about process %lu"),
- (unsigned long int) pid);
+ pid);
return EXIT_FAILURE;
}
@@ -198,13 +259,11 @@
if (memcmp (uehdr.ehdr32.e_ident, ELFMAG, SELFMAG) != 0)
{
- error (0, 0, gettext ("process %lu is no ELF program"),
- (unsigned long int) pid);
+ error (0, 0, gettext ("process %lu is no ELF program"), pid);
return EXIT_FAILURE;
}
- snprintf (buf, sizeof (buf), "/proc/%lu/auxv", (unsigned long int) pid);
- fd = open (buf, O_RDONLY);
+ fd = openat (dfd, "auxv", O_RDONLY);
if (fd == -1)
goto no_info;
@@ -215,7 +274,7 @@
auxv_size += 512;
auxv = xrealloc (auxv, auxv_size);
- ssize_t n = read (fd, auxv, auxv_size);
+ ssize_t n = pread (fd, auxv, auxv_size, 0);
if (n < 0)
goto no_info;
if (n < auxv_size)
@@ -227,8 +286,14 @@
close (fd);
+ int retval;
if (uehdr.ehdr32.e_ident[EI_CLASS] == ELFCLASS32)
- return find_maps32 (pid, &uehdr.ehdr32, auxv, auxv_size);
+ retval = find_maps32 (pid, &uehdr.ehdr32, auxv, auxv_size);
else
- return find_maps64 (pid, &uehdr.ehdr64, auxv, auxv_size);
-}
+ retval = find_maps64 (pid, &uehdr.ehdr64, auxv, auxv_size);
+
+ free (auxv);
+ close (memfd);
+
+ return retval;
+}
Modified: fsf/trunk/libc/nss/makedb.c
==============================================================================
--- fsf/trunk/libc/nss/makedb.c (original)
+++ fsf/trunk/libc/nss/makedb.c Thu Aug 18 00:02:26 2011
@@ -619,7 +619,8 @@
valstrtab[valstrlen++] = '\0';
twalk (valstrtree, copy_valstr);
- for (struct database *db = databases; db != NULL; db = db->next)
+ static struct database *db;
+ for (db = databases; db != NULL; db = db->next)
if (db->nentries != 0)
{
++ndatabases;
@@ -640,10 +641,10 @@
db->keyidxtab = db->hashtable + nhashentries_max;
db->keystrtab = (char *) (db->keyidxtab + nhashentries_max);
- size_t max_chainlength;
- char *wp;
- size_t nhashentries;
- bool copy_string = false;
+ static size_t max_chainlength;
+ static char *wp;
+ static size_t nhashentries;
+ static bool copy_string;
void add_key(const void *nodep, const VISIT which, const int depth)
{
@@ -679,6 +680,7 @@
max_chainlength = MAX (max_chainlength, chainlength);
}
+ copy_string = false;
nhashentries = nhashentries_min;
for (size_t cnt = 0; cnt < TEST_RANGE; ++cnt)
{
Modified: fsf/trunk/libc/resolv/Makefile
==============================================================================
--- fsf/trunk/libc/resolv/Makefile (original)
+++ fsf/trunk/libc/resolv/Makefile Thu Aug 18 00:02:26 2011
@@ -76,6 +76,9 @@
-Dgetnetbyname=res_getnetbyname \
-Dgetnetbyaddr=res_getnetbyaddr
+ifeq (yes,$(have-ssp))
+CFLAGS-libresolv += -fstack-protector
+endif
CFLAGS-res_hconf.c = -fexceptions
# The BIND code elicits some harmless warnings.
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/Makefile
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/Makefile (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/Makefile Thu Aug 18 00:02:26 2011
@@ -22,7 +22,7 @@
eventfd eventfd_read eventfd_write prlimit
CFLAGS-gethostid.c = -fexceptions
-CFLAGS-tst-writev.c += -DARTIFICIAL_LIMIT=0x7ffff000
+CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=0x80000000-__getpagesize()"
sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
sys/klog.h sys/kdaemon.h \