public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: devel@edk2.groups.io, "Marvin Häuser" <mhaeuser@posteo.de>,
	"Pawel Polawski" <ppolawsk@redhat.com>,
	"Dongyan Qian" <qiandongyan@loongson.cn>,
	"Sunil V L" <sunilvl@ventanamicro.com>,
	"Baoqi Zhang" <zhangbaoqi@loongson.cn>,
	"Chao Li" <lichao@loongson.cn>,
	"Rebecca Cran" <rebecca@bsdio.com>,
	"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
	"Zhiguang Liu" <zhiguang.liu@intel.com>,
	"Liming Gao" <gaoliming@byosoft.com.cn>,
	"Yuwei Chen" <yuwei.chen@intel.com>,
	"Leif Lindholm" <quic_llindhol@quicinc.com>,
	"Michael D Kinney" <michael.d.kinney@intel.com>,
	"Daniel Schaefer" <git@danielschaefer.me>,
	"Bob Feng" <bob.c.feng@intel.com>,
	"Oliver Steffen" <osteffen@redhat.com>
Subject: Re: [edk2-devel] [PATCH v4 01/10] BaseTools: add BASETOOLS define
Date: Tue, 23 May 2023 09:07:45 +0200	[thread overview]
Message-ID: <CAMj1kXGrJKd97XEAp-rSyzoNWN5PhZhU6BvsdWBe8+2O_YHU9g@mail.gmail.com> (raw)
In-Reply-To: <fbiq64vcdsxxzmji3hcrnqjb5d6rpucqgjzkwmhulpi3ztya6y@xfrfgck2ltz2>

On Mon, 22 May 2023 at 16:31, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
>   Hi,
>
> > > Recent clang does have a '-fdirect-access-external-data' switch which
> > > should suppress these references, maybe in combination with
> > > -fvisibility=hidden?
> >
> > I'll try that.
>
> Works (test patch below for reference).
>

Excellent, thanks for confirming.

So basically, -fdirect-access-external-data forces the behavior in
Clang that became the default behavior in GCC 5, which is to assume
that an external variable reference can be resolved without the GOT,
which is usually true for hosted binaries (given that shared libraries
rarely export data symbols but only code symbols, so data symbols can
be assumed to be part of the same executable). It is always true for
EDK2 as we don't use runtime linking at all.

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.




>
> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> index 503a6687c1f0..f19992f68a84 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -1929,7 +1929,7 @@ RELEASE_CLANGDWARF_X64_CC_FLAGS       = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFI
>  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 -O0 DEF(CLANGDWARF_X64_TARGET) -g -fdirect-access-external-data
>  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
>
>

  reply	other threads:[~2023-05-23  7:08 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14  8:02 [PATCH v4 00/10] BaseTools: remove duplicate includes Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 01/10] BaseTools: add BASETOOLS define Gerd Hoffmann
2023-04-14 12:29   ` Marvin Häuser
2023-04-14 14:37     ` Gerd Hoffmann
2023-04-14 14:51       ` Marvin Häuser
2023-04-14 14:57       ` [edk2-devel] " Ard Biesheuvel
2023-04-14 15:10         ` Marvin Häuser
2023-04-18 11:52         ` Gerd Hoffmann
2023-04-18 11:59           ` Ard Biesheuvel
2023-04-18 13:20             ` Gerd Hoffmann
2023-04-18 13:41               ` Marvin Häuser
2023-04-18 15:50               ` Ard Biesheuvel
2023-04-21  3:26                 ` 回复: " gaoliming
2023-05-22 12:27         ` Gerd Hoffmann
2023-05-22 12:55           ` Ard Biesheuvel
2023-05-22 13:38             ` Gerd Hoffmann
2023-05-22 14:31               ` Gerd Hoffmann
2023-05-23  7:07                 ` Ard Biesheuvel [this message]
2023-05-23  8:49                   ` Gerd Hoffmann
2023-05-23  8:54                     ` Ard Biesheuvel
2023-04-14  8:02 ` [PATCH v4 02/10] MdePkg: don't set visibility to hidden for BaseTools Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 03/10] BaseTools: remove WinNtInclude.h Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 04/10] BaseTools: remove duplicate includes: <arch>/ProcessorBind.h Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 05/10] BaseTools: remove duplicate includes: IndustryStandard/Acpi*.h Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 06/10] MdePkg/PeImage.h: add bits from BaseTools version Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 07/10] BaseTools: drop IMAGE_FILE_MACHINE_ARM hacks Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 08/10] BaseTools: switch from EFI_IMAGE_MACHINE_* to IMAGE_FILE_MACHINE_* Gerd Hoffmann
2023-04-14 12:16   ` [edk2-devel] " Rebecca Cran
2023-04-14 14:39     ` Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 09/10] BaseTools: remove duplicate includes: IndustryStandard/PeImage.h Gerd Hoffmann
2023-04-14  8:02 ` [PATCH v4 10/10] BaseTools: remove duplicate includes: IndustryStandard/*.h Gerd Hoffmann
2023-04-14 12:18 ` [edk2-devel] [PATCH v4 00/10] BaseTools: remove duplicate includes Rebecca Cran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMj1kXGrJKd97XEAp-rSyzoNWN5PhZhU6BvsdWBe8+2O_YHU9g@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox