mirror of
https://github.com/openharmony/third_party_elfutils.git
synced 2026-08-27 04:41:15 -04:00
elfcompress: New utility.
Usage: elfcompress [OPTION...] FILE...
Compress or decompress sections in an ELF file.
-f, --force Force compression of section even if it would
become larger
-n, --name=SECTION SECTION name to (de)compress, SECTION is an
extended wildcard pattern (defaults to
'.?(z)debug*')
-o, --output=FILE Place (de)compressed output into FILE
-p, --permissive Relax a few rules to handle slightly broken ELF
files
-q, --quiet Be silent when a section cannot be compressed
-t, --type=TYPE What type of compression to apply. TYPE can be
'none' (decompress), 'zlib' (ELF ZLIB compression,
the default, 'zlib-gabi' is an alias) or
'zlib-gnu' (.zdebug GNU style compression, 'gnu'
is an alias)
-v, --verbose Print a message for each section being
(de)compressed
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
Signed-off-by: Mark Wielaard <mjw@redhat.com>
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2015-12-16 Mark Wielaard <mjw@redhat.com>
|
||||
|
||||
* elfcompress.c: New file.
|
||||
* Makefile.am (bin_PROGRAMS): Add elfcompress.
|
||||
(elfcompress_LDADD): New variable.
|
||||
|
||||
2015-12-18 Mark Wielaard <mjw@redhat.com>
|
||||
|
||||
* elflint.c (section_flags_string): Add NEWFLAG COMPRESSED.
|
||||
|
||||
+2
-1
@@ -35,7 +35,7 @@ native_ld = @native_ld@
|
||||
base_cpu = @base_cpu@
|
||||
|
||||
bin_PROGRAMS = readelf nm size strip ld elflint findtextrel addr2line \
|
||||
elfcmp objdump ranlib strings ar unstrip stack
|
||||
elfcmp objdump ranlib strings ar unstrip stack elfcompress
|
||||
|
||||
|
||||
ld_dsos = libld_elf_i386_pic.a
|
||||
@@ -125,6 +125,7 @@ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
|
||||
ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
|
||||
unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
|
||||
stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl $(demanglelib)
|
||||
elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
|
||||
|
||||
ldlex.o: ldscript.c
|
||||
ldlex_no_Werror = yes
|
||||
|
||||
+1321
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,9 @@
|
||||
2015-12-16 Mark Wielaard <mjw@redhat.com>
|
||||
|
||||
* run-compress-test.sh: New test.
|
||||
* Makefile.am (TESTS): Add run-compress-test.sh.
|
||||
(EXTRA_DISTS): Likewise.
|
||||
|
||||
2015-11-26 Mark Wielaard <mjw@redhat.com>
|
||||
|
||||
* zstrptr.c: New file.
|
||||
|
||||
+3
-2
@@ -123,7 +123,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
|
||||
run-getsrc-die.sh run-strptr.sh newdata elfstrtab dwfl-proc-attach \
|
||||
elfshphehdr run-lfs-symbols.sh run-dwelfgnucompressed.sh \
|
||||
run-elfgetchdr.sh \
|
||||
run-elfgetzdata.sh run-elfputzdata.sh run-zstrptr.sh
|
||||
run-elfgetzdata.sh run-elfputzdata.sh run-zstrptr.sh \
|
||||
run-compress-test.sh
|
||||
|
||||
if !BIARCH
|
||||
export ELFUTILS_DISABLE_BIARCH = 1
|
||||
@@ -320,7 +321,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
|
||||
testfile-zgabi32.bz2 testfile-zgabi64.bz2 \
|
||||
testfile-zgabi32be.bz2 testfile-zgabi64be.bz2 \
|
||||
run-elfgetchdr.sh run-elfgetzdata.sh run-elfputzdata.sh \
|
||||
run-zstrptr.sh
|
||||
run-zstrptr.sh run-compress-test.sh
|
||||
|
||||
if USE_VALGRIND
|
||||
valgrind_cmd='valgrind -q --leak-check=full --error-exitcode=1'
|
||||
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#! /bin/sh
|
||||
# Copyright (C) 2015 Red Hat, Inc.
|
||||
# This file is part of elfutils.
|
||||
#
|
||||
# This file 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.
|
||||
#
|
||||
# elfutils 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/>.
|
||||
|
||||
. $srcdir/test-subr.sh
|
||||
|
||||
# uncompress -> gnucompress -> uncompress -> elfcompress -> uncompress
|
||||
testrun_elfcompress_file()
|
||||
{
|
||||
infile="$1"
|
||||
uncompressedfile="${infile}.uncompressed"
|
||||
tempfiles "$uncompressedfile"
|
||||
|
||||
echo "uncompress $infile -> $uncompressedfile"
|
||||
testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${uncompressedfile} ${infile}
|
||||
testrun ${abs_top_builddir}/src/elflint --gnu-ld ${uncompressedfile}
|
||||
|
||||
SIZE_uncompressed=$(stat -c%s $uncompressedfile)
|
||||
|
||||
gnucompressedfile="${infile}.gnu"
|
||||
tempfiles "$gnucompressedfile"
|
||||
echo "compress gnu $uncompressedfile -> $gnucompressedfile"
|
||||
testrun ${abs_top_builddir}/src/elfcompress -v -t gnu -o ${gnucompressedfile} ${uncompressedfile}
|
||||
testrun ${abs_top_builddir}/src/elflint --gnu-ld ${gnucompressedfile}
|
||||
|
||||
SIZE_gnucompressed=$(stat -c%s $gnucompressedfile)
|
||||
test $SIZE_gnucompressed -lt $SIZE_uncompressed ||
|
||||
{ echo "*** failure $gnucompressedfile not smaller"; exit -1; }
|
||||
|
||||
gnuuncompressedfile="${infile}.gnu.uncompressed"
|
||||
tempfiles "$gnuuncompressedfile"
|
||||
echo "uncompress $gnucompressedfile -> $gnuuncompressedfile"
|
||||
testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${gnuuncompressedfile} ${gnucompressedfile}
|
||||
testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${gnuuncompressedfile}
|
||||
|
||||
elfcompressedfile="${infile}.gabi"
|
||||
tempfiles "$elfcompressedfile"
|
||||
echo "compress gabi $uncompressedfile -> $elfcompressedfile"
|
||||
testrun ${abs_top_builddir}/src/elfcompress -v -t zlib -o ${elfcompressedfile} ${uncompressedfile}
|
||||
testrun ${abs_top_builddir}/src/elflint --gnu-ld ${elfcompressedfile}
|
||||
|
||||
SIZE_elfcompressed=$(stat -c%s $elfcompressedfile)
|
||||
test $SIZE_elfcompressed -lt $SIZE_uncompressed ||
|
||||
{ echo "*** failure $elfcompressedfile not smaller"; exit -1; }
|
||||
|
||||
elfuncompressedfile="${infile}.gabi.uncompressed"
|
||||
tempfiles "$elfuncompressedfile"
|
||||
echo "uncompress $elfcompressedfile -> $elfuncompressedfile"
|
||||
testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${elfuncompressedfile} ${elfcompressedfile}
|
||||
testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${elfuncompressedfile}
|
||||
}
|
||||
|
||||
testrun_elfcompress()
|
||||
{
|
||||
testfile="$1"
|
||||
testfiles ${testfile}
|
||||
testrun_elfcompress_file ${testfile}
|
||||
|
||||
# Merge the string tables to make things a little more interesting.
|
||||
mergedfile="${testfile}.merged"
|
||||
tempfiles ${mergedfile}
|
||||
echo "merging string tables ${testfile} -> ${mergedfile}"
|
||||
testrun ${abs_top_builddir}/tests/elfstrmerge -o ${mergedfile} ${testfile}
|
||||
testrun_elfcompress_file ${mergedfile}
|
||||
}
|
||||
|
||||
# Random ELF32 testfile
|
||||
testrun_elfcompress testfile4
|
||||
|
||||
# Random ELF64 testfile
|
||||
testrun_elfcompress testfile12
|
||||
|
||||
# Random ELF64BE testfile
|
||||
testrun_elfcompress testfileppc64
|
||||
|
||||
# Random ELF32BE testfile
|
||||
testrun_elfcompress testfileppc32
|
||||
|
||||
# Already compressed files
|
||||
testrun_elfcompress testfile-zgnu64
|
||||
testrun_elfcompress testfile-zgnu64be
|
||||
testrun_elfcompress testfile-zgabi64
|
||||
testrun_elfcompress testfile-zgabi64be
|
||||
testrun_elfcompress testfile-zgnu32
|
||||
testrun_elfcompress testfile-zgnu32be
|
||||
testrun_elfcompress testfile-zgabi32
|
||||
testrun_elfcompress testfile-zgabi32be
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user