diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca60a53..520f622 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/linuxx64.efi.stub b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/linuxx64.efi.stub new file mode 100644 index 0000000..27a6304 Binary files /dev/null and b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/linuxx64.efi.stub differ diff --git a/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/linuxx64.elf.stub b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/linuxx64.elf.stub new file mode 100644 index 0000000..70c789e Binary files /dev/null and b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/linuxx64.elf.stub differ diff --git a/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/main.fmf b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/main.fmf new file mode 100644 index 0000000..12c5138 --- /dev/null +++ b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/main.fmf @@ -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 diff --git a/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/repro.sh b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/repro.sh new file mode 100755 index 0000000..0c8efd2 --- /dev/null +++ b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/repro.sh @@ -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" diff --git a/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/test.sh b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/test.sh new file mode 100755 index 0000000..c12d5fb --- /dev/null +++ b/tests/bugs/objcopy-doesnt-align-sections-with-section-alignment-set-section-alignment/test.sh @@ -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