Skip to content

Commit

Permalink
Merge commit 'origin/master' into fedora/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Schwab committed Aug 3, 2009
2 parents 50f823e + 4a13776 commit 2b7f0f7
Show file tree
Hide file tree
Showing 28 changed files with 632 additions and 229 deletions.
71 changes: 71 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,74 @@
2009-08-02 Ulrich Drepper <drepper@redhat.com>

* sysdeps/i386/configure.in: Add test for <cpuid.h>.

2009-07-31 Ulrich Drepper <drepper@redhat.com>

* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S (longjmp_msg): Yet
another rewrite. Much smaller and faster.
* sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: Likewise.

* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S (longjmp_msg): Get
ss_flags from the correct location.

2009-07-31 H.J. Lu <hongjiu.lu@intel.com>

* sysdeps/i386/i686/Makefile (sysdep_routines): Add cacheinfo.
* sysdeps/i386/i686/cacheinfo.c: New file.
* sysdeps/i386/i686/multiarch/Makefile: New file.
* sysdeps/i386/i686/multiarch/ifunc-defines.sym: New file.
* sysdeps/i386/i686/multiarch/init-arch.c: New file.
* sysdeps/i386/i686/multiarch/init-arch.h: New file.
* sysdeps/i386/i686/multiarch/sched_cpucount.c: New file.
* sysdeps/unix/sysv/linux/i386/i686/sysconf.c: New file.
* sysdeps/x86_64/cacheinfo.c: Include <cpuid.h>.
(__cpuid_count): New. Provide the default.
(__x86_64_prefetchw): Define only if DISABLE_PREFETCHW is not defined.
(__x86_64_preferred_memory_instruction): Define only if
DISABLE_PREFERRED_MEMORY_INSTRUCTION is not defined.
(intel_check_word): Use __cpuid.
(handle_intel): Likewise.
(handle_amd): Likewise.
(__cache_sysconf): Likewise.
(init_cacheinfo): Updated. Use __cpuid and __cpuid_count.
(__cache_sysconf): Likewise.
(init_cacheinfo): Updated. Use __cpuid and __cpuid_count.
* sysdeps/x86_64/multiarch/init-arch.c: Include <cpuid.h>.
(get_common_indeces): Use __cpuid.
(__init_cpu_features): Likewise. Disable SSSE3 on Atom only
if ENABLE_SSSE3_ON_ATOM is not defined.
* sysdeps/x86_64/multiarch/init-arch.h (HAS_SSE2): Define.
* sysdeps/x86_64/multiarch/sched_cpucount.c (POPCNT): Use
popcnt instead of popcntq.

2009-07-31 Jakub Jelinek <jakub@redhat.com>

* malloc/Makefile (CFLAGS-obstack.c): Add $(uses-callbacks).

2009-07-30 Ulrich Drepper <drepper@redhat.com>

* sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: New file.
* sysdeps/i386/____longjmp_chk.S: Remove all code. This is now a file
which always causes a compile error.

* sysdeps/i386/__longjmp.S: Remove bound-checking pointer support.

* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: New file. Content
comes from...
* sysdeps/x86_64/____longjmp_chk.S: ...here. This is now a file
which always causes a compile error.

* debug/Makefile (tests): Add tst-longjmp_chk2.
* debug/tst-longjmp_chk2.c: New file.

* sysdeps/x86_64/__longjmp.S: Remove CHECK_RSP handling. Fix CFI.
Remove incorrect use of BP_SYM.
* sysdeps/x86_64/____longjmp_chk.S: Rewrite. Complete implementation
here now since it is more complex than just a simple check.

* sysdeps/ia64/backtrace.c (backtrace_helper): Stop backtrace when
we make no more progress.

2009-07-29 Ulrich Drepper <drepper@redhat.com>

* math/s_fma.c: Don't define alias if __fma is a macro.
Expand Down
5 changes: 4 additions & 1 deletion debug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ CFLAGS-recv_chk.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-tst-longjmp_chk.c = -fexceptions -fasynchronous-unwind-tables \
-D_FORTIFY_SOURCE=1
CFLAGS-tst-longjmp_chk2.c = -fexceptions -fasynchronous-unwind-tables \
-D_FORTIFY_SOURCE=1

# We know these tests have problems with format strings, this is what
# we are testing. Disable that warning.
Expand Down Expand Up @@ -118,7 +120,8 @@ LDFLAGS-tst-lfschk6 = -lstdc++

tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6
tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6 \
tst-longjmp_chk2

extra-libs = libSegFault libpcprofile
extra-libs-others = $(extra-libs)
Expand Down
114 changes: 114 additions & 0 deletions debug/tst-longjmp_chk2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/* Test case mostly written by Paolo Bonzini <pbonzini@redhat.com>. */
#include <assert.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>


static jmp_buf mainloop;
static sigset_t mainsigset;
static int pass;


static void
stackoverflow_handler (int sig)
{
stack_t altstack;
pass++;
sigaltstack (NULL, &altstack);
/* Using printf is not really kosher in signal handlers but we know
it will work. */
printf ("%*sin signal handler\n", pass, "");
if (altstack.ss_flags & SS_ONSTACK)
printf ("%*son alternate stack\n", pass, "");
siglongjmp (mainloop, pass);
}


static volatile int *
recurse_1 (int n, volatile int *p)
{
if (n >= 0)
*recurse_1 (n + 1, p) += n;
return p;
}


static int
recurse (int n)
{
int sum = 0;
return *recurse_1 (n, &sum);
}


static int
do_test (void)
{
char mystack[SIGSTKSZ];
stack_t altstack;
struct sigaction action;
sigset_t emptyset;
/* Before starting the endless recursion, try to be friendly to the user's
machine. On some Linux 2.2.x systems, there is no stack limit for user
processes at all. We don't want to kill such systems. */
struct rlimit rl;
rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */
setrlimit (RLIMIT_STACK, &rl);
/* Install the alternate stack. */
altstack.ss_sp = mystack;
altstack.ss_size = sizeof (mystack);
altstack.ss_flags = 0; /* no SS_DISABLE */
if (sigaltstack (&altstack, NULL) < 0)
{
puts ("first sigaltstack failed");
return 0;
}
/* Install the SIGSEGV handler. */
sigemptyset (&action.sa_mask);
action.sa_handler = &stackoverflow_handler;
action.sa_flags = SA_ONSTACK;
sigaction (SIGSEGV, &action, (struct sigaction *) NULL);
sigaction (SIGBUS, &action, (struct sigaction *) NULL);

/* Save the current signal mask. */
sigemptyset (&emptyset);
sigprocmask (SIG_BLOCK, &emptyset, &mainsigset);

/* Provoke two stack overflows in a row. */
if (sigsetjmp (mainloop, 1) != 0)
{
assert (pass != 0);
printf ("%*sout of signal handler\n", pass, "");
}
else
assert (pass == 0);

sigaltstack (NULL, &altstack);
if (altstack.ss_flags & SS_ONSTACK)
printf ("%*son alternate stack\n", pass, "");
else
printf ("%*snot on alternate stack\n", pass, "");

if (pass < 2)
{
recurse (0);
puts ("recurse call returned");
return 2;
}

altstack.ss_flags |= SS_DISABLE;
if (sigaltstack (&altstack, NULL) == -1)
printf ("disabling alternate stack failed\n");
else
printf ("disabling alternate stack succeeded \n");

return 0;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
1 change: 1 addition & 0 deletions malloc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ $(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o)
include ../Rules

CFLAGS-mcheck-init.c = $(PIC-ccflag)
CFLAGS-obstack.c = $(uses-callbacks)

$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
-rm -f $@
Expand Down
4 changes: 4 additions & 0 deletions nptl/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2009-07-31 Ulrich Drepper <drepper@redhat.com>

* descr.h: Better definition of *_BITMASK macros for cancellation.

2009-07-29 Ulrich Drepper <drepper@redhat.com>

* sysdeps/x86_64/tls.h (TLS_TCB_ALIGN): Define explicitly to 32.
Expand Down
16 changes: 8 additions & 8 deletions nptl/descr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002-2006, 2007, 2008 Free Software Foundation, Inc.
/* Copyright (C) 2002-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -243,25 +243,25 @@ struct pthread
int cancelhandling;
/* Bit set if cancellation is disabled. */
#define CANCELSTATE_BIT 0
#define CANCELSTATE_BITMASK 0x01
#define CANCELSTATE_BITMASK (0x01 << CANCELSTATE_BIT)
/* Bit set if asynchronous cancellation mode is selected. */
#define CANCELTYPE_BIT 1
#define CANCELTYPE_BITMASK 0x02
#define CANCELTYPE_BITMASK (0x01 << CANCELTYPE_BIT)
/* Bit set if canceling has been initiated. */
#define CANCELING_BIT 2
#define CANCELING_BITMASK 0x04
#define CANCELING_BITMASK (0x01 << CANCELING_BIT)
/* Bit set if canceled. */
#define CANCELED_BIT 3
#define CANCELED_BITMASK 0x08
#define CANCELED_BITMASK (0x01 << CANCELED_BIT)
/* Bit set if thread is exiting. */
#define EXITING_BIT 4
#define EXITING_BITMASK 0x10
#define EXITING_BITMASK (0x01 << EXITING_BIT)
/* Bit set if thread terminated and TCB is freed. */
#define TERMINATED_BIT 5
#define TERMINATED_BITMASK 0x20
#define TERMINATED_BITMASK (0x01 << TERMINATED_BIT)
/* Bit set if thread is supposed to change XID. */
#define SETXID_BIT 6
#define SETXID_BITMASK 0x40
#define SETXID_BITMASK (0x01 << SETXID_BIT)
/* Mask for the rest. Helps the compiler to optimize. */
#define CANCEL_RESTMASK 0xffffff80

Expand Down
48 changes: 40 additions & 8 deletions nptl/sysdeps/x86_64/configure
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi

# This file is generated from configure.in by Autoconf. DO NOT EDIT!
# Local configure fragment for sysdeps/i386.

{ echo "$as_me:$LINENO: checking for .cfi_personality and .cfi_lsda pseudo-ops" >&5
echo $ECHO_N "checking for .cfi_personality and .cfi_lsda pseudo-ops... $ECHO_C" >&6; }
{ $as_echo "$as_me:$LINENO: checking for .cfi_personality and .cfi_lsda pseudo-ops" >&5
$as_echo_n "checking for .cfi_personality and .cfi_lsda pseudo-ops... " >&6; }
if test "${libc_cv_asm_cfi_personality+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
$as_echo_n "(cached) " >&6
else
cat > conftest.s <<EOF
${libc_cv_dot_text}
Expand All @@ -18,7 +50,7 @@ EOF
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
libc_cv_asm_cfi_personality=yes
else
Expand All @@ -27,10 +59,10 @@ EOF
rm -f conftest*

fi
{ echo "$as_me:$LINENO: result: $libc_cv_asm_cfi_personality" >&5
echo "${ECHO_T}$libc_cv_asm_cfi_personality" >&6; }
{ $as_echo "$as_me:$LINENO: result: $libc_cv_asm_cfi_personality" >&5
$as_echo "$libc_cv_asm_cfi_personality" >&6; }
if test x"$libc_cv_asm_cfi_personality" != xyes; then
{ { echo "$as_me:$LINENO: error: assembler too old, .cfi_personality support missing" >&5
echo "$as_me: error: assembler too old, .cfi_personality support missing" >&2;}
{ { $as_echo "$as_me:$LINENO: error: assembler too old, .cfi_personality support missing" >&5
$as_echo "$as_me: error: assembler too old, .cfi_personality support missing" >&2;}
{ (exit 1); exit 1; }; }
fi
46 changes: 1 addition & 45 deletions sysdeps/i386/____longjmp_chk.S
Original file line number Diff line number Diff line change
@@ -1,45 +1 @@
/* Copyright (C) 2001,2004,2005,2006,2009 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
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

.section .rodata.str1.1,"aMS",@progbits,1
.type longjmp_msg,@object
longjmp_msg:
.string "longjmp causes uninitialized stack frame"
.size longjmp_msg, .-longjmp_msg


#define __longjmp ____longjmp_chk

#ifdef PIC
# define CALL_FAIL movl %ebx, %ecx; \
cfi_register(%ebx,%ecx); \
LOAD_PIC_REG (bx); \
leal longjmp_msg@GOTOFF(%ebx), %eax; \
call __GI___fortify_fail@PLT
#else
# define CALL_FAIL movl $longjmp_msg, %eax; \
call __fortify_fail
#endif

#define CHECK_ESP(reg) \
cmpl reg, %esp; \
jbe .Lok; \
CALL_FAIL; \
.Lok:

#include "__longjmp.S"
#error "OS-specific version needed"
Loading

0 comments on commit 2b7f0f7

Please sign in to comment.