summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog12
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/dwelfgnucompressed.c104
-rwxr-xr-xtests/run-dwelfgnucompressed.sh108
-rwxr-xr-xtests/testfile-zgnu32.bz2bin0 -> 780 bytes
-rwxr-xr-xtests/testfile-zgnu32be.bz2bin0 -> 779 bytes
-rwxr-xr-xtests/testfile-zgnu64.bz2bin0 -> 785 bytes
-rwxr-xr-xtests/testfile-zgnu64be.bz2bin0 -> 795 bytes
8 files changed, 231 insertions, 3 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 933f7c92..5afe4bd2 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,15 @@
+2015-10-28 Mark Wielaard <mjw@redhat.com>
+
+ * dwelfgnucompressed.c: New file.
+ * run-dwelfgnucompressed.sh: New test.
+ * testfile-zgnu32.bz2: New testfile.
+ * testfile-zgnu64.bz2: Likewise.
+ * Makefile.am (check_PROGRAMS): Add dwelfgnucompressed.
+ (TESTS): Add run-dwelfgnucompressed.sh.
+ (EXTRA_DIST): Add run-dwelfgnucompressed.sh, testfile-zgnu32.bz2,
+ testfile-zgnu64.bz2, testfile-zgnu32be.bz2, testfile-zgnu64be.bz2.
+ (dwelfgnucompressed_LDADD): New variable.
+
2015-12-31 Mark Wielaard <mjw@redhat.com>
* elfstrmerge.c (main): Warn about STT_SECTION symbol for shstrhndx.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 54d88f25..8e2f2833 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,7 +52,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
backtrace-data backtrace-dwarf debuglink debugaltlink \
buildid deleted deleted-lib.so aggregate_size vdsosyms \
getsrc_die strptr newdata elfstrtab dwfl-proc-attach \
- elfshphehdr elfstrmerge
+ elfshphehdr elfstrmerge dwelfgnucompressed
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -120,7 +120,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
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 \
- elfshphehdr run-lfs-symbols.sh
+ elfshphehdr run-lfs-symbols.sh run-dwelfgnucompressed.sh
if !BIARCH
export ELFUTILS_DISABLE_BIARCH = 1
@@ -306,7 +306,10 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
testfile-x32-core.bz2 testfile-x32.bz2 \
backtrace.x32.core.bz2 backtrace.x32.exec.bz2 \
testfile-x32-s.bz2 testfile-x32-d.bz2 testfile-x32-debug.bz2 \
- run-lfs-symbols.sh lfs-symbols testfile-nolfs.bz2
+ run-lfs-symbols.sh lfs-symbols testfile-nolfs.bz2 \
+ testfile-zgnu32.bz2 testfile-zgnu64.bz2 \
+ testfile-zgnu32be.bz2 testfile-zgnu64be.bz2 \
+ run-dwelfgnucompressed.sh
if USE_VALGRIND
valgrind_cmd='valgrind -q --leak-check=full --error-exitcode=1'
@@ -455,6 +458,7 @@ dwfl_proc_attach_LDADD = $(libdw)
dwfl_proc_attach_LDFLAGS = -pthread $(AM_LDFLAGS)
elfshphehdr_LDADD =$(libelf)
elfstrmerge_LDADD = $(libebl) $(libelf)
+dwelfgnucompressed_LDADD = $(libelf) $(libdw)
if GCOV
check: check-am coverage
diff --git a/tests/dwelfgnucompressed.c b/tests/dwelfgnucompressed.c
new file mode 100644
index 00000000..0132271c
--- /dev/null
+++ b/tests/dwelfgnucompressed.c
@@ -0,0 +1,104 @@
+/* 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/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <inttypes.h>
+
+#include ELFUTILS_HEADER(elf)
+#include ELFUTILS_HEADER(dwelf)
+#include <gelf.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+ int result = 0;
+ int cnt;
+
+ elf_version (EV_CURRENT);
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ int fd = open (argv[cnt], O_RDONLY);
+
+ Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("%s not usable %s\n", argv[cnt], elf_errmsg (-1));
+ result = 1;
+ close (fd);
+ continue;
+ }
+
+ size_t shdrstrndx;
+ if (elf_getshdrstrndx (elf, &shdrstrndx) == -1)
+ {
+ printf ("elf_getshdrstrnd failed %s\n", elf_errmsg (-1));
+ result = 1;
+ close (fd);
+ continue;
+ }
+
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ int idx = elf_ndxscn (scn);
+ GElf_Shdr shdr;
+ if (gelf_getshdr (scn, &shdr) == NULL)
+ {
+ printf ("gelf_getshdr failed: %s\n", elf_errmsg (-1));
+ result = 1;
+ break;
+ }
+
+ const char *sname = elf_strptr (elf, shdrstrndx, shdr.sh_name);
+ if (sname == NULL)
+ {
+ printf ("couldn't get section name: %s\n", elf_errmsg (-1));
+ result = 1;
+ break;
+ }
+
+ if (strncmp(".zdebug", sname, strlen (".zdebug")) == 0)
+ {
+ ssize_t size;
+ if ((size = dwelf_scn_gnu_compressed_size (scn)) == -1)
+ {
+ printf ("dwelf_scn_gnu_compressed_size failed: %s\n",
+ elf_errmsg (-1));
+ result = 1;
+ break;
+ }
+ printf ("section %d: GNU Compressed size: %zx\n", idx, size);
+ }
+ }
+
+ elf_end (elf);
+ close (fd);
+ }
+
+ return result;
+}
diff --git a/tests/run-dwelfgnucompressed.sh b/tests/run-dwelfgnucompressed.sh
new file mode 100755
index 00000000..b93a56f2
--- /dev/null
+++ b/tests/run-dwelfgnucompressed.sh
@@ -0,0 +1,108 @@
+#! /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
+
+# = funcs.s =
+# .globl testfunc
+# testfunc:
+# nop
+# ret
+# .type testfunc, @function
+# .size testfunc, .-testfunc
+#
+# .globl testfunc2
+# testfunc2:
+# call testfunc
+# nop
+# nop
+# ret
+# .type testfunc2, @function
+# .size testfunc2, .-testfunc2
+#
+# .globl functest3
+# functest3:
+# jmp local
+# nop
+# nop
+# local:
+# call testfunc2
+# ret
+# .type functest3, @function
+# .size functest3, .-functest3
+
+# = start.s =
+# .global _start
+# _start:
+# call functest3
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# nop
+# ret
+# .type _start, @function
+# .size _start, .-_start
+
+# gas --compress-debug-sections=zlib-gnu -32 -g -o start.o start.s
+# gas --compress-debug-sections=zlib-gnu -32 -g -o funcs.o funcs.s
+# ld --compress-debug-sections=zlib-gnu -melf_i386 -g -o zgnu32 funcs.o start.o
+
+# gas --compress-debug-sections=zlib-gnu -64 -g -o start.o start.s
+# gas --compress-debug-sections=zlib-gnu -64 -g -o funcs.o funcs.s
+# ld --compress-debug-sections=zlib-gnu -g -o zgnu32 funcs.o start.o
+
+testfiles testfile-zgnu64
+testrun_compare ${abs_top_builddir}/tests/dwelfgnucompressed testfile-zgnu64 <<\EOF
+section 2: GNU Compressed size: 60
+section 3: GNU Compressed size: aa
+section 5: GNU Compressed size: 8d
+EOF
+
+testfiles testfile-zgnu64be
+testrun_compare ${abs_top_builddir}/tests/dwelfgnucompressed testfile-zgnu64be <<\EOF
+section 3: GNU Compressed size: 60
+section 4: GNU Compressed size: 7e
+section 6: GNU Compressed size: 8d
+EOF
+
+testfiles testfile-zgnu32
+testrun_compare ${abs_top_builddir}/tests/dwelfgnucompressed testfile-zgnu32 <<\EOF
+section 2: GNU Compressed size: 40
+section 3: GNU Compressed size: 9a
+section 5: GNU Compressed size: 85
+EOF
+
+testfiles testfile-zgnu32be
+testrun_compare ${abs_top_builddir}/tests/dwelfgnucompressed testfile-zgnu32be <<\EOF
+section 3: GNU Compressed size: 40
+section 4: GNU Compressed size: 6e
+section 6: GNU Compressed size: 85
+EOF
+
+exit 0
diff --git a/tests/testfile-zgnu32.bz2 b/tests/testfile-zgnu32.bz2
new file mode 100755
index 00000000..9d622cad
--- /dev/null
+++ b/tests/testfile-zgnu32.bz2
Binary files differ
diff --git a/tests/testfile-zgnu32be.bz2 b/tests/testfile-zgnu32be.bz2
new file mode 100755
index 00000000..c1dd589e
--- /dev/null
+++ b/tests/testfile-zgnu32be.bz2
Binary files differ
diff --git a/tests/testfile-zgnu64.bz2 b/tests/testfile-zgnu64.bz2
new file mode 100755
index 00000000..1bc2c090
--- /dev/null
+++ b/tests/testfile-zgnu64.bz2
Binary files differ
diff --git a/tests/testfile-zgnu64be.bz2 b/tests/testfile-zgnu64be.bz2
new file mode 100755
index 00000000..390c9c90
--- /dev/null
+++ b/tests/testfile-zgnu64be.bz2
Binary files differ