Blame tests/run-annobingroup.sh

Packit 032894
#! /bin/sh
Packit 032894
# Copyright (C) 2018 Red Hat, Inc.
Packit 032894
# This file is part of elfutils.
Packit 032894
#
Packit 032894
# This file is free software; you can redistribute it and/or modify
Packit 032894
# it under the terms of the GNU General Public License as published by
Packit 032894
# the Free Software Foundation; either version 3 of the License, or
Packit 032894
# (at your option) any later version.
Packit 032894
#
Packit 032894
# elfutils is distributed in the hope that it will be useful, but
Packit 032894
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 032894
# GNU General Public License for more details.
Packit 032894
#
Packit 032894
# You should have received a copy of the GNU General Public License
Packit 032894
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 032894
Packit 032894
. $srcdir/test-subr.sh
Packit 032894
Packit 032894
# Testfile generated by annobin, creates group.
Packit 032894
# strip and unstrip it. Check group symbol/name is correct.
Packit 032894
Packit 032894
# echo "int __attribute__((cold)) foo (void) { return 42; }" \
Packit 032894
#      > testfile-annobingroup.c
Packit 032894
# gcc -g -O2 -fplugin=annobin -c testfile-annobingroup.c
Packit 032894
testfiles testfile-annobingroup.o
Packit 032894
Packit 032894
tempfiles merged.elf stripped.elf debugfile1.elf debugfile2.elf debugfile3.elf remerged.elf
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g testfile-annobingroup.o << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [ 7] .gnu.build.attributes..text.unlikely
Packit 032894
  [ 8] .rela.gnu.build.attributes..text.unlikely
Packit 032894
  [ 9] .text.unlikely
Packit 032894
EOF
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile1.elf testfile-annobingroup.o
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [ 7] .gnu.build.attributes..text.unlikely
Packit 032894
  [ 8] .rela.gnu.build.attributes..text.unlikely
Packit 032894
  [ 9] .text.unlikely
Packit 032894
EOF
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g debugfile1.elf << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [ 7] .gnu.build.attributes..text.unlikely
Packit 032894
  [ 8] .rela.gnu.build.attributes..text.unlikely
Packit 032894
  [ 9] .text.unlikely
Packit 032894
EOF
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile1.elf
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g remerged.elf << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [ 7] .gnu.build.attributes..text.unlikely
Packit 032894
  [ 8] .rela.gnu.build.attributes..text.unlikely
Packit 032894
  [ 9] .text.unlikely
Packit 032894
EOF
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup.o remerged.elf
Packit 032894
Packit 032894
# echo "void * __attribute__((cold)) foo (void) { return foo; }"
Packit 032894
#      > testfile-annobingroup-i386.c
Packit 032894
# gcc -fpic -g -O2 -fplugin=annobin -c testfile-annobingroup-i386.c
Packit 032894
testfiles testfile-annobingroup-i386.o
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g testfile-annobingroup-i386.o << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [ 8] .gnu.build.attributes..text.unlikely
Packit 032894
  [ 9] .rel.gnu.build.attributes..text.unlikely
Packit 032894
  [10] .text.unlikely
Packit 032894
Packit 032894
COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contains 1 entry:
Packit 032894
  [13] .text.__x86.get_pc_thunk.ax
Packit 032894
EOF
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile2.elf testfile-annobingroup-i386.o
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [ 8] .gnu.build.attributes..text.unlikely
Packit 032894
  [ 9] .rel.gnu.build.attributes..text.unlikely
Packit 032894
  [10] .text.unlikely
Packit 032894
Packit 032894
COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contains 1 entry:
Packit 032894
  [13] .text.__x86.get_pc_thunk.ax
Packit 032894
EOF
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g debugfile2.elf << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [ 8] .gnu.build.attributes..text.unlikely
Packit 032894
  [ 9] .rel.gnu.build.attributes..text.unlikely
Packit 032894
  [10] .text.unlikely
Packit 032894
Packit 032894
COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contains 1 entry:
Packit 032894
  [13] .text.__x86.get_pc_thunk.ax
Packit 032894
EOF
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile2.elf
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g remerged.elf << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [ 8] .gnu.build.attributes..text.unlikely
Packit 032894
  [ 9] .rel.gnu.build.attributes..text.unlikely
Packit 032894
  [10] .text.unlikely
Packit 032894
Packit 032894
COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contains 1 entry:
Packit 032894
  [13] .text.__x86.get_pc_thunk.ax
Packit 032894
EOF
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup-i386.o remerged.elf
Packit 032894
Packit 032894
# echo "void * foo (void) { return foo; }" > testfile-annobingroup-x86_64.c
Packit 032894
# gcc -g -O2 -fplugin=annobin -c testfile-annobingroup-x86_64.c
Packit 032894
testfiles testfile-annobingroup-x86_64.o
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -g testfile-annobingroup-x86_64.o << EOF
Packit 032894
Packit 032894
Section group [ 1] '.group' with signature '.text.hot.group' contains 3 entries:
Packit 032894
  [11] .text.hot
Packit 032894
  [12] .gnu.build.attributes.hot
Packit 032894
  [13] .rela.gnu.build.attributes.hot
Packit 032894
Packit 032894
Section group [ 2] '.group' with signature '.text.unlikely.group' contains 3 entries:
Packit 032894
  [14] .text.unlikely
Packit 032894
  [15] .gnu.build.attributes.unlikely
Packit 032894
  [16] .rela.gnu.build.attributes.unlikely
Packit 032894
Packit 032894
Section group [ 3] '.group' with signature '.text.hot..group' contains 1 entry:
Packit 032894
  [26] .text.hot
Packit 032894
Packit 032894
Section group [ 4] '.group' with signature '.text.unlikely..group' contains 1 entry:
Packit 032894
  [27] .text.unlikely
Packit 032894
EOF
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile3.elf testfile-annobingroup-x86_64.o
Packit 032894
Packit 032894
# This would/should work, except for the unknown NOTEs.
Packit 032894
# testrun ${abs_top_builddir}/src/elflint --gnu stripped.elf
Packit 032894
# testrun ${abs_top_builddir}/src/elflint --gnu --debug debugfile3.elf
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile3.elf
Packit 032894
Packit 032894
testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup-x86_64.o remerged.elf
Packit 032894
Packit 032894
exit 0