From 120df7f566fab4f86a543cf61ec9679c5b9db62b Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Fri, 26 Nov 2021 15:17:10 +0800 Subject: [PATCH] Enable LTO and Hardened package Release: crash-8.0.0-2 Signed-off-by: Lianbo Jiang --- crash-8.0.0_build.patch | 35 +++++++++++++++++++++++++++++++++++ crash.spec | 17 +++++++---------- 2 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 crash-8.0.0_build.patch diff --git a/crash-8.0.0_build.patch b/crash-8.0.0_build.patch new file mode 100644 index 0000000..12cb747 --- /dev/null +++ b/crash-8.0.0_build.patch @@ -0,0 +1,35 @@ +diff --git crash-8.0.0/Makefile crash-8.0.0/Makefile +index d0574d8f07d3..9dbb61d0dbc8 100644 +--- crash-8.0.0/Makefile ++++ crash-8.0.0/Makefile +@@ -198,7 +198,7 @@ GDB_FLAGS= + # TARGET_CFLAGS will be configured automatically by configure + TARGET_CFLAGS= + +-CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${GDB_FLAGS} ${CFLAGS} ++CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${GDB_FLAGS} ${CFLAGS} ${CPPFLAGS} -fPIE + + GPL_FILES= + TAR_FILES=${SOURCE_FILES} Makefile ${GPL_FILES} README .rh_rpm_package crash.8 \ +@@ -228,7 +228,7 @@ all: make_configure + gdb_merge: force + @if [ ! -f ${GDB}/README ]; then \ + make --no-print-directory gdb_unzip; fi +- @echo "${LDFLAGS} -lz -llzo2 -lsnappy -ldl -rdynamic" > ${GDB}/gdb/mergelibs ++ @echo "${LDFLAGS} -lz -llzo2 -lsnappy -ldl -rdynamic -Wl,-z,now -fPIE" > ${GDB}/gdb/mergelibs + @echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj + @rm -f ${PROGRAM} + @if [ ! -f ${GDB}/config.status ]; then \ +diff --git crash-8.0.0/configure.c crash-8.0.0/configure.c +index 75006e881f5a..06c94d58c56c 100644 +--- crash-8.0.0/configure.c ++++ crash-8.0.0/configure.c +@@ -780,7 +780,8 @@ build_configure(struct supported_gdb_version *sp) + fprintf(fp2, "%s\n", sp->GDB); + sprintf(target_data.gdb_version, "%s", &sp->GDB[4]); + } else if (strncmp(buf, "LDFLAGS=", strlen("LDFLAGS=")) == 0) { +- fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : ""); ++ if (ldflags) ++ fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : ""); + } else + fprintf(fp2, "%s", buf); diff --git a/crash.spec b/crash.spec index 08c356b..15285b5 100644 --- a/crash.spec +++ b/crash.spec @@ -4,7 +4,7 @@ Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash Version: 8.0.0 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv3 Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz Source1: http://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz @@ -18,6 +18,7 @@ Requires: binutils Provides: bundled(libiberty) Provides: bundled(gdb) = 10.2 Patch0: lzo_snappy.patch +Patch1: crash-8.0.0_build.patch %description The core analysis suite is a self-contained tool that can be used to @@ -38,19 +39,12 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %prep %setup -n %{name}-%{version} -q %patch0 -p1 -b lzo_snappy.patch +%patch1 -p1 -b crash-8.0.0_build.patch %build -# This package has an internal copy of GDB which has broken configure code for -# INTDIV0_RAISES_SIGFPE and MUST_REINSTALL_SIGHANDLERS -# Updating that code properly seems nontrivial and best left to the package -# maintainer. -# Disable LTO -%define _lto_cflags %{nil} -# Disable hardened package -%undefine _hardened_build cp %{SOURCE1} . -make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}" +make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}" %install rm -rf %{buildroot} @@ -71,6 +65,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash %{_includedir}/* %changelog +* Fri Nov 26 2021 Lianbo Jiang - 8.0.0-2 +- Enable LTO and Hardened package + * Wed Nov 24 2021 Lianbo Jiang - 8.0.0-1 - Rebase to upstream 8.0.0