From 14a74d027dad02e96544c619839c539c4b8f7d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kadl=C4=8D=C3=ADk?= Date: Tue, 4 May 2021 12:54:49 +0200 Subject: [PATCH] Import RHEL's regression test for #531269 --- .../Makefile | 59 +++++++++++++++++++ .../PURPOSE | 0 .../bar.c | 19 ++++++ .../foo.c | 7 +++ .../main.fmf | 19 ++++++ .../runtest.sh | 57 ++++++++++++++++++ 6 files changed, 161 insertions(+) create mode 100644 tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/Makefile create mode 100644 tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/PURPOSE create mode 100644 tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/bar.c create mode 100644 tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/foo.c create mode 100644 tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/main.fmf create mode 100755 tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/runtest.sh diff --git a/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/Makefile b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/Makefile new file mode 100644 index 0000000..09d7dee --- /dev/null +++ b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/Makefile @@ -0,0 +1,59 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 Red Hat, Inc. All rights reserved. +# +# 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/Regressions/ld/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE bar.c foo.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Michal Nowak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: ld fails to merge different visibility for the same symbol in distinct object files" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: binutils binutils220" >> $(METADATA) + @echo "Requires: binutils binutils220 gcc44 gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 531269" >> $(METADATA) + @echo "Architectures: i386 x86_64" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/PURPOSE b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/PURPOSE new file mode 100644 index 0000000..e69de29 diff --git a/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/bar.c b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/bar.c new file mode 100644 index 0000000..d74dcd5 --- /dev/null +++ b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/bar.c @@ -0,0 +1,19 @@ +int foo __attribute__ ((section (".gnu.linkonce.d.1"), + visibility ("hidden"))) = 1; +int +__attribute__ ((section (".gnu.linkonce.t.1"), visibility ("hidden"))) +bar () +{ + return 1; +} +int +get_foo () +{ + return foo; +} +int +get_bar () +{ + return bar (); +} + diff --git a/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/foo.c b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/foo.c new file mode 100644 index 0000000..7834bd4 --- /dev/null +++ b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/foo.c @@ -0,0 +1,7 @@ +int foo __attribute__ ((section (".gnu.linkonce.d.1"))) = 1; +int +__attribute__ ((section (".gnu.linkonce.t.1"))) +bar () +{ + return 1; +} diff --git a/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/main.fmf b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/main.fmf new file mode 100644 index 0000000..d0fb32f --- /dev/null +++ b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/main.fmf @@ -0,0 +1,19 @@ +summary: ld fails to merge different visibility for the same symbol in distinct object + files +description: '' +contact: Michal Nowak +component: +- binutils +- binutils220 +test: ./runtest.sh +framework: beakerlib +recommend: +- binutils +- binutils220 +- gcc44 +- gcc +duration: 5m +link: +- relates: https://bugzilla.redhat.com/show_bug.cgi?id=531269 +extra-summary: /tools/binutils/Regressions/ld/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol +extra-task: /tools/binutils/Regressions/ld/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol diff --git a/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/runtest.sh b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/runtest.sh new file mode 100755 index 0000000..e89c252 --- /dev/null +++ b/tests/Regression/531269-ld-fails-to-merge-different-visibility-for-the-same-symbol/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 Red Hat, Inc. All rights reserved. +# +# 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Author: Michal Nowak +# +# Include rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="binutils" + +# Choose the compiler. +GCC=${GCC:-gcc} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlShowPackageVersion $PACKAGE + rlShowRunningKernel + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + cp foo.c bar.c $TmpDir + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest "gcc=$GCC Testing" + rlRun "$GCC -fPIC -c -o foo.o foo.c" 0 "Compile foo.c => foo.o" + rlRun "$GCC -fPIC -c -o bar.o bar.c" 0 "Compile bar.c => bar.o" + rlRun "ld -shared -o foobar.so foo.o bar.o" 0 "Link foo.o & bar.o => foobar.so" + rlAssertExists foobar.so + rm foobar.so foo.o bar.o + rlPhaseEnd + + rlPhaseStartCleanup Cleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd + rlJournalPrintText +rlJournalEnd