From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Miapb-0008Go-3b for mharc-grub-devel@gnu.org; Tue, 01 Sep 2009 17:23:59 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MiapZ-0008GI-SF for grub-devel@gnu.org; Tue, 01 Sep 2009 17:23:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MiapY-0008FR-6n for grub-devel@gnu.org; Tue, 01 Sep 2009 17:23:57 -0400 Received: from [199.232.76.173] (port=54065 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MiapY-0008FL-2m for grub-devel@gnu.org; Tue, 01 Sep 2009 17:23:56 -0400 Received: from mx20.gnu.org ([199.232.41.8]:45207) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MiapX-0000TJ-MT for grub-devel@gnu.org; Tue, 01 Sep 2009 17:23:55 -0400 Received: from ip1-68.bon.riksnet.se ([77.110.8.68] helo=micha.ume.nu) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MiapV-0007qQ-A5 for grub-devel@gnu.org; Tue, 01 Sep 2009 17:23:53 -0400 Received: from localhost (micha.ume.nu [127.0.0.1]) by micha.ume.nu (Postfix) with ESMTP id 7BDDF149A3 for ; Wed, 2 Sep 2009 00:13:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at ume.nu Received: from micha.ume.nu ([127.0.0.1]) by localhost (micha.ume.nu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id fLUPozzfbalp for ; Wed, 2 Sep 2009 00:13:40 +0200 (CEST) Received: from laptop1.localnet (ip1-67.bon.riksnet.se [77.110.8.67]) by micha.ume.nu (Postfix) with ESMTP id 2DC0014938 for ; Wed, 2 Sep 2009 00:13:40 +0200 (CEST) From: Magnus Granberg Organization: Ume.nu To: grub-devel@gnu.org Date: Tue, 1 Sep 2009 23:46:21 +0200 User-Agent: KMail/1.12.0 (Linux/2.6.30-gentoo-r5; KDE/4.3.0; x86_64; ; ) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200909012346.21400.zorry@ume.nu> X-Detected-Operating-System: by mx20.gnu.org: Genre and OS details not recognized. X-Greylist: delayed 1461 seconds by postgrey-1.27 at nadesico; Tue, 01 Sep 2009 17:23:51 EDT X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [PATCH] Some distributions ship compilers that include -fPIE in the default specs (Gentoo Hardened) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 21:23:58 -0000 Hi On Gentoo Hardened we compile with -fPIE in the default specs and grub fails to compile. This patch check if the compiler use -fPIE in the default specs and add -fno-PIE to TARGET_CFLAGS. --- aclocal.m4.zorry 2008-02-03 14:11:28.000000000 +0100 +++ aclocal.m4 2009-08-22 01:05:56.000000000 +0200 @@ -362,3 +362,31 @@ AC_MSG_RESULT([no]) [fi] ]) + +dnl Check if the C compiler supports `-fPIE'. +AC_DEFUN(grub_CHECK_PIE,[ +[# Position independent executable. +pie_possible=yes] +AC_MSG_CHECKING([whether `$CC' has `-fPIE' as default]) +# Is this a reliable test case? +AC_LANG_CONFTEST([[ +#ifdef __PIE__ +int main() { + return 0; +} +#else +#error NO __PIE__ DEFINED +#endif +]]) + +[# `$CC -c -o ...' might not be portable. But, oh, well... Is calling +# `ac_compile' like this correct, after all? +if eval "$ac_compile -S -o conftest.s" 2> /dev/null; then] + AC_MSG_RESULT([yes]) + [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? + rm -f conftest.s +else + pie_possible=no] + AC_MSG_RESULT([no]) +[fi] +]) --- configure.ac.zorry 2008-02-03 14:41:51.000000000 +0100 +++ configure.ac 2009-09-01 01:05:34.000000000 +0200 @@ -251,6 +251,14 @@ # Compiler features. # +# Position independent executable. +grub_CHECK_PIE +[# Need that, because some distributions ship compilers that include +# `-fPIE' in the default specs. +if [ x"$pie_possible" = xyes ]; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" +fi] + # Smashing stack protector. grub_CHECK_STACK_PROTECTOR [# Need that, because some distributions ship compilers that include --- Hardened-Development Overlay Magnus Granberg (Zorry)