红联Linux门户
Linux帮助

Ubuntu 16.10的gcc的重大改变

发布时间:2016-10-07 11:08:40来源:linux网站作者:astolia
Ubuntu 16.10中的gcc包在编译时开启了--enable-default-pie配置项,导致gcc在编译时是默认开启-fPIE和-pie。
对一般用户程序倒没什么,但是如果自己编译内核的话,就会出各种问题。
 
解决方法是给内核的编译参数加上-fno-pie和-no-pie明确禁止pie,下面是ubuntu官方的补丁文件:
 
From d5281ea1b3cb5a01eda0c2022d2409a2369613a3 Mon Sep 17 00:00:00 2001
From: Steve Beattie <steve.beattie@canonical.com>
Date: Tue, 10 May 2016 12:44:04 +0100
Subject: [PATCH 2/4] UBUNTU: SAUCE: (no-up) disable -pie when gcc has it enabled by default
In Ubuntu 16.10, gcc's defaults have been set to build Position
Independent Executables (PIE) on amd64 and ppc64le (gcc was configured
this way for s390x in Ubuntu 16.04 LTS). This breaks the kernel build on
amd64. The following patch disables pie for x86 builds (though not yet
verified to work with gcc configured to build PIE by default i386 --
we're not planning to enable it for that architecture).
The intent is for this patch to go upstream after expanding it to
additional architectures where needed, but I wanted to ensure that
we could build 16.10 kernels first. I've successfully built kernels
and booted them with this patch applied using the 16.10 compiler.
Patch is against yakkety.git, but also applies with minor movement
(no fuzz) against current linus.git.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
[apw@canonical.com: shifted up so works in arch/<arch/Makefile.]
BugLink: http://bugs.launchpad.net/bugs/1574982
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Acked-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Makefile b/Makefile
index 66da9a3..64fc2d5 100644
--- a/Makefile
+++ b/Makefile
@@ -611,6 +611,12 @@ endif # $(dot-config)
# Defaults to vmlinux, but the arch makefile usually adds further targets
all: vmlinux 
+# force no-pie for distro compilers that enable pie by default
+KBUILD_CFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CFLAGS += $(call cc-option, -no-pie)
+KBUILD_AFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)
+
# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
# values of the respective KBUILD_* variables
ARCH_CPPFLAGS :=
-- 
2.7.4
 
注:debian没有加--enable-default-pie,这是ubuntu自己搞的。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/24822.html