From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.17174.1684832060969745024 for ; Tue, 23 May 2023 01:54:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eBYZER6L; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 765FF623EC for ; Tue, 23 May 2023 08:54:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9385C4339B for ; Tue, 23 May 2023 08:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684832059; bh=WCUcwY1DSqKeXOJDUkkVG+JeP4ZSvqypJki4WxWcny4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=eBYZER6LBUoK3Uctv7B93Fuv3TENAvJaryqFgtkoc3ohVJmIcHEm52BDA4KFitXfW LGK1PAB0aVCYBSZfU1tSB/8DJq+APMi4ovv2HA6ffAJMf2ROr1/6tD0x1NV7b6Zmsb syw994PsK4JohIa+yytp+OMPZrknc4VSbmLICZN0F/9UUm6vrKEn1zOEG+D0H2ljEl G2eU3vVn2JovMd6d9+MG8vLDGlAW5D6xVmHHGKF7VkOY8/T2SQdmJXoqXG69oZhCS0 L5bjLsm57CxDY+A6DRf0eWi+RhFHP+F8owswsrLKD+Lt0Q5Ko7U7/R6YLQLZKlPZTy XvMvBsq5x1hgQ== Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2af7081c9ebso29006951fa.1 for ; Tue, 23 May 2023 01:54:19 -0700 (PDT) X-Gm-Message-State: AC+VfDxKEBDo8+7cYj4cWgf3RooB8G12U6Up6eU3jsI64KrCimrl3thM MptJlxjwZJRKyih54QlM3juEEgpdrfuytZhoenw= X-Google-Smtp-Source: ACHHUZ5jLdB9RVQ/8ITCUTAeRtJ3IER5yfp+wOK89gKAynfDV4gzIDJEuwc7/H0ouWpml/gIduDvmSvqQL9YUpudDAQ= X-Received: by 2002:a2e:b0f7:0:b0:2af:2986:44fb with SMTP id h23-20020a2eb0f7000000b002af298644fbmr3794063ljl.8.1684832057825; Tue, 23 May 2023 01:54:17 -0700 (PDT) MIME-Version: 1.0 References: <20230414080250.1357004-2-kraxel@redhat.com> <18EC1A6E-8B81-4564-83A5-DA8EC2BA54ED@posteo.de> <7twvlm4w6euyc637maj4mqskob5747wfu4tridl4jtxujruegg@r4jyw7vitl3w> In-Reply-To: From: "Ard Biesheuvel" Date: Tue, 23 May 2023 10:54:06 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v4 01/10] BaseTools: add BASETOOLS define To: Gerd Hoffmann Cc: devel@edk2.groups.io, =?UTF-8?Q?Marvin_H=C3=A4user?= , Pawel Polawski , Dongyan Qian , Sunil V L , Baoqi Zhang , Chao Li , Rebecca Cran , Ard Biesheuvel , Zhiguang Liu , Liming Gao , Yuwei Chen , Leif Lindholm , Michael D Kinney , Daniel Schaefer , Bob Feng , Oliver Steffen Content-Type: text/plain; charset="UTF-8" On Tue, 23 May 2023 at 10:50, Gerd Hoffmann wrote: > > Hi, > > > > Works (test patch below for reference). > > > > Excellent, thanks for confirming. > > > > So I think we should add this for all Clang configurations that enable > > PIE codegen. We don't support GCC < 5 anyway so this gives us uniform > > behavior for all ELF based toolchains used for x86. > > Which seems to be only X64, so the patch below should be about right > (doing s/-fpie/-fpie -fdirect-access-external-data/)? > > take care, > Gerd > > From 964965d9da66235e3a29d3735ebdf6c9544b86c3 Mon Sep 17 00:00:00 2001 > From: Gerd Hoffmann > Date: Mon, 22 May 2023 16:35:54 +0200 > Subject: [PATCH 1/1] BaseTools: add -fdirect-access-external-data to clang pie > builds > > Tell clang to not use external (via got) references for data access. > > Signed-off-by: Gerd Hoffmann Reviewed-by: Ard Biesheuvel > --- > BaseTools/Conf/tools_def.template | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template > index 503a6687c1f0..92421e3d0118 100755 > --- a/BaseTools/Conf/tools_def.template > +++ b/BaseTools/Conf/tools_def.template > @@ -1921,15 +1921,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 - > *_CLANGDWARF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_X64_TARGET) > *_CLANGDWARF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_X64_TARGET) > > -DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANGDWARF_X64_TARGET) -g > +DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -Oz -flto DEF(CLANGDWARF_X64_TARGET) -g > DEBUG_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs > DEBUG_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld > > -RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANGDWARF_X64_TARGET) > +RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -Oz -flto DEF(CLANGDWARF_X64_TARGET) > RELEASE_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs > RELEASE_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld > > -NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANGDWARF_X64_TARGET) -g > +NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -O0 DEF(CLANGDWARF_X64_TARGET) -g > NOOPT_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs > NOOPT_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld > > -- > 2.40.1 >