* Re: [edk2-devel] [PATCH] OvmfPkg: strip build paths in release builds
2021-03-17 15:39 [PATCH] OvmfPkg: strip build paths in release builds Ross Burton
@ 2021-03-18 14:58 ` Laszlo Ersek
0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2021-03-18 14:58 UTC (permalink / raw)
To: devel, ross
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.
>
^ permalink raw reply [flat|nested] 2+ messages in thread