public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, ross@burtonini.com
Subject: Re: [edk2-devel] [PATCH] OvmfPkg: strip build paths in release builds
Date: Thu, 18 Mar 2021 15:58:01 +0100	[thread overview]
Message-ID: <0196707e-7d7d-e8ad-c40c-dce6f9883ff3@redhat.com> (raw)
In-Reply-To: <20210317153918.591140-1-ross.burton@arm.com>

On 03/17/21 16:39, Ross Burton wrote:
> GenFw will embed a NM10 section which contains the path to the input file,

(1) typo: should be NB10.

> which means the output files have build paths embedded in them.  To reduce
> information leakage and ensure reproducible builds, pass --zero in release
> builds to remove this information.
>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3256
> Change-Id: Ie607893b979674e237cf04ead5c7690d7b1aedaf

(2) "Change-Id" is useless upstream, please drop it.

> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  OvmfPkg/AmdSev/AmdSevX64.dsc | 1 +
>  OvmfPkg/Bhyve/BhyveX64.dsc   | 1 +
>  OvmfPkg/OvmfPkgIa32.dsc      | 2 ++
>  OvmfPkg/OvmfPkgIa32X64.dsc   | 1 +
>  OvmfPkg/OvmfPkgX64.dsc       | 1 +
>  OvmfPkg/OvmfXen.dsc          | 1 +
>  6 files changed, 7 insertions(+)
>
> diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
> index 65c42284d9..69a05feea9 100644
> --- a/OvmfPkg/AmdSev/AmdSevX64.dsc
> +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
> @@ -78,6 +78,7 @@
>    GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
>    INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
>  !endif
> +  RELEASE_*_*_GENFW_FLAGS = --zero
>
>    #
>    # Disable deprecated APIs.
> diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
> index 4a1cdf5aca..132f55cf69 100644
> --- a/OvmfPkg/Bhyve/BhyveX64.dsc
> +++ b/OvmfPkg/Bhyve/BhyveX64.dsc
> @@ -76,6 +76,7 @@
>    GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
>    INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
>  !endif
> +  RELEASE_*_*_GENFW_FLAGS = --zero
>
>    #
>    # Disable deprecated APIs.
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 1eaf3e99c6..ce20f09df8 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -90,6 +90,8 @@
>
>  !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> +  RELEASE_*_*_GENFW_FLAGS = --zero
> +
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>    GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>    XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000

(3) The placement of this build option hampers the diffability between
OvmfPkgIa32.dsc and {OvmfPkgIa32X64.dsc, OvmfPkgX64.dsc}.

For example, if we diff OvmfPkgIa32.dsc and OvmfPkgIa32X64.dsc right
now, we get a nice hunk like:

> @@ -80,6 +79,11 @@
>  !if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANGPDB"
>    GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
>  !endif
> +!if $(SOURCE_DEBUG_ENABLE) == TRUE
> +  MSFT:*_*_X64_GENFW_FLAGS  = --keepexceptiontable
> +  GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
> +  INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
> +!endif
>
>    #
>    # Disable deprecated APIs.

Therefore, in the "OvmfPkgIa32.dsc" file, please add the GENFW flags
immediately  after the "!endif" that's visible in the quoted context,
like this:

> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 1eaf3e99c6c5..93c209950c7b 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -80,6 +80,7 @@ [BuildOptions]
>  !if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANGPDB"
>    GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
>  !endif
> +  RELEASE_*_*_GENFW_FLAGS = --zero
>
>    #
>    # Disable deprecated APIs.

Because that should allow for the following difference between Ia32 and
Ia32X64:

> @@ -80,6 +79,11 @@
>  !if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANGPDB"
>    GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
>  !endif
> +!if $(SOURCE_DEBUG_ENABLE) == TRUE
> +  MSFT:*_*_X64_GENFW_FLAGS  = --keepexceptiontable
> +  GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
> +  INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
> +!endif
>    RELEASE_*_*_GENFW_FLAGS = --zero
>
>    #

The rest of the patch looks good to me.

Thanks!
Laszlo


> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 4a5a430147..97cc438250 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -84,6 +84,7 @@
>    GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
>    INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
>  !endif
> +  RELEASE_*_*_GENFW_FLAGS = --zero
>
>    #
>    # Disable deprecated APIs.
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index d4d601b444..f544fb04bf 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -84,6 +84,7 @@
>    GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
>    INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
>  !endif
> +  RELEASE_*_*_GENFW_FLAGS = --zero
>
>    #
>    # Disable deprecated APIs.
> diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
> index 507029404f..fcaa35acf1 100644
> --- a/OvmfPkg/OvmfXen.dsc
> +++ b/OvmfPkg/OvmfXen.dsc
> @@ -74,6 +74,7 @@
>    GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
>    INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
>  !endif
> +  RELEASE_*_*_GENFW_FLAGS = --zero
>
>    #
>    # Disable deprecated APIs.
>


      reply	other threads:[~2021-03-18 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 15:39 [PATCH] OvmfPkg: strip build paths in release builds Ross Burton
2021-03-18 14:58 ` Laszlo Ersek [this message]

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=0196707e-7d7d-e8ad-c40c-dce6f9883ff3@redhat.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