Skip to content
5 changes: 4 additions & 1 deletion SPECS-SIGNED/kernel-signed/kernel-signed.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Summary: Signed Linux Kernel for %{buildarch} systems
Name: kernel-signed-%{buildarch}
Version: 5.15.145.2
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2
Vendor: Microsoft Corporation
Distribution: Mariner
Expand Down Expand Up @@ -153,6 +153,9 @@ ln -sf linux-%{uname_r}.cfg /boot/mariner.cfg
%exclude /module_info.ld

%changelog
* Wed Jan 17 2024 Pawel Winogrodzki <pawelwi@microsoft.com> - 5.15.145.2-2
- Bump release to match kernel-headers.

* Tue Jan 16 2024 Gary Swalling <gaswal@microsoft.com> - 5.15.145.2-1
- Update to 5.15.145.2

Expand Down
189 changes: 178 additions & 11 deletions SPECS/binutils/binutils.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
# Where the binaries aimed at gcc will live (ie. /usr/<target>/bin/).
%global auxbin_prefix %{_exec_prefix}

%global srcdir %{name}-%{version}

%ifarch x86_64
%global build_cross 1
%else
%global build_cross 0
%endif

%global build_aarch64 %{build_cross}

%global do_files() \
%if %2 \
%files -n binutils-%1 \
%{_prefix}/%1 \
%{_bindir}/%1-* \
%endif

Summary: Contains a linker, an assembler, and other tools
Name: binutils
Version: 2.37
Release: 7%{?dist}
Release: 8%{?dist}
License: GPLv2+
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -16,8 +36,20 @@ Patch2: thin_archive_descriptor.patch
Patch3: CVE-2021-45078.patch
Patch4: CVE-2022-38533.patch
Patch5: CVE-2022-4285.patch
# The gold linker doesn't understand the 'module_info.ld' script passed to all linkers and the tests fail to correctly link.
Patch6: disable_gold_test.patch
Provides: bundled(libiberty)

# Moving macro before the "SourceX" tags breaks PR checks parsing the specs.
%global do_package() \
%if %2 \
%package -n binutils-%1 \
Summary: Cross-build binary utilities for %1 \
Requires: cross-%{name}-common = %{version}-%{release} \
%description -n binutils-%1 \
Cross-build binary image generation, manipulation and query tools for the %1 architecture. \
%endif

%description
The Binutils package contains a linker, an assembler,
and other tools for handling object files.
Expand All @@ -30,10 +62,66 @@ Requires: %{name} = %{version}
It contains the libraries and header files to create applications
for handling compiled objects.

%if %{build_cross}
%package -n cross-%{name}-common
Summary: Cross-compilation binutils documentation
BuildArch: noarch

%description -n cross-%{name}-common
Documentation for the cross-compilation binutils package.
%endif

%do_package aarch64-linux-gnu %{build_aarch64}

%prep
%autosetup -p1
%setup -q -c

function prep_target () {
local target=$1
local condition=$2

if [ $condition != 0 ]
then
echo $1 >> cross.list
fi
}

pushd %{srcdir}
%autopatch -p1
popd

touch cross.list
prep_target aarch64-linux-gnu %{build_aarch64}

%build

function config_cross_target () {
local target=$1

cp -r %{srcdir} $target
pushd $target

%configure \
--exec-prefix=%{auxbin_prefix} \
--program-prefix=$target- \
--target=$target \
--disable-multilib \
--disable-nls \
--disable-install_libbfd \
--with-sysroot=%{_prefix}/$target/sys-root

popd
}

# Native components build steps.

# Copying extracted sources for each run of "configure" and "make".
# Building in separate subdirectories but with a single source causes
# other packages to fail with a "configure: error: C compiler cannot create executables" error.
# Proper fix needed and moved to a separate bug at the time of writing this comment.
cp -r %{srcdir} build
pushd build

%configure \
--disable-silent-rules \
--disable-werror \
Expand All @@ -43,26 +131,94 @@ for handling compiled objects.
--enable-shared \
--with-system-zlib

%make_build tooldir=%{_prefix}
popd
%make_build -C build tooldir=%{_prefix}


# Cross-compilation components build steps.

while read -r target
do
echo "=== BUILD cross-compilation target $target ==="
config_cross_target $target
%make_build -C $target tooldir=%{_prefix}
done < cross.list

%if %{build_cross}
# For documentation purposes only.

cp -r %{srcdir} cross-binutils
pushd cross-binutils

# $PACKAGE is used for the gettext catalog name when building 'cross-binutils-common'.
sed -i -e 's/^ PACKAGE=/ PACKAGE=cross-/' */configure

%configure \
--exec-prefix=%{auxbin_prefix} \
--program-prefix=cross- \
--disable-dependency-tracking \
--disable-silent-rules \
--disable-shared

popd
%make_build -C cross-binutils tooldir=%{_prefix}
%endif


%install
# Native components installation steps.

pushd build

%make_install tooldir=%{_prefix}
find %{buildroot} -type f -name "*.la" -delete -print
rm -rf %{buildroot}%{_infodir}
%find_lang %{name} --all-name

install -m 644 libiberty/pic/libiberty.a %{buildroot}%{_libdir}
install -m 644 include/libiberty.h %{buildroot}%{_includedir}

popd

# Cross-compilation components installation steps.

while read -r target
do
echo "=== INSTALL cross-compilation target $target ==="
mkdir -p %{buildroot}%{_prefix}/$target/sys-root
%make_install -C $target tooldir=%{auxbin_prefix}/$target

# Remove cross man files and ldscripts.
rm -rf %{buildroot}%{_mandir}/man1/$target-*
rm -rf %{buildroot}%{auxbin_prefix}/*/lib
done < cross.list

rm -rf %{buildroot}%{_infodir}
find %{buildroot} -type f -name "*.la" -delete -print

%if %{build_cross}
echo "=== INSTALL po targets ==="
for binary_name in binutils opcodes bfd gas ld gprof
do
%make_install -C cross-binutils/$binary_name/po
done

# Find the language files which only exist in the common package.
(
for binary_name in binutils opcodes bfd gas ld gprof
do
%find_lang cross-$binary_name
cat cross-${binary_name}.lang
done
) >files.cross
%endif

%check
sed -i 's/testsuite/ /g' gold/Makefile
%make_build check
%make_build -C build tooldir=%{_prefix} check

%ldconfig_scriptlets

%files -f %{name}.lang
%files -f build/%{name}.lang
%defattr(-,root,root)
%license COPYING
%license %{srcdir}/COPYING
%{_bindir}/dwp
%{_bindir}/gprof
%{_bindir}/ld.bfd
Expand All @@ -82,6 +238,8 @@ sed -i 's/testsuite/ /g' gold/Makefile
%{_bindir}/readelf
%{_bindir}/strip
%{_libdir}/ldscripts/*
%{_libdir}/libbfd-%{version}.so
%{_libdir}/libopcodes-%{version}.so
%{_mandir}/man1/readelf.1.gz
%{_mandir}/man1/windmc.1.gz
%{_mandir}/man1/ranlib.1.gz
Expand All @@ -100,8 +258,6 @@ sed -i 's/testsuite/ /g' gold/Makefile
%{_mandir}/man1/windres.1.gz
%{_mandir}/man1/size.1.gz
%{_mandir}/man1/objdump.1.gz
%{_libdir}/libbfd-%{version}.so
%{_libdir}/libopcodes-%{version}.so

%files devel
%{_includedir}/ansidecl.h
Expand Down Expand Up @@ -130,7 +286,18 @@ sed -i 's/testsuite/ /g' gold/Makefile
%{_libdir}/libopcodes.a
%{_libdir}/libopcodes.so

%if %{build_cross}
%files -n cross-%{name}-common -f files.cross
%license %{srcdir}/COPYING
%endif

%do_files aarch64-linux-gnu %{build_aarch64}

%changelog
* Fri Nov 17 2023 Pawel Winogrodzki <pawelwi@microsoft.com> - 2.37-8
- Add the cross-compilation subpackage for aarch64.
- Used Fedora 38 spec (license: MIT) for guidance.

* Wed Sep 20 2023 Jon Slobodzian <joslobo@microsoft.com> - 2.37-7
- Recompile with stack-protection fixed gcc version (CVE-2023-4039)

Expand Down
34 changes: 34 additions & 0 deletions SPECS/binutils/disable_gold_test.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/Makefile.in b/Makefile.in
index 9b3a5d75..8c955d5a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -16070,13 +16070,7 @@ maybe-check-gold:
@if gold
maybe-check-gold: check-gold

-check-gold:
- @: $(MAKE); $(unstage)
- @r=`${PWD_COMMAND}`; export r; \
- s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- $(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
- (cd $(HOST_SUBDIR)/gold && \
- $(MAKE) $(FLAGS_TO_PASS) $(EXTRA_BOOTSTRAP_FLAGS) check)
+check-gold: ;

@endif gold

@@ -52322,14 +52316,12 @@ all-stage3-gold: maybe-all-stage3-gas
all-stage4-gold: maybe-all-stage4-gas
all-stageprofile-gold: maybe-all-stageprofile-gas
all-stagefeedback-gold: maybe-all-stagefeedback-gas
-check-gold: maybe-all-binutils
check-stage1-gold: maybe-all-stage1-binutils
check-stage2-gold: maybe-all-stage2-binutils
check-stage3-gold: maybe-all-stage3-binutils
check-stage4-gold: maybe-all-stage4-binutils
check-stageprofile-gold: maybe-all-stageprofile-binutils
check-stagefeedback-gold: maybe-all-stagefeedback-binutils
-check-gold: maybe-all-gas
check-stage1-gold: maybe-all-stage1-gas
check-stage2-gold: maybe-all-stage2-gas
check-stage3-gold: maybe-all-stage3-gas
Loading