summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2015-10-21 01:30:44 +0200
committerMark Wielaard <mjw@redhat.com>2015-10-27 20:53:35 +0100
commitfbd1d4c5ba44997e3a13f4022b660c4f055f5378 (patch)
tree182d95d9a0c1a833b1930379003f11cf7d2b6837
parentf157480e418b8476871afc7c2e7ba1ad7f01330f (diff)
readelf: Extend -z to dumping hex and string sections (-x and -p).upstream/mjw/compress
-z, --decompress Show compression information for compressed sections (when used with -S); decompress section before dumping data (when used with -p or -x) Signed-off-by: Mark Wielaard <mjw@redhat.com>
-rw-r--r--src/ChangeLog7
-rw-r--r--src/readelf.c52
-rw-r--r--tests/ChangeLog7
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/run-readelf-zp.sh271
-rwxr-xr-xtests/run-readelf-zx.sh66
6 files changed, 396 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4e62c8e9..03a29c64 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-20 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (options): Expand -z help text.
+ (dump_data_section): Check whether we need and can decompress section
+ data and call elf_rawzdata if so,
+ (print_string_section): Likewise.
+
2015-10-16 Mark Wielaard <mjw@redhat.com>
* readelf.c (argp_option): Describe --decompress,-z.
diff --git a/src/readelf.c b/src/readelf.c
index 6441c561..2c10a34e 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -113,7 +113,7 @@ static const struct argp_option options[] =
{ "wide", 'W', NULL, 0,
N_("Ignored for compatibility (lines always wide)"), 0 },
{ "decompress", 'z', NULL, 0,
- N_("Show compression information for compressed sections (when used with -S)."), 0 },
+ N_("Show compression information for compressed sections (when used with -S); decompress section before dumping data (when used with -p or -x)"), 0 },
{ NULL, 0, NULL, 0, NULL, 0 }
};
@@ -9444,16 +9444,33 @@ dump_data_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
elf_ndxscn (scn), name);
else
{
+ if (print_decompress)
+ {
+ /* We try to decompress the section, but keep the old shdr around
+ so we can show both the original shdr size and the uncompressed
+ data size. We don't check for errors, if the section wasn't
+ compressed before, that is fine too. */
+ GElf_Shdr mem;
+ gelf_zscn_compress (scn, &mem, ELF_ZSCN_T_NONE, 0);
+ }
+
Elf_Data *data = elf_rawdata (scn, NULL);
if (data == NULL)
error (0, 0, gettext ("cannot get data for section [%zu] '%s': %s"),
elf_ndxscn (scn), name, elf_errmsg (-1));
else
{
- printf (gettext ("\nHex dump of section [%zu] '%s', %" PRIu64
- " bytes at offset %#0" PRIx64 ":\n"),
- elf_ndxscn (scn), name,
- shdr->sh_size, shdr->sh_offset);
+ if (data->d_size == shdr->sh_size)
+ printf (gettext ("\nHex dump of section [%zu] '%s', %" PRIu64
+ " bytes at offset %#0" PRIx64 ":\n"),
+ elf_ndxscn (scn), name,
+ shdr->sh_size, shdr->sh_offset);
+ else
+ printf (gettext ("\nHex dump of section [%zu] '%s', %" PRIu64
+ " bytes (%zd uncompressed) at offset %#0"
+ PRIx64 ":\n"),
+ elf_ndxscn (scn), name,
+ shdr->sh_size, data->d_size, shdr->sh_offset);
hex_dump (data->d_buf, data->d_size);
}
}
@@ -9467,16 +9484,33 @@ print_string_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
elf_ndxscn (scn), name);
else
{
+ if (print_decompress)
+ {
+ /* We try to decompress the section, but keep the old shdr around
+ so we can show both the original shdr size and the uncompressed
+ data size. We don't check for errors, if the section wasn't
+ compressed before, that is fine too. */
+ GElf_Shdr mem;
+ gelf_zscn_compress (scn, &mem, ELF_ZSCN_T_NONE, 0);
+ }
+
Elf_Data *data = elf_rawdata (scn, NULL);
if (data == NULL)
error (0, 0, gettext ("cannot get data for section [%zu] '%s': %s"),
elf_ndxscn (scn), name, elf_errmsg (-1));
else
{
- printf (gettext ("\nString section [%zu] '%s' contains %" PRIu64
- " bytes at offset %#0" PRIx64 ":\n"),
- elf_ndxscn (scn), name,
- shdr->sh_size, shdr->sh_offset);
+ if (data->d_size == shdr->sh_size)
+ printf (gettext ("\nString section [%zu] '%s' contains %" PRIu64
+ " bytes at offset %#0" PRIx64 ":\n"),
+ elf_ndxscn (scn), name,
+ shdr->sh_size, shdr->sh_offset);
+ else
+ printf (gettext ("\nString section [%zu] '%s' contains %" PRIu64
+ " bytes (%zd uncompressed) at offset %#0"
+ PRIx64 ":\n"),
+ elf_ndxscn (scn), name,
+ shdr->sh_size, data->d_size, shdr->sh_offset);
const char *start = data->d_buf;
const char *const limit = start + data->d_size;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 6a7e4959..d5ef82a0 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-20 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-zx.sh: New test.
+ * run-readelf-zp.sh: Likewise.
+ * Makefile.am (TESTS): Add run-readelf-zx.sh and run-readelf-zp.sh.
+ (EXTRA_DIST): Likewise.
+
2015-10-21 Mark Wielaard <mjw@redhat.com>
* Makefile.am (check_PROGRAMS): Add elfgetzdata and elfputzdata.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aae21660..8843ae30 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -116,7 +116,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-backtrace-core-s390x.sh run-backtrace-core-s390.sh \
run-backtrace-core-aarch64.sh \
run-backtrace-demangle.sh run-stack-d-test.sh run-stack-i-test.sh \
- run-stack-demangled-test.sh \
+ run-stack-demangled-test.sh run-readelf-zx.sh run-readelf-zp.sh \
run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \
run-linkmap-cut.sh run-aggregate-size.sh vdsosyms run-readelf-A.sh \
run-getsrc-die.sh run-strptr.sh newdata elfstrtab dwfl-proc-attach \
@@ -296,6 +296,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-stack-demangled-test.sh \
testfiledwarfinlines.bz2 testfiledwarfinlines.core.bz2 \
run-readelf-zdebug.sh testfile-debug.bz2 testfile-zdebug.bz2 \
+ run-readelf-zx.sh run-readelf-zp.sh \
run-deleted.sh run-linkmap-cut.sh linkmap-cut-lib.so.bz2 \
linkmap-cut.bz2 linkmap-cut.core.bz2 \
run-aggregate-size.sh testfile-sizes1.o.bz2 testfile-sizes2.o.bz2 \
diff --git a/tests/run-readelf-zp.sh b/tests/run-readelf-zp.sh
new file mode 100755
index 00000000..872126c5
--- /dev/null
+++ b/tests/run-readelf-zp.sh
@@ -0,0 +1,271 @@
+#! /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
+
+# See run-readelf-zdebug.sh for testfile.
+
+testfiles testfile-zdebug
+testrun_compare ${abs_top_builddir}/src/readelf -z -p.zdebug_str testfile-zdebug <<\EOF
+
+String section [35] '.zdebug_str' contains 2431 bytes (6433 uncompressed) at offset 0x1da3:
+ [ 0] UINT64_MAX 18446744073709551615UL
+ [ 22] __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L)
+ [ 5c] __linux 1
+ [ 66] __SIZEOF_SIZE_T__ 8
+ [ 7a] __UINTPTR_TYPE__ long unsigned int
+ [ 9d] __SIZEOF_POINTER__ 8
+ [ b2] __UINT8_MAX__ 255
+ [ c4] __PTRDIFF_MAX__ 9223372036854775807L
+ [ e9] __DEC64_MANT_DIG__ 16
+ [ ff] __FLT_RADIX__ 2
+ [ 10f] __DEC32_MIN__ 1E-95DF
+ [ 125] __unix__ 1
+ [ 130] testfile-zdebug.c
+ [ 142] __UINT_LEAST64_MAX__ 18446744073709551615UL
+ [ 16e] __SIZEOF_WINT_T__ 4
+ [ 182] __LONG_MAX__ 9223372036854775807L
+ [ 1a4] __LDBL_MIN__ 3.36210314311209350626e-4932L
+ [ 1cf] __GCC_ATOMIC_SHORT_LOCK_FREE 2
+ [ 1ee] __LP64__ 1
+ [ 1f9] __UINT64_C(c) c ## UL
+ [ 20f] __DBL_HAS_INFINITY__ 1
+ [ 226] __SSE2_MATH__ 1
+ [ 236] __linux__ 1
+ [ 242] __STDC_HOSTED__ 1
+ [ 254] __WINT_MIN__ 0U
+ [ 264] __x86_64__ 1
+ [ 271] __UINT32_TYPE__ unsigned int
+ [ 28e] __UINT_LEAST8_MAX__ 255
+ [ 2a6] __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
+ [ 2d7] __FLT_MAX__ 3.40282346638528859812e+38F
+ [ 2ff] long unsigned int
+ [ 311] __DBL_MANT_DIG__ 53
+ [ 325] linux 1
+ [ 32d] __DBL_HAS_QUIET_NAN__ 1
+ [ 345] __UINT8_TYPE__ unsigned char
+ [ 362] __DEC32_MAX_EXP__ 97
+ [ 377] __INT32_TYPE__ int
+ [ 38a] __SIG_ATOMIC_TYPE__ int
+ [ 3a2] __DEC64_MAX_EXP__ 385
+ [ 3b8] __DBL_MIN_EXP__ (-1021)
+ [ 3d0] _LP64 1
+ [ 3d8] __LDBL_HAS_INFINITY__ 1
+ [ 3f0] __INT_FAST64_TYPE__ long int
+ [ 40d] __gnu_linux__ 1
+ [ 41d] __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+ [ 43e] __UINT_FAST64_TYPE__ long unsigned int
+ [ 465] __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+ [ 48c] __UINT16_MAX__ 65535
+ [ 4a1] __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+ [ 4ce] __PRAGMA_REDEFINE_EXTNAME 1
+ [ 4ea] __INT_LEAST16_TYPE__ short int
+ [ 509] __k8__ 1
+ [ 512] __DECIMAL_DIG__ 21
+ [ 525] main
+ [ 52a] __DBL_MAX__ ((double)1.79769313486231570815e+308L)
+ [ 55d] __INT16_TYPE__ short int
+ [ 576] __LDBL_HAS_QUIET_NAN__ 1
+ [ 58f] __SIZEOF_DOUBLE__ 8
+ [ 5a3] __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
+ [ 5ca] __ATOMIC_SEQ_CST 5
+ [ 5dd] __UINT64_TYPE__ long unsigned int
+ [ 5ff] __INT_LEAST32_TYPE__ int
+ [ 618] __INT_LEAST64_MAX__ 9223372036854775807L
+ [ 641] __OPTIMIZE__ 1
+ [ 650] __INTMAX_C(c) c ## L
+ [ 665] __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
+ [ 687] __INT_FAST8_MAX__ 127
+ [ 69d] __PTRDIFF_TYPE__ long int
+ [ 6b7] __LDBL_MIN_EXP__ (-16381)
+ [ 6d1] __SIZEOF_LONG_LONG__ 8
+ [ 6e8] __FLT_DIG__ 6
+ [ 6f6] __UINTMAX_MAX__ 18446744073709551615UL
+ [ 71d] __SIZEOF_WCHAR_T__ 4
+ [ 732] __INT64_C(c) c ## L
+ [ 746] __UINTPTR_MAX__ 18446744073709551615UL
+ [ 76d] __FLT_MAX_10_EXP__ 38
+ [ 783] __FLT_MIN__ 1.17549435082228750797e-38F
+ [ 7ab] __UINT_LEAST64_TYPE__ long unsigned int
+ [ 7d3] __SIZEOF_LONG_DOUBLE__ 16
+ [ 7ed] __SIZE_MAX__ 18446744073709551615UL
+ [ 811] __INT8_C(c) c
+ [ 81f] __amd64__ 1
+ [ 82b] __INT_LEAST64_TYPE__ long int
+ [ 849] __INT_FAST64_MAX__ 9223372036854775807L
+ [ 871] __DEC_EVAL_METHOD__ 2
+ [ 887] __DEC32_MAX__ 9.999999E96DF
+ [ 8a3] __GNUC_MINOR__ 8
+ [ 8b4] __WCHAR_MAX__ 2147483647
+ [ 8cd] __SIZE_TYPE__ long unsigned int
+ [ 8ed] __INT8_MAX__ 127
+ [ 8fe] __INTMAX_MAX__ 9223372036854775807L
+ [ 922] __ATOMIC_HLE_RELEASE 131072
+ [ 93e] __FLT_HAS_QUIET_NAN__ 1
+ [ 956] __DBL_EPSILON__ ((double)2.22044604925031308085e-16L)
+ [ 98c] __FLT_MIN_EXP__ (-125)
+ [ 9a3] __INT_LEAST8_MAX__ 127
+ [ 9ba] __SIZEOF_INT128__ 16
+ [ 9cf] __INTPTR_MAX__ 9223372036854775807L
+ [ 9f3] __INTPTR_TYPE__ long int
+ [ a0c] __LDBL_MIN_10_EXP__ (-4931)
+ [ a28] __GCC_ATOMIC_POINTER_LOCK_FREE 2
+ [ a49] __UINT_LEAST32_MAX__ 4294967295U
+ [ a6a] __SIZEOF_SHORT__ 2
+ [ a7d] __LDBL_MAX_10_EXP__ 4932
+ [ a96] __INT16_C(c) c
+ [ aa5] __MMX__ 1
+ [ aaf] unix 1
+ [ ab6] __FLT_MAX_EXP__ 128
+ [ aca] __DEC64_MAX__ 9.999999999999999E384DD
+ [ af0] __FLT_EPSILON__ 1.19209289550781250000e-7F
+ [ b1b] __INT_FAST16_TYPE__ long int
+ [ b38] __VERSION__ "4.8.2 20140120 (Red Hat 4.8.2-15)"
+ [ b68] __GCC_ATOMIC_LLONG_LOCK_FREE 2
+ [ b87] __DEC128_MIN_EXP__ (-6142)
+ [ ba2] __ATOMIC_RELEASE 3
+ [ bb5] __GNUC_PATCHLEVEL__ 2
+ [ bcb] __UINT_FAST64_MAX__ 18446744073709551615UL
+ [ bf6] __DBL_DECIMAL_DIG__ 17
+ [ c0d] __DBL_DIG__ 15
+ [ c1c] __FLT_MANT_DIG__ 24
+ [ c30] __FLT_DECIMAL_DIG__ 9
+ [ c46] __INT16_MAX__ 32767
+ [ c5a] __DEC128_MIN__ 1E-6143DL
+ [ c73] __BIGGEST_ALIGNMENT__ 16
+ [ c8c] __INT64_MAX__ 9223372036854775807L
+ [ caf] __INT_FAST32_TYPE__ long int
+ [ ccc] __GCC_ATOMIC_INT_LOCK_FREE 2
+ [ ce9] __DEC128_MAX_EXP__ 6145
+ [ d01] __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+ [ d26] __FXSR__ 1
+ [ d31] __INT8_TYPE__ signed char
+ [ d4b] __ATOMIC_ACQ_REL 4
+ [ d5e] __UINT_LEAST16_MAX__ 65535
+ [ d79] __UINTMAX_TYPE__ long unsigned int
+ [ d9c] __UINT_FAST8_MAX__ 255
+ [ db3] __ORDER_BIG_ENDIAN__ 4321
+ [ dcd] __INT_LEAST32_MAX__ 2147483647
+ [ dec] __UINT_LEAST16_TYPE__ short unsigned int
+ [ e15] __INT_FAST8_TYPE__ signed char
+ [ e34] __DBL_MAX_EXP__ 1024
+ [ e49] __STDC__ 1
+ [ e54] __ELF__ 1
+ [ e5e] __FLT_EVAL_METHOD__ 0
+ [ e74] __ATOMIC_ACQUIRE 2
+ [ e87] __DEC64_EPSILON__ 1E-15DD
+ [ ea1] __INT32_MAX__ 2147483647
+ [ eba] __GCC_ATOMIC_CHAR_LOCK_FREE 2
+ [ ed8] __DEC128_EPSILON__ 1E-33DL
+ [ ef3] __UINT_FAST8_TYPE__ unsigned char
+ [ f15] __amd64 1
+ [ f1f] __DEC32_MIN_EXP__ (-94)
+ [ f37] __GCC_HAVE_DWARF2_CFI_ASM 1
+ [ f53] __LDBL_DIG__ 18
+ [ f63] __UINT32_MAX__ 4294967295U
+ [ f7e] __GNUC_GNU_INLINE__ 1
+ [ f94] __SSE2__ 1
+ [ f9f] __ATOMIC_HLE_ACQUIRE 65536
+ [ fba] __SSE_MATH__ 1
+ [ fc9] __INT_FAST16_MAX__ 9223372036854775807L
+ [ ff1] __LDBL_MAX__ 1.18973149535723176502e+4932L
+ [ 101c] __DBL_MIN__ ((double)2.22507385850720138309e-308L)
+ [ 104f] __DEC128_MANT_DIG__ 34
+ [ 1066] __INT32_C(c) c
+ [ 1075] __DEC64_MIN_EXP__ (-382)
+ [ 108e] __WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
+ [ 10b1] __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
+ [ 10d3] __LDBL_MAX_EXP__ 16384
+ [ 10ea] __DEC32_MANT_DIG__ 7
+ [ 10ff] __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+ [ 1139] __CHAR32_TYPE__ unsigned int
+ [ 1156] __INT_LEAST8_TYPE__ signed char
+ [ 1176] __UINT16_C(c) c
+ [ 1186] __GCC_ATOMIC_BOOL_LOCK_FREE 2
+ [ 11a4] __SIZEOF_FLOAT__ 4
+ [ 11b7] __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+ [ 11dc] __DBL_MAX_10_EXP__ 308
+ [ 11f3] __LDBL_EPSILON__ 1.08420217248550443401e-19L
+ [ 1220] __ORDER_PDP_ENDIAN__ 3412
+ [ 123a] __ORDER_LITTLE_ENDIAN__ 1234
+ [ 1257] __WINT_TYPE__ unsigned int
+ [ 1272] __unix 1
+ [ 127b] __ATOMIC_RELAXED 0
+ [ 128e] __UINT_FAST32_MAX__ 18446744073709551615UL
+ [ 12b9] __INT_FAST32_MAX__ 9223372036854775807L
+ [ 12e1] __SIG_ATOMIC_MAX__ 2147483647
+ [ 12ff] __UINT_FAST32_TYPE__ long unsigned int
+ [ 1326] __INT_MAX__ 2147483647
+ [ 133d] __GXX_ABI_VERSION 1002
+ [ 1354] __SIZEOF_INT__ 4
+ [ 1365] char
+ [ 136a] __UINT_FAST16_TYPE__ long unsigned int
+ [ 1391] __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+ [ 13c3] __WINT_MAX__ 4294967295U
+ [ 13dc] __FLT_HAS_INFINITY__ 1
+ [ 13f3] __SHRT_MAX__ 32767
+ [ 1406] __INT_LEAST16_MAX__ 32767
+ [ 1420] __LONG_LONG_MAX__ 9223372036854775807LL
+ [ 1448] __SIZEOF_LONG__ 8
+ [ 145a] __INTMAX_TYPE__ long int
+ [ 1473] __LDBL_HAS_DENORM__ 1
+ [ 1489] __code_model_small__ 1
+ [ 14a0] __REGISTER_PREFIX__
+ [ 14b5] __ATOMIC_CONSUME 1
+ [ 14c8] __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
+ [ 150d] __GNUC__ 4
+ [ 1518] __UINT16_TYPE__ short unsigned int
+ [ 153b] __SSE__ 1
+ [ 1545] __UINT32_C(c) c ## U
+ [ 155a] __k8 1
+ [ 1561] __UINTMAX_C(c) c ## UL
+ [ 1578] __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+ [ 159d] __SIZEOF_PTRDIFF_T__ 8
+ [ 15b4] __CHAR_BIT__ 8
+ [ 15c3] __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
+ [ 15f0] __DEC32_EPSILON__ 1E-6DF
+ [ 1609] __UINT_LEAST32_TYPE__ unsigned int
+ [ 162c] __DBL_HAS_DENORM__ 1
+ [ 1641] /tmp
+ [ 1646] __LDBL_MANT_DIG__ 64
+ [ 165b] __GCC_ATOMIC_LONG_LOCK_FREE 2
+ [ 1679] __DECIMAL_BID_FORMAT__ 1
+ [ 1692] __FLT_MIN_10_EXP__ (-37)
+ [ 16ab] __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
+ [ 16cf] __WCHAR_TYPE__ int
+ [ 16e2] __FINITE_MATH_ONLY__ 0
+ [ 16f9] argc
+ [ 16fe] __USER_LABEL_PREFIX__
+ [ 1715] __CHAR16_TYPE__ short unsigned int
+ [ 1738] __UINT64_MAX__ 18446744073709551615UL
+ [ 175e] __UINT8_C(c) c
+ [ 176d] __x86_64 1
+ [ 1778] __UINT_LEAST8_TYPE__ unsigned char
+ [ 179b] __INT64_TYPE__ long int
+ [ 17b3] __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+ [ 17d8] argv
+ [ 17dd] __GNUC_RH_RELEASE__ 15
+ [ 17f4] __UINT_FAST16_MAX__ 18446744073709551615UL
+ [ 181f] __FLT_HAS_DENORM__ 1
+ [ 1834] __DEC64_MIN__ 1E-383DD
+ [ 184b] __DBL_MIN_10_EXP__ (-307)
+ [ 1865] __FLT_DENORM_MIN__ 1.40129846432481707092e-45F
+ [ 1894] GNU C 4.8.2 20140120 (Red Hat 4.8.2-15) -mtune=generic -march=x86-64 -g3 -O3 -fuse-ld=gold -fno-asynchronous-unwind-tables
+ [ 190f] __SCHAR_MAX__ 127
+EOF
+
+exit 0
diff --git a/tests/run-readelf-zx.sh b/tests/run-readelf-zx.sh
new file mode 100755
index 00000000..994528c0
--- /dev/null
+++ b/tests/run-readelf-zx.sh
@@ -0,0 +1,66 @@
+#! /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
+
+# See run-elfgetchdr.sh for testfiles.
+
+testfiles testfile-zgnu64
+testrun_compare ${abs_top_builddir}/src/readelf -z -x.zdebug_aranges testfile-zgnu64 <<\EOF
+
+Hex dump of section [2] '.zdebug_aranges', 50 bytes (96 uncompressed) at offset 0x260:
+ 0x00000000 2c000000 02000000 00000800 00000000 ,...............
+ 0x00000010 78004000 00000000 14000000 00000000 x.@.............
+ 0x00000020 00000000 00000000 00000000 00000000 ................
+ 0x00000030 2c000000 02005500 00000800 00000000 ,.....U.........
+ 0x00000040 8c004000 00000000 16000000 00000000 ..@.............
+ 0x00000050 00000000 00000000 00000000 00000000 ................
+EOF
+
+testfiles testfile-zgabi64
+testrun_compare ${abs_top_builddir}/src/readelf -z -x.debug_aranges testfile-zgabi64 <<\EOF
+
+Hex dump of section [2] '.debug_aranges', 62 bytes (96 uncompressed) at offset 0x260:
+ 0x00000000 2c000000 02000000 00000800 00000000 ,...............
+ 0x00000010 78004000 00000000 14000000 00000000 x.@.............
+ 0x00000020 00000000 00000000 00000000 00000000 ................
+ 0x00000030 2c000000 02005500 00000800 00000000 ,.....U.........
+ 0x00000040 8c004000 00000000 16000000 00000000 ..@.............
+ 0x00000050 00000000 00000000 00000000 00000000 ................
+EOF
+
+testfiles testfile-zgnu32
+testrun_compare ${abs_top_builddir}/src/readelf -z -x.zdebug_aranges testfile-zgnu32 <<\EOF
+
+Hex dump of section [2] '.zdebug_aranges', 49 bytes (64 uncompressed) at offset 0x1c0:
+ 0x00000000 1c000000 02000000 00000400 00000000 ................
+ 0x00000010 54800408 14000000 00000000 00000000 T...............
+ 0x00000020 1c000000 02004d00 00000400 00000000 ......M.........
+ 0x00000030 68800408 16000000 00000000 00000000 h...............
+EOF
+
+testfiles testfile-zgabi32
+testrun_compare ${abs_top_builddir}/src/readelf -z -x.debug_aranges testfile-zgabi32 <<\EOF
+
+Hex dump of section [2] '.debug_aranges', 49 bytes (64 uncompressed) at offset 0x1c0:
+ 0x00000000 1c000000 02000000 00000400 00000000 ................
+ 0x00000010 54800408 14000000 00000000 00000000 T...............
+ 0x00000020 1c000000 02004d00 00000400 00000000 ......M.........
+ 0x00000030 68800408 16000000 00000000 00000000 h...............
+EOF
+
+exit 0