Blame tests/run-copymany-sections.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
# Same as run-copyadd-sections.sh, but for many > 0xffff sections.
Packit 032894
# Doesn't use mmap for addsections since that doesn't work.
Packit 032894
# ELF_C_RDWR_MMAP needs mremap which will fail since it needs too 
Packit 032894
# much space and the original mmap cannot move.
Packit 032894
Packit 032894
. $srcdir/test-subr.sh
Packit 032894
Packit 032894
test_copy_and_add ()
Packit 032894
{
Packit 032894
  in_file="$1"
Packit 032894
  out_file="${in_file}.copy"
Packit 032894
  out_file_mmap="${out_file}.mmap"
Packit 032894
Packit 032894
  tempfiles ${out_file} ${out_file_mmap} readelf.out
Packit 032894
Packit 032894
  # Can we copy the file?
Packit 032894
  testrun ${abs_builddir}/elfcopy ${in_file} ${out_file}
Packit 032894
  testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file}
Packit 032894
Packit 032894
  # Can we add a section (in-place)?
Packit 032894
  testrun ${abs_builddir}/addsections 65535 ${out_file}
Packit 032894
  testrun ${abs_top_builddir}/src/readelf -S ${out_file} > readelf.out
Packit 032894
  nr=$(grep '.extra' readelf.out | wc -l)
Packit 032894
  # We try twice...
Packit 032894
  if test ${nr} != 65535 -a ${nr} != 131070; then
Packit 032894
    # Show what went wrong
Packit 032894
    testrun ${abs_top_builddir}/src/readelf -S ${out_file}
Packit 032894
    exit 1
Packit 032894
  fi
Packit 032894
Packit 032894
  # Can we copy the file using ELF_C_WRITE_MMAP?
Packit 032894
  testrun ${abs_builddir}/elfcopy --mmap ${in_file} ${out_file_mmap}
Packit 032894
  testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file_mmap}
Packit 032894
Packit 032894
  # Don't try to add using mmap (see above)
Packit 032894
}
Packit 032894
Packit 032894
# A collection of random testfiles to test 32/64bit, little/big endian
Packit 032894
# and non-ET_REL (with phdrs)/ET_REL (without phdrs).
Packit 032894
# Try to add 0xffff sections twice.
Packit 032894
Packit 032894
# 32bit, big endian, rel
Packit 032894
testfiles testfile29
Packit 032894
test_copy_and_add testfile29
Packit 032894
test_copy_and_add testfile29.copy
Packit 032894
Packit 032894
# 64bit, big endian, rel
Packit 032894
testfiles testfile23
Packit 032894
test_copy_and_add testfile23
Packit 032894
test_copy_and_add testfile23.copy
Packit 032894
Packit 032894
# 32bit, little endian, rel
Packit 032894
testfiles testfile9
Packit 032894
test_copy_and_add testfile9
Packit 032894
test_copy_and_add testfile9.copy
Packit 032894
Packit 032894
# 64bit, little endian, rel
Packit 032894
testfiles testfile38
Packit 032894
test_copy_and_add testfile38
Packit 032894
test_copy_and_add testfile38.copy
Packit 032894
Packit 032894
# 32bit, big endian, non-rel
Packit 032894
testfiles testfile26
Packit 032894
test_copy_and_add testfile26
Packit 032894
test_copy_and_add testfile26.copy
Packit 032894
Packit 032894
# 64bit, big endian, non-rel
Packit 032894
testfiles testfile27
Packit 032894
test_copy_and_add testfile27
Packit 032894
test_copy_and_add testfile27.copy
Packit 032894
Packit 032894
# 32bit, little endian, non-rel
Packit 032894
testfiles testfile
Packit 032894
test_copy_and_add testfile
Packit 032894
test_copy_and_add testfile.copy
Packit 032894
Packit 032894
# 64bit, little endian, non-rel
Packit 032894
testfiles testfile10
Packit 032894
test_copy_and_add testfile10
Packit 032894
test_copy_and_add testfile10.copy
Packit 032894
Packit 032894
exit 0