From 687d7d4cfa12c82f5d9149212f009680be62930a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Prchl=C3=ADk?= Date: Thu, 25 Jan 2024 20:00:13 +0100 Subject: [PATCH 1/3] Switch tests to tmt from upstream repo, CentOS Stream --- plans/build-gating.fmf | 34 ++-- plans/regression.fmf | 18 ++ .../Sanity/rebuild-kernel-and-reboot/main.fmf | 64 ------ .../rebuild-kernel-and-reboot/runtest.sh | 186 ------------------ tests/Sanity/rebuild-wget/main.fmf | 20 -- tests/Sanity/rebuild-wget/runtest.sh | 70 ------- tests/Sanity/testsuite/main.fmf | 29 --- tests/Sanity/testsuite/runtest.sh | 136 ------------- 8 files changed, 33 insertions(+), 524 deletions(-) create mode 100644 plans/regression.fmf delete mode 100644 tests/Sanity/rebuild-kernel-and-reboot/main.fmf delete mode 100755 tests/Sanity/rebuild-kernel-and-reboot/runtest.sh delete mode 100644 tests/Sanity/rebuild-wget/main.fmf delete mode 100755 tests/Sanity/rebuild-wget/runtest.sh delete mode 100644 tests/Sanity/testsuite/main.fmf delete mode 100755 tests/Sanity/testsuite/runtest.sh diff --git a/plans/build-gating.fmf b/plans/build-gating.fmf index 266a6e2..5ddbd53 100644 --- a/plans/build-gating.fmf +++ b/plans/build-gating.fmf @@ -2,29 +2,25 @@ # Build/PR gating tests for binutils # -summary: binutils tests for build/PR gating +/common: + plan: + import: + url: https://gitlab.com/redhat/centos-stream/tests/binutils.git + ref: main + name: /plans/build-gating/common -adjust: +/kernel-rebuild: + plan: + import: + url: https://gitlab.com/redhat/centos-stream/tests/binutils.git + ref: main + name: /plans/build-gating/kernel-rebuild + +adjust+: - because: "Plan to be ran when executed locally, or executed by CI system to gate a build or PR." + # `commit` is used by Fedora CI, CentOS Stream CI, `build` by BaseOS CI when: >- trigger is defined and trigger != commit and trigger != build enabled: false - - - because: "CRB and Buildroot repositories must be enabled for various BuildRequires" - when: distro == rhel-9 - prepare+: - - how: shell - script: dnf config-manager --set-enabled rhel-CRB - -# This is probably not needed anymore. -# - how: shell -# script: dnf config-manager --set-enabled rhel-Buildroot - -discover: - how: fmf - filter: "tag:gate-build" - -execute: - how: tmt diff --git a/plans/regression.fmf b/plans/regression.fmf new file mode 100644 index 0000000..218485d --- /dev/null +++ b/plans/regression.fmf @@ -0,0 +1,18 @@ +# +# Build/PR gating tests for binutils +# + +/common: + plan: + import: + url: https://gitlab.com/redhat/centos-stream/tests/binutils.git + ref: main + name: /plans/regression + +adjust+: + - because: "Plan to be ran when executed locally, or executed by CI system after updating an erratum/bodhi update." + # `build` is used by Bodhi + when: >- + trigger is defined + and trigger != build + enabled: false diff --git a/tests/Sanity/rebuild-kernel-and-reboot/main.fmf b/tests/Sanity/rebuild-kernel-and-reboot/main.fmf deleted file mode 100644 index 2485629..0000000 --- a/tests/Sanity/rebuild-kernel-and-reboot/main.fmf +++ /dev/null @@ -1,64 +0,0 @@ -summary: Check whether newly built kernel boots correctly -description: | - Rebuild kernel, install it, reboot, and check if we're running the correct - kernel. Tailored specificaly for binutils buildroot testing process. - - A strong machine is recommended: - - - kernel rebuild is very resoruce-intensive task, and having more powerful - boxes for it is simply good, - - this task will get its own boxes, not clobbered by additional kernel packages - that are usually installed by other tasks in the same run. E.g.kernel-debuginfo, - when installed, will conflict with freshly build kernel packages. This should - workaround such situations, - - this tasks reboots its boxes - should such reboot break something, don't ruin - the whole run by it, right? - - Based on gcc/Sanity/rebuild-kernel by: - Author: Michal Nowak - Author: Marek Polacek -contact: -- Milos Prchlik -component: -- binutils -tag: -- gate-build -test: ./runtest.sh -framework: beakerlib -require: -- binutils -- gcc -- yum-utils -- rng-tools -- rpm-build -- newt-devel -- python-devel -- perl-ExtUtils-Embed -- unifdef -- elfutils-libelf-devel -- elfutils-devel -- pciutils-devel -- wget -- hmaccalc -- binutils-devel -- glibc-static -- texinfo -- gdb -- ecj -- graphviz -- gmp-devel -- mpfr-devel -- xmlto -- asciidoc -- net-tools -duration: 20h - -adjust: - - because: "pesign is available for some architectures only" - when: distro == rhel and arch != ppc64le and arch != s390x - require+: - - pesign - -# Dropping TCMS integration, these links should not be needed anymore. -# extra-summary: /tools/binutils/Sanity/rebuild-kernel-and-reboot -# extra-task: /tools/binutils/Sanity/rebuild-kernel-and-reboot diff --git a/tests/Sanity/rebuild-kernel-and-reboot/runtest.sh b/tests/Sanity/rebuild-kernel-and-reboot/runtest.sh deleted file mode 100755 index 5558d59..0000000 --- a/tests/Sanity/rebuild-kernel-and-reboot/runtest.sh +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/bash -# Copyright (c) 2009, 2012 Red Hat, Inc. All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Rebuild kernel, install it, reboot, and check if we're running the correct -# kernel. Tailored specificaly for binutils buildroot testing process. -# -# Author: Milos Prchlik -# -# Based on gcc/Sanity/rebuild-kernel by: -# Author: Michal Nowak -# Author: Marek Polacek - -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -export AVC_ERROR='+no_avc_check' - -case "$JUST_BUILD" in - 0|[Ff][Aa][Ll][Ss][Ee]|[Nn][Oo]) - JUST_BUILD=no - ;; - *) - JUST_BUILD=yes - ;; -esac - -LD="${LD:-/usr/bin/ld}" -GCC="${GCC:-/usr/bin/gcc}" - -PACKAGE="${PACKAGE:-$(rpm --qf '%{name}\n' -qf "$(which "$LD")" | head -1)}" -GCC_PACKAGE="${GCC_PACKAGE:-$(rpm --qf '%{name}\n' -qf "$(which "$GCC")" | head -1)}" - -PACKAGES="${PACKAGES:-$PACKAGE}" - -# Kernel package - usualy "kernel", but some trees may use different package -# name (e.g. kernel-PAE). -KERNEL="${KERNEL:-kernel}" - -REQUIRES="${REQUIRES:-$KERNEL $GCC_PACKAGE glibc}" -RPM_BUILD_ID="${RPM_BUILD_ID:-.LimeKitten}" - -# Workaround possible restraint issues - restraint may fail to set REBOOTCOUNT properly. -REBOOT_FLAG=/.rebuild-kernel-and-reboot.flag -REBOOTCOUNT="${REBOOTCOUNT:-0}" - -unset ARCH - -rlJournalStart - rlPhaseStartSetup - rlLogInfo "PACKAGES=$PACKAGES" - rlLogInfo "REQUIRES=$REQUIRES" - rlLogInfo "COLLECTIONS=$COLLECTIONS" - rlLogInfo "LD=$LD" - rlLogInfo "GCC=$GCC" - rlLogInfo "KERNEL=$KERNEL" - rlLogInfo "JUST_BUILD=$JUST_BUILD" - - # We'll use a lot of disk space (tens of GBs at least). The root FS - # often is the most beefy one in CI environemnts. Let's use it but also - # let's log what's actually available. - export TMPDIR=/test_tmp_root - rlRun "mkdir -p $TMPDIR" - rlLogInfo "TMPDIR=$TMPDIR" - rlLogInfo 'Disk space:' - df -h | while read line; do - rlLogInfo " $line" - done - - rlAssertRpm --all - - rlRun "AFTER_REBOOT=no" - - if [ "$REBOOTCOUNT" != "0" ]; then - rlLogInfo "Reboot count envvar is non-zero, update our flag" - rlRun "AFTER_REBOOT=yes" - elif [ -f "$REBOOT_FLAG" ]; then - rlLogInfo "FS reboot flag exists, update our flag" - rlRun "AFTER_REBOOT=yes" - fi - - if [ "$AFTER_REBOOT" = "no" ]; then - # We optionally need to skip checking for the presence of the metapackage - # because that would pull in all the dependent toolset subrpms. We do not - # always want that, especially in CI. - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - rlRun "pushd $TmpDir" - - # Speed up keygen. - rlRun "rngd -r /dev/hwrandom || rngd -r /dev/urandom" - - # Get the SRPM. - rlFetchSrcForInstalled "$KERNEL" - - rlRun "SRPM=`find . -name '*.src.rpm'`" - rlRun "SPECDIR=`rpm --define=\"_topdir $TmpDir\" --eval=%_specdir`" - - rlRun "rpm -ivh --define=\"_topdir $TmpDir\" $SRPM" - rlRun "SPECFILE=`find $SPECDIR/ -name '*.spec'`" - - builddep_options="--nobest" - rlRun "yum-builddep -y $builddep_options $SPECFILE" - fi - rlPhaseEnd - - if [ "$AFTER_REBOOT" = "no" ]; then - rlPhaseStartTest "Build" - if [ "$RPM_BUILD_ID" != "" ]; then - rlRun "sed -i \"s/# % define buildid .local/%define buildid $RPM_BUILD_ID/\" $SPECFILE" - rlRun "sed -i \"s/# define buildid .local/%define buildid $RPM_BUILD_ID/\" $SPECFILE" - fi - - if [ "`rlGetPrimaryArch`" == "ppc64" ]; then - TARGET="--target=ppc64" - else - TARGET="--target=$(uname -m)" - fi - - if rlRun "CC=$GCC rpmbuild --define=\"_topdir $TmpDir\" -bb $TARGET --clean $SPECFILE &> BUILD_LOG"; then - rlRun "RPMBUILD_OK=yes" - else - rlLogInfo "rpmbuild kernel failed" - rlRun "RPMBUILD_OK=no" - fi - rlBundleLogs "Build-log" BUILD_LOG - rlPhaseEnd - - # Install and boot the new kernel only if it's requested *and* the build was successful - if [ "$JUST_BUILD" = 'no' ] && [ "$RPMBUILD_OK" = "yes" ]; then - rlPhaseStartTest "Install" - RPMS="$(ls -1 $TmpDir/RPMS/*/*.rpm | grep -v kernel-selftests-internal | tr '\n' ' ')" - - rlRun "yum localinstall -y --disablerepo=\* $RPMS" - - rlLogInfo "$(rpm -qa | grep kernel | sort)" - - # Update the boot configuration - if [ "$(arch)" = "s390x" ]; then - rlRun "grubby --info=ALL" - rlLogInfo "Default kernel is $(grubby --default-kernel), index $(grubby --default-index)" - rlRun "KERNEL_FILE=$(ls -1 /boot/vmlinuz-*${RPM_BUILD_ID}."$(arch)")" - rlRun "ls -al $KERNEL_FILE" - rlRun "grubby --set-default $KERNEL_FILE" - rlLogInfo "Default kernel is $(grubby --default-kernel), index $(grubby --default-index)" - rlRun "zipl" - else - rlRun "grub2-set-default 2" - fi - rlPhaseEnd - - rlPhaseStartTest "Reboot" - rlRun "touch $REBOOT_FLAG" - - rlLog "Rebooting ..." - rhts-reboot - rlPhaseEnd - fi - fi - - # Verify the build ID only if its install and boot were requested - if [ "$JUST_BUILD" = 'no' ]; then - rlPhaseStartTest "Test" - if ! [ "$AFTER_REBOOT" = 'yes' ]; then - rlFail 'Not rebooted. Probably rhts-reboot did not work.' - fi - rlLogInfo "$(uname -a)" - rlRun "uname -r | grep $RPM_BUILD_ID" - rlPhaseEnd - fi - - rlPhaseStartCleanup - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/tests/Sanity/rebuild-wget/main.fmf b/tests/Sanity/rebuild-wget/main.fmf deleted file mode 100644 index 189e39c..0000000 --- a/tests/Sanity/rebuild-wget/main.fmf +++ /dev/null @@ -1,20 +0,0 @@ -summary: Rebuild wget -description: "" -contact: -- Milos Prchlik -component: -- binutils -tag: -- gate-build -test: ./runtest.sh -framework: beakerlib -require: -- binutils -- wget -- rpm-build -- gcc -duration: 1h - -# Dropping TCMS integration, these links should not be needed anymore. -# extra-summary: /tools/binutils/Sanity/rebuild-wget -# extra-task: /tools/binutils/Sanity/rebuild-wget diff --git a/tests/Sanity/rebuild-wget/runtest.sh b/tests/Sanity/rebuild-wget/runtest.sh deleted file mode 100755 index 28d7dbd..0000000 --- a/tests/Sanity/rebuild-wget/runtest.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# runtest.sh of /tools/binutils/Sanity/rebuild-wget -# Description: Rebuild wget -# Author: Milos Prchlik -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2015 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing -# to use, modify, copy, or redistribute it subject to the terms -# and conditions of the GNU General Public License version 2. -# -# This program is distributed in the hope that it will be -# useful, but WITHOUT ANY WARRANTY; without even the implied -# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program; if not, write to the Free -# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -LD="${LD:-/usr/bin/ld}" -GCC="${GCC:-/usr/bin/gcc}" - -BINUTILS_PACKAGE="$(rpm --qf '%{name}\n' -qf "$(which "$LD")" | head -1)" -GCC_PACKAGE="$(rpm --qf '%{name}\n' -qf "$(which "$GCC")" | head -1)" - -PACKAGES="${PACKAGES:-$BINUTILS_PACKAGE}" -REQUIRES="${REQUIRES:-$GCC_PACKAGE wget}" - -rlJournalStart - rlPhaseStartSetup - rlLogInfo "PACKAGES=$PACKAGES" - rlLogInfo "REQUIRES=$REQUIRES" - rlLogInfo "COLLECTIONS=$COLLECTIONS" - rlLogInfo "LD=$LD" - rlLogInfo "GCC=$GCC" - - rlAssertRpm --all - - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - rlRun "pushd $TmpDir" - - rlFetchSrcForInstalled "wget" - rlRun "SRPM=`find . -name 'wget-*.src.rpm'`" - rlRun "rpm -ivh --define='_topdir $TmpDir' $SRPM" - rlRun "SPECFILE=`find $TmpDir/ -name '*.spec'`" - rlRun "dnf builddep -y $SPECFILE" - rlPhaseEnd - - rlPhaseStartTest - rlRun "rpmbuild --define='_topdir $TmpDir' -bb --clean $SPECFILE" - rlPhaseEnd - - rlPhaseStartCleanup - rlRun "popd" - rlRun "rm -r $TmpDir" 0 "Removing tmp directory" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/tests/Sanity/testsuite/main.fmf b/tests/Sanity/testsuite/main.fmf deleted file mode 100644 index d7a0f0c..0000000 --- a/tests/Sanity/testsuite/main.fmf +++ /dev/null @@ -1,29 +0,0 @@ -summary: The test rebuilds binutils.src.rpm and runs the suite. -description: '' -contact: -- Milos Prchlik -component: -- binutils -tag: -- gate-build -test: ./runtest.sh -framework: beakerlib -require: -- binutils -- texinfo -- glibc-static -- dejagnu -- bison -- flex -- zlib-static -- sharutils -- yum-utils -- libstdc++-static -- rpm-build -- gcc-c++ -- annobin -duration: 3h - -# Dropping TCMS integration, these links should not be needed anymore. -# extra-summary: /tools/binutils/Sanity/testsuite -# extra-task: /tools/binutils/Sanity/testsuite diff --git a/tests/Sanity/testsuite/runtest.sh b/tests/Sanity/testsuite/runtest.sh deleted file mode 100755 index cbcca94..0000000 --- a/tests/Sanity/testsuite/runtest.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/bash -# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# runtest.sh of /tools/binutils/Sanity/testsuite -# -# Description: The test rebuilds binutils.src.rpm and runs the suite. -# The test is based on /tools/binutils/testsuite, but it had to be -# rewritten. -# -# Author: Michael Petlan -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2015 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing -# to use, modify, copy, or redistribute it subject to the terms -# and conditions of the GNU General Public License version 2. -# -# This program is distributed in the hope that it will be -# useful, but WITHOUT ANY WARRANTY; without even the implied -# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program; if not, write to the Free -# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -LD="${LD:-/usr/bin/ld}" -GCC="${GCC:-/usr/bin/gcc}" - -PACKAGE="${PACKAGE:-$(rpm --qf '%{name}\n' -qf "$(which "$LD")" | head -1)}" -GCC_PACKAGE="${GCC_PACKAGE:-$(rpm --qf '%{name}\n' -qf "$(which "$GCC")" | head -1)}" - -PACKAGES="${PACKAGES:-$PACKAGE}" -REQUIRES="${REQUIRES:-$GCC_PACKAGE}" - -rlJournalStart - rlPhaseStartSetup - ARCH="$(rlGetPrimaryArch)" - - if [ "$ARCH" = "x86_64" ]; then - BUILD_ARCHS="aarch64 ppc64le s390x x86_64" - else - BUILD_ARCHS="$ARCH" - fi - - rlLogInfo "PACKAGES=$PACKAGES" - rlLogInfo "REQUIRES=$REQUIRES" - rlLogInfo "COLLECTIONS=$COLLECTIONS" - rlLogInfo "LD=$LD" - rlLogInfo "GCC=$GCC" - rlLogInfo "ARCH=$ARCH" - rlLogInfo "BUILD_ARCHS=$BUILD_ARCHS" - - rlAssertRpm --all - - # temp dir - rlRun "TESTDIR=$PWD" - - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - - rlRun "LOGDIR=$TmpDir/LOGS" - rlRun "BUILDDIR=$(rpm --define='_topdir $TmpDir' --eval=%_builddir)" - rlRun "CURRENT_BUILD=${BUILDDIR}/binutils-$(rpmquery "$PACKAGE" --queryformat=%{VERSION})" - - rlRun "mkdir $LOGDIR" - - rlRun "pushd $TmpDir" - - # fetch'n'build the source - rlFetchSrcForInstalled "$PACKAGE" - rlRun "yum-builddep -y *.src.rpm" - rlRun "SRPM=$(find . -name 'binutils-*.src.rpm')" - rlRun "rpm -ivh --define='_topdir $TmpDir' $SRPM" - rlRun "SPECFILE=$(find "$TmpDir/" -name '*.spec')" - rlRun "dnf builddep -y $SPECFILE" - rlPhaseEnd - - rlPhaseStartSetup "Rebuild binutils" - rlRun "rpmbuild -bc --define='_topdir $TmpDir' $SPECFILE" - - for build_arch in $BUILD_ARCHS; do - rlRun "cp $CURRENT_BUILD/build-${build_arch}-redhat-linux/binutils/binutils.log $LOGDIR/binutils-$build_arch.log" - rlRun "cp $CURRENT_BUILD/build-${build_arch}-redhat-linux/binutils/binutils.sum $LOGDIR/binutils-$build_arch.sum" - - if [ "$build_arch" = "$ARCH" ]; then - rlRun "cp $CURRENT_BUILD/build-${build_arch}-redhat-linux/ld/ld.log $LOGDIR/ld-$build_arch.log" - rlRun "cp $CURRENT_BUILD/build-${build_arch}-redhat-linux/ld/ld.sum $LOGDIR/ld-$build_arch.sum" - fi - - rlRun "cp $CURRENT_BUILD/build-${build_arch}-redhat-linux/gas/testsuite/gas.log $LOGDIR/gas-$build_arch.log" - rlRun "cp $CURRENT_BUILD/build-${build_arch}-redhat-linux/gas/testsuite/gas.sum $LOGDIR/gas-$build_arch.sum" - done - rlPhaseEnd - - for TOOL in binutils ld gas; do - for build_arch in $BUILD_ARCHS; do - if [[ "$TOOL" == "ld" && "$build_arch" != "$ARCH" ]]; then - continue - fi - - tool_label="$TOOL / $build_arch" - tool_log="$LOGDIR/$TOOL-$build_arch" - - rlPhaseStartTest "$tool_label" - rlLogInfo "$tool_label Summary" - rlLogInfo "$(grep -A 50 '=== .* Summary ===' "$tool_log.sum")" - - rlRun "awk \"/=== $TOOL tests ===/,/=== $TOOL Summary ===/\" $tool_log.sum > $tool_log.tests" 0,1 "Save results of all tests" - rlRun "grep -E '^FAIL: ' $tool_log.tests | sort > $tool_log.failed" 0,1 "Save failures" - - rlRun "grep '# of unexpected failures' $tool_log.sum" 0,1 "Checking number of unexpected failures" - rlLogInfo "$(sort < "$tool_log.failed")" - rlLogInfo "$(grep -E '^[A-Z]+:' "$tool_log.tests" | sort)" - rlPhaseEnd - done - done - - rlPhaseStartCleanup - rlRun "tar czf $TmpDir/logs.tgz $LOGDIR/*.sum $LOGDIR/*.log $LOGDIR/*.tests $LOGDIR/*.failed" - rlRun "tar czf $TmpDir/buildroot.tgz $CURRENT_BUILD/" - rlFileSubmit logs.tar.gz - rlFileSubmit buildroot.tgz - rlRun "popd" # $TmpDir - rlRun "rm -r $TmpDir" 0 "Removing tmp directory" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd From b7976293c1b03ef9ea03d2c646d31d16dfafc579 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 12 Dec 2024 11:08:55 +0000 Subject: [PATCH 2/3] Fix assembler testsuite problems with new s390 tests. Resolves: RHEL-50068 --- binutils-s390-arch15-gas-tests-fixes.patch | 259 +++++++++++++++++++++ binutils.spec | 6 +- 2 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 binutils-s390-arch15-gas-tests-fixes.patch diff --git a/binutils-s390-arch15-gas-tests-fixes.patch b/binutils-s390-arch15-gas-tests-fixes.patch new file mode 100644 index 0000000..e60ccca --- /dev/null +++ b/binutils-s390-arch15-gas-tests-fixes.patch @@ -0,0 +1,259 @@ +diff -rup ../binutils.orig/gas/testsuite/gas/s390/esa-g5.d binutils-2.35.2/gas/testsuite/gas/s390/esa-g5.d +--- ../binutils.orig/gas/testsuite/gas/s390/esa-g5.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/esa-g5.d 2024-12-12 10:43:24.821620218 +0000 +@@ -1,4 +1,4 @@ +-#name: s390 opcode ++#name: s390 opcode (esa g5) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/esa-reloc.d binutils-2.35.2/gas/testsuite/gas/s390/esa-reloc.d +--- ../binutils.orig/gas/testsuite/gas/s390/esa-reloc.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/esa-reloc.d 2024-12-12 10:44:50.261914579 +0000 +@@ -1,4 +1,4 @@ +-#name: s390 reloc ++#name: s390 reloc (esa reloc) + #objdump: -dr + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/esa-z9-109.d binutils-2.35.2/gas/testsuite/gas/s390/esa-z9-109.d +--- ../binutils.orig/gas/testsuite/gas/s390/esa-z9-109.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/esa-z9-109.d 2024-12-12 10:44:35.717864467 +0000 +@@ -1,4 +1,4 @@ +-#name: s390 opcode ++#name: s390 opcode (esa z9 109) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/esa-z900.d binutils-2.35.2/gas/testsuite/gas/s390/esa-z900.d +--- ../binutils.orig/gas/testsuite/gas/s390/esa-z900.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/esa-z900.d 2024-12-12 11:02:05.545504284 +0000 +@@ -1,4 +1,4 @@ +-#name: s390 opcode ++#name: s390 opcode (esa z900) + #objdump: -drw + + .*: +file format .* +@@ -7,51 +7,51 @@ Disassembly of section .text: + + .* : + .*: c0 f4 00 00 00 00 [ ]*jg 0 +-*([\da-f]+): c0 04 00 00 00 00 [ ]*jgnop \1 +-*([\da-f]+): c0 14 00 00 00 00 [ ]*jgo \1 +-*([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 +-*([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 +-*([\da-f]+): c0 34 00 00 00 00 [ ]*jgnle \1 +-*([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 +-*([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 +-*([\da-f]+): c0 54 00 00 00 00 [ ]*jgnhe \1 +-*([\da-f]+): c0 64 00 00 00 00 [ ]*jglh \1 +-*([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 +-*([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 +-*([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 +-*([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 +-*([\da-f]+): c0 94 00 00 00 00 [ ]*jgnlh \1 +-*([\da-f]+): c0 a4 00 00 00 00 [ ]*jghe \1 +-*([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 +-*([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 +-*([\da-f]+): c0 c4 00 00 00 00 [ ]*jgle \1 +-*([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 +-*([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 +-*([\da-f]+): c0 e4 00 00 00 00 [ ]*jgno \1 +-*([\da-f]+): c0 f4 00 00 00 00 [ ]*jg \1 +-*([\da-f]+): c0 14 00 00 00 00 [ ]*jgo \1 +-*([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 +-*([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 +-*([\da-f]+): c0 34 00 00 00 00 [ ]*jgnle \1 +-*([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 +-*([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 +-*([\da-f]+): c0 54 00 00 00 00 [ ]*jgnhe \1 +-*([\da-f]+): c0 64 00 00 00 00 [ ]*jglh \1 +-*([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 +-*([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 +-*([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 +-*([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 +-*([\da-f]+): c0 94 00 00 00 00 [ ]*jgnlh \1 +-*([\da-f]+): c0 a4 00 00 00 00 [ ]*jghe \1 +-*([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 +-*([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 +-*([\da-f]+): c0 c4 00 00 00 00 [ ]*jgle \1 +-*([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 +-*([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 +-*([\da-f]+): c0 e4 00 00 00 00 [ ]*jgno \1 +-*([\da-f]+): c0 f4 00 00 00 00 [ ]*jg \1 +-*([\da-f]+): c0 65 00 00 00 00 [ ]*brasl %r6,\1 +-*([\da-f]+): c0 65 00 00 00 00 [ ]*brasl %r6,\1 ++ *([\da-f]+): c0 04 00 00 00 00 [ ]*jgnop \1 ++ *([\da-f]+): c0 14 00 00 00 00 [ ]*jgo \1 ++ *([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 ++ *([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 ++ *([\da-f]+): c0 34 00 00 00 00 [ ]*jgnle \1 ++ *([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 ++ *([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 ++ *([\da-f]+): c0 54 00 00 00 00 [ ]*jgnhe \1 ++ *([\da-f]+): c0 64 00 00 00 00 [ ]*jglh \1 ++ *([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 ++ *([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 ++ *([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 ++ *([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 ++ *([\da-f]+): c0 94 00 00 00 00 [ ]*jgnlh \1 ++ *([\da-f]+): c0 a4 00 00 00 00 [ ]*jghe \1 ++ *([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 ++ *([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 ++ *([\da-f]+): c0 c4 00 00 00 00 [ ]*jgle \1 ++ *([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 ++ *([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 ++ *([\da-f]+): c0 e4 00 00 00 00 [ ]*jgno \1 ++ *([\da-f]+): c0 f4 00 00 00 00 [ ]*jg \1 ++ *([\da-f]+): c0 14 00 00 00 00 [ ]*jgo \1 ++ *([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 ++ *([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 ++ *([\da-f]+): c0 34 00 00 00 00 [ ]*jgnle \1 ++ *([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 ++ *([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 ++ *([\da-f]+): c0 54 00 00 00 00 [ ]*jgnhe \1 ++ *([\da-f]+): c0 64 00 00 00 00 [ ]*jglh \1 ++ *([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 ++ *([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 ++ *([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 ++ *([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 ++ *([\da-f]+): c0 94 00 00 00 00 [ ]*jgnlh \1 ++ *([\da-f]+): c0 a4 00 00 00 00 [ ]*jghe \1 ++ *([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 ++ *([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 ++ *([\da-f]+): c0 c4 00 00 00 00 [ ]*jgle \1 ++ *([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 ++ *([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 ++ *([\da-f]+): c0 e4 00 00 00 00 [ ]*jgno \1 ++ *([\da-f]+): c0 f4 00 00 00 00 [ ]*jg \1 ++ *([\da-f]+): c0 65 00 00 00 00 [ ]*brasl %r6,\1 ++ *([\da-f]+): c0 65 00 00 00 00 [ ]*brasl %r6,\1 + .*: 01 0b [ ]*tam + .*: 01 0c [ ]*sam24 + .*: 01 0d [ ]*sam31 +@@ -62,7 +62,7 @@ Disassembly of section .text: + .*: b9 97 00 69 [ ]*dlr %r6,%r9 + .*: b9 98 00 69 [ ]*alcr %r6,%r9 + .*: b9 99 00 69 [ ]*slbr %r6,%r9 +-*([\da-f]+): c0 60 00 00 00 00 [ ]*larl %r6,\1 ++ *([\da-f]+): c0 60 00 00 00 00 [ ]*larl %r6,\1 + .*: e3 65 af ff 00 1e [ ]*lrv %r6,4095\(%r5,%r10\) + .*: e3 65 af ff 00 1f [ ]*lrvh %r6,4095\(%r5,%r10\) + .*: e3 65 af ff 00 3e [ ]*strv %r6,4095\(%r5,%r10\) +diff -rup ../binutils.orig/gas/testsuite/gas/s390/esa-z990.d binutils-2.35.2/gas/testsuite/gas/s390/esa-z990.d +--- ../binutils.orig/gas/testsuite/gas/s390/esa-z990.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/esa-z990.d 2024-12-12 10:44:05.349759849 +0000 +@@ -1,4 +1,4 @@ +-#name: s390 opcode ++#name: s390 opcode (esa z990) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-arch12.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-arch12.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-arch12.d 2024-12-12 10:18:15.923744415 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-arch12.d 2024-12-12 10:27:23.392254038 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (arch12) + #objdump: -dr + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-arch13.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-arch13.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-arch13.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-arch13.d 2024-12-12 10:27:23.392254038 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (arch 13) + #objdump: -dr + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-arch14.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-arch14.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-arch14.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-arch14.d 2024-12-12 10:27:23.392254038 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (arch14) + #objdump: -dr + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-arch15.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-arch15.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-arch15.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-arch15.d 2024-12-12 10:27:23.392254038 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (arch15) + #objdump: -dr + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-z10.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-z10.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-z10.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-z10.d 2024-12-12 10:27:23.392254038 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (z10) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-z13.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-z13.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-z13.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-z13.d 2024-12-12 10:27:23.393254042 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (z13) + #objdump: -dr + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-z196.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-z196.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-z196.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-z196.d 2024-12-12 10:27:23.393254042 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (z196) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-z9-109.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-z9-109.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-z9-109.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-z9-109.d 2024-12-12 10:27:23.393254042 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (z9 109) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-z9-ec.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-z9-ec.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-z9-ec.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-z9-ec.d 2024-12-12 10:27:23.393254042 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (z9 ec) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-z900.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-z900.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-z900.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-z900.d 2024-12-12 10:27:23.393254042 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (z900) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-z990.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-z990.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-z990.d 2024-12-12 10:18:15.923744415 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-z990.d 2024-12-12 10:27:23.393254042 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (z990) + #objdump: -drw + + .*: +file format .* +diff -rup ../binutils.orig/gas/testsuite/gas/s390/zarch-zEC12.d binutils-2.35.2/gas/testsuite/gas/s390/zarch-zEC12.d +--- ../binutils.orig/gas/testsuite/gas/s390/zarch-zEC12.d 2024-12-12 10:18:15.924744418 +0000 ++++ binutils-2.35.2/gas/testsuite/gas/s390/zarch-zEC12.d 2024-12-12 10:27:23.393254042 +0000 +@@ -1,4 +1,4 @@ +-#name: s390x opcode ++#name: s390x opcodes (zEC12) + #objdump: -dr + + .*: +file format .* diff --git a/binutils.spec b/binutils.spec index a37735c..61e1cf3 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: binutils%{?_with_debug:-debug} Version: 2.35.2 -Release: 58%{?dist} +Release: 59%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -500,6 +500,7 @@ Patch86: binutils-s390-arch15-13.patch Patch87: binutils-s390-arch15-14.patch Patch88: binutils-s390-arch15-15.patch Patch89: binutils-s390-arch15-16.patch +Patch90: binutils-s390-arch15-gas-tests-fixes.patch #---------------------------------------------------------------------------- @@ -1360,6 +1361,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Thu Dec 12 2024 Nick Clifton - 2.35.2-59 +- Fix assembler testsuite problems with new s390 tests. (RHEL-50068) + * Mon Nov 18 2024 Nick Clifton - 2.35.2-58 - Extend support for the arch15 and arch16 extensions to the s390 architecture. (RHEL-50068) From b754f74df907af05d57d4b805123498563580554 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 23 Jan 2025 13:03:08 +0000 Subject: [PATCH 3/3] Add an option to objcopy that creates padding sections that eliminate gaps between segments. Resolves: RHEL-60807 --- binutils-rhivos-segment-gap.patch | 253 ++++++++++++++++++++++++++++++ binutils.spec | 9 +- 2 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 binutils-rhivos-segment-gap.patch diff --git a/binutils-rhivos-segment-gap.patch b/binutils-rhivos-segment-gap.patch new file mode 100644 index 0000000..4612ce9 --- /dev/null +++ b/binutils-rhivos-segment-gap.patch @@ -0,0 +1,253 @@ +diff -rup binutils-2.41/binutils/doc/binutils.texi /home/nickc/binutils-2.41/binutils/doc/binutils.texi +--- binutils-2.41/binutils/doc/binutils.texi 2025-01-21 13:16:01.970763573 +0000 ++++ /home/nickc/binutils-2.41/binutils/doc/binutils.texi 2025-01-21 12:22:23.561279546 +0000 +@@ -1285,6 +1285,7 @@ objcopy [@option{-F} @var{bfdname}|@opti + [@option{--debugging}] + [@option{--gap-fill=}@var{val}] + [@option{--pad-to=}@var{address}] ++ [@option{--add-segment-padding-sections}] + [@option{--set-start=}@var{val}] + [@option{--adjust-start=}@var{incr}] + [@option{--change-addresses=}@var{incr}] +@@ -1666,6 +1667,18 @@ Pad the output file up to the load addre + done by increasing the size of the last section. The extra space is + filled in with the value specified by @option{--gap-fill} (default zero). + ++@item --add-segment-padding-sections ++Add empty sections that eliminate any gaps between loadable segments. ++This option only works with ELF format files that contains both ++sections and segments. The added sections will have the SHT_NOBITS ++type and permissions that match the segment that they are padding. ++The sections names will be of the form .segment.pad. where is ++the number of the load segment that is being padded. ++ ++Note - this option should not be used in conjunction with any other ++option that adds or removes sections, or changes their size in any ++way. ++ + @item --set-start @var{val} + Set the start address (also known as the entry address) of the new + file to @var{val}. Not all object file formats support setting the +--- /dev/null 2025-01-21 09:02:16.359001262 +0000 ++++ binutils-2.41/binutils/testsuite/binutils-all/add-segment-padding-sections.d 2025-01-21 13:13:49.615269853 +0000 +@@ -0,0 +1,10 @@ ++#PROG: objcopy ++#name: objcopy --add-segment-padding-sections ++#source: bintest.s ++#ld: -e 0 --defsym external_symbol=0 ++#objcopy: --add-segment-padding-sections ++#readelf: -lW ++ ++#... ++[ ]+LOAD[ ]+0x[0-9a-f]+[ ]+0x[0-9a-f]+[ ]+0x[0-9a-f]+[ ]+0x[0-9a-f]+[ ]+0x[0-9a-f]+000.* ++#pass +--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2025-01-23 10:46:24.867490584 +0000 ++++ binutils-2.35.2/binutils/testsuite/binutils-all/objcopy.exp 2025-01-23 10:48:05.957176799 +0000 +@@ -1356,3 +1356,7 @@ if { [istarget pdp11-*-*] } { + } + + objcopy_test "pr25662" $src executable "" "-T$srcdir/$subdir/pr25662.ld" ++ ++if [is_elf_format] { ++ run_dump_test "add-segment-padding-sections" ++} +--- binutils.orig/binutils/objcopy.c 2025-01-23 10:46:24.874490631 +0000 ++++ binutils-2.35.2/binutils/objcopy.c 2025-01-23 10:54:02.220653906 +0000 +@@ -242,6 +242,9 @@ static bfd_boolean change_leading_char = + /* Whether to remove the leading character from global symbol names. */ + static bfd_boolean remove_leading_char = FALSE; + ++/* If true add sections that pad loadable segments so that there are no gaps between them. */ ++static bfd_boolean add_segment_padding_sections = FALSE; ++ + /* Whether to permit wildcard in symbol comparison. */ + static bfd_boolean wildcard = FALSE; + +@@ -306,6 +309,7 @@ enum command_line_switch + { + OPTION_ADD_SECTION=150, + OPTION_ADD_GNU_DEBUGLINK, ++ OPTION_ADD_SEGMENT_PADDING_SECTIONS, + OPTION_ADD_SYMBOL, + OPTION_ALT_MACH_CODE, + OPTION_CHANGE_ADDRESSES, +@@ -417,6 +421,7 @@ static struct option copy_options[] = + { + {"add-gnu-debuglink", required_argument, 0, OPTION_ADD_GNU_DEBUGLINK}, + {"add-section", required_argument, 0, OPTION_ADD_SECTION}, ++ {"add-segment-padding-sections", no_argument, 0, OPTION_ADD_SEGMENT_PADDING_SECTIONS}, + {"add-symbol", required_argument, 0, OPTION_ADD_SYMBOL}, + {"adjust-section-vma", required_argument, 0, OPTION_CHANGE_SECTION_ADDRESS}, + {"adjust-start", required_argument, 0, OPTION_CHANGE_START}, +@@ -610,6 +615,7 @@ copy_usage (FILE *stream, int exit_statu + -b --byte Select byte in every interleaved block\n\ + --gap-fill Fill gaps between sections with \n\ + --pad-to Pad the last section up to address \n\ ++ --add-segment-padding-sections Add padding sections so that load segments do not have gaps\n\ + --set-start Set the start address to \n\ + {--change-start|--adjust-start} \n\ + Add to the start address\n\ +@@ -2569,6 +2575,142 @@ check_new_section_flags (flagword flags, + return flags; + } + ++static bfd_boolean ++is_loadable_segment (const Elf_Internal_Phdr * phdr) ++{ ++ return phdr->p_type == PT_LOAD || phdr->p_type == PT_TLS; ++} ++ ++static bfd_vma ++page_align_down (bfd_vma pagesize, bfd_vma addr) ++{ ++ return addr & ~ (pagesize - 1); ++} ++ ++static void ++add_padding_sections (bfd *ibfd, bfd *obfd) ++{ ++ if (obfd == NULL) /* Paranoia. */ ++ return; ++ ++ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour ++ || bfd_get_flavour (obfd) != bfd_target_elf_flavour) ++ { ++ non_fatal (_("the --add-segment-padding-sections option only works with ELF format files\n")); ++ return; ++ } ++ ++ if (add_sections != NULL || update_sections != NULL || gap_fill_set || pad_to_set) ++ { ++ non_fatal (_("the --add-segment-padding-sections option does not work with other paddding/modifying options\n")); ++ return; ++ } ++ ++ const struct elf_backend_data * bed = get_elf_backend_data (ibfd); ++ const struct elf_obj_tdata * tdata = elf_tdata (ibfd); ++ const Elf_Internal_Ehdr * ehdr = elf_elfheader (ibfd); ++ ++ if (bed == NULL || tdata == NULL || ehdr == NULL) ++ { ++ non_fatal ("could not find ELF data\n"); ++ return; ++ } ++ ++ const Elf_Internal_Phdr * prev = NULL; ++ unsigned int i; ++ bfd_boolean sections_added = FALSE; ++ ++ for (i = 1; i < ehdr->e_phnum; i++) ++ { ++ const Elf_Internal_Phdr * current = tdata->phdr + i; ++ ++ if (! is_loadable_segment (current)) ++ continue; ++ ++ /* If this is the first loadable segment, just record it. */ ++ if (prev == NULL) ++ { ++ prev = current; ++ continue; ++ } ++ ++ bfd_vma prev_end = prev->p_vaddr + prev->p_memsz; ++ bfd_vma current_start = page_align_down (bed->commonpagesize, current->p_vaddr); ++ ++ /* If the segments are not ordered by increasing p_vaddr then abort. ++ Note: the ELF standard requires that segments be sorted by p_vaddr, ++ but linker scripts are able to override this. */ ++ if (current_start < prev_end) ++ break; ++ ++ /* If the previous segment ended at the start of the ++ current segment then there is nothing to do. */ ++ if (prev_end == current_start) ++ { ++ prev = current; ++ continue; ++ } ++ ++ flagword flags = SEC_LINKER_CREATED | SEC_ALLOC; ++ ++ /* We do not add SEC_HAS_CONTENTS because we want to create a SHT_NOBITS ++ section. That way we will not take up (much) extra space in the file. */ ++ ++ if (prev->p_flags & PF_X) ++ flags |= SEC_CODE | SEC_READONLY; ++ else if (prev->p_flags & PF_R) ++ flags |= SEC_DATA | SEC_READONLY; ++ else if (prev->p_flags & PF_W) ++ flags |= SEC_DATA; ++ else ++ { ++ prev = current; ++ continue; ++ } ++ ++#define SEGMENT_PADDING_SECTION_NAME ".segment.pad" ++ char * new_name; ++ if (asprintf (& new_name, SEGMENT_PADDING_SECTION_NAME ".%u", i - 1) < 1) ++ { ++ non_fatal ("unable to construct padding section name\n"); ++ break; ++ } ++ ++ asection * new_section = bfd_make_section_with_flags (obfd, new_name, flags); ++ ++ if (new_section == NULL) ++ { ++ free (new_name); ++ non_fatal ("unable to make padding section\n"); ++ break; ++ } ++ ++ bfd_vma new_size = (current_start - prev->p_vaddr) - prev->p_memsz; ++ ++ if (! bfd_set_section_size (new_section, new_size)) ++ { ++ bfd_nonfatal_message (NULL, obfd, new_section, NULL); ++ break; ++ } ++ ++ if (! bfd_set_section_vma (new_section, prev_end)) ++ { ++ bfd_nonfatal_message (NULL, obfd, new_section, NULL); ++ break; ++ } ++ ++ /* Do not free the name - it is used later on. */ ++ ++ sections_added = TRUE; ++ prev = current; ++ } ++ ++ /* If we have added any sections, remove the section ++ to segment map so that it is regenerated. */ ++ if (sections_added) ++ elf_seg_map (obfd) = NULL; ++} ++ + /* Copy object file IBFD onto OBFD. + Returns TRUE upon success, FALSE otherwise. */ + +@@ -3175,6 +3317,9 @@ copy_object (bfd *ibfd, bfd *obfd, const + } + } + ++ if (add_segment_padding_sections) ++ add_padding_sections (ibfd, obfd); ++ + /* Symbol filtering must happen after the output sections + have been created, but before their contents are set. */ + dhandle = NULL; +@@ -5548,6 +5693,10 @@ copy_main (int argc, char *argv[]) + pad_to_set = TRUE; + break; + ++ case OPTION_ADD_SEGMENT_PADDING_SECTIONS: ++ add_segment_padding_sections = TRUE; ++ break; ++ + case OPTION_REMOVE_LEADING_CHAR: + remove_leading_char = TRUE; + break; diff --git a/binutils.spec b/binutils.spec index 29a7291..742734f 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: binutils%{?_with_debug:-debug} Version: 2.35.2 -Release: 60%{?dist} +Release: 61%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -506,6 +506,10 @@ Patch90: binutils-s390-arch15-gas-tests-fixes.patch # Lifetime: Fixed in 2.44 Patch91: binutils-linker-diagnostic-message.patch +# Purpose: Add option to objcopy to pad segments eliminating gaps. +# Lifetime: Permanent +Patch92: binutils-rhivos-segment-gap.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -1365,6 +1369,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Thu Jan 23 2025 Nick Clifton - 2.35.2-61 +- Add an option to objcopy that creates padding sections that eliminate gaps between segments. (RHEL-60807) + * Mon Jan 06 2025 Nick Clifton - 2.35.2-60 - Add a helpful linker diagnostic message about missing static libraries. (RHEL-69758)