diff --git a/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/Makefile b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/Makefile new file mode 100644 index 0000000..fd8e9af --- /dev/null +++ b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/Makefile @@ -0,0 +1,56 @@ +# Copyright (c) 2010 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 http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/binutils/Regressions/ld/bz587788-ld_-r-generates-R_X86_64_NONE +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE foo.c module-common.lds + +.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 -r generates R_X86_64_NONE" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: binutils binutils220" >> $(METADATA) + @echo "Requires: binutils gcc44 gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv3" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 587788" >> $(METADATA) + @echo "Architectures: x86_64" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/PURPOSE b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/PURPOSE new file mode 100644 index 0000000..b7dec1d --- /dev/null +++ b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/PURPOSE @@ -0,0 +1,42 @@ +WRONG: + + $ readelf -r foo2.o + + Relocation section '.rela.debug_info' at offset 0x618 contains 11 entries: + Offset Info Type Sym. Value Sym. Name + Addend + 000000000006 00040000000a R_X86_64_32 0000000000000000 .debug_abbrev + 0 + 00000000000c 00080000000a R_X86_64_32 0000000000000000 .debug_str + b + 000000000011 00080000000a R_X86_64_32 0000000000000000 .debug_str + 38 + 000000000015 00080000000a R_X86_64_32 0000000000000000 .debug_str + 6 + 000000000019 000100000001 R_X86_64_64 0000000000000000 .text + 0 + 000000000021 000100000001 R_X86_64_64 0000000000000000 .text + 0 + 000000000029 00060000000a R_X86_64_32 0000000000000000 .debug_line + 0 + 00000000002e 00080000000a R_X86_64_32 0000000000000000 .debug_str + 33 + 00000000003b 000c00000001 R_X86_64_64 0000000000000004 here + 0 + 00000000004b 00080000000a R_X86_64_32 0000000000000000 .debug_str + 0 +-> 000000000058 000000000000 R_X86_64_NONE 0000000000000000 + + Relocation section '.rela.debug_pubnames' at offset 0x720 contains 1 entries: + Offset Info Type Sym. Value Sym. Name + Addend + 000000000006 00050000000a R_X86_64_32 0000000000000000 .debug_info + 0 + + +OK: + + Relocation section '.rela.debug_info' at offset 0x628 contains 10 entries: + Offset Info Type Sym. Value Sym. Name + Addend + 000000000006 00040000000a R_X86_64_32 0000000000000000 .debug_abbrev + 0 + 00000000000c 00080000000a R_X86_64_32 0000000000000000 .debug_str + 1f + 000000000011 00080000000a R_X86_64_32 0000000000000000 .debug_str + 46 + 000000000015 00080000000a R_X86_64_32 0000000000000000 .debug_str + b + 000000000019 000100000001 R_X86_64_64 0000000000000000 .text + 0 + 000000000021 000100000001 R_X86_64_64 0000000000000000 .text + 0 + 000000000029 00060000000a R_X86_64_32 0000000000000000 .debug_line + 0 + 00000000002e 00080000000a R_X86_64_32 0000000000000000 .debug_str + 6 + 00000000003b 000c00000001 R_X86_64_64 0000000000000004 here + 0 + 00000000004b 00080000000a R_X86_64_32 0000000000000000 .debug_str + 0 + + Relocation section '.rela.debug_pubnames' at offset 0x730 contains 1 entries: + Offset Info Type Sym. Value Sym. Name + Addend + 000000000006 00050000000a R_X86_64_32 0000000000000000 .debug_info + 0 + diff --git a/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/foo.c b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/foo.c new file mode 100644 index 0000000..7e8b716 --- /dev/null +++ b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/foo.c @@ -0,0 +1 @@ +int here, there __attribute__ ((section (".discard"))); diff --git a/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/main.fmf b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/main.fmf new file mode 100644 index 0000000..e73e784 --- /dev/null +++ b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/main.fmf @@ -0,0 +1,48 @@ +summary: ld -r generates R_X86_64_NONE +description: "WRONG:\n\n $ readelf -r foo2.o\n \n Relocation section '.rela.debug_info'\ + \ at offset 0x618 contains 11 entries:\n Offset Info Type\ + \ Sym. Value Sym. Name + Addend\n 000000000006 00040000000a R_X86_64_32\ + \ 0000000000000000 .debug_abbrev + 0\n 00000000000c 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + b\n 000000000011 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + 38\n 000000000015 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + 6\n 000000000019 000100000001 R_X86_64_64\ + \ 0000000000000000 .text + 0\n 000000000021 000100000001 R_X86_64_64\ + \ 0000000000000000 .text + 0\n 000000000029 00060000000a R_X86_64_32\ + \ 0000000000000000 .debug_line + 0\n 00000000002e 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + 33\n 00000000003b 000c00000001 R_X86_64_64\ + \ 0000000000000004 here + 0\n 00000000004b 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + 0\n-> 000000000058 000000000000 R_X86_64_NONE\ + \ 0000000000000000\n \n Relocation section '.rela.debug_pubnames'\ + \ at offset 0x720 contains 1 entries:\n Offset Info Type\ + \ Sym. Value Sym. Name + Addend\n 000000000006 00050000000a R_X86_64_32\ + \ 0000000000000000 .debug_info + 0\n\n\nOK:\n\n Relocation section '.rela.debug_info'\ + \ at offset 0x628 contains 10 entries:\n Offset Info Type\ + \ Sym. Value Sym. Name + Addend\n 000000000006 00040000000a R_X86_64_32\ + \ 0000000000000000 .debug_abbrev + 0\n 00000000000c 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + 1f\n 000000000011 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + 46\n 000000000015 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + b\n 000000000019 000100000001 R_X86_64_64\ + \ 0000000000000000 .text + 0\n 000000000021 000100000001 R_X86_64_64\ + \ 0000000000000000 .text + 0\n 000000000029 00060000000a R_X86_64_32\ + \ 0000000000000000 .debug_line + 0\n 00000000002e 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + 6\n 00000000003b 000c00000001 R_X86_64_64\ + \ 0000000000000004 here + 0\n 00000000004b 00080000000a R_X86_64_32\ + \ 0000000000000000 .debug_str + 0\n \n Relocation section '.rela.debug_pubnames'\ + \ at offset 0x730 contains 1 entries:\n Offset Info Type\ + \ Sym. Value Sym. Name + Addend\n 000000000006 00050000000a R_X86_64_32\ + \ 0000000000000000 .debug_info + 0\n\n" +contact: Michal Nowak +component: +- binutils +- binutils220 +test: ./runtest.sh +framework: beakerlib +recommend: +- binutils +- gcc44 +- gcc +duration: 5m +link: +- relates: https://bugzilla.redhat.com/show_bug.cgi?id=587788 +extra-summary: /tools/binutils/Regressions/ld/bz587788-ld_-r-generates-R_X86_64_NONE +extra-task: /tools/binutils/Regressions/ld/bz587788-ld_-r-generates-R_X86_64_NONE diff --git a/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/module-common.lds b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/module-common.lds new file mode 100644 index 0000000..96e0e15 --- /dev/null +++ b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/module-common.lds @@ -0,0 +1,9 @@ +/* + * Common module linker script, always used when linking a module. + * Archs are free to supply their own linker scripts. ld will + * combine them automatically. + */ +SECTIONS { + /DISCARD/ : { *(.discard) } +} + diff --git a/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/runtest.sh b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/runtest.sh new file mode 100755 index 0000000..52b4242 --- /dev/null +++ b/tests/Regression/bz587788-ld_-r-generates-R_X86_64_NONE/runtest.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/binutils/Regressions/ld/bz579696-ld-r-produces-nonzero-sh_addr-values +# Description: .text, .data, and .bss show sh_addr values that are not zero. +# Author: Michal Nowak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010, 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 http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="binutils" + +# Choose the compiler. +GCC=${GCC:-gcc} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlAssertRpm gcc + rlCheckRpm gcc44 + rlCheckRpm binutils220 + + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + cp foo.c module-common.lds $TmpDir + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "$GCC -c foo.c -g -O0" + rlRun "ld -r -o foo2.o -T module-common.lds foo.o" + rlAssertExists foo2.o + readelf -r foo2.o &> readelf.r + cat readelf.r + rlAssertNotGrep R_X86_64_NONE readelf.r + + rm foo2.o foo.o readelf.r + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd