From: "Jan Beulich" Subject: [PATCH] x86-64: suppress some unneeded side effects of -fPIC Date: Tue, 12 Sep 2006 16:43:56 +0100 Message-ID: <4506F1DC.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Full PIC mode isn't needed for Xen, namely is there no need to access data objects via the GOT or call functions through the PLT. Adding -fvisibility=hidden (if the compiler supports it) helps, although it doesn't do as good a job as would be desired (I'm in talks with our compiler guys to understand why). Signed-off-by: Jan Beulich Index: 2006-09-11/xen/arch/x86/Rules.mk =================================================================== --- 2006-09-11.orig/xen/arch/x86/Rules.mk 2006-08-21 18:02:23.000000000 +0200 +++ 2006-09-11/xen/arch/x86/Rules.mk 2006-09-12 17:32:14.000000000 +0200 @@ -11,6 +11,23 @@ HAS_VGA := y pae ?= n supervisor_mode_kernel ?= n +# Test for at least GCC v3.2.x. +gcc-ver = $(shell $(CC) -dumpversion | sed -e 's/^\(.\)\.\(.\)\.\(.\)/\$(1)/') +ifeq ($(call gcc-ver,1),1) +$(error gcc-1.x.x unsupported - upgrade to at least gcc-3.2.x) +endif +ifeq ($(call gcc-ver,1),2) +$(error gcc-2.x.x unsupported - upgrade to at least gcc-3.2.x) +endif +ifeq ($(call gcc-ver,1),3) +ifeq ($(call gcc-ver,2),0) +$(error gcc-3.0.x unsupported - upgrade to at least gcc-3.2.x) +endif +ifeq ($(call gcc-ver,2),1) +$(error gcc-3.1.x unsupported - upgrade to at least gcc-3.2.x) +endif +endif + CFLAGS += -nostdinc -fno-builtin -fno-common -fno-strict-aliasing CFLAGS += -iwithprefix include -Werror -Wno-pointer-arith -pipe CFLAGS += -I$(BASEDIR)/include @@ -41,6 +58,9 @@ endif ifeq ($(TARGET_SUBARCH),x86_64) CFLAGS += -mno-red-zone -fpic -fno-reorder-blocks +ifneq ($(call gcc-ver,1),3) +CFLAGS += -fvisibility=hidden +endif CFLAGS += -fno-asynchronous-unwind-tables LDFLAGS += -m elf_x86_64 x86_32 := n @@ -50,20 +70,3 @@ endif HDRS += $(wildcard $(BASEDIR)/include/asm-x86/hvm/*.h) HDRS += $(wildcard $(BASEDIR)/include/asm-x86/hvm/svm/*.h) HDRS += $(wildcard $(BASEDIR)/include/asm-x86/hvm/vmx/*.h) - -# Test for at least GCC v3.2.x. -gcc-ver = $(shell $(CC) -dumpversion | sed -e 's/^\(.\)\.\(.\)\.\(.\)/\$(1)/') -ifeq ($(call gcc-ver,1),1) -$(error gcc-1.x.x unsupported - upgrade to at least gcc-3.2.x) -endif -ifeq ($(call gcc-ver,1),2) -$(error gcc-2.x.x unsupported - upgrade to at least gcc-3.2.x) -endif -ifeq ($(call gcc-ver,1),3) -ifeq ($(call gcc-ver,2),0) -$(error gcc-3.0.x unsupported - upgrade to at least gcc-3.2.x) -endif -ifeq ($(call gcc-ver,2),1) -$(error gcc-3.1.x unsupported - upgrade to at least gcc-3.2.x) -endif -endif