> From: Roger Pau Monne <roger....@citrix.com>
> Sent: Wednesday, March 2, 2022 2:27 PM
> To: xen-devel@lists.xenproject.org <xen-devel@lists.xenproject.org>
> Cc: Ross Lagerwall <ross.lagerw...@citrix.com>; konrad.w...@oracle.com 
> <konrad.w...@oracle.com>; doe...@amazon.de <doe...@amazon.de>; jul...@xen.org 
> <jul...@xen.org>; Andrew Cooper <andrew.coop...@citrix.com>; Roger Pau Monne 
> <roger....@citrix.com>
> Subject: [PATCH 4/4] livepatch: differentiate between old and new build 
> systems 
>  
> Do not attempt to modify the build system if CFLAGS are not set in
> Rules.mk, and instead rely on CONFIG_LIVEPATCH already setting
> -f{function,data}-sections.
> 
> Signed-off-by: Roger Pau Monné <roger....@citrix.com>
> ---
> This depends on getting the patch to add -f{function,data}-sections
> when using CONFIG_LIVEPATCH accepted.
> ---
>  livepatch-build | 22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/livepatch-build b/livepatch-build
> index 38a92be..656cdac 100755
> --- a/livepatch-build
> +++ b/livepatch-build
> @@ -98,14 +98,20 @@ function build_special()
>  
>      # Build with special GCC flags
>      cd "${SRCDIR}/xen" || die
> -    sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections 
> -fdata-sections/' Rules.mk
> -    cp -p arch/x86/Makefile arch/x86/Makefile.bak
> -    sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' 
> arch/x86/Makefile
> -    # Restore timestamps to prevent spurious rebuilding
> -    touch --reference=arch/x86/Makefile.bak arch/x86/Makefile
> -    make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" || die
> -    sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS 
> += -nostdinc/' Rules.mk
> -    mv -f arch/x86/Makefile.bak arch/x86/Makefile
> +    if grep -q 'nostdinc' Rules.mk; then
> +         # Support for old build system, attempt to set 
> -f{function,data}-sections and rebuild
> +        sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc 
> -ffunction-sections -fdata-sections/' Rules.mk
> +        cp -p arch/x86/Makefile arch/x86/Makefile.bak
> +        sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' 
> arch/x86/Makefile
> +        # Restore timestamps to prevent spurious rebuilding
> +        touch --reference=arch/x86/Makefile.bak arch/x86/Makefile
> +        make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" 
> || die
> +        sed -i 's/CFLAGS += -nostdinc -ffunction-sections 
> -fdata-sections/CFLAGS += -nostdinc/' Rules.mk
> +        mv -f arch/x86/Makefile.bak arch/x86/Makefile
> +    else
> +        # -f{function,data}-sections set by CONFIG_LIVEPATCH
> +        make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" 
> || die
> +    fi
>  
>      unset LIVEPATCH_BUILD_DIR
>      unset LIVEPATCH_CAPTURE_DIR
> -- 
> 2.34.1

Reviewed-by: Ross Lagerwall <ross.lagerw...@citrix.com>

Reply via email to