diff --git a/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/Makefile b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/Makefile new file mode 100644 index 0000000..585a0ad --- /dev/null +++ b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/binutils/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x +# Description: Test for BZ#872148 (PIE + __thread produce text relocations on s390(x)) +# 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/binutils/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE reproducer6.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Milos Prchlik " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for BZ#872148 (PIE + __thread produce text relocations on s390(x))" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: binutils" >> $(METADATA) + @echo "Requires: binutils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: yes" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 872148" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/PURPOSE b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/PURPOSE new file mode 100644 index 0000000..c01b776 --- /dev/null +++ b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/PURPOSE @@ -0,0 +1,17 @@ +PURPOSE of /tools/binutils/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x +Description: Test for BZ#872148 (PIE + __thread produce text relocations on s390(x)) +Author: Milos Prchlik +Bug summary: PIE + __thread produce text relocations on s390(x) +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=872148 + +Requires systemd without a workaround: + +# PIE is broken on s390 (#868839, #872148) +%ifnarch s390 s390x +%global _hardened_build 1 +%endif + +^^ this is a workaround that makes bug disappear for this particular reproducer. +So, fetch systemd srpm, comment this condition out, rebuild, install, reboot, then +you can run this tests. One day I may make this part automatic but replacing systemd +wouldn't be seen as a good behaviour by other tests run after this task, so not yet. diff --git a/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/main.fmf b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/main.fmf new file mode 100644 index 0000000..c761004 --- /dev/null +++ b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/main.fmf @@ -0,0 +1,30 @@ +summary: Test for BZ#872148 (PIE + __thread produce text relocations on s390(x)) +description: | + Bug summary: PIE + __thread produce text relocations on s390(x) + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=872148 + + Requires systemd without a workaround: + + # PIE is broken on s390 (#868839, #872148) + %ifnarch s390 s390x + %global _hardened_build 1 + %endif + + ^^ this is a workaround that makes bug disappear for this particular reproducer. + So, fetch systemd srpm, comment this condition out, rebuild, install, reboot, then + you can run this tests. One day I may make this part automatic but replacing systemd + wouldn't be seen as a good behaviour by other tests run after this task, so not yet. +contact: Milos Prchlik +component: +- binutils +test: ./runtest.sh +framework: beakerlib +recommend: +- binutils +- elfutils +- gcc +duration: 15m +link: +- relates: https://bugzilla.redhat.com/show_bug.cgi?id=872148 +extra-summary: /tools/binutils/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x +extra-task: /tools/binutils/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x diff --git a/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/reproducer6.c b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/reproducer6.c new file mode 100644 index 0000000..29f574e --- /dev/null +++ b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/reproducer6.c @@ -0,0 +1,20 @@ +/* + This reproducer is taken from https://sourceware.org/bugzilla/show_bug.cgi?id=6443 + Author is Jakub Jelinek + + gcc -O2 -pie -fpie -o reproducer6 reproducer6.c + eu-readelf -d reproducer6 | grep TEXTREL + test $? -eq 0 && echo FAIL || echo PASS +*/ + +__thread int a; +__thread int b __attribute((tls_model ("local-exec"))); +__thread int c __attribute((tls_model ("initial-exec"))); +__thread int d __attribute((tls_model ("local-dynamic"))); +__thread int e __attribute((tls_model ("global-dynamic"))); + +int +main (void) +{ + return a + b + c + d + e; +} diff --git a/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/runtest.sh b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/runtest.sh new file mode 100755 index 0000000..3e265d0 --- /dev/null +++ b/tests/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x/runtest.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/binutils/Regression/bz872148-PIE-thread-produce-text-relocations-on-s390-x +# Description: Test for BZ#872148 (PIE + __thread produce text relocations on s390(x)) +# 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 + +PACKAGES="binutils" + +rlJournalStart + rlPhaseStartSetup + rlLogInfo "PACKAGES=$PACKAGES" + rlLogInfo "REQUIRES=$REQUIRES" + rlLogInfo "COLLECTIONS=$COLLECTIONS" + rlLogInfo "SKIP_COLLECTION_METAPACKAGE_CHECK=$SKIP_COLLECTION_METAPACKAGE_CHECK" + + # 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. + _COLLECTIONS="$COLLECTIONS" + if ! test -z $SKIP_COLLECTION_METAPACKAGE_CHECK; then + for c in $SKIP_COLLECTION_METAPACKAGE_CHECK; do + rlLogInfo "ignoring metapackage check for collection $c" + export COLLECTIONS=$(shopt -s extglob && echo ${COLLECTIONS//$c/}) + done + fi + + rlLogInfo "(without skipped) COLLECTIONS=$COLLECTIONS" + + rlAssertRpm --all + + export COLLECTIONS="$_COLLECTIONS" + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp reproducer6.c $TmpDir/" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc -O2 -pie -fpie -o reproducer6 reproducer6.c" + rlRun "eu-readelf -d reproducer6 > elfutils.log" + rlRun "readelf -d reproducer6 > binutils.log" + rlAssertNotGrep "TEXTREL" binutils.log + rlAssertNotGrep "TEXTREL" elfutils.log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" # $TmpDir + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd