Add test for RHEL-30268

objcopy doesn't align sections with --section-alignment/--set-section-alignment
This commit is contained in:
Miloš Prchlík 2024-07-02 16:08:47 +02:00
commit b9e16fe4fb
6 changed files with 64 additions and 0 deletions

View file

@ -6,6 +6,7 @@ repos:
rev: v4.4.0
hooks:
- id: check-added-large-files
args: ["--maxkb=600"]
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict

View file

@ -0,0 +1,9 @@
summary: objcopy doesn't align sections with --section-alignment/--set-section-alignment
duration: 15m
require+:
- python3-virt-firmware
link+:
- verifies: https://issues.redhat.com/browse/RHEL-30268

View file

@ -0,0 +1,15 @@
#!/bin/bash
set -eu
while read -r line; do
section="$(echo "$line" | sed -r 's/^.+\(\.([a-z]+)\)$/\1/')"
address="$(echo "$line" | sed -r 's/^.+ file (0x[0-9a-z]+).+$/\1/')"
echo "$section @$address"
if ((address % 512 != 0)); then
echo "Section $section alignment is not multiple of 512"
exit 1
fi
done < <(pe-inspect $1 | grep --text "section")
echo "All OK"

View file

@ -0,0 +1,39 @@
#!/bin/bash
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$TMT_TREE/tests/lib.sh" || exit 1
rlJournalStart
rlPhaseStartSetup
buTestHeader
buEnterTmpDir
buCopyReproducers "repro.sh linuxx64.efi.stub linuxx64.elf.stub"
rlPhaseEnd
rlPhaseStartTest
rlRun "objcopy -v --file-alignment=512 --section-alignment=512 --target=efi-app-x86_64 -j .text -j .data -j .dynamic linuxx64.elf.stub foo.pe"
rlRun "pe-inspect foo.pe"
rlRun "./repro.sh foo.pe"
rlRun "objcopy -v --file-alignment=512 --section-alignment=512 --target=efi-app-x86_64 -j .text -j .data -j .dynamic -j .sbat linuxx64.elf.stub foo.pe"
rlRun "pe-inspect foo.pe"
rlRun "./repro.sh foo.pe"
rlRun "objcopy -v --file-alignment=512 --section-alignment=512 --target=efi-app-x86_64 -j .text -j .data -j .dynamic linuxx64.efi.stub foo.pe"
rlRun "pe-inspect foo.pe"
rlRun "./repro.sh foo.pe"
rlRun "objcopy -v --file-alignment=512 --section-alignment=512 --target=efi-app-x86_64 -j .text -j .data -j .dynamic -j .sbat linuxx64.efi.stub foo.pe"
rlRun "pe-inspect foo.pe"
rlRun "./repro.sh foo.pe"
rlPhaseEnd
rlPhaseStartCleanup
buExitTmpDir
rlPhaseEnd
rlJournalPrintText
rlJournalEnd