From patchwork Sat Sep 19 18:05:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Heading X-Patchwork-Id: 519769 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 74C32140187 for ; Sun, 20 Sep 2015 04:05:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=DD6us4xn; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 71BE12F641; Sat, 19 Sep 2015 18:05:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zW2KSsh4W5g8; Sat, 19 Sep 2015 18:05:41 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 8B7912623F; Sat, 19 Sep 2015 18:05:40 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 7BD411C0FF5 for ; Sat, 19 Sep 2015 18:05:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 770A189032 for ; Sat, 19 Sep 2015 18:05:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1byvZ6bFysww for ; Sat, 19 Sep 2015 18:05:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by whitealder.osuosl.org (Postfix) with ESMTPS id 8149188CEF for ; Sat, 19 Sep 2015 18:05:37 +0000 (UTC) Received: by wicgb1 with SMTP id gb1so67563288wic.1 for ; Sat, 19 Sep 2015 11:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=woWMWKiUC0jseZW8Y9QPmK/qeGIRngKu3Xe6VPp9HVM=; b=DD6us4xnzYq4wn5Ta23q9yggiDWSE4tny91RPw+uw1NBF1yaJLFf3BDbyNqtGnvWHX C1MeSTW7+iUqMx873I3T5vjY5ihIOB+snq/MQQw6KLNQ7n16JFZeE91Pd8V76+4OFg8o iumo6Rh5rrKwdN6FlARHfPPB3rRfWzbOU8UMJrr6yoEoqDsWCGgs78Vp2KOsNMA6wXsa Cn+jssIw9ujli/Mz3UKYJw7IlthnRQjP7FXCTZw26u90Y1YY0ZdJTvu0jqymfJB/0uXe 3vTjJOounL9Nx80+QeOcO2xmuN6sUO5LWx2WeG3Xr+rii87tF8OUK8/254OVIjp4z28W eBHg== X-Received: by 10.195.11.202 with SMTP id ek10mr15095244wjd.12.1442685936187; Sat, 19 Sep 2015 11:05:36 -0700 (PDT) Received: from bhfedora.localdomain ([82.15.84.251]) by smtp.gmail.com with ESMTPSA id kr10sm1580846wjc.25.2015.09.19.11.05.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Sep 2015 11:05:35 -0700 (PDT) From: Brendan Heading To: buildroot@buildroot.org Date: Sat, 19 Sep 2015 19:05:31 +0100 Message-Id: <1442685931-20556-1-git-send-email-brendanheading@gmail.com> X-Mailer: git-send-email 2.4.3 Cc: Brendan Heading Subject: [Buildroot] [PATCH RFC v1 1/1] gcc: improve checking of stack smashing support with uclibc X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Fixes: http://autobuild.buildroot.net/results/123/123a5b3f72ba8c1a4aa1cea5b7b846a04fd4e923/ http://autobuild.buildroot.net/results/38c/38cfa4e7249a8770b06dbd392acba79303d3f9bc/ .. and others. Improve GCC's checking of stack smashing support, adding a specific case statement for uclibc, and removing the check done after checking the glibc version. Signed-off-by: Brendan Heading --- Patch V1 - this initial version only fixes 4.7.4 - wanted to check that we are heading the right way before I fix all the other versions. Note that I manually modified configure, rather than regenerating it from configure.ac. Original plan was to reverse the order of the existing __GLIBC_MINOR__ and uclibc check. However, the uclibc check falls through if it does not detect uclibc, so I figure it better to add the separate case statement. --- ...ing-of-stack-smashing-support-with-uclibc.patch | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 package/gcc/4.7.4/920-gcc-improve-checking-of-stack-smashing-support-with-uclibc.patch diff --git a/package/gcc/4.7.4/920-gcc-improve-checking-of-stack-smashing-support-with-uclibc.patch b/package/gcc/4.7.4/920-gcc-improve-checking-of-stack-smashing-support-with-uclibc.patch new file mode 100644 index 0000000..8f5d961 --- /dev/null +++ b/package/gcc/4.7.4/920-gcc-improve-checking-of-stack-smashing-support-with-uclibc.patch @@ -0,0 +1,81 @@ +From 39bbd72364c34da7ba78f26354512eb5229cebdc Mon Sep 17 00:00:00 2001 +From: Brendan Heading +Date: Fri, 18 Sep 2015 14:54:25 +0100 +Subject: [PATCH 1/1] gcc: improve checking of stack smashing support with + uclibc + +Signed-off-by: Brendan Heading +--- + gcc/configure | 15 +++++++++------ + gcc/configure.ac | 15 +++++++++------ + 2 files changed, 18 insertions(+), 12 deletions(-) + +diff --git a/gcc/configure b/gcc/configure +index 63cba0a..d1ac2ea 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -26797,6 +26797,15 @@ else + *-*-musl*) + # All versions of musl provide stack protector + gcc_cv_libc_provides_ssp=yes;; ++ *-*-uclibc*) ++ if $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC__[ ]+1' \ ++ $target_header_dir/features.h > /dev/null && \ ++ test -f $target_header_dir/bits/uClibc_config.h && \ ++ $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC_HAS_SSP__[ ]+1' \ ++ $target_header_dir/bits/uClibc_config.h > /dev/null; then ++ gcc_cv_libc_provides_ssp=yes ++ fi ++ ;; + *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu) + # glibc 2.4 and later provides __stack_chk_fail and + # either __stack_chk_guard, or TLS access to stack guard canary. +@@ -26811,12 +26820,6 @@ else + && $EGREP '^[ ]*#[ ]*define[ ]+__GLIBC_MINOR__[ ]+([1-9][0-9]|[4-9])' \ + $target_header_dir/features.h > /dev/null; then + gcc_cv_libc_provides_ssp=yes +- elif $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC__[ ]+1' \ +- $target_header_dir/features.h > /dev/null && \ +- test -f $target_header_dir/bits/uClibc_config.h && \ +- $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC_HAS_SSP__[ ]+1' \ +- $target_header_dir/bits/uClibc_config.h > /dev/null; then +- gcc_cv_libc_provides_ssp=yes + fi + # all versions of Bionic support stack protector + elif test -f $target_header_dir/sys/cdefs.h \ +diff --git a/gcc/configure.ac b/gcc/configure.ac +index ea1c147..5954cc7 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -4672,6 +4672,15 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library, + *-*-musl*) + # All versions of musl provide stack protector + gcc_cv_libc_provides_ssp=yes;; ++ *-*-uclibc*) ++ if $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC__[ ]+1' \ ++ $target_header_dir/features.h > /dev/null && \ ++ test -f $target_header_dir/bits/uClibc_config.h && \ ++ $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC_HAS_SSP__[ ]+1' \ ++ $target_header_dir/bits/uClibc_config.h > /dev/null; then ++ gcc_cv_libc_provides_ssp=yes ++ fi ++ ;; + *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu) + [# glibc 2.4 and later provides __stack_chk_fail and + # either __stack_chk_guard, or TLS access to stack guard canary. +@@ -4686,12 +4695,6 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library, + && $EGREP '^[ ]*#[ ]*define[ ]+__GLIBC_MINOR__[ ]+([1-9][0-9]|[4-9])' \ + $target_header_dir/features.h > /dev/null; then + gcc_cv_libc_provides_ssp=yes +- elif $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC__[ ]+1' \ +- $target_header_dir/features.h > /dev/null && \ +- test -f $target_header_dir/bits/uClibc_config.h && \ +- $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC_HAS_SSP__[ ]+1' \ +- $target_header_dir/bits/uClibc_config.h > /dev/null; then +- gcc_cv_libc_provides_ssp=yes + fi + # all versions of Bionic support stack protector + elif test -f $target_header_dir/sys/cdefs.h \ +-- +2.4.3 +