Squashed 'third_party/elfutils/' content from commit 555e15e
Change-Id: I61cde98949e47e5c8c09c33260de17f30921be79
git-subtree-dir: third_party/elfutils
git-subtree-split: 555e15ebe8bf1eb33d00747173cfc80cc65648a4
diff --git a/tests/ChangeLog b/tests/ChangeLog
new file mode 100644
index 0000000..5ee8626
--- /dev/null
+++ b/tests/ChangeLog
@@ -0,0 +1,2978 @@
+2018-02-09 Joshua Watt <JPEWhacker@gmail.com>
+
+ * elfstrmerge.c (main): Use FALLTHROUGH macro instead of comment.
+
+2018-01-22 Mark Wielaard <mark@klomp.org>
+
+ * allfcts.c (setup_alt): Print warning when alt file couldn't be
+ found.
+ * run-allfcts-multi.sh: Add testcase where alt file is in a subdir
+ where it cannot be found by allfcts itself (but it can by libdw).
+
+2018-01-25 Mark Wielaard <mark@klomp.org>
+
+ * elfstrmerge.c (main): Initialize and check symtabshdr instead of
+ symtabndx.
+
+2018-01-14 Petr Machata <pmachata@gmail.com>
+
+ * testfile-sizes4.o.bz2: New test file.
+ * testfile-sizes4.s: New test source.
+ * run-aggregate-size.sh: Check testfile-sizes4.o v size 257.
+
+2017-12-23 Mark Wielaard <mark@klomp.org>
+
+ * backtrace-subr.sh (check_native_core): Use a lock file and try
+ to extract core using coredumpctl.
+ * Makefile.am (CLEANFILES): Clean core-dump-backtrace.lock.
+
+2017-12-11 Dima Kogan <dima@secretsauce.net>
+
+ * run-aggregate-size.sh: Added check for multi-dimensional arrays.
+ * run-peel-type.sh: Likewise.
+ * testfile-sizes3.o.bz2: Likewise.
+
+2017-12-07 Mark Wielaard <mark@klomp.org>
+
+ * run-readelf-variant.sh: New test.
+ * testfile-ada-variant.bz2: New testfile.
+ * Makefile.am (TESTS): Add run-readelf-variant.sh.
+ (EXTRA_DISTS): Add run-readelf-variant.sh and
+ testfile-ada-variant.bz2.
+
+2017-11-29 Mark Wielaard <mark@klomp.org>
+
+ * run-readelf-loc.sh: Adjust expected loc list output.
+ * run-readelf-zdebug-rel.sh: Likewise.
+ * run-readelf-zdebug.sh: Likewise.
+
+2017-11-29 Mark Wielaard <mark@klomp.org>
+
+ * run-readelf-loc.sh: Adjust expected range list output.
+ * run-readelf-zdebug.sh: Likewise.
+
+2017-11-29 Mark Wielaard <mark@klomp.org>
+
+ * run-readelf-dwz-multi.sh: Add expected file names.
+ * run-readelf-zdebug-rel.sh: Likewise.
+
+2017-11-29 Mark Wielaard <mark@klomp.org>
+
+ * run-readelf-dwz-multi.sh: Add expected abbrev codes.
+ * run-readelf-zdebug-rel.sh: Likewise.
+
+2017-11-29 Mark Wielaard <mark@klomp.org>
+
+ * run-readelf-dwz-multi.sh: Adjust expected ops index spaces.
+ * run-readelf-loc.sh: Likewise.
+ * run-readelf-zdebug-rel.sh: Likewise.
+ * run-readelf-zdebug.sh: Likewise.
+
+2017-11-16 Mark Wielaard <mark@klomp.org>
+
+ * varlocs.c (main): Fix cfi_debug => cfi_debug_bias typo in assert.
+
+2017-11-10 Mark Wielaard <mark@klomp.org>
+
+ * run-exprlocs-self.sh: New test.
+ * run-varlocs-self.sh: Likewise.
+ * Makefile.am (TESTS) Add run-exprlocs-self.sh and
+ run-varlocs-self.sh.
+ (EXTRA_DIST): Likewise.
+ * varlocs.c (cfi_debug_bias): New global variable.
+ (is_ET_REL): Likewise.
+ (print_expr): Don't crash and burn when CFI cannot be found for an
+ ET_REL file for DW_OP_call_frame_cfa.
+ (handle_die): If there is no entry_pc pick the lowest pc start range
+ for the DIE.
+ (main): Check at least one CU was found. Use dwfl_module_dwarf_cfi
+ and dwfl_module_eh_cfi to fix memory leak. Set is_ET_REL.
+
+2017-11-03 Mark Wielaard <mark@klomp.org>
+
+ * run-exprlocs.sh: New test.
+ * testfile-stridex.bz2: New testfile.
+ * Makefile.am (TESTS): Add run-exprlocs.sh.
+ (EXTRA_DIST): Add run-exprlocs.sh and testfile-stridex.bz2.
+ * varlocs.c (dwarf_tag_string): New function.
+ (dwarf_attr_string): Likewise.
+ (dwarf_form_string): Likewise.
+ (print_expr): Fix typo in error message.r
+ Handle DW_OP_GNU_variable_value.
+ (attr_arg): New struct.
+ (handle_attr): New function.
+ (handle_die): Likewise.
+ (main): Handle --exprlocs argument. Call handle_die.
+
+2017-10-16 Mark Wielaard <mark@klomp.org>
+
+ * md5-sha1-test.c: Removed.
+ * Makefile.am (check_PROGRAMS): Remove md5-sha1-test.
+ (TESTS): Likewise.
+ (md5_sha1_test_LDADD): Removed.
+
+2017-10-04 Mark Wielaard <mark@klomp.org>
+
+ * msg_tst.c: Handle ELF_E_INVALID_ELF.
+
+2017-09-10 Mark Wielaard <mark@klomp.org>
+
+ * run-ar.sh: New test.
+ * Makefile.am (TESTS): Add run-ar.sh.
+ (EXTRA_DIST): Likewise.
+
+2017-08-18 Ulf Hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: Drop -rdynamic from deleted_lib_so_LDFLAGS.
+
+2017-04-27 Ulf Hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: Use fpie_CFLAGS and fpic_CFLAGS.
+
+2017-08-08 Dmitry V. Levin <ldv@altlinux.org>
+
+ * run-strip-nothing.sh: Add -s.
+
+2017-07-26 Mark Wielaard <mark@klomp.org>
+
+ * dwarf-getmacros.c (mac): Use DW_MACRO names instead of DW_MACRO_GNU.
+
+2016-10-27 Mark Wielaard <mjw@redhat.com>
+
+ * dwarf_default_lower_bound.c: New test.
+ * Makefile.am (check_PROGRAMS): Add dwarf_default_lower_bound.
+ (TESTS): Likewise.
+ (dwarf_default_lower_bound_LDADD): New variable.
+
+2017-07-21 Mark Wielaard <mark@klomp.org>
+
+ * get-lines.c (main): Add dwarf_line_file test.
+
+2017-07-19 Gustavo Romero <gromero@linux.vnet.ibm.com>
+
+ * run-addrcfi.sh: Update generic SPRs names to HTM SPRs names
+ * run-allregs.sh: Update generic SPRs names to HTM SPRs names
+
+2017-07-20 Mark Wielaard <mark@klomp.org>
+
+ * run-strip-g.sh: New test.
+ * Makefile.am (TESTS): Add run-strip-g.sh.
+ (EXTRA_DIST): Likewise.
+
+2017-07-18 Mark Wielaard <mark@klomp.org>
+
+ * Makefile.am (TESTS): Always add run-disasm-bpf.sh if HAVE_LIBASM.
+
+2017-05-04 Ulf Hermann <ulf.hermann@qt.io>
+
+ * elfshphehdr.c: For writing, use /dev/null rather than /dev/zero.
+
+2017-07-14 Mark Wielaard <mark@klomp.org>
+
+ * run-strip-remove-keep.sh: New test.
+ * Makefile.am (TESTS): Add run-strip-remove-keep.sh.
+ (EXTRA_DIST): Likewise.
+
+2017-06-07 Mark Wielaard <mark@klomp.org>
+
+ * run-strip-nothing.sh: New test.
+ * Makefile.am (TESTS): Add run-strip-nothing.sh.
+ (EXTRA_DIST): Likewise.
+
+2017-06-06 Mark Wielaard <mark@klomp.org>
+
+ * run-strip-test.sh: Test strip -g doesn't introduce extra .shstrtab.
+
+2017-05-30 Mark Wielaard <mark@klomp.org>
+
+ * run-backtrace-fp-core-ppc64le.sh: New test.
+ * backtrace.ppc64le.fp.core.bz2: New test file.
+ * backtrace.ppc64le.fp.exec.bz2: New testfile.
+ * backtrace-subr.sh (check_backtracegen): Accept '(null)'.
+ * Makefile.am (TESTS): Add run-backtrace-fp-core-ppc64le.sh.
+ (EXTRA_DIST): Add run-backtrace-fp-core-ppc64le.sh,
+ backtrace.ppc64le.fp.core.bz2 and backtrace.ppc64le.fp.exec.bz2.
+
+2017-02-13 Ulf Hermann <ulf.hermann@qt.io>
+ Mark Wielaard <mark@klomp.org>
+
+ * Makefile.am: Add test for unwinding with frame pointers on aarch64
+ * backtrace.aarch64.fp.core.bz2: New file
+ * backtrace.aarch64.fp.exec.bz2: New file
+ * run-backtrace-fp-core-aarch64.sh: New file
+ * backtrace-subr.sh (check_err): Allow Invalid register.
+ * backtrace.c (callback_verify): Allow duplicate_sigusr2 frames.
+
+2017-04-06 Mark Wielaard <mark@klomp.org>
+
+ * run-backtrace-fp-core-i386.sh: New test.
+ * backtrace.i386.fp.core.bz2: New test file.
+ * backtrace.i386.fp.exec.bz2: New testfile.
+ * Makefile.am (TESTS): Add run-backtrace-fp-core-i386.sh.
+ (EXTRA_DIST): Add run-backtrace-fp-core-i386.sh,
+ backtrace.i386.fp.core.bz2 and backtrace.i386.fp.exec.bz2.
+
+2017-02-09 Ulf Hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: Add test for unwinding with frame pointers on x86_64
+ * backtrace.x86_64.fp.core.bz2: New file
+ * backtrace.x86_64.fp.exec.bz2: New file
+ * run-backtrace-fp-core-x86_64.sh: New file
+
+2017-04-25 Mark Wielaard <mark@klomp.org>
+
+ * backtrace-subr.sh (check_backtracegen): New function.
+ (check_core): Add check_backtracegen call.
+ * backtrace.ppc.exec.bz2: Regenerated.
+ * backtrace.ppc.core.bz2: Likewise.
+
+2017-04-24 Mark Wielaard <mark@klomp.org>
+
+ * backtrace.c: Remove option to allow unknown symbols in the trace.
+ * backtrace-substr.sh: Remove option to allow unknown symbols
+ to check_core() and allow failed symbol lookups in check_err().
+
+2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
+
+ * run-readelf-dwz-multi.sh: Expect readelf to output "yes" for flags
+ that are set.
+ * run-readelf-zdebug-rel.sh: Likewise.
+
+2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
+
+ * backtrace-child.c: Include sys/ptrace.h only on linux.
+ * backtrace-dwarf.c: Likewise.
+
+2017-04-05 Mark Wielaard <mark@klomp.org>
+
+ * test-subr.sh (testrun_on_self_compressed): New function.
+ * run-elflint-self.sh: Call testrun_on_self_compressed.
+ * run-elflint-test.sh: Add testfile42z and testfile-s390x-hash-bothz.
+
+2017-03-30 Mark Wielaard <mark@klomp.org>
+
+ * peel_type.c: New file.
+ * run-peel-type.sh: New test.
+ * Makefile.am (check_PROGRAMS): Add peel_type.c.
+ (TESTS): Add run-peel-type.sh.
+ (EXTRA_DIST): Likewise.
+ (peel_type_LDADD): New variable.
+
+2017-03-27 Mark Wielaard <mark@klomp.org>
+
+ * fillfile.c: New file.
+ * Makefile.am (check_PROGRAMS): Add fillfile.
+ (TESTS): Likewise.
+ (fillfile_LDADD): New variable.
+
+2017-02-15 Mark Wielaard <mark@klomp.org>
+
+ * Makefile.am (EXTRA_DIST): Add testfileppc64attrs.o.bz2.
+ * run-readelf-A.sh: Add testfileppc64.o test.
+
+2017-02-15 Ulf Hermann <ulf.hermann@qt.io>
+
+ * elfstrmerge.c: Include system.h.
+
+2017-02-09 Ulf Hermann <ulf.hermann@qt.io>
+
+ * backtrace.c: Add an option to allow unknown symbols in the trace
+ * backtrace-substr.sh: Add an option to allow unknown symbols
+ to check_core() and allow failed symbol lookups in check_err()
+
+2017-02-09 Ulf Hermann <ulf.hermann@qt.io>
+
+ * backtrace-data.c: Don't assert that symbols are found.
+ The unwinder is allowed to ask for invalid addresses. We deny
+ such requests, rather than make the test fail.
+
+2016-11-17 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-s.sh: Add --symbols=.dynsym and --symbols=.symtab tests.
+
+2016-11-02 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-data.c (thread_callback): Add explicit break after error.
+ * backtrace.c (callback_verify): Change PASSTHRU to FALLTHRU.
+
+2016-10-22 Kevin Cernekee <cernekee@chromium.org>
+
+ * Makefile.am (TESTS): Add run-unstrip-test4.sh.
+ (EXTRA_DIST): Add run-unstrip-test4.sh, testfile-strtab.bz2,
+ testfile-strtab.stripped.bz2, testfile-strtab.debuginfo.bz2.
+ (run-unstrip-test4.sh): New file.
+ (testfile-strtab.bz2): New file.
+ (testfile-strtab.stripped.bz2): New file.
+ (testfile-strtab.debuginfo.bz2): New file.
+
+2016-10-11 Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
+
+ * arextract.c: Remove sys/param.h include, add system.h include.
+
+2016-08-30 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (asm_tst?_LDADD): Add libdw.
+
+2016-08-25 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-child.c: Disable and add documentation about why we disable
+ RAISE_JMP_PATCHING even on x86_64.
+ * backtrace.c (is_x86_64_native): Rename to...
+ (use_raise_jmp_patching): ... this.
+ (callback_verify): Use use_raise_jmp_patching instead of
+ is_x86_64_native.
+ (see_exec_module): Return DWARF_CB_ABORT after finding the correct exe
+ path.
+ (prepare_thread): Use RAISE_JMP_PATCHING instead of __x86_64__
+ conditional.
+ (exec_dump): Only assert on data.mod != NULL. Drop ptrdiff. Use
+ RAISE_JMP_PATCHING instead of __x86_64__ conditional. Use
+ use_raise_jmp_patching instead of is_x86_64_native.
+
+2016-08-24 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add testfilesparc64attrs.o.bz2.
+
+2016-08-09 Jose E. Marchesi <jose.marchesi@oracle.com>
+
+ * testfilesparc64attrs.o.bz2: New file.
+ * run-readelf-A.sh: Check attributes in a sparc object.
+
+2016-08-06 Mark Wielaard <mjw@redhat.com>
+
+ * run-strip-reloc.sh: Add explicit compressed and uncompressed
+ test cases.
+
+2016-08-10 Richard Henderson <rth@redhat.com>
+
+ * file-bpf-dis1.expect.bz2: Fix expected mod and endian operations
+ output.
+
+2016-07-08 Mark Wielaard <mjw@redhat.com>
+
+ * update3_LDADD: Use libdw instead of libebl.
+ * update4_LDADD: Likewise.
+ * alldts_LDADD: Likewise.
+ * elfstrmerge_LDADD: Likewise.
+ * alldts.c (main): Use dwelf_strtab instead of ebl_strtab.
+ * elfstrmerge.c (release): Likewise.
+ (main): Likewise.
+ * update3.c (main): Likewise.
+ * update4.c (main): Likewise.
+
+2016-07-10 Andreas Schwab <schwab@linux-m68k.org>
+
+ * Makefile.am (TESTS): Add run-strip-test11.sh.
+ (EXTRA_DIST): Add run-strip-test11.sh, hello_m68k.ko.bz2,
+ testfile-m86k-core.bz2, testfile-m68k.bz2, testfile-m68k-s.bz2.
+ (run-strip-test11.sh): New file.
+ (hello_m68k.ko.bz2): New file.
+ (testfile-m68k-core.bz2): New file.
+ (testfile-m68k.bz2): New file.
+ (testfile-m68k-s.bz2): New file.
+ * run-allregs.sh: Add test for testfile-m68k-core.
+ * run-readelf-mixed-corenote.sh: Likewise.
+ * run-strip-reloc.sh: Add test for hello_m68k.ko.
+
+2016-07-06 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add vendorelf.
+ (TESTS): Likewise.
+ (vendorelf_LDADD): New variable.
+ * vendorelf.c: New test.
+ * elfshphehdr.c (test): Check elf_getphdrnum succeeds.
+
+2016-06-24 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add emptyfile.
+ (TESTS): Likewise.
+ (emptyfile_LDADD): New variable.
+ * emptyfile.c: New test.
+
+2016-06-28 Richard Henderson <rth@redhat.com>
+
+ * Makefile.am (TESTS): Add run-disasm-bpf.sh, conditionally.
+ (EXTRA_DIST): Add run-disasm-bpf.sh, testfile-bpf-dis1.expect.bz2,
+ testfile-bpf-dis1.o.bz2
+ (run-disasm-bpf.sh): New file.
+ (testfile-bpf-dis1.expect.bz2): New file.
+ (testfile-bpf-dis1.o.bz2): New file.
+
+2016-02-09 Mark Wielaard <mjw@redhat.com>
+
+ * testfile-s390x-hash-both.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add testfile-s390x-hash-both.bz2.
+ * run-elflint-test.sh: Add elflint testfile-s390x-hash-both test.
+
+2016-02-04 Mark Wielaard <mjw@redhat.com>
+
+ * run-strip-nobitsalign.sh: New test.
+ * testfile-nobitsalign.bz2: New testfile.
+ * testfile-nobitsalign.strip.bz2: Likewise.
+ * Makefile.am (TESTS): Add run-strip-nobitsalign.sh.
+ (EXTRA_DIST): Add run-strip-nobitsalign.sh, testfile-nobitsalign.bz2
+ and testfile-nobitsalign.strip.bz2.
+ * run-strip-test.sh: Add --gnu to elflint calls.
+
+2016-01-13 Mark Wielaard <mjw@redhat.com>
+
+ * dwfl-bug-fd-leak.c: Skip test unless on __linux__.
+
+2016-01-13 Mark Wielaard <mjw@redhat.com>
+
+ * dwfl-proc-attach.c: Guard linux specific header.
+
+2016-01-13 Mark Wielaard <mjw@redhat.com>
+
+ * system-elf-libelf-test.c: New test.
+ * Makefile.am (TESTS): Add system-elf-libelf-test, if !STANDALONE.
+ (check_PROGRAMS): Likewise.
+ (system_elf_libelf_test_CPPFLAGS): New variable.
+ (system_elf_libelf_test_LDADD): Likewise.
+
+2016-01-08 Mark Wielaard <mjw@redhat.com>
+
+ * elfputzdata.c (main): Fix parentheses in strncmp test.
+
+2016-01-08 Mark Wielaard <mjw@redhat.com>
+
+ * elfputzdata.c (main): Use PRId64 to print 64 bit value.
+
+2016-01-08 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Always unconditionally add
+ run-readelf-zdebug.sh and run-readelf-zdebug-rel.sh.
+
+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.
+ * run-zstrptr.sh: New test.
+ * elfputzdata.c (main): (re)compress .shstrtab.
+ * run-elfputzdata.sh: Expect .shstrtab compression.
+ * Makefile.am (check_PROGRAMS): Add zstrptr.
+ (TESTS): Add run-zstrptr.sh.
+ (EXTRA_DIST): Likewise.
+ (zstrptr_LDADD): New variable.
+
+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.
+ (TESTS): Add run-elfgetzdata.sh and run-elfputzdata.sh.
+ (EXTRA_DIST: Likewise.
+ (elfgetzdata_LDADD): New variable.
+ (elfputzdata_LDADD): Likewise.
+ * elfgetzdata.c: New file.
+ * elfputzdata.c: Likewise.
+ * msg_tst.c: Handle ELF_E_ALREADY_COMPRESSED,
+ ELF_E_UNKNOWN_COMPRESSION_TYPE, ELF_E_COMPRESS_ERROR and
+ ELF_E_DECOMPRESS_ERROR.
+ * run-elfgetzdata.sh: New test.
+ * run-elfputzdata.sh: Likewise.
+
+2015-10-28 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-z.sh: New test.
+ * Makefile.am (TESTS): Add run-readelf-z.sh.
+ (EXTRA_DIST): Likewise.
+
+2015-10-28 Mark Wielaard <mjw@redhat.com>
+
+ * elfgetchdr.c: New file.
+ * run-elfgetchdr.sh: New test.
+ * testfile-zgabi32.bz2: New testfile.
+ * testfile-zgabi32be.bz2: Likewise.
+ * testfile-zgabi64.bz2: Likewise.
+ * testfile-zgabi64be.bz2: Likewise.
+ * Makefile.am (check_PROGRAMS): Add elfgetchdr.
+ (TESTS): Add run-elfgetchdr.sh.
+ (EXTRA_DIST): Add run-elfgetchdr.sh, testfile-zgabi32.bz2,
+ testfile-zgabi32be.bz2, testfile-zgabi64.bz2, testfile-zgabi64be.bz2.
+ (welfgetchdr_LDADD): New variable.
+ * msg_tst.c: Add ELF_E_NOT_COMPRESSED, ELF_E_INVALID_SECTION_TYPE
+ and ELF_E_INVALID_SECTION_FLAGS,
+
+
+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.
+ * run-elfstrmerge-test.sh: New test.
+ * Makefile.am (TESTS): Add run-elfstrmerge-test.sh
+ (EXTRA_DIST): Likewise.
+
+2015-12-08 Jose E. Marchesi <jose.marchesi@oracle.com>
+
+ * run-backtrace-core-sparc.sh: New file.
+ * backtrace.sparc.core.bz2: New file.
+ * backtrace.sparc.exec.bz2: New file.
+ * Makefile.am (EXTRA_DIST): ... and added all here.
+ (TESTS): Added run-backtrace-core-sparc.sh.
+
+2015-12-02 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (valgrind_cmd): Use --leak-check=full.
+ * run-backtrace-demangle.sh: Disable valgrind.
+ * run-stack-demangled-test.sh: Likewise.
+ * run-stack-d-test.sh: Likewise.
+ * run-stack-i-test.sh: Likewise.
+
+2015-12-01 Mark Wielaard <mjw@redhat.com>
+
+ * test-flag-nobits.c (main): Call elf_end.
+ * rerequest_tag.c (main): Call dwarf_end.
+ * funcscopes.c (handle_function): Free scopes.
+ * dwarf-getstring.c (main): Call dwarf_end.
+ * allregs.c (main): Free state.info.
+ * alldts.c (main): Free dyn.
+ * addrcfi.c (handle_address): Free stuff.frame between handle_cfi
+ calls.
+ * addrscopes.c (handle_address): Free scopes.
+
+2015-10-16 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am [BUILD_STATIC] (libdw): Add -lz.
+ [BUILD_STATIC] (libelf): Likewise.
+
+2015-10-16 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (dwfl_proc_attach_LDFLAGS): Add AM_LDFLAGS.
+
+2015-10-09 Josh Stone <jistone@redhat.com>
+
+ * lfs-symbols: New list of LFS-related symbols from lintian.
+ * testfile-nolfs.bz2: New test binary for sanity checking.
+ * run-lfs-symbols.sh: New test.
+ * Makefile.am (TESTS): Add run-lfs-symbols.sh.
+ (EXTRA_DIST): Add lfs-symbols, testfile-nolfs.bz2, and
+ run-lfs-symbols.sh.
+ * alldts.c (main): Replace open64 with open.
+ * dwarf-getstring.c (main): Likewise.
+ * arls.c: Include config.h.
+ * ecp.c: Likewise.
+ * rdwrmmap.c: Likewise.
+ * test-elf_cntl_gelf_getshdr.c: Likewise.
+ * test-flag-nobits.c: Include config.h.
+ (main): Replace open64 with open.
+
+2015-10-09 Mark Wielaard <mjw@redhat.com>
+
+ * elfshphehdr.c (check): Rename argument from check to statement.
+ (check_elf): Likewise.
+
+2015-10-05 Josh Stone <jistone@redhat.com>
+
+ * Makefile.am (backtrace-child-biarch): Add AM_V_CC silencer.
+
+2015-10-02 Mark Wielaard <mjw@redhat.com>
+
+ * elfstrmerge.c: New check program.
+ * run-strip-strmerge.sh: New test.
+ * Makefile.am (check_PROGRAMS): Add elfstrmerge.
+ (EXTRA_DIST): Add run-strip-strmerge.sh
+ (elfstrmerge_LDADD): New variable.
+
+2015-09-29 Mark Wielaard <mjw@redhat.com>
+
+ * elfshphehdr.c: New test.
+ * Makefile.am (check_PROGRAMS): Add elfshphehdr.
+ (TESTS): Likewise.
+ (elfshphehdr_LDADD): New variable.
+
+2015-09-08 Mark Wielaard <mjw@redhat.com>
+
+ * dwfl-proc-attach.c: New test.
+ * Makefile.am (check_PROGRAMS): Add dwfl-proc-attach.
+ (TESTS): Likewise.
+ (dwfl_proc_attach_LDADD): New variable.
+ (dwfl_proc_attach_LDFLAGS): Likewise.
+
+2015-09-04 Chih-Hung Hsieh <chh@google.com>
+
+ * varlocs.c (print_base_type): Initialize enctype.
+
+2015-09-04 Chih-Hung Hsieh <chh@google.com>
+
+ * md5-sha1-test.c (md5_expected): Removed.
+ (sha1_expected): Likewise.
+
+2015-09-04 Chih-Hung Hsieh <chh@google.com>
+
+ * asm-tst1.c (main): Replace %Z length modifier with %z.
+ * asm-tst2.c (main): Likewise.
+ * asm-tst3.c (main): Likewise.
+ * asm-tst4.c (main): Likewise.
+ * asm-tst5.c (main): Likewise.
+ * asm-tst6.c (main): Likewise.
+ * asm-tst7.c (main): Likewise.
+ * asm-tst8.c (main): Likewise.
+ * asm-tst9.c (main): Likewise.
+ * sectiondump.c (print_bytes): Likewise.
+
+2015-08-14 Mark Wielaard <mjw@redhat.com>
+
+ * run-addr2line-alt-debugpath.sh: New test.
+ * Makefile.am (TESTS): Add run-addr2line-alt-debugpath.sh
+ (EXTRA_DIST): Likewise.
+
+2015-07-29 Mark Wielaard <mjw@redhat.com>
+
+ * run-unstrip-test3.sh: New test.
+ * testfile-info-link.bz2: New file.
+ * testfile-info-link.debuginfo.bz2: Likewise.
+ * testfile-info-link.stripped.bz2: Likewise.
+ * Makefile.am (TESTS): Add run-unstrip-test3.sh.
+ (EXTRA_DIST): Add run-unstrip-test3.sh, testfile-info-link.bz2,
+ testfile-info-link.debuginfo.bz2, testfile-info-link.stripped.bz2.
+
+2015-06-27 Pino Toscano <toscano.pino@tiscali.it>
+
+ * tests/run-deleted.sh: Skip when detecting a not implemented
+ dwfl_linux_proc_attach.
+
+2015-06-27 Pino Toscano <toscano.pino@tiscali.it>
+
+ * tests/dwfl-bug-fd-leak.c (elfutils_open): Check for null results of
+ dwfl_addrmodule.
+
+2015-06-26 Pino Toscano <toscano.pino@tiscali.it>
+
+ * tests/vdsosyms.c [!__linux__] (main): Mark argv as unused.
+
+2015-06-26 Pino Toscano <toscano.pino@tiscali.it>
+
+ * tests/backtrace-data.c: Reduce scope of some includes to match their
+ usage.
+ * tests/backtrace.c: Likewise.
+ * tests/deleted.c: Likewise.
+
+2015-06-16 Mark Wielaard <mjw@redhat.com>
+
+ * run-strip-test.sh: Add strip-in-place (eu-strip without -o) test
+ for non-ET_REL files.
+
+2015-05-30 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-subr.sh (check_native_core): Notice core file couldn't be
+ generated before skipping.
+ * run-addr2line-i-demangle-test.sh: Notice demangler is unsupported
+ before skipping.
+ * run-backtrace-demangle.sh: Likewise.
+ * run-stack-demangled-test.sh: Likewise.
+ * run-backtrace-native-biarch.sh: Notice biarch testing is disabled
+ before skipping.
+ * run-backtrace-native-core-biarch.sh: Likewise.
+ * test-subr.sh (testfiles): Notice how bunzip2 fails before skipping.
+
+2015-05-20 Mark Wielaard <mjw@redhat.com>
+
+ * run-addr2line-i-test.sh: Add pretty test.
+ * run-addr2line-test.sh: Likewise.
+
+2015-05-20 Mark Wielaard <mjw@redhat.com>
+
+ * run-addr2line-i-demangle-test.sh: New test.
+ * Makefile.am (TESTS): Add run-addr2line-i-demangle-test.sh.
+ (EXTRA_DIST): Likewise.
+
+2015-05-20 Mark Wielaard <mjw@redhat.com>
+
+ * run-addr2line-test.sh: Add -a test variants.
+ * run-addr2line-i-test.sh: Likewise.
+
+2015-05-20 Mark Wielaard <mjw@redhat.com>
+
+ * run-addrname-test.sh: Make sure all input addresses are hex.
+
+2015-05-04 Max Filippov <jcmvbkbc@gmail.com>
+
+ * backtrace-child.c (stdarg, main): Replace assert_perror with assert.
+ * backtrace-data.c (memory_read, maps_lookup, set_initial_registers)
+ (main): Likewise.
+ * backtrace-dwarf.c (main): Likewise.
+ * backtrace.c (prepare_thread, exec_dump): Likewise.
+
+2015-05-04 Anthony G. Basile <blueness@gentoo.org>
+
+ * Makefile.am (line2addr_LDADD, addrscopes_LDADD, funcscopes_LDADD)
+ (funcretval_LDADD, allregs_LDADD, find_prologues_LDADD)
+ (dwflmodtest_LDADD, dwfl_addr_sect_LDADD, addrcfi_LDADD)
+ (low_high_pc_LDADD, dwflsyms_LDADD, dwfllines_LDADD, varlocs_LDADD)
+ (backtrace_LDADD, aggregate_size_LDADD): Append $(argp_LDADD).
+
+2015-05-01 Mark Wielaard <mjw@redhat.com>
+
+ * run-stack-d-test.sh: Use --raw and mangled output.
+ * run-stack-i-test.sh: Likewise.
+ * run-stack-demangled-test.sh: New test.
+ * Makefile.am (EXTRA_DIST): Add run-stack-demangled-test.sh.
+ (TESTS): Likewise.
+
+2015-04-01 H.J. Lu <hjl.tools@gmail.com>
+
+ * Makefile.am (TESTS): Add run-strip-test10.sh.
+ (EXTRA_DIST): Likewise. Add testfile-x32-d.bz2.
+ Add testfile-x32-debug.bz2.
+ * run-strip-test10.sh: New file.
+ * testfile-x32-d.bz2: Likewise.
+ * testfile-x32-debug.bz2: Likewise.
+
+2015-04-01 H.J. Lu <hjl.tools@gmail.com>
+
+ * Makefile.am (TESTS): Add run-strip-test9.sh.
+ (EXTRA_DIST): Likewise. Add testfile-x32-s.bz2.
+ * run-strip-test9.sh: New file.
+ * testfile-x32-s.bz2: Likewise.
+
+2015-04-01 H.J. Lu <hjl.tools@gmail.com>
+
+ * Makefile.am (TESTS): Add run-backtrace-core-x32.sh.
+ (EXTRA_DIST): Likewise. Add backtrace.x32.core.bz2.
+ Add backtrace.x32.exec.bz2.
+ * backtrace.x32.core.bz2 : New file.
+ * backtrace.x32.exec.bz2: Likewise.
+ * run-backtrace-core-x32.sh: Likewise.
+
+2015-04-01 H.J. Lu <hjl.tools@gmail.com>
+
+ * run-addrcfi.sh: Add a test for testfile-x32.
+ * testfile-x32.bz2: New file.
+ * Makefile.am (EXTRA_DIST): Add testfile-x32.bz2.
+
+2015-04-01 H.J. Lu <hjl.tools@gmail.com>
+
+ * run-allregs.sh: Add a test for testfile-x32-core.
+
+2015-04-01 H.J. Lu <hjl.tools@gmail.com>
+
+ * run-readelf-mixed-corenote.sh: Add a test for testfile-x32-core.
+ * testfile-x32-core.bz2: New file.
+ * Makefile.am (EXTRA_DIST): Add testfile-x32-core.bz2.
+
+2015-03-18 Petr Machata <pmachata@redhat.com>
+
+ * addrcfi.c (op_name): Adjust uses of know-dwarf.h macros to match
+ the API changes.
+ * allregs.c (dwarf_encoding_string): Likewise.
+ * show-die-info.c (dwarf_tag_string, dwarf_attr_string): Likewise.
+ * varlocs.c (dwarf_encoding_string, dwarf_opcode_string): Likewise.
+
+2015-03-18 Petr Machata <pmachata@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add run-dwarf-ranges.sh,
+ debug-ranges-no-lowpc.o.bz2.
+
+2015-03-13 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-dwarf.c: Add explicit includes.
+ (cleanup_13_abort): Remove unused static declaration.
+ (thread_callback): Add explicit return.
+
+2015-03-13 H.J. Lu <hjl.tools@gmail.com>
+
+ * backtrace.c (prepare_thread): Use PTRACE_GETREGS/PTRACE_SETREGS
+ instead of PTRACE_POKEUSER.
+ (exec_dump): Check EM_X86_64 instead of ELFCLASS64 for
+ is_x86_64_native.
+
+2015-02-18 Mark Wielaard <mjw@redhat.com>
+
+ * newdata.c (check_section_data): Use PRId64 for printing loff_t.
+
+2015-02-11 Josh Stone <jistone@redhat.com>
+
+ * backtrace.c (exec_dump): Initialize jmp.
+
+2015-02-11 Petr Machata <pmachata@redhat.com>
+
+ * run-dwarf-ranges.sh: New test.
+ * dwarf-ranges.c: New file.
+ * debug-ranges-no-lowpc.s, debug-ranges-no-lowpc.o.bz2: New test case.
+
+2015-01-21 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add elfstrtab.
+ (TESTS): Likewise.
+ (elfstrtab_LDADD): New variable.
+ * elfstrtab.c: New test.
+
+2015-01-20 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add newdata.
+ (TESTS): Likewise.
+ (newdata_LDADD): new variable.
+ * newdata.c: New test.
+
+2015-01-20 Mark Wielaard <mjw@redhat.com>
+
+ * strptr.c: New file.
+ * run-strptr.sh: New test.
+ * Makefile.am (check_PROGRAMS): Add strptr.
+ (TESTS): Add run-strptr.sh.
+ (EXTRA_DIST): Likewise.
+ (strptr_LDADD): New variable.
+
+2015-01-15 Mark Wielaard <mjw@redhat.com>
+
+ * deleted.c (main): Call prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY).
+ * vdsosyms.c (main): Use getpid () instead of getppid ().
+
+2014-12-27 Mark Wielaard <mjw@redhat.com>
+
+ * addrscopes.c (handle_address): Last address in scope is highpc - 1.
+ * funcscopes.c (handle_function): Likewise.
+ * run-addrscopes.sh: Adjust last address in scope.
+ * run-funcscopes.sh: Likewise.
+
+2015-01-07 Mark Wielaard <mjw@redhat.com>
+
+ * run-addrcfi.sh: Add test for ppc32 eh_frame_hdr address search.
+
+2015-01-14 Mark Wielaard <mjw@redhat.com>
+
+ * testfile-debug-types.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add testfile-debug-types.bz2.
+ * typeiter2.c (main): Print both name and offset of found form DIE.
+ * run-typeiter.s: Adjust output and add testfile-debug-types.
+
+2014-12-26 Mark Wielaard <mjw@redhat.com>
+
+ * run-test-archive64.sh: Add nm test.
+
+2014-12-19 Mark Wielaard <mjw@redhat.com>
+
+ * run-deleted.sh: Don't check libfunc on ppc64.
+
+2014-12-19 Mark Wielaard <mjw@redhat.com>
+
+ * vdsosyms.c (vdso_seen): Removed.
+ (vdso_syms): New global.
+ (module_callback): Set and check vdso_syms.
+ (main): Return value depends on vdso_syms.
+
+2014-12-19 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-subr.sh (check_native_unsupported): Relax special ARM
+ grep a little.
+ * run-deleted.sh: Call check_native_unsupported.
+
+2014-12-18 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add testfile-macros-0xff.bz2.
+
+2014-12-12 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (deleted_lib_so_CFLAGS): Add
+ -fasynchronous-unwind-tables.
+
+2014-12-11 Josh Stone <jistone@redhat.com>
+
+ * run-addr2line-i-lex-test.sh: New test.
+ * testfile-lex-inlines.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add run-addr2line-i-lex-test.sh and
+ testfile-lex-inlines.bz2.
+ (TESTS): Add run-addr2line-i-lex-test.sh.
+
+2014-12-10 Josh Stone <jistone@redhat.com>
+
+ * run-addr2line-i-test.sh: Test 0x5f0 to make sure linkage_name is
+ preferred over the plain die name.
+
+2014-12-02 Petr Machata <pmachata@redhat.com>
+
+ * dwarf-getmacros.c (mac): Skip over DW_MACINFO_undef,
+ DW_MACRO_GNU_undef_indirect opcodes. Add a default branch.
+ (main): Initialize off to DWARF_GETMACROS_START when an extra
+ command line argument is passed.
+ * testfile-macros-0xff.bz2: New test case.
+ * testfile-macros-0xff.s: New file (source for the above).
+ * run-dwarf-getmacros.sh: Add two tests.
+
+2014-11-27 Mark Wielaard <mjw@redhat.com>
+
+ * vdsosyms.c (main): Call dwfl_linux_proc_attach.
+
+2014-11-21 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-A.sh: New test.
+ * testfileppc32attrs.o.bz2: New test file.
+ * Makefile.am (TESTS): Add run-readelf-A.sh.
+ (EXTRA_DIST): Add run-readelf-A.sh and testfileppc32attrs.o.bz2.
+
+2014-11-10 Mark Wielaard <mjw@redhat.com>
+
+ * vdsosyms.c: New test.
+ * Makefile.am (check_PROGRAMS): Add vdsosyms.
+ (TESTS): Likewise.
+ (vdsosyms_LDADD): New variable.
+
+2014-09-10 Petr Machata <pmachata@redhat.com>
+
+ * dwarf-getmacros.c: Update to use the new macro iteration
+ interfaces.
+ * run-dwarf-getmacros.sh: Adjust, add a test that uses
+ testfile-macros.
+
+2014-10-06 Mark Wielaard <mjw@redhat.com>
+
+ * run-aggregate-size.sh: Add testfile-sizes3.o test case.
+ * testfile-sizes3.o.bz2: New test file.
+ * Makefile.am (EXTRA_DIST): Add testfile-sizes3.o.bz2.
+
+2014-10-02 Mark Wielaard <mjw@redhat.com>
+
+ * run-deleted.sh: Unset VALGRIND_CMD before running deleted.
+
+2014-10-02 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add aggregate_size.c.
+ (TESTS): Add run-aggregate-size.sh.
+ (EXTRA_DIST): Add run-aggregate-size.sh, testfile-sizes1.o.bz2
+ and testfile-sizes2.o.bz2.
+ (aggregate_size_LDADD): New variable.
+ * aggregate_size.c: New file.
+ * run-aggregate-size.sh: New test.
+ * testfile-sizes1.o.bz2: New test file.
+ * testfile-sizes2.o.bz2: Likewise.
+
+2014-09-26 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Support NT_FILE for locating files.
+ * Makefile.am (TESTS): Add run-linkmap-cut.sh.
+ (EXTRA_DIST): Add run-linkmap-cut.sh, linkmap-cut-lib.so.bz2,
+ linkmap-cut.bz2 and linkmap-cut.core.bz2 .
+ * linkmap-cut-lib.so.bz2: New file.
+ * linkmap-cut.bz2: New file.
+ * linkmap-cut.core.bz2: New file.
+ * run-linkmap-cut.sh: New file.
+ * run-unstrip-n.sh: Update its expected output.
+
+2014-08-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add deleted and deleted-lib.so.
+ (TESTS, EXTRA_DIST): Add run-deleted.sh.
+ (deleted_LDADD, deleted_lib_so_LDFLAGS, deleted_lib_so_CFLAGS): New.
+ * deleted-lib.c: New file.
+ * deleted.c: New file.
+ * run-deleted.sh: New file.
+
+2014-06-15 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace.c (frame_callback): Error on seeing more than 16 frames.
+
+2014-06-13 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace.c (callback_verify): Accept "__libc_do_syscall" as first
+ frame symname.
+
+2014-06-13 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-subr.sh (check_native_unsupported): New function.
+ (check_native): Call it.
+ (check_native_core): Likewise.
+ * run-backtrace-dwarf.sh: Likewise.
+
+2014-06-11 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace.c (main): Check that Dwfl was attached by calling
+ dwfl_pid and printing the error when it is not.
+
+2014-05-18 Mark Wielaard <mjw@redhat.com>
+
+ * testfile-backtrace-demangle.cc (cxxfunc): Make non-static.
+ (f): Likewise.
+ * testfile-backtrace-demangle.bz2: Regenerate.
+ * testfile-backtrace-demangle.core.bz2: Likewise.
+
+2014-05-02 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): run-readelf-dwz-multi.sh and
+ run-allfcts-multi.sh are now added unconditionally.
+
+2014-05-01 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-dwz-multi.sh: Add tests with alt debug files in .dwz
+ subdir.
+
+2014-04-30 Mark Wielaard <mjw@redhat.com>
+
+ * buildid.c, buildid.sh, testfile42_noshdrs.bz2: New files.
+ * Makefile.am (check_PROGRAMS): Add buildid.
+ (TESTS): Add run-buildid.sh.
+ (EXTRA_DISTS): Add run-buildid.sh and testfile42_noshdrs.bz2.
+ (buildid_LDADD): New variable.
+
+2014-04-24 Florian Weimer <fweimer@redhat.com>
+
+ * allfcts.c (setup_alt): New function.
+ (main): Call it. Implementation additional error checking and
+ reporting.
+
+2014-04-24 Florian Weimer <fweimer@redhat.com>
+
+ * debugaltlink.c, run-debugaltlink.sh: New files.
+ * Makefile.am (check_PROGRAMS): Add debugaltlink.
+ (TESTS): Add run-debugaltlink.sh.
+ (debugaltlink_LDADD): New variable.
+
+2014-04-11 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (AM_CPPFLAGS): Add -I libdwelf.
+ (check_PROGRAMS): Add debuglink.
+ (TESTS): Add run-debuglink.sh
+ (EXTRA_DIST): Likewise.
+ (debuglink_LDADD): New.
+ * debuglink.c: New file.
+ * run-debuglink.sh: Likewise.
+
+2014-03-23 Mark Wielaard <mjw@redhat.com>
+
+ * run-nm-self.sh: Use test = not == for string comparisons.
+
+2014-04-22 Kurt Roeckx <kurt@roeckx.be>
+
+ * backtrace.c: Make Linux only.
+ * backtrace-child.c: Make Linux only.
+ * backtrace-data.c: Make Linux only.
+ * backtrace-dwarf.c: Make Linux only.
+ * backtrace-subr.sh: Skip core file unwinding tests when not supported.
+
+2014-03-14 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am: Remove MUDFLAP conditions. Remove libmudflap from all
+ LDADD lines.
+ * configure.ac: Remove MUDFLAP conditional.
+
+2014-04-09 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-zdebug.sh: New test.
+ * testfile-debug.bz2: New testfile.
+ * testfile-zdebug.bz2: New testfile.
+ * Makefile.am (TESTS): Add run-readelf-zdebug.sh if ZLIB.
+ (EXTRA_DIST): Add run-readelf-zdebug.sh, testfile-debug.bz2 and
+ testfile-zdebug.bz2.
+
+2014-04-10 Mark Wielaard <mjw@redhat.com>
+
+ * testfile_i686_core.bz2: New test file.
+ * run-readelf-mixed-corenote.sh: Add testfile_i686_core test.
+ * Makefile.am (EXTRA_DIST): Add testfile_i686_core.bz2
+
+2014-04-09 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Add run-backtrace-core-aarch64.sh.
+ (EXTRA_DIST): Add run-backtrace-core-aarch64.sh,
+ backtrace.aarch64.core.bz2 and backtrace.aarch64.exec.bz2.
+ * run-backtrace-core-aarch64.sh: New test.
+
+2014-03-11 Josh Stone <jistone@redhat.com>
+
+ * testfilebaxmin.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add testfilebaxmin.bz2.
+ * run-readelf-s.sh: Test testfilebaxmin.
+ * run-dwflsyms.sh: Likewise.
+
+2014-01-26 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-subr.sh (check_unsupported): Special case arm*.
+
+2014-01-25 Mark Wielaard <mjw@redhat.com>
+
+ * run-addrcfi.sh (EM_ARM): Change reg13 (sp) from undefined to
+ location expression: call_frame_cfa stack_value.
+
+2014-01-22 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (line2addr_no_Wformat): Removed.
+
+2014-01-21 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Add run-stack-i-test.sh.
+ (EXTRA_DIST): Likewise.
+ * run-stack-i-test.sh: New test.
+
+2014-01-20 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Add run-stack-d-test.sh.
+ (EXTRA_DIST): Add run-stack-d-test.sh, testfiledwarfinlines.bz2
+ testfiledwarfinlines.core.bz2.
+ * run-stack-d-test.sh: New test.
+ * testfiledwarfinlines.bz2: New test file.
+ * testfiledwarfinlines.core.bz2: Likewise.
+
+2014-01-16 Mark Wielaard <mjw@redhat.com>
+
+ * run-nm-self.sh: Don't use testrun_on_self_quiet but just testrun
+ on one ET_REL, one ET_EXEC and one ET_DYN file.
+ * test-subr.sh (self_test_files): Add two ET_REL files, only add
+ two libebl ET_DYN backend files.
+
+2014-01-16 Mark Wielaard <mjw@redhat.com>
+
+ * run-backtrace-demangle.sh: Check exitcode and max number of frames.
+
+2014-01-18 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix false FAILs on testsuite with ulimit -c unlimited.
+ * backtrace-child.c (sigusr2): Call pthread_exit.
+ (main): Return, do not call abort.
+
+2014-01-15 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix corruption of non-C++ symbols by the demangler.
+ * Makefile.am (TESTS): Add run-backtrace-demangle.sh.
+ <!DEMANGLE>: Add ELFUTILS_DISABLE_DEMANGLE export.
+ (EXTRA_DIST): Add run-backtrace-demangle.sh,
+ testfile-backtrace-demangle.bz2, testfile-backtrace-demangle.cc,
+ testfile-backtrace-demangle.core.bz2.
+ * backtrace-demangle.cc: New file.
+ * run-backtrace-demangle.sh: New file.
+ * testfile-backtrace-demangle.bz2: New file.
+ * testfile-backtrace-demangle.cc: New file.
+ * testfile-backtrace-demangle.core.bz2: New file.
+
+2014-01-07 Matthias Klose <doko@ubuntu.com>
+
+ * backtrace-subr.sh (check_native_core): Check to see if core file
+ was created without ".PID" extension, if so mv core to core.PID.
+ Skip test if no core file was created or could be found.
+
+2014-01-04 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-data.c (main): Don't assert if raise returns.
+ * backtrace-dwarf.c (report_pid): Call dwfl_linux_proc_attach with
+ assume_ptrace_attached true.
+ (ptrace_detach_stopped): Removed function.
+ (main): Don't call ptrace_detach_stopped.
+ * backtrace.c (ptrace_detach_stopped): Removed function.
+ (report_pid): Call dwfl_linux_proc_attach with assume_ptrace_attached
+ true.
+ (exec_dump): Don't call ptrace_detach_stopped.
+
+2014-01-04 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-subr.sh (check_native_core): Skip, exit 77, the test
+ if we cannot adjust core ulimit.
+
+2014-01-04 Mark Wielaard <mjw@redhat.com>
+
+ * cleanup-13.c (force_unwind_stop): Removed.
+ (force_unwind): Just call abort. Don't setup _Unwind_Exception and
+ don't call _Unwind_ForcedUnwind.
+
+2014-01-03 Mark Wielaard <mjw@redhat.com>
+
+ * run-addrcfi.sh: Add case for EM_AARCH64.
+ * testfileaarch64.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add testfilesaarch64.bz2.
+
+2013-12-30 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-dwarf.c (report_pid): Explicitly call
+ dwfl_linux_proc_attach and check for errors.
+ * backtrace.c (report_pid): Likewise.
+
+2013-12-21 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace.c (callback_verify): Only assert that case 5 is the last
+ instruction of backtracegen on x86_64 native.
+
+2013-12-18 Jan Kratochvil <jan.kratochvil@redhat.com>
+ Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add testfile66.bz2, testfile66.core.bz2
+ and testfilebaz*ppc64*.bz2 files.
+ * dwflsyms.c (list_syms): Remove unused from parameter mod_name. Print
+ error on dwfl_module_getsymtab error.
+ (list_syms): Use dwfl_module_getsym and dwfl_module_getsym_info.
+ Compare values for non-ET_REL. Use dwfl_module_addrinfo.
+ Also print section of actual value if different from sym.
+ * run-addrname-test.sh (testfile66, testfile66.core): New tests.
+ Test addr2line -x by showing different sections for address and
+ found name in testfile66.
+ * run-dwflsyms.sh (testfile66, testfile66.core, hello_ppc64.ko,
+ testfilebaz*ppc64): New tests.
+ * testfile66.bz2, testfile66.core.bz2, testfilebazdbgppc64.bz2,
+ testfilebazdbgppc64.debug.bz2, testfilebazdbgppc64_pl.bz2,
+ testfilebazdbgppc64_plr.bz2, testfilebazdynppc64.bz2,
+ testfilebazmdbppc64.bz2, testfilebazminppc64.bz2,
+ testfilebazminppc64_pl.bz2, testfilebazminppc64_plr.bz2,
+ testfilebaztabppc64.bz2: New test files.
+
+2013-12-18 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ unwinder: s390 and s390x
+ * Makefile.am (TESTS): Add run-backtrace-core-s390x.sh and
+ run-backtrace-core-s390.sh.
+ (EXTRA_DIST): Add backtrace.s390x.core.bz2, backtrace.s390x.exec.bz2,
+ backtrace.s390.core.bz2, backtrace.s390.exec.bz2,
+ run-backtrace-core-s390x.sh and run-backtrace-core-s390.sh.
+ * backtrace.s390.core.bz2: New file.
+ * backtrace.s390.exec.bz2: New file.
+ * backtrace.s390x.core.bz2: New file.
+ * backtrace.s390x.exec.bz2: New file.
+ * run-backtrace-core-s390.sh: New file.
+ * run-backtrace-core-s390x.sh: New file.
+
+2013-12-17 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * backtrace-dwarf.c (executable, find_elf, dwfl_offline): Remove unused
+ code.
+
+2013-12-15 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ unwinder: ppc
+ * Makefile.am (TESTS): Add run-backtrace-core-ppc.sh.
+ (EXTRA_DIST): Add backtrace.ppc.core.bz2,
+ backtrace.ppc.exec.bz2 and run-backtrace-core-ppc.sh.
+ * backtrace.ppc.core.bz2: New file.
+ * backtrace.ppc.exec.bz2: New file.
+ * run-backtrace-core-ppc.sh: New file.
+
+2013-12-10 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (backtrace_child_biarch_SOURCES): New backtrace-child.c.
+
+2013-12-10 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (valgrind_cmd): Remove --trace-children=yes.
+ * backtrace-subr.sh (check_native_core): Disable valgrind while
+ dumping core.
+ * run-backtrace-data.sh: Disable valgrind.
+ * run-backtrace-dwarf.sh: Likewise.
+
+2013-12-09 Mark Wielaard <mjw@redhat.com>
+
+ * varlocs.c (print_expr): Update comment to explain empty location
+ associated with DW_OP_GNU_implicit_pointer.
+
+2013-12-05 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix test FAIL with -O2.
+ * backtrace-child.c (sigusr2): Add NOINLINE_NOCLONE and final asm stub.
+
+2013-12-05 Mark Wielaard <mjw@redhat.com>
+
+ * backtrace-data.c (main): If unsupported also print to stderr.
+ * run-backtrace-dwarf.sh: Add check_unsupported and check_main.
+
+2013-12-04 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (backtrace-child-biarch): Add $(EXEEXT).
+
+2013-12-02 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add backtrace, backtrace-child,
+ backtrace-data and backtrace-dwarf.
+ (BUILT_SOURCES, clean-local, backtrace-child-biarch): New.
+ (TESTS): Add run-backtrace-native.sh, run-backtrace-data.sh,
+ run-backtrace-dwarf.sh, run-backtrace-native-biarch.sh,
+ run-backtrace-native-core.sh, run-backtrace-native-core-biarch.sh,
+ run-backtrace-core-x86_64.sh and run-backtrace-core-i386.sh.
+ <!BIARCH> Add export of ELFUTILS_DISABLE_BIARCH.
+ (EXTRA_DIST): Add run-backtrace-data.sh, run-backtrace-dwarf.sh,
+ cleanup-13.c, run-backtrace-native.sh, run-backtrace-native-biarch.sh,
+ run-backtrace-native-core.sh, run-backtrace-native-core-biarch.sh,
+ run-backtrace-core-x86_64.sh, run-backtrace-core-i386.sh,
+ backtrace-subr.sh, backtrace.i386.core.bz2, backtrace.i386.exec.bz2,
+ backtrace.x86_64.core.bz2, backtrace.x86_64.exec.bz2.
+ (backtrace_LDADD, backtrace_child_CFLAGS, backtrace_child_LDFLAGS)
+ (backtrace_data_LDADD, backtrace_dwarf_CFLAGS, backtrace_dwarf_LDADD):
+ New.
+ * backtrace-child.c: New file.
+ * backtrace-data.c: New file.
+ * backtrace-dwarf.c: New file.
+ * backtrace-subr.sh: New file.
+ * backtrace.c: New file.
+ * cleanup-13.c: New file.
+ * backtrace.i386.core.bz2: New file.
+ * backtrace.i386.exec.bz2: New file.
+ * backtrace.x86_64.core.bz2: New file.
+ * backtrace.x86_64.exec.bz2: New file.
+ * run-backtrace-core-i386.sh: New file.
+ * run-backtrace-core-x86_64.sh: New file.
+ * run-backtrace-native-biarch.sh: New file.
+ * run-backtrace-native-core-biarch.sh: New file.
+ * run-backtrace-native-core.sh: New file.
+ * run-backtrace-native.sh: New file.
+ * run-backtrace-data.sh: New file.
+ * run-backtrace-dwarf.sh: New file.
+
+2013-11-27 Mark Wielaard <mjw@redhat.com>
+
+ * dwflsyms.c (gelf_bind_order): New function.
+ (elf_section_name): Likewise.
+ (addr_in_section): Likewise.
+ (list_syms): Use dwfl_module_getsym_elf and dwfl_module_addrsym_elf.
+ Refine assert using gelf_bind_order. Print elf_section_name. Check
+ bias with addr_in_section.
+ * run-dwflsyms.sh: Add section names to expected output.
+
+2013-11-26 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add run-funcretval.sh.
+
+2013-11-25 Petr Machata <pmachata@redhat.com>
+
+ * testfile_aarch64_core.bz2, hello_aarch64.ko.bz2: New files.
+ * funcretval_test.c, funcretval_test_aarch64.bz2: Likewise.
+ * Makefile.am (EXTRA_DIST): Add these.
+ (TESTS): Add run-funcretval.sh.
+ * run-allregs.sh: Use testfile_aarch64_core.bz2 for a regs_test.
+ * run-readelf-mixed-corenote.sh: ... and for a readelf -n test.
+ * run-strip-reloc.sh: Add a test on hello_aarch64.ko.bz2.
+ * run-funcretval.sh: New file.
+
+2013-11-18 Josh Stone <jistone@redhat.com>
+
+ * testfilebazdbg_plr.bz2: New testfile.
+ * testfilebazmin_plr.bz2: Likewise.
+ * Makefile.am (EXTRA_DIST): Add the above files.
+ * run-dwflsyms.sh: Add prelink -r tests.
+
+2013-11-15 Mark Wielaard <mjw@redhat.com>
+
+ * testfilebazmdb.bz2: Regenerated.
+ * testfilebazmin.bz2: Likewise.
+ * testfilebazdbg_pl.bz2: New testfile.
+ * testfilebazmin_pl.bz2: Likewise.
+ * Makefile.am (EXTRA_DIST): Add testfilebazdbg_pl.bz2 and
+ testfilebazmin_pl.bz2.
+ * dwflsyms.c (list_syms): Call dwfl_module_relocate_address and
+ print relative address of function symbols.
+ * run-dwflsyms.sh: Add prelink tests and adjust expected output.
+
+2013-11-01 Michael Forney <mforney@mforney.org>
+
+ * Makefile.am (TESTS_ENVIRONMENT): Use and export NM.
+ * run-arsymtest.sh: Use NM.
+
+2013-11-05 Mark Wielaard <mjw@redhat.com>
+
+ * allfcts.c (main): Correct dwarf_getfuncs return value check.
+
+2013-10-10 Mark Wielaard <mjw@redhat.com>
+ Josh Stone <jistone@redhat.com>
+
+ * run-allfcts-multi.sh: New test.
+ * test-offset-loop.bz2: New testfile.
+ * test-offset-loop.alt.bz2: New testfile.
+ * Makefile.am (TESTS): Add run-allcft-multi.sh if ENABLE_DWZ.
+ (EXTRA_DIST): Add run-allfcts-multi.sh, test-offset-loop.bz2 and
+ test-offset-loop.alt.bz2.
+
+2013-10-15 Mark Wielaard <mjw@redhat.com>
+
+ * run-unstrip-M.sh: New test.
+ * Makefile.am (TESTS): Add run-unstrip-M.sh.
+ (EXTRA_DIST): Likewise.
+
+2013-10-06 Mark Wielaard <mjw@redhat.com>
+
+ * run-addrcfi.sh: Remove nop from expected ppc and ppc64
+ location expression.
+
+2013-10-03 Josh Stone <jistone@redhat.com>
+
+ * typeiter2.c: New file, reversing typeiter.c.
+ * run-typeiter.sh: Also run typeiter2.
+ * Makefile.am (check_PROGRAMS): Add typeiter2.
+ (typeiter2_LDADD): New variable.
+
+2013-09-26 Petr Machata <pmachata@redhat.com>
+
+ * run-readelf-mixed-corenote.sh: Update output of testfile71
+ dump--readelf can newly decode the NT_FILE note.
+
+2013-09-26 Petr Machata <pmachata@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add testfile71.bz2.
+ * run-readelf-mixed-corenote.sh: New test for this file.
+ * testfile71.bz2: New file.
+
+2013-09-20 Mark Wielaard <mjw@redhat.com>
+
+ * allfcts.c (cb): Return DWARF_CB_ABORT.
+ (main): Iterate over all offsets returned by dwarf_getfuncs.
+ * run-allfcts.sh: Add nested_funcs and class_func testcases.
+ * testfile_nested_funcs.bz2: New test file.
+ * testfile_class_func.bz2: Likewise.
+ * Makefile.am (EXTRA_DIST): Add testfile_class_func.bz2 and
+ testfile_nested_funcs.bz2.
+
+2013-08-30 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add varlocs.
+ (TESTS): Add run-varlocs.sh.
+ (EXTRA_DIST): Add run-varlocs.sh, testfile_const_type.c,
+ testfile_const_type.bz2, testfile_implicit_pointer.c,
+ testfile_implicit_pointer.bz2, testfile_parameter_ref.c,
+ testfile_entry_value.c, testfile_entry_value.bz2,
+ testfile_implicit_value.c and testfile_implicit_value.bz2.
+ (varlocs_LDADD): New.
+ * run-varlocs: New test.
+ * testfile_const_type.c: New test source file.
+ * testfile_entry_value.c: Likewise.
+ * testfile_implicit_pointer.c: Likewise.
+ * testfile_implicit_value.c: Likewise.
+ * testfile_parameter_ref.c: Likewise.
+ * testfile_const_type.bz2: New test file.
+ * testfile_entry_value.bz2: Likewise.
+ * testfile_implicit_pointer.bz2: Likewise.
+ * testfile_implicit_value.bz2: Likewise.
+ * testfile_parameter_ref.bz2: Likewise.
+ * varlocs.c: New test source.
+
+2013-08-29 Mark Wielaard <mjw@redhat.com>
+
+ * run-addrcfi.sh: Add case for EM_ARM.
+ * testfilearm.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add testfilesarm.bz2.
+
+2013-08-28 Mark Wielaard <mjw@redhat.com>
+
+ * addrcfi.c (handle_cfi): Handle .debug_frame or .eh_frame
+ completely missing.
+ * run-addrcfi.sh: Add case for EM_S390 ELFCLASS32 and ELFCLASS64.
+ * testfiles390.bz2: New testfile.
+ * testfiles390x.bz2: Likewise.
+ * Makefile.am (EXTRA_DIST): Add testfiles390.bz2 and
+ testfiles390x.bz2.
+
+2013-08-28 Mark Wielaard <mjw@redhat.com>
+
+ * addrcfi.c (handle_cfi): Use printf not error.
+ * run-addrcfi.sh: Add case for EM_PPC and EM_PPC64.
+ * testfileppc32.bz2: New testfile.
+ * testfileppc64.bz2: Likewise.
+ * Makefile.am (EXTRA_DIST): Add testfileppc32.bz2 and
+ testfileppc64.bz2.
+
+2013-08-27 Mark Wielaard <mjw@redhat.com>
+
+ * run-addrcfi.sh: New test.
+ * Makefile.am (TESTS): Add run-addrcfi.sh.
+ (EXTRA_DIST): Likewise.
+ * addrcfi.c (op_name): New function.
+ (print_detail): Call and print op_name. Check ops, not result
+ to check if this is "same value" or "undefined".
+ (handle_cfi): Make sure cfa_ops doesn't point to NULL.
+
+2013-08-13 Mark Wielaard <mjw@redhat.com>
+
+ * run-addr2line-i-test.sh: New test.
+ * testfile-inlines.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add run-addr2line-i-test.sh and
+ testfile-inlines.bz2.
+ (TESTS): Add run-addr2line-i-test.sh.
+
+2013-08-12 Mark Wielaard <mjw@redhat.com>
+
+ * run-addr2line-test.sh: New test.
+ * Makefile.am (EXTRA_DIST): Add run-addr2line-test.sh.
+ (TESTS): Likewise.
+
+2013-07-23 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * run-unstrip-n.sh (test-core.*): Ignore libc.so.6 entry and order of
+ the entries.
+
+2013-07-02 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Fix typo, forgot extension in
+ testfilenolines.bz2.
+
+2013-05-30 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add test-core-lib.so.bz2,
+ test-core.core.bz2 and test-core.exec.bz2.
+ * run-addrname-test.sh: New test for these files.
+ * run-unstrip-n.sh: Update expected output. New test for these files.
+ * test-core-lib.so.bz2: New file.
+ * test-core.core.bz2: New file.
+ * test-core.exec.bz2: New file.
+
+2013-05-03 Mark Wielaard <mjw@redhat.com>
+
+ * testfilenolines.bz2: New test file.
+ * Makefile.am (EXTRA_DIST): Add testfilenolines.bz2.
+ * run-get-lines.sh: Run testrun_compare on testfilenolines.
+
+2013-04-30 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * dwfl-report-elf-align.c: Use false add_p_vaddr for dwfl_report_elf.
+
+2013-04-29 Mark Wielaard <mjw@redhat.com>
+
+ * test-subr.sh: Don't use pushd, just cd into test-dir.
+ (exit_cleanup): Don't use popd, just cd .. to get out.
+
+2013-04-27 Mark Wielaard <mjw@redhat.com>
+
+ * test-subr.sh (exit_cleanup): New function.
+ (trap): Use exit_cleanup as argument.
+ * run-native-test.sh (native_exit): New function.
+ (trap): For EXIT (0) use native_exit as argument.
+
+2013-04-27 Mark Wielaard <mjw@redhat.com>
+
+ * update1.c (main): Use unique tempfile name and unlink file.
+ * update2.c (main): Likewise.
+ * update3.c (main): Likewise.
+ * update4.c (main): Use unique tempfile name.
+
+2013-04-27 Mark Wielaard <mjw@redhat.com>
+
+ * run-alldts.sh: Add testfile-alldts to tempfiles.
+ * run-elf_cntl_gelf_getshdr.sh: Add test_shdr.out to tempfiles.
+ * run-macro-test.sh: Add readelf.macros.out to tempfiles.
+ * run-strip-reloc.sh: Add readelf.out, readelf.out1, readelf.out2
+ and out.stripped1, out.debug1, out.stripped2, out.debug2 to tempfiles.
+
+2013-04-26 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (installed_TESTS_ENVIRONMENT): Export environment,
+ remove wrapper.
+ (TESTS_ENVIRONMENT): Likewise.
+ (installed_LOG_COMPILER): New variable defining wrapper.
+ (LOG_COMPILER): Likewise.
+ * run-*.sh: Fixup location of input and output files.
+ * test-subr.sh: Create test_dir, pushd to execute test in.
+ (trap): Remove test_dir.
+ (testfiles): Use abs_srcdir.
+ (installed_testrun): Match on abs_builddir or abs_top_builddir.
+ (self_test_files): Adjust path.
+
+2013-04-24 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am: Use AM_CPPFLAGS instead of INCLUDES.
+
+2013-03-25 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-aranges.sh: New test.
+ * testfilefoobarbaz.bz2: New test file.
+ * Makefile.am (TESTS): Add run-readelf-aranges.sh.
+ (EXTRA_DIST): Add run-readelf-aranges.sh and testfilefoobarbaz.bz2.
+
+2013-03-25 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-dwz-multi.sh: Expect high_pc also as address.
+
+2013-03-20 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add dwfl-report-elf-align.
+ (TESTS): Add run-dwfl-report-elf-align.sh.
+ (EXTRA_DIST): Add run-dwfl-report-elf-align.sh and
+ testfile-dwfl-report-elf-align-shlib.so.bz2 .
+ (dwfl_report_elf_align_LDADD): New.
+ * dwfl-report-elf-align.c: New file.
+ * run-dwfl-report-elf-align.sh: New file.
+ * testfile-dwfl-report-elf-align-shlib.so.bz2: New file.
+
+2013-03-12 Mark Wielaard <mjw@redhat.com>
+
+ * run-dwfllines.sh: New test.
+ * dwfllines.c: New test program.
+ * Makefile.am (TESTS): Add run-dwfllines.sh.
+ (EXTRA_DIST): Likewise.
+ (dwfllines_LDADD): New variable.
+
+2013-02-22 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Remove run-readelf-s.sh and run-dwflsyms.sh.
+ (LZMA): Add run-readelf-s.sh and run-dwflsyms.sh to TESTS.
+
+2013-02-15 Mark Wielaard <mjw@redhat.com>
+
+ * testfile-dwzstr.bz2: New testfile.
+ * testfile-dwzstr.multi.bz2: Likewise.
+ * run-readelf-dwz-multi.sh: Add readelf testfile-dwzstr test.
+ * Makefile.am (EXTRA_DIST): Add testfile-dwzstr.bz2 and
+ testfile-dwzstr.multi.bz2.
+
+2013-01-30 Mark Wielaard <mjw@redhat.com>
+
+ * testfileloc.bz2: New testfile.
+ * run-readelf-loc.sh: New test.
+ * Makefile.am (TESTS): Add run-readelf-loc.sh.
+ (EXTRA_DIST): Add run-readelf-loc.sh and testfileloc.bz2.
+
+2013-01-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * run-readelf-mixed-corenote.sh: New testcase for readelf -n of s390
+ and s390x core notes.
+ * testfile67.bz2: New file.
+ * testfile68.bz2: New file.
+ * Makefile.am (EXTRA_DIST): Add testfile67.bz2 and testfile68.bz2 .
+
+2013-01-23 Mark Wielaard <mjw@redhat.com>
+
+ * testfilebasmin.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add testfilebasmin.bz2.
+ * run-readelf-s.sh: Test testfilebasmin.
+ * run-dwflsyms.sh: Likewise.
+
+2013-01-16 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add dwflsyms.
+ (TESTS): Add run-readelf-s.sh and run-dwflsyms.sh.
+ (EXTRA_DIST): Add run-readelf-s.sh, testfilebazdbg.bz2,
+ testfilebazdyn.bz2, testfilebazmin.bz2, testfilebazdbg.debug.bz2,
+ testfilebazmdb.bz2, testfilebaztab.bz2 and run-dwflsyms.sh.
+ (dwflsyms_LDADD): New variable.
+
+2013-01-07 Roland McGrath <roland@hack.frob.com>
+
+ * run-prelink-addr-test.sh: Use ln -snf.
+
+2012-12-03 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (valgrind_cmd): Add --run-libc-freeres=no.
+
+2012-11-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * run-addrname-test.sh: New test for PIE relocation.
+ * testfile70.core.bz2: New file.
+ * testfile70.exec.bz2: New file.
+ * Makefile.am (EXTRA_DIST): Add testfile70.core.bz2 and
+ testfile70.exec.bz2 .
+
+2012-10-27 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add testfile64.bz2, testfile65.bz2,
+ testfile69.core.bz2 and testfile69.so.bz2 .
+
+2012-10-17 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * run-addrname-test.sh: New test for DSO with build-id bias.
+ * testfile69.core.bz2: New file.
+ * testfile69.so.bz2: New file.
+
+2012-10-10 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * run-addrname-test.sh: New test for core vDSO bias.
+ * testfile65.bz2: New file.
+
+2012-10-10 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * run-addrname-test.sh: New test for symbol preferences.
+ * testfile64.bz2: New file.
+
+2012-10-01 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS_ENVIRONMENT): Define valgrind_cmd if USE_VALGRIND.
+ * test-wrapper.sh: Export VALGRIND_CMD if available.
+ * test-subr.sh (built_testrun): Use VALGRIND_CMD to invoke test prog.
+ (installed_testrun): Likewise.
+
+2012-09-24 Petr Machata <pmachata@redhat.com>
+
+ * testfile63.bz2: New testfile.
+ * run-readelf-mixed-corenote.sh: New test.
+ * Makefile.am (TEST): Add run-readelf-mixed-corenote.sh.
+ (EXTRA_DIST): Add testfile63.bz2 and run-readelf-mixed-corenote.sh.
+
+2012-09-24 Petr Machata <pmachata@redhat.com>
+
+ * testfile62.bz2: New testfile.
+ * run-readelf-vmcoreinfo.sh: New test.
+ * Makefile.am (TEST): Add run-readelf-vmcoreinfo.sh.
+ (EXTRA_DIST): Add testfile62.bz2 and run-readelf-vmcoreinfo.sh.
+
+2012-09-18 Petr Machata <pmachata@redhat.com>
+
+ * testfile61.bz2: New testfile.
+ * run-allregs.sh: Run reg_test testfile61.
+ * Makefile.am (EXTRA_DIST): Add testfile61.bz2.
+
+2012-08-24 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add testfile60.bz2.
+
+2012-08-22 Jeff Kenton <jkenton@tilera.com>
+
+ * testfile60.bz2: New testfile.
+ * run-allregs.sh: Run reg_test testfile60.
+
+2012-08-24 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Only add run-readelf-dwz-multi.sh if
+ ENABLE_DWZ.
+
+2012-08-16 Mark Wielaard <mjw@redhat.com>
+
+ * allregs.c (dwarf_encoding_string): Rewritten using known-dwarf
+ macros.
+ * show-die-info.c (tagnames): Removed.
+ (attrs): Removed.
+ (dwarf_tag_string): New function using known-dwarf macros.
+ (dwarf_attr_string): Likewise.
+ (handle): Call dwarf_tag_string and dwarf_attr_string instead.
+ * run-readelf-dwz-multi.sh: Expect language C89, not ISO C89.
+
+2012-06-27 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Add run-readelf-dwz-multi.sh.
+ (EXTRA_DIST): Add run-readelf-dwz-multi.sh,
+ libtestfile_multi_shared.so.bz2, testfile_multi.dwz.bz2 and
+ testfile_multi_main.bz2.
+ * run-readelf-dwz-multi.sh: New test.
+ * libtestfile_multi_shared.so.bz2: New testfile.
+ * testfile_multi.dwz.bz2: New testifle.
+ * testfile_multi_main.bz2: New testifle.
+
+2012-08-01 Petr Machata <pmachata@redhat.com>
+
+ * run-test-archive64.sh: New test.
+ * testarchive64.a.bz2: New testfile.
+ * Makefile.am (TESTS): Add run-test-archive64.sh.
+ (EXTRA_DIST): Likewise.
+
+2012-08-01 Mark Wielaard <mjw@redhat.com>
+
+ * run-nm-self.sh: New test.
+ * run-readelf-self.sh: Likewise.
+ * test-subr.sh (testrun_on_self_quiet): New function.
+ * Makefile.am (TESTS): Add run-nm-self.sh and run-readelf-self.sh.
+ (EXTRA_DIST): Likewise.
+
+2012-08-01 Mark Wielaard <mjw@redhat.com>
+
+ * test-subr.sh (self_test_files): New list of files.
+ (testrun_on_self): New function.
+ * run-elflint-self.sh: Use testrun_on_self.
+
+2012-07-19 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add test-elf_cntl_gelf_getshdr.
+ (TESTS): Add run-elf_cntl_gelf_getshdr.sh.
+ (EXTRA_DIST): Likewise.
+ (test_elf_cntl_gelf_getshdr_LDADD): New.
+ test-elf_cntl_gelf_getshdr.c: New test program.
+ run-elf_cntl_gelf_getshdr.sh: New test script.
+
+2012-07-19 Mark Wielaard <mjw@redhat.com>
+
+ * run-elflint-self.sh: runtests on ../backends/*so files.
+
+2012-07-19 Mark Wielaard <mjw@redhat.com>
+
+ * run-unstrip-n.sh: test_cleanup.
+ * Makefile.am (EXTRA_DIST): Add testcore-rtlib-ppc.bz2.
+
+2012-07-11 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-macro.sh: New test.
+ * testfilemacro.bz2: New testfile.
+ * Makefile.am (TESTS): Add run-readelf-macro.sh.
+ (EXTRA_DIST): Add run-readelf-macro.sh and testfilemacro.bz2.
+
+2012-06-27 Mark Wielaard <mjw@redhat.com>
+
+ * run-readelf-gdb-index.sh: New test.
+ * testfilegdbindex5.bz2: New testfile.
+ * testfilegdbindex7.bz2: Likewise.
+ * Makefile.am (TESTS): Add run-readelf-gdb-index.sh.
+ (EXTRA_DIST): run-readelf-gdb_index.sh, testfilegdbindex5.bz2 and
+ testfilegdbindex7.bz2.
+
+2012-07-17 Mark Wielaard <mjw@redhat.com>
+
+ * testcore-rtlib-ppc.bz2: New testfile.
+ * run-unstrip-n.sh: Check new ppc core testfile.
+
+2012-06-26 Mike Frysinger <vapier@gentoo.org>
+
+ * Makefile.am (check_PROGRAMS): Rename from noinst_PROGRAMS.
+
+2012-06-26 Mark Wielaard <mjw@redhat.com>
+
+ * run-macro-test.sh: New test.
+ * testfile-macinfo.bz2: New testfile.
+ * testfile-macros.bz2: Likewise.
+
+2012-05-07 Mark Wielaard <mjw@redhat.com>
+
+ * low_high_pc.c: Use proper inttypes in printf formats.
+
+2012-05-11 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS_ENVIRONMENT): Set LC_ALL and LANG to C.
+
+2012-05-07 Mark Wielaard <mjw@redhat.com>
+
+ * low_high_pc.c: Allow highpc == lowpc for CU DIEs for buggy GCC.
+
+2012-04-27 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Add run-low_high_pc.sh
+ (EXTRA_DIST): Add run-low_high_pc.sh and testfile_low_high_pc.bz2
+ (noinst_PROGRAMS): Add low_high_pc.
+ (low_high_pc_LDADD): New variable.
+ * low_high_pc.c: New test.
+
+2012-04-26 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Remove run-show-ciefde.sh.
+ * run-show-ciefde.sh: Removed old libdwarf test.
+ * show-ciefde.c: Likewise.
+
+2012-04-02 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Add run-unstrip-n.sh.
+ (EXTRA_DIST): Add testcore-rtlib.bz2 and run-unstrip-n.sh.
+ * run-unstrip-n.sh: New test.
+ * testcore-rtlib.bz2: New testfile.
+
+2012-04-02 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Add run-readelf-d.sh.
+ (EXTRA_DIST): Add testlib_dynseg.so.bz2 and run-readelf-d.sh.
+ * run-readelf-d.sh: New test.
+ * run-elflint-test.sh: Check new testfile.
+
+2012-03-21 Tom Tromey <tromey@redhat.com>
+
+ * typeiter.c: New file.
+ * run-typeiter.sh: New file.
+ * testfile59.bz2: New file.
+ * Makefile.am (noinst_PROGRAMS): Add typeiter.
+ (TESTS): Add run-typeiter.sh.
+ (EXTRA_DIST): Add run-typeiter.sh, testfile59.bz2.
+ (typeiter_LDADD): New variable.
+
+2012-02-21 Kurt Roeckx <kurt@roeckx.be>
+
+ * run-alldts.sh: testrun ./alldts.
+
+2012-02-21 Roland McGrath <roland@hack.frob.com>
+
+ * test-wrapper.sh: Add ${libdir}/elfutils to LD_LIBRARY_PATH.
+ * test-subr.sh (installed_testrun): Likewise.
+
+2012-01-18 Roland McGrath <roland@hack.frob.com>
+
+ * asm-tst4.c (main): Don't set LD_LIBRARY_PATH in system invocation;
+ it will have been inherited correctly from the test harness.
+ * asm-tst5.c (main): Likewise.
+ * asm-tst6.c (main): Likewise.
+ Reported by Serge Pavlov <serge.pavlov.at.gnu@gmail.com>.
+
+2011-07-09 Roland McGrath <roland@hack.frob.com>
+
+ * sha1-tst.c: File removed.
+ * Makefile.am (noinst_PROGRAMS, TESTS): Remove it.
+ (sha1_tst_LDADD): Variable removed.
+
+ * md5-sha1-test.c: New file.
+ * Makefile.am [!STANDALONE] (noinst_PROGRAMS, TESTS): Add it.
+ (md5_sha1_test_LDADD): New variable.
+
+2011-05-30 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add run-readelf-twofiles.sh and
+ run-rerequest_tag.sh
+
+2011-05-24 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add hello_s390.ko.bz2.
+ * run-strip-reloc.sh: Add hello_s390.ko testcase.
+ * hello_s390.ko.bz2: New test file.
+
+2011-05-23 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (TESTS): Add run-strip-reloc.sh.
+ (EXTRA_DIST): Add run-strip-reloc.sh, hello_i386.ko.bz2
+ hello_x86_64.ko.bz2 and hello_ppc64.ko.bz2
+ * run-strip-reloc.sh: New test.
+ * hello_i386.ko.bz2: New test file.
+ * hello_x86_64.ko.bz2: Likewise.
+ * hello_ppc64.ko.bz2: Likewise.
+
+2011-05-18 Mark Wielaard <mjw@redhat.com>
+
+ * run-strip-groups.sh: New test.
+ * testfile58.bz2: New test file.
+ * Makefile.am (EXTRA_DIST): Add testfile58.bz2.
+ (TESTS): Add run-strip-groups.sh.
+ (EXTRA_DIST): Likewise.
+
+2011-03-28 Marek Polacek <mpolacek@redhat.com>
+
+ * alldts.c: New file.
+ * run-alldts.sh: Use it.
+ * Makefile.am (TESTS, EXTRA_DIST, noinst_PROGRAMS): Add them.
+ (alldts_LDADD): New variable.
+
+2011-03-02 Marek Polacek <mpolacek@redhat.com>
+
+ * dwarf-getstring.c: New test.
+ * run-dwarf-getstring.sh: And its wrapper.
+ * Makefile.am (EXTRA_DIST): Add and update all.
+
+2011-02-27 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.am (TESTS): Add run-readelf-twofiles.sh.
+ * run-readelf-twofiles.sh: New file.
+
+2011-02-25 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (BUILD_RPATH): Be consistent in naming.
+
+2011-02-02 Josh Stone <jistone@redhat.com>
+
+ * run-prelink-addr-test.sh: Add testfile55, 32 and 64-bit.
+ * testfile55-64.bz2, testfile55-64.debug.bz2,
+ testfile55-64.prelink.bz2, testfile55-32.bz2,
+ testfile55-32.debug.bz2, testfile55-32.prelink.bz2: New.
+ * Makefile.am (EXTRA_DIST): Add and update all.
+
+2011-01-12 Roland McGrath <roland@redhat.com>
+
+ * run-prelink-addr-test.sh: Make symlinks to find .debug files
+ corresponding to .noshdrs files.
+
+2011-01-11 Josh Stone <jistone@redhat.com>
+
+ * run-prelink-addr-test.sh: Add testfile54, 32 and 64-bit.
+ * testfile54-32.so.bz2, testfile54-32.so.debug.bz2,
+ testfile54-32.prelink.so.bz2, testfile54-32.noshdrs.so.bz2,
+ testfile54-64.so.bz2, testfile54-64.so.debug.bz2,
+ testfile54-64.prelink.so.bz2, testfile54-64.noshdrs.so.bz2: New.
+ * Makefile.am (EXTRA_DIST): Add and update all.
+
+ * run-prelink-addr-test.sh: Run 32 and 64-bit testfile53 tests.
+ * testfile53.bz2, testfile53.debug.bz2,
+ testfile53.prelink.bz2: Deleted, so...
+ * testfile53-64.bz2, testfile53-64.debug.bz2,
+ testfile53-64.prelink.bz2: Recreated with 64-bit names.
+ * testfile53-32.bz2, testfile53-32.debug.bz2,
+ testfile53-32.prelink.bz2: New in 32-bit.
+ * Makefile.am (EXTRA_DIST): Add and update all.
+
+ * run-prelink-addr-test.sh: Run 32 and 64-bit testfile52 tests.
+ * testfile52.so.bz2, testfile52.so.debug.bz2,
+ testfile52.prelink.so.bz2: Deleted, so...
+ * testfile52-32.so.bz2, testfile52-32.so.debug.bz2,
+ testfile52-32.prelink.so.bz2: Recreated with 32-bit names.
+ * testfile52-32.noshdrs.so.bz2: New data file, stripped of headers.
+ * testfile52-64.so.bz2, testfile52-64.so.debug.bz2,
+ testfile52-64.prelink.so.bz2, testfile52-64.noshdrs.so.bz2: New files.
+ * Makefile.am (EXTRA_DIST): Add and update all.
+
+2011-01-10 Josh Stone <jistone@redhat.com>
+
+ * run-prelink-addr-test.sh: New test for prelinked addrs.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+ * testfile52.so.bz2, testfile52.so.debug.bz2: New data files.
+ * testfile52.prelink.so.bz2: New data file, shows REL->RELA.
+ * testfile53.bz2, testfile53.debug.bz2: New data files.
+ * testfile53.prelink.bz2: New data file, shows ET_EXEC remap.
+ * Makefile.am (EXTRA_DIST): Add them.
+
+2010-06-04 Roland McGrath <roland@redhat.com>
+
+ * run-unstrip-test.sh: Also test modifying the file in place.
+
+2010-04-22 Roland McGrath <roland@redhat.com>
+
+ * addrcfi.c (handle_cfi): Fix function name in error message.
+ Use dwarf_errmsg, not dwfl_errmsg, after dwarf_cfi_addrframe.
+
+2010-04-14 Roland McGrath <roland@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add run-test-flag-nobits.sh here too.
+
+2010-04-10 Ulrich Drepper <drepper@redhat.com>
+
+ * msg_tst.c: Adjust expected error message.
+
+2010-04-01 Petr Machata <pmachata@redhat.com>
+
+ * test-flag-nobits.c: New test.
+ * run-test-flag-nobits.sh: And its wrapper.
+ * Makefile.am (noinst_PROGRAMS, TESTS): Add them.
+ (test_flag_nobits_LDADD): New variable.
+
+2010-02-15 Roland McGrath <roland@redhat.com>
+
+ * Makefile.am: Use config/eu.am for common stuff.
+
+ * asm-tst9.c (main): Rename local to avoid shadowing another local.
+
+2009-07-22 Roland McGrath <roland@redhat.com>
+
+ * addrcfi.c: Update dwarf_frame_{cfa,register} calling convention.
+
+2009-07-08 Roland McGrath <roland@redhat.com>
+
+ * addrcfi.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (addrcfi_LDADD): New variable.
+
+2009-05-07 Petr Machata <pmachata@redhat.com>
+
+ * testfile51.bz2: New data file.
+ * dwarf-getmacros.c: New test core.
+ * run-dwarf-getmacros.sh: New test wrapper.
+ * Makefile.am (TESTS, EXTRA_DIST, noinst_PROGRAMS): Add them.
+ (dwarf_getmacros_LDADD): New variable.
+
+2009-04-23 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile [BUILD_STATIC] (libdw): Add $(zip_LIBS).
+ (rdwrmmap_LDADD): Add $(libmudflap).
+
+2009-04-21 Roland McGrath <roland@redhat.com>
+
+ * testfile50.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+ * run-dwfl-addr-sect.sh: Add a case using it.
+
+2008-12-31 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: Add tests for dppd, dpps, insertps, movntdqa,
+ mpsadbw, packusdw, pblendvb, pblendw, pcmpeqq, pcmpestri, pcmpestrm,
+ pcmpistri, pcmpistrm, pcmpgtq, phminposuw, pinsrb, pinsrd, pmaxsb,
+ pmaxsd, pmaxud, pmaxuw, pminsb, pminsd, pminud, pminuw, pmovsxbw,
+ pmovsxbd, pmovsxbq, pmovsxwd, pmovsxwq, pmovsxdq, pmovsxbw, pmovsxbd,
+ pmovsxbq, pmovsxwd, pmovsxwq, pmovsxdq, pmuldq, pmulld, popcnt, ptest,
+ roundss, roundps, roundpd, and roundsd.
+ * testfile45.S.bz2: Likewise.
+ * testfile44.expect.bz2: Adjust accordingly.
+ * testfile45.expect.bz2: Likewise.
+
+ * testfile44.S.bz2: Add tests for blendvpd and blendvps.
+ * testfile45.S.bz2: Likewise.
+ * testfile44.expect.bz2: Adjust accordingly.
+ * testfile45.expect.bz2: Likewise.
+
+2008-12-30 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: Add tests for blendpd and blendps.
+ * testfile45.S.bz2: Likewise.
+ * testfile44.expect.bz2: Adjust accordingly.
+ * testfile45.expect.bz2: Likewise.
+
+2008-12-19 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: Add tests for AMD 3DNOW.
+ * testfile45.S.bz2: Likewise.
+ * testfile44.expect.bz2: Adjust accordingly.
+ * testfile45.expect.bz2: Likewise.
+
+2008-11-26 Roland McGrath <roland@redhat.com>
+
+ * dwfl-bug-getmodules.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (dwfl_bug_getmodules_LDADD): New variable.
+
+2008-09-10 Roland McGrath <roland@redhat.com>
+
+ * test-subr.sh (LC_ALL): Export it set to "C".
+ * run-dwfl-addr-sect.sh: Don't do it here.
+ * run-strings-test.sh: Likewise.
+
+2008-08-21 Denys Vlasenko <dvlasenk@redhat.com>
+
+ * run-addrname-test.sh: Add a new case.
+ * testfile49.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+
+2008-04-10 Roland McGrath <roland@redhat.com>
+
+ * testfile48.bz2, testfile48.bz2.debug: New data files.
+ * Makefile.am (EXTRA_DIST): Add them.
+ * run-strip-test8.sh: Use them.
+
+ * testfile16.bz2, testfile16.debug.bz2: Replace data files.
+
+ * run-strip-test.sh: Fail if stripped output has ".debug_*" sections.
+ * run-strip-test8.sh: New file.
+ * testfile47.bz2: New data file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add them.
+
+2008-03-31 Roland McGrath <roland@redhat.com>
+
+ * run-early-offscn.sh: New file.
+ * early-offscn.c: New file.
+ * Makefile.am (noinst_PROGRAMS, TESTS, EXTRA_DIST): Add them.
+ (early_offscn_LDADD): New variable.
+
+2008-03-19 Roland McGrath <roland@redhat.com>
+
+ * run-addrname-test.sh: Add a new case.
+
+2008-02-22 Roland McGrath <roland@redhat.com>
+
+ * run-elflint-test.sh: Typo fix.
+
+2008-02-21 Roland McGrath <roland@redhat.com>
+
+ * run-disasm-x86.sh: Use uname instead of arch, keep tools required
+ for the build down to minimum.
+ * run-disasm-x86-64.sh: Likewise.
+
+2008-02-20 Roland McGrath <roland@redhat.com>
+
+ * testfile46.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+ * run-elflint-test.sh: Test on it.
+
+2008-02-01 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am: Hook up sha1-tst.c.
+ * sha1-tst.c: New file.
+
+2008-01-21 Roland McGrath <roland@redhat.com>
+
+ * testfile45.S.bz2: Add tests for cltq, cqto.
+ * testfile45.expect.bz2: Adjust.
+
+2008-01-14 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile45.S.bz2: Add more tests.
+ * testfile45.expect.bz2: Adjust.
+
+2008-01-11 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile45.expect.bz2: Adjust for adding of address for %rip based
+ address mode.
+
+2008-01-10 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile45.S.bz2: Add more tests.
+ * testfile45.expect.bz2: Adjust.
+
+2008-01-08 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am (TESTS): Add run-disasm-x86-64.sh.
+ (EXTRA): Add testfile45.S.bz2, testfile45.expect.bz2,
+ run-disasm-x86-64.sh.
+ * run-disasm-x86-64.sh: New file.
+ * testfile45.S.bz2: New file.
+ * testfile45.expect.bz2: New file.
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2008-01-04 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2008-01-04 Roland McGrath <roland@redhat.com>
+
+ * dwfl-bug-fd-leak.c (main): Add a cast.
+
+2008-01-03 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2008-01-01 Ulrich Drepper <drepper@redhat.com>
+
+ * line2addr.c: Use %m modifier instead of %a to appease gcc.
+
+2008-01-01 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2007-12-31 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2007-12-30 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2007-12-29 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.s.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2007-12-28 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2007-12-27 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust.
+
+2007-12-26 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: New tests.
+ * testfile44.expect.bz2: Adjust
+
+2007-12-21 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile44.S.bz2: More tests.
+ * testfile44.expect.bz2: Adjust appropriately.
+
+2007-12-19 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am (TESTS): Add run-disasm.sh.
+ (EXTRA_DIST): Add run-disasm.sh, testfile44.S.bz2, and
+ testfile44.expect.bz2.
+ * run-disasm.sh: New file.
+ * testfile44.S.bz2: New file.
+ * testfile44.expect.bz2: New file.
+
+2007-12-15 Roland McGrath <roland@redhat.com>
+
+ * run-allregs.sh: Change expected output for powerpc spefscr.
+
+2007-10-20 Roland McGrath <roland@redhat.com>
+
+ * run-dwfl-addr-sect.sh: Change expected output, no errors.
+
+2007-10-19 Roland McGrath <roland@redhat.com>
+
+ * dwfl-addr-sect.c (handle_address): Return int.
+ Don't exit on error, just return nonzero.
+ (main): Collect results.
+ * run-dwfl-addr-sect.sh: New file.
+ * testfile43.bz2: New data file.
+ * Makefile.am (EXTRA_DIST, TESTS): Add them.
+
+2007-10-18 Roland McGrath <roland@redhat.com>
+
+ * run-allregs.sh: Update expected ppc output for vrsave/vscr.
+
+2007-10-16 Roland McGrath <roland@redhat.com>
+
+ * test-subr.sh (remove_files): Don't pass -Bb to diff.
+
+2007-10-09 Roland McGrath <roland@redhat.com>
+
+ * dwflmodtest.c (print_module): Don't use %p in output.
+ * run-dwfl-bug-offline-rel.sh: Updated expected output.
+
+2007-10-08 Roland McGrath <roland@redhat.com>
+
+ * testfile42.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+ * run-elflint-test.sh: New test on that file.
+
+2007-10-04 Roland McGrath <roland@redhat.com>
+
+ * run-readelf-test4.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
+2007-10-03 Roland McGrath <roland@redhat.com>
+
+ * run-readelf-test3.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
+2007-10-01 Roland McGrath <roland@redhat.com>
+
+ * run-readelf-test2.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
+2007-09-11 Roland McGrath <roland@redhat.com>
+
+ * run-addrname-test.sh: Add a new case.
+ * testfile41.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+
+2007-08-23 Roland McGrath <roland@redhat.com>
+
+ * run-allregs.sh: Update expected x86-64 output for %rflags.
+
+2007-08-12 Roland McGrath <roland@redhat.com>
+
+ * run-strip-test7.sh: New file.
+ * testfile39.bz2: New data file.
+ * testfile40.bz2: New data file.
+ * testfile40.debug.bz2: New data file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add them.
+
+2007-08-09 Roland McGrath <roland@redhat.com>
+
+ * dwfl-bug-report.c: Fix header inclusion.
+
+2007-08-08 Roland McGrath <roland@redhat.com>
+
+ * run-addrname-test.sh: Add a new case using addr2line -S.
+ * testfile38.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+
+2007-07-16 Roland McGrath <roland@redhat.com>
+
+ * dwfl-bug-report.c: New file.
+ * Makefile.am (noinst_PROGRAMS, TESTS): Add it.
+ (dwfl_bug_report_LDADD): New variable.
+
+2007-06-06 Roland McGrath <roland@redhat.com>
+
+ * run-unstrip-test.sh: Declare testfile.unstrip for removal.
+
+2007-06-05 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add missing line continuation and
+ testfile37.bz and testfile37.debug.bz2.
+
+2007-05-23 Roland McGrath <roland@redhat.com>
+
+ * run-allregs.sh: Update expected Alpha results.
+
+2007-05-18 Roland McGrath <roland@redhat.com>
+
+ * run-strip-test4.sh (stripped, debugfile): Use new reference files.
+ * testfile37.bz2: New data file.
+ * testfile37.debug.bz2: New data file.
+ * run-unstrip-test2.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add them.
+
+2007-05-10 Roland McGrath <roland@redhat.com>
+
+ * run-dwfl-bug-offline-rel.sh: New file.
+ * testfile36.bz2: New data file.
+ * testfile36.debug.bz2: New data file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add them.
+
+2007-04-28 Roland McGrath <roland@redhat.com>
+
+ * run-strip-test6.sh (stripped, debugfile): Use new reference files.
+ * testfile35.bz2: New data file.
+ * testfile35.debug.bz2: New data file.
+ * run-unstrip-test.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add them.
+
+ * run-strip-test.sh: Do all elflint and cmp runs even when some fail.
+
+2007-04-26 Roland McGrath <roland@redhat.com>
+
+ * run-elflint-self.sh: Run all tests even if one fails.
+
+ * run-allregs.sh: Add expected output for alpha.
+
+2007-04-24 Roland McGrath <roland@redhat.com>
+
+ * run-strip-test.sh: When we saved the debug info, test unstrip too.
+
+2007-04-22 Roland McGrath <roland@redhat.com>
+
+ * run-allregs.sh: Update expected register info.
+
+2007-04-16 Roland McGrath <roland@redhat.com>
+
+ * dwfl-addr-sect.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (dwfl_addr_sect_LDADD): New variable.
+
+2007-04-05 Roland McGrath <roland@redhat.com>
+
+ * get-files.c: Test dwarf_getsrcdirs.
+ * run-get-files.sh: Update expected output.
+
+2007-04-01 Roland McGrath <roland@redhat.com>
+
+ * run-allregs.sh: Updated expected output for x86_64.
+
+2007-03-04 Roland McGrath <roland@redhat.com>
+
+ * dwfl-bug-fd-leak.c: New file.
+ * Makefile.am (noinst_PROGRAMS, TESTS): Add it.
+ (dwfl_bug_fd_leak_LDADD): New variable.
+
+ * dwflmodtest.c: Test dwfl_getmodules before and after getdwarf,
+ show what files have been located.
+
+2007-02-02 Roland McGrath <roland@redhat.com>
+
+ * run-addrname-test.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+ * testfile34.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+
+2007-01-20 Roland McGrath <roland@redhat.com>
+
+ * testfile33.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+ * run-elflint-test.sh: Test on it too.
+
+2007-01-18 Roland McGrath <roland@redhat.com>
+
+ * Makefile.am (CFLAGS): Don't molest it.
+
+2007-01-11 Roland McGrath <roland@redhat.com>
+
+ * testfile32.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+ * run-elflint-test.sh: Test on it too.
+
+2007-02-04 Ulrich Drepper <drepper@redhat.com>
+
+ * arls.c: New file.
+ * Makefile (noinst_PROGRAMS): Add arls.
+
+ * run-ranlib-test2.sh: Fix type in comment.
+
+2007-01-10 Ulrich Drepper <drepper@redhat.com>
+
+ * run-elflint-self.sh (runtest): Show which file has the problem.
+
+2007-01-10 Roland McGrath <roland@redhat.com>
+
+ * dwfl-bug-addr-overflow.c: New file.
+ * Makefile.am (TESTS): Add it.
+ (dwfl_bug_addr_overflow_LDADD): New variable.
+
+2006-12-17 Roland McGrath <roland@redhat.com>
+
+ * msg_tst.c (libelf_msgs): Fix ELF_E_INVALID_PHDR msg.
+
+2006-09-05 Roland McGrath <roland@redhat.com>
+
+ * run-strings-test.sh: Export LC_ALL=C for the test.
+
+2006-08-29 Roland McGrath <roland@redhat.com>
+
+ * run-arextract.sh: Use testrun, tempfiles functions from test-subr.sh.
+ * run-arsymtest.sh: Likewise.
+
+ * run-native-test.sh (native.c compilation): Add some braces.
+
+2006-08-22 Roland McGrath <roland@redhat.com>
+
+ * allregs.c (dwarf_encoding_string): New function, swiped from readelf.
+ (struct reginfo): New members bits, type.
+ (one_register, match_register): Update to take new args,
+ record and display new info.
+ (main): Display new info.
+ * run-allregs.sh: Update expected results.
+
+2006-08-03 Roland McGrath <roland@redhat.com>
+
+ * run-allregs.sh: Add sparc cases.
+ * testfile30.bz2: New data file.
+ * testfile31.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add them.
+
+2006-07-21 Roland McGrath <roland@redhat.com>
+
+ * allregs.c (struct reginfo): Increase size of name.
+ (one_register): Assert that it's big enough.
+
+2006-04-04 Roland McGrath <roland@redhat.com>
+
+ * run-bug1-test.sh: Test a second case, to cover both byte orders.
+ * testfile29.bz2: New file.
+ * testfile29.rdwr.bz2: New file.
+ * Makefile.am (EXTRA_DIST): Add them.
+
+2006-04-04 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am: Add rules to run run-bug1-test.sh.
+ * rdwrmmap.c: New file.
+ * run-bug1-test.sh: New file.
+ * testfile28.bz2: New file.
+ * testfile28.rdwr.bz2: New file.
+
+2006-03-09 Roland McGrath <roland@redhat.com>
+
+ * Makefile.am (AM_LDFLAGS): Define to pass -rpath-link.
+
+2006-03-01 Roland McGrath <roland@redhat.com>
+
+ * show-die-info.c (tagnames, attrs): Update name tables for dwarf.h
+ changes matching 3.0 spec.
+
+2006-01-13 Roland McGrath <roland@redhat.com>
+
+ * run-native-test.sh: Do kill -9 and reap explicitly at end, since
+ bash 3.1 whines when it's done in the trap 0 handler.
+
+2006-01-11 Roland McGrath <roland@redhat.com>
+
+ * testfile26.bz2: New data file.
+ * testfile27.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add them.
+ * run-allregs.sh: Test s390 data.
+
+2005-12-14 Roland McGrath <roland@redhat.com>
+
+ * run-native-test.sh: Redirect output from native test process.
+
+2005-12-13 Roland McGrath <roland@redhat.com>
+
+ * allregs.c (main): Fail if we find no registers.
+
+ * run-native-test.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
+2005-12-10 Ulrich Drepper <drepper@redhat.com
+
+ * run-readelf-test1.sh: New file.
+ * Makefile.am (TESTS): Add run-readelf-test1.sh.
+ (EXTRA_DIST): Likewise.
+
+2005-12-07 Roland McGrath <roland@redhat.com>
+
+ * ecp.c (main): Use elf_end to clean up.
+
+2005-11-25 Roland McGrath <roland@redhat.com>
+
+ * coverage.sh: Given -v argument, print names of unused files.
+
+ * addrscopes.c (main): Use dwfl_end before return.
+ * allregs.c (main): Likewise.
+ * find-prologues.c (main): Likewise.
+ * funcretval.c (main): Likewise.
+ * funcscopes.c (main): Likewise.
+ * line2addr.c (main): Likewise.
+
+ * run-allregs.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
+ * allregs.c: Use libdwfl wrapper instead of direct libebl calls.
+ * Makefile.am (allregs_LDADD): Updated.
+
+ * allregs.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (allregs_LDADD): New variable.
+
+2005-11-18 Roland McGrath <roland@redhat.com>
+
+ * test-subr.sh (installed_testrun): Treat /usr/lib64 like /usr/lib.
+ * test-wrapper.sh: Likewise.
+
+2005-11-17 Roland McGrath <roland@redhat.com>
+
+ * Makefile.am (installed_TESTS_ENVIRONMENT): Set libdir, bindir in
+ environment for test-wrapper.sh.
+ * test-wrapper.sh: Set LD_LIBRARY_PATH from ${libdir} if not /usr/lib.
+ * test-subr.sh (installed_testrun): Likewise.
+ Use explicit path in ${bindir}.
+
+ * Makefile.am (installcheck-local): Fix typo in last change.
+
+2005-11-16 Roland McGrath <roland@redhat.com>
+
+ * configure.ac: New file, for standalone build/dist of test suite.
+ * Makefile.am [!STANDALONE] (INCLUDES): Don't define it.
+ (asm_TESTS): New variable, broken out of ...
+ (TESTS): ... here. Also remove msg_tst.
+ [!STANDALONE] (TESTS, noinst_PROGRAMS): Add in $(asm_TESTS), msg_tst.
+ (installed_TESTS_ENVIRONMENT): New variable.
+ [STANDALONE] (TESTS_ENVIRONMENT): Use that.
+ [!STANDALONE] (installcheck-local): Likewise.
+ [STANDALONE] (libdw, libelf, libasm, libebl): Define using -lfoo.
+ * addrscopes.c: Include <config.h>.
+ Use ELFUTILS_HEADER macro in #include of installed elfutils/ headers.
+ * allfcts.c: Likewise.
+ * asm-tst1.c: Likewise.
+ * asm-tst2.c: Likewise.
+ * asm-tst3.c: Likewise.
+ * asm-tst4.c: Likewise.
+ * asm-tst5.c: Likewise.
+ * asm-tst6.c: Likewise.
+ * asm-tst7.c: Likewise.
+ * asm-tst8.c: Likewise.
+ * asm-tst9.c: Likewise.
+ * dwflmodtest.c: Likewise.
+ * find-prologues.c: Likewise.
+ * funcscopes.c: Likewise.
+ * get-aranges.c: Likewise.
+ * get-files.c: Likewise.
+ * get-lines.c: Likewise.
+ * get-pubnames.c: Likewise.
+ * line2addr.c: Likewise.
+ * newscn.c: Likewise.
+ * show-abbrev.c: Likewise.
+ * show-die-info.c: Likewise.
+ * update3.c: Likewise.
+ * update4.c: Likewise.
+ * funcretval.c: Likewise.
+
+ * dwflmodtest.c (print_instance): Don't use INTUSE.
+ (options): Don't use N_ macro.
+
+2005-11-15 Roland McGrath <roland@redhat.com>
+
+ * coverage.sh: Look in backends.
+ * Makefile.am (BUILD_RPATH): Search ../backends, not ../libebl.
+ (TESTS_ENVIRONMENT): Likewise.
+
+ * funcretval.c (handle_function): Don't take DW_AT_type of FUNCDIE,
+ pass FUNCDIE direclty to dwfl_module_return_value_location.
+
+ * Makefile.am (BUILD_RPATH): New variable.
+ [TESTS_RPATH] (AM_LDFLAGS): Pass -rpath option using that value.
+ (tests_rpath): New variable.
+ (installcheck-local): Pass it to test-wrapper.sh.
+ * test-wrapper.sh: In "installed" format, take yes/no value
+ for elfutils_tests_rpath, which export. When running a test
+ binary for installcheck, exit 77.
+ * test-subr.sh (installed_testrun): When running a test binary
+ for installcheck, exit 77 if $elfutils_tests_rpath = yes.
+
+2005-11-14 Roland McGrath <roland@redhat.com>
+
+ * test-subr.sh: New file.
+ * test-wrapper.sh: New file.
+ * Makefile.am (EXTRA_DIST): Add them.
+ (AM_LDFLAGS): Variable removed.
+ (TESTS_ENVIRONMENT): New variable.
+ (installcheck-local): New target.
+ * run-addrscopes.sh: Use test-subr.sh.
+ * run-allfcts.sh: Likewise.
+ * run-ecp-test.sh: Likewise.
+ * run-ecp-test2.sh: Likewise.
+ * run-elflint-self.sh: Likewise.
+ * run-elflint-test.sh: Likewise.
+ * run-find-prologues.sh: Likewise.
+ * run-funcscopes.sh: Likewise.
+ * run-get-aranges.sh: Likewise.
+ * run-get-files.sh: Likewise.
+ * run-get-lines.sh: Likewise.
+ * run-get-pubnames.sh: Likewise.
+ * run-line2addr.sh: Likewise.
+ * run-ranlib-test.sh: Likewise.
+ * run-ranlib-test2.sh: Likewise.
+ * run-show-abbrev.sh: Likewise.
+ * run-show-ciefde.sh: Likewise.
+ * run-show-die-info.sh: Likewise.
+ * run-strings-test.sh: Likewise.
+ * run-strip-test.sh: Likewise.
+
+2005-11-13 Roland McGrath <roland@redhat.com>
+
+ * funcretval.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (funcretval_LDADD): New variable.
+
+2005-11-09 Ulrich Drepper <drepper@redhat.com>
+
+ * line2addr.c (handle_module): Add missing parameter to printf.
+
+2005-10-27 Roland McGrath <roland@redhat.com>
+
+ * allfcts.c (cb): Update for dwarf_func_* -> dwarf_decl_* changes.
+ * funcscopes.c (handle_function): Likewise.
+ * dwflmodtest.c (print_inline, print_func): Likewise.
+ * find-prologues.c (handle_function): Likewise.
+
+2005-10-27 Roland McGrath <roland@redhat.com>
+
+ * run-find-prologues.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
+ * find-prologues.c (handle_function): Skip inlines.
+
+2005-10-25 Roland McGrath <roland@redhat.com>
+
+ * find-prologues.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (find_prologues_LDADD): New variable.
+
+2005-09-02 Ulrich Drepper <drepper@redhat.com>
+
+ * run-strings-test.sh: Remove strings.out in the end.
+
+2005-08-31 Ulrich Drepper <drepper@redhat.com>
+
+ * run-addrscopes.sh: Use correct exit code if test cannot be performed.
+ * run-allfcts.sh: Likewise.
+ * run-ecp-test.sh: Likewise.
+ * run-ecp-test2.sh: Likewise.
+ * run-elflint-test.sh: Likewise.
+ * run-funcscopes.sh: Likewise.
+ * run-get-aranges.sh: Likewise.
+ * run-get-files.sh: Likewise.
+ * run-get-lines.sh: Likewise.
+ * run-get-pubnames.sh: Likewise.
+ * run-line2addr.sh: Likewise.
+ * run-ranlib-test2.sh: Likewise.
+ * run-show-abbrev.sh: Likewise.
+ * run-show-ciefde.sh: Likewise.
+ * run-show-die-info.sh: Likewise.
+ * run-strings-test.sh: Likewise.
+ * run-strip-test.sh: Likewise.
+
+2005-08-30 Ulrich Drepper <drepper@redhat.com>
+
+ * coverage.sh: Handle case where there is no .gcno file at all.
+
+2005-08-29 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add coverage.
+ [GCOV]: Generate coverage summary after the tests ran
+ * coverage.sh: New file.
+
+2005-08-28 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.an [BUILD_STATIC] (libdw): Add -ldl.
+ (CLEANFILES): Add *.gcno *.gcda *.gconv.
+
+2005-08-28 Ulrich Drepper <drepper@redhat.com>
+
+ * run-strings-test.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
+2005-08-27 Roland McGrath <roland@redhat.com>
+
+ * addrscopes.c (handle_address): Apply bias to PC addresses.
+
+ * run-funcscopes.sh: New file.
+ * testfile25.bz2: New data file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add them.
+
+2005-08-26 Roland McGrath <roland@redhat.com>
+
+ * addrscopes.c (dwarf_diename_integrate): Removed.
+ (print_vars, handle_address): Use plain dwarf_diename.
+
+2005-08-25 Roland McGrath <roland@redhat.com>
+
+ * funcscopes.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (funcscopes_LDADD): New variable.
+
+ * run-addrscopes.sh: Add another case.
+ * testfile24.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+
+ * addrscopes.c (handle_address): Take new argument IGNORE_INLINES,
+ pass it to dwarf_getscopes.
+ (main): Pass it, true when '=' follows an address.
+
+2005-08-24 Roland McGrath <roland@redhat.com>
+
+ * line2addr.c (print_address): Omit () for DSOs.
+
+2005-08-24 Ulrich Drepper <drepper@redhat.com>
+
+ * run-line2addr.sh: Remove testfile23 in the end.
+
+ * Makefile.am [BUILD_STATIC] (libdw): Add $(libelf) and $(libebl).
+ [MUDFLAP] (AM_LDFLAGS): Define to find libebl modules.
+
+2005-08-22 Roland McGrath <roland@redhat.com>
+
+ * run-line2addr.sh: Add a case.
+ * testfile23.bz2: New data file.
+ * Makefile.am (EXTRA_DIST): Add it.
+
+2005-08-18 Roland McGrath <roland@redhat.com>
+
+ * run-addrscopes.sh: New file.
+ * testfile22.bz2: New data file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add them.
+
+ * addrscopes.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (addrscopes_LDADD): New variable.
+
+2005-08-15 Ulrich Drepper <drepper@redhat.com>
+
+ * run-elflint-self.sh: Don't run test if the file doesn't exist.
+
+2005-08-15 Roland McGrath <roland@redhat.com>
+
+ * dwflmodtest.c (print_instance, print_inline): New functions.
+ (print_func): Call print_inline.
+ (options, parse_opt): Grok -i/--inlines.
+
+2005-08-07 Roland McGrath <roland@redhat.com>
+
+ * dwflmodtest.c: Print function details only if -f flag is given.
+
+2005-08-06 Ulrich Drepper <drepper@redhat.com>
+
+ * run-elflint-self.sh: New file.
+ * Makefile.am (TESTS): Add run-elflint-self.sh.
+ (EXTRA_DIST): Likewise.
+
+ * Makefile.am: Link with statis libs if BUILD_STATIC.
+ (dwflmodtest_LDADD): Also link with -ldl.
+
+2005-08-02 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am: Add -ldl to asm_tst[1-9]_LDASS.
+ * asm-tst1.c: Adjust for new asm_begin interface. Open backend
+ library first.
+ * asm-tst2.c: Likewise.
+ * asm-tst3.c: Likewise.
+ * asm-tst4.c: Likewise.
+ * asm-tst5.c: Likewise.
+ * asm-tst6.c: Likewise.
+ * asm-tst7.c: Likewise.
+ * asm-tst8.c: Likewise.
+ * asm-tst9.c: Likewise.
+
+ * msg_tst.c: Add new error message.
+
+2005-07-28 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am (dwflmodtest_LDADD): Add $(libebl).
+
+2005-06-01 Roland McGrath <roland@redhat.com>
+
+ * line2addr.c: Rewritten using libdwfl.
+ * run-line2addr.sh: Update test for changed arguments.
+ * Makefile.am (INCLUDES): Add libdwfl source directory to path.
+ (libdwfl): New variable.
+ (line2addr_LDADD): Use it.
+
+2005-07-28 Roland McGrath <roland@redhat.com>
+
+ * dwflmodtest.c: New file, moved from ../libdwfl/ptest.c to here.
+ * Makefile.am (noinst_PROGRAMS): Add dwflmodtest.
+ (dwflmodtest_LDADD): New variable.
+ (INCLUDES): Add -I$(top_srcdir)/libdwfl here.
+
+2005-07-21 Ulrich Drepper <drepper@redhat.com>
+
+ * testfile18.bz2: New file.
+ * run-elflint-test.sh: New file.
+ * Makefile.am (TESTS): Add run-elflint-test.sh.
+ (EXTRA_DIST): Add run-elflint-test.sh and testfile18.bz2.
+
+2005-05-24 Ulrich Drepper <drepper@redhat.com>
+
+ * get-files.c (main): Use correct format specifier.
+
+2005-05-21 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am: Add -Wextra to CFLAGS.
+ * get-files.c: Remove warning this produced.
+ * get-pubnames.c: Likewise.
+ * newfile.c: Likewise.
+ * newscn.c: Likewise.
+ * scnnames.c: Likewise.
+ * showptable.c: Likewise.
+ * test-nlist.c: Likewise.
+ * update1.c: Likewise.
+ * update2.c: Likewise.
+ * update3.c: Likewise.
+ * update4.c: Likewise.
+
+2005-05-08 Ulrich Drepper <drepper@redhat.com>
+
+ * run-line2addr.sh: Remove testfile14 at the end.
+
+ * run-strip-test.sh: Remove debuginfo test input file as well.
+
+ * Makefile.am (EXTRA_DIST): Newly added files incorrectly used
+ .bz, not .bz2.
+
+2005-05-03 Roland McGrath <roland@redhat.com>
+
+ * run-strip-test.sh: Use variables for test file names.
+ Optionally produce separate debug file and check it.
+ * run-strip-test2.sh: Use run-strip-test.sh via ., no duplication.
+ * run-strip-test3.sh: Likewise.
+ * run-strip-test4.sh: New file.
+ * run-strip-test5.sh: New file.
+ * run-strip-test6.sh: New file.
+ * testfile15.bz: New file.
+ * testfile15.debug.bz: New file.
+ * testfile16.bz: New file.
+ * testfile16.debug.bz: New file.
+ * testfile17.bz: New file.
+ * testfile17.debug.bz: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add them.
+
+2005-04-25 Ulrich Drepper <drepper@redhat.com>
+
+ * run-line2addr.sh: Also use testfile14. Adjust for correct
+ return of multiple matches.
+ * testfile14.bz2: New file.
+ * Makefile.am (EXTRA_DIST): Add testfile14.bz2.
+
+ * show-abbrev.c (main): Adjust for dwarf_getabbrev interface change.
+
+2005-04-04 Roland McGrath <roland@redhat.com>
+
+ * line2addr.c (main): Initialize LINES and NLINES before calling
+ dwarf_getsrc_file, and free LINES afterwards.
+
+ * allfcts.c (main): Use size_t for CUHL.
+
+2005-04-04 Ulrich Drepper <drepper@redhat.com>
+
+ * line2addr.c: New file.
+ * run-line2addr.sh: New file.
+ * Makefile.am: Add rules to build, run, and distribute new code.
+
+2005-04-02 Ulrich Drepper <drepper@redhat.com>
+
+ * allfcts.c: New file.
+ * run-allfcts.sh: New file.
+ * Makefile.am: Add rules to build, run, and distribute new code.
+
+2005-02-05 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am [MUDFLAP] (AM_CFLAGS): Add -fmudflap. Link all test
+ programs with -lmudflap.
+
+2004-09-25 Ulrich Drepper <drepper@redhat.com>
+
+ * asm-tst4.c (main): Add LD_LIBRARY_PATH to elflint invocation.
+ * asm-tst5.c (main): Likewise.
+ * asm-tst6.c (main): Likewise.
+
+2004-01-17 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am: Support building with mudflap.
+
+2004-01-12 Ulrich Drepper <drepper@redhat.com>
+
+ * get-aranges.c: Rewrite to use libdw.
+ * Makefile.am: Reenable get-aranges test.
+
+2004-01-11 Ulrich Drepper <drepper@redhat.com>
+
+ * get-lines.c: New file.
+ * get-files.c: Adjust for libdw.
+ * run-get-files.sh: Adjust expected result.
+ * run-get-lines.sh: Likewise.
+ * Makefile.am: Run get-lines test. Don't run get-aranges and
+ get-ciefde test for now.
+
+ * show-abbrev.c: Adjust call to dwarf_getabbrevattr after interface
+ change. Print attribute offset information.
+ * run-show-abbrev.sh: Adjust expected output.
+
+2004-01-09 Ulrich Drepper <drepper@redhat.com>
+
+ * show-abbrev.c: Adjust call to dwarf_nextcu after interface change.
+ * show-die-info.c: Likewise.
+ * run-show-die-info.sh: Adjust expected output.
+
+2003-08-13 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.in: Depend on libebl.a, not libebl.so.
+
+2003-08-11 Ulrich Drepper <drepper@redhat.com>
+
+ * Moved to CVS archive.
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..1fce447
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,527 @@
+## Process this file with automake to create Makefile.in
+##
+## Copyright (C) 1996-2017 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/>.
+##
+include $(top_srcdir)/config/eu.am
+BUILD_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf
+
+AM_LDFLAGS =
+
+if !STANDALONE
+AM_CPPFLAGS += -I$(top_srcdir)/libasm -I$(top_srcdir)/libdw \
+ -I$(top_srcdir)/libdwfl -I$(top_srcdir)/libdwelf \
+ -I$(top_srcdir)/libebl -I$(top_srcdir)/libelf \
+ -I$(top_srcdir)/lib -I..
+AM_LDFLAGS += -Wl,-rpath-link,../libasm:../libdw:../libelf
+endif
+
+if TESTS_RPATH
+AM_LDFLAGS += -Wl,-rpath,$(BUILD_RPATH)
+tests_rpath = yes
+else
+tests_rpath = no
+endif
+
+check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
+ showptable update1 update2 update3 update4 test-nlist \
+ show-die-info get-files get-lines get-pubnames \
+ get-aranges allfcts line2addr addrscopes funcscopes \
+ show-abbrev hash newscn ecp dwflmodtest \
+ find-prologues funcretval allregs rdwrmmap \
+ dwfl-bug-addr-overflow arls dwfl-bug-fd-leak \
+ dwfl-addr-sect dwfl-bug-report early-offscn \
+ dwfl-bug-getmodules dwarf-getmacros dwarf-ranges addrcfi \
+ test-flag-nobits dwarf-getstring rerequest_tag \
+ alldts typeiter typeiter2 low_high_pc \
+ test-elf_cntl_gelf_getshdr dwflsyms dwfllines \
+ dwfl-report-elf-align varlocs backtrace backtrace-child \
+ backtrace-data backtrace-dwarf debuglink debugaltlink \
+ buildid deleted deleted-lib.so aggregate_size peel_type \
+ vdsosyms \
+ getsrc_die strptr newdata elfstrtab dwfl-proc-attach \
+ elfshphehdr elfstrmerge dwelfgnucompressed elfgetchdr \
+ elfgetzdata elfputzdata zstrptr emptyfile vendorelf \
+ fillfile dwarf_default_lower_bound
+
+asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
+ asm-tst6 asm-tst7 asm-tst8 asm-tst9
+
+if BIARCH
+check_PROGRAMS += backtrace-child-biarch
+endif
+
+# Substitute $(COMPILE).
+backtrace-child-biarch$(EXEEXT): backtrace-child.c
+ $(AM_V_CC)$(CC_BIARCH) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS) $(backtrace_child_CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) $(backtrace_child_LDFLAGS) \
+ -o $@ $<
+
+TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
+ update1 update2 update3 update4 \
+ run-show-die-info.sh run-get-files.sh run-get-lines.sh \
+ run-get-pubnames.sh run-get-aranges.sh run-allfcts.sh \
+ run-show-abbrev.sh run-line2addr.sh hash \
+ newscn run-strip-test.sh run-strip-test2.sh \
+ run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \
+ run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \
+ run-strip-test9.sh run-strip-test10.sh run-strip-test11.sh \
+ run-strip-nothing.sh run-strip-g.sh \
+ run-strip-groups.sh run-strip-reloc.sh run-strip-strmerge.sh \
+ run-strip-nobitsalign.sh run-strip-remove-keep.sh \
+ run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-test3.sh \
+ run-unstrip-test4.sh run-unstrip-M.sh run-elfstrmerge-test.sh \
+ run-ecp-test.sh run-ecp-test2.sh run-alldts.sh \
+ run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \
+ run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
+ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
+ run-find-prologues.sh run-allregs.sh run-addrcfi.sh \
+ run-nm-self.sh run-readelf-self.sh \
+ run-varlocs-self.sh run-exprlocs-self.sh \
+ run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \
+ run-readelf-test4.sh run-readelf-twofiles.sh \
+ run-readelf-macro.sh run-readelf-loc.sh \
+ run-readelf-aranges.sh run-readelf-line.sh run-readelf-z.sh \
+ run-native-test.sh run-bug1-test.sh \
+ run-debuglink.sh run-debugaltlink.sh run-buildid.sh \
+ dwfl-bug-addr-overflow run-addrname-test.sh \
+ dwfl-bug-fd-leak dwfl-bug-report \
+ run-dwfl-bug-offline-rel.sh run-dwfl-addr-sect.sh \
+ run-disasm-x86.sh run-disasm-x86-64.sh \
+ run-early-offscn.sh run-dwarf-getmacros.sh run-dwarf-ranges.sh \
+ run-test-flag-nobits.sh run-prelink-addr-test.sh \
+ run-dwarf-getstring.sh run-rerequest_tag.sh run-typeiter.sh \
+ run-readelf-d.sh run-readelf-gdb_index.sh run-unstrip-n.sh \
+ run-low_high_pc.sh run-macro-test.sh run-elf_cntl_gelf_getshdr.sh \
+ run-test-archive64.sh run-readelf-vmcoreinfo.sh \
+ run-readelf-mixed-corenote.sh run-dwfllines.sh \
+ run-readelf-variant.sh \
+ run-dwfl-report-elf-align.sh run-addr2line-test.sh \
+ run-addr2line-i-test.sh run-addr2line-i-lex-test.sh \
+ run-addr2line-i-demangle-test.sh run-addr2line-alt-debugpath.sh \
+ run-varlocs.sh run-exprlocs.sh run-funcretval.sh \
+ run-backtrace-native.sh run-backtrace-data.sh run-backtrace-dwarf.sh \
+ run-backtrace-native-biarch.sh run-backtrace-native-core.sh \
+ run-backtrace-native-core-biarch.sh run-backtrace-core-x86_64.sh \
+ run-backtrace-fp-core-x86_64.sh \
+ run-backtrace-fp-core-aarch64.sh \
+ run-backtrace-fp-core-ppc64le.sh \
+ run-backtrace-core-x32.sh \
+ run-backtrace-core-i386.sh run-backtrace-fp-core-i386.sh \
+ run-backtrace-core-ppc.sh \
+ run-backtrace-core-s390x.sh run-backtrace-core-s390.sh \
+ run-backtrace-core-aarch64.sh run-backtrace-core-sparc.sh \
+ run-backtrace-demangle.sh run-stack-d-test.sh run-stack-i-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 run-peel-type.sh \
+ vdsosyms run-readelf-A.sh \
+ 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-compress-test.sh \
+ run-readelf-zdebug.sh run-readelf-zdebug-rel.sh \
+ emptyfile vendorelf fillfile dwarf_default_lower_bound
+
+if !BIARCH
+export ELFUTILS_DISABLE_BIARCH = 1
+endif
+
+if !DEMANGLE
+export ELFUTILS_DISABLE_DEMANGLE = 1
+endif
+
+if !STANDALONE
+check_PROGRAMS += msg_tst system-elf-libelf-test
+TESTS += msg_tst system-elf-libelf-test
+endif
+
+if LZMA
+TESTS += run-readelf-s.sh run-dwflsyms.sh
+endif
+
+if HAVE_LIBASM
+check_PROGRAMS += $(asm_TESTS)
+TESTS += $(asm_TESTS) run-disasm-bpf.sh
+endif
+
+EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
+ run-show-die-info.sh run-get-files.sh run-get-lines.sh \
+ run-get-pubnames.sh run-get-aranges.sh \
+ run-show-abbrev.sh run-strip-test.sh \
+ run-strip-test2.sh run-ecp-test.sh run-ecp-test2.sh \
+ testfile.bz2 testfile2.bz2 testfile3.bz2 testfile4.bz2 \
+ testfile5.bz2 testfile6.bz2 testfile7.bz2 testfile8.bz2 \
+ testfile9.bz2 testfile10.bz2 testfile11.bz2 testfile12.bz2 \
+ testfile13.bz2 run-strip-test3.sh run-allfcts.sh \
+ testfile_class_func.bz2 testfile_nested_funcs.bz2 \
+ run-line2addr.sh run-elflint-test.sh testfile14.bz2 \
+ run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \
+ run-strip-test7.sh run-strip-test8.sh run-strip-groups.sh \
+ run-strip-test9.sh run-strip-test10.sh run-strip-test11.sh \
+ run-strip-nothing.sh run-strip-remove-keep.sh run-strip-g.sh \
+ run-strip-strmerge.sh run-strip-nobitsalign.sh \
+ testfile-nobitsalign.bz2 testfile-nobitsalign.strip.bz2 \
+ run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \
+ hello_ppc64.ko.bz2 hello_s390.ko.bz2 hello_aarch64.ko.bz2 \
+ hello_m68k.ko.bz2 \
+ run-unstrip-test.sh run-unstrip-test2.sh \
+ testfile-info-link.bz2 testfile-info-link.debuginfo.bz2 \
+ testfile-info-link.stripped.bz2 run-unstrip-test3.sh \
+ run-unstrip-test4.sh testfile-strtab.bz2 \
+ testfile-strtab.stripped.bz2 testfile-strtab.debuginfo.bz2 \
+ run-unstrip-M.sh run-elfstrmerge-test.sh \
+ run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \
+ run-ranlib-test3.sh run-ranlib-test4.sh \
+ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
+ run-nm-self.sh run-readelf-self.sh run-addrcfi.sh \
+ run-varlocs-self.sh run-exprlocs-self.sh \
+ run-find-prologues.sh run-allregs.sh run-native-test.sh \
+ run-addrname-test.sh run-dwfl-bug-offline-rel.sh \
+ run-dwfl-addr-sect.sh run-early-offscn.sh \
+ run-dwarf-getmacros.sh \
+ run-dwarf-ranges.sh debug-ranges-no-lowpc.o.bz2 \
+ run-test-flag-nobits.sh \
+ run-dwarf-getstring.sh run-rerequest_tag.sh run-alldts.sh \
+ testfile15.bz2 testfile15.debug.bz2 \
+ testfile16.bz2 testfile16.debug.bz2 \
+ testfile17.bz2 testfile17.debug.bz2 \
+ testfile18.bz2 testfile19.bz2 testfile19.index.bz2 \
+ testfile20.bz2 testfile20.index.bz2 \
+ testfile21.bz2 testfile21.index.bz2 \
+ testfile22.bz2 testfile23.bz2 testfile24.bz2 testfile25.bz2 \
+ testfile26.bz2 testfile27.bz2 \
+ coverage.sh test-subr.sh test-wrapper.sh \
+ run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \
+ run-readelf-test4.sh run-readelf-twofiles.sh \
+ run-bug1-test.sh testfile28.bz2 testfile28.rdwr.bz2 \
+ run-debuglink.sh run-debugaltlink.sh run-buildid.sh \
+ testfile29.bz2 testfile29.rdwr.bz2 \
+ testfile30.bz2 testfile31.bz2 testfile32.bz2 testfile33.bz2 \
+ testfile34.bz2 testfile35.bz2 testfile35.debug.bz2 \
+ testfile36.bz2 testfile36.debug.bz2 \
+ testfile37.bz2 testfile37.debug.bz2 \
+ testfile38.bz2 testfile39.bz2 testfile40.bz2 testfile40.debug.bz2 \
+ testfile41.bz2 testfile42.bz2 testfile42_noshdrs.bz2 \
+ testfile43.bz2 \
+ testfile44.S.bz2 testfile44.expect.bz2 run-disasm-x86.sh \
+ testfile45.S.bz2 testfile45.expect.bz2 run-disasm-x86-64.sh \
+ testfile46.bz2 testfile47.bz2 testfile48.bz2 testfile48.debug.bz2 \
+ testfile49.bz2 testfile50.bz2 testfile51.bz2 \
+ testfile-macros-0xff.bz2 \
+ run-readelf-macro.sh testfilemacro.bz2 \
+ run-readelf-loc.sh testfileloc.bz2 \
+ run-readelf-aranges.sh run-readelf-line.sh testfilefoobarbaz.bz2 \
+ run-readelf-z.sh \
+ run-readelf-dwz-multi.sh libtestfile_multi_shared.so.bz2 \
+ testfile_multi.dwz.bz2 testfile_multi_main.bz2 \
+ testfile-dwzstr.bz2 testfile-dwzstr.multi.bz2 \
+ run-allfcts-multi.sh \
+ test-offset-loop.bz2 test-offset-loop.alt.bz2 \
+ run-prelink-addr-test.sh \
+ testfile52-32.so.bz2 testfile52-32.so.debug.bz2 \
+ testfile52-32.prelink.so.bz2 testfile52-32.noshdrs.so.bz2 \
+ testfile52-64.so.bz2 testfile52-64.so.debug.bz2 \
+ testfile52-64.prelink.so.bz2 testfile52-64.noshdrs.so.bz2 \
+ testfile53-32.bz2 testfile53-32.debug.bz2 \
+ testfile53-32.prelink.bz2 testfile53-64.bz2 \
+ testfile53-64.debug.bz2 testfile53-64.prelink.bz2 \
+ testfile54-32.so.bz2 testfile54-32.so.debug.bz2 \
+ testfile54-32.prelink.so.bz2 testfile54-32.noshdrs.so.bz2 \
+ testfile54-64.so.bz2 testfile54-64.so.debug.bz2 \
+ testfile54-64.prelink.so.bz2 testfile54-64.noshdrs.so.bz2 \
+ testfile55-32.bz2 testfile55-32.debug.bz2 \
+ testfile55-32.prelink.bz2 testfile55-64.bz2 \
+ testfile55-64.debug.bz2 testfile55-64.prelink.bz2 \
+ testfile56.bz2 testfile57.bz2 testfile58.bz2 \
+ run-typeiter.sh testfile59.bz2 \
+ run-readelf-d.sh testlib_dynseg.so.bz2 \
+ testfile-s390x-hash-both.bz2 \
+ run-readelf-gdb_index.sh testfilegdbindex5.bz2 \
+ testfilegdbindex7.bz2 \
+ run-readelf-s.sh testfilebazdbg.bz2 testfilebazdyn.bz2 \
+ testfilebazmin.bz2 testfilebazdbg.debug.bz2 testfilebazmdb.bz2 \
+ testfilebaztab.bz2 testfilebasmin.bz2 testfilebaxmin.bz2 \
+ testfilebazdbg_pl.bz2 testfilebazmin_pl.bz2 \
+ testfilebazdbg_plr.bz2 testfilebazmin_plr.bz2 \
+ testfilebazdbgppc64.bz2 testfilebazdbgppc64.debug.bz2 \
+ testfilebazdbgppc64_pl.bz2 testfilebazdbgppc64_plr.bz2 \
+ testfilebazdynppc64.bz2 testfilebazmdbppc64.bz2 \
+ testfilebazminppc64.bz2 testfilebazminppc64_pl.bz2 \
+ testfilebazminppc64_plr.bz2 testfilebaztabppc64.bz2 \
+ run-readelf-variant.sh testfile-ada-variant.bz2 \
+ run-dwflsyms.sh \
+ run-unstrip-n.sh testcore-rtlib.bz2 testcore-rtlib-ppc.bz2 \
+ run-low_high_pc.sh testfile_low_high_pc.bz2 \
+ run-macro-test.sh testfile-macinfo.bz2 testfile-macros.bz2 \
+ run-elf_cntl_gelf_getshdr.sh \
+ run-test-archive64.sh testarchive64.a.bz2 \
+ testfile60.bz2 testfile61.bz2 \
+ run-readelf-vmcoreinfo.sh testfile62.bz2 \
+ run-readelf-mixed-corenote.sh testfile63.bz2 testfile64.bz2 \
+ testfile65.bz2 testfile67.bz2 testfile68.bz2 \
+ testfile69.core.bz2 testfile69.so.bz2 \
+ testfile70.core.bz2 testfile70.exec.bz2 testfile71.bz2 \
+ run-dwfllines.sh run-dwfl-report-elf-align.sh \
+ testfile-dwfl-report-elf-align-shlib.so.bz2 \
+ testfilenolines.bz2 test-core-lib.so.bz2 test-core.core.bz2 \
+ test-core.exec.bz2 run-addr2line-test.sh \
+ run-addr2line-i-test.sh testfile-inlines.bz2 \
+ run-addr2line-i-lex-test.sh testfile-lex-inlines.bz2 \
+ run-addr2line-i-demangle-test.sh run-addr2line-alt-debugpath.sh \
+ testfileppc32.bz2 testfileppc64.bz2 \
+ testfiles390.bz2 testfiles390x.bz2 \
+ testfilearm.bz2 testfileaarch64.bz2 \
+ run-varlocs.sh run-exprlocs.sh testfile-stridex.bz2 \
+ testfile_const_type.c testfile_const_type.bz2 \
+ testfile_implicit_pointer.c testfile_implicit_pointer.bz2 \
+ testfile_parameter_ref.c testfile_parameter_ref.bz2 \
+ testfile_entry_value.c testfile_entry_value.bz2 \
+ testfile_implicit_value.c testfile_implicit_value.bz2 \
+ testfile_aarch64_core.bz2 testfile_i686_core.bz2 \
+ run-funcretval.sh funcretval_test.c funcretval_test_aarch64.bz2 \
+ run-backtrace-data.sh run-backtrace-dwarf.sh cleanup-13.c \
+ run-backtrace-native.sh run-backtrace-native-biarch.sh \
+ run-backtrace-native-core.sh run-backtrace-native-core-biarch.sh \
+ run-backtrace-core-x86_64.sh run-backtrace-core-i386.sh \
+ run-backtrace-fp-core-x86_64.sh \
+ run-backtrace-core-x32.sh \
+ run-backtrace-fp-core-aarch64.sh \
+ backtrace.aarch64.fp.core.bz2 backtrace.aarch64.fp.exec.bz2 \
+ backtrace-subr.sh backtrace.i386.core.bz2 backtrace.i386.exec.bz2 \
+ run-backtrace-fp-core-i386.sh \
+ backtrace.i386.fp.core.bz2 backtrace.i386.fp.exec.bz2 \
+ run-backtrace-fp-core-ppc64le.sh \
+ backtrace.ppc64le.fp.core.bz2 backtrace.ppc64le.fp.exec.bz2 \
+ backtrace.x86_64.core.bz2 backtrace.x86_64.exec.bz2 \
+ backtrace.x86_64.fp.core.bz2 backtrace.x86_64.fp.exec.bz2 \
+ backtrace.ppc.core.bz2 backtrace.ppc.exec.bz2 \
+ run-backtrace-core-ppc.sh testfile66.bz2 testfile66.core.bz2 \
+ backtrace.s390x.core.bz2 backtrace.s390x.exec.bz2 \
+ backtrace.s390.core.bz2 backtrace.s390.exec.bz2 \
+ run-backtrace-core-s390x.sh run-backtrace-core-s390.sh \
+ run-backtrace-core-aarch64.sh \
+ backtrace.aarch64.core.bz2 backtrace.aarch64.exec.bz2 \
+ run-backtrace-core-sparc.sh \
+ backtrace.sparc.core.bz2 backtrace.sparc.exec.bz2 \
+ run-backtrace-demangle.sh testfile-backtrace-demangle.bz2 \
+ testfile-backtrace-demangle.cc \
+ testfile-backtrace-demangle.core.bz2 \
+ run-stack-d-test.sh run-stack-i-test.sh \
+ run-stack-demangled-test.sh \
+ testfiledwarfinlines.bz2 testfiledwarfinlines.core.bz2 \
+ run-readelf-zdebug.sh testfile-debug.bz2 testfile-zdebug.bz2 \
+ run-readelf-zdebug-rel.sh testfile-debug-rel.o.bz2 \
+ testfile-debug-rel-g.o.bz2 testfile-debug-rel-z.o.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 \
+ testfile-sizes3.o.bz2 testfile-sizes4.o.bz2 testfile-sizes4.s \
+ run-peel-type.sh \
+ run-readelf-A.sh testfileppc32attrs.o.bz2 \
+ testfilesparc64attrs.o.bz2 testfileppc64attrs.o.bz2 \
+ testfile-debug-types.bz2 \
+ run-getsrc-die.sh run-strptr.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 \
+ testfile-zgnu32.bz2 testfile-zgnu64.bz2 \
+ testfile-zgnu32be.bz2 testfile-zgnu64be.bz2 \
+ run-dwelfgnucompressed.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-compress-test.sh \
+ run-disasm-bpf.sh \
+ testfile-bpf-dis1.expect.bz2 testfile-bpf-dis1.o.bz2 \
+ testfile-m68k-core.bz2 testfile-m68k.bz2 testfile-m68k-s.bz2
+
+if USE_VALGRIND
+valgrind_cmd='valgrind -q --leak-check=full --error-exitcode=1'
+endif
+
+
+installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \
+ bindir=$(DESTDIR)$(bindir); \
+ LC_ALL=C; LANG=C; \
+ VALGRIND_CMD=$(valgrind_cmd); \
+ abs_srcdir=$(abs_srcdir); \
+ abs_builddir=$(abs_builddir); \
+ abs_top_builddir=$(abs_top_builddir); \
+ export abs_srcdir; export abs_builddir; \
+ export abs_top_builddir; \
+ export libdir; export bindir; \
+ export LC_ALL; export LANG; export VALGRIND_CMD; \
+ NM=$(NM); export NM;
+installed_LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
+ installed $(tests_rpath) \
+ '$(program_transform_name)'
+if STANDALONE
+TESTS_ENVIRONMENT = $(installed_TESTS_ENVIRONMENT)
+LOG_COMPILER = $(installed_LOG_COMPILER)
+else !STANDALONE
+TESTS_ENVIRONMENT = LC_ALL=C; LANG=C; VALGRIND_CMD=$(valgrind_cmd); \
+ abs_srcdir=$(abs_srcdir); abs_builddir=$(abs_builddir); \
+ abs_top_builddir=$(abs_top_builddir); \
+ export abs_srcdir; export abs_builddir; \
+ export abs_top_builddir; \
+ export LC_ALL; export LANG; export VALGRIND_CMD; \
+ NM=$(NM); export NM;
+LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
+ $(abs_top_builddir)/libdw:$(abs_top_builddir)/backends:$(abs_top_builddir)/libelf:$(abs_top_builddir)/libasm
+
+installcheck-local:
+ $(MAKE) $(AM_MAKEFLAGS) \
+ TESTS_ENVIRONMENT="$(installed_TESTS_ENVIRONMENT)" \
+ LOG_COMPILER="$(installed_LOG_COMPILER)" check-TESTS
+endif !STANDALONE
+
+if STANDALONE
+libdw = -ldw
+libelf = -lelf
+libasm = -lasm
+libebl = -lebl
+else !STANDALONE
+if BUILD_STATIC
+libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) $(libebl) -ldl
+libelf = ../libelf/libelf.a -lz
+libasm = ../libasm/libasm.a
+else
+libdw = ../libdw/libdw.so
+libelf = ../libelf/libelf.so
+libasm = ../libasm/libasm.so
+endif
+libebl = ../libebl/libebl.a
+libeu = ../lib/libeu.a
+endif !STANDALONE
+
+arextract_LDADD = $(libelf)
+arsymtest_LDADD = $(libelf)
+newfile_LDADD = $(libelf)
+saridx_LDADD = $(libelf)
+scnnames_LDADD = $(libelf)
+sectiondump_LDADD = $(libelf)
+showptable_LDADD = $(libelf)
+hash_LDADD = $(libelf)
+test_nlist_LDADD = $(libelf)
+msg_tst_LDADD = $(libelf)
+newscn_LDADD = $(libelf)
+early_offscn_LDADD = $(libelf)
+ecp_LDADD = $(libelf)
+update1_LDADD = $(libelf)
+update2_LDADD = $(libelf)
+update3_LDADD = $(libdw) $(libelf)
+update4_LDADD = $(libdw) $(libelf)
+show_die_info_LDADD = $(libdw) $(libelf)
+get_pubnames_LDADD = $(libdw) $(libelf)
+show_abbrev_LDADD = $(libdw) $(libelf)
+get_lines_LDADD = $(libdw) $(libelf)
+get_files_LDADD = $(libdw) $(libelf)
+get_aranges_LDADD = $(libdw) $(libelf)
+allfcts_LDADD = $(libdw) $(libelf)
+line2addr_LDADD = $(libdw) $(argp_LDADD)
+addrscopes_LDADD = $(libdw) $(argp_LDADD)
+funcscopes_LDADD = $(libdw) $(argp_LDADD)
+funcretval_LDADD = $(libdw) $(argp_LDADD)
+allregs_LDADD = $(libdw) $(argp_LDADD)
+find_prologues_LDADD = $(libdw) $(argp_LDADD)
+#show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf)
+asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+asm_tst3_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+asm_tst4_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+asm_tst5_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+asm_tst6_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+asm_tst7_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) -ldl
+dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl
+rdwrmmap_LDADD = $(libelf)
+dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) -ldl
+arls_LDADD = $(libelf)
+dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) -ldl
+dwfl_bug_report_LDADD = $(libdw) $(libebl) $(libelf) -ldl
+dwfl_bug_getmodules_LDADD = $(libdw) $(libebl) $(libelf) -ldl
+dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl
+dwarf_getmacros_LDADD = $(libdw)
+dwarf_ranges_LDADD = $(libdw)
+dwarf_getstring_LDADD = $(libdw)
+addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl
+test_flag_nobits_LDADD = $(libelf)
+rerequest_tag_LDADD = $(libdw)
+alldts_LDADD = $(libdw) $(libelf)
+typeiter_LDADD = $(libdw) $(libelf)
+typeiter2_LDADD = $(libdw) $(libelf)
+low_high_pc_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+test_elf_cntl_gelf_getshdr_LDADD = $(libelf)
+dwflsyms_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+dwfllines_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+dwfl_report_elf_align_LDADD = $(libdw)
+varlocs_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+backtrace_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+# backtrace-child-biarch also uses those *_CFLAGS and *_LDLAGS variables:
+backtrace_child_CFLAGS = $(fpie_CFLAGS)
+backtrace_child_LDFLAGS = -pie -pthread
+backtrace_child_biarch_SOURCES = backtrace-child.c
+backtrace_data_LDADD = $(libdw) $(libelf)
+backtrace_dwarf_CFLAGS = -Wno-unused-parameter
+backtrace_dwarf_LDADD = $(libdw) $(libelf)
+debuglink_LDADD = $(libdw) $(libelf)
+debugaltlink_LDADD = $(libdw) $(libelf)
+buildid_LDADD = $(libdw) $(libelf)
+deleted_LDADD = ./deleted-lib.so
+deleted_lib_so_LDFLAGS = -shared
+deleted_lib_so_CFLAGS = $(fpic_CFLAGS) -fasynchronous-unwind-tables
+aggregate_size_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+peel_type_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+vdsosyms_LDADD = $(libdw) $(libelf)
+getsrc_die_LDADD = $(libdw) $(libelf)
+strptr_LDADD = $(libelf)
+newdata_LDADD = $(libelf)
+elfstrtab_LDADD = $(libelf)
+dwfl_proc_attach_LDADD = $(libdw)
+dwfl_proc_attach_LDFLAGS = -pthread $(AM_LDFLAGS)
+elfshphehdr_LDADD =$(libelf)
+elfstrmerge_LDADD = $(libdw) $(libelf)
+dwelfgnucompressed_LDADD = $(libelf) $(libdw)
+elfgetchdr_LDADD = $(libelf) $(libdw)
+elfgetzdata_LDADD = $(libelf)
+elfputzdata_LDADD = $(libelf)
+zstrptr_LDADD = $(libelf)
+emptyfile_LDADD = $(libelf)
+vendorelf_LDADD = $(libelf)
+fillfile_LDADD = $(libelf)
+dwarf_default_lower_bound_LDADD = $(libdw)
+
+# We want to test the libelf header against the system elf.h header.
+# Don't include any -I CPPFLAGS.
+system_elf_libelf_test_CPPFLAGS =
+system_elf_libelf_test_LDADD = $(libelf)
+
+# A lock file used to make sure only one test dumps core at a time
+CLEANFILES += core-dump-backtrace.lock
+
+if GCOV
+check: check-am coverage
+.PHONY: coverage
+coverage:
+ -$(srcdir)/coverage.sh
+endif
diff --git a/tests/addrcfi.c b/tests/addrcfi.c
new file mode 100644
index 0000000..589b851
--- /dev/null
+++ b/tests/addrcfi.c
@@ -0,0 +1,233 @@
+/* Test program for CFI handling.
+ Copyright (C) 2009-2010, 2013, 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../libdw/known-dwarf.h"
+
+static const char *
+op_name (unsigned int code)
+{
+ static const char *const known[] =
+ {
+#define DWARF_ONE_KNOWN_DW_OP(NAME, CODE) [CODE] = #NAME,
+ DWARF_ALL_KNOWN_DW_OP
+#undef DWARF_ONE_KNOWN_DW_OP
+ };
+
+ if (likely (code < sizeof (known) / sizeof (known[0])))
+ return known[code];
+
+ return NULL;
+}
+
+static void
+print_detail (int result, const Dwarf_Op *ops, size_t nops, Dwarf_Addr bias)
+{
+ if (result < 0)
+ printf ("indeterminate (%s)\n", dwarf_errmsg (-1));
+ else if (nops == 0)
+ printf ("%s\n", ops == NULL ? "same_value" : "undefined");
+ else
+ {
+ printf ("%s expression:", result == 0 ? "location" : "value");
+ for (size_t i = 0; i < nops; ++i)
+ {
+ printf (" %s", op_name(ops[i].atom));
+ if (ops[i].number2 == 0)
+ {
+ if (ops[i].atom == DW_OP_addr)
+ printf ("(%#" PRIx64 ")", ops[i].number + bias);
+ else if (ops[i].number != 0)
+ printf ("(%" PRId64 ")", ops[i].number);
+ }
+ else
+ printf ("(%" PRId64 ",%" PRId64 ")",
+ ops[i].number, ops[i].number2);
+ }
+ puts ("");
+ }
+}
+
+struct stuff
+{
+ Dwarf_Frame *frame;
+ Dwarf_Addr bias;
+};
+
+static int
+print_register (void *arg,
+ int regno,
+ const char *setname,
+ const char *prefix,
+ const char *regname,
+ int bits __attribute__ ((unused)),
+ int type __attribute__ ((unused)))
+{
+ struct stuff *stuff = arg;
+
+ printf ("\t%s reg%u (%s%s): ", setname, regno, prefix, regname);
+
+ Dwarf_Op ops_mem[2];
+ Dwarf_Op *ops;
+ size_t nops;
+ int result = dwarf_frame_register (stuff->frame, regno, ops_mem, &ops, &nops);
+ print_detail (result, ops, nops, stuff->bias);
+
+ return DWARF_CB_OK;
+}
+
+static int
+handle_cfi (Dwfl *dwfl, const char *which, Dwarf_CFI *cfi,
+ GElf_Addr pc, struct stuff *stuff)
+{
+ if (cfi == NULL)
+ {
+ printf ("handle_cfi no CFI (%s): %s\n", which, dwarf_errmsg (-1));
+ return -1;
+ }
+
+ int result = dwarf_cfi_addrframe (cfi, pc - stuff->bias, &stuff->frame);
+ if (result != 0)
+ {
+ printf ("dwarf_cfi_addrframe (%s): %s\n", which, dwarf_errmsg (-1));
+ return 1;
+ }
+
+ Dwarf_Addr start = pc;
+ Dwarf_Addr end = pc;
+ bool signalp;
+ int ra_regno = dwarf_frame_info (stuff->frame, &start, &end, &signalp);
+ if (ra_regno >= 0)
+ {
+ start += stuff->bias;
+ end += stuff->bias;
+ }
+
+ printf ("%s has %#" PRIx64 " => [%#" PRIx64 ", %#" PRIx64 "):\n",
+ which, pc, start, end);
+
+ if (ra_regno < 0)
+ printf ("\treturn address register unavailable (%s)\n",
+ dwarf_errmsg (0));
+ else
+ printf ("\treturn address in reg%u%s\n",
+ ra_regno, signalp ? " (signal frame)" : "");
+
+ // Point cfa_ops to dummy to match print_detail expectations.
+ // (nops == 0 && cfa_ops != NULL => "undefined")
+ Dwarf_Op dummy;
+ Dwarf_Op *cfa_ops = &dummy;
+ size_t cfa_nops;
+ result = dwarf_frame_cfa (stuff->frame, &cfa_ops, &cfa_nops);
+
+ printf ("\tCFA ");
+ print_detail (result, cfa_ops, cfa_nops, stuff->bias);
+
+ (void) dwfl_module_register_names (dwfl_addrmodule (dwfl, pc),
+ &print_register, stuff);
+
+ return 0;
+}
+
+static int
+handle_address (GElf_Addr pc, Dwfl *dwfl)
+{
+ Dwfl_Module *mod = dwfl_addrmodule (dwfl, pc);
+
+ struct stuff stuff;
+ stuff.frame = NULL;
+ stuff.bias = 0;
+ int res = handle_cfi (dwfl, ".eh_frame",
+ dwfl_module_eh_cfi (mod, &stuff.bias), pc, &stuff);
+ free (stuff.frame);
+
+ stuff.frame = NULL;
+ stuff.bias = 0;
+ res &= handle_cfi (dwfl, ".debug_frame",
+ dwfl_module_dwarf_cfi (mod, &stuff.bias), pc, &stuff);
+ free (stuff.frame);
+
+ return res;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ Dwfl *dwfl = NULL;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
+ assert (dwfl != NULL);
+
+ int result = 0;
+
+ /* Now handle the addresses. In case none are given on the command
+ line, read from stdin. */
+ if (remaining == argc)
+ {
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdin, FSETLOCKING_BYCALLER);
+
+ char *buf = NULL;
+ size_t len = 0;
+ while (!feof_unlocked (stdin))
+ {
+ if (getline (&buf, &len, stdin) < 0)
+ break;
+
+ char *endp;
+ uintmax_t addr = strtoumax (buf, &endp, 0);
+ if (endp != buf)
+ result |= handle_address (addr, dwfl);
+ else
+ result = 1;
+ }
+
+ free (buf);
+ }
+ else
+ {
+ do
+ {
+ char *endp;
+ uintmax_t addr = strtoumax (argv[remaining], &endp, 0);
+ if (endp != argv[remaining])
+ result |= handle_address (addr, dwfl);
+ else
+ result = 1;
+ }
+ while (++remaining < argc);
+ }
+
+ dwfl_end (dwfl);
+
+ return result;
+}
diff --git a/tests/addrscopes.c b/tests/addrscopes.c
new file mode 100644
index 0000000..791569f
--- /dev/null
+++ b/tests/addrscopes.c
@@ -0,0 +1,196 @@
+/* Test program for dwarf_getscopes.
+ Copyright (C) 2005, 2014 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <error.h>
+#include <string.h>
+
+
+static void
+paddr (const char *prefix, Dwarf_Addr addr, Dwfl_Line *line)
+{
+ const char *src;
+ int lineno, linecol;
+ if (line != NULL
+ && (src = dwfl_lineinfo (line, &addr, &lineno, &linecol,
+ NULL, NULL)) != NULL)
+ {
+ if (linecol != 0)
+ printf ("%s%#" PRIx64 " (%s:%d:%d)",
+ prefix, addr, src, lineno, linecol);
+ else
+ printf ("%s%#" PRIx64 " (%s:%d)",
+ prefix, addr, src, lineno);
+ }
+ else
+ printf ("%s%#" PRIx64, prefix, addr);
+}
+
+static void
+print_vars (unsigned int indent, Dwarf_Die *die)
+{
+ Dwarf_Die child;
+ if (dwarf_child (die, &child) == 0)
+ do
+ switch (dwarf_tag (&child))
+ {
+ case DW_TAG_variable:
+ case DW_TAG_formal_parameter:
+ printf ("%*s%-30s[%6" PRIx64 "]\n", indent, "",
+ dwarf_diename (&child),
+ (uint64_t) dwarf_dieoffset (&child));
+ break;
+ default:
+ break;
+ }
+ while (dwarf_siblingof (&child, &child) == 0);
+
+ Dwarf_Attribute attr_mem;
+ Dwarf_Die origin;
+ if (dwarf_hasattr (die, DW_AT_abstract_origin)
+ && dwarf_formref_die (dwarf_attr (die, DW_AT_abstract_origin, &attr_mem),
+ &origin) != NULL
+ && dwarf_child (&origin, &child) == 0)
+ do
+ switch (dwarf_tag (&child))
+ {
+ case DW_TAG_variable:
+ case DW_TAG_formal_parameter:
+ printf ("%*s%s (abstract)\n", indent, "",
+ dwarf_diename (&child));
+ break;
+ default:
+ break;
+ }
+ while (dwarf_siblingof (&child, &child) == 0);
+}
+
+
+#define INDENT 4
+
+static void
+handle_address (GElf_Addr pc, Dwfl *dwfl)
+{
+ Dwarf_Addr cubias;
+ Dwarf_Die *cudie = dwfl_addrdie (dwfl, pc, &cubias);
+ if (cudie == NULL)
+ error (EXIT_FAILURE, 0, "dwfl_addrdie: %s", dwfl_errmsg (-1));
+
+ Dwarf_Die *scopes;
+ int n = dwarf_getscopes (cudie, pc - cubias, &scopes);
+ if (n < 0)
+ error (EXIT_FAILURE, 0, "dwarf_getscopes: %s", dwarf_errmsg (-1));
+ else if (n == 0)
+ printf ("%#" PRIx64 ": not in any scope\n", pc);
+ else
+ {
+ printf ("%#" PRIx64 ":\n", pc);
+ unsigned int indent = 0;
+ while (n-- > 0)
+ {
+ Dwarf_Die *const die = &scopes[n];
+
+ indent += INDENT;
+ printf ("%*s%s (%#x)", indent, "",
+ dwarf_diename (die) ?: "<unnamed>",
+ dwarf_tag (die));
+
+ Dwarf_Addr lowpc, highpc;
+ if (dwarf_lowpc (die, &lowpc) == 0
+ && dwarf_highpc (die, &highpc) == 0)
+ {
+ lowpc += cubias;
+ highpc += cubias;
+ Dwfl_Line *loline = dwfl_getsrc (dwfl, lowpc);
+ Dwfl_Line *hiline = dwfl_getsrc (dwfl, highpc - 1);
+ paddr (": ", lowpc, loline);
+ if (highpc != lowpc)
+ paddr (" .. ", highpc - 1, hiline == loline ? NULL : hiline);
+ }
+ puts ("");
+
+ print_vars (indent + INDENT, die);
+ }
+ free (scopes);
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ Dwfl *dwfl = NULL;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
+ assert (dwfl != NULL);
+
+ int result = 0;
+
+ /* Now handle the addresses. In case none are given on the command
+ line, read from stdin. */
+ if (remaining == argc)
+ {
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdin, FSETLOCKING_BYCALLER);
+
+ char *buf = NULL;
+ size_t len = 0;
+ while (!feof_unlocked (stdin))
+ {
+ if (getline (&buf, &len, stdin) < 0)
+ break;
+
+ char *endp;
+ uintmax_t addr = strtoumax (buf, &endp, 0);
+ if (endp != buf)
+ handle_address (addr, dwfl);
+ else
+ result = 1;
+ }
+
+ free (buf);
+ }
+ else
+ {
+ do
+ {
+ char *endp;
+ uintmax_t addr = strtoumax (argv[remaining], &endp, 0);
+ if (endp != argv[remaining])
+ handle_address (addr, dwfl);
+ else
+ result = 1;
+ }
+ while (++remaining < argc);
+ }
+
+ dwfl_end (dwfl);
+
+ return result;
+}
diff --git a/tests/aggregate_size.c b/tests/aggregate_size.c
new file mode 100644
index 0000000..930eafa
--- /dev/null
+++ b/tests/aggregate_size.c
@@ -0,0 +1,83 @@
+/* Test program for dwarf_aggregate_size. Prints size of top-level vars.
+ Copyright (C) 2014 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 <argp.h>
+#include <inttypes.h>
+#include <fcntl.h>
+#include ELFUTILS_HEADER(dw)
+#include ELFUTILS_HEADER(dwfl)
+#include <stdio.h>
+#include <unistd.h>
+#include <dwarf.h>
+
+void
+print_var_type_size (Dwarf_Die *var)
+{
+ Dwarf_Attribute attr_mem;
+ Dwarf_Die type_mem;
+ Dwarf_Die *type;
+ const char *name = dwarf_diename (var);
+
+ type = dwarf_formref_die (dwarf_attr (var, DW_AT_type, &attr_mem),
+ &type_mem);
+ if (type != NULL)
+ {
+ Dwarf_Word size;
+ if (dwarf_aggregate_size (type, &size) < 0)
+ printf ("%s no size: %s\n", name, dwarf_errmsg (-1));
+ else
+ printf ("%s size %" PRIu64 "\n", name, size);
+ }
+ else
+ printf ("%s has no type.\n", name);
+}
+
+int
+main (int argc, char *argv[])
+{
+
+ int remaining;
+ Dwfl *dwfl;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining,
+ &dwfl);
+ assert (dwfl != NULL);
+
+ Dwarf_Die *cu = NULL;
+ Dwarf_Addr dwbias;
+ while ((cu = dwfl_nextcu (dwfl, cu, &dwbias)) != NULL)
+ {
+ Dwarf_Die die_mem;
+ Dwarf_Die *die = &die_mem;
+ dwarf_child (cu, &die_mem);
+
+ while (1)
+ {
+ if (dwarf_tag (die) == DW_TAG_variable)
+ print_var_type_size (die);
+
+ if (dwarf_siblingof (die, &die_mem) != 0)
+ break;
+ }
+ }
+
+ dwfl_end (dwfl);
+}
diff --git a/tests/alldts.c b/tests/alldts.c
new file mode 100644
index 0000000..28b3063
--- /dev/null
+++ b/tests/alldts.c
@@ -0,0 +1,270 @@
+/* Create an ELF file with all the DT_* flags set.
+ Copyright (C) 2011, 2016 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Marek Polacek <mpolacek@redhat.com>, 2011.
+
+ 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 ELFUTILS_HEADER(dwelf)
+#include <elf.h>
+#include <gelf.h>
+#include <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+int
+main (void)
+{
+ static const char fname[] = "testfile-alldts";
+ Dwelf_Strtab *shst;
+ Dwelf_Strent *dynscn;
+ Dwelf_Strent *shstrtabse;
+ const Elf32_Sword dtflags[] =
+ {
+ DT_NULL, DT_NEEDED, DT_PLTRELSZ, DT_PLTGOT,
+ DT_HASH, DT_STRTAB, DT_SYMTAB, DT_RELA,
+ DT_RELASZ, DT_RELAENT, DT_STRSZ, DT_SYMENT,
+ DT_INIT, DT_FINI, DT_SONAME, DT_RPATH,
+ DT_SYMBOLIC, DT_REL, DT_RELSZ, DT_RELENT,
+ DT_PLTREL, DT_DEBUG, DT_TEXTREL, DT_JMPREL,
+ DT_BIND_NOW, DT_INIT_ARRAY, DT_FINI_ARRAY,
+ DT_INIT_ARRAYSZ, DT_FINI_ARRAYSZ, DT_RUNPATH,
+ DT_FLAGS, DT_ENCODING, DT_PREINIT_ARRAY,
+ DT_PREINIT_ARRAYSZ, DT_VERSYM, DT_GNU_PRELINKED,
+ DT_GNU_CONFLICTSZ, DT_GNU_LIBLISTSZ, DT_CHECKSUM,
+ DT_PLTPADSZ, DT_MOVEENT, DT_MOVESZ, DT_FEATURE_1,
+ DT_POSFLAG_1, DT_SYMINSZ, DT_SYMINENT, DT_GNU_HASH,
+ DT_TLSDESC_PLT, DT_TLSDESC_GOT, DT_GNU_CONFLICT,
+ DT_GNU_LIBLIST, DT_CONFIG, DT_DEPAUDIT, DT_AUDIT,
+ DT_PLTPAD, DT_MOVETAB, DT_SYMINFO, DT_RELACOUNT,
+ DT_RELCOUNT, DT_FLAGS_1, DT_VERDEF, DT_VERDEFNUM,
+ DT_VERNEED, DT_VERNEEDNUM, DT_AUXILIARY, DT_FILTER
+ };
+ const int ndtflags = sizeof (dtflags) / sizeof (dtflags[0]);
+
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+ /* Open the file. */
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %m\n", fname);
+ return 1;
+ }
+
+ /* Tell the library which version are we expecting. */
+ elf_version (EV_CURRENT);
+
+ /* Create an ELF descriptor. */
+ Elf *elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ /* Create an ELF header. */
+ Elf32_Ehdr *ehdr = elf32_newehdr (elf);
+ if (ehdr == NULL)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ ehdr->e_ident[0] = 42;
+ ehdr->e_ident[5] = 1;
+ ehdr->e_ident[6] = 2;
+ ehdr->e_type = ET_EXEC;
+ ehdr->e_machine = EM_386;
+ ehdr->e_version = 1;
+ ehdr->e_ehsize = 1;
+ ehdr->e_shnum = 3;
+
+ elf_flagehdr (elf, ELF_C_SET, ELF_F_DIRTY);
+
+ /* Create the program headers. */
+ Elf32_Phdr *phdr = elf32_newphdr (elf, 2);
+ if (phdr == NULL)
+ {
+ printf ("cannot create program headers: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ phdr[0].p_type = PT_PHDR;
+ phdr[1].p_type = PT_DYNAMIC;
+
+ elf_flagphdr (elf, ELF_C_SET, ELF_F_DIRTY);
+ shst = dwelf_strtab_init (true);
+
+ /* Create the .dynamic section. */
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create DYNAMIC section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ Elf32_Shdr *shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for DYNAMIC section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ dynscn = dwelf_strtab_add (shst, ".dynamic");
+
+ /* We'll need to know the section offset. But this will be set up
+ by elf_update later, so for now just store the address. */
+ const Elf32_Off *const dynscn_offset = &shdr->sh_offset;
+ shdr->sh_type = SHT_DYNAMIC;
+ shdr->sh_flags = SHF_ALLOC | SHF_WRITE;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ /* This section will start here. */
+ shdr->sh_addr = 0x1a0;
+
+ /* Create new section data. */
+ Elf_Data *data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data for DYNAMIC section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ /* Allocate memory for all the .dynamic entries. */
+ Elf32_Dyn *dyn = malloc (ndtflags * sizeof (Elf32_Dyn));
+ if (dyn == NULL)
+ {
+ printf ("malloc failed: %m\n");
+ return 1;
+ }
+
+ /* Now write all the DT_* flags. */
+ for (int i = 0; i < ndtflags; ++i)
+ {
+ dyn[i].d_tag = dtflags[i];
+ dyn[i].d_un.d_val = 0xdeadbeef;
+ }
+
+ /* Set the pointer to allocated memory. */
+ data->d_buf = dyn;
+ data->d_type = ELF_T_DYN;
+ data->d_version = EV_CURRENT;
+ data->d_size = ndtflags * sizeof (Elf32_Dyn);
+ data->d_align = 0x8;
+
+ /* Create .shstrtab section. */
+ scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create SHSTRTAB section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for SHSTRTAB section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ shstrtabse = dwelf_strtab_add (shst, ".shstrtab");
+
+ shdr->sh_type = SHT_STRTAB;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_entsize = 1;
+
+ /* We have to store the section index in the ELF header. */
+ ehdr->e_shstrndx = elf_ndxscn (scn);
+
+ data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data SHSTRTAB section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ /* No more sections, finalize the section header string table. */
+ dwelf_strtab_finalize (shst, data);
+
+ elf32_getshdr (elf_getscn (elf, 1))->sh_name = dwelf_strent_off (dynscn);
+ shdr->sh_name = dwelf_strent_off (shstrtabse);
+
+ /* Let the library compute the internal structure information. */
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in elf_update(NULL): %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ ehdr = elf32_getehdr (elf);
+
+ phdr[0].p_offset = ehdr->e_phoff;
+ phdr[0].p_vaddr = ehdr->e_phoff;
+ phdr[0].p_paddr = ehdr->e_phoff;
+ phdr[0].p_flags = PF_R | PF_X;
+ phdr[0].p_filesz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_memsz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_align = sizeof (Elf32_Word);
+
+ phdr[1].p_flags = PF_W | PF_R;
+ phdr[1].p_offset = *dynscn_offset;
+ /* Set up the start of this segment to equal start address of the
+ .dynamic section. */
+ phdr[1].p_vaddr = 0x1a0;
+ phdr[1].p_paddr = 0x1a0;
+ phdr[1].p_align = 2 * sizeof (Elf32_Word);
+ phdr[1].p_filesz = ndtflags * sizeof (Elf32_Dyn);
+ phdr[1].p_memsz = ndtflags * sizeof (Elf32_Dyn);
+
+ /* Write out the file. */
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ /* We don't need the string table anymore. */
+ dwelf_strtab_free (shst);
+
+ /* And the data allocated in the .shstrtab section. */
+ free (data->d_buf);
+
+ /* And the dynamic entries. */
+ free (dyn);
+
+ /* All done. */
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/allfcts.c b/tests/allfcts.c
new file mode 100644
index 0000000..f637311
--- /dev/null
+++ b/tests/allfcts.c
@@ -0,0 +1,112 @@
+/* Copyright (C) 2005, 2013 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 <err.h>
+#include <fcntl.h>
+#include ELFUTILS_HEADER(dw)
+#include ELFUTILS_HEADER(dwelf)
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+cb (Dwarf_Die *func, void *arg __attribute__ ((unused)))
+{
+ const char *file = dwarf_decl_file (func);
+ int line = -1;
+ dwarf_decl_line (func, &line);
+ const char *fct = dwarf_diename (func);
+
+ printf ("%s:%d:%s\n", file, line, fct);
+
+ return DWARF_CB_ABORT;
+}
+
+static Dwarf *
+setup_alt (Dwarf *main)
+{
+ const char *alt_name;
+ const void *build_id;
+ ssize_t ret = dwelf_dwarf_gnu_debugaltlink (main, &alt_name, &build_id);
+ if (ret == 0)
+ return NULL;
+ if (ret == -1)
+ errx (1, "dwelf_dwarf_gnu_debugaltlink: %s", dwarf_errmsg (-1));
+ int fd = open (alt_name, O_RDONLY);
+ if (fd < 0)
+ {
+ printf ("Warning: no alt file found.\n");
+ return NULL;
+ }
+ Dwarf *dbg_alt = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg_alt == NULL)
+ errx (1, "dwarf_begin (%s): %s", alt_name, dwarf_errmsg (-1));
+ if (elf_cntl (dwarf_getelf (dbg_alt), ELF_C_FDREAD) != 0)
+ errx (1, "elf_cntl (%s, ELF_C_FDREAD): %s", alt_name, elf_errmsg (-1));
+ close (fd);
+ dwarf_setalt (main, dbg_alt);
+ return dbg_alt;
+}
+
+int
+main (int argc, char *argv[])
+{
+ for (int i = 1; i < argc; ++i)
+ {
+ int fd = open (argv[i], O_RDONLY);
+ if (fd < 0)
+ err (1, "open (%s)", argv[i]);
+
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg != NULL)
+ {
+ Dwarf_Off off = 0;
+ size_t cuhl;
+ Dwarf_Off noff;
+ Dwarf *dbg_alt = setup_alt (dbg);
+
+ while (dwarf_nextcu (dbg, off, &noff, &cuhl, NULL, NULL, NULL) == 0)
+ {
+ Dwarf_Die die_mem;
+ Dwarf_Die *die = dwarf_offdie (dbg, off + cuhl, &die_mem);
+
+ /* Explicitly stop in the callback and then resume each time. */
+ ptrdiff_t doff = 0;
+ do
+ {
+ doff = dwarf_getfuncs (die, cb, NULL, doff);
+ if (dwarf_errno () != 0)
+ errx (1, "dwarf_getfuncs (%s): %s",
+ argv[i], dwarf_errmsg (-1));
+ }
+ while (doff != 0);
+
+ off = noff;
+ }
+
+ dwarf_end (dbg_alt);
+ dwarf_end (dbg);
+ }
+ else
+ errx (1, "dwarf_begin (%s): %s", argv[i], dwarf_errmsg (-1));
+
+ close (fd);
+ }
+}
diff --git a/tests/allregs.c b/tests/allregs.c
new file mode 100644
index 0000000..286f7e3
--- /dev/null
+++ b/tests/allregs.c
@@ -0,0 +1,204 @@
+/* Copyright (C) 2005, 2006, 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <locale.h>
+#include <argp.h>
+#include <assert.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+
+#include "../libdw/known-dwarf.h"
+
+static const char *
+dwarf_encoding_string (unsigned int code)
+{
+ static const char *const known[] =
+ {
+#define DWARF_ONE_KNOWN_DW_ATE(NAME, CODE) [CODE] = #NAME,
+ DWARF_ALL_KNOWN_DW_ATE
+#undef DWARF_ONE_KNOWN_DW_ATE
+ };
+
+ if (likely (code < sizeof (known) / sizeof (known[0])))
+ return known[code];
+
+ return NULL;
+}
+
+
+static int
+first_module (Dwfl_Module *mod,
+ void **userdatap __attribute__ ((unused)),
+ const char *name __attribute__ ((unused)),
+ Dwarf_Addr low_addr __attribute__ ((unused)),
+ void *arg)
+{
+ Dwarf_Addr bias;
+ if (dwfl_module_getelf (mod, &bias) == NULL) /* Not really a module. */
+ return DWARF_CB_OK;
+
+ *(Dwfl_Module **) arg = mod;
+ return DWARF_CB_ABORT;
+}
+
+
+struct state
+{
+ struct reginfo *info;
+ int nregs;
+};
+
+struct reginfo
+{
+ const char *set, *pfx;
+ int regno;
+ int bits;
+ int type;
+ char name[32];
+};
+
+static int
+compare (const void *r1, const void *r2)
+{
+ const struct reginfo *a = r1, *b = r2;
+ if (a->set == b->set)
+ return a->regno - b->regno;
+ if (a->set == NULL)
+ return 1;
+ if (b->set == NULL)
+ return -1;
+ if (!strcmp (a->set, "integer"))
+ return -1;
+ if (!strcmp (b->set, "integer"))
+ return 1;
+ return strcmp (a->set, b->set);
+}
+
+static int
+one_register (void *arg,
+ int regno,
+ const char *setname,
+ const char *prefix,
+ const char *regname,
+ int bits, int type)
+{
+ struct state *state = arg;
+
+ if (regno >= state->nregs)
+ {
+ state->info = realloc (state->info, (regno + 1) * sizeof state->info[0]);
+ memset (&state->info[state->nregs], 0,
+ ((void *) &state->info[regno + 1]
+ - (void *) &state->info[state->nregs]));
+ state->nregs = regno + 1;
+ }
+
+ state->info[regno].regno = regno;
+ state->info[regno].set = setname;
+ state->info[regno].pfx = prefix;
+ state->info[regno].bits = bits;
+ state->info[regno].type = type;
+ assert (strlen (regname) < sizeof state->info[regno].name);
+ strcpy (state->info[regno].name, regname);
+
+ return DWARF_CB_OK;
+}
+
+
+static int
+match_register (void *arg,
+ int regno,
+ const char *setname,
+ const char *prefix,
+ const char *regname,
+ int bits, int type)
+{
+ if (regno == *(int *) arg)
+ printf ("%5d => %s register %s%s %s %d bits\n",
+ regno, setname, prefix, regname,
+ dwarf_encoding_string (type), bits);
+
+ return DWARF_CB_ABORT;
+}
+
+
+int
+main (int argc, char **argv)
+{
+ int remaining;
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ Dwfl *dwfl = NULL;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
+ assert (dwfl != NULL);
+
+ Dwfl_Module *mod = NULL;
+ if (dwfl_getmodules (dwfl, &first_module, &mod, 0) < 0)
+ error (EXIT_FAILURE, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
+
+ if (remaining == argc)
+ {
+ struct state state = { NULL, 0 };
+ int result = dwfl_module_register_names (mod, &one_register, &state);
+ if (result != 0 || state.nregs == 0)
+ error (EXIT_FAILURE, 0, "dwfl_module_register_names: %s",
+ result ? dwfl_errmsg (-1) : "no backend registers known");
+
+ qsort (state.info, state.nregs, sizeof state.info[0], &compare);
+
+ const char *set = NULL;
+ for (int i = 0; i < state.nregs; ++i)
+ if (state.info[i].set != NULL)
+ {
+ if (set != state.info[i].set)
+ printf ("%s registers:\n", state.info[i].set);
+ set = state.info[i].set;
+
+ printf ("\t%3d: %s%s (%s), %s %d bits\n",
+ state.info[i].regno,
+ state.info[i].pfx ?: "", state.info[i].name,
+ state.info[i].name,
+ dwarf_encoding_string (state.info[i].type),
+ state.info[i].bits);
+ }
+ free (state.info);
+ }
+ else
+ do
+ {
+ const char *arg = argv[remaining++];
+ int regno = atoi (arg);
+ int result = dwfl_module_register_names (mod, &match_register, ®no);
+ if (result != DWARF_CB_ABORT)
+ error (EXIT_FAILURE, 0, "dwfl_module_register_names: %s",
+ result ? dwfl_errmsg (-1) : "no backend registers known");
+ }
+ while (remaining < argc);
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/arextract.c b/tests/arextract.c
new file mode 100644
index 0000000..2c4dc75
--- /dev/null
+++ b/tests/arextract.c
@@ -0,0 +1,159 @@
+/* Copyright (C) 1999, 2000, 2002 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+ 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 <fcntl.h>
+#include <gelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <system.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int fd;
+ Elf *elf;
+ Elf *subelf;
+ Elf_Cmd cmd;
+ off_t offset;
+ size_t todo;
+
+ if (argc < 4)
+ exit (1);
+
+ /* Open the archive. */
+ fd = open (argv[1], O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("Cannot open input file: %m");
+ exit (1);
+ }
+
+ /* Set the ELF version. */
+ elf_version (EV_CURRENT);
+
+ /* Create an ELF descriptor. */
+ cmd = ELF_C_READ;
+ elf = elf_begin (fd, cmd, NULL);
+ if (elf == NULL)
+ {
+ printf ("Cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* If it is no archive punt. */
+ if (elf_kind (elf) != ELF_K_AR)
+ {
+ printf ("`%s' is no archive\n", argv[1]);
+ exit (1);
+ }
+
+ /* Get the elements of the archive one after the other. */
+ while ((subelf = elf_begin (fd, cmd, elf)) != NULL)
+ {
+ /* The the header for this element. */
+ Elf_Arhdr *arhdr = elf_getarhdr (subelf);
+
+ if (arhdr == NULL)
+ {
+ printf ("cannot get arhdr: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (strcmp (arhdr->ar_name, argv[2]) == 0)
+ {
+ int outfd;
+
+ /* Get the offset of the file in the archive. */
+ offset = elf_getbase (subelf);
+ if (offset == -1)
+ {
+ printf ("\
+Failed to get base address for the archive element: %s\n",
+ elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Open the output file. */
+ outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, 0666);
+ if (outfd == -1)
+ {
+ printf ("cannot open output file: %m");
+ exit (1);
+ }
+
+ /* Now write out the data. */
+ todo = arhdr->ar_size;
+ while (todo > 0)
+ {
+ char buf[1024];
+ ssize_t n = pread (fd, buf, MIN (sizeof buf, todo), offset);
+ if (n == 0)
+ break;
+
+ if (write (outfd, buf, n) != n)
+ {
+ puts ("Writing output failed");
+ exit (1);
+ }
+
+ offset += n;
+ todo -= n;
+ }
+
+ /* Check whether all the date was read and written out. */
+ if (todo != 0)
+ {
+ puts ("Reading archive member failed.");
+ exit (1);
+ }
+
+ /* Close the descriptors. */
+ if (elf_end (subelf) != 0 || elf_end (elf) != 0)
+ {
+ printf ("Freeing ELF descriptors failed: %s", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (outfd);
+ close (fd);
+
+ /* All went well. */
+ exit (0);
+ }
+
+ /* Get next archive element. */
+ cmd = elf_next (subelf);
+ if (elf_end (subelf) != 0)
+ {
+ printf ("error while freeing sub-ELF descriptor: %s\n",
+ elf_errmsg (-1));
+ exit (1);
+ }
+ }
+
+ /* When we reach this point we haven't found the given file in the
+ archive. */
+ printf ("File `%s' not found in archive\n", argv[2]);
+ exit (1);
+}
diff --git a/tests/arls.c b/tests/arls.c
new file mode 100644
index 0000000..ca0d3e6
--- /dev/null
+++ b/tests/arls.c
@@ -0,0 +1,111 @@
+/* Copyright (C) 2007 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 <ar.h>
+#include <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int handle (const char *fname);
+
+
+int
+main (int argc, char *argv[])
+{
+ elf_version (EV_CURRENT);
+
+ int result = 0;
+ if (argc == 1)
+ result = handle ("a.out");
+ else
+ for (int i = 1; i < argc; ++i)
+ result |= handle (argv[1]);
+
+ return result;
+}
+
+
+static int
+handle (const char *fname)
+{
+ int fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open '%s': %m\n", fname);
+ return 1;
+ }
+
+ Elf *elf = elf_begin (fd, ELF_C_READ_MMAP, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot get ELF handling for '%s': %s\n",
+ fname, elf_errmsg (-1));
+ close (fd);
+ return 1;
+ }
+
+ if (elf_kind (elf) != ELF_K_AR)
+ {
+ printf ("'%s' is no archive\n", fname);
+ elf_end (elf);
+ close (fd);
+ return 1;
+ }
+
+ printf ("%s:\n", fname);
+ Elf *subelf = NULL;
+ Elf_Cmd cmd = ELF_C_READ_MMAP;
+ while ((subelf = elf_begin (fd, cmd, elf)) != NULL)
+ {
+ Elf_Arhdr *arhdr = elf_getarhdr (subelf);
+ if (arhdr == NULL)
+ {
+ printf ("cannot get archive header in '%s': %s\n",
+ fname, elf_errmsg (-1));
+ elf_end (subelf);
+ elf_end (elf);
+ close (fd);
+ return 1;
+ }
+
+ off_t off = elf_getaroff (subelf);
+
+ printf ("\nOffset %llu\n"
+ " Name %s\n"
+ " Date %ld\n"
+ " UID %d\n"
+ " GID %d\n"
+ " Mode %o\n"
+ " Size %lld\n",
+ (unsigned long long int) off,
+ arhdr->ar_name, (long int) arhdr->ar_date, (int) arhdr->ar_uid,
+ (int) arhdr->ar_gid,
+ (int) arhdr->ar_mode, (long long int) arhdr->ar_size);
+
+ cmd = elf_next (subelf);
+ elf_end (subelf);
+ }
+
+ close (fd);
+
+ return 0;
+}
diff --git a/tests/arsymtest.c b/tests/arsymtest.c
new file mode 100644
index 0000000..c724863
--- /dev/null
+++ b/tests/arsymtest.c
@@ -0,0 +1,136 @@
+/* Copyright (C) 1999, 2000, 2002 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int fd;
+ FILE *fp;
+ Elf *elf;
+ Elf_Arsym *arsym;
+ size_t narsym;
+
+ if (argc < 3)
+ exit (1);
+
+ /* Open the archive. */
+ fd = open (argv[1], O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("Cannot open input file: %m");
+ exit (1);
+ }
+
+ /* Open the output file. */
+ fp = fopen (argv[2], "w");
+ if (fp == NULL)
+ {
+ printf ("Cannot open output file: %m");
+ exit (1);
+ }
+
+ /* Set the ELF version. */
+ elf_version (EV_CURRENT);
+
+ /* Create an ELF descriptor. */
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("Cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* If it is no archive punt. */
+ if (elf_kind (elf) != ELF_K_AR)
+ {
+ printf ("`%s' is no archive\n", argv[1]);
+ exit (1);
+ }
+
+ /* Now get the index of the archive. */
+ arsym = elf_getarsym (elf, &narsym);
+ if (arsym == NULL)
+ {
+ printf ("Cannot get archive index: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* If there is no element in the index do nothing. There always is
+ an empty entry at the end which is included in the count and
+ which we want to skip. */
+ if (narsym-- > 1)
+ while (narsym-- > 0)
+ {
+ Elf *subelf;
+ Elf_Arhdr *arhdr;
+
+ if (elf_rand (elf, arsym[narsym].as_off) != arsym[narsym].as_off)
+ {
+ printf ("random access for symbol `%s' fails: %s\n",
+ arsym[narsym].as_name, elf_errmsg (-1));
+ exit (1);
+ }
+
+ subelf = elf_begin (fd, ELF_C_READ, elf);
+ if (subelf == NULL)
+ {
+ printf ("Cannot create ELF descriptor for archive member: %s\n",
+ elf_errmsg (-1));
+ exit (1);
+ }
+
+ arhdr = elf_getarhdr (subelf);
+ if (arhdr == NULL)
+ {
+ printf ("Cannot get archive header for element `%s': %s\n",
+ arsym[narsym].as_name, elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Now print what we actually want. */
+ fprintf (fp, "%s in %s\n", arsym[narsym].as_name, arhdr->ar_name);
+
+ /* Free the ELF descriptor. */
+ if (elf_end (subelf) != 0)
+ {
+ printf ("Error while freeing subELF descriptor: %s\n",
+ elf_errmsg (-1));
+ exit (1);
+ }
+ }
+
+ /* Free the ELF descriptor. */
+ if (elf_end (elf) != 0)
+ {
+ printf ("Error while freeing ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+ fclose (fp);
+
+ return 0;
+}
diff --git a/tests/asm-tst1.c b/tests/asm-tst1.c
new file mode 100644
index 0000000..9afc676
--- /dev/null
+++ b/tests/asm-tst1.c
@@ -0,0 +1,256 @@
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static const char fname[] = "asm-tst1-out.o";
+
+
+static const GElf_Ehdr expected_ehdr =
+ {
+ .e_ident = { [EI_MAG0] = ELFMAG0,
+ [EI_MAG1] = ELFMAG1,
+ [EI_MAG2] = ELFMAG2,
+ [EI_MAG3] = ELFMAG3,
+ [EI_CLASS] = ELFCLASS32,
+ [EI_DATA] = ELFDATA2LSB,
+ [EI_VERSION] = EV_CURRENT },
+ .e_type = ET_REL,
+ .e_machine = EM_386,
+ .e_version = EV_CURRENT,
+ .e_shoff = 88,
+ .e_ehsize = sizeof (Elf32_Ehdr),
+ .e_shentsize = sizeof (Elf32_Shdr),
+ .e_shnum = 4,
+ .e_shstrndx = 3
+ };
+
+
+static const char *scnnames[4] =
+ {
+ [0] = "",
+ [1] = ".text",
+ [2] = ".data",
+ [3] = ".shstrtab"
+ };
+
+
+int
+main (void)
+{
+ AsmCtx_t *ctx;
+ AsmScn_t *scn1;
+ AsmScn_t *scn2;
+ int fd;
+ Elf *elf;
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr;
+ int result = 0;
+ size_t cnt;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ /* Create two sections. */
+ scn1 = asm_newscn (ctx, ".text", SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR);
+ scn2 = asm_newscn (ctx, ".data", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
+ if (scn1 == NULL || scn2 == NULL)
+ {
+ printf ("cannot create section in output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Special alignment for the .text section. */
+ if (asm_align (scn1, 32) != 0)
+ {
+ printf ("cannot align .text section: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Check the file. */
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open generated file: %m\n");
+ result = 1;
+ goto out;
+ }
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close;
+ }
+ if (elf_kind (elf) != ELF_K_ELF)
+ {
+ puts ("not a valid ELF file");
+ result = 1;
+ goto out_close2;
+ }
+
+ ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close2;
+ }
+
+ if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0)
+ {
+ puts ("ELF header does not match");
+ result = 1;
+ goto out_close2;
+ }
+
+ for (cnt = 1; cnt < 4; ++cnt)
+ {
+ Elf_Scn *scn;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr;
+
+ scn = elf_getscn (elf, cnt);
+ if (scn == NULL)
+ {
+ printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get section header for section %zd: %s\n",
+ cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ if (strcmp (elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ scnnames[cnt]) != 0)
+ {
+ printf ("section %zd's name differs: %s vs %s\n", cnt,
+ elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ scnnames[cnt]);
+ result = 1;
+ }
+
+ if (shdr->sh_type != (cnt == 3 ? SHT_STRTAB : SHT_PROGBITS))
+ {
+ printf ("section %zd's type differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_flags != (SHF_ALLOC | SHF_EXECINSTR))
+ || (cnt == 2 && shdr->sh_flags != (SHF_ALLOC | SHF_WRITE))
+ || (cnt == 3 && shdr->sh_flags != 0))
+ {
+ printf ("section %zd's flags differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_addr != 0)
+ {
+ printf ("section %zd's address differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_offset != ((sizeof (Elf32_Ehdr) + 31) & ~31))
+ {
+ printf ("section %zd's offset differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt != 3 && shdr->sh_size != 0)
+ || (cnt == 3 && shdr->sh_size != 23))
+ {
+ printf ("section %zd's size differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_link != 0)
+ {
+ printf ("section %zd's link differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_info != 0)
+ {
+ printf ("section %zd's info differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_addralign != 32)
+ || (cnt != 1 && shdr->sh_addralign != 1))
+ {
+ printf ("section %zd's addralign differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_entsize != 0)
+ {
+ printf ("section %zd's entsize differs\n", cnt);
+ result = 1;
+ }
+ }
+
+ out_close2:
+ elf_end (elf);
+ out_close:
+ close (fd);
+ out:
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/asm-tst2.c b/tests/asm-tst2.c
new file mode 100644
index 0000000..2556d0c
--- /dev/null
+++ b/tests/asm-tst2.c
@@ -0,0 +1,278 @@
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static const char fname[] = "asm-tst2-out.o";
+
+
+static const GElf_Ehdr expected_ehdr =
+ {
+ .e_ident = { [EI_MAG0] = ELFMAG0,
+ [EI_MAG1] = ELFMAG1,
+ [EI_MAG2] = ELFMAG2,
+ [EI_MAG3] = ELFMAG3,
+ [EI_CLASS] = ELFCLASS32,
+ [EI_DATA] = ELFDATA2LSB,
+ [EI_VERSION] = EV_CURRENT },
+ .e_type = ET_REL,
+ .e_machine = EM_386,
+ .e_version = EV_CURRENT,
+ .e_shoff = 96,
+ .e_ehsize = sizeof (Elf32_Ehdr),
+ .e_shentsize = sizeof (Elf32_Shdr),
+ .e_shnum = 3,
+ .e_shstrndx = 2
+ };
+
+
+static const char *scnnames[3] =
+ {
+ [0] = "",
+ [1] = ".data",
+ [2] = ".shstrtab"
+ };
+
+
+int
+main (void)
+{
+ AsmCtx_t *ctx;
+ AsmScn_t *scn1;
+ AsmScn_t *scn2;
+ int result = 0;
+ int fd;
+ Elf *elf;
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr;
+ size_t cnt;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ /* Create two sections. */
+ scn1 = asm_newscn (ctx, ".data", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
+ scn2 = asm_newsubscn (scn1, 1);
+ if (scn1 == NULL || scn2 == NULL)
+ {
+ printf ("cannot create section in output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Special alignment for the .text section. */
+ if (asm_align (scn1, 16) != 0)
+ {
+ printf ("cannot align .text section: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+
+ /* Add a few strings. */
+ if (asm_addstrz (scn1, "one", 4) != 0)
+ {
+ printf ("cannot insert first string: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+ if (asm_addstrz (scn2, "three", 0) != 0)
+ {
+ printf ("cannot insert second string: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+ if (asm_addstrz (scn1, "two", 4) != 0)
+ {
+ printf ("cannot insert third string: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Check the file. */
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open generated file: %m\n");
+ result = 1;
+ goto out;
+ }
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close;
+ }
+ if (elf_kind (elf) != ELF_K_ELF)
+ {
+ puts ("not a valid ELF file");
+ result = 1;
+ goto out_close2;
+ }
+
+ ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close2;
+ }
+
+ if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0)
+ {
+ puts ("ELF header does not match");
+ result = 1;
+ goto out_close2;
+ }
+
+ for (cnt = 1; cnt < 3; ++cnt)
+ {
+ Elf_Scn *scn;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr;
+
+ scn = elf_getscn (elf, cnt);
+ if (scn == NULL)
+ {
+ printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get section header for section %zd: %s\n",
+ cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ if (strcmp (elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ scnnames[cnt]) != 0)
+ {
+ printf ("section %zd's name differs: %s vs %s\n", cnt,
+ elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ scnnames[cnt]);
+ result = 1;
+ }
+
+ if (shdr->sh_type != (cnt == 2 ? SHT_STRTAB : SHT_PROGBITS))
+ {
+ printf ("section %zd's type differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_flags != (SHF_ALLOC | SHF_WRITE))
+ || (cnt == 2 && shdr->sh_flags != 0))
+ {
+ printf ("section %zd's flags differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_addr != 0)
+ {
+ printf ("section %zd's address differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_offset != ((sizeof (Elf32_Ehdr) + 15) & ~15))
+ || (cnt == 2
+ && shdr->sh_offset != (((sizeof (Elf32_Ehdr) + 15) & ~15)
+ + strlen ("one") + 1
+ + strlen ("two") + 1
+ + strlen ("three") + 1)))
+ {
+ printf ("section %zd's offset differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_size != (strlen ("one") + 1
+ + strlen ("two") + 1
+ + strlen ("three") + 1))
+ || (cnt == 2 && shdr->sh_size != 17))
+ {
+ printf ("section %zd's size differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_link != 0)
+ {
+ printf ("section %zd's link differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_info != 0)
+ {
+ printf ("section %zd's info differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_addralign != 16)
+ || (cnt != 1 && shdr->sh_addralign != 1))
+ {
+ printf ("section %zd's addralign differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_entsize != 0)
+ {
+ printf ("section %zd's entsize differs\n", cnt);
+ result = 1;
+ }
+ }
+
+ out_close2:
+ elf_end (elf);
+ out_close:
+ close (fd);
+ out:
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/asm-tst3.c b/tests/asm-tst3.c
new file mode 100644
index 0000000..e52cfbe
--- /dev/null
+++ b/tests/asm-tst3.c
@@ -0,0 +1,339 @@
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static const char fname[] = "asm-tst3-out.o";
+
+
+static const char *scnnames[5] =
+ {
+ [0] = "",
+ [1] = ".data",
+ [2] = ".strtab",
+ [3] = ".symtab",
+ [4] = ".shstrtab"
+ };
+
+
+static unsigned int scntypes[5] =
+ {
+ [0] = SHT_NULL,
+ [1] = SHT_PROGBITS,
+ [2] = SHT_STRTAB,
+ [3] = SHT_SYMTAB,
+ [4] = SHT_STRTAB
+ };
+
+
+int
+main (void)
+{
+ AsmCtx_t *ctx;
+ AsmScn_t *scn1;
+ AsmScn_t *scn2;
+ int result = 0;
+ int fd;
+ Elf *elf;
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr;
+ size_t cnt;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ /* Create two sections. */
+ scn1 = asm_newscn (ctx, ".data", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
+ scn2 = asm_newsubscn (scn1, 1);
+ if (scn1 == NULL || scn2 == NULL)
+ {
+ printf ("cannot create section in output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Special alignment for the .text section. */
+ if (asm_align (scn1, 16) != 0)
+ {
+ printf ("cannot align .text section: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+
+ /* Add a few strings with names. */
+ if (asm_newsym (scn1, "one", 4, STT_OBJECT, STB_GLOBAL) == NULL)
+ {
+ printf ("cannot create first name: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+ if (asm_addstrz (scn1, "one", 4) != 0)
+ {
+ printf ("cannot insert first string: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+ if (asm_newsym (scn2, "three", 6, STT_OBJECT, STB_WEAK) == NULL)
+ {
+ printf ("cannot create second name: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+ if (asm_addstrz (scn2, "three", 0) != 0)
+ {
+ printf ("cannot insert second string: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+ if (asm_newsym (scn1, "two", 4, STT_OBJECT, STB_LOCAL) == NULL)
+ {
+ printf ("cannot create third name: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+ if (asm_addstrz (scn1, "two", 4) != 0)
+ {
+ printf ("cannot insert third string: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Check the file. */
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open generated file: %m\n");
+ result = 1;
+ goto out;
+ }
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close;
+ }
+ if (elf_kind (elf) != ELF_K_ELF)
+ {
+ puts ("not a valid ELF file");
+ result = 1;
+ goto out_close2;
+ }
+
+ ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close2;
+ }
+
+ for (cnt = 1; cnt < 5; ++cnt)
+ {
+ Elf_Scn *scn;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr;
+
+ scn = elf_getscn (elf, cnt);
+ if (scn == NULL)
+ {
+ printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get section header for section %zd: %s\n",
+ cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ if (strcmp (elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ scnnames[cnt]) != 0)
+ {
+ printf ("section %zd's name differs: %s vs %s\n", cnt,
+ elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ scnnames[cnt]);
+ result = 1;
+ }
+
+ if (shdr->sh_type != scntypes[cnt])
+ {
+ printf ("section %zd's type differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_flags != (SHF_ALLOC | SHF_WRITE))
+ || (cnt != 1 && shdr->sh_flags != 0))
+ {
+ printf ("section %zd's flags differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_addr != 0)
+ {
+ printf ("section %zd's address differs\n", cnt);
+ result = 1;
+ }
+
+ if (cnt == 3)
+ {
+ Elf_Data *data;
+
+ if (shdr->sh_link != 2)
+ {
+ puts ("symbol table has incorrect link");
+ result = 1;
+ }
+
+ data = elf_getdata (scn, NULL);
+ if (data == NULL)
+ {
+ puts ("cannot get data of symbol table");
+ result = 1;
+ }
+ else
+ {
+ size_t inner;
+
+ for (inner = 1;
+ inner < (shdr->sh_size
+ / gelf_fsize (elf, ELF_T_SYM, 1, EV_CURRENT));
+ ++inner)
+ {
+ GElf_Sym sym_mem;
+ GElf_Sym *sym;
+
+ sym = gelf_getsym (data, inner, &sym_mem);
+ if (sym == NULL)
+ {
+ printf ("cannot get symbol %zu: %s\n",
+ inner, elf_errmsg (-1));
+ result = 1;
+ }
+ else
+ {
+ /* The order of the third and fourth entry depends
+ on how the hash table is organized. */
+ static const char *names[4] =
+ {
+ [0] = "",
+ [1] = "two",
+ [2] = "one",
+ [3] = "three"
+ };
+ static const int info[4] =
+ {
+ [0] = GELF_ST_INFO (STB_LOCAL, STT_NOTYPE),
+ [1] = GELF_ST_INFO (STB_LOCAL, STT_OBJECT),
+ [2] = GELF_ST_INFO (STB_GLOBAL, STT_OBJECT),
+ [3] = GELF_ST_INFO (STB_WEAK, STT_OBJECT)
+ };
+ static const unsigned value[4] =
+ {
+ [0] = 0,
+ [1] = 4,
+ [2] = 0,
+ [3] = 8
+ };
+
+ if (strcmp (names[inner],
+ elf_strptr (elf, shdr->sh_link,
+ sym->st_name)) != 0)
+ {
+ printf ("symbol %zu has different name\n", inner);
+ result = 1;
+ }
+
+ if (sym->st_value != value[inner])
+ {
+ printf ("symbol %zu has wrong value\n", inner);
+ result = 1;
+ }
+
+ if (sym->st_other != 0)
+ {
+ printf ("symbol %zu has wrong other info\n", inner);
+ result = 1;
+ }
+
+ if (sym->st_shndx != 1)
+ {
+ printf ("symbol %zu has wrong section reference\n",
+ inner);
+ result = 1;
+ }
+
+ if (sym->st_info != info[inner])
+ {
+ printf ("symbol %zu has wrong type or binding\n",
+ inner);
+ result = 1;
+ }
+
+ if ((inner != 3 && sym->st_size != 4)
+ || (inner == 3 && sym->st_size != 6))
+ {
+ printf ("symbol %zu has wrong size\n", inner);
+ result = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ out_close2:
+ elf_end (elf);
+ out_close:
+ close (fd);
+ out:
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/asm-tst4.c b/tests/asm-tst4.c
new file mode 100644
index 0000000..52e9e20
--- /dev/null
+++ b/tests/asm-tst4.c
@@ -0,0 +1,104 @@
+/* Copyright (C) 2002-2012 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static const char fname[] = "asm-tst4-out.o";
+
+
+int
+main (void)
+{
+ AsmCtx_t *ctx;
+ int result = 0;
+ size_t cnt;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ /* Create 66000 sections. */
+ for (cnt = 0; cnt < 66000; ++cnt)
+ {
+ char buf[20];
+ AsmScn_t *scn;
+
+ /* Create a unique name. */
+ snprintf (buf, sizeof (buf), ".data.%zu", cnt);
+
+ /* Create the section. */
+ scn = asm_newscn (ctx, buf, SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
+ if (scn == NULL)
+ {
+ printf ("cannot create section \"%s\" in output file: %s\n",
+ buf, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Add some content. */
+ if (asm_adduint32 (scn, cnt) != 0)
+ {
+ printf ("cannot create content of section \"%s\": %s\n",
+ buf, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ if (result == 0)
+ result = WEXITSTATUS (system ("../src/elflint -q asm-tst4-out.o"));
+
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/asm-tst5.c b/tests/asm-tst5.c
new file mode 100644
index 0000000..5a29b01
--- /dev/null
+++ b/tests/asm-tst5.c
@@ -0,0 +1,116 @@
+/* Copyright (C) 2002-2012 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#include "system.h"
+
+
+static const char fname[] = "asm-tst5-out.o";
+
+
+int
+main (void)
+{
+ AsmCtx_t *ctx;
+ int result = 0;
+ size_t cnt;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ /* Create 66000 sections. */
+ for (cnt = 0; cnt < 66000; ++cnt)
+ {
+ char buf[20];
+ AsmScn_t *scn;
+
+ /* Create a unique name. */
+ snprintf (buf, sizeof (buf), ".data.%zu", cnt);
+
+ /* Create the section. */
+ scn = asm_newscn (ctx, buf, SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
+ if (scn == NULL)
+ {
+ printf ("cannot create section \"%s\" in output file: %s\n",
+ buf, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Add a name. */
+ snprintf (buf, sizeof (buf), "%zu", cnt);
+ if (asm_newsym (scn, buf, sizeof (uint32_t), STT_OBJECT,
+ STB_GLOBAL) == NULL)
+ {
+ printf ("cannot create symbol \"%s\": %s\n", buf, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Add some content. */
+ if (asm_adduint32 (scn, cnt) != 0)
+ {
+ printf ("cannot create content of section \"%s\": %s\n",
+ buf, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ if (result == 0)
+ result = WEXITSTATUS (system ("../src/elflint -q asm-tst5-out.o"));
+
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/asm-tst6.c b/tests/asm-tst6.c
new file mode 100644
index 0000000..bd9b362
--- /dev/null
+++ b/tests/asm-tst6.c
@@ -0,0 +1,150 @@
+/* Copyright (C) 2002-2012 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#include <system.h>
+
+
+static const char fname[] = "asm-tst6-out.o";
+
+
+int
+main (void)
+{
+ AsmCtx_t *ctx;
+ int result = 0;
+ size_t cnt;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ for (cnt = 0; cnt < 22000; ++cnt)
+ {
+ char buf[512];
+ AsmScnGrp_t *grp;
+ AsmScn_t *scn;
+ AsmSym_t *sym;
+
+ snprintf (buf, sizeof (buf), ".grp%zu", cnt);
+ grp = asm_newscngrp (ctx, buf, NULL, 0);
+ if (grp == NULL)
+ {
+ printf ("cannot section group %zu: %s\n", cnt, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ scn = asm_newscn_ingrp (ctx, ".data", SHT_PROGBITS,
+ SHF_ALLOC | SHF_WRITE, grp);
+ if (scn == NULL)
+ {
+ printf ("cannot data section for group %zu: %s\n",
+ cnt, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Add a name. */
+ snprintf (buf, sizeof (buf), "%zu", cnt);
+ sym = asm_newsym (scn, buf, sizeof (uint32_t), STT_OBJECT,
+ STB_GLOBAL);
+ if (sym == NULL)
+ {
+ printf ("cannot create symbol \"%s\": %s\n", buf, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Add some content. */
+ if (asm_adduint32 (scn, cnt) != 0)
+ {
+ printf ("cannot create content of section \"%s\": %s\n",
+ buf, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Now we have a symbol, use it as the signature. */
+ if (asm_scngrp_newsignature (grp, sym) != 0)
+ {
+ printf ("cannot set signature for section group %zu: %s\n",
+ cnt, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Create a phony debug info section. */
+ scn = asm_newscn_ingrp (ctx, ".stab", SHT_PROGBITS, 0, grp);
+ if (scn == NULL)
+ {
+ printf ("cannot stab section for group %zu: %s\n",
+ cnt, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Add some content. */
+ if (asm_adduint32 (scn, cnt) != 0)
+ {
+ printf ("cannot create content of section \"%s\": %s\n",
+ buf, asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ if (result == 0)
+ result = WEXITSTATUS (system ("../src/elflint -q asm-tst6-out.o"));
+
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/asm-tst7.c b/tests/asm-tst7.c
new file mode 100644
index 0000000..00cb2bf
--- /dev/null
+++ b/tests/asm-tst7.c
@@ -0,0 +1,181 @@
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static const char fname[] = "asm-tst7-out.o";
+
+
+int
+main (void)
+{
+ int result = 0;
+ size_t cnt;
+ AsmCtx_t *ctx;
+ Elf *elf;
+ int fd;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ if (asm_newcomsym (ctx, "commsym", 4, 16) == NULL)
+ {
+ printf ("cannot create common symbol: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Check the file. */
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open generated file: %m\n");
+ result = 1;
+ goto out;
+ }
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close;
+ }
+ if (elf_kind (elf) != ELF_K_ELF)
+ {
+ puts ("not a valid ELF file");
+ result = 1;
+ goto out_close2;
+ }
+
+ for (cnt = 1; 1; ++cnt)
+ {
+ Elf_Scn *scn;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr;
+
+ scn = elf_getscn (elf, cnt);
+ if (scn == NULL)
+ {
+ printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get section header for section %zd: %s\n",
+ cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+ /* We are looking for the symbol table. */
+ if (shdr->sh_type != SHT_SYMTAB)
+ continue;
+
+ for (cnt = 1; cnt< (shdr->sh_size
+ / gelf_fsize (elf, ELF_T_SYM, 1, EV_CURRENT));
+ ++cnt)
+ {
+ GElf_Sym sym_mem;
+ GElf_Sym *sym;
+
+ if (cnt > 1)
+ {
+ puts ("too many symbol");
+ result = 1;
+ break;
+ }
+
+ sym = gelf_getsym (elf_getdata (scn, NULL), cnt, &sym_mem);
+ if (sym == NULL)
+ {
+ printf ("cannot get symbol %zu: %s\n", cnt, elf_errmsg (-1));
+ result = 1;
+ }
+ else
+ {
+ if (sym->st_shndx != SHN_COMMON)
+ {
+ printf ("expected common symbol, got section %u\n",
+ (unsigned int) sym->st_shndx);
+ result = 1;
+ }
+
+ if (sym->st_value != 16)
+ {
+ printf ("requested alignment 16, is %" PRIuMAX "\n",
+ (uintmax_t) sym->st_value);
+ result = 1;
+ }
+
+ if (sym->st_size != 4)
+ {
+ printf ("requested size 4, is %" PRIuMAX "\n",
+ (uintmax_t) sym->st_value);
+ result = 1;
+ }
+ }
+ }
+
+ break;
+ }
+
+ out_close2:
+ elf_end (elf);
+ out_close:
+ close (fd);
+ out:
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/asm-tst8.c b/tests/asm-tst8.c
new file mode 100644
index 0000000..4fb0d99
--- /dev/null
+++ b/tests/asm-tst8.c
@@ -0,0 +1,189 @@
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static const char fname[] = "asm-tst8-out.o";
+
+
+int
+main (void)
+{
+ int result = 0;
+ size_t cnt;
+ AsmCtx_t *ctx;
+ Elf *elf;
+ int fd;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ if (asm_newabssym (ctx, "tst8-out.s", 4, 0xfeedbeef, STT_FILE, STB_LOCAL)
+ == NULL)
+ {
+ printf ("cannot create absolute symbol: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Check the file. */
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open generated file: %m\n");
+ result = 1;
+ goto out;
+ }
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close;
+ }
+ if (elf_kind (elf) != ELF_K_ELF)
+ {
+ puts ("not a valid ELF file");
+ result = 1;
+ goto out_close2;
+ }
+
+ for (cnt = 1; 1; ++cnt)
+ {
+ Elf_Scn *scn;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr;
+
+ scn = elf_getscn (elf, cnt);
+ if (scn == NULL)
+ {
+ printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get section header for section %zd: %s\n",
+ cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+ /* We are looking for the symbol table. */
+ if (shdr->sh_type != SHT_SYMTAB)
+ continue;
+
+ for (cnt = 1; cnt< (shdr->sh_size
+ / gelf_fsize (elf, ELF_T_SYM, 1, EV_CURRENT));
+ ++cnt)
+ {
+ GElf_Sym sym_mem;
+ GElf_Sym *sym;
+
+ if (cnt > 1)
+ {
+ puts ("too many symbol");
+ result = 1;
+ break;
+ }
+
+ sym = gelf_getsym (elf_getdata (scn, NULL), cnt, &sym_mem);
+ if (sym == NULL)
+ {
+ printf ("cannot get symbol %zu: %s\n", cnt, elf_errmsg (-1));
+ result = 1;
+ }
+ else
+ {
+ if (sym->st_shndx != SHN_ABS)
+ {
+ printf ("expected common symbol, got section %u\n",
+ (unsigned int) sym->st_shndx);
+ result = 1;
+ }
+
+ if (sym->st_value != 0xfeedbeef)
+ {
+ printf ("requested value 0xfeedbeef, is %#" PRIxMAX "\n",
+ (uintmax_t) sym->st_value);
+ result = 1;
+ }
+
+ if (sym->st_size != 4)
+ {
+ printf ("requested size 4, is %" PRIuMAX "\n",
+ (uintmax_t) sym->st_value);
+ result = 1;
+ }
+
+ if (GELF_ST_TYPE (sym->st_info) != STT_FILE)
+ {
+ printf ("requested type FILE, is %u\n",
+ (unsigned int) GELF_ST_TYPE (sym->st_info));
+ result = 1;
+ }
+ }
+ }
+
+ break;
+ }
+
+ out_close2:
+ elf_end (elf);
+ out_close:
+ close (fd);
+ out:
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/asm-tst9.c b/tests/asm-tst9.c
new file mode 100644
index 0000000..b6d0e43
--- /dev/null
+++ b/tests/asm-tst9.c
@@ -0,0 +1,335 @@
+/* Copyright (C) 2002-2010 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(asm)
+#include <libelf.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static const char fname[] = "asm-tst9-out.o";
+
+
+static int32_t input[] =
+ {
+ 0, 1, 129, 510, 2000, 33000, 0x7ffffff, 0x7fffffff
+ };
+#define ninput (sizeof (input) / sizeof (input[0]))
+
+
+static const GElf_Ehdr expected_ehdr =
+ {
+ .e_ident = { [EI_MAG0] = ELFMAG0,
+ [EI_MAG1] = ELFMAG1,
+ [EI_MAG2] = ELFMAG2,
+ [EI_MAG3] = ELFMAG3,
+ [EI_CLASS] = ELFCLASS32,
+ [EI_DATA] = ELFDATA2LSB,
+ [EI_VERSION] = EV_CURRENT },
+ .e_type = ET_REL,
+ .e_machine = EM_386,
+ .e_version = EV_CURRENT,
+ .e_shoff = 180,
+ .e_ehsize = sizeof (Elf32_Ehdr),
+ .e_shentsize = sizeof (Elf32_Shdr),
+ .e_shnum = 3,
+ .e_shstrndx = 2
+ };
+
+
+static const char *scnnames[3] =
+ {
+ [0] = "",
+ [1] = ".data",
+ [2] = ".shstrtab"
+ };
+
+
+static const char expecteddata[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x7f,
+ 0x81, 0x01, 0x81, 0x01, 0xff, 0xfe, 0xff, 0xff, 0x0f, 0xff, 0x7e, 0xfe,
+ 0x03, 0xfe, 0x03, 0x82, 0xfc, 0xff, 0xff, 0x0f, 0x82, 0x7c, 0xd0, 0x0f,
+ 0xd0, 0x0f, 0xb0, 0xf0, 0xff, 0xff, 0x0f, 0xb0, 0x70, 0xe8, 0x81, 0x02,
+ 0xe8, 0x81, 0x02, 0x98, 0xfe, 0xfd, 0xff, 0x0f, 0x98, 0xfe, 0x7d, 0xff,
+ 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0x81, 0x80, 0x80, 0xc0, 0x0f,
+ 0x81, 0x80, 0x80, 0x40, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff,
+ 0xff, 0x07, 0x81, 0x80, 0x80, 0x80, 0x08, 0x81, 0x80, 0x80, 0x80, 0x78
+ };
+
+
+int
+main (void)
+{
+ AsmCtx_t *ctx;
+ AsmScn_t *scn;
+ int result = 0;
+ int fd;
+ Elf *elf;
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr;
+ size_t cnt;
+
+ elf_version (EV_CURRENT);
+
+ Ebl *ebl = ebl_openbackend_machine (EM_386);
+ if (ebl == NULL)
+ {
+ puts ("cannot open backend library");
+ return 1;
+ }
+
+ ctx = asm_begin (fname, ebl, false);
+ if (ctx == NULL)
+ {
+ printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
+ return 1;
+ }
+
+ /* Create two sections. */
+ scn = asm_newscn (ctx, ".data", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
+ if (scn == NULL)
+ {
+ printf ("cannot create section in output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Special alignment for the .text section. */
+ if (asm_align (scn, 16) != 0)
+ {
+ printf ("cannot align .text section: %s\n", asm_errmsg (-1));
+ result = 1;
+ }
+
+ /* Add a few ULEB128 and SLEB128 numbers. */
+ for (cnt = 0; cnt < ninput; ++cnt)
+ {
+ if (asm_adduleb128 (scn, input[cnt]) != 0)
+ {
+ printf ("cannot insert uleb %" PRIu32 ": %s\n",
+ (uint32_t) input[cnt], asm_errmsg (-1));
+ result = 1;
+ }
+
+ if (asm_addsleb128 (scn, input[cnt]) != 0)
+ {
+ printf ("cannot insert sleb %" PRId32 ": %s\n",
+ input[cnt], asm_errmsg (-1));
+ result = 1;
+ }
+
+ if (asm_adduleb128 (scn, -input[cnt]) != 0)
+ {
+ printf ("cannot insert uleb %" PRIu32 ": %s\n",
+ (uint32_t) -input[cnt], asm_errmsg (-1));
+ result = 1;
+ }
+
+ if (asm_addsleb128 (scn, -input[cnt]) != 0)
+ {
+ printf ("cannot insert sleb %" PRId32 ": %s\n",
+ -input[cnt], asm_errmsg (-1));
+ result = 1;
+ }
+ }
+
+ /* Create the output file. */
+ if (asm_end (ctx) != 0)
+ {
+ printf ("cannot create output file: %s\n", asm_errmsg (-1));
+ asm_abort (ctx);
+ return 1;
+ }
+
+ /* Check the file. */
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open generated file: %m\n");
+ result = 1;
+ goto out;
+ }
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close;
+ }
+ if (elf_kind (elf) != ELF_K_ELF)
+ {
+ puts ("not a valid ELF file");
+ result = 1;
+ goto out_close2;
+ }
+
+ ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ result = 1;
+ goto out_close2;
+ }
+
+ if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0)
+ {
+ puts ("ELF header does not match");
+ result = 1;
+ goto out_close2;
+ }
+
+ for (cnt = 1; cnt < 3; ++cnt)
+ {
+ Elf_Scn *escn;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr;
+
+ escn = elf_getscn (elf, cnt);
+ if (escn == NULL)
+ {
+ printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ shdr = gelf_getshdr (escn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get section header for section %zd: %s\n",
+ cnt, elf_errmsg (-1));
+ result = 1;
+ continue;
+ }
+
+ if (strcmp (elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ scnnames[cnt]) != 0)
+ {
+ printf ("section %zd's name differs: %s vs %s\n", cnt,
+ elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ scnnames[cnt]);
+ result = 1;
+ }
+
+ if (shdr->sh_type != (cnt == 2 ? SHT_STRTAB : SHT_PROGBITS))
+ {
+ printf ("section %zd's type differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_flags != (SHF_ALLOC | SHF_WRITE))
+ || (cnt == 2 && shdr->sh_flags != 0))
+ {
+ printf ("section %zd's flags differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_addr != 0)
+ {
+ printf ("section %zd's address differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_offset != ((sizeof (Elf32_Ehdr) + 15) & ~15))
+ || (cnt == 2
+ && shdr->sh_offset != (((sizeof (Elf32_Ehdr) + 15) & ~15)
+ + sizeof (expecteddata))))
+ {
+ printf ("section %zd's offset differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_size != sizeof (expecteddata))
+ || (cnt == 2 && shdr->sh_size != 17))
+ {
+ printf ("section %zd's size differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_link != 0)
+ {
+ printf ("section %zd's link differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_info != 0)
+ {
+ printf ("section %zd's info differs\n", cnt);
+ result = 1;
+ }
+
+ if ((cnt == 1 && shdr->sh_addralign != 16)
+ || (cnt != 1 && shdr->sh_addralign != 1))
+ {
+ printf ("section %zd's addralign differs\n", cnt);
+ result = 1;
+ }
+
+ if (shdr->sh_entsize != 0)
+ {
+ printf ("section %zd's entsize differs\n", cnt);
+ result = 1;
+ }
+
+ if (cnt == 1)
+ {
+ Elf_Data *data = elf_getdata (escn, NULL);
+
+ if (data == NULL)
+ {
+ printf ("cannot get data of section %zd\n", cnt);
+ result = 1;
+ }
+ else
+ {
+ if (data->d_size != sizeof (expecteddata))
+ {
+ printf ("data block size of section %zd wrong: got %zd, "
+ "expected 96\n", cnt, data->d_size);
+ result = 1;
+ }
+
+ if (memcmp (data->d_buf, expecteddata, sizeof (expecteddata))
+ != 0)
+ {
+ printf ("data block content of section %zd wrong\n", cnt);
+ result = 1;
+ }
+ }
+ }
+ }
+
+ out_close2:
+ elf_end (elf);
+ out_close:
+ close (fd);
+ out:
+ /* We don't need the file anymore. */
+ unlink (fname);
+
+ ebl_closebackend (ebl);
+
+ return result;
+}
diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c
new file mode 100644
index 0000000..2c27414
--- /dev/null
+++ b/tests/backtrace-child.c
@@ -0,0 +1,250 @@
+/* Test child for parent backtrace test.
+ Copyright (C) 2013, 2016 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/>. */
+
+/* Command line syntax: ./backtrace-child [--ptraceme|--gencore]
+ --ptraceme will call ptrace (PTRACE_TRACEME) in the two threads.
+ --gencore will call abort () at its end.
+ Main thread will signal SIGUSR2. Other thread will signal SIGUSR1.
+ There used to be a difference between x86_64 and other architectures.
+ To test getting a signal at the very first instruction of a function:
+ PC will get changed to function 'jmp' by backtrace.c function
+ prepare_thread. Then SIGUSR2 will be signalled to backtrace-child
+ which will invoke function sigusr2.
+ This is all done so that signal interrupts execution of the very first
+ instruction of a function. Properly handled unwind should not slip into
+ the previous unrelated function.
+ The tested functionality is arch-independent but the code reproducing it
+ has to be arch-specific.
+ On non-x86_64:
+ sigusr2 gets called by normal function call from function stdarg.
+ On any arch then sigusr2 calls raise (SIGUSR1) for --ptraceme.
+ abort () is called otherwise, expected for --gencore core dump.
+
+ Expected x86_64 output:
+ TID 10276:
+ # 0 0x7f7ab61e9e6b raise
+ # 1 0x7f7ab661af47 - 1 main
+ # 2 0x7f7ab5e3bb45 - 1 __libc_start_main
+ # 3 0x7f7ab661aa09 - 1 _start
+ TID 10278:
+ # 0 0x7f7ab61e9e6b raise
+ # 1 0x7f7ab661ab3c - 1 sigusr2
+ # 2 0x7f7ab5e4fa60 __restore_rt
+ # 3 0x7f7ab661ab47 jmp
+ # 4 0x7f7ab661ac92 - 1 stdarg
+ # 5 0x7f7ab661acba - 1 backtracegen
+ # 6 0x7f7ab661acd1 - 1 start
+ # 7 0x7f7ab61e2c53 - 1 start_thread
+ # 8 0x7f7ab5f0fdbd - 1 __clone
+
+ Expected non-x86_64 (i386) output; __kernel_vsyscall are skipped if found:
+ TID 10408:
+ # 0 0xf779f430 __kernel_vsyscall
+ # 1 0xf7771466 - 1 raise
+ # 2 0xf77c1d07 - 1 main
+ # 3 0xf75bd963 - 1 __libc_start_main
+ # 4 0xf77c1761 - 1 _start
+ TID 10412:
+ # 0 0xf779f430 __kernel_vsyscall
+ # 1 0xf7771466 - 1 raise
+ # 2 0xf77c18f4 - 1 sigusr2
+ # 3 0xf77c1a10 - 1 stdarg
+ # 4 0xf77c1a2c - 1 backtracegen
+ # 5 0xf77c1a48 - 1 start
+ # 6 0xf77699da - 1 start_thread
+ # 7 0xf769bbfe - 1 __clone
+
+ But the raise jmp patching was unreliable. It depends on the CFI for the raise()
+ function in glibc to be the same as for the jmp() function. This is not always
+ the case. Some newer glibc versions rewrote raise() and now the CFA is calculated
+ differently. So we disable raise jmp patching everywhere.
+ */
+
+#ifdef __x86_64__
+/* #define RAISE_JMP_PATCHING 1 */
+#endif
+
+#include <config.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <errno.h>
+#include <string.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#ifndef __linux__
+
+int
+main (int argc __attribute__ ((unused)), char **argv)
+{
+ fprintf (stderr, "%s: Unwinding not supported for this architecture\n",
+ argv[0]);
+ return 77;
+}
+
+#else /* __linux__ */
+#include <sys/ptrace.h>
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define NOINLINE_NOCLONE __attribute__ ((noinline, noclone))
+#else
+#define NOINLINE_NOCLONE __attribute__ ((noinline))
+#endif
+
+#define NORETURN __attribute__ ((noreturn))
+#define UNUSED __attribute__ ((unused))
+#define USED __attribute__ ((used))
+
+static int ptraceme, gencore;
+
+/* Execution will arrive here from jmp by an artificial ptrace-spawn signal. */
+
+static NOINLINE_NOCLONE void
+sigusr2 (int signo)
+{
+ assert (signo == SIGUSR2);
+ if (! gencore)
+ {
+ raise (SIGUSR1);
+ /* Do not return as stack may be invalid due to ptrace-patched PC to the
+ jmp function. */
+ pthread_exit (NULL);
+ /* Not reached. */
+ abort ();
+ }
+ /* Here we dump the core for --gencore. */
+ raise (SIGABRT);
+ /* Avoid tail call optimization for the raise call. */
+ asm volatile ("");
+}
+
+static NOINLINE_NOCLONE void
+dummy1 (void)
+{
+ asm volatile ("");
+}
+
+#ifdef RAISE_JMP_PATCHING
+static NOINLINE_NOCLONE USED void
+jmp (void)
+{
+ /* Not reached, signal will get ptrace-spawn to jump into sigusr2. */
+ abort ();
+}
+#endif
+
+static NOINLINE_NOCLONE void
+dummy2 (void)
+{
+ asm volatile ("");
+}
+
+static NOINLINE_NOCLONE NORETURN void
+stdarg (int f UNUSED, ...)
+{
+ sighandler_t sigusr2_orig = signal (SIGUSR2, sigusr2);
+ assert (sigusr2_orig == SIG_DFL);
+ errno = 0;
+ if (ptraceme)
+ {
+ long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
+ assert (errno == 0);
+ assert (l == 0);
+ }
+#ifdef RAISE_JMP_PATCHING
+ if (! gencore)
+ {
+ /* Execution will get PC patched into function jmp. */
+ raise (SIGUSR1);
+ }
+#endif
+ sigusr2 (SIGUSR2);
+ /* Not reached. */
+ abort ();
+}
+
+static NOINLINE_NOCLONE void
+dummy3 (void)
+{
+ asm volatile ("");
+}
+
+static NOINLINE_NOCLONE void
+backtracegen (void)
+{
+ stdarg (1);
+ /* Here should be no instruction after the stdarg call as it is noreturn
+ function. It must be stdarg so that it is a call and not jump (jump as
+ a tail-call). */
+}
+
+static NOINLINE_NOCLONE void
+dummy4 (void)
+{
+ asm volatile ("");
+}
+
+static void *
+start (void *arg UNUSED)
+{
+ backtracegen ();
+ /* Not reached. */
+ abort ();
+}
+
+int
+main (int argc UNUSED, char **argv)
+{
+ setbuf (stdout, NULL);
+ assert (*argv++);
+ ptraceme = (*argv && strcmp (*argv, "--ptraceme") == 0);
+ argv += ptraceme;
+ gencore = (*argv && strcmp (*argv, "--gencore") == 0);
+ argv += gencore;
+ assert (!*argv);
+ /* These dummy* functions are there so that each of their surrounding
+ functions has some unrelated code around. The purpose of some of the
+ tests is verify unwinding the very first / after the very last instruction
+ does not inappropriately slip into the unrelated code around. */
+ dummy1 ();
+ dummy2 ();
+ dummy3 ();
+ dummy4 ();
+ if (gencore)
+ printf ("%ld\n", (long) getpid ());
+ pthread_t thread;
+ int i = pthread_create (&thread, NULL, start, NULL);
+ // pthread_* functions do not set errno.
+ assert (i == 0);
+ if (ptraceme)
+ {
+ errno = 0;
+ long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
+ assert (errno == 0);
+ assert (l == 0);
+ }
+ if (gencore)
+ pthread_join (thread, NULL);
+ else
+ raise (SIGUSR2);
+ return 0;
+}
+
+#endif /* ! __linux__ */
+
diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
new file mode 100644
index 0000000..a387d8f
--- /dev/null
+++ b/tests/backtrace-data.c
@@ -0,0 +1,341 @@
+/* Test custom provided Dwfl_Thread_Callbacks vector.
+ Copyright (C) 2013 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/>. */
+
+/* Test custom provided Dwfl_Thread_Callbacks vector. Test mimics what
+ a ptrace based vector would do. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <error.h>
+#include <unistd.h>
+#include <dwarf.h>
+#if defined(__x86_64__) && defined(__linux__)
+#include <sys/resource.h>
+#include <sys/ptrace.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/user.h>
+#include <fcntl.h>
+#include <string.h>
+#include ELFUTILS_HEADER(dwfl)
+#endif
+
+#if !defined(__x86_64__) || !defined(__linux__)
+
+int
+main (int argc __attribute__ ((unused)), char **argv)
+{
+ fprintf (stderr, "%s: Unwinding not supported for this architecture\n",
+ argv[0]);
+ return 77;
+}
+
+#else /* __x86_64__ && __linux__ */
+
+/* The only arch specific code is set_initial_registers. */
+
+static int
+find_elf (Dwfl_Module *mod __attribute__ ((unused)),
+ void **userdata __attribute__ ((unused)),
+ const char *modname __attribute__ ((unused)),
+ Dwarf_Addr base __attribute__ ((unused)),
+ char **file_name __attribute__ ((unused)),
+ Elf **elfp __attribute__ ((unused)))
+{
+ /* Not used as modules are reported explicitly. */
+ assert (0);
+}
+
+static bool
+memory_read (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Word *result,
+ void *dwfl_arg __attribute__ ((unused)))
+{
+ pid_t child = dwfl_pid (dwfl);
+
+ errno = 0;
+ long l = ptrace (PTRACE_PEEKDATA, child, (void *) (uintptr_t) addr, NULL);
+
+ // The unwinder can ask for an invalid address.
+ // Don't assert on that but just politely refuse.
+ if (errno != 0) {
+ errno = 0;
+ return false;
+ }
+ *result = l;
+
+ return true;
+}
+
+/* Return filename and VMA address *BASEP where its mapping starts which
+ contains ADDR. */
+
+static char *
+maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep)
+{
+ char *fname;
+ int i = asprintf (&fname, "/proc/%ld/maps", (long) pid);
+ assert (errno == 0);
+ assert (i > 0);
+ FILE *f = fopen (fname, "r");
+ assert (errno == 0);
+ assert (f);
+ free (fname);
+ for (;;)
+ {
+ // 37e3c22000-37e3c23000 rw-p 00022000 00:11 49532 /lib64/ld-2.14.90.so */
+ unsigned long start, end, offset;
+ i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*x", &start, &end, &offset);
+ assert (errno == 0);
+ if (i != 3)
+ break;
+ char *filename = strdup ("");
+ assert (filename);
+ size_t filename_len = 0;
+ for (;;)
+ {
+ int c = fgetc (f);
+ assert (c != EOF);
+ if (c == '\n')
+ break;
+ if (c == ' ' && *filename == '\0')
+ continue;
+ filename = realloc (filename, filename_len + 2);
+ assert (filename);
+ filename[filename_len++] = c;
+ filename[filename_len] = '\0';
+ }
+ if (start <= addr && addr < end)
+ {
+ i = fclose (f);
+ assert (errno == 0);
+ assert (i == 0);
+
+ *basep = start - offset;
+ return filename;
+ }
+ free (filename);
+ }
+ *basep = 0;
+ return NULL;
+}
+
+/* Add module containing ADDR to the DWFL address space.
+
+ dwfl_report_elf call here violates Dwfl manipulation as one should call
+ dwfl_report only between dwfl_report_begin_add and dwfl_report_end.
+ Current elfutils implementation does not mind as dwfl_report_begin_add is
+ empty. */
+
+static Dwfl_Module *
+report_module (Dwfl *dwfl, pid_t child, Dwarf_Addr addr)
+{
+ GElf_Addr base;
+ char *long_name = maps_lookup (child, addr, &base);
+ if (!long_name)
+ return NULL; // not found
+ Dwfl_Module *mod = dwfl_report_elf (dwfl, long_name, long_name, -1,
+ base, false /* add_p_vaddr */);
+ assert (mod);
+ free (long_name);
+ assert (dwfl_addrmodule (dwfl, addr) == mod);
+ return mod;
+}
+
+static pid_t
+next_thread (Dwfl *dwfl, void *dwfl_arg __attribute__ ((unused)),
+ void **thread_argp)
+{
+ if (*thread_argp != NULL)
+ return 0;
+ /* Put arbitrary non-NULL value into *THREAD_ARGP as a marker so that this
+ function returns non-zero PID only once. */
+ *thread_argp = thread_argp;
+ return dwfl_pid (dwfl);
+}
+
+static bool
+set_initial_registers (Dwfl_Thread *thread,
+ void *thread_arg __attribute__ ((unused)))
+{
+ pid_t child = dwfl_pid (dwfl_thread_dwfl (thread));
+
+ struct user_regs_struct user_regs;
+ long l = ptrace (PTRACE_GETREGS, child, NULL, &user_regs);
+ assert (errno == 0);
+ assert (l == 0);
+
+ Dwarf_Word dwarf_regs[17];
+ dwarf_regs[0] = user_regs.rax;
+ dwarf_regs[1] = user_regs.rdx;
+ dwarf_regs[2] = user_regs.rcx;
+ dwarf_regs[3] = user_regs.rbx;
+ dwarf_regs[4] = user_regs.rsi;
+ dwarf_regs[5] = user_regs.rdi;
+ dwarf_regs[6] = user_regs.rbp;
+ dwarf_regs[7] = user_regs.rsp;
+ dwarf_regs[8] = user_regs.r8;
+ dwarf_regs[9] = user_regs.r9;
+ dwarf_regs[10] = user_regs.r10;
+ dwarf_regs[11] = user_regs.r11;
+ dwarf_regs[12] = user_regs.r12;
+ dwarf_regs[13] = user_regs.r13;
+ dwarf_regs[14] = user_regs.r14;
+ dwarf_regs[15] = user_regs.r15;
+ dwarf_regs[16] = user_regs.rip;
+ bool ok = dwfl_thread_state_registers (thread, 0, 17, dwarf_regs);
+ assert (ok);
+
+ /* x86_64 has PC contained in its CFI subset of DWARF register set so
+ elfutils will figure out the real PC value from REGS.
+ So no need to explicitly call dwfl_thread_state_register_pc. */
+
+ return true;
+}
+
+static const Dwfl_Thread_Callbacks callbacks =
+{
+ next_thread,
+ NULL, /* get_thread */
+ memory_read,
+ set_initial_registers,
+ NULL, /* detach */
+ NULL, /* thread_detach */
+};
+
+static int
+frame_callback (Dwfl_Frame *state, void *arg)
+{
+ unsigned *framenop = arg;
+ Dwarf_Addr pc;
+ bool isactivation;
+ if (! dwfl_frame_pc (state, &pc, &isactivation))
+ {
+ error (1, 0, "%s", dwfl_errmsg (-1));
+ return 1;
+ }
+ Dwarf_Addr pc_adjusted = pc - (isactivation ? 0 : 1);
+
+ /* Get PC->SYMNAME. */
+ Dwfl *dwfl = dwfl_thread_dwfl (dwfl_frame_thread (state));
+ Dwfl_Module *mod = dwfl_addrmodule (dwfl, pc_adjusted);
+ if (mod == NULL)
+ mod = report_module (dwfl, dwfl_pid (dwfl), pc_adjusted);
+ const char *symname = NULL;
+ symname = dwfl_module_addrname (mod, pc_adjusted);
+
+ printf ("#%2u %#" PRIx64 "%4s\t%s\n", (*framenop)++, (uint64_t) pc,
+ ! isactivation ? "- 1" : "", symname);
+ return DWARF_CB_OK;
+}
+
+static int
+thread_callback (Dwfl_Thread *thread, void *thread_arg __attribute__ ((unused)))
+{
+ unsigned frameno = 0;
+ switch (dwfl_thread_getframes (thread, frame_callback, &frameno))
+ {
+ case 0:
+ break;
+ case -1:
+ error (1, 0, "dwfl_thread_getframes: %s", dwfl_errmsg (-1));
+ break;
+ default:
+ abort ();
+ }
+ return DWARF_CB_OK;
+}
+
+int
+main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ __fsetlocking (stdin, FSETLOCKING_BYCALLER);
+ __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+ __fsetlocking (stderr, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ elf_version (EV_CURRENT);
+
+ pid_t child = fork ();
+ switch (child)
+ {
+ case -1:
+ assert (errno == 0);
+ assert (0);
+ case 0:;
+ long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
+ assert (errno == 0);
+ assert (l == 0);
+ raise (SIGUSR1);
+ return 0;
+ default:
+ break;
+ }
+
+ int status;
+ pid_t pid = waitpid (child, &status, 0);
+ assert (errno == 0);
+ assert (pid == child);
+ assert (WIFSTOPPED (status));
+ assert (WSTOPSIG (status) == SIGUSR1);
+
+ static char *debuginfo_path;
+ static const Dwfl_Callbacks offline_callbacks =
+ {
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ .debuginfo_path = &debuginfo_path,
+ .section_address = dwfl_offline_section_address,
+ .find_elf = find_elf,
+ };
+ Dwfl *dwfl = dwfl_begin (&offline_callbacks);
+ assert (dwfl);
+
+ struct user_regs_struct user_regs;
+ long l = ptrace (PTRACE_GETREGS, child, NULL, &user_regs);
+ assert (errno == 0);
+ assert (l == 0);
+ report_module (dwfl, child, user_regs.rip);
+
+ bool ok = dwfl_attach_state (dwfl, EM_NONE, child, &callbacks, NULL);
+ assert (ok);
+
+ /* Multiple threads are not handled here. */
+ int err = dwfl_getthreads (dwfl, thread_callback, NULL);
+ assert (! err);
+
+ dwfl_end (dwfl);
+ kill (child, SIGKILL);
+ pid = waitpid (child, &status, 0);
+ assert (errno == 0);
+ assert (pid == child);
+ assert (WIFSIGNALED (status));
+ assert (WTERMSIG (status) == SIGKILL);
+
+ return EXIT_SUCCESS;
+}
+
+#endif /* x86_64 */
diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
new file mode 100644
index 0000000..2dc8a9a
--- /dev/null
+++ b/tests/backtrace-dwarf.c
@@ -0,0 +1,170 @@
+/* Test program for unwinding of complicated DWARF expressions.
+ Copyright (C) 2013, 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <signal.h>
+#include <inttypes.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <errno.h>
+#include <error.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include ELFUTILS_HEADER(dwfl)
+
+#ifndef __linux__
+
+int
+main (int argc __attribute__ ((unused)), char **argv)
+{
+ fprintf (stderr, "%s: Unwinding not supported for this architecture\n",
+ argv[0]);
+ return 77;
+}
+
+#else /* __linux__ */
+#include <sys/ptrace.h>
+
+#define main cleanup_13_main
+#include "cleanup-13.c"
+#undef main
+
+static void
+report_pid (Dwfl *dwfl, pid_t pid)
+{
+ int result = dwfl_linux_proc_report (dwfl, pid);
+ if (result < 0)
+ error (2, 0, "dwfl_linux_proc_report: %s", dwfl_errmsg (-1));
+ else if (result > 0)
+ error (2, result, "dwfl_linux_proc_report");
+
+ if (dwfl_report_end (dwfl, NULL, NULL) != 0)
+ error (2, 0, "dwfl_report_end: %s", dwfl_errmsg (-1));
+
+ result = dwfl_linux_proc_attach (dwfl, pid, true);
+ if (result < 0)
+ error (2, 0, "dwfl_linux_proc_attach: %s", dwfl_errmsg (-1));
+ else if (result > 0)
+ error (2, result, "dwfl_linux_proc_attach");
+}
+
+static Dwfl *
+pid_to_dwfl (pid_t pid)
+{
+ static char *debuginfo_path;
+ static const Dwfl_Callbacks proc_callbacks =
+ {
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ .debuginfo_path = &debuginfo_path,
+
+ .find_elf = dwfl_linux_proc_find_elf,
+ };
+ Dwfl *dwfl = dwfl_begin (&proc_callbacks);
+ if (dwfl == NULL)
+ error (2, 0, "dwfl_begin: %s", dwfl_errmsg (-1));
+ report_pid (dwfl, pid);
+ return dwfl;
+}
+
+static int
+frame_callback (Dwfl_Frame *state, void *frame_arg)
+{
+ Dwarf_Addr pc;
+ bool isactivation;
+ if (! dwfl_frame_pc (state, &pc, &isactivation))
+ {
+ error (0, 0, "%s", dwfl_errmsg (-1));
+ return DWARF_CB_ABORT;
+ }
+ Dwarf_Addr pc_adjusted = pc - (isactivation ? 0 : 1);
+
+ /* Get PC->SYMNAME. */
+ Dwfl_Thread *thread = dwfl_frame_thread (state);
+ Dwfl *dwfl = dwfl_thread_dwfl (thread);
+ Dwfl_Module *mod = dwfl_addrmodule (dwfl, pc_adjusted);
+ const char *symname = NULL;
+ if (mod)
+ symname = dwfl_module_addrname (mod, pc_adjusted);
+
+ printf ("%#" PRIx64 "\t%s\n", (uint64_t) pc, symname);
+
+ if (symname && (strcmp (symname, "main") == 0
+ || strcmp (symname, ".main") == 0))
+ {
+ kill (dwfl_pid (dwfl), SIGKILL);
+ exit (0);
+ }
+
+ return DWARF_CB_OK;
+}
+
+static int
+thread_callback (Dwfl_Thread *thread, void *thread_arg)
+{
+ dwfl_thread_getframes (thread, frame_callback, NULL);
+ /* frame_callback shall exit (0) on success. */
+ error (1, 0, "dwfl_thread_getframes: %s", dwfl_errmsg (-1));
+ return DWARF_CB_ABORT;
+}
+
+int
+main (int argc __attribute__ ((unused)), char **argv)
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ __fsetlocking (stdin, FSETLOCKING_BYCALLER);
+ __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+ __fsetlocking (stderr, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ elf_version (EV_CURRENT);
+
+ pid_t pid = fork ();
+ switch (pid)
+ {
+ case -1:
+ abort ();
+ case 0:;
+ long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
+ assert (errno == 0);
+ assert (l == 0);
+ cleanup_13_main ();
+ abort ();
+ default:
+ break;
+ }
+
+ errno = 0;
+ int status;
+ pid_t got = waitpid (pid, &status, 0);
+ assert (errno == 0);
+ assert (got == pid);
+ assert (WIFSTOPPED (status));
+ assert (WSTOPSIG (status) == SIGABRT);
+
+ Dwfl *dwfl = pid_to_dwfl (pid);
+ dwfl_getthreads (dwfl, thread_callback, NULL);
+
+ /* There is an exit (0) call if we find the "main" frame, */
+ error (1, 0, "dwfl_getthreads: %s", dwfl_errmsg (-1));
+}
+
+#endif /* ! __linux__ */
+
diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh
new file mode 100644
index 0000000..e04a7ea
--- /dev/null
+++ b/tests/backtrace-subr.sh
@@ -0,0 +1,195 @@
+# Copyright (C) 2013, 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
+
+# Verify one of the backtraced threads contains function 'main'.
+check_main()
+{
+ if grep -w main $1; then
+ return
+ fi
+ echo >&2 $2: no main
+ false
+}
+
+# Without proper ELF symbols resolution we could get inappropriate weak
+# symbol "gsignal" with the same address as the correct symbol "raise".
+# It was fixed by GIT commit 78dec228b3cfb2f9300cd0b682ebf416c9674c91 .
+# [patch] Improve ELF symbols preference (global > weak)
+# https://lists.fedorahosted.org/pipermail/elfutils-devel/2012-October/002624.html
+check_gsignal()
+{
+ if ! grep -w gsignal $1; then
+ return
+ fi
+ echo >&2 $2: found gsignal
+ false
+}
+
+
+# Makes sure we saw the function that initiated the backtrace
+# when the core was generated through the tests backtrace --gencore.
+# This might disappear when frame pointer chasing gone bad.
+check_backtracegen()
+{
+ if grep -w backtracegen $1; then
+ return
+ fi
+ echo >&2 $2: no backtracegen
+ false
+}
+
+# Verify the STDERR output does not contain unexpected errors.
+# In some cases we cannot reliably find out we got behind _start as some
+# operating system do not properly terminate CFI by undefined PC.
+# Ignore it here as it is a bug of OS, not a bug of elfutils.
+check_err()
+{
+ if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range|address out of range|Invalid register|\(null\))$' \
+ | wc -c) \
+ -eq 0 ]
+ then
+ return
+ fi
+ echo >&2 $2: neither empty nor just out of DWARF
+ false
+}
+
+check_all()
+{
+ bt=$1
+ err=$2
+ testname=$3
+ check_main $bt $testname
+ check_gsignal $bt $testname
+ check_err $err $testname
+}
+
+check_unsupported()
+{
+ err=$1
+ testname=$2
+ if grep -q ': Unwinding not supported for this architecture$' $err; then
+ echo >&2 $testname: arch not supported
+ exit 77
+ fi
+}
+
+check_native_unsupported()
+{
+ err=$1
+ testname=$2
+ check_unsupported $err $testname
+
+ # ARM is special. It is supported, but it doesn't use .eh_frame by default
+ # making the native tests fail unless debuginfo (for glibc) is installed
+ # and we can fall back on .debug_frame for the CFI.
+ case "`uname -m`" in
+ arm* )
+ if egrep 'dwfl_thread_getframes(.*)No DWARF information found' $err; then
+ echo >&2 $testname: arm needs debuginfo installed for all libraries
+ exit 77
+ fi
+ ;;
+ esac
+}
+
+check_core()
+{
+ arch=$1
+ testfiles backtrace.$arch.{exec,core}
+ tempfiles backtrace.$arch.{bt,err}
+ echo ./backtrace ./backtrace.$arch.{exec,core}
+ testrun ${abs_builddir}/backtrace -e ./backtrace.$arch.exec --core=./backtrace.$arch.core 1>backtrace.$arch.bt 2>backtrace.$arch.err || true
+ cat backtrace.$arch.{bt,err}
+ check_unsupported backtrace.$arch.err backtrace.$arch.core
+ check_all backtrace.$arch.{bt,err} backtrace.$arch.core
+ check_backtracegen backtrace.$arch.bt backtrace.$arch.core
+}
+
+# Backtrace live process.
+# Do not abort on non-zero exit code due to some warnings of ./backtrace
+# - see function check_err.
+check_native()
+{
+ child=$1
+ tempfiles $child.{bt,err}
+ (set +ex; testrun ${abs_builddir}/backtrace --backtrace-exec=${abs_builddir}/$child 1>$child.bt 2>$child.err; true)
+ cat $child.{bt,err}
+ check_native_unsupported $child.err $child
+ check_all $child.{bt,err} $child
+}
+
+# Backtrace core file.
+check_native_core()
+{
+# systemd-coredump/coredumpctl doesn't seem to like concurrent core dumps
+# use a lock file (fd 200) tests/core-dump-backtrace.lock
+(
+ child=$1
+
+ # Disable valgrind while dumping core.
+ SAVED_VALGRIND_CMD="$VALGRIND_CMD"
+ unset VALGRIND_CMD
+
+ # Wait for lock for 10 seconds or skip.
+ flock -x -w 10 200 || exit 77;
+
+ # Skip the test if we cannot adjust core ulimit.
+ pid="`ulimit -c unlimited || exit 77; set +ex; testrun ${abs_builddir}/$child --gencore; true`"
+ core="core.$pid"
+ # see if /proc/sys/kernel/core_uses_pid is set to 0
+ if [ -f core ]; then
+ mv core "$core"
+ fi
+ type -P coredumpctl && have_coredumpctl=1 || have_coredumpctl=0
+ if [ ! -f "$core" -a $have_coredumpctl -eq 1 ]; then
+ # Maybe systemd-coredump took it. But give it some time to dump first...
+ sleep 1
+ coredumpctl --output="$core" dump $pid || rm -f $core
+
+ # Try a couple of times after waiting some more if something went wrong...
+ if [ ! -f "$core" ]; then
+ sleep 2
+ coredumpctl --output="$core" dump $pid || rm -f $core
+ fi
+
+ if [ ! -f "$core" ]; then
+ sleep 3
+ coredumpctl --output="$core" dump $pid || rm -f $core
+ fi
+ fi
+ if [ ! -f "$core" ]; then
+ echo "No $core file generated";
+ exit 77;
+ fi
+
+ if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
+ VALGRIND_CMD="$SAVED_VALGRIND_CMD"
+ export VALGRIND_CMD
+ fi
+
+ # Do not abort on non-zero exit code due to some warnings of ./backtrace
+ # - see function check_err.
+ tempfiles $core{,.{bt,err}}
+ (set +ex; testrun ${abs_builddir}/backtrace -e ${abs_builddir}/$child --core=$core 1>$core.bt 2>$core.err; true)
+ cat $core.{bt,err}
+ check_native_unsupported $core.err $child-$core
+ check_all $core.{bt,err} $child-$core
+ rm $core{,.{bt,err}}
+) 200>${abs_builddir}/core-dump-backtrace.lock
+}
diff --git a/tests/backtrace.aarch64.core.bz2 b/tests/backtrace.aarch64.core.bz2
new file mode 100644
index 0000000..3082a5a
--- /dev/null
+++ b/tests/backtrace.aarch64.core.bz2
Binary files differ
diff --git a/tests/backtrace.aarch64.exec.bz2 b/tests/backtrace.aarch64.exec.bz2
new file mode 100755
index 0000000..66216b5
--- /dev/null
+++ b/tests/backtrace.aarch64.exec.bz2
Binary files differ
diff --git a/tests/backtrace.aarch64.fp.core.bz2 b/tests/backtrace.aarch64.fp.core.bz2
new file mode 100644
index 0000000..ff86788
--- /dev/null
+++ b/tests/backtrace.aarch64.fp.core.bz2
Binary files differ
diff --git a/tests/backtrace.aarch64.fp.exec.bz2 b/tests/backtrace.aarch64.fp.exec.bz2
new file mode 100644
index 0000000..9d06db1
--- /dev/null
+++ b/tests/backtrace.aarch64.fp.exec.bz2
Binary files differ
diff --git a/tests/backtrace.c b/tests/backtrace.c
new file mode 100644
index 0000000..f5dd761
--- /dev/null
+++ b/tests/backtrace.c
@@ -0,0 +1,500 @@
+/* Test program for unwinding of frames.
+ Copyright (C) 2013, 2014, 2016 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <error.h>
+#include <unistd.h>
+#include <dwarf.h>
+#ifdef __linux__
+#include <sys/resource.h>
+#include <sys/ptrace.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/user.h>
+#include <fcntl.h>
+#include <string.h>
+#include <argp.h>
+#include ELFUTILS_HEADER(dwfl)
+#endif
+
+#ifndef __linux__
+
+int
+main (int argc __attribute__ ((unused)), char **argv)
+{
+ fprintf (stderr, "%s: Unwinding not supported for this architecture\n",
+ argv[0]);
+ return 77;
+}
+
+#else /* __linux__ */
+
+static int
+dump_modules (Dwfl_Module *mod, void **userdata __attribute__ ((unused)),
+ const char *name, Dwarf_Addr start,
+ void *arg __attribute__ ((unused)))
+{
+ Dwarf_Addr end;
+ dwfl_module_info (mod, NULL, NULL, &end, NULL, NULL, NULL, NULL);
+ printf ("%#" PRIx64 "\t%#" PRIx64 "\t%s\n", (uint64_t) start, (uint64_t) end,
+ name);
+ return DWARF_CB_OK;
+}
+
+static bool use_raise_jmp_patching;
+static pid_t check_tid;
+
+static void
+callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc,
+ const char *symname, Dwfl *dwfl)
+{
+ static bool seen_main = false;
+ if (symname && *symname == '.')
+ symname++;
+ if (symname && strcmp (symname, "main") == 0)
+ seen_main = true;
+ if (pc == 0)
+ {
+ assert (seen_main);
+ return;
+ }
+ if (check_tid == 0)
+ check_tid = tid;
+ if (tid != check_tid)
+ {
+ // For the main thread we are only interested if we can unwind till
+ // we see the "main" symbol.
+ return;
+ }
+ Dwfl_Module *mod;
+ /* See case 4. Special case to help out simple frame pointer unwinders. */
+ static bool duplicate_sigusr2 = false;
+ if (duplicate_sigusr2)
+ frameno--;
+ static bool reduce_frameno = false;
+ if (reduce_frameno)
+ frameno--;
+ if (! use_raise_jmp_patching && frameno >= 2)
+ frameno += 2;
+ const char *symname2 = NULL;
+ switch (frameno)
+ {
+ case 0:
+ if (! reduce_frameno && symname
+ && (strcmp (symname, "__kernel_vsyscall") == 0
+ || strcmp (symname, "__libc_do_syscall") == 0))
+ reduce_frameno = true;
+ else
+ assert (symname && strcmp (symname, "raise") == 0);
+ break;
+ case 1:
+ assert (symname != NULL && strcmp (symname, "sigusr2") == 0);
+ break;
+ case 2: // x86_64 only
+ /* __restore_rt - glibc maybe does not have to have this symbol. */
+ break;
+ case 3: // use_raise_jmp_patching
+ if (use_raise_jmp_patching)
+ {
+ /* Verify we trapped on the very first instruction of jmp. */
+ assert (symname != NULL && strcmp (symname, "jmp") == 0);
+ mod = dwfl_addrmodule (dwfl, pc - 1);
+ if (mod)
+ symname2 = dwfl_module_addrname (mod, pc - 1);
+ assert (symname2 == NULL || strcmp (symname2, "jmp") != 0);
+ break;
+ }
+ FALLTHROUGH;
+ case 4:
+ /* Some simple frame unwinders get this wrong and think sigusr2
+ is calling itself again. Allow it and just pretend there is
+ an extra sigusr2 frame. */
+ if (symname != NULL && strcmp (symname, "sigusr2") == 0)
+ {
+ duplicate_sigusr2 = true;
+ break;
+ }
+ assert (symname != NULL && strcmp (symname, "stdarg") == 0);
+ break;
+ case 5:
+ /* Verify we trapped on the very last instruction of child. */
+ assert (symname != NULL && strcmp (symname, "backtracegen") == 0);
+ mod = dwfl_addrmodule (dwfl, pc);
+ if (mod)
+ symname2 = dwfl_module_addrname (mod, pc);
+
+ // Note that the following assert might in theory even fail on x86_64,
+ // there is no guarantee that the compiler doesn't reorder the
+ // instructions or even inserts some padding instructions at the end
+ // (which apparently happens on ppc64).
+ if (use_raise_jmp_patching)
+ assert (symname2 == NULL || strcmp (symname2, "backtracegen") != 0);
+ break;
+ }
+}
+
+static int
+frame_callback (Dwfl_Frame *state, void *frame_arg)
+{
+ int *framenop = frame_arg;
+ Dwarf_Addr pc;
+ bool isactivation;
+
+ if (*framenop > 16)
+ {
+ error (0, 0, "Too many frames: %d\n", *framenop);
+ return DWARF_CB_ABORT;
+ }
+
+ if (! dwfl_frame_pc (state, &pc, &isactivation))
+ {
+ error (0, 0, "%s", dwfl_errmsg (-1));
+ return DWARF_CB_ABORT;
+ }
+ Dwarf_Addr pc_adjusted = pc - (isactivation ? 0 : 1);
+
+ /* Get PC->SYMNAME. */
+ Dwfl_Thread *thread = dwfl_frame_thread (state);
+ Dwfl *dwfl = dwfl_thread_dwfl (thread);
+ Dwfl_Module *mod = dwfl_addrmodule (dwfl, pc_adjusted);
+ const char *symname = NULL;
+ if (mod)
+ symname = dwfl_module_addrname (mod, pc_adjusted);
+
+ printf ("#%2d %#" PRIx64 "%4s\t%s\n", *framenop, (uint64_t) pc,
+ ! isactivation ? "- 1" : "", symname);
+ pid_t tid = dwfl_thread_tid (thread);
+ callback_verify (tid, *framenop, pc, symname, dwfl);
+ (*framenop)++;
+
+ return DWARF_CB_OK;
+}
+
+static int
+thread_callback (Dwfl_Thread *thread, void *thread_arg __attribute__((unused)))
+{
+ printf ("TID %ld:\n", (long) dwfl_thread_tid (thread));
+ int frameno = 0;
+ switch (dwfl_thread_getframes (thread, frame_callback, &frameno))
+ {
+ case 0:
+ break;
+ case DWARF_CB_ABORT:
+ return DWARF_CB_ABORT;
+ case -1:
+ error (0, 0, "dwfl_thread_getframes: %s", dwfl_errmsg (-1));
+ /* All platforms do not have yet proper unwind termination. */
+ break;
+ default:
+ abort ();
+ }
+ return DWARF_CB_OK;
+}
+
+static void
+dump (Dwfl *dwfl)
+{
+ ptrdiff_t ptrdiff = dwfl_getmodules (dwfl, dump_modules, NULL, 0);
+ assert (ptrdiff == 0);
+ bool err = false;
+ switch (dwfl_getthreads (dwfl, thread_callback, NULL))
+ {
+ case 0:
+ break;
+ case DWARF_CB_ABORT:
+ err = true;
+ break;
+ case -1:
+ error (0, 0, "dwfl_getthreads: %s", dwfl_errmsg (-1));
+ err = true;
+ break;
+ default:
+ abort ();
+ }
+ callback_verify (0, 0, 0, NULL, dwfl);
+ if (err)
+ exit (EXIT_FAILURE);
+}
+
+struct see_exec_module
+{
+ Dwfl_Module *mod;
+ char selfpath[PATH_MAX + 1];
+};
+
+static int
+see_exec_module (Dwfl_Module *mod, void **userdata __attribute__ ((unused)),
+ const char *name __attribute__ ((unused)),
+ Dwarf_Addr start __attribute__ ((unused)), void *arg)
+{
+ struct see_exec_module *data = arg;
+ if (strcmp (name, data->selfpath) != 0)
+ return DWARF_CB_OK;
+ assert (data->mod == NULL);
+ data->mod = mod;
+ return DWARF_CB_ABORT;
+}
+
+/* We used to do this on x86_64 only (see backtrace-child why we now don't):
+ PC will get changed to function 'jmp' by backtrace.c function
+ prepare_thread. Then SIGUSR2 will be signalled to backtrace-child
+ which will invoke function sigusr2.
+ This is all done so that signal interrupts execution of the very first
+ instruction of a function. Properly handled unwind should not slip into
+ the previous unrelated function. */
+
+#ifdef __x86_64__
+/* #define RAISE_JMP_PATCHING 1 */
+#endif
+
+static void
+prepare_thread (pid_t pid2 __attribute__ ((unused)),
+ void (*jmp) (void) __attribute__ ((unused)))
+{
+#ifndef RAISE_JMP_PATCHING
+ abort ();
+#else /* RAISE_JMP_PATCHING */
+ long l;
+ struct user_regs_struct user_regs;
+ errno = 0;
+ l = ptrace (PTRACE_GETREGS, pid2, 0, (intptr_t) &user_regs);
+ assert (errno == 0);
+ assert (l == 0);
+ user_regs.rip = (intptr_t) jmp;
+ l = ptrace (PTRACE_SETREGS, pid2, 0, (intptr_t) &user_regs);
+ assert (errno == 0);
+ assert (l == 0);
+ l = ptrace (PTRACE_CONT, pid2, NULL, (void *) (intptr_t) SIGUSR2);
+ int status;
+ pid_t got = waitpid (pid2, &status, __WALL);
+ assert (errno == 0);
+ assert (got == pid2);
+ assert (WIFSTOPPED (status));
+ assert (WSTOPSIG (status) == SIGUSR1);
+#endif /* RAISE_JMP_PATCHING */
+}
+
+#include <asm/unistd.h>
+#include <unistd.h>
+#define tgkill(pid, tid, sig) syscall (__NR_tgkill, (pid), (tid), (sig))
+
+static void
+report_pid (Dwfl *dwfl, pid_t pid)
+{
+ int result = dwfl_linux_proc_report (dwfl, pid);
+ if (result < 0)
+ error (2, 0, "dwfl_linux_proc_report: %s", dwfl_errmsg (-1));
+ else if (result > 0)
+ error (2, result, "dwfl_linux_proc_report");
+
+ if (dwfl_report_end (dwfl, NULL, NULL) != 0)
+ error (2, 0, "dwfl_report_end: %s", dwfl_errmsg (-1));
+
+ result = dwfl_linux_proc_attach (dwfl, pid, true);
+ if (result < 0)
+ error (2, 0, "dwfl_linux_proc_attach: %s", dwfl_errmsg (-1));
+ else if (result > 0)
+ error (2, result, "dwfl_linux_proc_attach");
+}
+
+static Dwfl *
+pid_to_dwfl (pid_t pid)
+{
+ static char *debuginfo_path;
+ static const Dwfl_Callbacks proc_callbacks =
+ {
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ .debuginfo_path = &debuginfo_path,
+
+ .find_elf = dwfl_linux_proc_find_elf,
+ };
+ Dwfl *dwfl = dwfl_begin (&proc_callbacks);
+ if (dwfl == NULL)
+ error (2, 0, "dwfl_begin: %s", dwfl_errmsg (-1));
+ report_pid (dwfl, pid);
+ return dwfl;
+}
+
+static void
+exec_dump (const char *exec)
+{
+ pid_t pid = fork ();
+ switch (pid)
+ {
+ case -1:
+ abort ();
+ case 0:
+ execl (exec, exec, "--ptraceme", NULL);
+ abort ();
+ default:
+ break;
+ }
+
+ /* Catch the main thread. Catch it first otherwise the /proc evaluation of
+ PID may have caught still ourselves before executing execl above. */
+ errno = 0;
+ int status;
+ pid_t got = waitpid (pid, &status, 0);
+ assert (errno == 0);
+ assert (got == pid);
+ assert (WIFSTOPPED (status));
+ // Main thread will signal SIGUSR2. Other thread will signal SIGUSR1.
+ assert (WSTOPSIG (status) == SIGUSR2);
+
+ /* Catch the spawned thread. Do not use __WCLONE as we could get racy
+ __WCLONE, probably despite pthread_create already had to be called the new
+ task is not yet alive enough for waitpid. */
+ pid_t pid2 = waitpid (-1, &status, __WALL);
+ assert (errno == 0);
+ assert (pid2 > 0);
+ assert (pid2 != pid);
+ assert (WIFSTOPPED (status));
+ // Main thread will signal SIGUSR2. Other thread will signal SIGUSR1.
+ assert (WSTOPSIG (status) == SIGUSR1);
+
+ Dwfl *dwfl = pid_to_dwfl (pid);
+ char *selfpathname;
+ int i = asprintf (&selfpathname, "/proc/%ld/exe", (long) pid);
+ assert (i > 0);
+ struct see_exec_module data;
+ ssize_t ssize = readlink (selfpathname, data.selfpath,
+ sizeof (data.selfpath));
+ free (selfpathname);
+ assert (ssize > 0 && ssize < (ssize_t) sizeof (data.selfpath));
+ data.selfpath[ssize] = '\0';
+ data.mod = NULL;
+ dwfl_getmodules (dwfl, see_exec_module, &data, 0);
+ assert (data.mod != NULL);
+ GElf_Addr loadbase;
+ Elf *elf = dwfl_module_getelf (data.mod, &loadbase);
+ GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ assert (ehdr != NULL);
+ /* It is false also on x86_64 with i386 inferior. */
+#ifndef RAISE_JMP_PATCHING
+ use_raise_jmp_patching = false;
+#else /* RAISE_JMP_PATCHING_ */
+ use_raise_jmp_patching = ehdr->e_machine == EM_X86_64;
+#endif /* __x86_64__ */
+ void (*jmp) (void) = 0;
+ if (use_raise_jmp_patching)
+ {
+ // Find inferior symbol named "jmp".
+ int nsym = dwfl_module_getsymtab (data.mod);
+ int symi;
+ for (symi = 1; symi < nsym; ++symi)
+ {
+ GElf_Sym symbol;
+ const char *symbol_name = dwfl_module_getsym (data.mod, symi, &symbol, NULL);
+ if (symbol_name == NULL)
+ continue;
+ switch (GELF_ST_TYPE (symbol.st_info))
+ {
+ case STT_SECTION:
+ case STT_FILE:
+ case STT_TLS:
+ continue;
+ default:
+ if (strcmp (symbol_name, "jmp") != 0)
+ continue;
+ break;
+ }
+ /* LOADBASE is already applied here. */
+ jmp = (void (*) (void)) (uintptr_t) symbol.st_value;
+ break;
+ }
+ assert (symi < nsym);
+ prepare_thread (pid2, jmp);
+ }
+ dwfl_end (dwfl);
+ check_tid = pid2;
+ dwfl = pid_to_dwfl (pid);
+ dump (dwfl);
+ dwfl_end (dwfl);
+}
+
+#define OPT_BACKTRACE_EXEC 0x100
+
+static const struct argp_option options[] =
+ {
+ { "backtrace-exec", OPT_BACKTRACE_EXEC, "EXEC", 0, N_("Run executable"), 0 },
+ { NULL, 0, NULL, 0, NULL, 0 }
+ };
+
+
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case ARGP_KEY_INIT:
+ state->child_inputs[0] = state->input;
+ break;
+
+ case OPT_BACKTRACE_EXEC:
+ exec_dump (arg);
+ exit (0);
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+int
+main (int argc __attribute__ ((unused)), char **argv)
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ __fsetlocking (stdin, FSETLOCKING_BYCALLER);
+ __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+ __fsetlocking (stderr, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ elf_version (EV_CURRENT);
+
+ Dwfl *dwfl = NULL;
+ const struct argp_child argp_children[] =
+ {
+ { .argp = dwfl_standard_argp () },
+ { .argp = NULL }
+ };
+ const struct argp argp =
+ {
+ options, parse_opt, NULL, NULL, argp_children, NULL, NULL
+ };
+ (void) argp_parse (&argp, argc, argv, 0, NULL, &dwfl);
+ assert (dwfl != NULL);
+ /* We want to make sure the dwfl was properly attached. */
+ if (dwfl_pid (dwfl) < 0)
+ error (2, 0, "dwfl_pid: %s", dwfl_errmsg (-1));
+ dump (dwfl);
+ dwfl_end (dwfl);
+ return 0;
+}
+
+#endif /* ! __linux__ */
+
diff --git a/tests/backtrace.i386.core.bz2 b/tests/backtrace.i386.core.bz2
new file mode 100644
index 0000000..e120d9b
--- /dev/null
+++ b/tests/backtrace.i386.core.bz2
Binary files differ
diff --git a/tests/backtrace.i386.exec.bz2 b/tests/backtrace.i386.exec.bz2
new file mode 100644
index 0000000..1b0f001
--- /dev/null
+++ b/tests/backtrace.i386.exec.bz2
Binary files differ
diff --git a/tests/backtrace.i386.fp.core.bz2 b/tests/backtrace.i386.fp.core.bz2
new file mode 100644
index 0000000..3c49e24
--- /dev/null
+++ b/tests/backtrace.i386.fp.core.bz2
Binary files differ
diff --git a/tests/backtrace.i386.fp.exec.bz2 b/tests/backtrace.i386.fp.exec.bz2
new file mode 100755
index 0000000..cb4d32e
--- /dev/null
+++ b/tests/backtrace.i386.fp.exec.bz2
Binary files differ
diff --git a/tests/backtrace.ppc.core.bz2 b/tests/backtrace.ppc.core.bz2
new file mode 100644
index 0000000..3a025d2
--- /dev/null
+++ b/tests/backtrace.ppc.core.bz2
Binary files differ
diff --git a/tests/backtrace.ppc.exec.bz2 b/tests/backtrace.ppc.exec.bz2
new file mode 100644
index 0000000..333c6be
--- /dev/null
+++ b/tests/backtrace.ppc.exec.bz2
Binary files differ
diff --git a/tests/backtrace.ppc64le.fp.core.bz2 b/tests/backtrace.ppc64le.fp.core.bz2
new file mode 100644
index 0000000..e63babf
--- /dev/null
+++ b/tests/backtrace.ppc64le.fp.core.bz2
Binary files differ
diff --git a/tests/backtrace.ppc64le.fp.exec.bz2 b/tests/backtrace.ppc64le.fp.exec.bz2
new file mode 100755
index 0000000..ed1352a
--- /dev/null
+++ b/tests/backtrace.ppc64le.fp.exec.bz2
Binary files differ
diff --git a/tests/backtrace.s390.core.bz2 b/tests/backtrace.s390.core.bz2
new file mode 100644
index 0000000..db34694
--- /dev/null
+++ b/tests/backtrace.s390.core.bz2
Binary files differ
diff --git a/tests/backtrace.s390.exec.bz2 b/tests/backtrace.s390.exec.bz2
new file mode 100644
index 0000000..4c1b4ae
--- /dev/null
+++ b/tests/backtrace.s390.exec.bz2
Binary files differ
diff --git a/tests/backtrace.s390x.core.bz2 b/tests/backtrace.s390x.core.bz2
new file mode 100644
index 0000000..61c23ec
--- /dev/null
+++ b/tests/backtrace.s390x.core.bz2
Binary files differ
diff --git a/tests/backtrace.s390x.exec.bz2 b/tests/backtrace.s390x.exec.bz2
new file mode 100644
index 0000000..8009239
--- /dev/null
+++ b/tests/backtrace.s390x.exec.bz2
Binary files differ
diff --git a/tests/backtrace.sparc.core.bz2 b/tests/backtrace.sparc.core.bz2
new file mode 100644
index 0000000..ad37f75
--- /dev/null
+++ b/tests/backtrace.sparc.core.bz2
Binary files differ
diff --git a/tests/backtrace.sparc.exec.bz2 b/tests/backtrace.sparc.exec.bz2
new file mode 100755
index 0000000..b049ec5
--- /dev/null
+++ b/tests/backtrace.sparc.exec.bz2
Binary files differ
diff --git a/tests/backtrace.x32.core.bz2 b/tests/backtrace.x32.core.bz2
new file mode 100644
index 0000000..c06d70a
--- /dev/null
+++ b/tests/backtrace.x32.core.bz2
Binary files differ
diff --git a/tests/backtrace.x32.exec.bz2 b/tests/backtrace.x32.exec.bz2
new file mode 100644
index 0000000..e89401b
--- /dev/null
+++ b/tests/backtrace.x32.exec.bz2
Binary files differ
diff --git a/tests/backtrace.x86_64.core.bz2 b/tests/backtrace.x86_64.core.bz2
new file mode 100644
index 0000000..1f34e20
--- /dev/null
+++ b/tests/backtrace.x86_64.core.bz2
Binary files differ
diff --git a/tests/backtrace.x86_64.exec.bz2 b/tests/backtrace.x86_64.exec.bz2
new file mode 100644
index 0000000..70a151b
--- /dev/null
+++ b/tests/backtrace.x86_64.exec.bz2
Binary files differ
diff --git a/tests/backtrace.x86_64.fp.core.bz2 b/tests/backtrace.x86_64.fp.core.bz2
new file mode 100644
index 0000000..e773ca2
--- /dev/null
+++ b/tests/backtrace.x86_64.fp.core.bz2
Binary files differ
diff --git a/tests/backtrace.x86_64.fp.exec.bz2 b/tests/backtrace.x86_64.fp.exec.bz2
new file mode 100644
index 0000000..0695845
--- /dev/null
+++ b/tests/backtrace.x86_64.fp.exec.bz2
Binary files differ
diff --git a/tests/buildid.c b/tests/buildid.c
new file mode 100644
index 0000000..87c1877
--- /dev/null
+++ b/tests/buildid.c
@@ -0,0 +1,81 @@
+/* Test program for dwelf_elf_gnu_build_id, print build ID.
+ Copyright (C) 2014 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <err.h>
+#include <errno.h>
+#include ELFUTILS_HEADER(elf)
+#include ELFUTILS_HEADER(dwelf)
+#include <stdio.h>
+#include <error.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int
+main (int argc, char *argv[])
+{
+ if (argc < 2)
+ error (EXIT_FAILURE, 0, "No input file given");
+
+ elf_version (EV_CURRENT);
+
+ for (int i = 1; i < argc; i++)
+ {
+ const char *file = argv[i];
+ int fd = open (file, O_RDONLY);
+ if (fd < 0)
+ error (EXIT_FAILURE, errno, "couldn't open file '%s'", file);
+
+ Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf("%s: elf_begin failed: %s\n", file, elf_errmsg (-1));
+ close (fd);
+ continue;
+ }
+
+ const void *build_id;
+ ssize_t len = dwelf_elf_gnu_build_id (elf, &build_id);
+ switch (len)
+ {
+ case 0:
+ printf ("%s: <no NT_GNU_BUILD_ID note>\n", file);
+ break;
+ case -1:
+ errx (1, "dwelf_elf_gnu_build_id (%s): %s",
+ file, elf_errmsg (-1));
+ default:
+ printf ("%s: build ID: ", file);
+ const unsigned char *p = build_id;
+ const unsigned char *end = p + len;
+ while (p < end)
+ printf("%02x", (unsigned)*p++);
+ putchar('\n');
+ }
+
+ elf_end (elf);
+ close (fd);
+ }
+
+ return 0;
+}
diff --git a/tests/cleanup-13.c b/tests/cleanup-13.c
new file mode 100644
index 0000000..3919b91
--- /dev/null
+++ b/tests/cleanup-13.c
@@ -0,0 +1,316 @@
+// http://gcc.gnu.org/viewcvs/gcc/trunk/gcc/testsuite/gcc.dg/cleanup-13.c?view=co&content-type=text%2Fplain
+
+/* HP-UX libunwind.so doesn't provide _UA_END_OF_STACK */
+/* { dg-do run } */
+/* { dg-options "-fexceptions" } */
+/* { dg-skip-if "" { "ia64-*-hpux11.*" } { "*" } { "" } } */
+/* Verify DW_OP_* handling in the unwinder. */
+
+#include <unwind.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* #define OP_addr(x) 0x06, ... */
+#define OP_deref 0x06,
+#define SLEB128(x) (x)&0x7f /* Assume here the value is -0x40 ... 0x3f. */
+#define ULEB128(x) (x)&0x7f /* Assume here the value is 0 ... 0x7f. */
+#define VAL1(x) (x)&0xff
+#if defined (__BIG_ENDIAN__)
+#define VAL2(x) ((x)>>8)&0xff,(x)&0xff
+#define VAL4(x) ((x)>>24)&0xff,((x)>>16)&0xff,((x)>>8)&0xff,(x)&0xff
+#define VAL8(x) ((x)>>56)&0xff,((x)>>48)&0xff,((x)>>40)&0xff,((x)>>32)&0xff,((x)>>24)&0xff,((x)>>16)&0xff,((x)>>8)&0xff,(x)&0xff
+#elif defined(__LITTLE_ENDIAN__) || defined(__x86_64__) || defined(__i386__)
+#define VAL2(x) (x)&0xff,((x)>>8)&0xff
+#define VAL4(x) (x)&0xff,((x)>>8)&0xff,((x)>>16)&0xff,((x)>>24)&0xff
+#define VAL8(x) (x)&0xff,((x)>>8)&0xff,((x)>>16)&0xff,((x)>>24)&0xff,((x)>>32)&0xff,((x)>>40)&0xff,((x)>>48)&0xff,((x)>>56)&0xff
+#endif
+#define OP_const1u(x) 0x08,VAL1(x),
+#define OP_const1s(x) 0x09,VAL1(x),
+#define OP_const2u(x) 0x0a,VAL2(x),
+#define OP_const2s(x) 0x0b,VAL2(x),
+#define OP_const4u(x) 0x0c,VAL4(x),
+#define OP_const4s(x) 0x0d,VAL4(x),
+#define OP_const8u(x) 0x0e,VAL8(x),
+#define OP_const8s(x) 0x0f,VAL8(x),
+#define OP_constu(x) 0x10,ULEB128(x),
+#define OP_consts(x) 0x11,SLEB128(x),
+#define OP_dup 0x12,
+#define OP_drop 0x13,
+#define OP_over 0x14,
+#define OP_pick(x) 0x15,VAL1(x),
+#define OP_swap 0x16,
+#define OP_rot 0x17,
+#define OP_xderef 0x18,
+#define OP_abs 0x19,
+#define OP_and 0x1a,
+#define OP_div 0x1b,
+#define OP_minus 0x1c,
+#define OP_mod 0x1d,
+#define OP_mul 0x1e,
+#define OP_neg 0x1f,
+#define OP_not 0x20,
+#define OP_or 0x21,
+#define OP_plus 0x22,
+#define OP_plus_uconst(x) 0x23,ULEB128(x),
+#define OP_shl 0x24,
+#define OP_shr 0x25,
+#define OP_shra 0x26,
+#define OP_xor 0x27,
+#define OP_bra(x) 0x28,VAL2(x),
+#define OP_eq 0x29,
+#define OP_ge 0x2a,
+#define OP_gt 0x2b,
+#define OP_le 0x2c,
+#define OP_lt 0x2d,
+#define OP_ne 0x2e,
+#define OP_skip(x) 0x2f,VAL2(x),
+#define OP_lit0 0x30,
+#define OP_lit1 0x31,
+#define OP_lit2 0x32,
+#define OP_lit3 0x33,
+#define OP_lit4 0x34,
+#define OP_lit5 0x35,
+#define OP_lit6 0x36,
+#define OP_lit7 0x37,
+#define OP_lit8 0x38,
+#define OP_lit9 0x39,
+#define OP_lit10 0x3a,
+#define OP_lit11 0x3b,
+#define OP_lit12 0x3c,
+#define OP_lit13 0x3d,
+#define OP_lit14 0x3e,
+#define OP_lit15 0x3f,
+#define OP_lit16 0x40,
+#define OP_lit17 0x41,
+#define OP_lit18 0x42,
+#define OP_lit19 0x43,
+#define OP_lit20 0x44,
+#define OP_lit21 0x45,
+#define OP_lit22 0x46,
+#define OP_lit23 0x47,
+#define OP_lit24 0x48,
+#define OP_lit25 0x49,
+#define OP_lit26 0x4a,
+#define OP_lit27 0x4b,
+#define OP_lit28 0x4c,
+#define OP_lit29 0x4d,
+#define OP_lit30 0x4e,
+#define OP_lit31 0x4f,
+#define OP_reg0 0x50,
+#define OP_reg1 0x51,
+#define OP_reg2 0x52,
+#define OP_reg3 0x53,
+#define OP_reg4 0x54,
+#define OP_reg5 0x55,
+#define OP_reg6 0x56,
+#define OP_reg7 0x57,
+#define OP_reg8 0x58,
+#define OP_reg9 0x59,
+#define OP_reg10 0x5a,
+#define OP_reg11 0x5b,
+#define OP_reg12 0x5c,
+#define OP_reg13 0x5d,
+#define OP_reg14 0x5e,
+#define OP_reg15 0x5f,
+#define OP_reg16 0x60,
+#define OP_reg17 0x61,
+#define OP_reg18 0x62,
+#define OP_reg19 0x63,
+#define OP_reg20 0x64,
+#define OP_reg21 0x65,
+#define OP_reg22 0x66,
+#define OP_reg23 0x67,
+#define OP_reg24 0x68,
+#define OP_reg25 0x69,
+#define OP_reg26 0x6a,
+#define OP_reg27 0x6b,
+#define OP_reg28 0x6c,
+#define OP_reg29 0x6d,
+#define OP_reg30 0x6e,
+#define OP_reg31 0x6f,
+#define OP_breg0(x) 0x70,SLEB128(x),
+#define OP_breg1(x) 0x71,SLEB128(x),
+#define OP_breg2(x) 0x72,SLEB128(x),
+#define OP_breg3(x) 0x73,SLEB128(x),
+#define OP_breg4(x) 0x74,SLEB128(x),
+#define OP_breg5(x) 0x75,SLEB128(x),
+#define OP_breg6(x) 0x76,SLEB128(x),
+#define OP_breg7(x) 0x77,SLEB128(x),
+#define OP_breg8(x) 0x78,SLEB128(x),
+#define OP_breg9(x) 0x79,SLEB128(x),
+#define OP_breg10(x) 0x7a,SLEB128(x),
+#define OP_breg11(x) 0x7b,SLEB128(x),
+#define OP_breg12(x) 0x7c,SLEB128(x),
+#define OP_breg13(x) 0x7d,SLEB128(x),
+#define OP_breg14(x) 0x7e,SLEB128(x),
+#define OP_breg15(x) 0x7f,SLEB128(x),
+#define OP_breg16(x) 0x80,SLEB128(x),
+#define OP_breg17(x) 0x81,SLEB128(x),
+#define OP_breg18(x) 0x82,SLEB128(x),
+#define OP_breg19(x) 0x83,SLEB128(x),
+#define OP_breg20(x) 0x84,SLEB128(x),
+#define OP_breg21(x) 0x85,SLEB128(x),
+#define OP_breg22(x) 0x86,SLEB128(x),
+#define OP_breg23(x) 0x87,SLEB128(x),
+#define OP_breg24(x) 0x88,SLEB128(x),
+#define OP_breg25(x) 0x89,SLEB128(x),
+#define OP_breg26(x) 0x8a,SLEB128(x),
+#define OP_breg27(x) 0x8b,SLEB128(x),
+#define OP_breg28(x) 0x8c,SLEB128(x),
+#define OP_breg29(x) 0x8d,SLEB128(x),
+#define OP_breg30(x) 0x8e,SLEB128(x),
+#define OP_breg31(x) 0x8f,SLEB128(x),
+#define OP_regx(x) 0x90,SLEB128(x),
+#define OP_fbreg(x) 0x91,SLEB128(x),
+#define OP_bregx(x,y) 0x92,ULEB128(x),SLEB128(y),
+#define OP_piece(x) 0x93,ULEB128(x),
+#define OP_deref_size(x) 0x94,VAL1(x),
+#define OP_xderef_size(x) 0x95,VAL1(x),
+#define OP_nop 0x96,
+#define OP_nop_termination 0x96
+#define OP_push_object_address 0x97,
+#define OP_call2(x) 0x98,VAL2(x),
+#define OP_call4(x) 0x99,VAL4(x),
+/* #define OP_call_ref(x) 0x9a,... */
+#define OP_form_tls_address(x) 0x9b,
+#define OP_call_frame_cfa 0x9c,
+#define OP_bit_piece(x) 0x9d,ULEB128(x),
+/* #define OP_implicit_value(x...) 0x9e,... */
+#define OP_stack_value 0x9f,
+#define OP_GNU_push_tls_address 0xe0,
+/* #define OP_GNU_encoded_addr(x...) 0xf1, */
+
+#define ASSERT_TOS_NON0 OP_bra(3) OP_skip(-3)
+#define ASSERT_TOS_0 OP_lit0 OP_eq ASSERT_TOS_NON0
+
+/* Initially there is CFA value on the stack, we want to
+ keep it there at the end. */
+#define CFI_PROGRAM \
+OP_lit0 OP_nop ASSERT_TOS_0 \
+OP_lit1 ASSERT_TOS_NON0 \
+OP_lit1 OP_const1u(1) OP_eq ASSERT_TOS_NON0 \
+OP_lit16 OP_const2u(16) OP_eq ASSERT_TOS_NON0 \
+OP_lit31 OP_const4u(31) OP_ne ASSERT_TOS_0 \
+OP_lit1 OP_neg OP_const1s(-1) OP_eq ASSERT_TOS_NON0 \
+OP_lit16 OP_neg OP_const2s(-16) OP_ne ASSERT_TOS_0 \
+OP_lit31 OP_const4s(-31) OP_neg OP_ne ASSERT_TOS_0 \
+OP_lit7 OP_dup OP_plus_uconst(2) OP_lit9 OP_eq ASSERT_TOS_NON0 \
+ OP_lit7 OP_eq ASSERT_TOS_NON0 \
+OP_lit20 OP_lit1 OP_drop OP_lit20 OP_eq ASSERT_TOS_NON0 \
+OP_lit17 OP_lit19 OP_over OP_lit17 OP_eq ASSERT_TOS_NON0 \
+ OP_lit19 OP_eq ASSERT_TOS_NON0 OP_lit17 OP_eq ASSERT_TOS_NON0 \
+OP_lit1 OP_lit2 OP_lit3 OP_lit4 OP_pick(2) OP_lit2 OP_eq ASSERT_TOS_NON0\
+ OP_lit4 OP_eq ASSERT_TOS_NON0 OP_lit3 OP_eq ASSERT_TOS_NON0 \
+ OP_pick(0) OP_lit2 OP_eq ASSERT_TOS_NON0 \
+ OP_lit2 OP_eq ASSERT_TOS_NON0 OP_lit1 OP_eq ASSERT_TOS_NON0 \
+OP_lit6 OP_lit12 OP_swap OP_lit6 OP_eq ASSERT_TOS_NON0 \
+ OP_lit12 OP_eq ASSERT_TOS_NON0 \
+OP_lit7 OP_lit8 OP_lit9 OP_rot OP_lit8 OP_eq ASSERT_TOS_NON0 \
+ OP_lit7 OP_eq ASSERT_TOS_NON0 OP_lit9 OP_eq ASSERT_TOS_NON0 \
+OP_lit7 OP_abs OP_lit7 OP_eq ASSERT_TOS_NON0 \
+OP_const1s(-123) OP_abs OP_const1u(123) OP_eq ASSERT_TOS_NON0 \
+OP_lit3 OP_lit6 OP_and OP_lit2 OP_eq ASSERT_TOS_NON0 \
+OP_lit3 OP_lit6 OP_or OP_lit7 OP_eq ASSERT_TOS_NON0 \
+OP_lit17 OP_lit2 OP_minus OP_lit15 OP_eq ASSERT_TOS_NON0 \
+/* Divide is signed truncating toward zero. */ \
+OP_const1s(-6) OP_const1s(-2) OP_div OP_lit3 OP_eq ASSERT_TOS_NON0 \
+OP_const1s(-7) OP_const1s(3) OP_div OP_const1s(-2) \
+ OP_eq ASSERT_TOS_NON0 \
+/* Modulo is unsigned. */ \
+OP_const1s(-6) OP_const1s(-4) OP_mod OP_const1s(-6) \
+ OP_eq ASSERT_TOS_NON0 \
+OP_const1s(-6) OP_lit4 OP_mod OP_lit2 OP_eq ASSERT_TOS_NON0 \
+OP_lit6 OP_const1s(-4) OP_mod OP_lit6 OP_eq ASSERT_TOS_NON0 \
+/* Signed modulo can be implemented using "over over div mul minus". */\
+OP_const1s(-6) OP_const1s(-4) OP_over OP_over OP_div OP_mul OP_minus \
+ OP_const1s(-2) OP_eq ASSERT_TOS_NON0 \
+OP_const1s(-7) OP_lit3 OP_over OP_over OP_div OP_mul OP_minus \
+ OP_const1s(-1) OP_eq ASSERT_TOS_NON0 \
+OP_lit7 OP_const1s(-3) OP_over OP_over OP_div OP_mul OP_minus \
+ OP_lit1 OP_eq ASSERT_TOS_NON0 \
+OP_lit16 OP_lit31 OP_plus_uconst(1) OP_mul OP_const2u(512) \
+ OP_eq ASSERT_TOS_NON0 \
+OP_lit5 OP_not OP_lit31 OP_and OP_lit26 OP_eq ASSERT_TOS_NON0 \
+OP_lit12 OP_lit31 OP_plus OP_const1u(43) OP_eq ASSERT_TOS_NON0 \
+OP_const1s(-6) OP_lit2 OP_plus OP_const1s(-4) OP_eq ASSERT_TOS_NON0 \
+OP_const1s(-6) OP_plus_uconst(3) OP_const1s(-3) OP_eq ASSERT_TOS_NON0 \
+OP_lit16 OP_lit4 OP_shl OP_const2u(256) OP_eq ASSERT_TOS_NON0 \
+OP_lit16 OP_lit3 OP_shr OP_lit2 OP_eq ASSERT_TOS_NON0 \
+OP_const1s(-16) OP_lit3 OP_shra OP_const1s(-2) OP_eq ASSERT_TOS_NON0 \
+OP_lit3 OP_lit6 OP_xor OP_lit5 OP_eq ASSERT_TOS_NON0 \
+OP_lit3 OP_lit6 OP_le ASSERT_TOS_NON0 \
+OP_lit3 OP_lit3 OP_le ASSERT_TOS_NON0 \
+OP_lit6 OP_lit3 OP_le ASSERT_TOS_0 \
+OP_lit3 OP_lit6 OP_lt ASSERT_TOS_NON0 \
+OP_lit3 OP_lit3 OP_lt ASSERT_TOS_0 \
+OP_lit6 OP_lit3 OP_lt ASSERT_TOS_0 \
+OP_lit3 OP_lit6 OP_ge ASSERT_TOS_0 \
+OP_lit3 OP_lit3 OP_ge ASSERT_TOS_NON0 \
+OP_lit6 OP_lit3 OP_ge ASSERT_TOS_NON0 \
+OP_lit3 OP_lit6 OP_gt ASSERT_TOS_0 \
+OP_lit3 OP_lit3 OP_gt ASSERT_TOS_0 \
+OP_lit6 OP_lit3 OP_gt ASSERT_TOS_NON0 \
+OP_const1s(-6) OP_lit1 OP_shr OP_lit0 OP_gt ASSERT_TOS_NON0 \
+OP_const1s(-6) OP_lit1 OP_shra OP_lit0 OP_lt ASSERT_TOS_NON0
+
+#define CFI_ESCAPE_VAL_2(VALUES...) #VALUES
+#define CFI_ESCAPE_VAL_1(VALUES...) CFI_ESCAPE_VAL_2(VALUES)
+#define CFI_ESCAPE_VAL(VALUES...) CFI_ESCAPE_VAL_1(VALUES)
+#define CFI_ESCAPE do { } while (0)
+#define CFI_ARCH_PROGRAM OP_nop_termination
+#ifdef __GCC_HAVE_DWARF2_CFI_ASM
+#if defined (__x86_64__)
+#undef CFI_ESCAPE
+#undef CFI_ARCH_PROGRAM
+#define CFI_ARCH_PROGRAM CFI_PROGRAM OP_lit8 OP_minus OP_nop_termination
+unsigned char cfi_arch_program[] = { CFI_ARCH_PROGRAM };
+extern char verify_it[sizeof (cfi_arch_program) - 0x80 < 0x3f80 ? 1 : -1];
+/* DW_CFA_expression %rip, uleb128(l2-l1), l1: program DW_OP_lit8 DW_OP_minus DW_OP_nop l2: */
+#define CFI_ESCAPE \
+ asm volatile (".cfi_escape 0x10, 0x10, (%P0&0x7f)+0x80, %P0>>7, " \
+ CFI_ESCAPE_VAL (CFI_ARCH_PROGRAM) \
+ : : "i" (sizeof (cfi_arch_program)))
+#elif defined (__i386__)
+#undef CFI_ESCAPE
+#undef CFI_ARCH_PROGRAM
+#define CFI_ARCH_PROGRAM CFI_PROGRAM OP_lit4 OP_minus OP_nop_termination
+unsigned char cfi_arch_program[] = { CFI_ARCH_PROGRAM };
+extern char verify_it[sizeof (cfi_arch_program) - 0x80 < 0x3f80 ? 1 : -1];
+/* DW_CFA_expression %eip, uleb128(l2-l1), l1: program DW_OP_lit4 DW_OP_minus DW_OP_nop l2: */
+#define CFI_ESCAPE \
+ asm volatile (".cfi_escape 0x10, 8, (%P0&0x7f)+0x80, %P0>>7, " \
+ CFI_ESCAPE_VAL (CFI_ARCH_PROGRAM) \
+ : : "i" (sizeof (cfi_arch_program)))
+#endif
+#endif
+
+/* The original GCC testcase tests the runtime unwinder using
+ _Unwind_ForcedUnwind, we just inspect the child when it aborts. */
+
+static void force_unwind ()
+{
+ abort ();
+}
+
+static void handler (void *p __attribute__((unused)))
+{
+ exit (0);
+}
+
+__attribute__((noinline)) static void callme ()
+{
+ CFI_ESCAPE;
+ force_unwind ();
+}
+
+__attribute__((noinline)) static void doit ()
+{
+ char dummy __attribute__((cleanup (handler)));
+ callme ();
+}
+
+int main()
+{
+ doit ();
+ abort ();
+}
diff --git a/tests/configure.ac b/tests/configure.ac
new file mode 100644
index 0000000..ed51920
--- /dev/null
+++ b/tests/configure.ac
@@ -0,0 +1,58 @@
+dnl Process this file with autoconf to produce a configure script.
+dnl Configure input file for elfutils test suite. -*-autoconf-*-
+dnl
+dnl Copyright (C) 2005 Red Hat, Inc.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, version 2.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software Foundation,
+dnl Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+dnl
+AC_INIT([elfutils tests],[0.117],
+ [http://bugzilla.redhat.com/bugzilla/],
+ [elfutils-tests])
+
+AC_COPYRIGHT([Copyright (C) 2005 Red Hat, Inc.])
+AC_PREREQ(2.59) dnl Minimum Autoconf version required.
+
+AM_INIT_AUTOMAKE([foreign 1.7])
+
+AC_CONFIG_SRCDIR([allfcts.c])
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_HEADERS([config.h])
+
+AC_PROG_CC
+
+AC_CACHE_CHECK([for gcc with C99 support], ac_cv_c99, [dnl
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -std=gnu99"
+AC_COMPILE_IFELSE([dnl
+int foo (int a) { for (int i = 0; i < a; ++i) if (i % 4) break; int s = a; }],
+ ac_cv_c99=yes, ac_cv_c99=no)
+CFLAGS="$old_CFLAGS"])
+AS_IF([test "x$ac_cv_c99" != xyes],
+ AC_MSG_ERROR([gcc with C99 support required]))
+
+AC_CHECK_HEADERS([libelf.h elfutils/libdw.h],,
+[AC_MSG_ERROR([elfutils-devel package not installed])])
+
+AC_CHECK_LIB([asm], [asm_begin], [have_libasm=yes], [have_libasm=no])
+AM_CONDITIONAL(HAVE_LIBASM, [test $have_libasm = yes])
+
+AM_CONDITIONAL(STANDALONE, true)
+AM_CONDITIONAL(BUILD_STATIC, false)
+AM_CONDITIONAL(TESTS_RPATH, false)
+AM_CONDITIONAL(GCOV, false)
+
+dnl Text of the config.h file.
+AH_BOTTOM([#define ELFUTILS_HEADER(name) <elfutils/lib##name.h>])
+
+AC_OUTPUT
diff --git a/tests/coverage.sh b/tests/coverage.sh
new file mode 100755
index 0000000..5cc353c
--- /dev/null
+++ b/tests/coverage.sh
@@ -0,0 +1,40 @@
+#! /bin/bash
+
+if [ "x$1" = "x-v" ]; then
+ verbose=yes
+else
+ verbose=no
+fi
+
+cd ..
+
+for d in lib libasm libdw libdwfl libebl libelf backends src; do
+ tmp=$d-data
+ cd $d
+ unused=0
+ unused_files=
+ for f in *.gcno; do
+ base="$(basename $f .gcno)"
+ fc="$base.c"
+ gcda="$base.gcda"
+ if [ -f "$gcda" ]; then
+ gcov -n -a "$fc" |
+ gawk "/$d.$fc/ { getline; co=gensub(/.*:(.*)% .*/, \"\\\\1\", \"g\"); co=co+0.0; li=\$4+0; printf \"%-35s %6.2f %5d\n\", \"$d/$fc\", co, li } " >> $tmp
+ else
+ unused=$(($unused + 1))
+ unused_files="$unused_files $fc"
+ fi
+ done
+ if [ -f $tmp ]; then
+ gawk "{ copct=\$2; co=(\$3*copct)/100; toco+=(co+0); toli += (\$3+0); } END { printf \"%-12s %6.2f%% covered unused files: %3d\n\", \"$d\", (toco*100)/toli, \"$unused\" }" $tmp
+ rm -f $tmp
+ else
+ printf "%-12s 0.00%% covered unused files: %3d\n" "$d" $unused
+ fi
+ if [ $verbose = yes ]; then
+ for f in $unused_files; do
+ printf '%-42s%s\n' '' $f
+ done
+ fi
+ cd ..
+done
diff --git a/tests/debug-ranges-no-lowpc.o.bz2 b/tests/debug-ranges-no-lowpc.o.bz2
new file mode 100644
index 0000000..871a3fb
--- /dev/null
+++ b/tests/debug-ranges-no-lowpc.o.bz2
Binary files differ
diff --git a/tests/debug-ranges-no-lowpc.s b/tests/debug-ranges-no-lowpc.s
new file mode 100644
index 0000000..879bce2
--- /dev/null
+++ b/tests/debug-ranges-no-lowpc.s
@@ -0,0 +1,49 @@
+ .section .debug_info
+.Lcu1_begin:
+ .4byte .Lcu1_end - .Lcu1_start
+.Lcu1_start:
+ .2byte 3 /* Version */
+ .4byte .Labbrev1_begin /* Abbrevs */
+ .byte 8 /* Pointer size */
+ .uleb128 2 /* Abbrev (DW_TAG_compile_unit) */
+ .4byte 0
+.Lcu1_end:
+ .section .note.gnu.build-id, "a", %note
+ .4byte 4
+ .4byte 8
+ .4byte 3
+ .ascii "GNU\0"
+ .byte 0x01
+ .byte 0x02
+ .byte 0x03
+ .byte 0x04
+ .byte 0x05
+ .byte 0x06
+ .byte 0x07
+ .byte 0x08
+ .section .debug_abbrev
+.Labbrev1_begin:
+ .uleb128 2 /* Abbrev start */
+ .uleb128 0x11 /* DW_TAG_compile_unit */
+ .byte 0 /* has_children */
+ .uleb128 0x55 /* DW_AT_ranges */
+ .uleb128 0x06 /* DW_FORM_data4 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .section .debug_ranges
+
+ .8byte 0xffffffffffffffff
+ .8byte 0
+
+ .8byte 1
+ .8byte 2
+
+ .8byte 3
+ .8byte 4
+
+ .8byte 0
+ .8byte 0
+
diff --git a/tests/debugaltlink.c b/tests/debugaltlink.c
new file mode 100644
index 0000000..6d97d50
--- /dev/null
+++ b/tests/debugaltlink.c
@@ -0,0 +1,83 @@
+/* Test program for dwelf_dwarf_gnu_debugaltlink, print name and build ID.
+ Copyright (C) 2014 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <err.h>
+#include <errno.h>
+#include ELFUTILS_HEADER(dw)
+#include ELFUTILS_HEADER(dwelf)
+#include <stdio.h>
+#include <error.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int
+main (int argc, char *argv[])
+{
+ if (argc < 2)
+ error (EXIT_FAILURE, 0, "No input file given");
+
+ elf_version (EV_CURRENT);
+
+ for (int i = 1; i < argc; i++)
+ {
+ const char *file = argv[i];
+ int fd = open (file, O_RDONLY);
+ if (fd < 0)
+ error (EXIT_FAILURE, errno, "couldn't open file '%s'", file);
+
+ Dwarf *dwarf = dwarf_begin (fd, DWARF_C_READ);
+ if (dwarf == NULL)
+ {
+ printf("%s: dwarf_begin failed: %s\n", file, dwarf_errmsg (-1));
+ close (fd);
+ continue;
+ }
+
+ const char *name;
+ const void *build_id;
+ ssize_t ret = dwelf_dwarf_gnu_debugaltlink
+ (dwarf, &name, &build_id);
+ switch (ret)
+ {
+ case 0:
+ printf ("%s: <no .gnu_debugaltlink section>\n", file);
+ break;
+ case -1:
+ errx (1, "dwelf_dwarf_gnu_debugaltlink (%s): %s",
+ file, dwarf_errmsg (-1));
+ default:
+ printf ("%s: %s, build ID: ", file, name);
+ const unsigned char *p = build_id;
+ const unsigned char *end = p + ret;
+ while (p < end)
+ printf("%02x", (unsigned)*p++);
+ putchar('\n');
+ }
+
+ dwarf_end (dwarf);
+ close (fd);
+ }
+
+ return 0;
+}
diff --git a/tests/debuglink.c b/tests/debuglink.c
new file mode 100644
index 0000000..935d102
--- /dev/null
+++ b/tests/debuglink.c
@@ -0,0 +1,64 @@
+/* Test program for dwelf_elf_gnu_debuglink, print name and crc.
+ Copyright (C) 2014 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <errno.h>
+#include ELFUTILS_HEADER(dwelf)
+#include <stdio.h>
+#include <error.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int
+main (int argc, char *argv[])
+{
+ if (argc < 2)
+ error (EXIT_FAILURE, 0, "No input file given");
+
+ elf_version (EV_CURRENT);
+
+ for (int i = 1; i < argc; i++)
+ {
+ const char *file = argv[i];
+ int fd = open (file, O_RDONLY);
+ if (fd < 0)
+ error (EXIT_FAILURE, errno, "couldn't open file '%s'", file);
+
+ Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ error (EXIT_FAILURE, 0, "elf_begin failed for '%s': %s",
+ file, elf_errmsg (-1));
+
+ GElf_Word crc;
+ const char *debug = dwelf_elf_gnu_debuglink (elf, &crc);
+ if (debug == NULL)
+ printf ("%s: <no gnu_debuglink file>\n", file);
+ else
+ printf ("%s: %s, crc: %" PRIx32 "\n", file, debug, crc);
+
+ elf_end (elf);
+ close (fd);
+ }
+
+ return 0;
+}
diff --git a/tests/deleted-lib.c b/tests/deleted-lib.c
new file mode 100644
index 0000000..1ff411b
--- /dev/null
+++ b/tests/deleted-lib.c
@@ -0,0 +1,27 @@
+/* Test program for opening already deleted running binaries.
+ Copyright (C) 2014 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/>. */
+
+#include <config.h>
+#include <unistd.h>
+
+void
+libfunc (void)
+{
+ sleep (60000);
+ /* Avoid tail call optimization for the sleep call. */
+ asm volatile ("");
+}
diff --git a/tests/deleted.c b/tests/deleted.c
new file mode 100644
index 0000000..6be35bc
--- /dev/null
+++ b/tests/deleted.c
@@ -0,0 +1,58 @@
+/* Test program for opening already deleted running binaries.
+ Copyright (C) 2014 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/>. */
+
+#include <config.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+#ifdef __linux__
+#include <sys/prctl.h>
+#endif
+
+extern void libfunc (void);
+
+int
+main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
+{
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ pid_t pid = fork ();
+ assert (pid != -1);
+ if (pid == 0)
+ {
+ int err = close (0);
+ assert (!err);
+ err = close (1);
+ assert (!err);
+ err = close (2);
+ assert (!err);
+ /* Make sure eu-stack -p works on this process even with
+ "restricted ptrace". */
+#ifdef PR_SET_PTRACER_ANY
+ prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
+#endif
+ libfunc ();
+ abort ();
+ }
+ printf ("%d\n", pid);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/dwarf-getmacros.c b/tests/dwarf-getmacros.c
new file mode 100644
index 0000000..ac70248
--- /dev/null
+++ b/tests/dwarf-getmacros.c
@@ -0,0 +1,144 @@
+/* Test program for dwarf_getmacros and related
+ Copyright (C) 2009, 2014 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/>. */
+
+#include <config.h>
+#include ELFUTILS_HEADER(dw)
+#include <dwarf.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <inttypes.h>
+
+static void include (Dwarf *dbg, Dwarf_Off macoff, ptrdiff_t token);
+
+static int
+mac (Dwarf_Macro *macro, void *dbg)
+{
+ static int level = 0;
+
+ unsigned int opcode;
+ dwarf_macro_opcode (macro, &opcode);
+ switch (opcode)
+ {
+ case DW_MACRO_import:
+ {
+ Dwarf_Attribute at;
+ int r = dwarf_macro_param (macro, 0, &at);
+ assert (r == 0);
+
+ Dwarf_Word w;
+ r = dwarf_formudata (&at, &w);
+ assert (r == 0);
+
+ printf ("%*sinclude %#" PRIx64 "\n", level, "", w);
+ ++level;
+ include (dbg, w, DWARF_GETMACROS_START);
+ --level;
+ printf ("%*s/include\n", level, "");
+ break;
+ }
+
+ case DW_MACRO_start_file:
+ {
+ Dwarf_Files *files;
+ size_t nfiles;
+ if (dwarf_macro_getsrcfiles (dbg, macro, &files, &nfiles) < 0)
+ printf ("dwarf_macro_getsrcfiles: %s\n",
+ dwarf_errmsg (dwarf_errno ()));
+
+ Dwarf_Word w = 0;
+ dwarf_macro_param2 (macro, &w, NULL);
+
+ const char *name = dwarf_filesrc (files, (size_t) w, NULL, NULL);
+ printf ("%*sfile %s\n", level, "", name);
+ ++level;
+ break;
+ }
+
+ case DW_MACRO_end_file:
+ {
+ --level;
+ printf ("%*s/file\n", level, "");
+ break;
+ }
+
+ case DW_MACINFO_define:
+ case DW_MACRO_define_strp:
+ {
+ const char *value;
+ dwarf_macro_param2 (macro, NULL, &value);
+ printf ("%*s%s\n", level, "", value);
+ break;
+ }
+
+ case DW_MACINFO_undef:
+ case DW_MACRO_undef_strp:
+ break;
+
+ default:
+ {
+ size_t paramcnt;
+ dwarf_macro_getparamcnt (macro, ¶mcnt);
+ printf ("%*sopcode %u with %zd arguments\n",
+ level, "", opcode, paramcnt);
+ break;
+ }
+ }
+
+ return DWARF_CB_ABORT;
+}
+
+static void
+include (Dwarf *dbg, Dwarf_Off macoff, ptrdiff_t token)
+{
+ while ((token = dwarf_getmacros_off (dbg, macoff, mac, dbg, token)) != 0)
+ if (token == -1)
+ {
+ puts (dwarf_errmsg (dwarf_errno ()));
+ break;
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ assert (argc >= 3);
+ const char *name = argv[1];
+ ptrdiff_t cuoff = strtol (argv[2], NULL, 0);
+ bool new_style = argc > 3;
+
+ int fd = open (name, O_RDONLY);
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+
+ Dwarf_Die cudie_mem, *cudie = dwarf_offdie (dbg, cuoff, &cudie_mem);
+
+ for (ptrdiff_t off = new_style ? DWARF_GETMACROS_START : 0;
+ (off = dwarf_getmacros (cudie, mac, dbg, off)); )
+ if (off == -1)
+ {
+ puts (dwarf_errmsg (dwarf_errno ()));
+ break;
+ }
+
+ dwarf_end (dbg);
+
+ return 0;
+}
diff --git a/tests/dwarf-getstring.c b/tests/dwarf-getstring.c
new file mode 100644
index 0000000..ffa3e37
--- /dev/null
+++ b/tests/dwarf-getstring.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2011 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Marek Polacek <mpolacek@redhat.com>, 2011.
+
+ 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 ELFUTILS_HEADER(dwfl)
+#include <assert.h>
+#include <dwarf.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int cnt;
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ Dwarf_Off offset = 0;
+ size_t len;
+
+ int fd = open (argv[cnt], O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open '%s': %m\n", argv[cnt]);
+ return 1;
+ }
+
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ {
+ printf ("%s not usable: %s\n", argv[cnt], dwarf_errmsg (-1));
+ close (fd);
+ return 1;
+ }
+
+ /* Try to use NULL Dwarf object. */
+ const char *str = dwarf_getstring (NULL, offset, &len);
+ assert (str == NULL);
+
+ /* Use insane offset. */
+ str = dwarf_getstring (dbg, ~0UL, &len);
+ assert (str == NULL);
+
+ /* Now do some real work. */
+ for (int i = 0; i < 100; ++i)
+ {
+ str = dwarf_getstring (dbg, offset, &len);
+ puts (str);
+
+ /* Advance. */
+ offset += len + 1;
+ }
+
+ dwarf_end (dbg);
+ close (fd);
+ }
+
+ return 0;
+}
diff --git a/tests/dwarf-ranges.c b/tests/dwarf-ranges.c
new file mode 100644
index 0000000..4bcf96c
--- /dev/null
+++ b/tests/dwarf-ranges.c
@@ -0,0 +1,57 @@
+/* Test program for dwarf_ranges
+ 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/>. */
+
+#include <config.h>
+#include ELFUTILS_HEADER(dw)
+#include <dwarf.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <inttypes.h>
+
+int
+main (int argc, char *argv[])
+{
+ assert (argc >= 3);
+ const char *name = argv[1];
+ ptrdiff_t cuoff = strtol (argv[2], NULL, 0);
+
+ int fd = open (name, O_RDONLY);
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+
+ Dwarf_Die cudie_mem, *cudie = dwarf_offdie (dbg, cuoff, &cudie_mem);
+
+ Dwarf_Addr base, start, end;
+ for (ptrdiff_t off = 0;
+ (off = dwarf_ranges (cudie, off, &base, &start, &end)); )
+ if (off == -1)
+ {
+ puts (dwarf_errmsg (dwarf_errno ()));
+ break;
+ }
+ else
+ fprintf (stderr, "%"PRIx64"..%"PRIx64" (base %"PRIx64")\n",
+ start, end, base);
+
+ dwarf_end (dbg);
+
+ return 0;
+}
diff --git a/tests/dwarf_default_lower_bound.c b/tests/dwarf_default_lower_bound.c
new file mode 100644
index 0000000..d57424f
--- /dev/null
+++ b/tests/dwarf_default_lower_bound.c
@@ -0,0 +1,83 @@
+/* Test all DW_LANG constants are handled by dwarf_default_lower_bound.
+
+ Copyright (C) 2016 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 <dwarf.h>
+#include ELFUTILS_HEADER(dw)
+#include "../libdw/known-dwarf.h"
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void
+test_lang (const char *name, int lang)
+{
+ Dwarf_Sword low;
+ int res = dwarf_default_lower_bound (lang, &low);
+
+ /* Assembler is special, it doesn't really have arrays. */
+ if (lang == DW_LANG_Mips_Assembler)
+ {
+ if (res == 0)
+ {
+ printf ("%s shouldn't have a known lower bound\n", name);
+ exit (-1);
+ }
+ printf ("%s: <unknown>\n", name);
+ return;
+ }
+
+ if (res != 0)
+ {
+ printf ("dwarf_default_lower_bound failed (%d) for %s\n", res, name);
+ exit (-1);
+ }
+
+ /* All currently known lower bounds are either zero or one, but
+ they don't have to. Update test once one is a different value. */
+ if (low != 0 && low != 1)
+ {
+ printf ("unexpected lower bound %" PRId64 " for %s\n", low, name);
+ exit (-1);
+ }
+
+ printf ("%s: %" PRId64 "\n", name, low);
+}
+
+int
+main (int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused)))
+{
+ Dwarf_Sword low;
+ /* Bad language code must fail. */
+ if (dwarf_default_lower_bound (-1, &low) == 0)
+ {
+ printf ("Bad lang code -1 succeeded (%" PRId64 ")\n", low);
+ exit (-1);
+ }
+
+ /* Test all known language codes. */
+#define DWARF_ONE_KNOWN_DW_LANG(NAME, CODE) test_lang (#NAME, CODE);
+ DWARF_ALL_KNOWN_DW_LANG
+#undef DWARF_ONE_KNOWN_DW_LANG
+
+ return 0;
+}
diff --git a/tests/dwelfgnucompressed.c b/tests/dwelfgnucompressed.c
new file mode 100644
index 0000000..0132271
--- /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/dwfl-addr-sect.c b/tests/dwfl-addr-sect.c
new file mode 100644
index 0000000..21e470a
--- /dev/null
+++ b/tests/dwfl-addr-sect.c
@@ -0,0 +1,80 @@
+/* Test program for libdwfl ... foo
+ Copyright (C) 2007 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <locale.h>
+#include <argp.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+
+static int
+handle_address (Dwfl *dwfl, Dwarf_Addr address)
+{
+ Dwfl_Module *mod = dwfl_addrmodule (dwfl, address);
+ Dwarf_Addr adjusted = address;
+ Dwarf_Addr bias;
+ Elf_Scn *scn = dwfl_module_address_section (mod, &adjusted, &bias);
+ if (scn == NULL)
+ {
+ error (0, 0, "%#" PRIx64 ": dwfl_module_address_section: %s",
+ address, dwfl_errmsg (-1));
+ return 1;
+ }
+ printf ("address %#" PRIx64 " => module \"%s\" section %zu + %#" PRIx64 "\n",
+ address,
+ dwfl_module_info (mod, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ elf_ndxscn (scn), adjusted);
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ int remaining;
+ Dwfl *dwfl = NULL;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
+ assert (dwfl != NULL);
+
+ int result = 0;
+ for (; remaining < argc; ++remaining)
+ {
+ char *endp;
+ uintmax_t addr = strtoumax (argv[remaining], &endp, 0);
+ if (endp != argv[remaining])
+ result |= handle_address (dwfl, addr);
+ else
+ result = 1;
+ }
+
+ dwfl_end (dwfl);
+
+ return result;
+}
diff --git a/tests/dwfl-bug-addr-overflow.c b/tests/dwfl-bug-addr-overflow.c
new file mode 100644
index 0000000..aa8030e
--- /dev/null
+++ b/tests/dwfl-bug-addr-overflow.c
@@ -0,0 +1,73 @@
+/* Test program for libdwfl basic module tracking, relocation.
+ Copyright (C) 2007 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <error.h>
+#include <locale.h>
+#include ELFUTILS_HEADER(dwfl)
+
+
+static const Dwfl_Callbacks offline_callbacks =
+ {
+ .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo),
+ .section_address = INTUSE(dwfl_offline_section_address),
+ };
+
+
+int
+main (void)
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ Dwfl *dwfl = dwfl_begin (&offline_callbacks);
+ assert (dwfl != NULL);
+
+ Dwfl_Module *high = dwfl_report_module (dwfl, "high",
+ UINT64_C (0xffffffff00010000),
+ UINT64_C (0xffffffff00020000));
+ assert (high);
+ Dwfl_Module *low = dwfl_report_module (dwfl, "low",
+ UINT64_C (0x00010000),
+ UINT64_C (0x00020000));
+ assert (low);
+ Dwfl_Module *middle = dwfl_report_module (dwfl, "middle",
+ UINT64_C (0xffff00010000),
+ UINT64_C (0xffff00020000));
+ assert (middle);
+
+ int ret = dwfl_report_end (dwfl, NULL, NULL);
+ assert (ret == 0);
+
+ Dwfl_Module *mod = dwfl_addrmodule (dwfl, UINT64_C (0xffffffff00010123));
+ assert (mod == high);
+ mod = dwfl_addrmodule (dwfl, UINT64_C (0x00010123));
+ assert (mod == low);
+ mod = dwfl_addrmodule (dwfl, UINT64_C (0xffff00010123));
+ assert (mod == middle);
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/dwfl-bug-fd-leak.c b/tests/dwfl-bug-fd-leak.c
new file mode 100644
index 0000000..689cdd7
--- /dev/null
+++ b/tests/dwfl-bug-fd-leak.c
@@ -0,0 +1,116 @@
+/* Test program for libdwfl file decriptors leakage.
+ Copyright (C) 2007, 2008 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <error.h>
+#include <unistd.h>
+#include <dwarf.h>
+
+#ifndef __linux__
+int
+main (void)
+{
+ return 77; /* dwfl_linux_proc_report is linux specific. */
+}
+#else
+
+#include <sys/resource.h>
+#include ELFUTILS_HEADER(dwfl)
+
+
+static Dwfl *
+elfutils_open (pid_t pid, Dwarf_Addr address)
+{
+ static char *debuginfo_path;
+ static const Dwfl_Callbacks proc_callbacks =
+ {
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ .debuginfo_path = &debuginfo_path,
+
+ .find_elf = dwfl_linux_proc_find_elf,
+ };
+ Dwfl *dwfl = dwfl_begin (&proc_callbacks);
+ if (dwfl == NULL)
+ error (2, 0, "dwfl_begin: %s", dwfl_errmsg (-1));
+
+ int result = dwfl_linux_proc_report (dwfl, pid);
+ if (result < 0)
+ error (2, 0, "dwfl_linux_proc_report: %s", dwfl_errmsg (-1));
+ else if (result > 0)
+ error (2, result, "dwfl_linux_proc_report");
+
+ if (dwfl_report_end (dwfl, NULL, NULL) != 0)
+ error (2, 0, "dwfl_report_end: %s", dwfl_errmsg (-1));
+
+ Dwarf_Addr bias;
+ Dwarf *dbg = dwfl_addrdwarf (dwfl, address, &bias);
+ if (dbg != NULL)
+ {
+ Elf *elf = dwarf_getelf (dbg);
+ if (elf == NULL)
+ error (2, 0, "dwarf_getelf: %s", dwarf_errmsg (-1));
+ }
+ else
+ {
+ Dwfl_Module *module = dwfl_addrmodule (dwfl, address);
+ if (module == NULL)
+ error (2, 0, "dwfl_addrmodule: no module available for 0x%" PRIx64 "",
+ address);
+ Elf *elf = dwfl_module_getelf (module, &bias);
+ if (elf == NULL)
+ error (2, 0, "dwfl_module_getelf: %s", dwfl_errmsg (-1));
+ }
+
+ return dwfl;
+}
+
+static void
+elfutils_close (Dwfl *dwfl)
+{
+ dwfl_end (dwfl);
+}
+
+int
+main (void)
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ struct rlimit fd_limit = { .rlim_cur = 32, .rlim_max = 32 };
+ if (setrlimit (RLIMIT_NOFILE, &fd_limit) < 0)
+ error (2, errno, "setrlimit");
+
+ for (int i = 0; i < 5000; ++i)
+ {
+ Dwfl *dwfl = elfutils_open (getpid (), (Dwarf_Addr) (uintptr_t) &main);
+ elfutils_close (dwfl);
+ }
+
+ return 0;
+}
+#endif
diff --git a/tests/dwfl-bug-getmodules.c b/tests/dwfl-bug-getmodules.c
new file mode 100644
index 0000000..1ee989f
--- /dev/null
+++ b/tests/dwfl-bug-getmodules.c
@@ -0,0 +1,66 @@
+/* Test program for dwfl_getmodules bug.
+ Copyright (C) 2008 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/>. */
+
+#include <config.h>
+#include ELFUTILS_HEADER(dwfl)
+
+#include <error.h>
+
+static const Dwfl_Callbacks callbacks =
+ {
+ .find_elf = dwfl_linux_proc_find_elf,
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ };
+
+static int
+iterate (Dwfl_Module *mod __attribute__ ((unused)),
+ void **userdata __attribute__ ((unused)),
+ const char *name __attribute__ ((unused)),
+ Dwarf_Addr base, void *arg)
+{
+ if (base != 0x2000)
+ return DWARF_CB_OK;
+
+ if (dwfl_addrmodule (arg, 0x2100) == NULL)
+ error (1, 0, "dwfl_addrmodule: %s", dwfl_errmsg (-1));
+
+ return DWARF_CB_ABORT;
+}
+
+int
+main (void)
+{
+ Dwfl *dwfl = dwfl_begin (&callbacks);
+
+ dwfl_report_module (dwfl, "m1", 0, 0x1000);
+ dwfl_report_module (dwfl, "m2", 0x2000, 0x3000);
+ dwfl_report_module (dwfl, "m3", 0x4000, 0x5000);
+
+ dwfl_report_end (dwfl, NULL, NULL);
+
+ ptrdiff_t offset = dwfl_getmodules (dwfl, &iterate, dwfl, 0);
+ if (offset <= 0)
+ error (1, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
+
+ offset = dwfl_getmodules (dwfl, &iterate, NULL, offset);
+ if (offset != 0)
+ error (1, 0, "dwfl_getmodules (%d): %s", (int) offset, dwfl_errmsg (-1));
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/dwfl-bug-report.c b/tests/dwfl-bug-report.c
new file mode 100644
index 0000000..80ff806
--- /dev/null
+++ b/tests/dwfl-bug-report.c
@@ -0,0 +1,48 @@
+/* Test program for dwfl_report_end bug.
+ Copyright (C) 2007 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/>. */
+
+#include <config.h>
+#include ELFUTILS_HEADER(dwfl)
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+static const Dwfl_Callbacks callbacks =
+ {
+ .find_elf = dwfl_linux_proc_find_elf,
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ };
+
+int
+main (void)
+{
+ Dwfl *dwfl = dwfl_begin (&callbacks);
+
+ for (int i = 0; i < 5; ++i)
+ {
+ dwfl_report_begin (dwfl);
+ dwfl_report_module (dwfl, "module1", 0, 10);
+ dwfl_report_end (dwfl, NULL, NULL);
+ }
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/dwfl-proc-attach.c b/tests/dwfl-proc-attach.c
new file mode 100644
index 0000000..e7bb201
--- /dev/null
+++ b/tests/dwfl-proc-attach.c
@@ -0,0 +1,103 @@
+/* Test dwfl_linux_proc_attach works without any modules.
+ 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/>. */
+
+#include <config.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <error.h>
+#include <unistd.h>
+#ifdef __linux__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/user.h>
+#include <fcntl.h>
+#include <string.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <pthread.h>
+#endif
+
+#ifndef __linux__
+int
+main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
+{
+ printf ("dwfl_linux_proc_attach unsupported.\n");
+ return 77;
+}
+#else /* __linux__ */
+
+static pthread_t thread1;
+static pthread_t thread2;
+
+static void *
+sleeper (void* d __attribute__ ((unused)))
+{
+ sleep (60);
+ return NULL;
+}
+
+static char *debuginfo_path = NULL;
+
+static const Dwfl_Callbacks proc_callbacks =
+ {
+ .find_elf = dwfl_linux_proc_find_elf,
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ .debuginfo_path = &debuginfo_path,
+ };
+
+static int
+thread_callback (Dwfl_Thread *thread, void *thread_arg)
+{
+ int *threads = (int *) thread_arg;
+ pid_t tid = dwfl_thread_tid (thread);
+ printf ("thread tid: %d\n", tid);
+ (*threads)++;
+
+ return DWARF_CB_OK;
+}
+
+int
+main (int argc __attribute__ ((unused)),
+ char **argv __attribute__ ((unused)))
+{
+ /* Create two extra threads to iterate through. */
+ int err;
+ if ((err = pthread_create (&thread1, NULL, sleeper, NULL)) != 0)
+ error (-1, err, "Couldn't create thread1");
+ if ((err = pthread_create (&thread2, NULL, sleeper, NULL)) != 0)
+ error (-1, err, "Couldn't create thread2");
+
+ Dwfl *dwfl = dwfl_begin (&proc_callbacks);
+ if (dwfl == NULL)
+ error (-1, 0, "dwfl_begin: %s", dwfl_errmsg (-1));
+
+ pid_t pid = getpid ();
+ /* This used to fail, since we don't have any modules yet. */
+ if (dwfl_linux_proc_attach (dwfl, pid, false) < 0)
+ error (-1, 0, "dwfl_linux_proc_attach pid %d: %s", pid,
+ dwfl_errmsg (-1));
+
+ /* Did we see all 3 threads? */
+ int threads = 0;
+ if (dwfl_getthreads (dwfl, thread_callback, &threads) != DWARF_CB_OK)
+ error (-1, 0, "dwfl_getthreads failed: %s", dwfl_errmsg (-1));
+
+ return (threads == 3) ? 0 : -1;
+}
+
+#endif /* __linux__ */
diff --git a/tests/dwfl-report-elf-align.c b/tests/dwfl-report-elf-align.c
new file mode 100644
index 0000000..a4e97d3
--- /dev/null
+++ b/tests/dwfl-report-elf-align.c
@@ -0,0 +1,72 @@
+/* Test program for dwfl_report_elf incorrect BASE alignment.
+ Copyright (C) 2013 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <error.h>
+#include <locale.h>
+#include <string.h>
+#include <stdlib.h>
+#include ELFUTILS_HEADER(dwfl)
+
+
+static const Dwfl_Callbacks offline_callbacks =
+ {
+ .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo),
+ .section_address = INTUSE(dwfl_offline_section_address),
+ };
+
+
+int
+main (int argc, char **argv)
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ if (argc != 5)
+ error (1, 0, "dwfl-report-elf-align shlib.so base funcaddr funcname");
+
+ Dwfl *dwfl = dwfl_begin (&offline_callbacks);
+ assert (dwfl != NULL);
+
+ char *endptr;
+ uintptr_t base = strtoull (argv[2], &endptr, 0);
+ assert (endptr && !*endptr);
+
+ Dwfl_Module *mod = dwfl_report_elf (dwfl, argv[1], argv[1], -1, base, false);
+ assert (mod != NULL);
+
+ uintptr_t funcaddr = strtoull (argv[3], &endptr, 0);
+ assert (endptr && !*endptr);
+
+ Dwfl_Module *mod_found = dwfl_addrmodule (dwfl, funcaddr);
+ assert (mod_found == mod);
+
+ const char *symname = dwfl_module_addrname (mod, funcaddr);
+ assert (symname != NULL);
+ assert (strcmp (symname, argv[4]) == 0);
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/dwfllines.c b/tests/dwfllines.c
new file mode 100644
index 0000000..90379dd
--- /dev/null
+++ b/tests/dwfllines.c
@@ -0,0 +1,164 @@
+/* Copyright (C) 2013 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 <inttypes.h>
+#include <assert.h>
+#include ELFUTILS_HEADER(dw)
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+
+int
+main (int argc, char *argv[])
+{
+ int cnt;
+
+ Dwfl *dwfl = NULL;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &cnt, &dwfl);
+ assert (dwfl != NULL);
+
+ Dwarf_Die *cu = NULL;
+ Dwarf_Addr bias;
+ do
+ {
+ cu = dwfl_nextcu (dwfl, cu, &bias);
+ if (cu != NULL)
+ {
+ Dwfl_Module *mod = dwfl_cumodule (cu);
+ const char *modname = (dwfl_module_info (mod, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL)
+ ?: "<unknown>");
+ const char *cuname = (dwarf_diename (cu) ?: "<unknown>");
+
+ printf ("mod: %s CU: [%" PRIx64 "] %s\n", modname,
+ dwarf_dieoffset (cu), cuname);
+
+ size_t lines;
+ if (dwfl_getsrclines (cu, &lines) != 0)
+ continue; // No lines...
+
+ for (size_t i = 0; i < lines; i++)
+ {
+ Dwfl_Line *line = dwfl_onesrcline (cu, i);
+
+ Dwarf_Addr addr;
+ int lineno;
+ int colno;
+ Dwarf_Word mtime;
+ Dwarf_Word length;
+ const char *src = dwfl_lineinfo (line, &addr, &lineno, &colno,
+ &mtime, &length);
+
+ Dwarf_Addr dw_bias;
+ Dwarf_Line *dw_line = dwfl_dwarf_line (line, &dw_bias);
+ assert (bias == dw_bias);
+
+ Dwarf_Addr dw_addr;
+ if (dwarf_lineaddr (dw_line, &dw_addr) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineaddr: %s",
+ dwarf_errmsg (-1));
+ assert (addr == dw_addr + dw_bias);
+
+ unsigned int dw_op_index;
+ if (dwarf_lineop_index (dw_line, &dw_op_index) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineop_index: %s",
+ dwarf_errmsg (-1));
+
+ int dw_lineno;
+ if (dwarf_lineno (dw_line, &dw_lineno) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineno: %s",
+ dwarf_errmsg (-1));
+ assert (lineno == dw_lineno);
+
+ int dw_colno;
+ if (dwarf_linecol (dw_line, &dw_colno) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineno: %s",
+ dwarf_errmsg (-1));
+ assert (colno == dw_colno);
+
+ bool begin;
+ if (dwarf_linebeginstatement (dw_line, &begin) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_linebeginstatement: %s",
+ dwarf_errmsg (-1));
+
+ bool end;
+ if (dwarf_lineendsequence (dw_line, &end) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineendsequence: %s",
+ dwarf_errmsg (-1));
+
+ bool pend;
+ if (dwarf_lineprologueend (dw_line, &pend) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineprologueend: %s",
+ dwarf_errmsg (-1));
+
+ bool ebegin;
+ if (dwarf_lineepiloguebegin (dw_line, &ebegin) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineepiloguebegin: %s",
+ dwarf_errmsg (-1));
+
+ bool block;
+ if (dwarf_lineblock (dw_line, &block) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineblock: %s",
+ dwarf_errmsg (-1));
+
+ unsigned int isa;
+ if (dwarf_lineisa (dw_line, &isa) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_lineisa: %s",
+ dwarf_errmsg (-1));
+
+ unsigned int disc;
+ if (dwarf_linediscriminator (dw_line, &disc) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_linediscriminator: %s",
+ dwarf_errmsg (-1));
+
+ const char *dw_src;
+ Dwarf_Word dw_mtime;
+ Dwarf_Word dw_length;
+ dw_src = dwarf_linesrc (dw_line, &dw_mtime, &dw_length);
+ assert (strcmp (src, dw_src) == 0);
+ assert (mtime == dw_mtime);
+ assert (length == dw_length);
+
+ printf ("%zd %#" PRIx64 " %s:%d:%d\n"
+ " time: %#" PRIX64 ", len: %" PRIu64
+ ", idx: %d, b: %d, e: %d"
+ ", pe: %d, eb: %d, block: %d"
+ ", isa: %d, disc: %d\n",
+ i, addr, src, lineno, colno, mtime, length,
+ dw_op_index, begin, end, pend, ebegin, block, isa, disc);
+
+ Dwarf_Die *linecu = dwfl_linecu (line);
+ assert (cu == linecu);
+
+ Dwfl_Module *linemod = dwfl_linemodule (line);
+ assert (mod == linemod);
+ }
+ }
+ }
+ while (cu != NULL);
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/dwflmodtest.c b/tests/dwflmodtest.c
new file mode 100644
index 0000000..0027f96
--- /dev/null
+++ b/tests/dwflmodtest.c
@@ -0,0 +1,287 @@
+/* Test program for libdwfl basic module tracking, relocation.
+ Copyright (C) 2005, 2007 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <locale.h>
+#include <argp.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+
+static bool show_inlines;
+
+struct info
+{
+ Dwarf_Die *cudie;
+ Dwarf_Addr dwbias;
+};
+
+static int
+print_instance (Dwarf_Die *instance, void *arg)
+{
+ const struct info *info = arg;
+
+ printf (" inlined");
+
+ Dwarf_Files *files;
+ if (dwarf_getsrcfiles (info->cudie, &files, NULL) == 0)
+ {
+ Dwarf_Attribute attr_mem;
+ Dwarf_Word val;
+ if (dwarf_formudata (dwarf_attr (instance, DW_AT_call_file,
+ &attr_mem), &val) == 0)
+ {
+ const char *file = dwarf_filesrc (files, val, NULL, NULL);
+ int lineno = 0, colno = 0;
+ if (dwarf_formudata (dwarf_attr (instance, DW_AT_call_line,
+ &attr_mem), &val) == 0)
+ lineno = val;
+ if (dwarf_formudata (dwarf_attr (instance, DW_AT_call_column,
+ &attr_mem), &val) == 0)
+ colno = val;
+ if (lineno == 0)
+ {
+ if (file != NULL)
+ printf (" from %s", file);
+ }
+ else if (colno == 0)
+ printf (" at %s:%u", file, lineno);
+ else
+ printf (" at %s:%u:%u", file, lineno, colno);
+ }
+ }
+
+ Dwarf_Addr lo = -1, hi = -1, entry = -1;
+ if (dwarf_lowpc (instance, &lo) == 0)
+ lo += info->dwbias;
+ else
+ printf (" (lowpc => %s)", dwarf_errmsg (-1));
+ if (dwarf_highpc (instance, &hi) == 0)
+ hi += info->dwbias;
+ else
+ printf (" (highpc => %s)", dwarf_errmsg (-1));
+
+ Dwarf_Attribute attr_mem;
+ Dwarf_Attribute *attr = dwarf_attr (instance, DW_AT_entry_pc, &attr_mem);
+ if (attr != NULL)
+ {
+ if (dwarf_formaddr (attr, &entry) == 0)
+ entry += info->dwbias;
+ else
+ printf (" (entrypc => %s)", dwarf_errmsg (-1));
+ }
+
+ if (lo != (Dwarf_Addr) -1 || hi != (Dwarf_Addr) -1)
+ printf (" %#" PRIx64 "..%#" PRIx64, lo, hi);
+ if (entry != (Dwarf_Addr) -1)
+ printf (" => %#" PRIx64 "\n", entry);
+ else
+ puts ("");
+
+ return DWARF_CB_OK;
+}
+
+static void
+print_inline (Dwarf_Die *func, void *arg)
+{
+ if (dwarf_func_inline_instances (func, &print_instance, arg) != 0)
+ printf (" error finding instances: %s\n", dwarf_errmsg (-1));
+}
+
+static int
+print_func (Dwarf_Die *func, void *arg)
+{
+ const struct info *info = arg;
+
+ const char *file = dwarf_decl_file (func);
+ int line = -1;
+ dwarf_decl_line (func, &line);
+ const char *fct = dwarf_diename (func);
+
+ printf (" %s:%d: %s:", file, line, fct);
+
+ if (dwarf_func_inline (func))
+ {
+ puts (" inline function");
+ if (show_inlines)
+ print_inline (func, arg);
+ }
+ else
+ {
+ Dwarf_Addr lo = -1, hi = -1, entry = -1;
+ if (dwarf_lowpc (func, &lo) == 0)
+ lo += info->dwbias;
+ else
+ printf (" (lowpc => %s)", dwarf_errmsg (-1));
+ if (dwarf_highpc (func, &hi) == 0)
+ hi += info->dwbias;
+ else
+ printf (" (highpc => %s)", dwarf_errmsg (-1));
+ if (dwarf_entrypc (func, &entry) == 0)
+ entry += info->dwbias;
+ else
+ printf (" (entrypc => %s)", dwarf_errmsg (-1));
+
+ if (lo != (Dwarf_Addr) -1 || hi != (Dwarf_Addr) -1
+ || entry != (Dwarf_Addr) -1)
+ printf (" %#" PRIx64 "..%#" PRIx64 " => %#" PRIx64 "\n",
+ lo, hi, entry);
+ else
+ puts ("");
+ }
+
+ return DWARF_CB_OK;
+}
+
+static int
+list_module (Dwfl_Module *mod __attribute__ ((unused)),
+ void **userdata __attribute__ ((unused)),
+ const char *name, Dwarf_Addr base,
+ void *arg __attribute__ ((unused)))
+{
+ Dwarf_Addr start;
+ Dwarf_Addr end;
+ const char *file;
+ const char *debug;
+ if (dwfl_module_info (mod, NULL, &start, &end,
+ NULL, NULL, &file, &debug) != name
+ || start != base)
+ abort ();
+ printf ("module: %30s %08" PRIx64 "..%08" PRIx64 " %s %s\n",
+ name, start, end, file, debug);
+ return DWARF_CB_OK;
+}
+
+static int
+print_module (Dwfl_Module *mod __attribute__ ((unused)),
+ void **userdata __attribute__ ((unused)),
+ const char *name, Dwarf_Addr base,
+ Dwarf *dw, Dwarf_Addr bias,
+ void *arg)
+{
+ printf ("module: %30s %08" PRIx64 " %s %" PRIx64 " (%s)\n",
+ name, base, dw == NULL ? "no" : "DWARF", bias, dwfl_errmsg (-1));
+
+ if (dw != NULL && *(const bool *) arg)
+ {
+ Dwarf_Off off = 0;
+ size_t cuhl;
+ Dwarf_Off noff;
+
+ while (dwarf_nextcu (dw, off, &noff, &cuhl, NULL, NULL, NULL) == 0)
+ {
+ Dwarf_Die die_mem;
+ struct info info = { dwarf_offdie (dw, off + cuhl, &die_mem), bias };
+ (void) dwarf_getfuncs (info.cudie, print_func, &info, 0);
+
+ off = noff;
+ }
+ }
+
+ return DWARF_CB_OK;
+}
+
+static bool show_functions;
+
+/* gettext helper macro. */
+#undef N_
+#define N_(Str) Str
+
+static const struct argp_option options[] =
+ {
+ { "functions", 'f', NULL, 0, N_("Additionally show function names"), 0 },
+ { "inlines", 'i', NULL, 0, N_("Show instances of inlined functions"), 0 },
+ { NULL, 0, NULL, 0, NULL, 0 }
+ };
+
+static error_t
+parse_opt (int key, char *arg __attribute__ ((unused)),
+ struct argp_state *state __attribute__ ((unused)))
+{
+ switch (key)
+ {
+ case ARGP_KEY_INIT:
+ state->child_inputs[0] = state->input;
+ break;
+
+ case 'f':
+ show_functions = true;
+ break;
+
+ case 'i':
+ show_inlines = show_functions = true;
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ Dwfl *dwfl = NULL;
+ const struct argp_child argp_children[] =
+ {
+ { .argp = dwfl_standard_argp () },
+ { .argp = NULL }
+ };
+ const struct argp argp =
+ {
+ options, parse_opt, NULL, NULL, argp_children, NULL, NULL
+ };
+ (void) argp_parse (&argp, argc, argv, 0, NULL, &dwfl);
+ assert (dwfl != NULL);
+
+ ptrdiff_t p = 0;
+ do
+ p = dwfl_getmodules (dwfl, &list_module, NULL, p);
+ while (p > 0);
+ if (p < 0)
+ error (2, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
+
+ do
+ p = dwfl_getdwarf (dwfl, &print_module, &show_functions, p);
+ while (p > 0);
+ if (p < 0)
+ error (2, 0, "dwfl_getdwarf: %s", dwfl_errmsg (-1));
+
+ p = 0;
+ do
+ p = dwfl_getmodules (dwfl, &list_module, NULL, p);
+ while (p > 0);
+ if (p < 0)
+ error (2, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/dwflsyms.c b/tests/dwflsyms.c
new file mode 100644
index 0000000..49ac334
--- /dev/null
+++ b/tests/dwflsyms.c
@@ -0,0 +1,226 @@
+/* Test program for libdwfl symbol resolving
+ Copyright (C) 2013 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <elf.h>
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <error.h>
+#include <string.h>
+
+static const char *
+gelf_type (GElf_Sym *sym)
+{
+ switch (GELF_ST_TYPE (sym->st_info))
+ {
+ case STT_NOTYPE:
+ return "NOTYPE";
+ case STT_OBJECT:
+ return "OBJECT";
+ case STT_FUNC:
+ return "FUNC";
+ case STT_SECTION:
+ return "SECTION";
+ case STT_FILE:
+ return "FILE";
+ case STT_COMMON:
+ return "COMMON";
+ case STT_TLS:
+ return "TLS";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *
+gelf_bind (GElf_Sym *sym)
+{
+ switch (GELF_ST_BIND (sym->st_info))
+ {
+ case STB_LOCAL:
+ return "LOCAL";
+ case STB_GLOBAL:
+ return "GLOBAL";
+ case STB_WEAK:
+ return "WEAK";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static int
+gelf_bind_order (GElf_Sym *sym)
+{
+ switch (GELF_ST_BIND (sym->st_info))
+ {
+ case STB_LOCAL:
+ return 1;
+ case STB_WEAK:
+ return 2;
+ case STB_GLOBAL:
+ return 3;
+ default:
+ return 0;
+ }
+}
+
+static const char *
+elf_section_name (Elf *elf, GElf_Word shndx)
+{
+ GElf_Ehdr ehdr;
+ GElf_Shdr shdr;
+ Elf_Scn *scn = elf_getscn (elf, shndx);
+ gelf_getshdr (scn, &shdr);
+ gelf_getehdr (elf, &ehdr);
+ return elf_strptr (elf, ehdr.e_shstrndx, shdr.sh_name);
+}
+
+bool
+addr_in_section (Elf *elf, GElf_Word shndx, GElf_Addr addr)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn = elf_getscn (elf, shndx);
+ gelf_getshdr (scn, &shdr);
+ return addr >= shdr.sh_addr && addr < shdr.sh_addr + shdr.sh_size;
+}
+
+static int
+list_syms (struct Dwfl_Module *mod,
+ void **user __attribute__ ((unused)), const char *mod_name,
+ Dwarf_Addr low_addr __attribute__ ((unused)),
+ void *arg __attribute__ ((unused)))
+{
+ int syms = dwfl_module_getsymtab (mod);
+ if (syms < 0)
+ {
+ printf ("%s: %s\n", mod_name, dwfl_errmsg (-1));
+ return DWARF_CB_OK;
+ }
+
+ for (int ndx = 0; ndx < syms; ndx++)
+ {
+ GElf_Sym sym;
+ GElf_Word shndxp;
+ Elf *elf;
+ Dwarf_Addr bias;
+ const char *name = dwfl_module_getsym (mod, ndx, &sym, &shndxp);
+
+ printf("%4d: %s\t%s\t%s (%" PRIu64 ") %#" PRIx64,
+ ndx, gelf_type (&sym), gelf_bind (&sym), name,
+ sym.st_size, sym.st_value);
+
+ /* The info variant doesn't adjust st_value but returns the (possible)
+ adjusted value separately. */
+ GElf_Addr value;
+ GElf_Sym isym;
+ name = dwfl_module_getsym_info (mod, ndx, &isym, &value, &shndxp,
+ &elf, &bias);
+
+ GElf_Ehdr ehdr;
+ gelf_getehdr (elf, &ehdr);
+
+ // getsym st_values might or might not be adjusted depending on section.
+ // For ET_REL the adjustment is section relative.
+ assert (sym.st_value == isym.st_value
+ || sym.st_value == isym.st_value + bias
+ || ehdr.e_type == ET_REL);
+
+ /* And the reverse, which works for function symbols at least.
+ Note this only works because the st.value is adjusted by
+ dwfl_module_getsym (). */
+ if (GELF_ST_TYPE (sym.st_info) == STT_FUNC && shndxp != SHN_UNDEF)
+ {
+ /* Make sure the adjusted value really falls in the elf section. */
+ assert (addr_in_section (elf, shndxp, sym.st_value - bias));
+
+ GElf_Addr addr = value;
+ GElf_Sym asym;
+ GElf_Word ashndxp;
+ Elf *aelf;
+ Dwarf_Addr abias;
+ GElf_Off off;
+ const char *aname = dwfl_module_addrinfo (mod, addr, &off, &asym,
+ &ashndxp, &aelf, &abias);
+
+ /* Make sure the adjusted value really falls in the elf section. */
+ assert (addr_in_section (aelf, ashndxp, asym.st_value)
+ || ehdr.e_type == ET_REL);
+
+ /* Either they are the same symbol (name), the binding of
+ asym is "stronger" (or equal) to sym or asym is more specific
+ (has a lower address) than sym. */
+ assert ((strcmp (name, aname) == 0
+ || gelf_bind_order (&asym) >= gelf_bind_order (&sym))
+ && value <= sym.st_value);
+
+ addr = sym.st_value;
+ int res = dwfl_module_relocate_address (mod, &addr);
+ assert (res != -1);
+ if (shndxp < SHN_LORESERVE)
+ printf(", rel: %#" PRIx64 " (%s)", addr,
+ elf_section_name (elf, shndxp));
+ else
+ printf(", rel: %#" PRIx64 "", addr);
+
+ /* Print the section of the actual value if different from sym. */
+ if (value != isym.st_value + bias && ehdr.e_type != ET_REL)
+ {
+ GElf_Addr ebias;
+ addr = value;
+ Elf_Scn *scn = dwfl_module_address_section (mod, &addr, &ebias);
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ Elf *melf = dwfl_module_getelf (mod, &ebias);
+ gelf_getehdr (melf, &ehdr);
+ const char *sname = elf_strptr (melf, ehdr.e_shstrndx,
+ shdr->sh_name);
+ printf (" [%#" PRIx64 ", rel: %#" PRIx64 " (%s)]",
+ value, addr, sname);
+ }
+
+ }
+ printf ("\n");
+ }
+
+ return DWARF_CB_OK;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+ Dwfl *dwfl;
+ error_t res;
+
+ res = argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
+ assert (res == 0 && dwfl != NULL);
+
+ ptrdiff_t off = 0;
+ do
+ off = dwfl_getmodules (dwfl, list_syms, NULL, off);
+ while (off > 0);
+
+ dwfl_end (dwfl);
+
+ return off;
+}
diff --git a/tests/early-offscn.c b/tests/early-offscn.c
new file mode 100644
index 0000000..924cb9e
--- /dev/null
+++ b/tests/early-offscn.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 2008 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 <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char *argv[])
+{
+ if (argc < 2)
+ error (1, 0, "Usage: %s FILE OFFSET", argv[0]);
+
+ /* Set the ELF version. */
+ elf_version (EV_CURRENT);
+
+ /* Open the archive. */
+ int fd = open (argv[1], O_RDONLY);
+ if (fd < 0)
+ error (1, errno, "cannot open '%s'", argv[1]);
+
+ Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ error (2, 0, "elf_begin: %s", elf_errmsg (-1));
+
+ Elf_Scn *scn = gelf_offscn (elf, strtoull (argv[2], NULL, 0));
+ if (scn == NULL)
+ error (3, 0, "gelf_offscn: %s", elf_errmsg (-1));
+
+ elf_end (elf);
+ return 0;
+}
diff --git a/tests/ecp.c b/tests/ecp.c
new file mode 100644
index 0000000..38a6859
--- /dev/null
+++ b/tests/ecp.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main (int argc, char *argv[])
+{
+ if (argc < 3)
+ error (EXIT_FAILURE, 0, "usage: %s FROMNAME TONAME", argv[0]);
+
+ elf_version (EV_CURRENT);
+
+ int infd = open (argv[1], O_RDONLY);
+ if (infd == -1)
+ error (EXIT_FAILURE, errno, "cannot open input file '%s'", argv[1]);
+
+ Elf *inelf = elf_begin (infd, ELF_C_READ, NULL);
+ if (inelf == NULL)
+ error (EXIT_FAILURE, 0, "problems opening '%s' as ELF file: %s",
+ argv[1], elf_errmsg (-1));
+
+ int outfd = creat (argv[2], 0666);
+ if (outfd == -1)
+ error (EXIT_FAILURE, errno, "cannot open output file '%s'", argv[2]);
+
+ Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
+ if (outelf == NULL)
+ error (EXIT_FAILURE, 0, "problems opening '%s' as ELF file: %s",
+ argv[2], elf_errmsg (-1));
+
+ gelf_newehdr (outelf, gelf_getclass (inelf));
+
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr;
+ gelf_update_ehdr (outelf, (ehdr = gelf_getehdr (inelf, &ehdr_mem)));
+
+ if (ehdr->e_phnum > 0)
+ {
+ int cnt;
+
+ if (gelf_newphdr (outelf, ehdr->e_phnum) == 0)
+ error (EXIT_FAILURE, 0, "cannot create program header: %s",
+ elf_errmsg (-1));
+
+ for (cnt = 0; cnt < ehdr->e_phnum; ++cnt)
+ {
+ GElf_Phdr phdr_mem;
+
+ gelf_update_phdr (outelf, cnt, gelf_getphdr (inelf, cnt, &phdr_mem));
+ }
+ }
+
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (inelf, scn)) != NULL)
+ {
+ Elf_Scn *newscn = elf_newscn (outelf);
+
+ GElf_Shdr shdr_mem;
+ gelf_update_shdr (newscn, gelf_getshdr (scn, &shdr_mem));
+
+ *elf_newdata (newscn) = *elf_getdata (scn, NULL);
+ }
+
+ elf_flagelf (outelf, ELF_C_SET, ELF_F_LAYOUT);
+
+ if (elf_update (outelf, ELF_C_WRITE) == -1)
+ error (EXIT_FAILURE, 0, "elf_update failed: %s", elf_errmsg (-1));
+
+ elf_end (outelf);
+ close (outfd);
+
+ elf_end (inelf);
+
+ return 0;
+}
diff --git a/tests/elfgetchdr.c b/tests/elfgetchdr.c
new file mode 100644
index 0000000..44ba178
--- /dev/null
+++ b/tests/elfgetchdr.c
@@ -0,0 +1,124 @@
+/* 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;
+ }
+
+ if ((shdr.sh_flags & SHF_COMPRESSED) != 0)
+ {
+ GElf_Chdr chdr;
+ if (gelf_getchdr (scn, &chdr) == NULL)
+ {
+ printf ("gelf_getchdr failed: %s\n", elf_errmsg (-1));
+ result = 1;
+ break;
+ }
+
+ printf ("section %d: ELF Compressed ch_type: %" PRId32
+ ", ch_size: %" PRIx64 ", ch_addralign: %" PRIx64 "\n",
+ idx, chdr.ch_type, chdr.ch_size, chdr.ch_addralign);
+ }
+ else
+ {
+ 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;
+ }
+
+ /* This duplicates what the dwelfgnucompressed testcase does. */
+ 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);
+ }
+ else
+ printf ("section %d: NOT Compressed\n", idx);
+ }
+ }
+
+ elf_end (elf);
+ close (fd);
+ }
+
+ return result;
+}
diff --git a/tests/elfgetzdata.c b/tests/elfgetzdata.c
new file mode 100644
index 0000000..82afbe5
--- /dev/null
+++ b/tests/elfgetzdata.c
@@ -0,0 +1,113 @@
+/* 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 <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <libelf.h>
+#include <gelf.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int result = 0;
+ int cnt;
+
+ if (argc < 3
+ || (strcmp (argv[1], "read") != 0
+ && strcmp (argv[1], "mmap") != 0))
+ {
+ printf ("Usage: (read|mmap) files...\n");
+ return -1;
+ }
+
+ bool mmap = strcmp (argv[1], "mmap") == 0;
+
+ elf_version (EV_CURRENT);
+
+ for (cnt = 2; cnt < argc; ++cnt)
+ {
+ int fd = open (argv[cnt], O_RDONLY);
+
+ Elf *elf = elf_begin (fd, mmap ? ELF_C_READ_MMAP : ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("%s not usable %s\n", argv[cnt], elf_errmsg (-1));
+ result = 1;
+ close (fd);
+ continue;
+ }
+
+ /* To get the section names. */
+ size_t strndx;
+ elf_getshdrstrndx (elf, &strndx);
+
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ size_t idx = elf_ndxscn (scn);
+ GElf_Shdr mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &mem);
+ const char *name = elf_strptr (elf, strndx, shdr->sh_name);
+ if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
+ {
+ /* Real compressed section. */
+ if (elf_compress (scn, 0, 0) < 0)
+ {
+ printf ("elf_compress failed for section %zd: %s\n",
+ idx, elf_errmsg (-1));
+ return -1;
+ }
+ Elf_Data *d = elf_getdata (scn, NULL);
+ printf ("%zd: %s, ELF compressed, size: %zx\n",
+ idx, name, d->d_size);
+ }
+ else
+ {
+ /* Maybe an old GNU compressed .z section? */
+ if (name[0] == '.' && name[1] == 'z')
+ {
+ if (elf_compress_gnu (scn, 0, 0) < 0)
+ {
+ printf ("elf_compress_gnu failed for section %zd: %s\n",
+ idx, elf_errmsg (-1));
+ return -1;
+ }
+ Elf_Data *d = elf_getdata (scn, NULL);
+ printf ("%zd: %s, GNU compressed, size: %zx\n",
+ idx, name, d->d_size);
+ }
+ else
+ printf ("%zd: %s, NOT compressed\n", idx, name);
+ }
+ }
+
+ elf_end (elf);
+ close (fd);
+ }
+
+ return result;
+}
diff --git a/tests/elfputzdata.c b/tests/elfputzdata.c
new file mode 100644
index 0000000..66ab77b
--- /dev/null
+++ b/tests/elfputzdata.c
@@ -0,0 +1,237 @@
+/* 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 <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <libelf.h>
+#include <gelf.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int result = 0;
+ int cnt;
+
+ if (argc < 3
+ || (strcmp (argv[1], "elf") != 0
+ && strcmp (argv[1], "gnu") != 0))
+ {
+ printf ("Usage: (elf|gnu) files...\n");
+ return -1;
+ }
+
+ int gnu;
+ if (strcmp (argv[1], "gnu") == 0)
+ gnu = 1;
+ else
+ gnu = 0;
+
+ elf_version (EV_CURRENT);
+
+ for (cnt = 2; 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;
+ }
+
+ /* To get the section names. */
+ size_t strndx;
+ elf_getshdrstrndx (elf, &strndx);
+
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ size_t idx = elf_ndxscn (scn);
+ GElf_Shdr mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &mem);
+ const char *name = elf_strptr (elf, strndx, shdr->sh_name);
+ if (shdr->sh_type == SHT_NOBITS
+ || (shdr->sh_flags & SHF_ALLOC) != 0)
+ {
+ printf ("Cannot compress %zd %s\n", idx, name);
+ }
+ else if ((shdr->sh_flags & SHF_COMPRESSED) != 0
+ || strncmp (name, ".zdebug", strlen (".zdebug")) == 0)
+ {
+ printf ("Already compressed %zd %s\n", idx, name);
+ }
+ else
+ {
+ size_t orig_size = shdr->sh_size;
+ printf ("Lets compress %zd %s, size: %" PRId64 "\n",
+ idx, name, shdr->sh_size);
+ Elf_Data *d = elf_getdata (scn, NULL);
+ if (d == NULL)
+ {
+ printf ("Couldn't get orig data for section %zd\n", idx);
+ return -1;
+ }
+ /* Make a copy so we can compare after
+ compression/decompression. */
+ if (d->d_size != orig_size)
+ {
+ printf ("Unexpected data size for orig section %zd\n", idx);
+ return -1;
+ }
+ char *orig_buf = malloc (d->d_size);
+ if (orig_size > 0 && orig_buf == NULL)
+ {
+ printf ("No memory to copy section %zd data\n", idx);
+ return -1;
+ }
+ if (orig_size > 0)
+ memcpy (orig_buf, d->d_buf, orig_size);
+
+ bool forced = false;
+ if (gnu)
+ {
+ int res = elf_compress_gnu (scn, 1, 0);
+ if (res == 0)
+ {
+ forced = true;
+ res = elf_compress_gnu (scn, 1, ELF_CHF_FORCE);
+ }
+ if (res < 0)
+ {
+ printf ("elf_compress_gnu%sfailed for section %zd: %s\n",
+ forced ? " (forced) " : " ",
+ idx, elf_errmsg (-1));
+ return -1;
+ }
+ }
+ else
+ {
+ int res = elf_compress (scn, ELFCOMPRESS_ZLIB, 0);
+ if (res == 0)
+ {
+ forced = true;
+ res = elf_compress (scn, ELFCOMPRESS_ZLIB, ELF_CHF_FORCE);
+ }
+ if (res < 0)
+ {
+ printf ("elf_compress%sfailed for section %zd: %s\n",
+ forced ? " (forced) " : " ",
+ idx, elf_errmsg (-1));
+ return -1;
+ }
+ }
+ GElf_Shdr newmem;
+ GElf_Shdr *newshdr = gelf_getshdr (scn, &newmem);
+ size_t new_size = newshdr->sh_size;
+ d = elf_getdata (scn, NULL);
+ // Don't check this, might depend on zlib implementation.
+ // fprintf (stderr, " new_size: %zd\n", new_size);
+ if (d->d_size != new_size)
+ {
+ printf ("Unexpected data size for compressed section %zd\n",
+ idx);
+ return -1;
+ }
+
+ if (forced && new_size < orig_size)
+ {
+ printf ("section %zd forced to compress, but size smaller\n",
+ idx);
+ return -1;
+ }
+
+ if (! forced && new_size >= orig_size)
+ {
+ printf ("section %zd compressed to bigger size\n",
+ idx);
+ return -1;
+ }
+
+ if (new_size == orig_size
+ && memcmp (orig_buf, d->d_buf, orig_size) == 0)
+ {
+ printf ("section %zd didn't compress\n", idx);
+ return -1;
+ }
+
+ if (gnu)
+ {
+ if (elf_compress_gnu (scn, 0, 0) < 0)
+ {
+ printf ("elf_[un]compress_gnu failed for section %zd: %s\n",
+ idx, elf_errmsg (-1));
+ return -1;
+ }
+ }
+ else
+ {
+ if (elf_compress (scn, 0, 0) < 0)
+ {
+ printf ("elf_[un]compress failed for section %zd: %s\n",
+ idx, elf_errmsg (-1));
+ return -1;
+ }
+ }
+ GElf_Shdr newermem;
+ GElf_Shdr *newershdr = gelf_getshdr (scn, &newermem);
+ size_t newer_size = newershdr->sh_size;
+ d = elf_getdata (scn, NULL);
+ // fprintf (stderr, " newer_size: %zd\n", newer_size);
+ if (d->d_size != newer_size)
+ {
+ printf ("Unexpected data size for compressed section %zd\n",
+ idx);
+ return -1;
+ }
+ if (newer_size != orig_size
+ && memcmp (orig_buf, d->d_buf, orig_size) != 0)
+ {
+ printf ("section %zd didn't correctly uncompress\n", idx);
+ return -1;
+ }
+ free (orig_buf);
+ // Recompress the string table, just to make sure
+ // everything keeps working. See elf_strptr above.
+ if (! gnu && idx == strndx
+ && elf_compress (scn, ELFCOMPRESS_ZLIB, 0) < 0)
+ {
+ printf ("couldn't recompress section header strings: %s\n",
+ elf_errmsg (-1));
+ return -1;
+ }
+ }
+ }
+
+ elf_end (elf);
+ close (fd);
+ }
+
+ return result;
+}
diff --git a/tests/elfshphehdr.c b/tests/elfshphehdr.c
new file mode 100644
index 0000000..8183937
--- /dev/null
+++ b/tests/elfshphehdr.c
@@ -0,0 +1,182 @@
+/* Test program for adding section and program headers and ehdr updates.
+ 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <stdbool.h>
+
+void
+check (const char *msg, bool statement)
+{
+ if (! statement)
+ {
+ fprintf (stderr, "%s FAILED\n", msg);
+ exit (-1);
+ }
+ else
+ fprintf (stderr, "%s OK\n", msg);
+}
+
+void
+check_elf (const char *msg, bool statement)
+{
+ if (! statement)
+ {
+ fprintf (stderr, "%s: %s\n", msg, elf_errmsg (-1));
+ exit (-1);
+ }
+ else
+ fprintf (stderr, "%s OK\n", msg);
+}
+
+void
+test (Elf *elf, int class, bool layout)
+{
+ fprintf (stderr, "testing ELF class: %d, layout: %d\n", class, layout);
+
+ check_elf ("gelf_newehdr", gelf_newehdr (elf, class) != 0);
+ check_elf ("gelf_getclass", gelf_getclass (elf) == class);
+
+ check_elf ("elf_flagelf", elf_flagelf (elf, layout ? ELF_C_SET : ELF_C_CLR,
+ ELF_F_LAYOUT) != 0);
+
+ GElf_Ehdr ehdr;
+ check_elf ("gelf_getehdr", gelf_getehdr (elf, &ehdr) != NULL);
+ check ("e_shnum == 0", ehdr.e_shnum == 0);
+ check ("e_phnum == 0", ehdr.e_phnum == 0);
+ check ("e_shoff == 0", ehdr.e_shoff == 0);
+ check ("e_phoff == 0", ehdr.e_phoff == 0);
+
+ size_t shnum;
+ check_elf ("elf_getshdrnum", elf_getshdrnum (elf, &shnum) == 0);
+ check ("shnum == 0", shnum == 0);
+
+ size_t phnum;
+ check_elf ("elf_getphdrnum", elf_getphdrnum (elf, &phnum) == 0);
+ check ("phnum == 0", phnum == 0);
+
+ /* Lets fill in some info we are always responsible for. */
+ ehdr.e_ident[EI_DATA] = ELFDATANONE; /* Ask for native encoding. */
+ ehdr.e_type = ET_EXEC;
+ ehdr.e_machine = EM_386;
+ ehdr.e_version = EV_NONE; /* Ask for current version. */
+ check_elf ("gelf_update_ehdr", gelf_update_ehdr (elf, &ehdr) != 0);
+
+ check_elf ("elf_update", elf_update (elf, ELF_C_NULL) > 0);
+
+ check_elf ("gelf_getehdr", gelf_getehdr (elf, &ehdr) != NULL);
+ check ("EI_DATA", ehdr.e_ident[EI_DATA] != ELFDATANONE);
+ check ("e_version", ehdr.e_version == EV_CURRENT);
+
+ /* The sh/ph values shouldn't have changed. */
+ check ("e_shnum == 0", ehdr.e_shnum == 0);
+ check ("e_phnum == 0", ehdr.e_phnum == 0);
+ check ("e_shoff == 0", ehdr.e_shoff == 0);
+ check ("e_phoff == 0", ehdr.e_phoff == 0);
+
+ check_elf ("elf_getshdrnum", elf_getshdrnum (elf, &shnum) == 0);
+ check ("shnum == 0", shnum == 0);
+
+ check_elf ("elf_getphdrnum", elf_getphdrnum (elf, &phnum) == 0);
+ check ("phnum == 0", phnum == 0);
+
+ /* Lets add a header. */
+ check_elf ("elf_newscn", elf_newscn (elf) != NULL);
+ check_elf ("gelf_newphdr", gelf_newphdr (elf, 1) != 0);
+
+ /* If we are responsible for the layout ourselves we should also
+ tell where to put them. */
+ if (layout)
+ {
+ check_elf ("gelf_getehdr", gelf_getehdr (elf, &ehdr) != NULL);
+ /* phdrs go right after the ehdr. */
+ ehdr.e_phoff = ehdr.e_ehsize;
+ /* shdrs go right after the phdrs. */
+ ehdr.e_shoff = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize;
+ check_elf ("gelf_update_ehdr", gelf_update_ehdr (elf, &ehdr) != 0);
+ }
+
+ check_elf ("elf_update", elf_update (elf, ELF_C_NULL) > 0);
+
+ check_elf ("elf_getshdrnum", elf_getshdrnum (elf, &shnum) == 0);
+ check ("shnum == 1", shnum == 2); /* section zero is also created. */
+
+ check_elf ("elf_getphdrnum", elf_getphdrnum (elf, &phnum) == 0);
+ check ("phnum == 1", phnum == 1);
+
+ check_elf ("gelf_getehdr", gelf_getehdr (elf, &ehdr) != NULL);
+
+ check ("EI_DATA", ehdr.e_ident[EI_DATA] != ELFDATANONE);
+ check ("e_version", ehdr.e_version == EV_CURRENT);
+
+ check ("e_shnum == 2", ehdr.e_shnum == 2);
+ check ("e_phnum == 1", ehdr.e_phnum == 1);
+ check ("e_shoff != 0", ehdr.e_shoff != 0);
+ check ("e_phoff != 0", ehdr.e_phoff != 0);
+
+ size_t shentsize = (class == ELFCLASS32
+ ? sizeof (Elf32_Shdr) : sizeof (Elf64_Shdr));
+ check ("e_shentsize", ehdr.e_shentsize == shentsize);
+ size_t phentsize = (class == ELFCLASS32
+ ? sizeof (Elf32_Phdr) : sizeof (Elf64_Phdr));
+ check ("e_phentsize", ehdr.e_phentsize == phentsize);
+}
+
+int
+main (int argc __attribute__ ((unused)), char **argv __attribute ((unused)))
+{
+ elf_version (EV_CURRENT);
+
+ int fd = open("/dev/null", O_WRONLY);
+ check ("open", fd >= 0);
+
+ Elf *elf;
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ check_elf ("elf_begin", elf != NULL);
+ test (elf, ELFCLASS32, false);
+ elf_end (elf);
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ check_elf ("elf_begin", elf != NULL);
+ test (elf, ELFCLASS32, true);
+ elf_end (elf);
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ check_elf ("elf_begin", elf != NULL);
+ test (elf, ELFCLASS64, false);
+ elf_end (elf);
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ check_elf ("elf_begin", elf != NULL);
+ test (elf, ELFCLASS64, true);
+ elf_end (elf);
+
+ close (fd);
+ return 0;
+}
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
new file mode 100644
index 0000000..3bb90c4
--- /dev/null
+++ b/tests/elfstrmerge.c
@@ -0,0 +1,675 @@
+/* Merge string sections.
+ Copyright (C) 2015, 2016 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/>. */
+
+#include <config.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <error.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <unistd.h>
+
+#include <system.h>
+#include <gelf.h>
+#include ELFUTILS_HEADER(dwelf)
+#include "elf-knowledge.h"
+
+/* The original ELF file. */
+static int fd = -1;
+static Elf *elf = NULL;
+static bool replace;
+
+/* The new ELF file. */
+static char *fnew = NULL;
+static int fdnew = -1;
+static Elf *elfnew = NULL;
+
+/* The merged string table. */
+static Dwelf_Strtab *strings = NULL;
+
+/* Section name strents. */
+static Dwelf_Strent **scnstrents = NULL;
+
+/* Symbol name strends. */
+static Dwelf_Strent **symstrents = NULL;
+
+/* New ELF file buffers. */
+static Elf_Data newstrtabdata = { .d_buf = NULL };
+static size_t newshnums = 0;
+static void **newscnbufs = NULL;
+
+/* Release all files and resources allocated. */
+static void
+release (void)
+{
+ /* The new string table. */
+ if (strings != NULL)
+ dwelf_strtab_free (strings);
+
+ free (scnstrents);
+ free (symstrents);
+ free (newstrtabdata.d_buf);
+
+ /* Any new data buffers allocated. */
+ for (size_t i = 0; i < newshnums; i++)
+ free (newscnbufs[i]);
+ free (newscnbufs);
+
+ /* The new ELF file. */
+ if (fdnew != -1)
+ {
+ unlink (fnew);
+ elf_end (elfnew);
+ close (fdnew);
+ }
+ // Don't release, we might need it in the error message.
+ // if (replace)
+ // free (fnew);
+
+ /* The original ELF file. */
+ elf_end (elf);
+ close (fd);
+}
+
+/* The various ways we can fail... Cleanup and show some message to
+ the user. The file name may be NULL. */
+static void __attribute__ ((noreturn))
+fail (const char *msg, const char *fname)
+{
+ release ();
+ if (fname != NULL)
+ error (1, 0, "%s: %s", fname, msg);
+ else
+ error (1, 0, "%s", msg);
+ abort();
+}
+
+static void __attribute__ ((noreturn))
+fail_errno (const char *msg, const char *fname)
+{
+ release ();
+ if (fname != NULL)
+ error (1, errno, "%s: %s", fname, msg);
+ else
+ error (1, errno, "%s", msg);
+ abort();
+}
+
+static void __attribute__ ((noreturn))
+fail_idx (const char *msg, const char *fname, size_t idx)
+{
+ release ();
+ if (fname != NULL)
+ error (1, 0, "%s: %s %zd", fname, msg, idx);
+ else
+ error (1, 0, "%s %zd", msg, idx);
+ abort();
+}
+
+static void __attribute__ ((noreturn))
+fail_elf (const char *msg, const char *fname)
+{
+ release ();
+ if (fname != NULL)
+ error (1, 0, "%s: %s: %s", fname, msg, elf_errmsg (-1));
+ else
+ error (1, 0, "%s: %s", msg, elf_errmsg (-1));
+ abort();
+}
+
+static void __attribute__ ((noreturn))
+fail_elf_idx (const char *msg, const char *fname, size_t idx)
+{
+ release ();
+ if (fname != NULL)
+ error (1, 0, "%s: %s %zd: %s", fname, msg, idx, elf_errmsg (-1));
+ else
+ error (1, 0, "%s %zd: %s", msg, idx, elf_errmsg (-1));
+ abort();
+}
+
+int
+main (int argc, char **argv)
+{
+ elf_version (EV_CURRENT);
+
+ /* Basic command line handling. Need to replace the input file? */
+ if ((argc != 2 && argc != 4)
+ || (argc == 4 && strcmp (argv[1], "-o") != 0))
+ fail ("Usage argument: [-o <outputfile>] <inputfile>", NULL);
+ replace = argc == 2;
+
+ /* Get the ELF file. */
+ const char *fname;
+ if (replace)
+ fname = argv[1];
+ else
+ fname = argv[3];
+ fd = open (fname, O_RDONLY);
+ if (fd < 0)
+ fail_errno ("couldn't open", fname);
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ fail_elf ("couldn't open ELF file for reading", fname);
+
+ GElf_Ehdr ehdr;
+ if (gelf_getehdr (elf, &ehdr) == NULL)
+ fail_elf ("Couldn't get ehdr", fname);
+
+ /* Get the section header string table. */
+ size_t shdrstrndx;
+ if (elf_getshdrstrndx (elf, &shdrstrndx) != 0)
+ fail_elf ("couldn't get section header string table index", fname);
+
+ Elf_Scn *shdrstrscn = elf_getscn (elf, shdrstrndx);
+ GElf_Shdr shdrstrshdr_mem;
+ GElf_Shdr *shdrstrshdr = gelf_getshdr (shdrstrscn, &shdrstrshdr_mem);
+ if (shdrstrshdr == NULL)
+ fail_elf ("couldn't get section header string table section", fname);
+
+ if ((shdrstrshdr->sh_flags & SHF_ALLOC) != 0)
+ fail ("section header string table is an allocated section", fname);
+
+ /* Get the symtab section. */
+ size_t symtabndx = 0;
+ Elf_Scn *symtabscn = NULL;
+ GElf_Shdr symtabshdr_mem;
+ GElf_Shdr *symtabshdr = NULL;
+ while ((symtabscn = elf_nextscn (elf, symtabscn)) != NULL)
+ {
+ symtabshdr = gelf_getshdr (symtabscn, &symtabshdr_mem);
+ if (symtabshdr == NULL)
+ fail_elf ("couldn't get shdr", fname);
+
+ if (symtabshdr->sh_type == SHT_SYMTAB)
+ {
+ /* Just pick the first, we don't expect more than one. */
+ symtabndx = elf_ndxscn (symtabscn);
+ break;
+ }
+ }
+
+ if (symtabshdr == NULL)
+ fail ("No symtab found", fname);
+
+ if ((symtabshdr->sh_flags & SHF_ALLOC) != 0)
+ fail ("symtab is an allocated section", fname);
+
+ /* Get the strtab of the symtab. */
+ size_t strtabndx = symtabshdr->sh_link;
+ Elf_Scn *strtabscn = elf_getscn (elf, strtabndx);
+ GElf_Shdr strtabshdr_mem;
+ GElf_Shdr *strtabshdr = gelf_getshdr (strtabscn, &strtabshdr_mem);
+ if (strtabshdr == NULL)
+ fail_elf ("Couldn't get strtab section", fname);
+
+ if (shdrstrndx == strtabndx)
+ {
+ error (0, 0, "%s: Nothing to do, shstrtab == strtab", fname);
+ release ();
+ return 0;
+ }
+
+ if ((strtabshdr->sh_flags & SHF_ALLOC) != 0)
+ fail ("strtab is an allocated section", fname);
+
+ size_t phnum;
+ if (elf_getphdrnum (elf, &phnum) != 0)
+ fail_elf ("Couldn't get number of phdrs", fname);
+
+ /* If there are phdrs we want to maintain the layout of the
+ allocated sections in the file. */
+ bool layout = phnum != 0;
+
+ /* Create a new merged strings table that starts with the empty string. */
+ strings = dwelf_strtab_init (true);
+ if (strings == NULL)
+ fail ("No memory to create merged string table", NULL);
+
+ /* Add the strings from all the sections. */
+ size_t shdrnum;
+ if (elf_getshdrnum (elf, &shdrnum) != 0)
+ fail_elf ("Couldn't get number of sections", fname);
+ scnstrents = malloc (shdrnum * sizeof (Dwelf_Strent *));
+ if (scnstrents == NULL)
+ fail ("couldn't allocate memory for section strings", NULL);
+
+ /* While going through all sections keep track of last allocated
+ offset if needed to keep the layout. We'll put any unallocated
+ sections behind those (strtab is unallocated and will change
+ size). */
+ GElf_Off last_offset = 0;
+ if (layout)
+ last_offset = (ehdr.e_phoff
+ + gelf_fsize (elf, ELF_T_PHDR, phnum, EV_CURRENT));
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ size_t scnnum = elf_ndxscn (scn);
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ fail_elf_idx ("couldn't get shdr", fname, scnnum);
+ /* Don't add the .shstrtab section itself, we'll not use it. */
+ if (shdr->sh_name != 0 && scnnum != shdrstrndx)
+ {
+ const char *sname = elf_strptr (elf, shdrstrndx, shdr->sh_name);
+ if (sname == NULL)
+ fail_elf_idx ("couldn't get section name", fname, scnnum);
+ if ((scnstrents[scnnum] = dwelf_strtab_add (strings, sname)) == NULL)
+ fail ("No memory to add to merged string table", NULL);
+ }
+
+ if (layout)
+ if ((shdr->sh_flags & SHF_ALLOC) != 0)
+ {
+ GElf_Off off = shdr->sh_offset + (shdr->sh_type != SHT_NOBITS
+ ? shdr->sh_size : 0);
+ if (last_offset < off)
+ last_offset = off;
+ }
+ }
+
+ /* Add the strings from all the symbols. */
+ size_t elsize = gelf_fsize (elf, ELF_T_SYM, 1, EV_CURRENT);
+ Elf_Data *symd = elf_getdata (symtabscn, NULL);
+ if (symd == NULL)
+ fail_elf ("couldn't get symtab data", fname);
+ size_t symsnum = symd->d_size / elsize;
+ symstrents = malloc (symsnum * sizeof (Dwelf_Strent *));
+ if (symstrents == NULL)
+ fail_errno ("Couldn't allocate memory for symbol strings", NULL);
+ for (size_t i = 0; i < symsnum; i++)
+ {
+ GElf_Sym sym_mem;
+ GElf_Sym *sym = gelf_getsym (symd, i, &sym_mem);
+ if (sym == NULL)
+ fail_elf_idx ("Couldn't get symbol", fname, i);
+ if (sym->st_name != 0)
+ {
+ const char *sname = elf_strptr (elf, strtabndx, sym->st_name);
+ if (sname == NULL)
+ fail_elf_idx ("Couldn't get symbol name", fname, i);
+ if ((symstrents[i] = dwelf_strtab_add (strings, sname)) == NULL)
+ fail_idx ("No memory to add to merged string table symbol",
+ fname, i);
+ }
+ }
+
+ /* We got all strings, build the new string table and store it as
+ new strtab. */
+ dwelf_strtab_finalize (strings, &newstrtabdata);
+
+ /* We share at least the empty string so the result is at least 1
+ byte smaller. */
+ if (newstrtabdata.d_size >= shdrstrshdr->sh_size + strtabshdr->sh_size)
+ fail ("Impossible, merged string table is larger", fname);
+
+ /* section index mapping and sanity checking. */
+ size_t newsecndx (size_t secndx, const char *what, size_t widx,
+ const char *member, size_t midx)
+ {
+ if (unlikely (secndx == 0 || secndx == shdrstrndx || secndx >= shdrnum))
+ {
+ /* Don't use fail... too specialized messages. Call release
+ outselves and then error. Ignores midx if widx is
+ zero. */
+ release ();
+ if (widx == 0)
+ error (1, 0, "%s: bad section index %zd in %s for %s",
+ fname, secndx, what, member);
+ else if (midx == 0)
+ error (1, 0, "%s: bad section index %zd in %s %zd for %s",
+ fname, secndx, what, widx, member);
+ else
+ error (1, 0, "%s: bad section index %zd in %s %zd for %s %zd",
+ fname, secndx, what, widx, member, midx);
+ }
+
+ return secndx < shdrstrndx ? secndx : secndx - 1;
+ }
+
+ struct stat st;
+ if (fstat (fd, &st) != 0)
+ fail_errno("Couldn't fstat", fname);
+
+ /* Create a new (temporary) ELF file for the result. */
+ if (replace)
+ {
+ size_t fname_len = strlen (fname);
+ fnew = malloc (fname_len + sizeof (".XXXXXX"));
+ if (fnew == NULL)
+ fail_errno ("couldn't allocate memory for new file name", NULL);
+ strcpy (mempcpy (fnew, fname, fname_len), ".XXXXXX");
+
+ fdnew = mkstemp (fnew);
+ }
+ else
+ {
+ fnew = argv[2];
+ fdnew = open (fnew, O_WRONLY | O_CREAT, st.st_mode & ALLPERMS);
+ }
+
+ if (fdnew < 0)
+ fail_errno ("couldn't create output file", fnew);
+
+ elfnew = elf_begin (fdnew, ELF_C_WRITE, NULL);
+ if (elfnew == NULL)
+ fail_elf ("couldn't open new ELF for writing", fnew);
+
+ /* Create the new ELF header and copy over all the data. */
+ if (gelf_newehdr (elfnew, gelf_getclass (elf)) == 0)
+ fail_elf ("Couldn't create new ehdr", fnew);
+ GElf_Ehdr newehdr;
+ if (gelf_getehdr (elfnew, &newehdr) == NULL)
+ fail_elf ("Couldn't get ehdr", fnew);
+
+ newehdr.e_ident[EI_DATA] = ehdr.e_ident[EI_DATA];
+ newehdr.e_type = ehdr.e_type;
+ newehdr.e_machine = ehdr.e_machine;
+ newehdr.e_version = ehdr.e_version;
+ newehdr.e_entry = ehdr.e_entry;
+ newehdr.e_flags = ehdr.e_flags;
+
+ /* The new file uses the new strtab as shstrtab. */
+ size_t newstrtabndx = newsecndx (strtabndx, "ehdr", 0, "e_shstrndx", 0);
+ if (newstrtabndx < SHN_LORESERVE)
+ newehdr.e_shstrndx = newstrtabndx;
+ else
+ {
+ Elf_Scn *zscn = elf_getscn (elfnew, 0);
+ GElf_Shdr zshdr_mem;
+ GElf_Shdr *zshdr = gelf_getshdr (zscn, &zshdr_mem);
+ if (zshdr == NULL)
+ fail_elf ("Couldn't get section zero", fnew);
+ zshdr->sh_link = strtabndx;
+ if (gelf_update_shdr (zscn, zshdr) == 0)
+ fail_elf ("Couldn't update section zero", fnew);
+ newehdr.e_shstrndx = SHN_XINDEX;
+ }
+
+ if (gelf_update_ehdr (elfnew, &newehdr) == 0)
+ fail ("Couldn't update ehdr", fnew);
+
+ /* Copy the program headers if any. */
+ if (phnum != 0)
+ {
+ if (gelf_newphdr (elfnew, phnum) == 0)
+ fail_elf ("Couldn't create phdrs", fnew);
+
+ for (size_t cnt = 0; cnt < phnum; ++cnt)
+ {
+ GElf_Phdr phdr_mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem);
+ if (phdr == NULL)
+ fail_elf_idx ("Couldn't get phdr", fname, cnt);
+ if (gelf_update_phdr (elfnew, cnt, phdr) == 0)
+ fail_elf_idx ("Couldn't create phdr", fnew, cnt);
+ }
+ }
+
+ newshnums = shdrnum - 1;
+ newscnbufs = calloc (sizeof (void *), newshnums);
+ if (newscnbufs == NULL)
+ fail_errno ("Couldn't allocate memory for new section buffers", NULL);
+
+ /* Copy the sections, except the shstrtab, fill the strtab with the
+ combined strings and adjust section references. */
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ size_t ndx = elf_ndxscn (scn);
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ fail_elf_idx ("Couldn't get shdr", fname, ndx);
+
+ /* Section zero is always created. Skip the shtrtab. */
+ if (ndx == 0 || ndx == shdrstrndx)
+ continue;
+
+ Elf_Scn *newscn = elf_newscn (elfnew);
+ if (newscn == NULL)
+ fail_elf_idx ("couldn't create new section", fnew, ndx);
+
+ GElf_Shdr newshdr;
+ newshdr.sh_name = (shdr->sh_name != 0
+ ? dwelf_strent_off (scnstrents[ndx]) : 0);
+ newshdr.sh_type = shdr->sh_type;
+ newshdr.sh_flags = shdr->sh_flags;
+ newshdr.sh_addr = shdr->sh_addr;
+ newshdr.sh_size = shdr->sh_size;
+ if (shdr->sh_link != 0)
+ newshdr.sh_link = newsecndx (shdr->sh_link, "shdr", ndx, "sh_link", 0);
+ else
+ newshdr.sh_link = 0;
+ if (SH_INFO_LINK_P (shdr) && shdr->sh_info != 0)
+ newshdr.sh_info = newsecndx (shdr->sh_info, "shdr", ndx, "sh_info", 0);
+ else
+ newshdr.sh_info = shdr->sh_info;
+ newshdr.sh_entsize = shdr->sh_entsize;
+
+ /* Some sections need a new data buffer because they need to
+ manipulate the original data. Allocate and check here, so we
+ have a list of all data buffers we might need to release when
+ done. */
+ void new_data_buf (Elf_Data *d)
+ {
+ size_t s = d->d_size;
+ if (s == 0)
+ fail_idx ("Expected data in section", fname, ndx);
+ void *b = malloc (d->d_size);
+ if (b == NULL)
+ fail_idx ("Couldn't allocated buffer for section", NULL, ndx);
+ newscnbufs[newsecndx (ndx, "section", ndx, "d_buf", 0)] = d->d_buf = b;
+ }
+
+ Elf_Data *newdata = elf_newdata (newscn);
+ if (newdata == NULL)
+ fail_elf_idx ("Couldn't create new data for section", fnew, ndx);
+ if (ndx == strtabndx)
+ *newdata = newstrtabdata;
+ else
+ {
+ /* The symtab, dynsym, group and symtab_shndx sections
+ contain section indexes. Symbol tables (symtab and
+ dynsym) contain indexes to strings. Update both if
+ necessary. */
+ Elf_Data *data = elf_getdata (scn, NULL);
+ if (data == NULL)
+ fail_elf_idx ("Couldn't get data from section", fname, ndx);
+ *newdata = *data;
+ switch (shdr->sh_type)
+ {
+ case SHT_SYMTAB:
+ case SHT_DYNSYM:
+ {
+ /* We need to update the section numbers of the
+ symbols and if this symbol table uses the strtab
+ section also the name indexes. */
+ const bool update_name = shdr->sh_link == strtabndx;
+ if (update_name && ndx != symtabndx)
+ fail ("Only one symbol table using strtab expected", fname);
+ new_data_buf (newdata);
+ size_t syms = (data->d_size
+ / gelf_fsize (elf, ELF_T_SYM, 1, EV_CURRENT));
+ for (size_t i = 0; i < syms; i++)
+ {
+ GElf_Sym sym;
+ if (gelf_getsym (data, i, &sym) == NULL)
+ fail_elf_idx ("Couldn't get symbol", fname, i);
+
+ if (GELF_ST_TYPE (sym.st_info) == STT_SECTION
+ && sym.st_shndx == shdrstrndx)
+ fprintf (stderr, "WARNING:"
+ " symbol table [%zd] contains section symbol %zd"
+ " for old shdrstrndx %zd\n", ndx, i, shdrstrndx);
+ else if (sym.st_shndx != SHN_UNDEF
+ && sym.st_shndx < SHN_LORESERVE)
+ sym.st_shndx = newsecndx (sym.st_shndx, "section", ndx,
+ "symbol", i);
+ if (update_name && sym.st_name != 0)
+ sym.st_name = dwelf_strent_off (symstrents[i]);
+
+ /* We explicitly don't update the SHNDX table at
+ the same time, we do that below. */
+ if (gelf_update_sym (newdata, i, &sym) == 0)
+ fail_elf_idx ("Couldn't update symbol", fnew, i);
+ }
+ }
+ break;
+
+ case SHT_GROUP:
+ {
+ new_data_buf (newdata);
+ /* A section group contains Elf32_Words. The first
+ word is a falg value, the rest of the words are
+ indexes of the sections belonging to the group. */
+ Elf32_Word *group = (Elf32_Word *) data->d_buf;
+ Elf32_Word *newgroup = (Elf32_Word *) newdata->d_buf;
+ size_t words = data->d_size / sizeof (Elf32_Word);
+ if (words == 0)
+ fail_idx ("Not enough data in group section", fname, ndx);
+ newgroup[0] = group[0];
+ for (size_t i = 1; i < words; i++)
+ newgroup[i] = newsecndx (group[i], "section", ndx,
+ "group", i);
+ }
+ break;
+
+ case SHT_SYMTAB_SHNDX:
+ {
+ new_data_buf (newdata);
+ /* A SHNDX just contains an array of section indexes
+ for the corresponding symbol table. The entry is
+ SHN_UNDEF unless the corresponding symbol is
+ SHN_XINDEX. */
+ Elf32_Word *shndx = (Elf32_Word *) data->d_buf;
+ Elf32_Word *newshndx = (Elf32_Word *) newdata->d_buf;
+ size_t words = data->d_size / sizeof (Elf32_Word);
+ for (size_t i = 0; i < words; i++)
+ if (shndx[i] == SHN_UNDEF)
+ newshndx[i] = SHN_UNDEF;
+ else
+ newshndx[i] = newsecndx (shndx[i], "section", ndx,
+ "shndx", i);
+ }
+ break;
+
+ case SHT_DYNAMIC:
+ FALLTHROUGH;
+ /* There are string indexes in here, but
+ they (should) point to a allocated string table,
+ which we don't alter. */
+ default:
+ /* Nothing to do. Section data doesn't contain section
+ or strtab indexes. */
+ break;
+ }
+ }
+
+ /* When we are responsible for the layout explicitly set
+ sh_addralign, sh_size and sh_offset. Otherwise libelf will
+ calculate those from the Elf_Data. */
+ if (layout)
+ {
+ /* We have just one Elf_Data. */
+ newshdr.sh_size = newdata->d_size;
+ newshdr.sh_addralign = newdata->d_align;
+
+ /* Keep the offset of allocated sections so they are at the
+ same place in the file. Add unallocated ones after the
+ allocated ones. */
+ if ((shdr->sh_flags & SHF_ALLOC) != 0)
+ newshdr.sh_offset = shdr->sh_offset;
+ else
+ {
+ /* Zero means one. No alignment constraints. */
+ size_t addralign = newshdr.sh_addralign ?: 1;
+ last_offset = (last_offset + addralign - 1) & ~(addralign - 1);
+ newshdr.sh_offset = last_offset;
+ if (newshdr.sh_type != SHT_NOBITS)
+ last_offset += newshdr.sh_size;
+ }
+ }
+ else
+ {
+ newshdr.sh_addralign = 0;
+ newshdr.sh_size = 0;
+ newshdr.sh_offset = 0;
+ }
+
+ if (gelf_update_shdr (newscn, &newshdr) == 0)
+ fail_elf_idx ("Couldn't update section header", fnew, ndx);
+ }
+
+ /* If we have phdrs we want elf_update to layout the SHF_ALLOC
+ sections precisely as in the original file. In that case we are
+ also responsible for setting phoff and shoff */
+ if (layout)
+ {
+ /* Position the shdrs after the last (unallocated) section. */
+ if (gelf_getehdr (elfnew, &newehdr) == NULL)
+ fail_elf ("Couldn't get ehdr", fnew);
+ const size_t offsize = gelf_fsize (elf, ELF_T_OFF, 1, EV_CURRENT);
+ newehdr.e_shoff = ((last_offset + offsize - 1)
+ & ~((GElf_Off) (offsize - 1)));
+
+ /* The phdrs go in the same place as in the original file.
+ Normally right after the ELF header. */
+ newehdr.e_phoff = ehdr.e_phoff;
+
+ if (gelf_update_ehdr (elfnew, &newehdr) == 0)
+ fail_elf ("Couldn't update ehdr", fnew);
+
+ elf_flagelf (elfnew, ELF_C_SET, ELF_F_LAYOUT);
+ }
+
+ if (elf_update (elfnew, ELF_C_WRITE) == -1)
+ fail_elf ("Couldn't write ELF", fnew);
+
+ elf_end (elfnew);
+ elfnew = NULL;
+
+ /* Try to match mode and owner.group of the original file. */
+ if (fchmod (fdnew, st.st_mode & ALLPERMS) != 0)
+ error (0, errno, "Couldn't fchmod %s", fnew);
+ if (fchown (fdnew, st.st_uid, st.st_gid) != 0)
+ error (0, errno, "Couldn't fchown %s", fnew);
+
+ /* Finally replace the old file with the new merged strings file. */
+ if (replace)
+ if (rename (fnew, fname) != 0)
+ fail_errno ("rename", fnew);
+
+ /* We are finally done with the new file, don't unlink it now. */
+ close (fdnew);
+ if (replace)
+ free (fnew);
+ fnew = NULL;
+ fdnew = -1;
+
+ release ();
+ return 0;
+}
diff --git a/tests/elfstrtab.c b/tests/elfstrtab.c
new file mode 100644
index 0000000..c27d6cf
--- /dev/null
+++ b/tests/elfstrtab.c
@@ -0,0 +1,396 @@
+/* Test program for elf_strptr function.
+ 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 <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+
+/* Index of last string added. Returned by add_string (). */
+static size_t stridx = 0;
+
+/* Some random strings. */
+static char *str1;
+static size_t str1_off;
+static char *str2;
+static size_t str2_off;
+static char *str3;
+static size_t str3_off;
+
+/* First three strings we write out. They should always be there. */
+static char *orig_str1;
+static size_t orig_str1_off;
+static char *orig_str2;
+static size_t orig_str2_off;
+static char *orig_str3;
+static size_t orig_str3_off;
+
+static void
+check_orig_strings (Elf *elf, int ndx, const char *msg)
+{
+ printf ("checking orig strings: %s\n", msg);
+
+ const char *str = elf_strptr (elf, ndx, 0);
+ printf ("\t'%s'\n", str);
+ if (str == NULL || strcmp ("", str) != 0)
+ exit (1);
+
+ str = elf_strptr (elf, ndx, 1);
+ printf ("\t'%s'\n", str);
+ if (str == NULL || strcmp (".strings", str) != 0)
+ exit (1);
+
+ str = elf_strptr (elf, ndx, orig_str1_off);
+ printf ("\t'%s'\n", str);
+ if (str == NULL || strcmp (orig_str1, str) != 0)
+ exit (1);
+
+ str = elf_strptr (elf, ndx, orig_str2_off);
+ printf ("\t'%s'\n", str);
+ if (str == NULL || strcmp (orig_str2, str) != 0)
+ exit (1);
+
+ str = elf_strptr (elf, ndx, orig_str3_off);
+ printf ("\t'%s'\n", str);
+ if (str == NULL || strcmp (orig_str3, str) != 0)
+ exit (1);
+}
+
+static void
+check_strings (Elf *elf, int ndx, const char *msg)
+{
+ check_orig_strings (elf, ndx, msg);
+
+ const char *str = elf_strptr (elf, ndx, str1_off);
+ printf ("\t'%s'\n", str);
+ if (str == NULL || strcmp (str1, str) != 0)
+ exit (1);
+
+ str = elf_strptr (elf, ndx, str2_off);
+ printf ("\t'%s'\n", str);
+ if (str == NULL || strcmp (str2, str) != 0)
+ exit (1);
+
+ str = elf_strptr (elf, ndx, str3_off);
+ printf ("\t'%s'\n", str);
+ if (str == NULL || strcmp (str3, str) != 0)
+ exit (1);
+}
+
+/* Adds a string and returns the offset in the section. */
+static size_t
+add_string (Elf_Scn *scn, char *str)
+{
+ size_t lastidx = stridx;
+ size_t size = strlen (str) + 1;
+
+ Elf_Data *data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = str;
+ data->d_type = ELF_T_BYTE;
+ data->d_size = size;
+ data->d_align = 1;
+ data->d_version = EV_CURRENT;
+
+ stridx += size;
+ printf ("add_string: '%s', stridx: %zd, lastidx: %zd\n",
+ str, stridx, lastidx);
+ return lastidx;
+}
+
+static void
+check_elf (const char *fname, int class, int use_mmap)
+{
+ printf ("\nfname: %s\n", fname);
+ stridx = 0;
+
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Create an ELF header.
+ if (gelf_newehdr (elf, class) == 0)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Initialize header.
+ ehdr->e_ident[EI_DATA] = class == ELFCLASS64 ? ELFDATA2LSB : ELFDATA2MSB;
+ ehdr->e_ident[EI_OSABI] = ELFOSABI_GNU;
+ ehdr->e_type = ET_NONE;
+ ehdr->e_machine = EM_X86_64;
+ ehdr->e_version = EV_CURRENT;
+
+ // Create strings section.
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Add an empty string to the table as NUL entry for section zero.
+ add_string (scn, "");
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr->sh_type = SHT_STRTAB;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_addralign = 1;
+ shdr->sh_entsize = 0;
+ shdr->sh_name = add_string (scn, ".strings");
+
+ // We have to store the section strtab index in the ELF header.
+ // So sections have actual names.
+ int ndx = elf_ndxscn (scn);
+ ehdr->e_shstrndx = ndx;
+
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Add some random strings. These are the original ones. They should
+ // always be there (together with the empty "" and .strings section
+ // name strings.
+ orig_str1 = "elfutils";
+ orig_str1_off = add_string (scn, orig_str1);
+ orig_str2 = "strtabelf";
+ orig_str2_off = add_string (scn, orig_str2);
+ orig_str3 = "three";
+ orig_str3_off = add_string (scn, orig_str3);
+
+ // Finished strings section, update the header.
+ if (gelf_update_shdr (scn, shdr) == 0)
+ {
+ printf ("cannot update STRTAB section header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Let the library compute the internal structure information.
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in elf_update(NULL): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Check our strings are there.
+ check_orig_strings (elf, ndx, "first elf_update, before write");
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Check out strings are there.
+ check_orig_strings (elf, ndx, "first elf_update, after write");
+
+ // Add some more random strings. These will not be written to disk.
+ scn = elf_getscn (elf, ndx);
+ if (scn == NULL)
+ {
+ printf ("couldn't re-get strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ str1 = "elfutils2";
+ str1_off = add_string (scn, str1);
+ str2 = "strtabelf2";
+ str2_off = add_string (scn, str2);
+ str3 = "three2";
+ str3_off = add_string (scn, str3);
+
+ // Update internal structure information again.
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in re-elf_update(NULL): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Check our new strings are there.
+ check_strings (elf, ndx, "first extra strings");
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ /* Read the ELF from disk now. */
+ fd = open (fname, O_RDWR, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_RDWR_MMAP : ELF_C_RDWR, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Are our strings there? */
+ check_orig_strings (elf, ndx, "read ELF file, orig strings");
+
+ // Add some more random strings.
+ scn = elf_getscn (elf, ndx);
+ if (scn == NULL)
+ {
+ printf ("couldn't re-get strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Reset stridx to end of section.
+ printf ("sh_size: %" PRIu64 "\n", shdr->sh_size);
+ stridx = shdr->sh_size;
+
+ str1 = "0123456789";
+ str1_off = add_string (scn, str1);
+ str2 = "supercalifragilisticexpialidocious";
+ str2_off = add_string (scn, str2);
+ str3 = "forty-two";
+ str3_off = add_string (scn, str3);
+
+ // Update internal structure information.
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in rw-elf_update(NULL): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Check our new strings are there. */
+ check_strings (elf, ndx, "read file, added strings");
+
+ // Write updated ELF file.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in re-elf_update(NULL): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ // And read it in one last time.
+ fd = open (fname, O_RDONLY, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_READ_MMAP : ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Are all our strings there? */
+ check_strings (elf, ndx, "all together now");
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ unlink (fname);
+}
+
+int
+main (int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused)))
+{
+ elf_version (EV_CURRENT);
+
+ // Fill holes with something non-zero to more easily spot
+ // unterminated strings.
+ elf_fill ('X');
+
+ check_elf ("strtab.elf.32", ELFCLASS32, 0);
+ check_elf ("strtab.elf.32.mmap", ELFCLASS32, 1);
+ check_elf ("strtab.elf.64", ELFCLASS64, 0);
+ check_elf ("strtab.elf.64.mmap", ELFCLASS64, 1);
+
+ return 0;
+}
+
diff --git a/tests/emptyfile.c b/tests/emptyfile.c
new file mode 100644
index 0000000..6d08624
--- /dev/null
+++ b/tests/emptyfile.c
@@ -0,0 +1,277 @@
+/* Test program for adding a section to an empty ELF file.
+ Copyright (C) 2016 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 <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+
+/* Index of last string added. Returned by add_string (). */
+static size_t stridx = 0;
+
+/* Adds a string and returns the offset in the section. */
+static size_t
+add_string (Elf_Scn *scn, char *str)
+{
+ size_t lastidx = stridx;
+ size_t size = strlen (str) + 1;
+
+ Elf_Data *data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = str;
+ data->d_type = ELF_T_BYTE;
+ data->d_size = size;
+ data->d_align = 1;
+ data->d_version = EV_CURRENT;
+
+ stridx += size;
+ printf ("add_string: '%s', stridx: %zd, lastidx: %zd\n",
+ str, stridx, lastidx);
+ return lastidx;
+}
+
+static void
+check_elf (const char *fname, int class, int use_mmap)
+{
+ printf ("\nfname: %s\n", fname);
+ stridx = 0; // Reset strtab strings index
+
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Create an ELF header.
+ if (gelf_newehdr (elf, class) == 0)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Initialize header.
+ ehdr->e_ident[EI_DATA] = class == ELFCLASS64 ? ELFDATA2LSB : ELFDATA2MSB;
+ ehdr->e_ident[EI_OSABI] = ELFOSABI_GNU;
+ ehdr->e_type = ET_NONE;
+ ehdr->e_machine = EM_X86_64;
+ ehdr->e_version = EV_CURRENT;
+
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ /* Reread the ELF from disk now. */
+ fd = open (fname, O_RDWR, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_RDWR_MMAP : ELF_C_RDWR, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // There are no sections yet.
+ if (elf_nextscn (elf, NULL) != NULL)
+ {
+ printf ("Empty elf had a section???\n");
+ exit (1);
+ }
+
+ // Create strtab section.
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Add an empty string to the table as NUL entry for section zero.
+ add_string (scn, "");
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr->sh_type = SHT_STRTAB;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_addralign = 1;
+ shdr->sh_entsize = 0;
+ shdr->sh_name = add_string (scn, ".strtab");
+
+ // We have to store the section strtab index in the ELF header.
+ // So sections have actual names.
+ int ndx = elf_ndxscn (scn);
+ ehdr->e_shstrndx = ndx;
+
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Finished strtab section, update the header.
+ if (gelf_update_shdr (scn, shdr) == 0)
+ {
+ printf ("cannot update STRTAB section header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ // And read it in one last time.
+ fd = open (fname, O_RDONLY, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_READ_MMAP : ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Is our new section there?
+ scn = elf_nextscn (elf, NULL);
+ if (scn == NULL)
+ {
+ printf ("cannot get new section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for new section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ size_t shstrndx;
+ if (elf_getshdrstrndx (elf, &shstrndx) < 0)
+ {
+ printf ("elf_getshdrstrndx: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ const char *sname = elf_strptr (elf, shstrndx, shdr->sh_name);
+ if (sname == NULL || strcmp (sname, ".strtab") != 0)
+ {
+ printf ("Bad section name: %s\n", sname);
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ unlink (fname);
+}
+
+int
+main (int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ elf_version (EV_CURRENT);
+
+ check_elf ("empty.elf.32", ELFCLASS32, 0);
+ check_elf ("empty.elf.32.mmap", ELFCLASS32, 1);
+ check_elf ("empty.elf.64", ELFCLASS64, 0);
+ check_elf ("empty.elf.64.mmap", ELFCLASS64, 1);
+
+ return 0;
+}
diff --git a/tests/fillfile.c b/tests/fillfile.c
new file mode 100644
index 0000000..915e249
--- /dev/null
+++ b/tests/fillfile.c
@@ -0,0 +1,448 @@
+/* Test program for changing data in one section (but not others) with gaps.
+ Copyright (C) 2017 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 <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+
+/* Index of last string added. Returned by add_string (). */
+static size_t stridx = 0;
+
+/* Adds a string and returns the offset in the section. */
+static size_t
+add_strtab_entry (Elf_Scn *strtab, const char *str)
+{
+ size_t lastidx = stridx;
+ size_t size = strlen (str) + 1;
+
+ Elf_Data *data = elf_newdata (strtab);
+ if (data == NULL)
+ {
+ printf ("cannot create data SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = (char *) str; /* Discards const, but we will not change. */
+ data->d_type = ELF_T_BYTE;
+ data->d_size = size;
+ data->d_align = 1;
+ data->d_version = EV_CURRENT;
+
+ stridx += size;
+ printf ("add_string: '%s', stridx: %zd, lastidx: %zd\n",
+ str, stridx, lastidx);
+ return lastidx;
+}
+
+static Elf_Scn *
+create_strtab (Elf *elf)
+{
+ // Create strtab section.
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Add an empty string to the table as NUL entry for section zero.
+ add_strtab_entry (scn, "");
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for new strtab section: %s\n",
+ elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr->sh_type = SHT_STRTAB;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_addralign = 1;
+ shdr->sh_entsize = 0;
+ shdr->sh_name = add_strtab_entry (scn, ".strtab");
+
+ // We have to store the section strtab index in the ELF header.
+ // So sections have actual names.
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ int ndx = elf_ndxscn (scn);
+ ehdr->e_shstrndx = ndx;
+
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Finished strtab section, update the header.
+ if (gelf_update_shdr (scn, shdr) == 0)
+ {
+ printf ("cannot update STRTAB section header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ return scn;
+}
+
+static char sec_data[] = { 1, 2, 3, 4, 5 };
+static char new_data[] = { 5, 4, 3, 2, 1 };
+
+static void
+add_data_section (Elf *elf, Elf_Scn *strtab, const char *sname)
+{
+ printf ("Add data section %s\n", sname);
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for new %s section: %s\n",
+ sname, elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr->sh_type = SHT_PROGBITS;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_addralign = 128; // Large alignment to force gap between sections.
+ shdr->sh_entsize = 1;
+ shdr->sh_name = add_strtab_entry (strtab, sname);
+
+ if (gelf_update_shdr (scn, shdr) == 0)
+ {
+ printf ("cannot update %s section header: %s\n", sname, elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Add some data, but less than alignment. */
+ Elf_Data *data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot update %s section header: %s\n", sname, elf_errmsg (-1));
+ exit (1);
+ }
+ data->d_buf = sec_data;
+ data->d_size = 5;
+}
+
+static void
+check_data (const char *sname, Elf_Data *data, char *buf)
+{
+ printf ("check data %s [", sname);
+ for (int i = 0; i < 5; i++)
+ printf ("%d%s", buf[i], i < 4 ? "," : "");
+ printf ("]\n");
+ if (data == NULL || data->d_buf == NULL)
+ {
+ printf ("No data in section %s\n", sname);
+ exit (1);
+ }
+
+ if (data->d_size != 5 || memcmp (data->d_buf, buf, 5) != 0)
+ {
+ printf ("Wrong data in section %s [", sname);
+ for (size_t i = 0; i < data->d_size; i++)
+ printf ("%d%s", ((char *)data->d_buf)[i],
+ i < data->d_size - 1 ? "," : "");
+ printf ("]\n");
+ exit(1);
+ }
+}
+
+static void
+check_elf (const char *fname, int class, int use_mmap)
+{
+ printf ("\nfname: %s\n", fname);
+ stridx = 0; // Reset strtab strings index
+
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Create an ELF header.
+ if (gelf_newehdr (elf, class) == 0)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Initialize header.
+ ehdr->e_ident[EI_DATA] = class == ELFCLASS64 ? ELFDATA2LSB : ELFDATA2MSB;
+ ehdr->e_ident[EI_OSABI] = ELFOSABI_GNU;
+ ehdr->e_type = ET_NONE;
+ ehdr->e_machine = EM_X86_64;
+ ehdr->e_version = EV_CURRENT;
+
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ Elf_Scn *strtab = create_strtab (elf);
+ add_data_section (elf, strtab, ".data1");
+ add_data_section (elf, strtab, ".data2");
+ add_data_section (elf, strtab, ".data3");
+ add_data_section (elf, strtab, ".data4");
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ /* Reread the ELF from disk now. */
+ printf ("Rereading %s\n", fname);
+ fd = open (fname, O_RDWR, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_RDWR_MMAP : ELF_C_RDWR, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* We are going to change some data (in-place), but want the layout
+ to stay exactly the same. */
+ elf_flagelf (elf, ELF_C_SET, ELF_F_LAYOUT);
+
+ size_t shdrstrndx;
+ if (elf_getshdrstrndx (elf, &shdrstrndx) != 0)
+ {
+ printf ("cannot get shdr str ndx\n");
+ exit (1);
+ }
+ printf ("shdrstrndx: %zd\n", shdrstrndx);
+
+ // Get third data section and change it.
+ Elf_Scn *checkscn = NULL;
+ Elf_Scn *scn = elf_nextscn (elf, NULL);
+ while (scn != NULL)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ const char *sname = elf_strptr (elf, shdrstrndx, shdr->sh_name);
+ if (sname != NULL && strcmp (".data3", sname) == 0)
+ checkscn = scn;
+
+ // Get all data, but don't really use it
+ // (this triggered the original bug).
+ Elf_Data *data = elf_getdata (scn, NULL);
+ if (data != NULL && data->d_buf != NULL && data->d_size == 0)
+ {
+ printf ("Bad data...n");
+ exit (1);
+ }
+ scn = elf_nextscn (elf, scn);
+ }
+
+ if (checkscn == NULL)
+ {
+ printf ("ELF file doesn't have a .data3 section\n");
+ exit (1);
+ }
+
+ Elf_Data *data = elf_getdata (checkscn, NULL);
+ check_data (".data3", data, sec_data);
+ memcpy (data->d_buf, new_data, 5);
+ elf_flagdata (data, ELF_C_SET, ELF_F_DIRTY);
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ // And read it in one last time.
+ printf ("Rereading %s again\n", fname);
+ fd = open (fname, O_RDONLY, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_READ_MMAP : ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Get all .data sections and check them.
+ Elf_Scn *scn1 = NULL;
+ Elf_Scn *scn2 = NULL;
+ Elf_Scn *scn3 = NULL;
+ Elf_Scn *scn4 = NULL;
+ scn = elf_nextscn (elf, NULL);
+ while (scn != NULL)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ const char *sname = elf_strptr (elf, shdrstrndx, shdr->sh_name);
+ if (sname != NULL && strcmp (".data1", sname) == 0)
+ scn1 = scn;
+ else if (sname != NULL && strcmp (".data2", sname) == 0)
+ scn2 = scn;
+ else if (sname != NULL && strcmp (".data3", sname) == 0)
+ scn3 = scn;
+ else if (sname != NULL && strcmp (".data4", sname) == 0)
+ scn4 = scn;
+ scn = elf_nextscn (elf, scn);
+ }
+
+ if (scn1 == NULL)
+ {
+ printf ("ELF file doesn't have a .data1 section\n");
+ exit (1);
+ }
+ data = elf_getdata (scn1, NULL);
+ check_data (".data1", data, sec_data);
+
+ if (scn2 == NULL)
+ {
+ printf ("ELF file doesn't have a .data2 section\n");
+ exit (1);
+ }
+ data = elf_getdata (scn2, NULL);
+ check_data (".data2", data, sec_data);
+
+ if (scn3 == NULL)
+ {
+ printf ("ELF file doesn't have a .data3 section\n");
+ exit (1);
+ }
+ data = elf_getdata (scn3, NULL);
+ check_data (".data3", data, new_data);
+
+ if (scn4 == NULL)
+ {
+ printf ("ELF file doesn't have a .data4 section\n");
+ exit (1);
+ }
+ data = elf_getdata (scn4, NULL);
+ check_data (".data4", data, sec_data);
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ unlink (fname);
+}
+
+int
+main (int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ elf_version (EV_CURRENT);
+
+ elf_fill (0xA);
+
+ check_elf ("fill.elf.32", ELFCLASS32, 0);
+ check_elf ("fill.elf.32.mmap", ELFCLASS32, 1);
+ check_elf ("fill.elf.64", ELFCLASS64, 0);
+ check_elf ("fill.elf.64.mmap", ELFCLASS64, 1);
+
+ return 0;
+}
diff --git a/tests/find-prologues.c b/tests/find-prologues.c
new file mode 100644
index 0000000..ba8ae37
--- /dev/null
+++ b/tests/find-prologues.c
@@ -0,0 +1,108 @@
+/* Test program for dwarf_entry_breakpoints.
+ Copyright (C) 2005 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <error.h>
+#include <string.h>
+#include <fnmatch.h>
+
+
+struct args
+{
+ Dwfl *dwfl;
+ Dwarf_Die *cu;
+ Dwarf_Addr dwbias;
+ char **argv;
+};
+
+static int
+handle_function (Dwarf_Die *func, void *arg)
+{
+ struct args *a = arg;
+
+ const char *name = dwarf_diename (func);
+ char **argv = a->argv;
+ if (argv[0] != NULL)
+ {
+ bool match;
+ do
+ match = fnmatch (*argv, name, 0) == 0;
+ while (!match && *++argv);
+ if (!match)
+ return 0;
+ }
+
+ if (dwarf_func_inline (func))
+ return 0;
+
+ Dwarf_Addr entrypc;
+ if (dwarf_entrypc (func, &entrypc) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_entrypc: %s: %s",
+ dwarf_diename (func), dwarf_errmsg (-1));
+ entrypc += a->dwbias;
+
+ printf ("%-16s %#.16" PRIx64, dwarf_diename (func), entrypc);
+
+ Dwarf_Addr *bkpts = NULL;
+ int result = dwarf_entry_breakpoints (func, &bkpts);
+ if (result <= 0)
+ printf ("\t%s\n", dwarf_errmsg (-1));
+ else
+ {
+ for (int i = 0; i < result; ++i)
+ printf (" %#.16" PRIx64 "%s", bkpts[i] + a->dwbias,
+ i == result - 1 ? "\n" : "");
+ free (bkpts);
+ }
+
+ return 0;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ struct args a = { .dwfl = NULL, .cu = NULL };
+
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining,
+ &a.dwfl);
+ assert (a.dwfl != NULL);
+ a.argv = &argv[remaining];
+
+ int result = 0;
+
+ while ((a.cu = dwfl_nextcu (a.dwfl, a.cu, &a.dwbias)) != NULL)
+ dwarf_getfuncs (a.cu, &handle_function, &a, 0);
+
+ dwfl_end (a.dwfl);
+
+ return result;
+}
diff --git a/tests/funcretval.c b/tests/funcretval.c
new file mode 100644
index 0000000..8d19d11
--- /dev/null
+++ b/tests/funcretval.c
@@ -0,0 +1,106 @@
+/* Test program for dwfl_module_return_value_location.
+ Copyright (C) 2005 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <error.h>
+#include <string.h>
+#include <fnmatch.h>
+
+
+struct args
+{
+ Dwfl *dwfl;
+ Dwarf_Die *cu;
+ Dwarf_Addr dwbias;
+ char **argv;
+};
+
+static int
+handle_function (Dwarf_Die *funcdie, void *arg)
+{
+ struct args *a = arg;
+
+ const char *name = dwarf_diename (funcdie);
+ char **argv = a->argv;
+ if (argv[0] != NULL)
+ {
+ bool match;
+ do
+ match = fnmatch (*argv, name, 0) == 0;
+ while (!match && *++argv);
+ if (!match)
+ return 0;
+ }
+
+ printf ("(%s) %s: ", dwfl_module_info (dwfl_cumodule (a->cu), NULL,
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL), name);
+
+ const Dwarf_Op *locops;
+ int nlocops = dwfl_module_return_value_location (dwfl_cumodule (a->cu),
+ funcdie, &locops);
+ if (nlocops < 0)
+ error (EXIT_FAILURE, 0, "dwfl_module_return_value_location: %s",
+ dwfl_errmsg (-1));
+ else if (nlocops == 0)
+ puts ("returns no value");
+ else
+ {
+ printf ("return value location:");
+ for (int i = 0; i < nlocops; ++i)
+ printf (" {%#x, %#" PRIx64 "}", locops[i].atom, locops[i].number);
+ puts ("");
+ }
+
+ return 0;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ struct args a = { .dwfl = NULL, .cu = NULL };
+
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining,
+ &a.dwfl);
+ assert (a.dwfl != NULL);
+ a.argv = &argv[remaining];
+
+ int result = 0;
+
+ while ((a.cu = dwfl_nextcu (a.dwfl, a.cu, &a.dwbias)) != NULL)
+ dwarf_getfuncs (a.cu, &handle_function, &a, 0);
+
+ dwfl_end (a.dwfl);
+
+ return result;
+}
diff --git a/tests/funcretval_test.c b/tests/funcretval_test.c
new file mode 100644
index 0000000..7e20f52
--- /dev/null
+++ b/tests/funcretval_test.c
@@ -0,0 +1,828 @@
+signed char fun_char (void) { return 5; }
+short fun_short (void) { return 6; }
+int fun_int (void) { return 7; }
+void *fun_ptr (void) { return &fun_ptr; }
+int fun_iptr (void) { return 8; }
+long fun_long (void) { return 9; }
+__int128 fun_int128 (void) { return 10; }
+
+typedef struct { int i[10]; } large_struct1_t;
+large_struct1_t fun_large_struct1 (void) {
+ large_struct1_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } };
+ return ret;
+}
+
+typedef struct { int i1; int i2; int i3; int i4; int i5;
+ int i6; int i7; int i8; int i9; int i10; } large_struct2_t;
+large_struct2_t fun_large_struct2 (void) {
+ large_struct2_t ret = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ return ret;
+}
+
+float fun_float (void) { return 1.5; }
+float _Complex fun_float_complex (void) { return 1.5 + 2.5i; }
+
+double fun_double (void) { return 2.5; }
+double _Complex fun_double_complex (void) { return 2.5 + 3.5i; }
+
+long double fun_long_double (void) { return 3.5; }
+long double _Complex fun_long_double_complex (void) { return 4.5 + 5.5i; }
+
+#ifdef FLOAT128
+__float128 fun_float128 (void) { return 3.5; }
+#endif
+
+// 8 byte vectors.
+
+typedef signed char __attribute__ ((vector_size (8))) vec_char_8_t;
+vec_char_8_t fun_vec_char_8 (void) {
+ vec_char_8_t ret = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ return ret;
+}
+
+typedef short __attribute__ ((vector_size (8))) vec_short_8_t;
+vec_short_8_t fun_vec_short_8 (void) {
+ vec_short_8_t ret = { 2, 3, 4, 5 };
+ return ret;
+}
+
+typedef int __attribute__ ((vector_size (8))) vec_int_8_t;
+vec_int_8_t fun_vec_int_8 (void) {
+ vec_int_8_t ret = { 3, 4 };
+ return ret;
+}
+
+typedef long __attribute__ ((vector_size (8))) vec_long_8_t;
+vec_long_8_t fun_vec_long_8 (void) {
+ vec_long_8_t ret = { 5 };
+ return ret;
+}
+
+typedef float __attribute__ ((vector_size (8))) vec_float_8_t;
+vec_float_8_t fun_vec_float_8 (void) {
+ vec_float_8_t ret = { 1.5, 2.5 };
+ return ret;
+}
+
+typedef double __attribute__ ((vector_size (8))) vec_double_8_t;
+#ifndef AARCH64_BUG_1032854
+// https://bugzilla.redhat.com/show_bug.cgi?id=1032854
+vec_double_8_t fun_vec_double_8 (void) {
+ vec_double_8_t ret = { 3.5 };
+ return ret;
+}
+#endif
+
+// 16 byte vectors.
+
+typedef signed char __attribute__ ((vector_size (16))) vec_char_16_t;
+vec_char_16_t fun_vec_char_16 (void) {
+ vec_char_16_t ret = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+ return ret;
+}
+
+typedef short __attribute__ ((vector_size (16))) vec_short_16_t;
+vec_short_16_t fun_vec_short_16 (void) {
+ vec_short_16_t ret = { 2, 3, 4, 5, 6, 7, 8 };
+ return ret;
+}
+
+typedef int __attribute__ ((vector_size (16))) vec_int_16_t;
+vec_int_16_t fun_vec_int_16 (void) {
+ vec_int_16_t ret = { 2, 3, 4 };
+ return ret;
+}
+
+typedef long __attribute__ ((vector_size (16))) vec_long_16_t;
+vec_long_16_t fun_vec_long_16 (void) {
+ vec_long_16_t ret = { 3, 4 };
+ return ret;
+}
+
+typedef __int128 __attribute__ ((vector_size (16))) vec_int128_16_t;
+vec_int128_16_t fun_vec_int128_16 (void) {
+ vec_int128_16_t ret = { 999 };
+ return ret;
+}
+
+typedef float __attribute__ ((vector_size (16))) vec_float_16_t;
+vec_float_16_t fun_vec_float_16 (void) {
+ vec_float_16_t ret = { 1.5, 2.5, 3.5, 4.5 };
+ return ret;
+}
+
+typedef double __attribute__ ((vector_size (16))) vec_double_16_t;
+vec_double_16_t fun_vec_double_16 (void) {
+ vec_double_16_t ret = { 2.5, 5 };
+ return ret;
+}
+
+#ifdef FLOAT128
+typedef __float128 __attribute__ ((vector_size (16))) vec_float128_16_t;
+vec_float128_16_t fun_vec_float128_16 (void) {
+ vec_float128_16_t ret = { 7.5 };
+ return ret;
+}
+#endif
+
+// Homogeneous floating-point aggregates.
+
+typedef struct { float f; } hfa1_float_t;
+hfa1_float_t fun_hfa1_float (void) {
+ hfa1_float_t ret = { 1.5 };
+ return ret;
+}
+
+typedef struct { double f; } hfa1_double_t;
+hfa1_double_t fun_hfa1_double (void) {
+ hfa1_double_t ret = { 3.0 };
+ return ret;
+}
+
+typedef struct { long double f; } hfa1_long_double_t;
+hfa1_long_double_t fun_hfa1_long_double (void) {
+ hfa1_long_double_t ret = { 3.0 };
+ return ret;
+}
+
+typedef struct { float f[1]; } hfa1_float_a_t;
+hfa1_float_a_t fun_hfa1_float_a (void) {
+ hfa1_float_a_t ret = { { 1.5 } };
+ return ret;
+}
+
+typedef struct { double f[1]; } hfa1_double_a_t;
+hfa1_double_a_t fun_hfa1_double_a (void) {
+ hfa1_double_a_t ret = { { 3.0 } };
+ return ret;
+}
+
+typedef struct { long double f[1]; } hfa1_long_double_a_t;
+hfa1_long_double_a_t fun_hfa1_long_double_a (void) {
+ hfa1_long_double_a_t ret = { { 3.0 } };
+ return ret;
+}
+
+typedef struct { float f; float g; } hfa2_float_t;
+hfa2_float_t fun_hfa2_float (void) {
+ hfa2_float_t ret = { 1.5, 3.0 };
+ return ret;
+}
+
+typedef struct { double f; double g; } hfa2_double_t;
+hfa2_double_t fun_hfa2_double (void) {
+ hfa2_double_t ret = { 3.0, 4.5 };
+ return ret;
+}
+
+typedef struct { long double f; long double g; } hfa2_long_double_t;
+hfa2_long_double_t fun_hfa2_long_double (void) {
+ hfa2_long_double_t ret = { 3.0, 4.5 };
+ return ret;
+}
+
+typedef struct { float f[2]; } hfa2_float_a_t;
+hfa2_float_a_t fun_hfa2_float_a (void) {
+ hfa2_float_a_t ret = { { 2.5, 3.5 } };
+ return ret;
+}
+
+typedef struct { double f[2]; } hfa2_double_a_t;
+hfa2_double_a_t fun_hfa2_double_a (void) {
+ hfa2_double_a_t ret = { { 3.0, 3.5 } };
+ return ret;
+}
+
+typedef struct { long double f[2]; } hfa2_long_double_a_t;
+hfa2_long_double_a_t fun_hfa2_long_double_a (void) {
+ hfa2_long_double_a_t ret = { { 3.0, 4.0 } };
+ return ret;
+}
+
+typedef struct { float f; float g; float h; } hfa3_float_t;
+hfa3_float_t fun_hfa3_float (void) {
+ hfa3_float_t ret = { 1.5, 3.0, 4.5 };
+ return ret;
+}
+
+typedef struct { double f; double g; double h; } hfa3_double_t;
+hfa3_double_t fun_hfa3_double (void) {
+ hfa3_double_t ret = { 3.0, 4.5, 9.5 };
+ return ret;
+}
+
+typedef struct { long double f; long double g; long double h; } hfa3_long_double_t;
+hfa3_long_double_t fun_hfa3_long_double (void) {
+ hfa3_long_double_t ret = { 3.0, 4.5, 9.5 };
+ return ret;
+}
+
+typedef struct { float f[3]; } hfa3_float_a_t;
+hfa3_float_a_t fun_hfa3_float_a (void) {
+ hfa3_float_a_t ret = { { 3.5, 4.5, 5.5 } };
+ return ret;
+}
+
+typedef struct { double f[3]; } hfa3_double_a_t;
+hfa3_double_a_t fun_hfa3_double_a (void) {
+ hfa3_double_a_t ret = { { 3.0, 3.5, 4.0 } };
+ return ret;
+}
+
+typedef struct { long double f[3]; } hfa3_long_double_a_t;
+hfa3_long_double_a_t fun_hfa3_long_double_a (void) {
+ hfa3_long_double_a_t ret = { { 3.0, 4.0, 5.0 } };
+ return ret;
+}
+
+typedef struct { float f; float g; float h; float i; } hfa4_float_t;
+hfa4_float_t fun_hfa4_float (void) {
+ hfa4_float_t ret = { 1.5, 3.5, 4.5, 9.5 };
+ return ret;
+}
+
+typedef struct { double f; double g; double h; double i; } hfa4_double_t;
+hfa4_double_t fun_hfa4_double (void) {
+ hfa4_double_t ret = { 3.5, 4.5, 9.5, 1.5 };
+ return ret;
+}
+
+typedef struct { long double f; long double g; long double h; long double i; } hfa4_long_double_t;
+hfa4_long_double_t fun_hfa4_long_double (void) {
+ hfa4_long_double_t ret = { 3.5, 4.5, 9.5, 1.5 };
+ return ret;
+}
+
+typedef struct { float f[4]; } hfa4_float_a_t;
+hfa4_float_a_t fun_hfa4_float_a (void) {
+ hfa4_float_a_t ret = { { 4.5, 5.5, 6.5, 7.5 } };
+ return ret;
+}
+
+typedef struct { double f[4]; } hfa4_double_a_t;
+hfa4_double_a_t fun_hfa4_double_a (void) {
+ hfa4_double_a_t ret = { { 3.0, 4.5, 5.0, 5.5 } };
+ return ret;
+}
+
+typedef struct { long double f[4]; } hfa4_long_double_a_t;
+hfa4_long_double_a_t fun_hfa4_long_double_a (void) {
+ hfa4_long_double_a_t ret = { { 3.0, 4.0, 5.0, 6.0 } };
+ return ret;
+}
+
+typedef struct { float f; float g; float h; float i; float j; } nfa5_float_t;
+nfa5_float_t fun_nfa5_float (void) {
+ nfa5_float_t ret = { 1.5, 3.5, 4.5, 9.5, 10.5 };
+ return ret;
+}
+
+typedef struct { double f; double g; double h; double i; double j; } nfa5_double_t;
+nfa5_double_t fun_nfa5_double (void) {
+ nfa5_double_t ret = { 3.5, 4.5, 9.5, 1.5, 2.5 };
+ return ret;
+}
+
+typedef struct { long double f; long double g; long double h; long double i; long double j; } nfa5_long_double_t;
+nfa5_long_double_t fun_nfa5_long_double (void) {
+ nfa5_long_double_t ret = { 3.5, 4.5, 9.5, 1.5, 2.5 };
+ return ret;
+}
+
+typedef struct { float f[5]; } nfa5_float_a_t;
+nfa5_float_a_t fun_nfa5_float_a (void) {
+ nfa5_float_a_t ret = { { 4.5, 5.5, 6.5, 7.5, 9.5 } };
+ return ret;
+}
+
+typedef struct { double f[5]; } nfa5_double_a_t;
+nfa5_double_a_t fun_nfa5_double_a (void) {
+ nfa5_double_a_t ret = { { 3.0, 4.5, 5.0, 5.5, 6.5 } };
+ return ret;
+}
+
+typedef struct { long double f[5]; } nfa5_long_double_a_t;
+nfa5_long_double_a_t fun_nfa5_long_double_a (void) {
+ nfa5_long_double_a_t ret = { { 3.0, 4.0, 5.0, 6.0, 7.0 } };
+ return ret;
+}
+
+#ifdef FLOAT128
+typedef struct { __float128 f; } hfa1_float128_t;
+hfa1_float128_t fun_hfa1_float128 (void) {
+ hfa1_float128_t ret = { 4.5 };
+ return ret;
+}
+
+typedef struct { __float128 f; __float128 g; } hfa2_float128_t;
+hfa2_float128_t fun_hfa2_float128 (void) {
+ hfa2_float128_t ret = { 4.5, 9.5 };
+ return ret;
+}
+
+typedef struct { __float128 f; __float128 g; __float128 h; } hfa3_float128_t;
+hfa3_float128_t fun_hfa3_float128 (void) {
+ hfa3_float128_t ret = { 4.5, 9.5, 12.5 };
+ return ret;
+}
+
+typedef struct { __float128 f; __float128 g; __float128 h; __float128 i; } hfa4_float128_t;
+hfa4_float128_t fun_hfa4_float128 (void) {
+ hfa4_float128_t ret = { 4.5, 9.5, 3.5, 1.5 };
+ return ret;
+}
+#endif
+
+// Homogeneous vector aggregates of 1 element.
+
+typedef struct { vec_char_8_t a; } hva1_vec_char_8_t;
+hva1_vec_char_8_t fun_hva1_vec_char_8 (void) {
+ hva1_vec_char_8_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8 } };
+ return ret;
+}
+
+typedef struct { vec_short_8_t a; } hva1_vec_short_8_t;
+hva1_vec_short_8_t fun_hva1_vec_short_8 (void) {
+ hva1_vec_short_8_t ret = { { 2, 3, 4, 5 } };
+ return ret;
+}
+
+typedef struct { vec_int_8_t a; } hva1_vec_int_8_t;
+hva1_vec_int_8_t fun_hva1_vec_int_8 (void) {
+ hva1_vec_int_8_t ret = { { 3, 4 } };
+ return ret;
+}
+
+typedef struct { vec_long_8_t a; } hva1_vec_long_8_t;
+hva1_vec_long_8_t fun_hva1_vec_long_8 (void) {
+ hva1_vec_long_8_t ret = { { 5 } };
+ return ret;
+}
+
+typedef struct { vec_float_8_t a; } hva1_vec_float_8_t;
+hva1_vec_float_8_t fun_hva1_vec_float_8 (void) {
+ hva1_vec_float_8_t ret = { { 1.5, 2.5 } };
+ return ret;
+}
+
+typedef struct { vec_double_8_t a; } hva1_vec_double_8_t;
+hva1_vec_double_8_t fun_hva1_vec_double_8 (void) {
+ hva1_vec_double_8_t ret = { { 3.5 } };
+ return ret;
+}
+
+typedef struct { vec_char_16_t a; } hva1_vec_char_16_t;
+hva1_vec_char_16_t fun_hva1_vec_char_16_t (void) {
+ hva1_vec_char_16_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16 } };
+ return ret;
+}
+
+typedef struct { vec_short_16_t a; } hva1_vec_short_16_t;
+hva1_vec_short_16_t fun_hva1_vec_short_16_t (void) {
+ hva1_vec_short_16_t ret = { { 2, 3, 4, 5, 6, 7, 8, 9 } };
+ return ret;
+}
+
+typedef struct { vec_int_16_t a; } hva1_vec_int_16_t;
+hva1_vec_int_16_t fun_hva1_vec_int_16_t (void) {
+ hva1_vec_int_16_t ret = { { 3, 4, 5, 6 } };
+ return ret;
+}
+
+typedef struct { vec_long_16_t a; } hva1_vec_long_16_t;
+hva1_vec_long_16_t fun_hva1_vec_long_16_t (void) {
+ hva1_vec_long_16_t ret = { { 4, 5 } };
+ return ret;
+}
+
+typedef struct { vec_int128_16_t a; } hva1_vec_int128_16_t;
+hva1_vec_int128_16_t fun_hva1_vec_int128_16_t (void) {
+ hva1_vec_int128_16_t ret = { { 6 } };
+ return ret;
+}
+
+typedef struct { vec_float_16_t a; } hva1_vec_float_16_t;
+hva1_vec_float_16_t fun_hva1_vec_float_16_t (void) {
+ hva1_vec_float_16_t ret = { { 1.5, 2.5, 3.5, 4.5 } };
+ return ret;
+}
+
+typedef struct { vec_double_16_t a; } hva1_vec_double_16_t;
+hva1_vec_double_16_t fun_hva1_vec_double_16_t (void) {
+ hva1_vec_double_16_t ret = { { 2.5, 3.5 } };
+ return ret;
+}
+
+#ifdef FLOAT128
+typedef struct { vec_float128_16_t a; } hva1_vec_float128_16_t;
+hva1_vec_float128_16_t fun_hva1_vec_float128_16_t (void) {
+ hva1_vec_float128_16_t ret = { { 4.5 } };
+ return ret;
+}
+#endif
+
+// Homogeneous vector aggregates of 2 elements.
+
+typedef struct { vec_char_8_t a; vec_char_8_t b; } hva2_vec_char_8_t;
+hva2_vec_char_8_t fun_hva2_vec_char_8 (void) {
+ hva2_vec_char_8_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8 },
+ { 2, 3, 4, 5, 6, 7, 8, 9 } };
+ return ret;
+}
+
+typedef struct { vec_short_8_t a; vec_short_8_t b; } hva2_vec_short_8_t;
+hva2_vec_short_8_t fun_hva2_vec_short_8 (void) {
+ hva2_vec_short_8_t ret = { { 2, 3, 4, 5 },
+ { 3, 4, 5, 6 } };
+ return ret;
+}
+
+typedef struct { vec_int_8_t a; vec_int_8_t b; } hva2_vec_int_8_t;
+hva2_vec_int_8_t fun_hva2_vec_int_8 (void) {
+ hva2_vec_int_8_t ret = { { 3, 4 },
+ { 4, 5 } };
+ return ret;
+}
+
+typedef struct { vec_long_8_t a; vec_long_8_t b; } hva2_vec_long_8_t;
+hva2_vec_long_8_t fun_hva2_vec_long_8 (void) {
+ hva2_vec_long_8_t ret = { { 5 },
+ { 6 } };
+ return ret;
+}
+
+typedef struct { vec_float_8_t a; vec_float_8_t b; } hva2_vec_float_8_t;
+hva2_vec_float_8_t fun_hva2_vec_float_8 (void) {
+ hva2_vec_float_8_t ret = { { 1.5, 2.5 },
+ { 2.5, 3.5 } };
+ return ret;
+}
+
+typedef struct { vec_double_8_t a; vec_double_8_t b; } hva2_vec_double_8_t;
+hva2_vec_double_8_t fun_hva2_vec_double_8 (void) {
+ hva2_vec_double_8_t ret = { { 3.5 },
+ { 4.5 } };
+ return ret;
+}
+
+typedef struct { vec_char_16_t a; vec_char_16_t b; } hva2_vec_char_16_t;
+hva2_vec_char_16_t fun_hva2_vec_char_16_t (void) {
+ hva2_vec_char_16_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16 },
+ { 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17 } };
+ return ret;
+}
+
+typedef struct { vec_short_16_t a; vec_short_16_t b; } hva2_vec_short_16_t;
+hva2_vec_short_16_t fun_hva2_vec_short_16_t (void) {
+ hva2_vec_short_16_t ret = { { 2, 3, 4, 5, 6, 7, 8, 9 },
+ { 3, 4, 5, 6, 7, 8, 9, 10 } };
+ return ret;
+}
+
+typedef struct { vec_int_16_t a; vec_int_16_t b; } hva2_vec_int_16_t;
+hva2_vec_int_16_t fun_hva2_vec_int_16_t (void) {
+ hva2_vec_int_16_t ret = { { 3, 4, 5, 6 },
+ { 4, 5, 6, 7 } };
+ return ret;
+}
+
+typedef struct { vec_long_16_t a; vec_long_16_t b; } hva2_vec_long_16_t;
+hva2_vec_long_16_t fun_hva2_vec_long_16_t (void) {
+ hva2_vec_long_16_t ret = { { 4, 5 },
+ { 5, 6 } };
+ return ret;
+}
+
+typedef struct { vec_int128_16_t a; vec_int128_16_t b; } hva2_vec_int128_16_t;
+hva2_vec_int128_16_t fun_hva2_vec_int128_16_t (void) {
+ hva2_vec_int128_16_t ret = { { 6 },
+ { 7 } };
+ return ret;
+}
+
+typedef struct { vec_float_16_t a; vec_float_16_t b; } hva2_vec_float_16_t;
+hva2_vec_float_16_t fun_hva2_vec_float_16_t (void) {
+ hva2_vec_float_16_t ret = { { 1.5, 2.5, 3.5, 4.5 },
+ { 2.5, 3.5, 4.5, 5.5 } };
+ return ret;
+}
+
+typedef struct { vec_double_16_t a; vec_double_16_t b; } hva2_vec_double_16_t;
+hva2_vec_double_16_t fun_hva2_vec_double_16_t (void) {
+ hva2_vec_double_16_t ret = { { 2.5, 3.5 },
+ { 3.5, 4.5 } };
+ return ret;
+}
+
+#ifdef FLOAT128
+typedef struct { vec_float128_16_t a; vec_float128_16_t b; } hva2_vec_float128_16_t;
+hva2_vec_float128_16_t fun_hva2_vec_float128_16_t (void) {
+ hva2_vec_float128_16_t ret = { { 4.5 },
+ { 5.5 } };
+ return ret;
+}
+#endif
+
+// Homogeneous vector aggregates of 3 elements.
+
+typedef struct { vec_char_8_t a; vec_char_8_t b; vec_char_8_t c; } hva3_vec_char_8_t;
+hva3_vec_char_8_t fun_hva3_vec_char_8 (void) {
+ hva3_vec_char_8_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8 },
+ { 2, 3, 4, 5, 6, 7, 8, 9 },
+ { 3, 4, 5, 6, 7, 8, 9, 10 } };
+ return ret;
+}
+
+typedef struct { vec_short_8_t a; vec_short_8_t b; vec_short_8_t c; } hva3_vec_short_8_t;
+hva3_vec_short_8_t fun_hva3_vec_short_8 (void) {
+ hva3_vec_short_8_t ret = { { 2, 3, 4, 5 },
+ { 3, 4, 5, 6 },
+ { 4, 5, 6, 7 } };
+ return ret;
+}
+
+typedef struct { vec_int_8_t a; vec_int_8_t b; vec_int_8_t c; } hva3_vec_int_8_t;
+hva3_vec_int_8_t fun_hva3_vec_int_8 (void) {
+ hva3_vec_int_8_t ret = { { 3, 4 },
+ { 4, 5 },
+ { 5, 6 } };
+ return ret;
+}
+
+typedef struct { vec_long_8_t a; vec_long_8_t b; vec_long_8_t c; } hva3_vec_long_8_t;
+hva3_vec_long_8_t fun_hva3_vec_long_8 (void) {
+ hva3_vec_long_8_t ret = { { 5 },
+ { 6 },
+ { 7 } };
+ return ret;
+}
+
+typedef struct { vec_float_8_t a; vec_float_8_t b; vec_float_8_t c; } hva3_vec_float_8_t;
+hva3_vec_float_8_t fun_hva3_vec_float_8 (void) {
+ hva3_vec_float_8_t ret = { { 1.5, 2.5 },
+ { 2.5, 3.5 },
+ { 3.5, 4.5 } };
+ return ret;
+}
+
+typedef struct { vec_double_8_t a; vec_double_8_t b; vec_double_8_t c; } hva3_vec_double_8_t;
+hva3_vec_double_8_t fun_hva3_vec_double_8 (void) {
+ hva3_vec_double_8_t ret = { { 3.5 },
+ { 4.5 },
+ { 5.5 } };
+ return ret;
+}
+
+typedef struct { vec_char_16_t a; vec_char_16_t b; vec_char_16_t c; } hva3_vec_char_16_t;
+hva3_vec_char_16_t fun_hva3_vec_char_16_t (void) {
+ hva3_vec_char_16_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16 },
+ { 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17 },
+ { 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18 } };
+ return ret;
+}
+
+typedef struct { vec_short_16_t a; vec_short_16_t b; vec_short_16_t c; } hva3_vec_short_16_t;
+hva3_vec_short_16_t fun_hva3_vec_short_16_t (void) {
+ hva3_vec_short_16_t ret = { { 2, 3, 4, 5, 6, 7, 8, 9 },
+ { 3, 4, 5, 6, 7, 8, 9, 10 },
+ { 4, 5, 6, 7, 8, 9, 10, 11 } };
+ return ret;
+}
+
+typedef struct { vec_int_16_t a; vec_int_16_t b; vec_int_16_t c; } hva3_vec_int_16_t;
+hva3_vec_int_16_t fun_hva3_vec_int_16_t (void) {
+ hva3_vec_int_16_t ret = { { 3, 4, 5, 6 },
+ { 4, 5, 6, 7 },
+ { 5, 6, 7, 8 } };
+ return ret;
+}
+
+typedef struct { vec_long_16_t a; vec_long_16_t b; vec_long_16_t c; } hva3_vec_long_16_t;
+hva3_vec_long_16_t fun_hva3_vec_long_16_t (void) {
+ hva3_vec_long_16_t ret = { { 3, 4 },
+ { 4, 5 },
+ { 5, 6 } };
+ return ret;
+}
+
+typedef struct { vec_int128_16_t a; vec_int128_16_t b; vec_int128_16_t c; } hva3_vec_int128_16_t;
+hva3_vec_int128_16_t fun_hva3_vec_int128_16_t (void) {
+ hva3_vec_int128_16_t ret = { { 6 },
+ { 7 },
+ { 8 } };
+ return ret;
+}
+
+typedef struct { vec_float_16_t a; vec_float_16_t b; vec_float_16_t c; } hva3_vec_float_16_t;
+hva3_vec_float_16_t fun_hva3_vec_float_16_t (void) {
+ hva3_vec_float_16_t ret = { { 1.5, 2.5, 3.5, 4.5 },
+ { 2.5, 3.5, 4.5, 5.5 },
+ { 3.5, 4.5, 5.5, 6.5 } };
+ return ret;
+}
+
+typedef struct { vec_double_16_t a; vec_double_16_t b; vec_double_16_t c; } hva3_vec_double_16_t;
+hva3_vec_double_16_t fun_hva3_vec_double_16_t (void) {
+ hva3_vec_double_16_t ret = { { 2.5, 3.5 },
+ { 3.5, 4.5 },
+ { 4.5, 5.5 } };
+ return ret;
+}
+
+#ifdef FLOAT128
+typedef struct { vec_float128_16_t a; vec_float128_16_t b; vec_float128_16_t c; } hva3_vec_float128_16_t;
+hva3_vec_float128_16_t fun_hva3_vec_float128_16_t (void) {
+ hva3_vec_float128_16_t ret = { { 4.5 },
+ { 5.5 },
+ { 6.5 } };
+ return ret;
+}
+#endif
+
+// Homogeneous vector aggregates of 3 elements.
+
+typedef struct { vec_char_8_t a; vec_char_8_t b; vec_char_8_t c; vec_char_8_t d; } hva4_vec_char_8_t;
+hva4_vec_char_8_t fun_hva4_vec_char_8 (void) {
+ hva4_vec_char_8_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8 },
+ { 2, 3, 4, 5, 6, 7, 8, 9 },
+ { 3, 4, 5, 6, 7, 8, 9, 10 },
+ { 4, 5, 6, 7, 8, 9, 10, 11 } };
+ return ret;
+}
+
+typedef struct { vec_short_8_t a; vec_short_8_t b; vec_short_8_t c; vec_short_8_t d; } hva4_vec_short_8_t;
+hva4_vec_short_8_t fun_hva4_vec_short_8 (void) {
+ hva4_vec_short_8_t ret = { { 2, 3, 4, 5 },
+ { 3, 4, 5, 6 },
+ { 4, 5, 6, 7 },
+ { 5, 6, 7, 8 } };
+ return ret;
+}
+
+typedef struct { vec_int_8_t a; vec_int_8_t b; vec_int_8_t c; vec_int_8_t d; } hva4_vec_int_8_t;
+hva4_vec_int_8_t fun_hva4_vec_int_8 (void) {
+ hva4_vec_int_8_t ret = { { 3, 4 },
+ { 4, 5 },
+ { 5, 6 },
+ { 6, 7 } };
+ return ret;
+}
+
+typedef struct { vec_long_8_t a; vec_long_8_t b; vec_long_8_t c; vec_long_8_t d; } hva4_vec_long_8_t;
+hva4_vec_long_8_t fun_hva4_vec_long_8 (void) {
+ hva4_vec_long_8_t ret = { { 5 },
+ { 6 },
+ { 7 },
+ { 8 } };
+ return ret;
+}
+
+typedef struct { vec_float_8_t a; vec_float_8_t b; vec_float_8_t c; vec_float_8_t d; } hva4_vec_float_8_t;
+hva4_vec_float_8_t fun_hva4_vec_float_8 (void) {
+ hva4_vec_float_8_t ret = { { 1.5, 2.5 },
+ { 2.5, 3.5 },
+ { 3.5, 4.5 },
+ { 4.5, 5.5 } };
+ return ret;
+}
+
+typedef struct { vec_double_8_t a; vec_double_8_t b; vec_double_8_t c; vec_double_8_t d; } hva4_vec_double_8_t;
+hva4_vec_double_8_t fun_hva4_vec_double_8 (void) {
+ hva4_vec_double_8_t ret = { { 3.5 },
+ { 4.5 },
+ { 5.5 },
+ { 6.5 } };
+ return ret;
+}
+
+typedef struct { vec_char_16_t a; vec_char_16_t b; vec_char_16_t c; vec_char_16_t d; } hva4_vec_char_16_t;
+hva4_vec_char_16_t fun_hva4_vec_char_16_t (void) {
+ hva4_vec_char_16_t ret = { { 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16 },
+ { 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17 },
+ { 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18 },
+ { 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19 } };
+ return ret;
+}
+
+typedef struct { vec_short_16_t a; vec_short_16_t b; vec_short_16_t c; vec_short_16_t d; } hva4_vec_short_16_t;
+hva4_vec_short_16_t fun_hva4_vec_short_16_t (void) {
+ hva4_vec_short_16_t ret = { { 2, 3, 4, 5, 6, 7, 8, 9 },
+ { 3, 4, 5, 6, 7, 8, 9, 10 },
+ { 4, 5, 6, 7, 8, 9, 10, 11 },
+ { 5, 6, 7, 8, 9, 10, 11, 12 } };
+ return ret;
+}
+
+typedef struct { vec_int_16_t a; vec_int_16_t b; vec_int_16_t c; vec_int_16_t d; } hva4_vec_int_16_t;
+hva4_vec_int_16_t fun_hva4_vec_int_16_t (void) {
+ hva4_vec_int_16_t ret = { { 3, 4, 5, 6 },
+ { 4, 5, 6, 7 },
+ { 5, 6, 7, 8 },
+ { 6, 7, 8, 9 } };
+ return ret;
+}
+
+typedef struct { vec_long_16_t a; vec_long_16_t b; vec_long_16_t c; vec_long_16_t d; } hva4_vec_long_16_t;
+hva4_vec_long_16_t fun_hva4_vec_long_16_t (void) {
+ hva4_vec_long_16_t ret = { { 3, 4 },
+ { 4, 5 },
+ { 5, 6 },
+ { 6, 7 } };
+ return ret;
+}
+
+typedef struct { vec_int128_16_t a; vec_int128_16_t b; vec_int128_16_t c; vec_int128_16_t d; } hva4_vec_int128_16_t;
+hva4_vec_int128_16_t fun_hva4_vec_int128_16_t (void) {
+ hva4_vec_int128_16_t ret = { { 6 },
+ { 7 },
+ { 8 },
+ { 9 } };
+ return ret;
+}
+
+typedef struct { vec_float_16_t a; vec_float_16_t b; vec_float_16_t c; vec_float_16_t d; } hva4_vec_float_16_t;
+hva4_vec_float_16_t fun_hva4_vec_float_16_t (void) {
+ hva4_vec_float_16_t ret = { { 1.5, 2.5, 3.5, 4.5 },
+ { 2.5, 3.5, 4.5, 5.5 },
+ { 3.5, 4.5, 5.5, 6.5 },
+ { 4.5, 5.5, 6.5, 7.5 } };
+ return ret;
+}
+
+typedef struct { vec_double_16_t a; vec_double_16_t b; vec_double_16_t c; vec_double_16_t d; } hva4_vec_double_16_t;
+hva4_vec_double_16_t fun_hva4_vec_double_16_t (void) {
+ hva4_vec_double_16_t ret = { { 2.5, 3.5 },
+ { 3.5, 4.5 },
+ { 4.5, 5.5 },
+ { 5.5, 6.5 } };
+ return ret;
+}
+
+#ifdef FLOAT128
+typedef struct { vec_float128_16_t a; vec_float128_16_t b; vec_float128_16_t c; vec_float128_16_t d; } hva4_vec_float128_16_t;
+hva4_vec_float128_16_t fun_hva4_vec_float128_16_t (void) {
+ hva4_vec_float128_16_t ret = { { 4.5 },
+ { 5.5 },
+ { 6.5 },
+ { 7.5 } };
+ return ret;
+}
+#endif
+
+// Mixed HFA.
+typedef struct { float _Complex a; float b; } mixed_hfa3_cff_t;
+mixed_hfa3_cff_t fun_mixed_hfa3_cff (void) {
+ mixed_hfa3_cff_t ret = { 1.5 + 2.5i, 3.5 };
+ return ret;
+}
+
+typedef struct { double _Complex a; double b; } mixed_hfa3_cdd_t;
+mixed_hfa3_cdd_t fun_mixed_hfa3_cdd (void) {
+ mixed_hfa3_cdd_t ret = { 1.5 + 2.5i, 3.5 };
+ return ret;
+}
+
+typedef struct { long double _Complex a; long double b; } mixed_hfa3_cldld_t;
+mixed_hfa3_cldld_t fun_mixed_hfa3_cldld (void) {
+ mixed_hfa3_cldld_t ret = { 1.5 + 2.5i, 3.5 };
+ return ret;
+}
+
+typedef struct { float b; float _Complex a; } mixed_hfa3_fcf_t;
+mixed_hfa3_fcf_t fun_mixed_hfa3_fcf (void) {
+ mixed_hfa3_fcf_t ret = { 3.5, 1.5 + 2.5i };
+ return ret;
+}
+
+typedef struct { double b; double _Complex a; } mixed_hfa3_dcd_t;
+mixed_hfa3_dcd_t fun_mixed_hfa3_dcd (void) {
+ mixed_hfa3_dcd_t ret = { 3.5, 1.5 + 2.5i };
+ return ret;
+}
+
+typedef struct { long double b; long double _Complex a; } mixed_hfa3_ldcld_t;
+mixed_hfa3_ldcld_t fun_mixed_hfa3_ldcld (void) {
+ mixed_hfa3_ldcld_t ret = { 3.5, 1.5 + 2.5i };
+ return ret;
+}
+
+typedef struct { vec_float_8_t a; vec_short_8_t b; } mixed_hfa2_fltsht_t;
+mixed_hfa2_fltsht_t fun_mixed_hfa2_fltsht_t (void) {
+ mixed_hfa2_fltsht_t ret = { { 3.5, 4.5 }, { 1, 2, 3, 4 } };
+ return ret;
+}
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/tests/funcretval_test_aarch64.bz2 b/tests/funcretval_test_aarch64.bz2
new file mode 100755
index 0000000..5494e10
--- /dev/null
+++ b/tests/funcretval_test_aarch64.bz2
Binary files differ
diff --git a/tests/funcscopes.c b/tests/funcscopes.c
new file mode 100644
index 0000000..9c90185
--- /dev/null
+++ b/tests/funcscopes.c
@@ -0,0 +1,195 @@
+/* Test program for dwarf_getscopes.
+ Copyright (C) 2005, 2014 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <error.h>
+#include <string.h>
+#include <fnmatch.h>
+
+
+static void
+paddr (const char *prefix, Dwarf_Addr addr, Dwfl_Line *line)
+{
+ const char *src;
+ int lineno, linecol;
+ if (line != NULL
+ && (src = dwfl_lineinfo (line, &addr, &lineno, &linecol,
+ NULL, NULL)) != NULL)
+ {
+ if (linecol != 0)
+ printf ("%s%#" PRIx64 " (%s:%d:%d)",
+ prefix, addr, src, lineno, linecol);
+ else
+ printf ("%s%#" PRIx64 " (%s:%d)",
+ prefix, addr, src, lineno);
+ }
+ else
+ printf ("%s%#" PRIx64, prefix, addr);
+}
+
+
+static void
+print_vars (unsigned int indent, Dwarf_Die *die)
+{
+ Dwarf_Die child;
+ if (dwarf_child (die, &child) == 0)
+ do
+ switch (dwarf_tag (&child))
+ {
+ case DW_TAG_variable:
+ case DW_TAG_formal_parameter:
+ printf ("%*s%-30s[%6" PRIx64 "]\n", indent, "",
+ dwarf_diename (&child),
+ (uint64_t) dwarf_dieoffset (&child));
+ break;
+ default:
+ break;
+ }
+ while (dwarf_siblingof (&child, &child) == 0);
+
+ Dwarf_Attribute attr_mem;
+ Dwarf_Die origin;
+ if (dwarf_hasattr (die, DW_AT_abstract_origin)
+ && dwarf_formref_die (dwarf_attr (die, DW_AT_abstract_origin, &attr_mem),
+ &origin) != NULL
+ && dwarf_child (&origin, &child) == 0)
+ do
+ switch (dwarf_tag (&child))
+ {
+ case DW_TAG_variable:
+ case DW_TAG_formal_parameter:
+ printf ("%*s%s (abstract)\n", indent, "",
+ dwarf_diename (&child));
+ break;
+ default:
+ break;
+ }
+ while (dwarf_siblingof (&child, &child) == 0);
+}
+
+
+#define INDENT 4
+
+struct args
+{
+ Dwfl *dwfl;
+ Dwarf_Die *cu;
+ Dwarf_Addr dwbias;
+ char **argv;
+};
+
+static int
+handle_function (Dwarf_Die *funcdie, void *arg)
+{
+ struct args *a = arg;
+
+ const char *name = dwarf_diename (funcdie);
+ char **argv = a->argv;
+ if (argv[0] != NULL)
+ {
+ bool match;
+ do
+ match = fnmatch (*argv, name, 0) == 0;
+ while (!match && *++argv);
+ if (!match)
+ return 0;
+ }
+
+ Dwarf_Die *scopes;
+ int n = dwarf_getscopes_die (funcdie, &scopes);
+ if (n <= 0)
+ error (EXIT_FAILURE, 0, "dwarf_getscopes_die: %s", dwarf_errmsg (-1));
+ else
+ {
+ Dwarf_Addr start, end;
+ const char *fname;
+ const char *modname = dwfl_module_info (dwfl_cumodule (a->cu), NULL,
+ &start, &end,
+ NULL, NULL,
+ &fname, NULL);
+ if (modname == NULL)
+ error (EXIT_FAILURE, 0, "dwfl_module_info: %s", dwarf_errmsg (-1));
+ if (modname[0] == '\0')
+ modname = fname;
+ printf ("%s: %#" PRIx64 " .. %#" PRIx64 "\n", modname, start, end);
+
+ unsigned int indent = 0;
+ while (n-- > 0)
+ {
+ Dwarf_Die *const die = &scopes[n];
+
+ indent += INDENT;
+ printf ("%*s%s (%#x)", indent, "",
+ dwarf_diename (die) ?: "<unnamed>",
+ dwarf_tag (die));
+
+ Dwarf_Addr lowpc, highpc;
+ if (dwarf_lowpc (die, &lowpc) == 0
+ && dwarf_highpc (die, &highpc) == 0)
+ {
+ lowpc += a->dwbias;
+ highpc += a->dwbias;
+ Dwfl_Line *loline = dwfl_getsrc (a->dwfl, lowpc);
+ Dwfl_Line *hiline = dwfl_getsrc (a->dwfl, highpc - 1);
+ paddr (": ", lowpc, loline);
+ if (highpc != lowpc)
+ paddr (" .. ", highpc - 1, hiline == loline ? NULL : hiline);
+ }
+ puts ("");
+
+ print_vars (indent + INDENT, die);
+ }
+ free (scopes);
+ }
+
+ return 0;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ struct args a = { .dwfl = NULL, .cu = NULL };
+
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining,
+ &a.dwfl);
+ assert (a.dwfl != NULL);
+ a.argv = &argv[remaining];
+
+ int result = 0;
+
+ while ((a.cu = dwfl_nextcu (a.dwfl, a.cu, &a.dwbias)) != NULL)
+ dwarf_getfuncs (a.cu, &handle_function, &a, 0);
+
+ dwfl_end (a.dwfl);
+
+ return result;
+}
diff --git a/tests/get-aranges.c b/tests/get-aranges.c
new file mode 100644
index 0000000..7f85cda
--- /dev/null
+++ b/tests/get-aranges.c
@@ -0,0 +1,142 @@
+/* Copyright (C) 2002, 2004 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include <libelf.h>
+#include ELFUTILS_HEADER(dw)
+#include <stdio.h>
+#include <unistd.h>
+
+
+static const Dwarf_Addr testaddr[] =
+{
+ 0x804842b, 0x804842c, 0x804843c, 0x8048459, 0x804845a,
+ 0x804845b, 0x804845c, 0x8048460, 0x8048465, 0x8048466,
+ 0x8048467, 0x8048468, 0x8048470, 0x8048471, 0x8048472
+};
+#define ntestaddr (sizeof (testaddr) / sizeof (testaddr[0]))
+
+
+int
+main (int argc, char *argv[])
+{
+ int result = 0;
+ int cnt;
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ int fd = open (argv[cnt], O_RDONLY);
+
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ {
+ printf ("%s not usable\n", argv[cnt]);
+ result = 1;
+ close (fd);
+ continue;
+ }
+
+ Dwarf_Aranges *aranges;
+ size_t naranges;
+ if (dwarf_getaranges (dbg, &aranges, &naranges) != 0)
+ printf ("%s: cannot get aranges\n", argv[cnt]);
+ else
+ {
+ for (size_t i = 0; i < ntestaddr; ++i)
+ {
+ Dwarf_Arange *found;
+
+ found = dwarf_getarange_addr (aranges, testaddr[i]);
+ if (found != NULL)
+ {
+ Dwarf_Off cu_offset;
+
+ if (dwarf_getarangeinfo (found, NULL, NULL, &cu_offset) != 0)
+ {
+ puts ("failed to get CU die offset");
+ result = 1;
+ }
+ else
+ {
+ const char *cuname;
+ Dwarf_Die cu_die;
+
+ if (dwarf_offdie (dbg, cu_offset, &cu_die) == NULL
+ || (cuname = dwarf_diename (&cu_die)) == NULL)
+ {
+ puts ("failed to get CU die");
+ result = 1;
+ }
+ else
+ printf ("CU name: \"%s\"\n", cuname);
+ }
+ }
+ else
+ printf ("%#llx: not in range\n",
+ (unsigned long long int) testaddr[i]);
+ }
+
+ for (size_t i = 0; i < naranges; ++i)
+ {
+ Dwarf_Arange *arange = dwarf_onearange (aranges, i);
+ if (arange == NULL)
+ {
+ printf ("cannot get arange %zu: %s\n", i, dwarf_errmsg (-1));
+ break;
+ }
+
+ Dwarf_Addr start;
+ Dwarf_Word length;
+ Dwarf_Off cu_offset;
+
+ if (dwarf_getarangeinfo (arange, &start, &length, &cu_offset)
+ != 0)
+ {
+ printf ("cannot get info from aranges[%zu]\n", i);
+ result = 1;
+ }
+ else
+ {
+ printf (" [%2zu] start: %#llx, length: %llu, cu: %llu\n",
+ i, (unsigned long long int) start,
+ (unsigned long long int) length,
+ (unsigned long long int) cu_offset);
+
+ const char *cuname;
+ Dwarf_Die cu_die;
+ if (dwarf_offdie (dbg, cu_offset, &cu_die) == NULL
+ || (cuname = dwarf_diename (&cu_die)) == NULL)
+ {
+ puts ("failed to get CU die");
+ result = 1;
+ }
+ else
+ printf ("CU name: \"%s\"\n", cuname);
+ }
+ }
+ }
+
+ dwarf_end (dbg);
+ close (fd);
+ }
+
+ return result;
+}
diff --git a/tests/get-files.c b/tests/get-files.c
new file mode 100644
index 0000000..0409173
--- /dev/null
+++ b/tests/get-files.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 2002, 2004, 2005, 2007 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include <libelf.h>
+#include ELFUTILS_HEADER(dw)
+#include <stdio.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int result = 0;
+ int cnt;
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ int fd = open (argv[cnt], O_RDONLY);
+
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ {
+ printf ("%s not usable\n", argv[cnt]);
+ result = 1;
+ if (fd != -1)
+ close (fd);
+ continue;
+ }
+
+ Dwarf_Off o = 0;
+ Dwarf_Off ncu;
+ Dwarf_Off ao;
+ size_t cuhl;
+ uint8_t asz;
+ uint8_t osz;
+ while (dwarf_nextcu (dbg, o, &ncu, &cuhl, &ao, &asz, &osz) == 0)
+ {
+ printf ("cuhl = %zu, o = %llu, asz = %hhu, osz = %hhu, ncu = %llu\n",
+ cuhl, (unsigned long long int) ao,
+ asz, osz, (unsigned long long int) ncu);
+
+ Dwarf_Die die_mem;
+ Dwarf_Die *die = dwarf_offdie (dbg, o + cuhl, &die_mem);
+ if (die == NULL)
+ {
+ printf ("%s: cannot get CU die\n", argv[cnt]);
+ result = 1;
+ break;
+ }
+
+ Dwarf_Files *files;
+ size_t nfiles;
+ if (dwarf_getsrcfiles (die, &files, &nfiles) != 0)
+ {
+ printf ("%s: cannot get files\n", argv[cnt]);
+ result = 1;
+ break;
+ }
+
+ const char *const *dirs;
+ size_t ndirs;
+ if (dwarf_getsrcdirs (files, &dirs, &ndirs) != 0)
+ {
+ printf ("%s: cannot get include directories\n", argv[cnt]);
+ result = 1;
+ break;
+ }
+
+ if (dirs[0] == NULL)
+ puts (" dirs[0] = (null)");
+ else
+ printf (" dirs[0] = \"%s\"\n", dirs[0]);
+ for (size_t i = 1; i < ndirs; ++i)
+ printf (" dirs[%zu] = \"%s\"\n", i, dirs[i]);
+
+ for (size_t i = 0; i < nfiles; ++i)
+ printf (" file[%zu] = \"%s\"\n", i,
+ dwarf_filesrc (files, i, NULL, NULL));
+
+ o = ncu;
+ }
+
+ dwarf_end (dbg);
+ close (fd);
+ }
+
+ return result;
+}
diff --git a/tests/get-lines.c b/tests/get-lines.c
new file mode 100644
index 0000000..188d016
--- /dev/null
+++ b/tests/get-lines.c
@@ -0,0 +1,160 @@
+/* Copyright (C) 2002, 2004 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include <inttypes.h>
+#include <libelf.h>
+#include ELFUTILS_HEADER(dw)
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int result = 0;
+ int cnt;
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ int fd = open (argv[cnt], O_RDONLY);
+
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ {
+ printf ("%s not usable: %s\n", argv[cnt], dwarf_errmsg (-1));
+ close (fd);
+ continue;
+ }
+
+ Dwarf_Off cuoff = 0;
+ Dwarf_Off old_cuoff = 0;
+ size_t hsize;
+ Dwarf_Off ao;
+ uint8_t asz;
+ uint8_t osz;
+ while (dwarf_nextcu (dbg, cuoff, &cuoff, &hsize, &ao, &asz, &osz) == 0)
+ {
+ printf ("cuhl = %zu, o = %llu, asz = %hhu, osz = %hhu, ncu = %llu\n",
+ hsize, (unsigned long long int) ao,
+ asz, osz, (unsigned long long int) cuoff);
+
+ /* Get the DIE for the CU. */
+ Dwarf_Die die;
+ if (dwarf_offdie (dbg, old_cuoff + hsize, &die) == NULL)
+ {
+ /* Something went wrong. */
+ printf ("%s: cannot get CU die\n", argv[cnt]);
+ result = 1;
+ break;
+ }
+ old_cuoff = cuoff;
+
+ Dwarf_Lines *lb;
+ size_t nlb;
+ if (dwarf_getsrclines (&die, &lb, &nlb) != 0)
+ {
+ printf ("%s: cannot get lines\n", argv[cnt]);
+ result = 1;
+ break;
+ }
+
+ printf (" %zu lines\n", nlb);
+
+ for (size_t i = 0; i < nlb; ++i)
+ {
+ Dwarf_Line *l = dwarf_onesrcline (lb, i);
+ if (l == NULL)
+ {
+ printf ("%s: cannot get individual line\n", argv[cnt]);
+ result = 1;
+ break;
+ }
+
+ Dwarf_Addr addr;
+ if (dwarf_lineaddr (l, &addr) != 0)
+ addr = 0;
+ const char *file = dwarf_linesrc (l, NULL, NULL);
+ int line;
+ if (dwarf_lineno (l, &line) != 0)
+ line = 0;
+
+ printf ("%" PRIx64 ": %s:%d:", (uint64_t) addr,
+ file ?: "???", line);
+
+ /* Getting the file path through the Dwarf_Files should
+ result in the same path. */
+ Dwarf_Files *files;
+ size_t idx;
+ if (dwarf_line_file (l, &files, &idx) != 0)
+ {
+ printf ("%s: cannot get file from line (%zd): %s\n",
+ argv[cnt], i, dwarf_errmsg (-1));
+ result = 1;
+ break;
+ }
+ const char *path = dwarf_filesrc (files, idx, NULL, NULL);
+ if ((path == NULL && file != NULL)
+ || (path != NULL && file == NULL)
+ || (strcmp (file, path) != 0))
+ {
+ printf ("%s: line %zd srcline (%s) != file srcline (%s)\n",
+ argv[cnt], i, file ?: "???", path ?: "???");
+ result = 1;
+ break;
+ }
+
+ int column;
+ if (dwarf_linecol (l, &column) != 0)
+ column = 0;
+ if (column >= 0)
+ printf ("%d:", column);
+
+ bool is_stmt;
+ if (dwarf_linebeginstatement (l, &is_stmt) != 0)
+ is_stmt = false;
+ bool end_sequence;
+ if (dwarf_lineendsequence (l, &end_sequence) != 0)
+ end_sequence = false;
+ bool basic_block;
+ if (dwarf_lineblock (l, &basic_block) != 0)
+ basic_block = false;
+ bool prologue_end;
+ if (dwarf_lineprologueend (l, &prologue_end) != 0)
+ prologue_end = false;
+ bool epilogue_begin;
+ if (dwarf_lineepiloguebegin (l, &epilogue_begin) != 0)
+ epilogue_begin = false;
+
+ printf (" is_stmt:%s, end_seq:%s, bb:%s, prologue:%s, epilogue:%s\n",
+ is_stmt ? "yes" : "no", end_sequence ? "yes" : "no",
+ basic_block ? "yes" : "no", prologue_end ? "yes" : "no",
+ epilogue_begin ? "yes" : "no");
+ }
+ }
+
+ dwarf_end (dbg);
+ close (fd);
+ }
+
+ return result;
+}
diff --git a/tests/get-pubnames.c b/tests/get-pubnames.c
new file mode 100644
index 0000000..4777f49
--- /dev/null
+++ b/tests/get-pubnames.c
@@ -0,0 +1,98 @@
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <fcntl.h>
+#include <libelf.h>
+#include ELFUTILS_HEADER(dw)
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int globcnt;
+
+static int
+callback (Dwarf *dbg, Dwarf_Global *gl, void *arg __attribute__ ((unused)))
+{
+ int result = DWARF_CB_OK;
+
+ printf (" [%2d] \"%s\", die: %llu, cu: %llu\n",
+ globcnt++, gl->name, (unsigned long long int) gl->die_offset,
+ (unsigned long long int) gl->cu_offset);
+
+ Dwarf_Die cu_die;
+ const char *cuname;
+ if (dwarf_offdie (dbg, gl->cu_offset, &cu_die) == NULL
+ || (cuname = dwarf_diename (&cu_die)) == NULL)
+ {
+ puts ("failed to get CU die");
+ result = DWARF_CB_ABORT;
+ }
+ else
+ printf ("CU name: \"%s\"\n", cuname);
+
+ const char *diename;
+ Dwarf_Die die;
+ if (dwarf_offdie (dbg, gl->die_offset, &die) == NULL
+ || (diename = dwarf_diename (&die)) == NULL)
+ {
+ puts ("failed to get object die");
+ result = DWARF_CB_ABORT;
+ }
+ else
+ printf ("object name: \"%s\"\n", diename);
+
+ return result;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int result = 0;
+ int cnt;
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ int fd = open (argv[cnt], O_RDONLY);
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ {
+ printf ("%s not usable: %s\n", argv[cnt], dwarf_errmsg (-1));
+ result = 1;
+ close (fd);
+ continue;
+ }
+
+ globcnt = 0;
+
+ if (dwarf_getpubnames (dbg, callback, NULL, 0) != 0)
+ {
+ printf ("dwarf_get_pubnames didn't return zero: %s\n",
+ dwarf_errmsg (-1));
+ result = 1;
+ }
+
+ dwarf_end (dbg);
+ close (fd);
+ }
+
+ return result;
+}
diff --git a/tests/getsrc_die.c b/tests/getsrc_die.c
new file mode 100644
index 0000000..055aede
--- /dev/null
+++ b/tests/getsrc_die.c
@@ -0,0 +1,72 @@
+/* Copyright (C) 2014 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 <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <libelf.h>
+#include ELFUTILS_HEADER(dw)
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ /* file addr+ */
+ int fd = open (argv[1], O_RDONLY);
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ error (-1, 0, "dwarf_begin (%s): %s\n", argv[1], dwarf_errmsg (-1));
+
+ for (int i = 2; i < argc; i++)
+ {
+ Dwarf_Addr addr;
+ char *endptr;
+ Dwarf_Die cudie;
+ Dwarf_Line *line;
+
+ errno = 0;
+ addr = strtoull (argv[i], &endptr, 16);
+ if (errno != 0)
+ error (-1, errno, "Cannot parrse '%s'", argv[1]);
+
+ if (dwarf_addrdie (dbg, addr, &cudie) == NULL)
+ error (-1, 0, "dwarf_addrdie (%s): %s", argv[i], dwarf_errmsg (-1));
+
+ line = dwarf_getsrc_die (&cudie, addr);
+ if (line == NULL)
+ error (-1, 0, "dwarf_getsrc_die (%s): %s", argv[i], dwarf_errmsg (-1));
+
+ const char *f = dwarf_linesrc (line, NULL, NULL);
+ int l;
+ if (dwarf_lineno (line, &l) != 0)
+ l = 0;
+
+ printf ("%s:%d\n", f ?: "???", l);
+ }
+
+ dwarf_end (dbg);
+ close (fd);
+
+ return 0;
+}
diff --git a/tests/hash.c b/tests/hash.c
new file mode 100644
index 0000000..86b6ad8
--- /dev/null
+++ b/tests/hash.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2002 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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 <libelf.h>
+#include <stdio.h>
+
+
+static int
+check (const char *name, unsigned long int expected)
+{
+ unsigned long int actual = elf_hash (name);
+
+ return actual != expected;
+}
+
+
+int
+main (void)
+{
+ int status;
+
+ /* Check some names. We know what the expected result is. */
+ status = check ("_DYNAMIC", 165832675);
+ status |= check ("_GLOBAL_OFFSET_TABLE_", 102264335);
+
+ return status;
+}
diff --git a/tests/hello_aarch64.ko.bz2 b/tests/hello_aarch64.ko.bz2
new file mode 100644
index 0000000..431d89f
--- /dev/null
+++ b/tests/hello_aarch64.ko.bz2
Binary files differ
diff --git a/tests/hello_i386.ko.bz2 b/tests/hello_i386.ko.bz2
new file mode 100644
index 0000000..f89b292
--- /dev/null
+++ b/tests/hello_i386.ko.bz2
Binary files differ
diff --git a/tests/hello_m68k.ko.bz2 b/tests/hello_m68k.ko.bz2
new file mode 100644
index 0000000..2da3d17
--- /dev/null
+++ b/tests/hello_m68k.ko.bz2
Binary files differ
diff --git a/tests/hello_ppc64.ko.bz2 b/tests/hello_ppc64.ko.bz2
new file mode 100644
index 0000000..f4d3ff2
--- /dev/null
+++ b/tests/hello_ppc64.ko.bz2
Binary files differ
diff --git a/tests/hello_s390.ko.bz2 b/tests/hello_s390.ko.bz2
new file mode 100644
index 0000000..41525bf
--- /dev/null
+++ b/tests/hello_s390.ko.bz2
Binary files differ
diff --git a/tests/hello_x86_64.ko.bz2 b/tests/hello_x86_64.ko.bz2
new file mode 100644
index 0000000..ba06f91
--- /dev/null
+++ b/tests/hello_x86_64.ko.bz2
Binary files differ
diff --git a/tests/lfs-symbols b/tests/lfs-symbols
new file mode 100644
index 0000000..282a4ad
--- /dev/null
+++ b/tests/lfs-symbols
@@ -0,0 +1,73 @@
+# Imported from lintian/data/binaries/lfs-symbols
+#
+# Exceptions:
+# fts* - linux-kernel-modules.c is careful with FTS_NOSTAT
+
+# Manually maintained list of non-lfs symbols
+#
+# List was found by grepping around in /usr/include on an i386 system
+# with build-essential installed
+#
+# Please keep this sorted by key.
+
+__fxstat
+__fxstatat
+__lxstat
+__xstat
+aio_cancel
+aio_error
+aio_fsync
+aio_read
+aio_return
+aio_suspend
+aio_write
+alphasort
+creat
+fallocate
+fgetpos
+fopen
+freopen
+fseeko
+fsetpos
+fstatfs
+fstatvfs
+ftello
+ftruncate
+#fts_open
+#fts_read
+#fts_children
+#fts_set
+#fts_close
+ftw
+getdirentries
+getrlimit
+glob
+globfree
+lio_listio
+lockf
+lseek
+mkostemp
+mkostemps
+mkstemp
+mkstemps
+mmap
+nftw
+open
+openat
+posix_fadvise
+posix_fallocate
+pread
+preadv
+prlimit
+pwrite
+pwritev
+readdir
+readdir_r
+scandir
+sendfile
+setrlimit
+statfs
+statvfs
+tmpfile
+truncate
+versionsort
diff --git a/tests/libtestfile_multi_shared.so.bz2 b/tests/libtestfile_multi_shared.so.bz2
new file mode 100755
index 0000000..e9eb6a7
--- /dev/null
+++ b/tests/libtestfile_multi_shared.so.bz2
Binary files differ
diff --git a/tests/line2addr.c b/tests/line2addr.c
new file mode 100644
index 0000000..e0d65d3
--- /dev/null
+++ b/tests/line2addr.c
@@ -0,0 +1,148 @@
+/* Copyright (C) 2005 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 <inttypes.h>
+#include <assert.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <argp.h>
+#include <stdio.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+
+
+static void
+print_address (Dwfl_Module *mod, Dwarf_Addr address)
+{
+ int n = dwfl_module_relocations (mod);
+ if (n < 0)
+ error (0, 0, "dwfl_module_relocations: %s", dwfl_errmsg (-1));
+ else if (n > 0)
+ {
+ int i = dwfl_module_relocate_address (mod, &address);
+ if (i < 0)
+ error (0, 0, "dwfl_module_relocate_address: %s", dwfl_errmsg (-1));
+ else
+ {
+ const char *modname = dwfl_module_info (mod, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
+ const char *secname = dwfl_module_relocation_info (mod, i, NULL);
+ if (n > 1 || secname[0] != '\0')
+ printf ("%s(%s)+%#" PRIx64, modname, secname, address);
+ else
+ printf ("%s+%#" PRIx64, modname, address);
+ return;
+ }
+ }
+
+ printf ("%#" PRIx64, address);
+}
+
+
+struct args
+{
+ const char *arg;
+ char *file;
+ int line;
+};
+
+static int
+handle_module (Dwfl_Module *mod __attribute__ ((unused)),
+ void **udata __attribute__ ((unused)),
+ const char *modname, Dwarf_Addr base __attribute__ ((unused)),
+ Dwarf *dbg __attribute__ ((unused)),
+ Dwarf_Addr bias __attribute__ ((unused)), void *arg)
+{
+ const struct args *const a = arg;
+
+ Dwfl_Line **lines = NULL;
+ size_t nlines = 0;
+
+ if (dwfl_module_getsrc_file (mod, a->file, a->line, 0, &lines, &nlines) == 0)
+ {
+ for (size_t inner = 0; inner < nlines; ++inner)
+ {
+ Dwarf_Addr addr;
+ int line = a->line, col = 0;
+ const char *file = dwfl_lineinfo (lines[inner], &addr, &line, &col,
+ NULL, NULL);
+ if (file != NULL)
+ {
+ printf ("%s -> ", a->arg);
+ print_address (mod, addr);
+ if (modname[0] != '\0')
+ printf (" (%s:", modname);
+ if (strcmp (file, a->file) || line != a->line || col != 0)
+ printf (" %s%s:%d", modname[0] != '\0' ? "" : "(",
+ file, line);
+ if (col != 0)
+ printf (":%d", col);
+ if (modname[0] != '\0'
+ || strcmp (file, a->file) || line != a->line || col != 0)
+ puts (")");
+ else
+ puts ("");
+ }
+ }
+ free (lines);
+ }
+
+ return DWARF_CB_OK;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int cnt;
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ Dwfl *dwfl = NULL;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &cnt, &dwfl);
+ assert (dwfl != NULL);
+
+ for (; cnt < argc; ++cnt)
+ {
+ struct args a = { .arg = argv[cnt] };
+
+ switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line))
+ {
+ default:
+ case 0:
+ printf ("ignored %s\n", argv[cnt]);
+ continue;
+ case 1:
+ a.line = 0;
+ break;
+ case 2:
+ break;
+ }
+
+ (void) dwfl_getdwarf (dwfl, &handle_module, &a, 0);
+
+ free (a.file);
+ }
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/linkmap-cut-lib.so.bz2 b/tests/linkmap-cut-lib.so.bz2
new file mode 100644
index 0000000..a1bda5c
--- /dev/null
+++ b/tests/linkmap-cut-lib.so.bz2
Binary files differ
diff --git a/tests/linkmap-cut.bz2 b/tests/linkmap-cut.bz2
new file mode 100644
index 0000000..f2ccd7c
--- /dev/null
+++ b/tests/linkmap-cut.bz2
Binary files differ
diff --git a/tests/linkmap-cut.core.bz2 b/tests/linkmap-cut.core.bz2
new file mode 100644
index 0000000..b55b2f2
--- /dev/null
+++ b/tests/linkmap-cut.core.bz2
Binary files differ
diff --git a/tests/low_high_pc.c b/tests/low_high_pc.c
new file mode 100644
index 0000000..d0f4302
--- /dev/null
+++ b/tests/low_high_pc.c
@@ -0,0 +1,109 @@
+/* Test program for dwarf_lowpc and dwarf_highpc
+ Copyright (C) 2012 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <error.h>
+#include <string.h>
+#include <fnmatch.h>
+
+struct args
+{
+ Dwfl *dwfl;
+ Dwarf_Die *cu;
+ Dwarf_Addr dwbias;
+ char **argv;
+ const char *file;
+};
+
+static struct args *args;
+
+static void
+fail(Dwarf_Off off, const char *name, const char *msg)
+{
+ printf("%s: [%" PRIx64 "] '%s' %s\n", args->file, off, name, msg);
+ exit(-1);
+}
+
+static int
+handle_die (Dwarf_Die *die, void *arg)
+{
+ args = arg;
+ Dwarf_Off off = dwarf_dieoffset (die);
+
+ const char *name = dwarf_diename (die);
+ if (name == NULL)
+ fail (off, "<no name>", "die without a name");
+
+ Dwarf_Addr lowpc = 0;
+ Dwarf_Addr highpc = 0;
+ if (dwarf_lowpc (die, &lowpc) != 0 && dwarf_hasattr (die, DW_AT_low_pc))
+ fail (off, name, "has DW_AT_low_pc but dwarf_lowpc fails");
+ if (dwarf_highpc (die, &highpc) != 0 && dwarf_hasattr (die, DW_AT_high_pc))
+ fail (off, name, "has DW_AT_high_pc but dwarf_highpc fails");
+
+ /* GCC < 4.7 had a bug where no code CUs got a highpc == lowpc.
+ Allow that, because it is not the main purpose of this test. */
+ if (dwarf_hasattr (die, DW_AT_low_pc)
+ && dwarf_hasattr (die, DW_AT_high_pc)
+ && highpc <= lowpc
+ && ! (dwarf_tag (die) == DW_TAG_compile_unit && highpc == lowpc))
+ {
+ printf("lowpc: %" PRIx64 ", highpc: %" PRIx64 "lx\n", lowpc, highpc);
+ fail (off, name, "highpc <= lowpc");
+ }
+
+ return 0;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ struct args a = { .dwfl = NULL, .cu = NULL };
+
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining,
+ &a.dwfl);
+ assert (a.dwfl != NULL);
+ a.argv = &argv[remaining];
+
+ int result = 0;
+
+ while ((a.cu = dwfl_nextcu (a.dwfl, a.cu, &a.dwbias)) != NULL)
+ {
+ a.file = dwarf_diename (a.cu);
+ handle_die (a.cu, &a);
+ dwarf_getfuncs (a.cu, &handle_die, &a, 0);
+ }
+
+ dwfl_end (a.dwfl);
+
+ return result;
+}
diff --git a/tests/msg_tst.c b/tests/msg_tst.c
new file mode 100644
index 0000000..aa974d0
--- /dev/null
+++ b/tests/msg_tst.c
@@ -0,0 +1,112 @@
+/* Copyright (C) 2002, 2005, 2006 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libelfP.h>
+
+static struct
+{
+ int id;
+ const char *expected;
+} libelf_msgs[ELF_E_NUM] =
+ {
+ { ELF_E_NOERROR, "no error" },
+ { ELF_E_UNKNOWN_ERROR, "unknown error" },
+ { ELF_E_UNKNOWN_VERSION, "unknown version" },
+ { ELF_E_UNKNOWN_TYPE, "unknown type" },
+ { ELF_E_INVALID_HANDLE, "invalid `Elf' handle" },
+ { ELF_E_SOURCE_SIZE, "invalid size of source operand" },
+ { ELF_E_DEST_SIZE, "invalid size of destination operand" },
+ { ELF_E_INVALID_ENCODING, "invalid encoding" },
+ { ELF_E_NOMEM, "out of memory" },
+ { ELF_E_INVALID_FILE, "invalid file descriptor" },
+ { ELF_E_INVALID_ELF, "invalid ELF file data" },
+ { ELF_E_INVALID_OP, "invalid operation" },
+ { ELF_E_NO_VERSION, "ELF version not set" },
+ { ELF_E_INVALID_CMD, "invalid command" },
+ { ELF_E_RANGE, "offset out of range" },
+ { ELF_E_ARCHIVE_FMAG, "invalid fmag field in archive header" },
+ { ELF_E_INVALID_ARCHIVE, "invalid archive file" },
+ { ELF_E_NO_ARCHIVE, "descriptor is not for an archive" },
+ { ELF_E_NO_INDEX, "no index available" },
+ { ELF_E_READ_ERROR, "cannot read data from file" },
+ { ELF_E_WRITE_ERROR, "cannot write data to file" },
+ { ELF_E_INVALID_CLASS, "invalid binary class" },
+ { ELF_E_INVALID_INDEX, "invalid section index" },
+ { ELF_E_INVALID_OPERAND, "invalid operand" },
+ { ELF_E_INVALID_SECTION, "invalid section" },
+ { ELF_E_INVALID_COMMAND, "invalid command" },
+ { ELF_E_WRONG_ORDER_EHDR, "executable header not created first" },
+ { ELF_E_FD_DISABLED, "file descriptor disabled" },
+ { ELF_E_FD_MISMATCH, "archive/member file descriptor mismatch" },
+ { ELF_E_OFFSET_RANGE, "offset out of range" },
+ { ELF_E_NOT_NUL_SECTION, "cannot manipulate null section" },
+ { ELF_E_DATA_MISMATCH, "data/scn mismatch" },
+ { ELF_E_INVALID_SECTION_HEADER, "invalid section header" },
+ { ELF_E_INVALID_DATA, "invalid data" },
+ { ELF_E_DATA_ENCODING, "unknown data encoding" },
+ { ELF_E_SECTION_TOO_SMALL, "section `sh_size' too small for data" },
+ { ELF_E_INVALID_ALIGN, "invalid section alignment" },
+ { ELF_E_INVALID_SHENTSIZE, "invalid section entry size" },
+ { ELF_E_UPDATE_RO, "update() for write on read-only file" },
+ { ELF_E_NOFILE, "no such file" },
+ { ELF_E_GROUP_NOT_REL,
+ "only relocatable files can contain section groups" },
+ { ELF_E_INVALID_PHDR,
+ "program header only allowed in executables, shared objects, \
+and core files" },
+ { ELF_E_NO_PHDR, "file has no program header" },
+ { ELF_E_INVALID_OFFSET, "invalid offset" },
+ { ELF_E_INVALID_SECTION_TYPE , "invalid section type" },
+ { ELF_E_INVALID_SECTION_FLAGS , "invalid section flags" },
+ { ELF_E_NOT_COMPRESSED, "section does not contain compressed data" },
+ { ELF_E_ALREADY_COMPRESSED, "section contains compressed data" },
+ { ELF_E_UNKNOWN_COMPRESSION_TYPE, "unknown compression type" },
+ { ELF_E_COMPRESS_ERROR, "cannot compress data" },
+ { ELF_E_DECOMPRESS_ERROR, "cannot decompress data" }
+ };
+
+
+int
+main (void)
+{
+ size_t cnt;
+ int result = EXIT_SUCCESS;
+
+ /* Clear the error state. */
+ (void) elf_errno ();
+
+ /* Check all the messages of libelf. */
+ for (cnt = 1; cnt < ELF_E_NUM; ++cnt)
+ {
+ const char *str = elf_errmsg (libelf_msgs[cnt].id);
+
+ if (strcmp (str, libelf_msgs[cnt].expected) != 0)
+ {
+ printf ("libelf msg %zu: expected \"%s\", got \"%s\"\n",
+ cnt, libelf_msgs[cnt].expected, str);
+ result = EXIT_FAILURE;
+ }
+ }
+
+ return result;
+}
diff --git a/tests/newdata.c b/tests/newdata.c
new file mode 100644
index 0000000..9af9956
--- /dev/null
+++ b/tests/newdata.c
@@ -0,0 +1,403 @@
+/* Test program for elf_newdata function.
+ 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 <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+// Random data string (16 bytes).
+static char *DATA = "123456789ABCDEF";
+static size_t DATA_LEN = 16;
+
+static void
+add_section_data (Elf *elf, char *buf, size_t len)
+{
+ printf ("Adding %zd bytes.\n", len);
+
+ Elf_Scn *scn = elf_getscn (elf, 1);
+ if (scn == NULL)
+ {
+ printf ("couldn't get data section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ Elf_Data *data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create newdata for section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = buf;
+ data->d_type = ELF_T_BYTE;
+ data->d_size = len;
+ data->d_align = 1;
+ data->d_version = EV_CURRENT;
+
+ // Let the library compute the internal structure information.
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in elf_update(NULL): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+}
+
+static Elf *
+create_elf (int fd, int class, int use_mmap)
+{
+ Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Create an ELF header.
+ if (gelf_newehdr (elf, class) == 0)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Initialize header.
+ ehdr->e_ident[EI_DATA] = class == ELFCLASS32 ? ELFDATA2LSB : ELFDATA2MSB;
+ ehdr->e_ident[EI_OSABI] = ELFOSABI_GNU;
+ ehdr->e_type = ET_NONE;
+ ehdr->e_machine = class == ELFCLASS32 ? EM_PPC : EM_X86_64;
+ ehdr->e_version = EV_CURRENT;
+
+ // Update the ELF header.
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Create a section.
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create new section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for data section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr->sh_type = SHT_PROGBITS;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_addralign = 1;
+ shdr->sh_entsize = 1;
+ shdr->sh_name = 0;
+
+ // Finish section, update the header.
+ if (gelf_update_shdr (scn, shdr) == 0)
+ {
+ printf ("cannot update header for DATA section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Add some data to the section.
+ add_section_data (elf, DATA, DATA_LEN);
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ return elf;
+}
+
+static Elf *
+read_elf (int fd, int use_mmap)
+{
+ printf ("Reading ELF file\n");
+ Elf *elf = elf_begin (fd, use_mmap ? ELF_C_RDWR_MMAP : ELF_C_RDWR, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-again: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ return elf;
+}
+
+static void
+check_section_size (Elf *elf, size_t size)
+{
+ Elf_Scn *scn = elf_getscn (elf, 1);
+ if (scn == NULL)
+ {
+ printf ("couldn't get data section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for DATA section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (shdr->sh_size == size)
+ printf ("OK %zd bytes.\n", size);
+ else
+ {
+ printf ("BAD size, expected %zd, got %" PRIu64 "\n",
+ size, shdr->sh_size);
+ exit (-1);
+ }
+}
+
+static void
+check_section_data (Elf *elf, char *data, size_t len, size_t times)
+{
+ Elf_Scn *scn = elf_getscn (elf, 1);
+ if (scn == NULL)
+ {
+ printf ("couldn't get data section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ Elf_Data *d = NULL;
+ for (size_t i = 0; i < times; i++)
+ {
+ if (d == NULL || i * len >= d->d_off + d->d_size)
+ {
+ d = elf_getdata (scn, d);
+ if (d == NULL)
+ {
+ printf ("cannot get data for section item %zd: %s\n",
+ i, elf_errmsg (-1));
+ exit (1);
+ }
+ else
+ printf ("OK, section data item %zd (d_off: %" PRId64
+ ", d_size: %zd)\n", i, d->d_off, d->d_size);
+ }
+ char *d_data = (char *) d->d_buf + (len * i) - d->d_off;
+ printf ("%zd data (d_off: %" PRId64
+ ", len * i: %zd): (%p + %" PRId64 ") %s\n",
+ i, d->d_off, len * i, d->d_buf, (len * i) - d->d_off, d_data);
+ if (memcmp (data, d_data, len) != 0)
+ {
+ printf ("Got bad data in section for item %zd.\n", i);
+ exit (1);
+ }
+ }
+}
+
+static void
+check_elf (int class, int use_mmap)
+{
+ static const char *fname;
+ if (class == ELFCLASS32)
+ fname = use_mmap ? "newdata.elf32.mmap" : "newdata.elf32";
+ else
+ fname = use_mmap ? "newdata.elf64.mmap" : "newdata.elf64";
+
+ printf ("\ncheck_elf: %s\n", fname);
+
+ int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 00666);
+ if (fd == -1)
+ {
+ printf ("cannot create `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ Elf *elf = create_elf (fd, class, use_mmap);
+ check_section_size (elf, DATA_LEN);
+ check_section_data (elf, DATA, DATA_LEN, 1);
+
+ // Add some more data (won't be written to disk).
+ add_section_data (elf, DATA, DATA_LEN);
+ check_section_size (elf, 2 * DATA_LEN);
+ check_section_data (elf, DATA, DATA_LEN, 2);
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ // Read the ELF from disk now. And add new data directly.
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = read_elf (fd, use_mmap);
+ check_section_size (elf, DATA_LEN);
+ // But don't check contents, that would read the data...
+
+ // Add some more data.
+ add_section_data (elf, DATA, DATA_LEN);
+ check_section_size (elf, 2 * DATA_LEN);
+ check_section_data (elf, DATA, DATA_LEN, 2);
+
+ // And some more.
+ add_section_data (elf, DATA, DATA_LEN);
+ check_section_size (elf, 3 * DATA_LEN);
+ check_section_data (elf, DATA, DATA_LEN, 3);
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ // Read the ELF from disk now. And add new data after raw reading.
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = read_elf (fd, use_mmap);
+ check_section_size (elf, DATA_LEN);
+ // But don't check contents, that would read the data...
+
+ // Get raw data before adding new data.
+ Elf_Scn *scn = elf_getscn (elf, 1);
+ if (scn == NULL)
+ {
+ printf ("couldn't get data section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ printf ("elf_rawdata\n");
+ Elf_Data *data = elf_rawdata (scn, NULL);
+ if (data == NULL)
+ {
+ printf ("couldn't get raw data from section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (data->d_size != DATA_LEN)
+ {
+ printf ("Unexpected Elf_Data: %zd", data->d_size);
+ exit (1);
+ }
+
+ // Now add more data.
+ add_section_data (elf, DATA, DATA_LEN);
+ check_section_size (elf, 2 * DATA_LEN);
+ check_section_data (elf, DATA, DATA_LEN, 2);
+
+ // And some more.
+ add_section_data (elf, DATA, DATA_LEN);
+ check_section_size (elf, 3 * DATA_LEN);
+ check_section_data (elf, DATA, DATA_LEN, 3);
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ // Read the ELF from disk now. And add new data after data reading.
+ fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = read_elf (fd, use_mmap);
+ check_section_size (elf, DATA_LEN);
+ // Get (converted) data before adding new data.
+ check_section_data (elf, DATA, DATA_LEN, 1);
+
+ printf ("elf_getdata\n");
+
+ // Now add more data.
+ add_section_data (elf, DATA, DATA_LEN);
+ check_section_size (elf, 2 * DATA_LEN);
+ check_section_data (elf, DATA, DATA_LEN, 2);
+
+ // And some more.
+ add_section_data (elf, DATA, DATA_LEN);
+ check_section_size (elf, 3 * DATA_LEN);
+ check_section_data (elf, DATA, DATA_LEN, 3);
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ unlink (fname);
+}
+
+int
+main (int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused)))
+{
+ // Initialize libelf.
+ elf_version (EV_CURRENT);
+
+ // Fill holes with something non-zero to more easily spot bad data.
+ elf_fill ('X');
+
+ check_elf (ELFCLASS32, 0);
+ check_elf (ELFCLASS32, 1);
+ check_elf (ELFCLASS64, 0);
+ check_elf (ELFCLASS64, 1);
+
+ return 0;
+}
diff --git a/tests/newfile.c b/tests/newfile.c
new file mode 100644
index 0000000..5eabdcb
--- /dev/null
+++ b/tests/newfile.c
@@ -0,0 +1,170 @@
+/* Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static void
+print_ehdr (Elf32_Ehdr *ehdr)
+{
+ int n;
+
+ for (n = 0; n < EI_NIDENT; ++n)
+ printf (" %02x", ehdr->e_ident[n]);
+
+ printf ("\ntype = %d\nmachine = %d\nversion = %d\nentry = %d\n"
+ "phoff = %d\nshoff = %d\nflags = %d\nehsize = %d\n"
+ "phentsize = %d\nphnum = %d\nshentsize = %d\nshnum = %d\n"
+ "shstrndx = %d\n",
+ ehdr->e_type,
+ ehdr->e_machine,
+ ehdr->e_version,
+ ehdr->e_entry,
+ ehdr->e_phoff,
+ ehdr->e_shoff,
+ ehdr->e_flags,
+ ehdr->e_ehsize,
+ ehdr->e_phentsize,
+ ehdr->e_phnum,
+ ehdr->e_shentsize,
+ ehdr->e_shnum,
+ ehdr->e_shstrndx);
+}
+
+int
+main (int argc, char *argv[] __attribute__ ((unused)))
+{
+ Elf *elf;
+ int result = 0;
+ int fd;
+ char fname[] = "newfile-XXXXXX";
+
+ fd = mkstemp (fname);
+ if (fd == -1)
+ {
+ printf ("cannot create temporary file: %m\n");
+ exit (1);
+ }
+ /* Remove the file when we exit. */
+ unlink (fname);
+
+ elf_version (EV_CURRENT);
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("elf_begin: %s\n", elf_errmsg (-1));
+ result = 1;
+ }
+ else
+ {
+ if (elf32_newehdr (elf) == NULL)
+ {
+ printf ("elf32_newehdr: %s\n", elf_errmsg (-1));
+ result = 1;
+ }
+ else
+ {
+ Elf32_Ehdr *ehdr = elf32_getehdr (elf);
+
+ if (ehdr == NULL)
+ {
+ printf ("elf32_getehdr: %s\n", elf_errmsg (-1));
+ result = 1;
+ }
+ else
+ {
+ int i;
+
+ if (argc > 1)
+ /* Use argc as a debugging flag. */
+ print_ehdr (ehdr);
+
+ /* Some tests. */
+ for (i = 0; i < EI_NIDENT; ++i)
+ if (ehdr->e_ident[i] != 0)
+ {
+ printf ("ehdr->e_ident[%d] != 0\n", i);
+ result = 1;
+ break;
+ }
+
+#define VALUE_TEST(name, val) \
+ if (ehdr->name != val) \
+ { \
+ printf ("ehdr->%s != %d\n", #name, val); \
+ result = 1; \
+ }
+#define ZERO_TEST(name) VALUE_TEST (name, 0)
+ ZERO_TEST (e_type);
+ ZERO_TEST (e_machine);
+ ZERO_TEST (e_version);
+ ZERO_TEST (e_entry);
+ ZERO_TEST (e_phoff);
+ ZERO_TEST (e_shoff);
+ ZERO_TEST (e_flags);
+ ZERO_TEST (e_ehsize);
+ ZERO_TEST (e_phentsize);
+ ZERO_TEST (e_phnum);
+ ZERO_TEST (e_shentsize);
+ ZERO_TEST (e_shnum);
+ ZERO_TEST (e_shstrndx);
+
+ if (elf32_newphdr (elf, 10) == NULL)
+ {
+ printf ("elf32_newphdr: %s\n", elf_errmsg (-1));
+ result = 1;
+ }
+ else
+ {
+ if (argc > 1)
+ print_ehdr (ehdr);
+
+ ehdr = elf32_getehdr (elf);
+ if (ehdr == NULL)
+ {
+ printf ("elf32_getehdr (#2): %s\n", elf_errmsg (-1));
+ result = 1;
+ }
+ else
+ {
+ ZERO_TEST (e_type);
+ ZERO_TEST (e_machine);
+ ZERO_TEST (e_version);
+ ZERO_TEST (e_entry);
+ ZERO_TEST (e_phoff);
+ ZERO_TEST (e_shoff);
+ ZERO_TEST (e_flags);
+ ZERO_TEST (e_ehsize);
+ VALUE_TEST (e_phentsize, (int) sizeof (Elf32_Phdr));
+ VALUE_TEST (e_phnum, 10);
+ ZERO_TEST (e_shentsize);
+ ZERO_TEST (e_shnum);
+ ZERO_TEST (e_shstrndx);
+ }
+ }
+ }
+ }
+
+ (void) elf_end (elf);
+ }
+
+ return result;
+}
diff --git a/tests/newscn.c b/tests/newscn.c
new file mode 100644
index 0000000..466f2f6
--- /dev/null
+++ b/tests/newscn.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 1999, 2000, 2001, 2002, 2005 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 <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+main (void)
+{
+ Elf *elf;
+ int fd;
+ Elf_Scn *section;
+
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ {
+ fprintf (stderr, "library fd of date\n");
+ exit (1);
+ }
+
+ char name[] = "test.XXXXXX";
+ fd = mkstemp (name);
+ if (fd < 0)
+ {
+ fprintf (stderr, "Failed to open fdput file: %s\n", name);
+ exit (1);
+ }
+ unlink (name);
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ fprintf (stderr, "Failed to elf_begin fdput file: %s\n", name);
+ exit (1);
+ }
+
+ section = elf_newscn (elf);
+ section = elf_nextscn (elf, section);
+ assert (section == NULL);
+
+ elf_end (elf);
+ close (fd);
+
+ return 0;
+}
diff --git a/tests/peel_type.c b/tests/peel_type.c
new file mode 100644
index 0000000..bccce32
--- /dev/null
+++ b/tests/peel_type.c
@@ -0,0 +1,119 @@
+/* Test program for dwarf_peel_type. Peels type of top-level vars.
+ Copyright (C) 2017 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 <argp.h>
+#include <inttypes.h>
+#include <fcntl.h>
+#include ELFUTILS_HEADER(dw)
+#include ELFUTILS_HEADER(dwfl)
+#include <stdio.h>
+#include <unistd.h>
+#include <dwarf.h>
+
+#include "../libdw/known-dwarf.h"
+
+static const char *
+dwarf_tag_string (unsigned int tag)
+{
+ switch (tag)
+ {
+#define DWARF_ONE_KNOWN_DW_TAG(NAME, CODE) case CODE: return #NAME;
+ DWARF_ALL_KNOWN_DW_TAG
+#undef DWARF_ONE_KNOWN_DW_TAG
+ default:
+ return NULL;
+ }
+}
+
+void
+print_var_raw_type (Dwarf_Die *var)
+{
+ Dwarf_Attribute attr_mem;
+ Dwarf_Die type_mem;
+ Dwarf_Die *type;
+ const char *name = dwarf_diename (var);
+
+ type = dwarf_formref_die (dwarf_attr (var, DW_AT_type, &attr_mem),
+ &type_mem);
+ if (type != NULL)
+ {
+ /* Test twice, once with a separate result DIE. Then with the
+ DIE itself. The resulting tag should be the same. */
+ Dwarf_Die result_mem;
+ Dwarf_Die *result = &result_mem;
+ int res = dwarf_peel_type (type, result);
+ if (res < 0)
+ printf ("%s error peeling type: %s\n", name, dwarf_errmsg (-1));
+ else if (res > 0)
+ printf ("%s missing DW_TAG_TYPE, could peel further: %s\n",
+ name, dwarf_tag_string (dwarf_tag (result)));
+ else
+ {
+ int tag = dwarf_tag (result);
+ printf ("%s raw type %s\n", name, dwarf_tag_string (tag));
+ res = dwarf_peel_type (type, type);
+ if (res < 0)
+ printf ("%s cannot peel type itself: %s\n", name,
+ dwarf_errmsg (-1));
+ else if (res > 0)
+ printf ("%s missing DW_TAG_TYPE, could peel type further: %s\n",
+ name, dwarf_tag_string (dwarf_tag (type)));
+ else if (dwarf_tag (type) != tag)
+ printf ("%s doesn't resolve the same: %s != %s\n", name,
+ dwarf_tag_string (tag),
+ dwarf_tag_string (dwarf_tag (type)));
+ }
+ }
+ else
+ printf ("%s has no type.\n", name);
+}
+
+int
+main (int argc, char *argv[])
+{
+
+ int remaining;
+ Dwfl *dwfl;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining,
+ &dwfl);
+ assert (dwfl != NULL);
+
+ Dwarf_Die *cu = NULL;
+ Dwarf_Addr dwbias;
+ while ((cu = dwfl_nextcu (dwfl, cu, &dwbias)) != NULL)
+ {
+ Dwarf_Die die_mem;
+ Dwarf_Die *die = &die_mem;
+ dwarf_child (cu, &die_mem);
+
+ while (1)
+ {
+ if (dwarf_tag (die) == DW_TAG_variable)
+ print_var_raw_type (die);
+
+ if (dwarf_siblingof (die, &die_mem) != 0)
+ break;
+ }
+ }
+
+ dwfl_end (dwfl);
+}
diff --git a/tests/rdwrmmap.c b/tests/rdwrmmap.c
new file mode 100644
index 0000000..6f027df
--- /dev/null
+++ b/tests/rdwrmmap.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 2006 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 <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <libelf.h>
+
+int
+main (int argc __attribute__ ((unused)), char *argv[])
+{
+ int fd = open (argv[1], O_RDWR);
+ if (fd < 0)
+ error (2, errno, "open: %s", argv[1]);
+
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ error (1, 0, "libelf version mismatch");
+
+ Elf *elf = elf_begin (fd, ELF_C_RDWR_MMAP, NULL);
+ if (elf == NULL)
+ error (1, 0, "elf_begin: %s", elf_errmsg (-1));
+
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ error (1, 0, "elf_update: %s", elf_errmsg (-1));
+
+ elf_end (elf);
+ close (fd);
+
+ return 0;
+}
diff --git a/tests/rerequest_tag.c b/tests/rerequest_tag.c
new file mode 100644
index 0000000..b4d4627
--- /dev/null
+++ b/tests/rerequest_tag.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2011 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/>. */
+
+#include <config.h>
+
+#include ELFUTILS_HEADER(dw)
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+int
+main (int argc, char **argv)
+{
+ assert (argc > 1);
+
+ int i = open (argv[1], O_RDONLY);
+ assert (i >= 0);
+
+ Dwarf *dw = dwarf_begin (i, DWARF_C_READ);
+ assert (dw != NULL);
+
+ Dwarf_Die die_mem, *die;
+ die = dwarf_offdie (dw, 11, &die_mem);
+ assert (die == &die_mem);
+ assert (dwarf_tag (die) == 0);
+
+ die = dwarf_offdie (dw, 11, &die_mem);
+ assert (die == &die_mem);
+ assert (dwarf_tag (die) == 0);
+
+ dwarf_end (dw);
+ return 0;
+}
diff --git a/tests/run-addr2line-alt-debugpath.sh b/tests/run-addr2line-alt-debugpath.sh
new file mode 100755
index 0000000..b508700
--- /dev/null
+++ b/tests/run-addr2line-alt-debugpath.sh
@@ -0,0 +1,67 @@
+#! /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-addr2line-i-test.sh
+testfiles testfile-inlines
+
+# Split off the debuginfo and put it under a separate subdir from the
+# original binary. Use --debuginfo-path to connect the dots again.
+# Note that we use separate subdirs/roots for the binaries and debug files.
+abs_test_bindir=$(pwd)/bindir
+abs_test_debugdir=$(pwd)/debugdir
+
+mkdir ${abs_test_bindir}
+mkdir ${abs_test_bindir}/bin
+mkdir ${abs_test_debugdir}
+mkdir ${abs_test_debugdir}/bin
+
+testrun ${abs_top_builddir}/src/strip -f ${abs_test_debugdir}/bin/testfile-inlines.debug -o ${abs_test_bindir}/bin/testfile-inlines testfile-inlines
+
+# Can we find the separate debuginfo file now?
+testrun_compare ${abs_top_builddir}/src/addr2line --pretty-print -a -f -i -e ${abs_test_bindir}/bin/testfile-inlines --debuginfo-path=${abs_test_debugdir} 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
+0x00000000000005a0: foobar at /tmp/x.cpp:5
+0x00000000000005a1: foobar at /tmp/x.cpp:6
+0x00000000000005b0: fubar at /tmp/x.cpp:10
+0x00000000000005b1: fubar at /tmp/x.cpp:11
+0x00000000000005c0: foobar at /tmp/x.cpp:5
+ (inlined by) bar at /tmp/x.cpp:15
+0x00000000000005d0: fubar at /tmp/x.cpp:10
+ (inlined by) baz at /tmp/x.cpp:20
+0x00000000000005e0: foobar at /tmp/x.cpp:5
+ (inlined by) bar at /tmp/x.cpp:15
+ (inlined by) _Z3foov at /tmp/x.cpp:25
+0x00000000000005e1: fubar at /tmp/x.cpp:10
+ (inlined by) baz at /tmp/x.cpp:20
+ (inlined by) _Z3foov at /tmp/x.cpp:26
+0x00000000000005f0: _Z2fuv at /tmp/x.cpp:31
+0x00000000000005f1: fubar at /tmp/x.cpp:10
+ (inlined by) _Z2fuv at /tmp/x.cpp:32
+0x00000000000005f2: foobar at /tmp/x.cpp:5
+ (inlined by) _Z2fuv at /tmp/x.cpp:33
+EOF
+
+# Cleanup
+rm ${abs_test_bindir}/bin/testfile-inlines
+rm ${abs_test_debugdir}/bin/testfile-inlines.debug
+rmdir ${abs_test_bindir}/bin
+rmdir ${abs_test_bindir}
+rmdir ${abs_test_debugdir}/bin
+rmdir ${abs_test_debugdir}
+
+exit 0
diff --git a/tests/run-addr2line-i-demangle-test.sh b/tests/run-addr2line-i-demangle-test.sh
new file mode 100755
index 0000000..1af8562
--- /dev/null
+++ b/tests/run-addr2line-i-demangle-test.sh
@@ -0,0 +1,70 @@
+#! /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/>.
+
+if test -n "$ELFUTILS_DISABLE_DEMANGLE"; then
+ echo "demangler unsupported"
+ exit 77
+fi
+
+. $srcdir/test-subr.sh
+
+# See run-addr2line-i-test.sh for how to generate test files.
+testfiles testfile-inlines
+
+# All together now plus (demangled) function names.
+testrun_compare ${abs_top_builddir}/src/addr2line -C -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
+foobar
+/tmp/x.cpp:5
+foobar
+/tmp/x.cpp:6
+fubar
+/tmp/x.cpp:10
+fubar
+/tmp/x.cpp:11
+foobar inlined at /tmp/x.cpp:15 in bar()
+/tmp/x.cpp:5
+bar
+/tmp/x.cpp:15
+fubar inlined at /tmp/x.cpp:20 in baz()
+/tmp/x.cpp:10
+baz
+/tmp/x.cpp:20
+foobar inlined at /tmp/x.cpp:15 in foo()
+/tmp/x.cpp:5
+bar
+/tmp/x.cpp:15
+foo()
+/tmp/x.cpp:25
+fubar inlined at /tmp/x.cpp:20 in foo()
+/tmp/x.cpp:10
+baz
+/tmp/x.cpp:20
+foo()
+/tmp/x.cpp:26
+fu()
+/tmp/x.cpp:31
+fubar inlined at /tmp/x.cpp:32 in fu()
+/tmp/x.cpp:10
+fu()
+/tmp/x.cpp:32
+foobar inlined at /tmp/x.cpp:33 in fu()
+/tmp/x.cpp:5
+fu()
+/tmp/x.cpp:33
+EOF
+
+exit 0
diff --git a/tests/run-addr2line-i-lex-test.sh b/tests/run-addr2line-i-lex-test.sh
new file mode 100755
index 0000000..c391fd9
--- /dev/null
+++ b/tests/run-addr2line-i-lex-test.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2014 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
+
+# // g++ x.cpp -g -fPIC -olibx.so -shared -O3 -fvisibility=hidden
+#
+# void foobar()
+# {
+# __asm__ ( "nop" ::: );
+# }
+#
+# void foo()
+# {
+# {
+# void (*bar) () = foobar;
+# bar();
+# }
+# }
+
+testfiles testfile-lex-inlines
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-lex-inlines 0x0000000000000680 <<\EOF
+/tmp/x.cpp:5
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-lex-inlines 0x0000000000000681 <<\EOF
+/tmp/x.cpp:5
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-lex-inlines 0x0000000000000690 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:12
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-lex-inlines 0x0000000000000691 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:12
+EOF
+
+# All together now (plus function names).
+testrun_compare ${abs_top_builddir}/src/addr2line -f -i -e testfile-lex-inlines 0x0000000000000680 0x0000000000000681 0x0000000000000690 0x0000000000000691 <<\EOF
+_Z6foobarv
+/tmp/x.cpp:5
+_Z6foobarv
+/tmp/x.cpp:5
+foobar inlined at /tmp/x.cpp:12 in _Z3foov
+/tmp/x.cpp:5
+_Z3foov
+/tmp/x.cpp:12
+foobar inlined at /tmp/x.cpp:12 in _Z3foov
+/tmp/x.cpp:5
+_Z3foov
+/tmp/x.cpp:12
+EOF
+
+exit 0
diff --git a/tests/run-addr2line-i-test.sh b/tests/run-addr2line-i-test.sh
new file mode 100755
index 0000000..d08f3cb
--- /dev/null
+++ b/tests/run-addr2line-i-test.sh
@@ -0,0 +1,223 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+# // g++ x.cpp -g -fPIC -olibx.so -shared -O3 -fvisibility=hidden
+#
+# void foobar()
+# {
+# __asm__ ( "nop" ::: );
+# }
+#
+# void fubar()
+# {
+# __asm__ ( "nop" ::: );
+# }
+#
+# void bar()
+# {
+# foobar();
+# }
+#
+# void baz()
+# {
+# fubar();
+# }
+#
+# void foo()
+# {
+# bar();
+# baz();
+# }
+#
+# void fu()
+# {
+# __asm__ ( "nop" ::: );
+# fubar();
+# foobar();
+# }
+
+testfiles testfile-inlines
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a0 <<\EOF
+/tmp/x.cpp:5
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a1 <<\EOF
+/tmp/x.cpp:6
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b0 <<\EOF
+/tmp/x.cpp:10
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b1 <<\EOF
+/tmp/x.cpp:11
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005c0 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:15
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005d0 <<\EOF
+/tmp/x.cpp:10
+/tmp/x.cpp:20
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005e0 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:15
+/tmp/x.cpp:25
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005e1 <<\EOF
+/tmp/x.cpp:10
+/tmp/x.cpp:20
+/tmp/x.cpp:26
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f1 <<\EOF
+/tmp/x.cpp:10
+/tmp/x.cpp:32
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f2 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:33
+EOF
+
+# All together now (plus function names).
+testrun_compare ${abs_top_builddir}/src/addr2line -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
+foobar
+/tmp/x.cpp:5
+foobar
+/tmp/x.cpp:6
+fubar
+/tmp/x.cpp:10
+fubar
+/tmp/x.cpp:11
+foobar inlined at /tmp/x.cpp:15 in _Z3barv
+/tmp/x.cpp:5
+bar
+/tmp/x.cpp:15
+fubar inlined at /tmp/x.cpp:20 in _Z3bazv
+/tmp/x.cpp:10
+baz
+/tmp/x.cpp:20
+foobar inlined at /tmp/x.cpp:15 in _Z3foov
+/tmp/x.cpp:5
+bar
+/tmp/x.cpp:15
+_Z3foov
+/tmp/x.cpp:25
+fubar inlined at /tmp/x.cpp:20 in _Z3foov
+/tmp/x.cpp:10
+baz
+/tmp/x.cpp:20
+_Z3foov
+/tmp/x.cpp:26
+_Z2fuv
+/tmp/x.cpp:31
+fubar inlined at /tmp/x.cpp:32 in _Z2fuv
+/tmp/x.cpp:10
+_Z2fuv
+/tmp/x.cpp:32
+foobar inlined at /tmp/x.cpp:33 in _Z2fuv
+/tmp/x.cpp:5
+_Z2fuv
+/tmp/x.cpp:33
+EOF
+
+# All together now (plus function names plus addresses).
+testrun_compare ${abs_top_builddir}/src/addr2line -a -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
+0x00000000000005a0
+foobar
+/tmp/x.cpp:5
+0x00000000000005a1
+foobar
+/tmp/x.cpp:6
+0x00000000000005b0
+fubar
+/tmp/x.cpp:10
+0x00000000000005b1
+fubar
+/tmp/x.cpp:11
+0x00000000000005c0
+foobar inlined at /tmp/x.cpp:15 in _Z3barv
+/tmp/x.cpp:5
+bar
+/tmp/x.cpp:15
+0x00000000000005d0
+fubar inlined at /tmp/x.cpp:20 in _Z3bazv
+/tmp/x.cpp:10
+baz
+/tmp/x.cpp:20
+0x00000000000005e0
+foobar inlined at /tmp/x.cpp:15 in _Z3foov
+/tmp/x.cpp:5
+bar
+/tmp/x.cpp:15
+_Z3foov
+/tmp/x.cpp:25
+0x00000000000005e1
+fubar inlined at /tmp/x.cpp:20 in _Z3foov
+/tmp/x.cpp:10
+baz
+/tmp/x.cpp:20
+_Z3foov
+/tmp/x.cpp:26
+0x00000000000005f0
+_Z2fuv
+/tmp/x.cpp:31
+0x00000000000005f1
+fubar inlined at /tmp/x.cpp:32 in _Z2fuv
+/tmp/x.cpp:10
+_Z2fuv
+/tmp/x.cpp:32
+0x00000000000005f2
+foobar inlined at /tmp/x.cpp:33 in _Z2fuv
+/tmp/x.cpp:5
+_Z2fuv
+/tmp/x.cpp:33
+EOF
+
+# All together now (plus function names and addresses and pretty)
+testrun_compare ${abs_top_builddir}/src/addr2line --pretty-print -a -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
+0x00000000000005a0: foobar at /tmp/x.cpp:5
+0x00000000000005a1: foobar at /tmp/x.cpp:6
+0x00000000000005b0: fubar at /tmp/x.cpp:10
+0x00000000000005b1: fubar at /tmp/x.cpp:11
+0x00000000000005c0: foobar at /tmp/x.cpp:5
+ (inlined by) bar at /tmp/x.cpp:15
+0x00000000000005d0: fubar at /tmp/x.cpp:10
+ (inlined by) baz at /tmp/x.cpp:20
+0x00000000000005e0: foobar at /tmp/x.cpp:5
+ (inlined by) bar at /tmp/x.cpp:15
+ (inlined by) _Z3foov at /tmp/x.cpp:25
+0x00000000000005e1: fubar at /tmp/x.cpp:10
+ (inlined by) baz at /tmp/x.cpp:20
+ (inlined by) _Z3foov at /tmp/x.cpp:26
+0x00000000000005f0: _Z2fuv at /tmp/x.cpp:31
+0x00000000000005f1: fubar at /tmp/x.cpp:10
+ (inlined by) _Z2fuv at /tmp/x.cpp:32
+0x00000000000005f2: foobar at /tmp/x.cpp:5
+ (inlined by) _Z2fuv at /tmp/x.cpp:33
+EOF
+
+exit 0
diff --git a/tests/run-addr2line-test.sh b/tests/run-addr2line-test.sh
new file mode 100755
index 0000000..1079c3e
--- /dev/null
+++ b/tests/run-addr2line-test.sh
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+testfiles testfile
+tempfiles good.out stdin.nl stdin.nl.out stdin.nonl stdin.nonl.out foo.out
+tempfiles addr2line.out
+
+cat > good.out <<\EOF
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+EOF
+
+echo "# Everything on the command line"
+cat good.out | testrun_compare ${abs_top_builddir}/src/addr2line -f -e testfile 0x08048468 0x0804845c foo bar foo+0x0 bar+0x0 foo-0x0 bar-0x0
+
+cat > stdin.nl <<\EOF
+0x08048468
+0x0804845c
+foo
+bar
+foo+0x0
+bar+0x0
+foo-0x0
+bar-0x0
+EOF
+
+echo "# Everything from stdin (with newlines)."
+cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
+cmp good.out stdin.nl.out || exit 1
+
+cat > foo.out <<\EOF
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+EOF
+
+echo "# stdin without newline address, just EOF."
+echo -n "0x08048468" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nonl.out || exit 1
+cmp foo.out stdin.nonl.out || exit 1
+
+echo "# stdin without newline symbol, just EOF."
+echo -n "foo" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
+cmp foo.out stdin.nonl.out || exit 1
+
+tempfiles good.addr.out
+
+cat > good.addr.out <<\EOF
+0x08048468
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+0x0804845c
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+0x08048468
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+0x0804845c
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+0x08048468
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+0x0804845c
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+0x08048468
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+0x0804845c
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+EOF
+
+echo "# Everything on the command line with addresses"
+cat good.addr.out | testrun_compare ${abs_top_builddir}/src/addr2line -a -f -e testfile 0x08048468 0x0804845c foo bar foo+0x0 bar+0x0 foo-0x0 bar-0x0
+
+echo "# Everything from stdin (with newlines) with addresses."
+cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -a -f -e testfile > stdin.nl.out || exit 1
+cmp good.addr.out stdin.nl.out || exit 1
+
+echo "# Pretty with functions and addresses."
+testrun_compare ${abs_top_builddir}/src/addr2line --pretty -a -f -e testfile 0x08048468 0x0804845c << EOF
+0x08048468: foo at /home/drepper/gnu/new-bu/build/ttt/f.c:3
+0x0804845c: bar at /home/drepper/gnu/new-bu/build/ttt/b.c:4
+EOF
+
+exit 0
diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh
new file mode 100755
index 0000000..376a6dc
--- /dev/null
+++ b/tests/run-addrcfi.sh
@@ -0,0 +1,3749 @@
+#! /bin/sh
+# Copyright (C) 2013
+# Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
+# 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
+
+# Note some testfiles are also used in run-allregs.sh.
+
+# Shows return address, CFA location expression and register rules
+# from ABI's default CFI program as setup by arch ebl backend hook
+# abi_cfi unless overridden by CIE and FDE program at given address.
+
+# EM_386 (function main 0x080489b8)
+testfiles testfile11
+testrun_compare ${abs_builddir}/addrcfi -e testfile11 0x080489b8 <<\EOF
+.eh_frame has 0x80489b8 => [0x80489b8, 0x80489b9):
+ return address in reg8
+ CFA location expression: bregx(4,4)
+ integer reg0 (%eax): undefined
+ integer reg1 (%ecx): undefined
+ integer reg2 (%edx): undefined
+ integer reg3 (%ebx): same_value
+ integer reg4 (%esp): location expression: call_frame_cfa stack_value
+ integer reg5 (%ebp): same_value
+ integer reg6 (%esi): same_value
+ integer reg7 (%edi): same_value
+ integer reg8 (%eip): location expression: call_frame_cfa plus_uconst(-4)
+ integer reg9 (%eflags): undefined
+ integer reg10 (%trapno): undefined
+ x87 reg11 (%st0): undefined
+ x87 reg12 (%st1): undefined
+ x87 reg13 (%st2): undefined
+ x87 reg14 (%st3): undefined
+ x87 reg15 (%st4): undefined
+ x87 reg16 (%st5): undefined
+ x87 reg17 (%st6): undefined
+ x87 reg18 (%st7): undefined
+ SSE reg21 (%xmm0): undefined
+ SSE reg22 (%xmm1): undefined
+ SSE reg23 (%xmm2): undefined
+ SSE reg24 (%xmm3): undefined
+ SSE reg25 (%xmm4): undefined
+ SSE reg26 (%xmm5): undefined
+ SSE reg27 (%xmm6): undefined
+ SSE reg28 (%xmm7): undefined
+ MMX reg29 (%mm0): undefined
+ MMX reg30 (%mm1): undefined
+ MMX reg31 (%mm2): undefined
+ MMX reg32 (%mm3): undefined
+ MMX reg33 (%mm4): undefined
+ MMX reg34 (%mm5): undefined
+ MMX reg35 (%mm6): undefined
+ MMX reg36 (%mm7): undefined
+ FPU-control reg37 (%fctrl): undefined
+ FPU-control reg38 (%fstat): undefined
+ FPU-control reg39 (%mxcsr): undefined
+ segment reg40 (%es): same_value
+ segment reg41 (%cs): same_value
+ segment reg42 (%ss): same_value
+ segment reg43 (%ds): same_value
+ segment reg44 (%fs): same_value
+ segment reg45 (%gs): same_value
+.debug_frame has 0x80489b8 => [0x80489b8, 0x80489b9):
+ return address in reg8
+ CFA location expression: bregx(4,4)
+ integer reg0 (%eax): undefined
+ integer reg1 (%ecx): undefined
+ integer reg2 (%edx): undefined
+ integer reg3 (%ebx): same_value
+ integer reg4 (%esp): location expression: call_frame_cfa stack_value
+ integer reg5 (%ebp): same_value
+ integer reg6 (%esi): same_value
+ integer reg7 (%edi): same_value
+ integer reg8 (%eip): location expression: call_frame_cfa plus_uconst(-4)
+ integer reg9 (%eflags): undefined
+ integer reg10 (%trapno): undefined
+ x87 reg11 (%st0): undefined
+ x87 reg12 (%st1): undefined
+ x87 reg13 (%st2): undefined
+ x87 reg14 (%st3): undefined
+ x87 reg15 (%st4): undefined
+ x87 reg16 (%st5): undefined
+ x87 reg17 (%st6): undefined
+ x87 reg18 (%st7): undefined
+ SSE reg21 (%xmm0): undefined
+ SSE reg22 (%xmm1): undefined
+ SSE reg23 (%xmm2): undefined
+ SSE reg24 (%xmm3): undefined
+ SSE reg25 (%xmm4): undefined
+ SSE reg26 (%xmm5): undefined
+ SSE reg27 (%xmm6): undefined
+ SSE reg28 (%xmm7): undefined
+ MMX reg29 (%mm0): undefined
+ MMX reg30 (%mm1): undefined
+ MMX reg31 (%mm2): undefined
+ MMX reg32 (%mm3): undefined
+ MMX reg33 (%mm4): undefined
+ MMX reg34 (%mm5): undefined
+ MMX reg35 (%mm6): undefined
+ MMX reg36 (%mm7): undefined
+ FPU-control reg37 (%fctrl): undefined
+ FPU-control reg38 (%fstat): undefined
+ FPU-control reg39 (%mxcsr): undefined
+ segment reg40 (%es): same_value
+ segment reg41 (%cs): same_value
+ segment reg42 (%ss): same_value
+ segment reg43 (%ds): same_value
+ segment reg44 (%fs): same_value
+ segment reg45 (%gs): same_value
+EOF
+
+# EM_X86_64 (function foo 0x00000000000009d0)
+testfiles testfile12
+testrun_compare ${abs_builddir}/addrcfi -e testfile12 0x00000000000009d0 <<\EOF
+.eh_frame has 0x9d0 => [0x9d0, 0x9d1):
+ return address in reg16
+ CFA location expression: bregx(7,8)
+ integer reg0 (%rax): same_value
+ integer reg1 (%rdx): undefined
+ integer reg2 (%rcx): undefined
+ integer reg3 (%rbx): undefined
+ integer reg4 (%rsi): undefined
+ integer reg5 (%rdi): undefined
+ integer reg6 (%rbp): same_value
+ integer reg7 (%rsp): location expression: call_frame_cfa stack_value
+ integer reg8 (%r8): undefined
+ integer reg9 (%r9): undefined
+ integer reg10 (%r10): undefined
+ integer reg11 (%r11): undefined
+ integer reg12 (%r12): same_value
+ integer reg13 (%r13): same_value
+ integer reg14 (%r14): same_value
+ integer reg15 (%r15): same_value
+ integer reg16 (%rip): location expression: call_frame_cfa plus_uconst(-8)
+ SSE reg17 (%xmm0): undefined
+ SSE reg18 (%xmm1): undefined
+ SSE reg19 (%xmm2): undefined
+ SSE reg20 (%xmm3): undefined
+ SSE reg21 (%xmm4): undefined
+ SSE reg22 (%xmm5): undefined
+ SSE reg23 (%xmm6): undefined
+ SSE reg24 (%xmm7): undefined
+ SSE reg25 (%xmm8): undefined
+ SSE reg26 (%xmm9): undefined
+ SSE reg27 (%xmm10): undefined
+ SSE reg28 (%xmm11): undefined
+ SSE reg29 (%xmm12): undefined
+ SSE reg30 (%xmm13): undefined
+ SSE reg31 (%xmm14): undefined
+ SSE reg32 (%xmm15): undefined
+ x87 reg33 (%st0): undefined
+ x87 reg34 (%st1): undefined
+ x87 reg35 (%st2): undefined
+ x87 reg36 (%st3): undefined
+ x87 reg37 (%st4): undefined
+ x87 reg38 (%st5): undefined
+ x87 reg39 (%st6): undefined
+ x87 reg40 (%st7): undefined
+ MMX reg41 (%mm0): undefined
+ MMX reg42 (%mm1): undefined
+ MMX reg43 (%mm2): undefined
+ MMX reg44 (%mm3): undefined
+ MMX reg45 (%mm4): undefined
+ MMX reg46 (%mm5): undefined
+ MMX reg47 (%mm6): undefined
+ MMX reg48 (%mm7): undefined
+ integer reg49 (%rflags): undefined
+ segment reg50 (%es): undefined
+ segment reg51 (%cs): undefined
+ segment reg52 (%ss): undefined
+ segment reg53 (%ds): undefined
+ segment reg54 (%fs): undefined
+ segment reg55 (%gs): undefined
+ segment reg58 (%fs.base): undefined
+ segment reg59 (%gs.base): undefined
+ control reg62 (%tr): undefined
+ control reg63 (%ldtr): undefined
+ control reg64 (%mxcsr): undefined
+ control reg65 (%fcw): undefined
+ control reg66 (%fsw): undefined
+.debug_frame has 0x9d0 => [0x9d0, 0x9d1):
+ return address in reg16
+ CFA location expression: bregx(7,8)
+ integer reg0 (%rax): same_value
+ integer reg1 (%rdx): undefined
+ integer reg2 (%rcx): undefined
+ integer reg3 (%rbx): undefined
+ integer reg4 (%rsi): undefined
+ integer reg5 (%rdi): undefined
+ integer reg6 (%rbp): same_value
+ integer reg7 (%rsp): location expression: call_frame_cfa stack_value
+ integer reg8 (%r8): undefined
+ integer reg9 (%r9): undefined
+ integer reg10 (%r10): undefined
+ integer reg11 (%r11): undefined
+ integer reg12 (%r12): same_value
+ integer reg13 (%r13): same_value
+ integer reg14 (%r14): same_value
+ integer reg15 (%r15): same_value
+ integer reg16 (%rip): location expression: call_frame_cfa plus_uconst(-8)
+ SSE reg17 (%xmm0): undefined
+ SSE reg18 (%xmm1): undefined
+ SSE reg19 (%xmm2): undefined
+ SSE reg20 (%xmm3): undefined
+ SSE reg21 (%xmm4): undefined
+ SSE reg22 (%xmm5): undefined
+ SSE reg23 (%xmm6): undefined
+ SSE reg24 (%xmm7): undefined
+ SSE reg25 (%xmm8): undefined
+ SSE reg26 (%xmm9): undefined
+ SSE reg27 (%xmm10): undefined
+ SSE reg28 (%xmm11): undefined
+ SSE reg29 (%xmm12): undefined
+ SSE reg30 (%xmm13): undefined
+ SSE reg31 (%xmm14): undefined
+ SSE reg32 (%xmm15): undefined
+ x87 reg33 (%st0): undefined
+ x87 reg34 (%st1): undefined
+ x87 reg35 (%st2): undefined
+ x87 reg36 (%st3): undefined
+ x87 reg37 (%st4): undefined
+ x87 reg38 (%st5): undefined
+ x87 reg39 (%st6): undefined
+ x87 reg40 (%st7): undefined
+ MMX reg41 (%mm0): undefined
+ MMX reg42 (%mm1): undefined
+ MMX reg43 (%mm2): undefined
+ MMX reg44 (%mm3): undefined
+ MMX reg45 (%mm4): undefined
+ MMX reg46 (%mm5): undefined
+ MMX reg47 (%mm6): undefined
+ MMX reg48 (%mm7): undefined
+ integer reg49 (%rflags): undefined
+ segment reg50 (%es): undefined
+ segment reg51 (%cs): undefined
+ segment reg52 (%ss): undefined
+ segment reg53 (%ds): undefined
+ segment reg54 (%fs): undefined
+ segment reg55 (%gs): undefined
+ segment reg58 (%fs.base): undefined
+ segment reg59 (%gs.base): undefined
+ control reg62 (%tr): undefined
+ control reg63 (%ldtr): undefined
+ control reg64 (%mxcsr): undefined
+ control reg65 (%fcw): undefined
+ control reg66 (%fsw): undefined
+EOF
+
+# EM_PPC (function bar 0x100004c0)
+# Note. First only in .debug_frame, second only in .eh_frame.
+#
+# = bar.c =
+#
+# static int b1 = 1;
+# int b2 = 1;
+#
+# static int
+# foo (int a)
+# {
+# return a + b2;
+# }
+#
+# int bar (int b)
+# {
+# return b - foo (b - b1);
+# }
+#
+# = foo.c =
+#
+# extern int bar (int b);
+# extern int b2;
+#
+# int
+# main (int argc, char ** argv)
+# {
+# return bar (argc + b2);
+# }
+#
+# gcc -g -O2 -m32 -c foo.c
+# gcc -g -O2 -m32 -c bar.c
+# gcc -g -O2 m32 -o testfileppc32 foo.o bar.o
+testfiles testfileppc32
+testrun_compare ${abs_builddir}/addrcfi -e testfileppc32 0x100004c0 <<\EOF
+dwarf_cfi_addrframe (.eh_frame): no matching address range
+.debug_frame has 0x100004c0 => [0x100004c0, 0x100004d0):
+ return address in reg65
+ CFA location expression: bregx(1)
+ integer reg0 (r0): undefined
+ integer reg1 (r1): location expression: call_frame_cfa stack_value
+ integer reg2 (r2): same_value
+ integer reg3 (r3): undefined
+ integer reg4 (r4): undefined
+ integer reg5 (r5): undefined
+ integer reg6 (r6): undefined
+ integer reg7 (r7): undefined
+ integer reg8 (r8): undefined
+ integer reg9 (r9): undefined
+ integer reg10 (r10): undefined
+ integer reg11 (r11): undefined
+ integer reg12 (r12): undefined
+ integer reg13 (r13): same_value
+ integer reg14 (r14): same_value
+ integer reg15 (r15): same_value
+ integer reg16 (r16): same_value
+ integer reg17 (r17): same_value
+ integer reg18 (r18): same_value
+ integer reg19 (r19): same_value
+ integer reg20 (r20): same_value
+ integer reg21 (r21): same_value
+ integer reg22 (r22): same_value
+ integer reg23 (r23): same_value
+ integer reg24 (r24): same_value
+ integer reg25 (r25): same_value
+ integer reg26 (r26): same_value
+ integer reg27 (r27): same_value
+ integer reg28 (r28): same_value
+ integer reg29 (r29): same_value
+ integer reg30 (r30): same_value
+ integer reg31 (r31): same_value
+ FPU reg32 (f0): undefined
+ FPU reg33 (f1): undefined
+ FPU reg34 (f2): undefined
+ FPU reg35 (f3): undefined
+ FPU reg36 (f4): undefined
+ FPU reg37 (f5): undefined
+ FPU reg38 (f6): undefined
+ FPU reg39 (f7): undefined
+ FPU reg40 (f8): undefined
+ FPU reg41 (f9): undefined
+ FPU reg42 (f10): undefined
+ FPU reg43 (f11): undefined
+ FPU reg44 (f12): undefined
+ FPU reg45 (f13): undefined
+ FPU reg46 (f14): undefined
+ FPU reg47 (f15): undefined
+ FPU reg48 (f16): undefined
+ FPU reg49 (f17): undefined
+ FPU reg50 (f18): undefined
+ FPU reg51 (f19): undefined
+ FPU reg52 (f20): undefined
+ FPU reg53 (f21): undefined
+ FPU reg54 (f22): undefined
+ FPU reg55 (f23): undefined
+ FPU reg56 (f24): undefined
+ FPU reg57 (f25): undefined
+ FPU reg58 (f26): undefined
+ FPU reg59 (f27): undefined
+ FPU reg60 (f28): undefined
+ FPU reg61 (f29): undefined
+ FPU reg62 (f30): undefined
+ FPU reg63 (f31): undefined
+ integer reg64 (cr): undefined
+ FPU reg65 (fpscr): same_value
+ integer reg66 (msr): undefined
+ vector reg67 (vscr): undefined
+ privileged reg70 (sr0): undefined
+ privileged reg71 (sr1): undefined
+ privileged reg72 (sr2): undefined
+ privileged reg73 (sr3): undefined
+ privileged reg74 (sr4): undefined
+ privileged reg75 (sr5): undefined
+ privileged reg76 (sr6): undefined
+ privileged reg77 (sr7): undefined
+ privileged reg78 (sr8): undefined
+ privileged reg79 (sr9): undefined
+ privileged reg80 (sr10): undefined
+ privileged reg81 (sr11): undefined
+ privileged reg82 (sr12): undefined
+ privileged reg83 (sr13): undefined
+ privileged reg84 (sr14): undefined
+ privileged reg85 (sr15): undefined
+ privileged reg100 (mq): undefined
+ privileged reg101 (xer): undefined
+ privileged reg102 (spr2): undefined
+ privileged reg103 (spr3): undefined
+ privileged reg104 (spr4): undefined
+ privileged reg105 (spr5): undefined
+ privileged reg106 (spr6): undefined
+ privileged reg107 (spr7): undefined
+ privileged reg108 (lr): undefined
+ privileged reg109 (ctr): undefined
+ privileged reg110 (spr10): undefined
+ privileged reg111 (spr11): undefined
+ privileged reg112 (spr12): undefined
+ privileged reg113 (spr13): undefined
+ privileged reg114 (tfhar): undefined
+ privileged reg115 (tfiar): undefined
+ privileged reg116 (texasr): undefined
+ privileged reg117 (spr17): undefined
+ privileged reg118 (dsisr): undefined
+ privileged reg119 (dar): undefined
+ privileged reg120 (spr20): undefined
+ privileged reg121 (spr21): undefined
+ privileged reg122 (dec): undefined
+ privileged reg123 (spr23): undefined
+ privileged reg124 (spr24): undefined
+ privileged reg125 (spr25): undefined
+ privileged reg126 (spr26): undefined
+ privileged reg127 (spr27): undefined
+ privileged reg128 (spr28): undefined
+ privileged reg129 (spr29): undefined
+ privileged reg130 (spr30): undefined
+ privileged reg131 (spr31): undefined
+ privileged reg132 (spr32): undefined
+ privileged reg133 (spr33): undefined
+ privileged reg134 (spr34): undefined
+ privileged reg135 (spr35): undefined
+ privileged reg136 (spr36): undefined
+ privileged reg137 (spr37): undefined
+ privileged reg138 (spr38): undefined
+ privileged reg139 (spr39): undefined
+ privileged reg140 (spr40): undefined
+ privileged reg141 (spr41): undefined
+ privileged reg142 (spr42): undefined
+ privileged reg143 (spr43): undefined
+ privileged reg144 (spr44): undefined
+ privileged reg145 (spr45): undefined
+ privileged reg146 (spr46): undefined
+ privileged reg147 (spr47): undefined
+ privileged reg148 (spr48): undefined
+ privileged reg149 (spr49): undefined
+ privileged reg150 (spr50): undefined
+ privileged reg151 (spr51): undefined
+ privileged reg152 (spr52): undefined
+ privileged reg153 (spr53): undefined
+ privileged reg154 (spr54): undefined
+ privileged reg155 (spr55): undefined
+ privileged reg156 (spr56): undefined
+ privileged reg157 (spr57): undefined
+ privileged reg158 (spr58): undefined
+ privileged reg159 (spr59): undefined
+ privileged reg160 (spr60): undefined
+ privileged reg161 (spr61): undefined
+ privileged reg162 (spr62): undefined
+ privileged reg163 (spr63): undefined
+ privileged reg164 (spr64): undefined
+ privileged reg165 (spr65): undefined
+ privileged reg166 (spr66): undefined
+ privileged reg167 (spr67): undefined
+ privileged reg168 (spr68): undefined
+ privileged reg169 (spr69): undefined
+ privileged reg170 (spr70): undefined
+ privileged reg171 (spr71): undefined
+ privileged reg172 (spr72): undefined
+ privileged reg173 (spr73): undefined
+ privileged reg174 (spr74): undefined
+ privileged reg175 (spr75): undefined
+ privileged reg176 (spr76): undefined
+ privileged reg177 (spr77): undefined
+ privileged reg178 (spr78): undefined
+ privileged reg179 (spr79): undefined
+ privileged reg180 (spr80): undefined
+ privileged reg181 (spr81): undefined
+ privileged reg182 (spr82): undefined
+ privileged reg183 (spr83): undefined
+ privileged reg184 (spr84): undefined
+ privileged reg185 (spr85): undefined
+ privileged reg186 (spr86): undefined
+ privileged reg187 (spr87): undefined
+ privileged reg188 (spr88): undefined
+ privileged reg189 (spr89): undefined
+ privileged reg190 (spr90): undefined
+ privileged reg191 (spr91): undefined
+ privileged reg192 (spr92): undefined
+ privileged reg193 (spr93): undefined
+ privileged reg194 (spr94): undefined
+ privileged reg195 (spr95): undefined
+ privileged reg196 (spr96): undefined
+ privileged reg197 (spr97): undefined
+ privileged reg198 (spr98): undefined
+ privileged reg199 (spr99): undefined
+ privileged reg200 (spr100): undefined
+ privileged reg201 (spr101): undefined
+ privileged reg202 (spr102): undefined
+ privileged reg203 (spr103): undefined
+ privileged reg204 (spr104): undefined
+ privileged reg205 (spr105): undefined
+ privileged reg206 (spr106): undefined
+ privileged reg207 (spr107): undefined
+ privileged reg208 (spr108): undefined
+ privileged reg209 (spr109): undefined
+ privileged reg210 (spr110): undefined
+ privileged reg211 (spr111): undefined
+ privileged reg212 (spr112): undefined
+ privileged reg213 (spr113): undefined
+ privileged reg214 (spr114): undefined
+ privileged reg215 (spr115): undefined
+ privileged reg216 (spr116): undefined
+ privileged reg217 (spr117): undefined
+ privileged reg218 (spr118): undefined
+ privileged reg219 (spr119): undefined
+ privileged reg220 (spr120): undefined
+ privileged reg221 (spr121): undefined
+ privileged reg222 (spr122): undefined
+ privileged reg223 (spr123): undefined
+ privileged reg224 (spr124): undefined
+ privileged reg225 (spr125): undefined
+ privileged reg226 (spr126): undefined
+ privileged reg227 (spr127): undefined
+ privileged reg228 (spr128): undefined
+ privileged reg229 (spr129): undefined
+ privileged reg230 (spr130): undefined
+ privileged reg231 (spr131): undefined
+ privileged reg232 (spr132): undefined
+ privileged reg233 (spr133): undefined
+ privileged reg234 (spr134): undefined
+ privileged reg235 (spr135): undefined
+ privileged reg236 (spr136): undefined
+ privileged reg237 (spr137): undefined
+ privileged reg238 (spr138): undefined
+ privileged reg239 (spr139): undefined
+ privileged reg240 (spr140): undefined
+ privileged reg241 (spr141): undefined
+ privileged reg242 (spr142): undefined
+ privileged reg243 (spr143): undefined
+ privileged reg244 (spr144): undefined
+ privileged reg245 (spr145): undefined
+ privileged reg246 (spr146): undefined
+ privileged reg247 (spr147): undefined
+ privileged reg248 (spr148): undefined
+ privileged reg249 (spr149): undefined
+ privileged reg250 (spr150): undefined
+ privileged reg251 (spr151): undefined
+ privileged reg252 (spr152): undefined
+ privileged reg253 (spr153): undefined
+ privileged reg254 (spr154): undefined
+ privileged reg255 (spr155): undefined
+ privileged reg256 (spr156): undefined
+ privileged reg257 (spr157): undefined
+ privileged reg258 (spr158): undefined
+ privileged reg259 (spr159): undefined
+ privileged reg260 (spr160): undefined
+ privileged reg261 (spr161): undefined
+ privileged reg262 (spr162): undefined
+ privileged reg263 (spr163): undefined
+ privileged reg264 (spr164): undefined
+ privileged reg265 (spr165): undefined
+ privileged reg266 (spr166): undefined
+ privileged reg267 (spr167): undefined
+ privileged reg268 (spr168): undefined
+ privileged reg269 (spr169): undefined
+ privileged reg270 (spr170): undefined
+ privileged reg271 (spr171): undefined
+ privileged reg272 (spr172): undefined
+ privileged reg273 (spr173): undefined
+ privileged reg274 (spr174): undefined
+ privileged reg275 (spr175): undefined
+ privileged reg276 (spr176): undefined
+ privileged reg277 (spr177): undefined
+ privileged reg278 (spr178): undefined
+ privileged reg279 (spr179): undefined
+ privileged reg280 (spr180): undefined
+ privileged reg281 (spr181): undefined
+ privileged reg282 (spr182): undefined
+ privileged reg283 (spr183): undefined
+ privileged reg284 (spr184): undefined
+ privileged reg285 (spr185): undefined
+ privileged reg286 (spr186): undefined
+ privileged reg287 (spr187): undefined
+ privileged reg288 (spr188): undefined
+ privileged reg289 (spr189): undefined
+ privileged reg290 (spr190): undefined
+ privileged reg291 (spr191): undefined
+ privileged reg292 (spr192): undefined
+ privileged reg293 (spr193): undefined
+ privileged reg294 (spr194): undefined
+ privileged reg295 (spr195): undefined
+ privileged reg296 (spr196): undefined
+ privileged reg297 (spr197): undefined
+ privileged reg298 (spr198): undefined
+ privileged reg299 (spr199): undefined
+ privileged reg300 (spr200): undefined
+ privileged reg301 (spr201): undefined
+ privileged reg302 (spr202): undefined
+ privileged reg303 (spr203): undefined
+ privileged reg304 (spr204): undefined
+ privileged reg305 (spr205): undefined
+ privileged reg306 (spr206): undefined
+ privileged reg307 (spr207): undefined
+ privileged reg308 (spr208): undefined
+ privileged reg309 (spr209): undefined
+ privileged reg310 (spr210): undefined
+ privileged reg311 (spr211): undefined
+ privileged reg312 (spr212): undefined
+ privileged reg313 (spr213): undefined
+ privileged reg314 (spr214): undefined
+ privileged reg315 (spr215): undefined
+ privileged reg316 (spr216): undefined
+ privileged reg317 (spr217): undefined
+ privileged reg318 (spr218): undefined
+ privileged reg319 (spr219): undefined
+ privileged reg320 (spr220): undefined
+ privileged reg321 (spr221): undefined
+ privileged reg322 (spr222): undefined
+ privileged reg323 (spr223): undefined
+ privileged reg324 (spr224): undefined
+ privileged reg325 (spr225): undefined
+ privileged reg326 (spr226): undefined
+ privileged reg327 (spr227): undefined
+ privileged reg328 (spr228): undefined
+ privileged reg329 (spr229): undefined
+ privileged reg330 (spr230): undefined
+ privileged reg331 (spr231): undefined
+ privileged reg332 (spr232): undefined
+ privileged reg333 (spr233): undefined
+ privileged reg334 (spr234): undefined
+ privileged reg335 (spr235): undefined
+ privileged reg336 (spr236): undefined
+ privileged reg337 (spr237): undefined
+ privileged reg338 (spr238): undefined
+ privileged reg339 (spr239): undefined
+ privileged reg340 (spr240): undefined
+ privileged reg341 (spr241): undefined
+ privileged reg342 (spr242): undefined
+ privileged reg343 (spr243): undefined
+ privileged reg344 (spr244): undefined
+ privileged reg345 (spr245): undefined
+ privileged reg346 (spr246): undefined
+ privileged reg347 (spr247): undefined
+ privileged reg348 (spr248): undefined
+ privileged reg349 (spr249): undefined
+ privileged reg350 (spr250): undefined
+ privileged reg351 (spr251): undefined
+ privileged reg352 (spr252): undefined
+ privileged reg353 (spr253): undefined
+ privileged reg354 (spr254): undefined
+ privileged reg355 (spr255): undefined
+ vector reg356 (vrsave): undefined
+ privileged reg357 (spr257): undefined
+ privileged reg358 (spr258): undefined
+ privileged reg359 (spr259): undefined
+ privileged reg360 (spr260): undefined
+ privileged reg361 (spr261): undefined
+ privileged reg362 (spr262): undefined
+ privileged reg363 (spr263): undefined
+ privileged reg364 (spr264): undefined
+ privileged reg365 (spr265): undefined
+ privileged reg366 (spr266): undefined
+ privileged reg367 (spr267): undefined
+ privileged reg368 (spr268): undefined
+ privileged reg369 (spr269): undefined
+ privileged reg370 (spr270): undefined
+ privileged reg371 (spr271): undefined
+ privileged reg372 (spr272): undefined
+ privileged reg373 (spr273): undefined
+ privileged reg374 (spr274): undefined
+ privileged reg375 (spr275): undefined
+ privileged reg376 (spr276): undefined
+ privileged reg377 (spr277): undefined
+ privileged reg378 (spr278): undefined
+ privileged reg379 (spr279): undefined
+ privileged reg380 (spr280): undefined
+ privileged reg381 (spr281): undefined
+ privileged reg382 (spr282): undefined
+ privileged reg383 (spr283): undefined
+ privileged reg384 (spr284): undefined
+ privileged reg385 (spr285): undefined
+ privileged reg386 (spr286): undefined
+ privileged reg387 (spr287): undefined
+ privileged reg388 (spr288): undefined
+ privileged reg389 (spr289): undefined
+ privileged reg390 (spr290): undefined
+ privileged reg391 (spr291): undefined
+ privileged reg392 (spr292): undefined
+ privileged reg393 (spr293): undefined
+ privileged reg394 (spr294): undefined
+ privileged reg395 (spr295): undefined
+ privileged reg396 (spr296): undefined
+ privileged reg397 (spr297): undefined
+ privileged reg398 (spr298): undefined
+ privileged reg399 (spr299): undefined
+ privileged reg400 (spr300): undefined
+ privileged reg401 (spr301): undefined
+ privileged reg402 (spr302): undefined
+ privileged reg403 (spr303): undefined
+ privileged reg404 (spr304): undefined
+ privileged reg405 (spr305): undefined
+ privileged reg406 (spr306): undefined
+ privileged reg407 (spr307): undefined
+ privileged reg408 (spr308): undefined
+ privileged reg409 (spr309): undefined
+ privileged reg410 (spr310): undefined
+ privileged reg411 (spr311): undefined
+ privileged reg412 (spr312): undefined
+ privileged reg413 (spr313): undefined
+ privileged reg414 (spr314): undefined
+ privileged reg415 (spr315): undefined
+ privileged reg416 (spr316): undefined
+ privileged reg417 (spr317): undefined
+ privileged reg418 (spr318): undefined
+ privileged reg419 (spr319): undefined
+ privileged reg420 (spr320): undefined
+ privileged reg421 (spr321): undefined
+ privileged reg422 (spr322): undefined
+ privileged reg423 (spr323): undefined
+ privileged reg424 (spr324): undefined
+ privileged reg425 (spr325): undefined
+ privileged reg426 (spr326): undefined
+ privileged reg427 (spr327): undefined
+ privileged reg428 (spr328): undefined
+ privileged reg429 (spr329): undefined
+ privileged reg430 (spr330): undefined
+ privileged reg431 (spr331): undefined
+ privileged reg432 (spr332): undefined
+ privileged reg433 (spr333): undefined
+ privileged reg434 (spr334): undefined
+ privileged reg435 (spr335): undefined
+ privileged reg436 (spr336): undefined
+ privileged reg437 (spr337): undefined
+ privileged reg438 (spr338): undefined
+ privileged reg439 (spr339): undefined
+ privileged reg440 (spr340): undefined
+ privileged reg441 (spr341): undefined
+ privileged reg442 (spr342): undefined
+ privileged reg443 (spr343): undefined
+ privileged reg444 (spr344): undefined
+ privileged reg445 (spr345): undefined
+ privileged reg446 (spr346): undefined
+ privileged reg447 (spr347): undefined
+ privileged reg448 (spr348): undefined
+ privileged reg449 (spr349): undefined
+ privileged reg450 (spr350): undefined
+ privileged reg451 (spr351): undefined
+ privileged reg452 (spr352): undefined
+ privileged reg453 (spr353): undefined
+ privileged reg454 (spr354): undefined
+ privileged reg455 (spr355): undefined
+ privileged reg456 (spr356): undefined
+ privileged reg457 (spr357): undefined
+ privileged reg458 (spr358): undefined
+ privileged reg459 (spr359): undefined
+ privileged reg460 (spr360): undefined
+ privileged reg461 (spr361): undefined
+ privileged reg462 (spr362): undefined
+ privileged reg463 (spr363): undefined
+ privileged reg464 (spr364): undefined
+ privileged reg465 (spr365): undefined
+ privileged reg466 (spr366): undefined
+ privileged reg467 (spr367): undefined
+ privileged reg468 (spr368): undefined
+ privileged reg469 (spr369): undefined
+ privileged reg470 (spr370): undefined
+ privileged reg471 (spr371): undefined
+ privileged reg472 (spr372): undefined
+ privileged reg473 (spr373): undefined
+ privileged reg474 (spr374): undefined
+ privileged reg475 (spr375): undefined
+ privileged reg476 (spr376): undefined
+ privileged reg477 (spr377): undefined
+ privileged reg478 (spr378): undefined
+ privileged reg479 (spr379): undefined
+ privileged reg480 (spr380): undefined
+ privileged reg481 (spr381): undefined
+ privileged reg482 (spr382): undefined
+ privileged reg483 (spr383): undefined
+ privileged reg484 (spr384): undefined
+ privileged reg485 (spr385): undefined
+ privileged reg486 (spr386): undefined
+ privileged reg487 (spr387): undefined
+ privileged reg488 (spr388): undefined
+ privileged reg489 (spr389): undefined
+ privileged reg490 (spr390): undefined
+ privileged reg491 (spr391): undefined
+ privileged reg492 (spr392): undefined
+ privileged reg493 (spr393): undefined
+ privileged reg494 (spr394): undefined
+ privileged reg495 (spr395): undefined
+ privileged reg496 (spr396): undefined
+ privileged reg497 (spr397): undefined
+ privileged reg498 (spr398): undefined
+ privileged reg499 (spr399): undefined
+ privileged reg500 (spr400): undefined
+ privileged reg501 (spr401): undefined
+ privileged reg502 (spr402): undefined
+ privileged reg503 (spr403): undefined
+ privileged reg504 (spr404): undefined
+ privileged reg505 (spr405): undefined
+ privileged reg506 (spr406): undefined
+ privileged reg507 (spr407): undefined
+ privileged reg508 (spr408): undefined
+ privileged reg509 (spr409): undefined
+ privileged reg510 (spr410): undefined
+ privileged reg511 (spr411): undefined
+ privileged reg512 (spr412): undefined
+ privileged reg513 (spr413): undefined
+ privileged reg514 (spr414): undefined
+ privileged reg515 (spr415): undefined
+ privileged reg516 (spr416): undefined
+ privileged reg517 (spr417): undefined
+ privileged reg518 (spr418): undefined
+ privileged reg519 (spr419): undefined
+ privileged reg520 (spr420): undefined
+ privileged reg521 (spr421): undefined
+ privileged reg522 (spr422): undefined
+ privileged reg523 (spr423): undefined
+ privileged reg524 (spr424): undefined
+ privileged reg525 (spr425): undefined
+ privileged reg526 (spr426): undefined
+ privileged reg527 (spr427): undefined
+ privileged reg528 (spr428): undefined
+ privileged reg529 (spr429): undefined
+ privileged reg530 (spr430): undefined
+ privileged reg531 (spr431): undefined
+ privileged reg532 (spr432): undefined
+ privileged reg533 (spr433): undefined
+ privileged reg534 (spr434): undefined
+ privileged reg535 (spr435): undefined
+ privileged reg536 (spr436): undefined
+ privileged reg537 (spr437): undefined
+ privileged reg538 (spr438): undefined
+ privileged reg539 (spr439): undefined
+ privileged reg540 (spr440): undefined
+ privileged reg541 (spr441): undefined
+ privileged reg542 (spr442): undefined
+ privileged reg543 (spr443): undefined
+ privileged reg544 (spr444): undefined
+ privileged reg545 (spr445): undefined
+ privileged reg546 (spr446): undefined
+ privileged reg547 (spr447): undefined
+ privileged reg548 (spr448): undefined
+ privileged reg549 (spr449): undefined
+ privileged reg550 (spr450): undefined
+ privileged reg551 (spr451): undefined
+ privileged reg552 (spr452): undefined
+ privileged reg553 (spr453): undefined
+ privileged reg554 (spr454): undefined
+ privileged reg555 (spr455): undefined
+ privileged reg556 (spr456): undefined
+ privileged reg557 (spr457): undefined
+ privileged reg558 (spr458): undefined
+ privileged reg559 (spr459): undefined
+ privileged reg560 (spr460): undefined
+ privileged reg561 (spr461): undefined
+ privileged reg562 (spr462): undefined
+ privileged reg563 (spr463): undefined
+ privileged reg564 (spr464): undefined
+ privileged reg565 (spr465): undefined
+ privileged reg566 (spr466): undefined
+ privileged reg567 (spr467): undefined
+ privileged reg568 (spr468): undefined
+ privileged reg569 (spr469): undefined
+ privileged reg570 (spr470): undefined
+ privileged reg571 (spr471): undefined
+ privileged reg572 (spr472): undefined
+ privileged reg573 (spr473): undefined
+ privileged reg574 (spr474): undefined
+ privileged reg575 (spr475): undefined
+ privileged reg576 (spr476): undefined
+ privileged reg577 (spr477): undefined
+ privileged reg578 (spr478): undefined
+ privileged reg579 (spr479): undefined
+ privileged reg580 (spr480): undefined
+ privileged reg581 (spr481): undefined
+ privileged reg582 (spr482): undefined
+ privileged reg583 (spr483): undefined
+ privileged reg584 (spr484): undefined
+ privileged reg585 (spr485): undefined
+ privileged reg586 (spr486): undefined
+ privileged reg587 (spr487): undefined
+ privileged reg588 (spr488): undefined
+ privileged reg589 (spr489): undefined
+ privileged reg590 (spr490): undefined
+ privileged reg591 (spr491): undefined
+ privileged reg592 (spr492): undefined
+ privileged reg593 (spr493): undefined
+ privileged reg594 (spr494): undefined
+ privileged reg595 (spr495): undefined
+ privileged reg596 (spr496): undefined
+ privileged reg597 (spr497): undefined
+ privileged reg598 (spr498): undefined
+ privileged reg599 (spr499): undefined
+ privileged reg600 (spr500): undefined
+ privileged reg601 (spr501): undefined
+ privileged reg602 (spr502): undefined
+ privileged reg603 (spr503): undefined
+ privileged reg604 (spr504): undefined
+ privileged reg605 (spr505): undefined
+ privileged reg606 (spr506): undefined
+ privileged reg607 (spr507): undefined
+ privileged reg608 (spr508): undefined
+ privileged reg609 (spr509): undefined
+ privileged reg610 (spr510): undefined
+ privileged reg611 (spr511): undefined
+ vector reg612 (spefscr): undefined
+ privileged reg613 (spr513): undefined
+ privileged reg614 (spr514): undefined
+ privileged reg615 (spr515): undefined
+ privileged reg616 (spr516): undefined
+ privileged reg617 (spr517): undefined
+ privileged reg618 (spr518): undefined
+ privileged reg619 (spr519): undefined
+ privileged reg620 (spr520): undefined
+ privileged reg621 (spr521): undefined
+ privileged reg622 (spr522): undefined
+ privileged reg623 (spr523): undefined
+ privileged reg624 (spr524): undefined
+ privileged reg625 (spr525): undefined
+ privileged reg626 (spr526): undefined
+ privileged reg627 (spr527): undefined
+ privileged reg628 (spr528): undefined
+ privileged reg629 (spr529): undefined
+ privileged reg630 (spr530): undefined
+ privileged reg631 (spr531): undefined
+ privileged reg632 (spr532): undefined
+ privileged reg633 (spr533): undefined
+ privileged reg634 (spr534): undefined
+ privileged reg635 (spr535): undefined
+ privileged reg636 (spr536): undefined
+ privileged reg637 (spr537): undefined
+ privileged reg638 (spr538): undefined
+ privileged reg639 (spr539): undefined
+ privileged reg640 (spr540): undefined
+ privileged reg641 (spr541): undefined
+ privileged reg642 (spr542): undefined
+ privileged reg643 (spr543): undefined
+ privileged reg644 (spr544): undefined
+ privileged reg645 (spr545): undefined
+ privileged reg646 (spr546): undefined
+ privileged reg647 (spr547): undefined
+ privileged reg648 (spr548): undefined
+ privileged reg649 (spr549): undefined
+ privileged reg650 (spr550): undefined
+ privileged reg651 (spr551): undefined
+ privileged reg652 (spr552): undefined
+ privileged reg653 (spr553): undefined
+ privileged reg654 (spr554): undefined
+ privileged reg655 (spr555): undefined
+ privileged reg656 (spr556): undefined
+ privileged reg657 (spr557): undefined
+ privileged reg658 (spr558): undefined
+ privileged reg659 (spr559): undefined
+ privileged reg660 (spr560): undefined
+ privileged reg661 (spr561): undefined
+ privileged reg662 (spr562): undefined
+ privileged reg663 (spr563): undefined
+ privileged reg664 (spr564): undefined
+ privileged reg665 (spr565): undefined
+ privileged reg666 (spr566): undefined
+ privileged reg667 (spr567): undefined
+ privileged reg668 (spr568): undefined
+ privileged reg669 (spr569): undefined
+ privileged reg670 (spr570): undefined
+ privileged reg671 (spr571): undefined
+ privileged reg672 (spr572): undefined
+ privileged reg673 (spr573): undefined
+ privileged reg674 (spr574): undefined
+ privileged reg675 (spr575): undefined
+ privileged reg676 (spr576): undefined
+ privileged reg677 (spr577): undefined
+ privileged reg678 (spr578): undefined
+ privileged reg679 (spr579): undefined
+ privileged reg680 (spr580): undefined
+ privileged reg681 (spr581): undefined
+ privileged reg682 (spr582): undefined
+ privileged reg683 (spr583): undefined
+ privileged reg684 (spr584): undefined
+ privileged reg685 (spr585): undefined
+ privileged reg686 (spr586): undefined
+ privileged reg687 (spr587): undefined
+ privileged reg688 (spr588): undefined
+ privileged reg689 (spr589): undefined
+ privileged reg690 (spr590): undefined
+ privileged reg691 (spr591): undefined
+ privileged reg692 (spr592): undefined
+ privileged reg693 (spr593): undefined
+ privileged reg694 (spr594): undefined
+ privileged reg695 (spr595): undefined
+ privileged reg696 (spr596): undefined
+ privileged reg697 (spr597): undefined
+ privileged reg698 (spr598): undefined
+ privileged reg699 (spr599): undefined
+ privileged reg700 (spr600): undefined
+ privileged reg701 (spr601): undefined
+ privileged reg702 (spr602): undefined
+ privileged reg703 (spr603): undefined
+ privileged reg704 (spr604): undefined
+ privileged reg705 (spr605): undefined
+ privileged reg706 (spr606): undefined
+ privileged reg707 (spr607): undefined
+ privileged reg708 (spr608): undefined
+ privileged reg709 (spr609): undefined
+ privileged reg710 (spr610): undefined
+ privileged reg711 (spr611): undefined
+ privileged reg712 (spr612): undefined
+ privileged reg713 (spr613): undefined
+ privileged reg714 (spr614): undefined
+ privileged reg715 (spr615): undefined
+ privileged reg716 (spr616): undefined
+ privileged reg717 (spr617): undefined
+ privileged reg718 (spr618): undefined
+ privileged reg719 (spr619): undefined
+ privileged reg720 (spr620): undefined
+ privileged reg721 (spr621): undefined
+ privileged reg722 (spr622): undefined
+ privileged reg723 (spr623): undefined
+ privileged reg724 (spr624): undefined
+ privileged reg725 (spr625): undefined
+ privileged reg726 (spr626): undefined
+ privileged reg727 (spr627): undefined
+ privileged reg728 (spr628): undefined
+ privileged reg729 (spr629): undefined
+ privileged reg730 (spr630): undefined
+ privileged reg731 (spr631): undefined
+ privileged reg732 (spr632): undefined
+ privileged reg733 (spr633): undefined
+ privileged reg734 (spr634): undefined
+ privileged reg735 (spr635): undefined
+ privileged reg736 (spr636): undefined
+ privileged reg737 (spr637): undefined
+ privileged reg738 (spr638): undefined
+ privileged reg739 (spr639): undefined
+ privileged reg740 (spr640): undefined
+ privileged reg741 (spr641): undefined
+ privileged reg742 (spr642): undefined
+ privileged reg743 (spr643): undefined
+ privileged reg744 (spr644): undefined
+ privileged reg745 (spr645): undefined
+ privileged reg746 (spr646): undefined
+ privileged reg747 (spr647): undefined
+ privileged reg748 (spr648): undefined
+ privileged reg749 (spr649): undefined
+ privileged reg750 (spr650): undefined
+ privileged reg751 (spr651): undefined
+ privileged reg752 (spr652): undefined
+ privileged reg753 (spr653): undefined
+ privileged reg754 (spr654): undefined
+ privileged reg755 (spr655): undefined
+ privileged reg756 (spr656): undefined
+ privileged reg757 (spr657): undefined
+ privileged reg758 (spr658): undefined
+ privileged reg759 (spr659): undefined
+ privileged reg760 (spr660): undefined
+ privileged reg761 (spr661): undefined
+ privileged reg762 (spr662): undefined
+ privileged reg763 (spr663): undefined
+ privileged reg764 (spr664): undefined
+ privileged reg765 (spr665): undefined
+ privileged reg766 (spr666): undefined
+ privileged reg767 (spr667): undefined
+ privileged reg768 (spr668): undefined
+ privileged reg769 (spr669): undefined
+ privileged reg770 (spr670): undefined
+ privileged reg771 (spr671): undefined
+ privileged reg772 (spr672): undefined
+ privileged reg773 (spr673): undefined
+ privileged reg774 (spr674): undefined
+ privileged reg775 (spr675): undefined
+ privileged reg776 (spr676): undefined
+ privileged reg777 (spr677): undefined
+ privileged reg778 (spr678): undefined
+ privileged reg779 (spr679): undefined
+ privileged reg780 (spr680): undefined
+ privileged reg781 (spr681): undefined
+ privileged reg782 (spr682): undefined
+ privileged reg783 (spr683): undefined
+ privileged reg784 (spr684): undefined
+ privileged reg785 (spr685): undefined
+ privileged reg786 (spr686): undefined
+ privileged reg787 (spr687): undefined
+ privileged reg788 (spr688): undefined
+ privileged reg789 (spr689): undefined
+ privileged reg790 (spr690): undefined
+ privileged reg791 (spr691): undefined
+ privileged reg792 (spr692): undefined
+ privileged reg793 (spr693): undefined
+ privileged reg794 (spr694): undefined
+ privileged reg795 (spr695): undefined
+ privileged reg796 (spr696): undefined
+ privileged reg797 (spr697): undefined
+ privileged reg798 (spr698): undefined
+ privileged reg799 (spr699): undefined
+ privileged reg800 (spr700): undefined
+ privileged reg801 (spr701): undefined
+ privileged reg802 (spr702): undefined
+ privileged reg803 (spr703): undefined
+ privileged reg804 (spr704): undefined
+ privileged reg805 (spr705): undefined
+ privileged reg806 (spr706): undefined
+ privileged reg807 (spr707): undefined
+ privileged reg808 (spr708): undefined
+ privileged reg809 (spr709): undefined
+ privileged reg810 (spr710): undefined
+ privileged reg811 (spr711): undefined
+ privileged reg812 (spr712): undefined
+ privileged reg813 (spr713): undefined
+ privileged reg814 (spr714): undefined
+ privileged reg815 (spr715): undefined
+ privileged reg816 (spr716): undefined
+ privileged reg817 (spr717): undefined
+ privileged reg818 (spr718): undefined
+ privileged reg819 (spr719): undefined
+ privileged reg820 (spr720): undefined
+ privileged reg821 (spr721): undefined
+ privileged reg822 (spr722): undefined
+ privileged reg823 (spr723): undefined
+ privileged reg824 (spr724): undefined
+ privileged reg825 (spr725): undefined
+ privileged reg826 (spr726): undefined
+ privileged reg827 (spr727): undefined
+ privileged reg828 (spr728): undefined
+ privileged reg829 (spr729): undefined
+ privileged reg830 (spr730): undefined
+ privileged reg831 (spr731): undefined
+ privileged reg832 (spr732): undefined
+ privileged reg833 (spr733): undefined
+ privileged reg834 (spr734): undefined
+ privileged reg835 (spr735): undefined
+ privileged reg836 (spr736): undefined
+ privileged reg837 (spr737): undefined
+ privileged reg838 (spr738): undefined
+ privileged reg839 (spr739): undefined
+ privileged reg840 (spr740): undefined
+ privileged reg841 (spr741): undefined
+ privileged reg842 (spr742): undefined
+ privileged reg843 (spr743): undefined
+ privileged reg844 (spr744): undefined
+ privileged reg845 (spr745): undefined
+ privileged reg846 (spr746): undefined
+ privileged reg847 (spr747): undefined
+ privileged reg848 (spr748): undefined
+ privileged reg849 (spr749): undefined
+ privileged reg850 (spr750): undefined
+ privileged reg851 (spr751): undefined
+ privileged reg852 (spr752): undefined
+ privileged reg853 (spr753): undefined
+ privileged reg854 (spr754): undefined
+ privileged reg855 (spr755): undefined
+ privileged reg856 (spr756): undefined
+ privileged reg857 (spr757): undefined
+ privileged reg858 (spr758): undefined
+ privileged reg859 (spr759): undefined
+ privileged reg860 (spr760): undefined
+ privileged reg861 (spr761): undefined
+ privileged reg862 (spr762): undefined
+ privileged reg863 (spr763): undefined
+ privileged reg864 (spr764): undefined
+ privileged reg865 (spr765): undefined
+ privileged reg866 (spr766): undefined
+ privileged reg867 (spr767): undefined
+ privileged reg868 (spr768): undefined
+ privileged reg869 (spr769): undefined
+ privileged reg870 (spr770): undefined
+ privileged reg871 (spr771): undefined
+ privileged reg872 (spr772): undefined
+ privileged reg873 (spr773): undefined
+ privileged reg874 (spr774): undefined
+ privileged reg875 (spr775): undefined
+ privileged reg876 (spr776): undefined
+ privileged reg877 (spr777): undefined
+ privileged reg878 (spr778): undefined
+ privileged reg879 (spr779): undefined
+ privileged reg880 (spr780): undefined
+ privileged reg881 (spr781): undefined
+ privileged reg882 (spr782): undefined
+ privileged reg883 (spr783): undefined
+ privileged reg884 (spr784): undefined
+ privileged reg885 (spr785): undefined
+ privileged reg886 (spr786): undefined
+ privileged reg887 (spr787): undefined
+ privileged reg888 (spr788): undefined
+ privileged reg889 (spr789): undefined
+ privileged reg890 (spr790): undefined
+ privileged reg891 (spr791): undefined
+ privileged reg892 (spr792): undefined
+ privileged reg893 (spr793): undefined
+ privileged reg894 (spr794): undefined
+ privileged reg895 (spr795): undefined
+ privileged reg896 (spr796): undefined
+ privileged reg897 (spr797): undefined
+ privileged reg898 (spr798): undefined
+ privileged reg899 (spr799): undefined
+ privileged reg900 (spr800): undefined
+ privileged reg901 (spr801): undefined
+ privileged reg902 (spr802): undefined
+ privileged reg903 (spr803): undefined
+ privileged reg904 (spr804): undefined
+ privileged reg905 (spr805): undefined
+ privileged reg906 (spr806): undefined
+ privileged reg907 (spr807): undefined
+ privileged reg908 (spr808): undefined
+ privileged reg909 (spr809): undefined
+ privileged reg910 (spr810): undefined
+ privileged reg911 (spr811): undefined
+ privileged reg912 (spr812): undefined
+ privileged reg913 (spr813): undefined
+ privileged reg914 (spr814): undefined
+ privileged reg915 (spr815): undefined
+ privileged reg916 (spr816): undefined
+ privileged reg917 (spr817): undefined
+ privileged reg918 (spr818): undefined
+ privileged reg919 (spr819): undefined
+ privileged reg920 (spr820): undefined
+ privileged reg921 (spr821): undefined
+ privileged reg922 (spr822): undefined
+ privileged reg923 (spr823): undefined
+ privileged reg924 (spr824): undefined
+ privileged reg925 (spr825): undefined
+ privileged reg926 (spr826): undefined
+ privileged reg927 (spr827): undefined
+ privileged reg928 (spr828): undefined
+ privileged reg929 (spr829): undefined
+ privileged reg930 (spr830): undefined
+ privileged reg931 (spr831): undefined
+ privileged reg932 (spr832): undefined
+ privileged reg933 (spr833): undefined
+ privileged reg934 (spr834): undefined
+ privileged reg935 (spr835): undefined
+ privileged reg936 (spr836): undefined
+ privileged reg937 (spr837): undefined
+ privileged reg938 (spr838): undefined
+ privileged reg939 (spr839): undefined
+ privileged reg940 (spr840): undefined
+ privileged reg941 (spr841): undefined
+ privileged reg942 (spr842): undefined
+ privileged reg943 (spr843): undefined
+ privileged reg944 (spr844): undefined
+ privileged reg945 (spr845): undefined
+ privileged reg946 (spr846): undefined
+ privileged reg947 (spr847): undefined
+ privileged reg948 (spr848): undefined
+ privileged reg949 (spr849): undefined
+ privileged reg950 (spr850): undefined
+ privileged reg951 (spr851): undefined
+ privileged reg952 (spr852): undefined
+ privileged reg953 (spr853): undefined
+ privileged reg954 (spr854): undefined
+ privileged reg955 (spr855): undefined
+ privileged reg956 (spr856): undefined
+ privileged reg957 (spr857): undefined
+ privileged reg958 (spr858): undefined
+ privileged reg959 (spr859): undefined
+ privileged reg960 (spr860): undefined
+ privileged reg961 (spr861): undefined
+ privileged reg962 (spr862): undefined
+ privileged reg963 (spr863): undefined
+ privileged reg964 (spr864): undefined
+ privileged reg965 (spr865): undefined
+ privileged reg966 (spr866): undefined
+ privileged reg967 (spr867): undefined
+ privileged reg968 (spr868): undefined
+ privileged reg969 (spr869): undefined
+ privileged reg970 (spr870): undefined
+ privileged reg971 (spr871): undefined
+ privileged reg972 (spr872): undefined
+ privileged reg973 (spr873): undefined
+ privileged reg974 (spr874): undefined
+ privileged reg975 (spr875): undefined
+ privileged reg976 (spr876): undefined
+ privileged reg977 (spr877): undefined
+ privileged reg978 (spr878): undefined
+ privileged reg979 (spr879): undefined
+ privileged reg980 (spr880): undefined
+ privileged reg981 (spr881): undefined
+ privileged reg982 (spr882): undefined
+ privileged reg983 (spr883): undefined
+ privileged reg984 (spr884): undefined
+ privileged reg985 (spr885): undefined
+ privileged reg986 (spr886): undefined
+ privileged reg987 (spr887): undefined
+ privileged reg988 (spr888): undefined
+ privileged reg989 (spr889): undefined
+ privileged reg990 (spr890): undefined
+ privileged reg991 (spr891): undefined
+ privileged reg992 (spr892): undefined
+ privileged reg993 (spr893): undefined
+ privileged reg994 (spr894): undefined
+ privileged reg995 (spr895): undefined
+ privileged reg996 (spr896): undefined
+ privileged reg997 (spr897): undefined
+ privileged reg998 (spr898): undefined
+ privileged reg999 (spr899): undefined
+ vector reg1124 (vr0): undefined
+ vector reg1125 (vr1): undefined
+ vector reg1126 (vr2): undefined
+ vector reg1127 (vr3): undefined
+ vector reg1128 (vr4): undefined
+ vector reg1129 (vr5): undefined
+ vector reg1130 (vr6): undefined
+ vector reg1131 (vr7): undefined
+ vector reg1132 (vr8): undefined
+ vector reg1133 (vr9): undefined
+ vector reg1134 (vr10): undefined
+ vector reg1135 (vr11): undefined
+ vector reg1136 (vr12): undefined
+ vector reg1137 (vr13): undefined
+ vector reg1138 (vr14): undefined
+ vector reg1139 (vr15): undefined
+ vector reg1140 (vr16): undefined
+ vector reg1141 (vr17): undefined
+ vector reg1142 (vr18): undefined
+ vector reg1143 (vr19): undefined
+ vector reg1144 (vr20): undefined
+ vector reg1145 (vr21): undefined
+ vector reg1146 (vr22): undefined
+ vector reg1147 (vr23): undefined
+ vector reg1148 (vr24): undefined
+ vector reg1149 (vr25): undefined
+ vector reg1150 (vr26): undefined
+ vector reg1151 (vr27): undefined
+ vector reg1152 (vr28): undefined
+ vector reg1153 (vr29): undefined
+ vector reg1154 (vr30): undefined
+ vector reg1155 (vr31): undefined
+EOF
+
+testrun_compare ${abs_builddir}/addrcfi -e testfileppc32 0x100004d2 <<\EOF
+.eh_frame has 0x100004d2 => [0x100004d0, 0x100004d4):
+ return address in reg65
+ CFA location expression: bregx(1)
+ integer reg0 (r0): undefined
+ integer reg1 (r1): location expression: call_frame_cfa stack_value
+ integer reg2 (r2): same_value
+ integer reg3 (r3): undefined
+ integer reg4 (r4): undefined
+ integer reg5 (r5): undefined
+ integer reg6 (r6): undefined
+ integer reg7 (r7): undefined
+ integer reg8 (r8): undefined
+ integer reg9 (r9): undefined
+ integer reg10 (r10): undefined
+ integer reg11 (r11): undefined
+ integer reg12 (r12): undefined
+ integer reg13 (r13): same_value
+ integer reg14 (r14): same_value
+ integer reg15 (r15): same_value
+ integer reg16 (r16): same_value
+ integer reg17 (r17): same_value
+ integer reg18 (r18): same_value
+ integer reg19 (r19): same_value
+ integer reg20 (r20): same_value
+ integer reg21 (r21): same_value
+ integer reg22 (r22): same_value
+ integer reg23 (r23): same_value
+ integer reg24 (r24): same_value
+ integer reg25 (r25): same_value
+ integer reg26 (r26): same_value
+ integer reg27 (r27): same_value
+ integer reg28 (r28): same_value
+ integer reg29 (r29): same_value
+ integer reg30 (r30): same_value
+ integer reg31 (r31): same_value
+ FPU reg32 (f0): undefined
+ FPU reg33 (f1): undefined
+ FPU reg34 (f2): undefined
+ FPU reg35 (f3): undefined
+ FPU reg36 (f4): undefined
+ FPU reg37 (f5): undefined
+ FPU reg38 (f6): undefined
+ FPU reg39 (f7): undefined
+ FPU reg40 (f8): undefined
+ FPU reg41 (f9): undefined
+ FPU reg42 (f10): undefined
+ FPU reg43 (f11): undefined
+ FPU reg44 (f12): undefined
+ FPU reg45 (f13): undefined
+ FPU reg46 (f14): undefined
+ FPU reg47 (f15): undefined
+ FPU reg48 (f16): undefined
+ FPU reg49 (f17): undefined
+ FPU reg50 (f18): undefined
+ FPU reg51 (f19): undefined
+ FPU reg52 (f20): undefined
+ FPU reg53 (f21): undefined
+ FPU reg54 (f22): undefined
+ FPU reg55 (f23): undefined
+ FPU reg56 (f24): undefined
+ FPU reg57 (f25): undefined
+ FPU reg58 (f26): undefined
+ FPU reg59 (f27): undefined
+ FPU reg60 (f28): undefined
+ FPU reg61 (f29): undefined
+ FPU reg62 (f30): undefined
+ FPU reg63 (f31): undefined
+ integer reg64 (cr): undefined
+ FPU reg65 (fpscr): same_value
+ integer reg66 (msr): undefined
+ vector reg67 (vscr): undefined
+ privileged reg70 (sr0): undefined
+ privileged reg71 (sr1): undefined
+ privileged reg72 (sr2): undefined
+ privileged reg73 (sr3): undefined
+ privileged reg74 (sr4): undefined
+ privileged reg75 (sr5): undefined
+ privileged reg76 (sr6): undefined
+ privileged reg77 (sr7): undefined
+ privileged reg78 (sr8): undefined
+ privileged reg79 (sr9): undefined
+ privileged reg80 (sr10): undefined
+ privileged reg81 (sr11): undefined
+ privileged reg82 (sr12): undefined
+ privileged reg83 (sr13): undefined
+ privileged reg84 (sr14): undefined
+ privileged reg85 (sr15): undefined
+ privileged reg100 (mq): undefined
+ privileged reg101 (xer): undefined
+ privileged reg102 (spr2): undefined
+ privileged reg103 (spr3): undefined
+ privileged reg104 (spr4): undefined
+ privileged reg105 (spr5): undefined
+ privileged reg106 (spr6): undefined
+ privileged reg107 (spr7): undefined
+ privileged reg108 (lr): undefined
+ privileged reg109 (ctr): undefined
+ privileged reg110 (spr10): undefined
+ privileged reg111 (spr11): undefined
+ privileged reg112 (spr12): undefined
+ privileged reg113 (spr13): undefined
+ privileged reg114 (tfhar): undefined
+ privileged reg115 (tfiar): undefined
+ privileged reg116 (texasr): undefined
+ privileged reg117 (spr17): undefined
+ privileged reg118 (dsisr): undefined
+ privileged reg119 (dar): undefined
+ privileged reg120 (spr20): undefined
+ privileged reg121 (spr21): undefined
+ privileged reg122 (dec): undefined
+ privileged reg123 (spr23): undefined
+ privileged reg124 (spr24): undefined
+ privileged reg125 (spr25): undefined
+ privileged reg126 (spr26): undefined
+ privileged reg127 (spr27): undefined
+ privileged reg128 (spr28): undefined
+ privileged reg129 (spr29): undefined
+ privileged reg130 (spr30): undefined
+ privileged reg131 (spr31): undefined
+ privileged reg132 (spr32): undefined
+ privileged reg133 (spr33): undefined
+ privileged reg134 (spr34): undefined
+ privileged reg135 (spr35): undefined
+ privileged reg136 (spr36): undefined
+ privileged reg137 (spr37): undefined
+ privileged reg138 (spr38): undefined
+ privileged reg139 (spr39): undefined
+ privileged reg140 (spr40): undefined
+ privileged reg141 (spr41): undefined
+ privileged reg142 (spr42): undefined
+ privileged reg143 (spr43): undefined
+ privileged reg144 (spr44): undefined
+ privileged reg145 (spr45): undefined
+ privileged reg146 (spr46): undefined
+ privileged reg147 (spr47): undefined
+ privileged reg148 (spr48): undefined
+ privileged reg149 (spr49): undefined
+ privileged reg150 (spr50): undefined
+ privileged reg151 (spr51): undefined
+ privileged reg152 (spr52): undefined
+ privileged reg153 (spr53): undefined
+ privileged reg154 (spr54): undefined
+ privileged reg155 (spr55): undefined
+ privileged reg156 (spr56): undefined
+ privileged reg157 (spr57): undefined
+ privileged reg158 (spr58): undefined
+ privileged reg159 (spr59): undefined
+ privileged reg160 (spr60): undefined
+ privileged reg161 (spr61): undefined
+ privileged reg162 (spr62): undefined
+ privileged reg163 (spr63): undefined
+ privileged reg164 (spr64): undefined
+ privileged reg165 (spr65): undefined
+ privileged reg166 (spr66): undefined
+ privileged reg167 (spr67): undefined
+ privileged reg168 (spr68): undefined
+ privileged reg169 (spr69): undefined
+ privileged reg170 (spr70): undefined
+ privileged reg171 (spr71): undefined
+ privileged reg172 (spr72): undefined
+ privileged reg173 (spr73): undefined
+ privileged reg174 (spr74): undefined
+ privileged reg175 (spr75): undefined
+ privileged reg176 (spr76): undefined
+ privileged reg177 (spr77): undefined
+ privileged reg178 (spr78): undefined
+ privileged reg179 (spr79): undefined
+ privileged reg180 (spr80): undefined
+ privileged reg181 (spr81): undefined
+ privileged reg182 (spr82): undefined
+ privileged reg183 (spr83): undefined
+ privileged reg184 (spr84): undefined
+ privileged reg185 (spr85): undefined
+ privileged reg186 (spr86): undefined
+ privileged reg187 (spr87): undefined
+ privileged reg188 (spr88): undefined
+ privileged reg189 (spr89): undefined
+ privileged reg190 (spr90): undefined
+ privileged reg191 (spr91): undefined
+ privileged reg192 (spr92): undefined
+ privileged reg193 (spr93): undefined
+ privileged reg194 (spr94): undefined
+ privileged reg195 (spr95): undefined
+ privileged reg196 (spr96): undefined
+ privileged reg197 (spr97): undefined
+ privileged reg198 (spr98): undefined
+ privileged reg199 (spr99): undefined
+ privileged reg200 (spr100): undefined
+ privileged reg201 (spr101): undefined
+ privileged reg202 (spr102): undefined
+ privileged reg203 (spr103): undefined
+ privileged reg204 (spr104): undefined
+ privileged reg205 (spr105): undefined
+ privileged reg206 (spr106): undefined
+ privileged reg207 (spr107): undefined
+ privileged reg208 (spr108): undefined
+ privileged reg209 (spr109): undefined
+ privileged reg210 (spr110): undefined
+ privileged reg211 (spr111): undefined
+ privileged reg212 (spr112): undefined
+ privileged reg213 (spr113): undefined
+ privileged reg214 (spr114): undefined
+ privileged reg215 (spr115): undefined
+ privileged reg216 (spr116): undefined
+ privileged reg217 (spr117): undefined
+ privileged reg218 (spr118): undefined
+ privileged reg219 (spr119): undefined
+ privileged reg220 (spr120): undefined
+ privileged reg221 (spr121): undefined
+ privileged reg222 (spr122): undefined
+ privileged reg223 (spr123): undefined
+ privileged reg224 (spr124): undefined
+ privileged reg225 (spr125): undefined
+ privileged reg226 (spr126): undefined
+ privileged reg227 (spr127): undefined
+ privileged reg228 (spr128): undefined
+ privileged reg229 (spr129): undefined
+ privileged reg230 (spr130): undefined
+ privileged reg231 (spr131): undefined
+ privileged reg232 (spr132): undefined
+ privileged reg233 (spr133): undefined
+ privileged reg234 (spr134): undefined
+ privileged reg235 (spr135): undefined
+ privileged reg236 (spr136): undefined
+ privileged reg237 (spr137): undefined
+ privileged reg238 (spr138): undefined
+ privileged reg239 (spr139): undefined
+ privileged reg240 (spr140): undefined
+ privileged reg241 (spr141): undefined
+ privileged reg242 (spr142): undefined
+ privileged reg243 (spr143): undefined
+ privileged reg244 (spr144): undefined
+ privileged reg245 (spr145): undefined
+ privileged reg246 (spr146): undefined
+ privileged reg247 (spr147): undefined
+ privileged reg248 (spr148): undefined
+ privileged reg249 (spr149): undefined
+ privileged reg250 (spr150): undefined
+ privileged reg251 (spr151): undefined
+ privileged reg252 (spr152): undefined
+ privileged reg253 (spr153): undefined
+ privileged reg254 (spr154): undefined
+ privileged reg255 (spr155): undefined
+ privileged reg256 (spr156): undefined
+ privileged reg257 (spr157): undefined
+ privileged reg258 (spr158): undefined
+ privileged reg259 (spr159): undefined
+ privileged reg260 (spr160): undefined
+ privileged reg261 (spr161): undefined
+ privileged reg262 (spr162): undefined
+ privileged reg263 (spr163): undefined
+ privileged reg264 (spr164): undefined
+ privileged reg265 (spr165): undefined
+ privileged reg266 (spr166): undefined
+ privileged reg267 (spr167): undefined
+ privileged reg268 (spr168): undefined
+ privileged reg269 (spr169): undefined
+ privileged reg270 (spr170): undefined
+ privileged reg271 (spr171): undefined
+ privileged reg272 (spr172): undefined
+ privileged reg273 (spr173): undefined
+ privileged reg274 (spr174): undefined
+ privileged reg275 (spr175): undefined
+ privileged reg276 (spr176): undefined
+ privileged reg277 (spr177): undefined
+ privileged reg278 (spr178): undefined
+ privileged reg279 (spr179): undefined
+ privileged reg280 (spr180): undefined
+ privileged reg281 (spr181): undefined
+ privileged reg282 (spr182): undefined
+ privileged reg283 (spr183): undefined
+ privileged reg284 (spr184): undefined
+ privileged reg285 (spr185): undefined
+ privileged reg286 (spr186): undefined
+ privileged reg287 (spr187): undefined
+ privileged reg288 (spr188): undefined
+ privileged reg289 (spr189): undefined
+ privileged reg290 (spr190): undefined
+ privileged reg291 (spr191): undefined
+ privileged reg292 (spr192): undefined
+ privileged reg293 (spr193): undefined
+ privileged reg294 (spr194): undefined
+ privileged reg295 (spr195): undefined
+ privileged reg296 (spr196): undefined
+ privileged reg297 (spr197): undefined
+ privileged reg298 (spr198): undefined
+ privileged reg299 (spr199): undefined
+ privileged reg300 (spr200): undefined
+ privileged reg301 (spr201): undefined
+ privileged reg302 (spr202): undefined
+ privileged reg303 (spr203): undefined
+ privileged reg304 (spr204): undefined
+ privileged reg305 (spr205): undefined
+ privileged reg306 (spr206): undefined
+ privileged reg307 (spr207): undefined
+ privileged reg308 (spr208): undefined
+ privileged reg309 (spr209): undefined
+ privileged reg310 (spr210): undefined
+ privileged reg311 (spr211): undefined
+ privileged reg312 (spr212): undefined
+ privileged reg313 (spr213): undefined
+ privileged reg314 (spr214): undefined
+ privileged reg315 (spr215): undefined
+ privileged reg316 (spr216): undefined
+ privileged reg317 (spr217): undefined
+ privileged reg318 (spr218): undefined
+ privileged reg319 (spr219): undefined
+ privileged reg320 (spr220): undefined
+ privileged reg321 (spr221): undefined
+ privileged reg322 (spr222): undefined
+ privileged reg323 (spr223): undefined
+ privileged reg324 (spr224): undefined
+ privileged reg325 (spr225): undefined
+ privileged reg326 (spr226): undefined
+ privileged reg327 (spr227): undefined
+ privileged reg328 (spr228): undefined
+ privileged reg329 (spr229): undefined
+ privileged reg330 (spr230): undefined
+ privileged reg331 (spr231): undefined
+ privileged reg332 (spr232): undefined
+ privileged reg333 (spr233): undefined
+ privileged reg334 (spr234): undefined
+ privileged reg335 (spr235): undefined
+ privileged reg336 (spr236): undefined
+ privileged reg337 (spr237): undefined
+ privileged reg338 (spr238): undefined
+ privileged reg339 (spr239): undefined
+ privileged reg340 (spr240): undefined
+ privileged reg341 (spr241): undefined
+ privileged reg342 (spr242): undefined
+ privileged reg343 (spr243): undefined
+ privileged reg344 (spr244): undefined
+ privileged reg345 (spr245): undefined
+ privileged reg346 (spr246): undefined
+ privileged reg347 (spr247): undefined
+ privileged reg348 (spr248): undefined
+ privileged reg349 (spr249): undefined
+ privileged reg350 (spr250): undefined
+ privileged reg351 (spr251): undefined
+ privileged reg352 (spr252): undefined
+ privileged reg353 (spr253): undefined
+ privileged reg354 (spr254): undefined
+ privileged reg355 (spr255): undefined
+ vector reg356 (vrsave): undefined
+ privileged reg357 (spr257): undefined
+ privileged reg358 (spr258): undefined
+ privileged reg359 (spr259): undefined
+ privileged reg360 (spr260): undefined
+ privileged reg361 (spr261): undefined
+ privileged reg362 (spr262): undefined
+ privileged reg363 (spr263): undefined
+ privileged reg364 (spr264): undefined
+ privileged reg365 (spr265): undefined
+ privileged reg366 (spr266): undefined
+ privileged reg367 (spr267): undefined
+ privileged reg368 (spr268): undefined
+ privileged reg369 (spr269): undefined
+ privileged reg370 (spr270): undefined
+ privileged reg371 (spr271): undefined
+ privileged reg372 (spr272): undefined
+ privileged reg373 (spr273): undefined
+ privileged reg374 (spr274): undefined
+ privileged reg375 (spr275): undefined
+ privileged reg376 (spr276): undefined
+ privileged reg377 (spr277): undefined
+ privileged reg378 (spr278): undefined
+ privileged reg379 (spr279): undefined
+ privileged reg380 (spr280): undefined
+ privileged reg381 (spr281): undefined
+ privileged reg382 (spr282): undefined
+ privileged reg383 (spr283): undefined
+ privileged reg384 (spr284): undefined
+ privileged reg385 (spr285): undefined
+ privileged reg386 (spr286): undefined
+ privileged reg387 (spr287): undefined
+ privileged reg388 (spr288): undefined
+ privileged reg389 (spr289): undefined
+ privileged reg390 (spr290): undefined
+ privileged reg391 (spr291): undefined
+ privileged reg392 (spr292): undefined
+ privileged reg393 (spr293): undefined
+ privileged reg394 (spr294): undefined
+ privileged reg395 (spr295): undefined
+ privileged reg396 (spr296): undefined
+ privileged reg397 (spr297): undefined
+ privileged reg398 (spr298): undefined
+ privileged reg399 (spr299): undefined
+ privileged reg400 (spr300): undefined
+ privileged reg401 (spr301): undefined
+ privileged reg402 (spr302): undefined
+ privileged reg403 (spr303): undefined
+ privileged reg404 (spr304): undefined
+ privileged reg405 (spr305): undefined
+ privileged reg406 (spr306): undefined
+ privileged reg407 (spr307): undefined
+ privileged reg408 (spr308): undefined
+ privileged reg409 (spr309): undefined
+ privileged reg410 (spr310): undefined
+ privileged reg411 (spr311): undefined
+ privileged reg412 (spr312): undefined
+ privileged reg413 (spr313): undefined
+ privileged reg414 (spr314): undefined
+ privileged reg415 (spr315): undefined
+ privileged reg416 (spr316): undefined
+ privileged reg417 (spr317): undefined
+ privileged reg418 (spr318): undefined
+ privileged reg419 (spr319): undefined
+ privileged reg420 (spr320): undefined
+ privileged reg421 (spr321): undefined
+ privileged reg422 (spr322): undefined
+ privileged reg423 (spr323): undefined
+ privileged reg424 (spr324): undefined
+ privileged reg425 (spr325): undefined
+ privileged reg426 (spr326): undefined
+ privileged reg427 (spr327): undefined
+ privileged reg428 (spr328): undefined
+ privileged reg429 (spr329): undefined
+ privileged reg430 (spr330): undefined
+ privileged reg431 (spr331): undefined
+ privileged reg432 (spr332): undefined
+ privileged reg433 (spr333): undefined
+ privileged reg434 (spr334): undefined
+ privileged reg435 (spr335): undefined
+ privileged reg436 (spr336): undefined
+ privileged reg437 (spr337): undefined
+ privileged reg438 (spr338): undefined
+ privileged reg439 (spr339): undefined
+ privileged reg440 (spr340): undefined
+ privileged reg441 (spr341): undefined
+ privileged reg442 (spr342): undefined
+ privileged reg443 (spr343): undefined
+ privileged reg444 (spr344): undefined
+ privileged reg445 (spr345): undefined
+ privileged reg446 (spr346): undefined
+ privileged reg447 (spr347): undefined
+ privileged reg448 (spr348): undefined
+ privileged reg449 (spr349): undefined
+ privileged reg450 (spr350): undefined
+ privileged reg451 (spr351): undefined
+ privileged reg452 (spr352): undefined
+ privileged reg453 (spr353): undefined
+ privileged reg454 (spr354): undefined
+ privileged reg455 (spr355): undefined
+ privileged reg456 (spr356): undefined
+ privileged reg457 (spr357): undefined
+ privileged reg458 (spr358): undefined
+ privileged reg459 (spr359): undefined
+ privileged reg460 (spr360): undefined
+ privileged reg461 (spr361): undefined
+ privileged reg462 (spr362): undefined
+ privileged reg463 (spr363): undefined
+ privileged reg464 (spr364): undefined
+ privileged reg465 (spr365): undefined
+ privileged reg466 (spr366): undefined
+ privileged reg467 (spr367): undefined
+ privileged reg468 (spr368): undefined
+ privileged reg469 (spr369): undefined
+ privileged reg470 (spr370): undefined
+ privileged reg471 (spr371): undefined
+ privileged reg472 (spr372): undefined
+ privileged reg473 (spr373): undefined
+ privileged reg474 (spr374): undefined
+ privileged reg475 (spr375): undefined
+ privileged reg476 (spr376): undefined
+ privileged reg477 (spr377): undefined
+ privileged reg478 (spr378): undefined
+ privileged reg479 (spr379): undefined
+ privileged reg480 (spr380): undefined
+ privileged reg481 (spr381): undefined
+ privileged reg482 (spr382): undefined
+ privileged reg483 (spr383): undefined
+ privileged reg484 (spr384): undefined
+ privileged reg485 (spr385): undefined
+ privileged reg486 (spr386): undefined
+ privileged reg487 (spr387): undefined
+ privileged reg488 (spr388): undefined
+ privileged reg489 (spr389): undefined
+ privileged reg490 (spr390): undefined
+ privileged reg491 (spr391): undefined
+ privileged reg492 (spr392): undefined
+ privileged reg493 (spr393): undefined
+ privileged reg494 (spr394): undefined
+ privileged reg495 (spr395): undefined
+ privileged reg496 (spr396): undefined
+ privileged reg497 (spr397): undefined
+ privileged reg498 (spr398): undefined
+ privileged reg499 (spr399): undefined
+ privileged reg500 (spr400): undefined
+ privileged reg501 (spr401): undefined
+ privileged reg502 (spr402): undefined
+ privileged reg503 (spr403): undefined
+ privileged reg504 (spr404): undefined
+ privileged reg505 (spr405): undefined
+ privileged reg506 (spr406): undefined
+ privileged reg507 (spr407): undefined
+ privileged reg508 (spr408): undefined
+ privileged reg509 (spr409): undefined
+ privileged reg510 (spr410): undefined
+ privileged reg511 (spr411): undefined
+ privileged reg512 (spr412): undefined
+ privileged reg513 (spr413): undefined
+ privileged reg514 (spr414): undefined
+ privileged reg515 (spr415): undefined
+ privileged reg516 (spr416): undefined
+ privileged reg517 (spr417): undefined
+ privileged reg518 (spr418): undefined
+ privileged reg519 (spr419): undefined
+ privileged reg520 (spr420): undefined
+ privileged reg521 (spr421): undefined
+ privileged reg522 (spr422): undefined
+ privileged reg523 (spr423): undefined
+ privileged reg524 (spr424): undefined
+ privileged reg525 (spr425): undefined
+ privileged reg526 (spr426): undefined
+ privileged reg527 (spr427): undefined
+ privileged reg528 (spr428): undefined
+ privileged reg529 (spr429): undefined
+ privileged reg530 (spr430): undefined
+ privileged reg531 (spr431): undefined
+ privileged reg532 (spr432): undefined
+ privileged reg533 (spr433): undefined
+ privileged reg534 (spr434): undefined
+ privileged reg535 (spr435): undefined
+ privileged reg536 (spr436): undefined
+ privileged reg537 (spr437): undefined
+ privileged reg538 (spr438): undefined
+ privileged reg539 (spr439): undefined
+ privileged reg540 (spr440): undefined
+ privileged reg541 (spr441): undefined
+ privileged reg542 (spr442): undefined
+ privileged reg543 (spr443): undefined
+ privileged reg544 (spr444): undefined
+ privileged reg545 (spr445): undefined
+ privileged reg546 (spr446): undefined
+ privileged reg547 (spr447): undefined
+ privileged reg548 (spr448): undefined
+ privileged reg549 (spr449): undefined
+ privileged reg550 (spr450): undefined
+ privileged reg551 (spr451): undefined
+ privileged reg552 (spr452): undefined
+ privileged reg553 (spr453): undefined
+ privileged reg554 (spr454): undefined
+ privileged reg555 (spr455): undefined
+ privileged reg556 (spr456): undefined
+ privileged reg557 (spr457): undefined
+ privileged reg558 (spr458): undefined
+ privileged reg559 (spr459): undefined
+ privileged reg560 (spr460): undefined
+ privileged reg561 (spr461): undefined
+ privileged reg562 (spr462): undefined
+ privileged reg563 (spr463): undefined
+ privileged reg564 (spr464): undefined
+ privileged reg565 (spr465): undefined
+ privileged reg566 (spr466): undefined
+ privileged reg567 (spr467): undefined
+ privileged reg568 (spr468): undefined
+ privileged reg569 (spr469): undefined
+ privileged reg570 (spr470): undefined
+ privileged reg571 (spr471): undefined
+ privileged reg572 (spr472): undefined
+ privileged reg573 (spr473): undefined
+ privileged reg574 (spr474): undefined
+ privileged reg575 (spr475): undefined
+ privileged reg576 (spr476): undefined
+ privileged reg577 (spr477): undefined
+ privileged reg578 (spr478): undefined
+ privileged reg579 (spr479): undefined
+ privileged reg580 (spr480): undefined
+ privileged reg581 (spr481): undefined
+ privileged reg582 (spr482): undefined
+ privileged reg583 (spr483): undefined
+ privileged reg584 (spr484): undefined
+ privileged reg585 (spr485): undefined
+ privileged reg586 (spr486): undefined
+ privileged reg587 (spr487): undefined
+ privileged reg588 (spr488): undefined
+ privileged reg589 (spr489): undefined
+ privileged reg590 (spr490): undefined
+ privileged reg591 (spr491): undefined
+ privileged reg592 (spr492): undefined
+ privileged reg593 (spr493): undefined
+ privileged reg594 (spr494): undefined
+ privileged reg595 (spr495): undefined
+ privileged reg596 (spr496): undefined
+ privileged reg597 (spr497): undefined
+ privileged reg598 (spr498): undefined
+ privileged reg599 (spr499): undefined
+ privileged reg600 (spr500): undefined
+ privileged reg601 (spr501): undefined
+ privileged reg602 (spr502): undefined
+ privileged reg603 (spr503): undefined
+ privileged reg604 (spr504): undefined
+ privileged reg605 (spr505): undefined
+ privileged reg606 (spr506): undefined
+ privileged reg607 (spr507): undefined
+ privileged reg608 (spr508): undefined
+ privileged reg609 (spr509): undefined
+ privileged reg610 (spr510): undefined
+ privileged reg611 (spr511): undefined
+ vector reg612 (spefscr): undefined
+ privileged reg613 (spr513): undefined
+ privileged reg614 (spr514): undefined
+ privileged reg615 (spr515): undefined
+ privileged reg616 (spr516): undefined
+ privileged reg617 (spr517): undefined
+ privileged reg618 (spr518): undefined
+ privileged reg619 (spr519): undefined
+ privileged reg620 (spr520): undefined
+ privileged reg621 (spr521): undefined
+ privileged reg622 (spr522): undefined
+ privileged reg623 (spr523): undefined
+ privileged reg624 (spr524): undefined
+ privileged reg625 (spr525): undefined
+ privileged reg626 (spr526): undefined
+ privileged reg627 (spr527): undefined
+ privileged reg628 (spr528): undefined
+ privileged reg629 (spr529): undefined
+ privileged reg630 (spr530): undefined
+ privileged reg631 (spr531): undefined
+ privileged reg632 (spr532): undefined
+ privileged reg633 (spr533): undefined
+ privileged reg634 (spr534): undefined
+ privileged reg635 (spr535): undefined
+ privileged reg636 (spr536): undefined
+ privileged reg637 (spr537): undefined
+ privileged reg638 (spr538): undefined
+ privileged reg639 (spr539): undefined
+ privileged reg640 (spr540): undefined
+ privileged reg641 (spr541): undefined
+ privileged reg642 (spr542): undefined
+ privileged reg643 (spr543): undefined
+ privileged reg644 (spr544): undefined
+ privileged reg645 (spr545): undefined
+ privileged reg646 (spr546): undefined
+ privileged reg647 (spr547): undefined
+ privileged reg648 (spr548): undefined
+ privileged reg649 (spr549): undefined
+ privileged reg650 (spr550): undefined
+ privileged reg651 (spr551): undefined
+ privileged reg652 (spr552): undefined
+ privileged reg653 (spr553): undefined
+ privileged reg654 (spr554): undefined
+ privileged reg655 (spr555): undefined
+ privileged reg656 (spr556): undefined
+ privileged reg657 (spr557): undefined
+ privileged reg658 (spr558): undefined
+ privileged reg659 (spr559): undefined
+ privileged reg660 (spr560): undefined
+ privileged reg661 (spr561): undefined
+ privileged reg662 (spr562): undefined
+ privileged reg663 (spr563): undefined
+ privileged reg664 (spr564): undefined
+ privileged reg665 (spr565): undefined
+ privileged reg666 (spr566): undefined
+ privileged reg667 (spr567): undefined
+ privileged reg668 (spr568): undefined
+ privileged reg669 (spr569): undefined
+ privileged reg670 (spr570): undefined
+ privileged reg671 (spr571): undefined
+ privileged reg672 (spr572): undefined
+ privileged reg673 (spr573): undefined
+ privileged reg674 (spr574): undefined
+ privileged reg675 (spr575): undefined
+ privileged reg676 (spr576): undefined
+ privileged reg677 (spr577): undefined
+ privileged reg678 (spr578): undefined
+ privileged reg679 (spr579): undefined
+ privileged reg680 (spr580): undefined
+ privileged reg681 (spr581): undefined
+ privileged reg682 (spr582): undefined
+ privileged reg683 (spr583): undefined
+ privileged reg684 (spr584): undefined
+ privileged reg685 (spr585): undefined
+ privileged reg686 (spr586): undefined
+ privileged reg687 (spr587): undefined
+ privileged reg688 (spr588): undefined
+ privileged reg689 (spr589): undefined
+ privileged reg690 (spr590): undefined
+ privileged reg691 (spr591): undefined
+ privileged reg692 (spr592): undefined
+ privileged reg693 (spr593): undefined
+ privileged reg694 (spr594): undefined
+ privileged reg695 (spr595): undefined
+ privileged reg696 (spr596): undefined
+ privileged reg697 (spr597): undefined
+ privileged reg698 (spr598): undefined
+ privileged reg699 (spr599): undefined
+ privileged reg700 (spr600): undefined
+ privileged reg701 (spr601): undefined
+ privileged reg702 (spr602): undefined
+ privileged reg703 (spr603): undefined
+ privileged reg704 (spr604): undefined
+ privileged reg705 (spr605): undefined
+ privileged reg706 (spr606): undefined
+ privileged reg707 (spr607): undefined
+ privileged reg708 (spr608): undefined
+ privileged reg709 (spr609): undefined
+ privileged reg710 (spr610): undefined
+ privileged reg711 (spr611): undefined
+ privileged reg712 (spr612): undefined
+ privileged reg713 (spr613): undefined
+ privileged reg714 (spr614): undefined
+ privileged reg715 (spr615): undefined
+ privileged reg716 (spr616): undefined
+ privileged reg717 (spr617): undefined
+ privileged reg718 (spr618): undefined
+ privileged reg719 (spr619): undefined
+ privileged reg720 (spr620): undefined
+ privileged reg721 (spr621): undefined
+ privileged reg722 (spr622): undefined
+ privileged reg723 (spr623): undefined
+ privileged reg724 (spr624): undefined
+ privileged reg725 (spr625): undefined
+ privileged reg726 (spr626): undefined
+ privileged reg727 (spr627): undefined
+ privileged reg728 (spr628): undefined
+ privileged reg729 (spr629): undefined
+ privileged reg730 (spr630): undefined
+ privileged reg731 (spr631): undefined
+ privileged reg732 (spr632): undefined
+ privileged reg733 (spr633): undefined
+ privileged reg734 (spr634): undefined
+ privileged reg735 (spr635): undefined
+ privileged reg736 (spr636): undefined
+ privileged reg737 (spr637): undefined
+ privileged reg738 (spr638): undefined
+ privileged reg739 (spr639): undefined
+ privileged reg740 (spr640): undefined
+ privileged reg741 (spr641): undefined
+ privileged reg742 (spr642): undefined
+ privileged reg743 (spr643): undefined
+ privileged reg744 (spr644): undefined
+ privileged reg745 (spr645): undefined
+ privileged reg746 (spr646): undefined
+ privileged reg747 (spr647): undefined
+ privileged reg748 (spr648): undefined
+ privileged reg749 (spr649): undefined
+ privileged reg750 (spr650): undefined
+ privileged reg751 (spr651): undefined
+ privileged reg752 (spr652): undefined
+ privileged reg753 (spr653): undefined
+ privileged reg754 (spr654): undefined
+ privileged reg755 (spr655): undefined
+ privileged reg756 (spr656): undefined
+ privileged reg757 (spr657): undefined
+ privileged reg758 (spr658): undefined
+ privileged reg759 (spr659): undefined
+ privileged reg760 (spr660): undefined
+ privileged reg761 (spr661): undefined
+ privileged reg762 (spr662): undefined
+ privileged reg763 (spr663): undefined
+ privileged reg764 (spr664): undefined
+ privileged reg765 (spr665): undefined
+ privileged reg766 (spr666): undefined
+ privileged reg767 (spr667): undefined
+ privileged reg768 (spr668): undefined
+ privileged reg769 (spr669): undefined
+ privileged reg770 (spr670): undefined
+ privileged reg771 (spr671): undefined
+ privileged reg772 (spr672): undefined
+ privileged reg773 (spr673): undefined
+ privileged reg774 (spr674): undefined
+ privileged reg775 (spr675): undefined
+ privileged reg776 (spr676): undefined
+ privileged reg777 (spr677): undefined
+ privileged reg778 (spr678): undefined
+ privileged reg779 (spr679): undefined
+ privileged reg780 (spr680): undefined
+ privileged reg781 (spr681): undefined
+ privileged reg782 (spr682): undefined
+ privileged reg783 (spr683): undefined
+ privileged reg784 (spr684): undefined
+ privileged reg785 (spr685): undefined
+ privileged reg786 (spr686): undefined
+ privileged reg787 (spr687): undefined
+ privileged reg788 (spr688): undefined
+ privileged reg789 (spr689): undefined
+ privileged reg790 (spr690): undefined
+ privileged reg791 (spr691): undefined
+ privileged reg792 (spr692): undefined
+ privileged reg793 (spr693): undefined
+ privileged reg794 (spr694): undefined
+ privileged reg795 (spr695): undefined
+ privileged reg796 (spr696): undefined
+ privileged reg797 (spr697): undefined
+ privileged reg798 (spr698): undefined
+ privileged reg799 (spr699): undefined
+ privileged reg800 (spr700): undefined
+ privileged reg801 (spr701): undefined
+ privileged reg802 (spr702): undefined
+ privileged reg803 (spr703): undefined
+ privileged reg804 (spr704): undefined
+ privileged reg805 (spr705): undefined
+ privileged reg806 (spr706): undefined
+ privileged reg807 (spr707): undefined
+ privileged reg808 (spr708): undefined
+ privileged reg809 (spr709): undefined
+ privileged reg810 (spr710): undefined
+ privileged reg811 (spr711): undefined
+ privileged reg812 (spr712): undefined
+ privileged reg813 (spr713): undefined
+ privileged reg814 (spr714): undefined
+ privileged reg815 (spr715): undefined
+ privileged reg816 (spr716): undefined
+ privileged reg817 (spr717): undefined
+ privileged reg818 (spr718): undefined
+ privileged reg819 (spr719): undefined
+ privileged reg820 (spr720): undefined
+ privileged reg821 (spr721): undefined
+ privileged reg822 (spr722): undefined
+ privileged reg823 (spr723): undefined
+ privileged reg824 (spr724): undefined
+ privileged reg825 (spr725): undefined
+ privileged reg826 (spr726): undefined
+ privileged reg827 (spr727): undefined
+ privileged reg828 (spr728): undefined
+ privileged reg829 (spr729): undefined
+ privileged reg830 (spr730): undefined
+ privileged reg831 (spr731): undefined
+ privileged reg832 (spr732): undefined
+ privileged reg833 (spr733): undefined
+ privileged reg834 (spr734): undefined
+ privileged reg835 (spr735): undefined
+ privileged reg836 (spr736): undefined
+ privileged reg837 (spr737): undefined
+ privileged reg838 (spr738): undefined
+ privileged reg839 (spr739): undefined
+ privileged reg840 (spr740): undefined
+ privileged reg841 (spr741): undefined
+ privileged reg842 (spr742): undefined
+ privileged reg843 (spr743): undefined
+ privileged reg844 (spr744): undefined
+ privileged reg845 (spr745): undefined
+ privileged reg846 (spr746): undefined
+ privileged reg847 (spr747): undefined
+ privileged reg848 (spr748): undefined
+ privileged reg849 (spr749): undefined
+ privileged reg850 (spr750): undefined
+ privileged reg851 (spr751): undefined
+ privileged reg852 (spr752): undefined
+ privileged reg853 (spr753): undefined
+ privileged reg854 (spr754): undefined
+ privileged reg855 (spr755): undefined
+ privileged reg856 (spr756): undefined
+ privileged reg857 (spr757): undefined
+ privileged reg858 (spr758): undefined
+ privileged reg859 (spr759): undefined
+ privileged reg860 (spr760): undefined
+ privileged reg861 (spr761): undefined
+ privileged reg862 (spr762): undefined
+ privileged reg863 (spr763): undefined
+ privileged reg864 (spr764): undefined
+ privileged reg865 (spr765): undefined
+ privileged reg866 (spr766): undefined
+ privileged reg867 (spr767): undefined
+ privileged reg868 (spr768): undefined
+ privileged reg869 (spr769): undefined
+ privileged reg870 (spr770): undefined
+ privileged reg871 (spr771): undefined
+ privileged reg872 (spr772): undefined
+ privileged reg873 (spr773): undefined
+ privileged reg874 (spr774): undefined
+ privileged reg875 (spr775): undefined
+ privileged reg876 (spr776): undefined
+ privileged reg877 (spr777): undefined
+ privileged reg878 (spr778): undefined
+ privileged reg879 (spr779): undefined
+ privileged reg880 (spr780): undefined
+ privileged reg881 (spr781): undefined
+ privileged reg882 (spr782): undefined
+ privileged reg883 (spr783): undefined
+ privileged reg884 (spr784): undefined
+ privileged reg885 (spr785): undefined
+ privileged reg886 (spr786): undefined
+ privileged reg887 (spr787): undefined
+ privileged reg888 (spr788): undefined
+ privileged reg889 (spr789): undefined
+ privileged reg890 (spr790): undefined
+ privileged reg891 (spr791): undefined
+ privileged reg892 (spr792): undefined
+ privileged reg893 (spr793): undefined
+ privileged reg894 (spr794): undefined
+ privileged reg895 (spr795): undefined
+ privileged reg896 (spr796): undefined
+ privileged reg897 (spr797): undefined
+ privileged reg898 (spr798): undefined
+ privileged reg899 (spr799): undefined
+ privileged reg900 (spr800): undefined
+ privileged reg901 (spr801): undefined
+ privileged reg902 (spr802): undefined
+ privileged reg903 (spr803): undefined
+ privileged reg904 (spr804): undefined
+ privileged reg905 (spr805): undefined
+ privileged reg906 (spr806): undefined
+ privileged reg907 (spr807): undefined
+ privileged reg908 (spr808): undefined
+ privileged reg909 (spr809): undefined
+ privileged reg910 (spr810): undefined
+ privileged reg911 (spr811): undefined
+ privileged reg912 (spr812): undefined
+ privileged reg913 (spr813): undefined
+ privileged reg914 (spr814): undefined
+ privileged reg915 (spr815): undefined
+ privileged reg916 (spr816): undefined
+ privileged reg917 (spr817): undefined
+ privileged reg918 (spr818): undefined
+ privileged reg919 (spr819): undefined
+ privileged reg920 (spr820): undefined
+ privileged reg921 (spr821): undefined
+ privileged reg922 (spr822): undefined
+ privileged reg923 (spr823): undefined
+ privileged reg924 (spr824): undefined
+ privileged reg925 (spr825): undefined
+ privileged reg926 (spr826): undefined
+ privileged reg927 (spr827): undefined
+ privileged reg928 (spr828): undefined
+ privileged reg929 (spr829): undefined
+ privileged reg930 (spr830): undefined
+ privileged reg931 (spr831): undefined
+ privileged reg932 (spr832): undefined
+ privileged reg933 (spr833): undefined
+ privileged reg934 (spr834): undefined
+ privileged reg935 (spr835): undefined
+ privileged reg936 (spr836): undefined
+ privileged reg937 (spr837): undefined
+ privileged reg938 (spr838): undefined
+ privileged reg939 (spr839): undefined
+ privileged reg940 (spr840): undefined
+ privileged reg941 (spr841): undefined
+ privileged reg942 (spr842): undefined
+ privileged reg943 (spr843): undefined
+ privileged reg944 (spr844): undefined
+ privileged reg945 (spr845): undefined
+ privileged reg946 (spr846): undefined
+ privileged reg947 (spr847): undefined
+ privileged reg948 (spr848): undefined
+ privileged reg949 (spr849): undefined
+ privileged reg950 (spr850): undefined
+ privileged reg951 (spr851): undefined
+ privileged reg952 (spr852): undefined
+ privileged reg953 (spr853): undefined
+ privileged reg954 (spr854): undefined
+ privileged reg955 (spr855): undefined
+ privileged reg956 (spr856): undefined
+ privileged reg957 (spr857): undefined
+ privileged reg958 (spr858): undefined
+ privileged reg959 (spr859): undefined
+ privileged reg960 (spr860): undefined
+ privileged reg961 (spr861): undefined
+ privileged reg962 (spr862): undefined
+ privileged reg963 (spr863): undefined
+ privileged reg964 (spr864): undefined
+ privileged reg965 (spr865): undefined
+ privileged reg966 (spr866): undefined
+ privileged reg967 (spr867): undefined
+ privileged reg968 (spr868): undefined
+ privileged reg969 (spr869): undefined
+ privileged reg970 (spr870): undefined
+ privileged reg971 (spr871): undefined
+ privileged reg972 (spr872): undefined
+ privileged reg973 (spr873): undefined
+ privileged reg974 (spr874): undefined
+ privileged reg975 (spr875): undefined
+ privileged reg976 (spr876): undefined
+ privileged reg977 (spr877): undefined
+ privileged reg978 (spr878): undefined
+ privileged reg979 (spr879): undefined
+ privileged reg980 (spr880): undefined
+ privileged reg981 (spr881): undefined
+ privileged reg982 (spr882): undefined
+ privileged reg983 (spr883): undefined
+ privileged reg984 (spr884): undefined
+ privileged reg985 (spr885): undefined
+ privileged reg986 (spr886): undefined
+ privileged reg987 (spr887): undefined
+ privileged reg988 (spr888): undefined
+ privileged reg989 (spr889): undefined
+ privileged reg990 (spr890): undefined
+ privileged reg991 (spr891): undefined
+ privileged reg992 (spr892): undefined
+ privileged reg993 (spr893): undefined
+ privileged reg994 (spr894): undefined
+ privileged reg995 (spr895): undefined
+ privileged reg996 (spr896): undefined
+ privileged reg997 (spr897): undefined
+ privileged reg998 (spr898): undefined
+ privileged reg999 (spr899): undefined
+ vector reg1124 (vr0): undefined
+ vector reg1125 (vr1): undefined
+ vector reg1126 (vr2): undefined
+ vector reg1127 (vr3): undefined
+ vector reg1128 (vr4): undefined
+ vector reg1129 (vr5): undefined
+ vector reg1130 (vr6): undefined
+ vector reg1131 (vr7): undefined
+ vector reg1132 (vr8): undefined
+ vector reg1133 (vr9): undefined
+ vector reg1134 (vr10): undefined
+ vector reg1135 (vr11): undefined
+ vector reg1136 (vr12): undefined
+ vector reg1137 (vr13): undefined
+ vector reg1138 (vr14): undefined
+ vector reg1139 (vr15): undefined
+ vector reg1140 (vr16): undefined
+ vector reg1141 (vr17): undefined
+ vector reg1142 (vr18): undefined
+ vector reg1143 (vr19): undefined
+ vector reg1144 (vr20): undefined
+ vector reg1145 (vr21): undefined
+ vector reg1146 (vr22): undefined
+ vector reg1147 (vr23): undefined
+ vector reg1148 (vr24): undefined
+ vector reg1149 (vr25): undefined
+ vector reg1150 (vr26): undefined
+ vector reg1151 (vr27): undefined
+ vector reg1152 (vr28): undefined
+ vector reg1153 (vr29): undefined
+ vector reg1154 (vr30): undefined
+ vector reg1155 (vr31): undefined
+dwarf_cfi_addrframe (.debug_frame): no matching address range
+EOF
+
+# EM_PPC64 (function bar 0x00000000100005b0)
+# Note. Only in .debug_frame, not in .eh_frame.
+# Same as testfileppc32 but without -m32.
+testfiles testfileppc64
+testrun_compare ${abs_builddir}/addrcfi -e testfileppc64 0x00000000100005b0 <<\EOF
+dwarf_cfi_addrframe (.eh_frame): no matching address range
+.debug_frame has 0x100005b0 => [0x100005b0, 0x100005d0):
+ return address in reg65
+ CFA location expression: bregx(1)
+ integer reg0 (r0): undefined
+ integer reg1 (r1): location expression: call_frame_cfa stack_value
+ integer reg2 (r2): same_value
+ integer reg3 (r3): undefined
+ integer reg4 (r4): undefined
+ integer reg5 (r5): undefined
+ integer reg6 (r6): undefined
+ integer reg7 (r7): undefined
+ integer reg8 (r8): undefined
+ integer reg9 (r9): undefined
+ integer reg10 (r10): undefined
+ integer reg11 (r11): undefined
+ integer reg12 (r12): undefined
+ integer reg13 (r13): same_value
+ integer reg14 (r14): same_value
+ integer reg15 (r15): same_value
+ integer reg16 (r16): same_value
+ integer reg17 (r17): same_value
+ integer reg18 (r18): same_value
+ integer reg19 (r19): same_value
+ integer reg20 (r20): same_value
+ integer reg21 (r21): same_value
+ integer reg22 (r22): same_value
+ integer reg23 (r23): same_value
+ integer reg24 (r24): same_value
+ integer reg25 (r25): same_value
+ integer reg26 (r26): same_value
+ integer reg27 (r27): same_value
+ integer reg28 (r28): same_value
+ integer reg29 (r29): same_value
+ integer reg30 (r30): same_value
+ integer reg31 (r31): same_value
+ FPU reg32 (f0): undefined
+ FPU reg33 (f1): undefined
+ FPU reg34 (f2): undefined
+ FPU reg35 (f3): undefined
+ FPU reg36 (f4): undefined
+ FPU reg37 (f5): undefined
+ FPU reg38 (f6): undefined
+ FPU reg39 (f7): undefined
+ FPU reg40 (f8): undefined
+ FPU reg41 (f9): undefined
+ FPU reg42 (f10): undefined
+ FPU reg43 (f11): undefined
+ FPU reg44 (f12): undefined
+ FPU reg45 (f13): undefined
+ FPU reg46 (f14): undefined
+ FPU reg47 (f15): undefined
+ FPU reg48 (f16): undefined
+ FPU reg49 (f17): undefined
+ FPU reg50 (f18): undefined
+ FPU reg51 (f19): undefined
+ FPU reg52 (f20): undefined
+ FPU reg53 (f21): undefined
+ FPU reg54 (f22): undefined
+ FPU reg55 (f23): undefined
+ FPU reg56 (f24): undefined
+ FPU reg57 (f25): undefined
+ FPU reg58 (f26): undefined
+ FPU reg59 (f27): undefined
+ FPU reg60 (f28): undefined
+ FPU reg61 (f29): undefined
+ FPU reg62 (f30): undefined
+ FPU reg63 (f31): undefined
+ integer reg64 (cr): undefined
+ FPU reg65 (fpscr): same_value
+ integer reg66 (msr): undefined
+ vector reg67 (vscr): undefined
+ privileged reg70 (sr0): undefined
+ privileged reg71 (sr1): undefined
+ privileged reg72 (sr2): undefined
+ privileged reg73 (sr3): undefined
+ privileged reg74 (sr4): undefined
+ privileged reg75 (sr5): undefined
+ privileged reg76 (sr6): undefined
+ privileged reg77 (sr7): undefined
+ privileged reg78 (sr8): undefined
+ privileged reg79 (sr9): undefined
+ privileged reg80 (sr10): undefined
+ privileged reg81 (sr11): undefined
+ privileged reg82 (sr12): undefined
+ privileged reg83 (sr13): undefined
+ privileged reg84 (sr14): undefined
+ privileged reg85 (sr15): undefined
+ privileged reg100 (spr0): undefined
+ privileged reg101 (xer): undefined
+ privileged reg102 (spr2): undefined
+ privileged reg103 (spr3): undefined
+ privileged reg104 (spr4): undefined
+ privileged reg105 (spr5): undefined
+ privileged reg106 (spr6): undefined
+ privileged reg107 (spr7): undefined
+ privileged reg108 (lr): undefined
+ privileged reg109 (ctr): undefined
+ privileged reg110 (spr10): undefined
+ privileged reg111 (spr11): undefined
+ privileged reg112 (spr12): undefined
+ privileged reg113 (spr13): undefined
+ privileged reg114 (tfhar): undefined
+ privileged reg115 (tfiar): undefined
+ privileged reg116 (texasr): undefined
+ privileged reg117 (spr17): undefined
+ privileged reg118 (dsisr): undefined
+ privileged reg119 (dar): undefined
+ privileged reg120 (spr20): undefined
+ privileged reg121 (spr21): undefined
+ privileged reg122 (dec): undefined
+ privileged reg123 (spr23): undefined
+ privileged reg124 (spr24): undefined
+ privileged reg125 (spr25): undefined
+ privileged reg126 (spr26): undefined
+ privileged reg127 (spr27): undefined
+ privileged reg128 (spr28): undefined
+ privileged reg129 (spr29): undefined
+ privileged reg130 (spr30): undefined
+ privileged reg131 (spr31): undefined
+ privileged reg132 (spr32): undefined
+ privileged reg133 (spr33): undefined
+ privileged reg134 (spr34): undefined
+ privileged reg135 (spr35): undefined
+ privileged reg136 (spr36): undefined
+ privileged reg137 (spr37): undefined
+ privileged reg138 (spr38): undefined
+ privileged reg139 (spr39): undefined
+ privileged reg140 (spr40): undefined
+ privileged reg141 (spr41): undefined
+ privileged reg142 (spr42): undefined
+ privileged reg143 (spr43): undefined
+ privileged reg144 (spr44): undefined
+ privileged reg145 (spr45): undefined
+ privileged reg146 (spr46): undefined
+ privileged reg147 (spr47): undefined
+ privileged reg148 (spr48): undefined
+ privileged reg149 (spr49): undefined
+ privileged reg150 (spr50): undefined
+ privileged reg151 (spr51): undefined
+ privileged reg152 (spr52): undefined
+ privileged reg153 (spr53): undefined
+ privileged reg154 (spr54): undefined
+ privileged reg155 (spr55): undefined
+ privileged reg156 (spr56): undefined
+ privileged reg157 (spr57): undefined
+ privileged reg158 (spr58): undefined
+ privileged reg159 (spr59): undefined
+ privileged reg160 (spr60): undefined
+ privileged reg161 (spr61): undefined
+ privileged reg162 (spr62): undefined
+ privileged reg163 (spr63): undefined
+ privileged reg164 (spr64): undefined
+ privileged reg165 (spr65): undefined
+ privileged reg166 (spr66): undefined
+ privileged reg167 (spr67): undefined
+ privileged reg168 (spr68): undefined
+ privileged reg169 (spr69): undefined
+ privileged reg170 (spr70): undefined
+ privileged reg171 (spr71): undefined
+ privileged reg172 (spr72): undefined
+ privileged reg173 (spr73): undefined
+ privileged reg174 (spr74): undefined
+ privileged reg175 (spr75): undefined
+ privileged reg176 (spr76): undefined
+ privileged reg177 (spr77): undefined
+ privileged reg178 (spr78): undefined
+ privileged reg179 (spr79): undefined
+ privileged reg180 (spr80): undefined
+ privileged reg181 (spr81): undefined
+ privileged reg182 (spr82): undefined
+ privileged reg183 (spr83): undefined
+ privileged reg184 (spr84): undefined
+ privileged reg185 (spr85): undefined
+ privileged reg186 (spr86): undefined
+ privileged reg187 (spr87): undefined
+ privileged reg188 (spr88): undefined
+ privileged reg189 (spr89): undefined
+ privileged reg190 (spr90): undefined
+ privileged reg191 (spr91): undefined
+ privileged reg192 (spr92): undefined
+ privileged reg193 (spr93): undefined
+ privileged reg194 (spr94): undefined
+ privileged reg195 (spr95): undefined
+ privileged reg196 (spr96): undefined
+ privileged reg197 (spr97): undefined
+ privileged reg198 (spr98): undefined
+ privileged reg199 (spr99): undefined
+ privileged reg200 (spr100): undefined
+ privileged reg201 (spr101): undefined
+ privileged reg202 (spr102): undefined
+ privileged reg203 (spr103): undefined
+ privileged reg204 (spr104): undefined
+ privileged reg205 (spr105): undefined
+ privileged reg206 (spr106): undefined
+ privileged reg207 (spr107): undefined
+ privileged reg208 (spr108): undefined
+ privileged reg209 (spr109): undefined
+ privileged reg210 (spr110): undefined
+ privileged reg211 (spr111): undefined
+ privileged reg212 (spr112): undefined
+ privileged reg213 (spr113): undefined
+ privileged reg214 (spr114): undefined
+ privileged reg215 (spr115): undefined
+ privileged reg216 (spr116): undefined
+ privileged reg217 (spr117): undefined
+ privileged reg218 (spr118): undefined
+ privileged reg219 (spr119): undefined
+ privileged reg220 (spr120): undefined
+ privileged reg221 (spr121): undefined
+ privileged reg222 (spr122): undefined
+ privileged reg223 (spr123): undefined
+ privileged reg224 (spr124): undefined
+ privileged reg225 (spr125): undefined
+ privileged reg226 (spr126): undefined
+ privileged reg227 (spr127): undefined
+ privileged reg228 (spr128): undefined
+ privileged reg229 (spr129): undefined
+ privileged reg230 (spr130): undefined
+ privileged reg231 (spr131): undefined
+ privileged reg232 (spr132): undefined
+ privileged reg233 (spr133): undefined
+ privileged reg234 (spr134): undefined
+ privileged reg235 (spr135): undefined
+ privileged reg236 (spr136): undefined
+ privileged reg237 (spr137): undefined
+ privileged reg238 (spr138): undefined
+ privileged reg239 (spr139): undefined
+ privileged reg240 (spr140): undefined
+ privileged reg241 (spr141): undefined
+ privileged reg242 (spr142): undefined
+ privileged reg243 (spr143): undefined
+ privileged reg244 (spr144): undefined
+ privileged reg245 (spr145): undefined
+ privileged reg246 (spr146): undefined
+ privileged reg247 (spr147): undefined
+ privileged reg248 (spr148): undefined
+ privileged reg249 (spr149): undefined
+ privileged reg250 (spr150): undefined
+ privileged reg251 (spr151): undefined
+ privileged reg252 (spr152): undefined
+ privileged reg253 (spr153): undefined
+ privileged reg254 (spr154): undefined
+ privileged reg255 (spr155): undefined
+ privileged reg256 (spr156): undefined
+ privileged reg257 (spr157): undefined
+ privileged reg258 (spr158): undefined
+ privileged reg259 (spr159): undefined
+ privileged reg260 (spr160): undefined
+ privileged reg261 (spr161): undefined
+ privileged reg262 (spr162): undefined
+ privileged reg263 (spr163): undefined
+ privileged reg264 (spr164): undefined
+ privileged reg265 (spr165): undefined
+ privileged reg266 (spr166): undefined
+ privileged reg267 (spr167): undefined
+ privileged reg268 (spr168): undefined
+ privileged reg269 (spr169): undefined
+ privileged reg270 (spr170): undefined
+ privileged reg271 (spr171): undefined
+ privileged reg272 (spr172): undefined
+ privileged reg273 (spr173): undefined
+ privileged reg274 (spr174): undefined
+ privileged reg275 (spr175): undefined
+ privileged reg276 (spr176): undefined
+ privileged reg277 (spr177): undefined
+ privileged reg278 (spr178): undefined
+ privileged reg279 (spr179): undefined
+ privileged reg280 (spr180): undefined
+ privileged reg281 (spr181): undefined
+ privileged reg282 (spr182): undefined
+ privileged reg283 (spr183): undefined
+ privileged reg284 (spr184): undefined
+ privileged reg285 (spr185): undefined
+ privileged reg286 (spr186): undefined
+ privileged reg287 (spr187): undefined
+ privileged reg288 (spr188): undefined
+ privileged reg289 (spr189): undefined
+ privileged reg290 (spr190): undefined
+ privileged reg291 (spr191): undefined
+ privileged reg292 (spr192): undefined
+ privileged reg293 (spr193): undefined
+ privileged reg294 (spr194): undefined
+ privileged reg295 (spr195): undefined
+ privileged reg296 (spr196): undefined
+ privileged reg297 (spr197): undefined
+ privileged reg298 (spr198): undefined
+ privileged reg299 (spr199): undefined
+ privileged reg300 (spr200): undefined
+ privileged reg301 (spr201): undefined
+ privileged reg302 (spr202): undefined
+ privileged reg303 (spr203): undefined
+ privileged reg304 (spr204): undefined
+ privileged reg305 (spr205): undefined
+ privileged reg306 (spr206): undefined
+ privileged reg307 (spr207): undefined
+ privileged reg308 (spr208): undefined
+ privileged reg309 (spr209): undefined
+ privileged reg310 (spr210): undefined
+ privileged reg311 (spr211): undefined
+ privileged reg312 (spr212): undefined
+ privileged reg313 (spr213): undefined
+ privileged reg314 (spr214): undefined
+ privileged reg315 (spr215): undefined
+ privileged reg316 (spr216): undefined
+ privileged reg317 (spr217): undefined
+ privileged reg318 (spr218): undefined
+ privileged reg319 (spr219): undefined
+ privileged reg320 (spr220): undefined
+ privileged reg321 (spr221): undefined
+ privileged reg322 (spr222): undefined
+ privileged reg323 (spr223): undefined
+ privileged reg324 (spr224): undefined
+ privileged reg325 (spr225): undefined
+ privileged reg326 (spr226): undefined
+ privileged reg327 (spr227): undefined
+ privileged reg328 (spr228): undefined
+ privileged reg329 (spr229): undefined
+ privileged reg330 (spr230): undefined
+ privileged reg331 (spr231): undefined
+ privileged reg332 (spr232): undefined
+ privileged reg333 (spr233): undefined
+ privileged reg334 (spr234): undefined
+ privileged reg335 (spr235): undefined
+ privileged reg336 (spr236): undefined
+ privileged reg337 (spr237): undefined
+ privileged reg338 (spr238): undefined
+ privileged reg339 (spr239): undefined
+ privileged reg340 (spr240): undefined
+ privileged reg341 (spr241): undefined
+ privileged reg342 (spr242): undefined
+ privileged reg343 (spr243): undefined
+ privileged reg344 (spr244): undefined
+ privileged reg345 (spr245): undefined
+ privileged reg346 (spr246): undefined
+ privileged reg347 (spr247): undefined
+ privileged reg348 (spr248): undefined
+ privileged reg349 (spr249): undefined
+ privileged reg350 (spr250): undefined
+ privileged reg351 (spr251): undefined
+ privileged reg352 (spr252): undefined
+ privileged reg353 (spr253): undefined
+ privileged reg354 (spr254): undefined
+ privileged reg355 (spr255): undefined
+ vector reg356 (vrsave): undefined
+ privileged reg357 (spr257): undefined
+ privileged reg358 (spr258): undefined
+ privileged reg359 (spr259): undefined
+ privileged reg360 (spr260): undefined
+ privileged reg361 (spr261): undefined
+ privileged reg362 (spr262): undefined
+ privileged reg363 (spr263): undefined
+ privileged reg364 (spr264): undefined
+ privileged reg365 (spr265): undefined
+ privileged reg366 (spr266): undefined
+ privileged reg367 (spr267): undefined
+ privileged reg368 (spr268): undefined
+ privileged reg369 (spr269): undefined
+ privileged reg370 (spr270): undefined
+ privileged reg371 (spr271): undefined
+ privileged reg372 (spr272): undefined
+ privileged reg373 (spr273): undefined
+ privileged reg374 (spr274): undefined
+ privileged reg375 (spr275): undefined
+ privileged reg376 (spr276): undefined
+ privileged reg377 (spr277): undefined
+ privileged reg378 (spr278): undefined
+ privileged reg379 (spr279): undefined
+ privileged reg380 (spr280): undefined
+ privileged reg381 (spr281): undefined
+ privileged reg382 (spr282): undefined
+ privileged reg383 (spr283): undefined
+ privileged reg384 (spr284): undefined
+ privileged reg385 (spr285): undefined
+ privileged reg386 (spr286): undefined
+ privileged reg387 (spr287): undefined
+ privileged reg388 (spr288): undefined
+ privileged reg389 (spr289): undefined
+ privileged reg390 (spr290): undefined
+ privileged reg391 (spr291): undefined
+ privileged reg392 (spr292): undefined
+ privileged reg393 (spr293): undefined
+ privileged reg394 (spr294): undefined
+ privileged reg395 (spr295): undefined
+ privileged reg396 (spr296): undefined
+ privileged reg397 (spr297): undefined
+ privileged reg398 (spr298): undefined
+ privileged reg399 (spr299): undefined
+ privileged reg400 (spr300): undefined
+ privileged reg401 (spr301): undefined
+ privileged reg402 (spr302): undefined
+ privileged reg403 (spr303): undefined
+ privileged reg404 (spr304): undefined
+ privileged reg405 (spr305): undefined
+ privileged reg406 (spr306): undefined
+ privileged reg407 (spr307): undefined
+ privileged reg408 (spr308): undefined
+ privileged reg409 (spr309): undefined
+ privileged reg410 (spr310): undefined
+ privileged reg411 (spr311): undefined
+ privileged reg412 (spr312): undefined
+ privileged reg413 (spr313): undefined
+ privileged reg414 (spr314): undefined
+ privileged reg415 (spr315): undefined
+ privileged reg416 (spr316): undefined
+ privileged reg417 (spr317): undefined
+ privileged reg418 (spr318): undefined
+ privileged reg419 (spr319): undefined
+ privileged reg420 (spr320): undefined
+ privileged reg421 (spr321): undefined
+ privileged reg422 (spr322): undefined
+ privileged reg423 (spr323): undefined
+ privileged reg424 (spr324): undefined
+ privileged reg425 (spr325): undefined
+ privileged reg426 (spr326): undefined
+ privileged reg427 (spr327): undefined
+ privileged reg428 (spr328): undefined
+ privileged reg429 (spr329): undefined
+ privileged reg430 (spr330): undefined
+ privileged reg431 (spr331): undefined
+ privileged reg432 (spr332): undefined
+ privileged reg433 (spr333): undefined
+ privileged reg434 (spr334): undefined
+ privileged reg435 (spr335): undefined
+ privileged reg436 (spr336): undefined
+ privileged reg437 (spr337): undefined
+ privileged reg438 (spr338): undefined
+ privileged reg439 (spr339): undefined
+ privileged reg440 (spr340): undefined
+ privileged reg441 (spr341): undefined
+ privileged reg442 (spr342): undefined
+ privileged reg443 (spr343): undefined
+ privileged reg444 (spr344): undefined
+ privileged reg445 (spr345): undefined
+ privileged reg446 (spr346): undefined
+ privileged reg447 (spr347): undefined
+ privileged reg448 (spr348): undefined
+ privileged reg449 (spr349): undefined
+ privileged reg450 (spr350): undefined
+ privileged reg451 (spr351): undefined
+ privileged reg452 (spr352): undefined
+ privileged reg453 (spr353): undefined
+ privileged reg454 (spr354): undefined
+ privileged reg455 (spr355): undefined
+ privileged reg456 (spr356): undefined
+ privileged reg457 (spr357): undefined
+ privileged reg458 (spr358): undefined
+ privileged reg459 (spr359): undefined
+ privileged reg460 (spr360): undefined
+ privileged reg461 (spr361): undefined
+ privileged reg462 (spr362): undefined
+ privileged reg463 (spr363): undefined
+ privileged reg464 (spr364): undefined
+ privileged reg465 (spr365): undefined
+ privileged reg466 (spr366): undefined
+ privileged reg467 (spr367): undefined
+ privileged reg468 (spr368): undefined
+ privileged reg469 (spr369): undefined
+ privileged reg470 (spr370): undefined
+ privileged reg471 (spr371): undefined
+ privileged reg472 (spr372): undefined
+ privileged reg473 (spr373): undefined
+ privileged reg474 (spr374): undefined
+ privileged reg475 (spr375): undefined
+ privileged reg476 (spr376): undefined
+ privileged reg477 (spr377): undefined
+ privileged reg478 (spr378): undefined
+ privileged reg479 (spr379): undefined
+ privileged reg480 (spr380): undefined
+ privileged reg481 (spr381): undefined
+ privileged reg482 (spr382): undefined
+ privileged reg483 (spr383): undefined
+ privileged reg484 (spr384): undefined
+ privileged reg485 (spr385): undefined
+ privileged reg486 (spr386): undefined
+ privileged reg487 (spr387): undefined
+ privileged reg488 (spr388): undefined
+ privileged reg489 (spr389): undefined
+ privileged reg490 (spr390): undefined
+ privileged reg491 (spr391): undefined
+ privileged reg492 (spr392): undefined
+ privileged reg493 (spr393): undefined
+ privileged reg494 (spr394): undefined
+ privileged reg495 (spr395): undefined
+ privileged reg496 (spr396): undefined
+ privileged reg497 (spr397): undefined
+ privileged reg498 (spr398): undefined
+ privileged reg499 (spr399): undefined
+ privileged reg500 (spr400): undefined
+ privileged reg501 (spr401): undefined
+ privileged reg502 (spr402): undefined
+ privileged reg503 (spr403): undefined
+ privileged reg504 (spr404): undefined
+ privileged reg505 (spr405): undefined
+ privileged reg506 (spr406): undefined
+ privileged reg507 (spr407): undefined
+ privileged reg508 (spr408): undefined
+ privileged reg509 (spr409): undefined
+ privileged reg510 (spr410): undefined
+ privileged reg511 (spr411): undefined
+ privileged reg512 (spr412): undefined
+ privileged reg513 (spr413): undefined
+ privileged reg514 (spr414): undefined
+ privileged reg515 (spr415): undefined
+ privileged reg516 (spr416): undefined
+ privileged reg517 (spr417): undefined
+ privileged reg518 (spr418): undefined
+ privileged reg519 (spr419): undefined
+ privileged reg520 (spr420): undefined
+ privileged reg521 (spr421): undefined
+ privileged reg522 (spr422): undefined
+ privileged reg523 (spr423): undefined
+ privileged reg524 (spr424): undefined
+ privileged reg525 (spr425): undefined
+ privileged reg526 (spr426): undefined
+ privileged reg527 (spr427): undefined
+ privileged reg528 (spr428): undefined
+ privileged reg529 (spr429): undefined
+ privileged reg530 (spr430): undefined
+ privileged reg531 (spr431): undefined
+ privileged reg532 (spr432): undefined
+ privileged reg533 (spr433): undefined
+ privileged reg534 (spr434): undefined
+ privileged reg535 (spr435): undefined
+ privileged reg536 (spr436): undefined
+ privileged reg537 (spr437): undefined
+ privileged reg538 (spr438): undefined
+ privileged reg539 (spr439): undefined
+ privileged reg540 (spr440): undefined
+ privileged reg541 (spr441): undefined
+ privileged reg542 (spr442): undefined
+ privileged reg543 (spr443): undefined
+ privileged reg544 (spr444): undefined
+ privileged reg545 (spr445): undefined
+ privileged reg546 (spr446): undefined
+ privileged reg547 (spr447): undefined
+ privileged reg548 (spr448): undefined
+ privileged reg549 (spr449): undefined
+ privileged reg550 (spr450): undefined
+ privileged reg551 (spr451): undefined
+ privileged reg552 (spr452): undefined
+ privileged reg553 (spr453): undefined
+ privileged reg554 (spr454): undefined
+ privileged reg555 (spr455): undefined
+ privileged reg556 (spr456): undefined
+ privileged reg557 (spr457): undefined
+ privileged reg558 (spr458): undefined
+ privileged reg559 (spr459): undefined
+ privileged reg560 (spr460): undefined
+ privileged reg561 (spr461): undefined
+ privileged reg562 (spr462): undefined
+ privileged reg563 (spr463): undefined
+ privileged reg564 (spr464): undefined
+ privileged reg565 (spr465): undefined
+ privileged reg566 (spr466): undefined
+ privileged reg567 (spr467): undefined
+ privileged reg568 (spr468): undefined
+ privileged reg569 (spr469): undefined
+ privileged reg570 (spr470): undefined
+ privileged reg571 (spr471): undefined
+ privileged reg572 (spr472): undefined
+ privileged reg573 (spr473): undefined
+ privileged reg574 (spr474): undefined
+ privileged reg575 (spr475): undefined
+ privileged reg576 (spr476): undefined
+ privileged reg577 (spr477): undefined
+ privileged reg578 (spr478): undefined
+ privileged reg579 (spr479): undefined
+ privileged reg580 (spr480): undefined
+ privileged reg581 (spr481): undefined
+ privileged reg582 (spr482): undefined
+ privileged reg583 (spr483): undefined
+ privileged reg584 (spr484): undefined
+ privileged reg585 (spr485): undefined
+ privileged reg586 (spr486): undefined
+ privileged reg587 (spr487): undefined
+ privileged reg588 (spr488): undefined
+ privileged reg589 (spr489): undefined
+ privileged reg590 (spr490): undefined
+ privileged reg591 (spr491): undefined
+ privileged reg592 (spr492): undefined
+ privileged reg593 (spr493): undefined
+ privileged reg594 (spr494): undefined
+ privileged reg595 (spr495): undefined
+ privileged reg596 (spr496): undefined
+ privileged reg597 (spr497): undefined
+ privileged reg598 (spr498): undefined
+ privileged reg599 (spr499): undefined
+ privileged reg600 (spr500): undefined
+ privileged reg601 (spr501): undefined
+ privileged reg602 (spr502): undefined
+ privileged reg603 (spr503): undefined
+ privileged reg604 (spr504): undefined
+ privileged reg605 (spr505): undefined
+ privileged reg606 (spr506): undefined
+ privileged reg607 (spr507): undefined
+ privileged reg608 (spr508): undefined
+ privileged reg609 (spr509): undefined
+ privileged reg610 (spr510): undefined
+ privileged reg611 (spr511): undefined
+ vector reg612 (spefscr): undefined
+ privileged reg613 (spr513): undefined
+ privileged reg614 (spr514): undefined
+ privileged reg615 (spr515): undefined
+ privileged reg616 (spr516): undefined
+ privileged reg617 (spr517): undefined
+ privileged reg618 (spr518): undefined
+ privileged reg619 (spr519): undefined
+ privileged reg620 (spr520): undefined
+ privileged reg621 (spr521): undefined
+ privileged reg622 (spr522): undefined
+ privileged reg623 (spr523): undefined
+ privileged reg624 (spr524): undefined
+ privileged reg625 (spr525): undefined
+ privileged reg626 (spr526): undefined
+ privileged reg627 (spr527): undefined
+ privileged reg628 (spr528): undefined
+ privileged reg629 (spr529): undefined
+ privileged reg630 (spr530): undefined
+ privileged reg631 (spr531): undefined
+ privileged reg632 (spr532): undefined
+ privileged reg633 (spr533): undefined
+ privileged reg634 (spr534): undefined
+ privileged reg635 (spr535): undefined
+ privileged reg636 (spr536): undefined
+ privileged reg637 (spr537): undefined
+ privileged reg638 (spr538): undefined
+ privileged reg639 (spr539): undefined
+ privileged reg640 (spr540): undefined
+ privileged reg641 (spr541): undefined
+ privileged reg642 (spr542): undefined
+ privileged reg643 (spr543): undefined
+ privileged reg644 (spr544): undefined
+ privileged reg645 (spr545): undefined
+ privileged reg646 (spr546): undefined
+ privileged reg647 (spr547): undefined
+ privileged reg648 (spr548): undefined
+ privileged reg649 (spr549): undefined
+ privileged reg650 (spr550): undefined
+ privileged reg651 (spr551): undefined
+ privileged reg652 (spr552): undefined
+ privileged reg653 (spr553): undefined
+ privileged reg654 (spr554): undefined
+ privileged reg655 (spr555): undefined
+ privileged reg656 (spr556): undefined
+ privileged reg657 (spr557): undefined
+ privileged reg658 (spr558): undefined
+ privileged reg659 (spr559): undefined
+ privileged reg660 (spr560): undefined
+ privileged reg661 (spr561): undefined
+ privileged reg662 (spr562): undefined
+ privileged reg663 (spr563): undefined
+ privileged reg664 (spr564): undefined
+ privileged reg665 (spr565): undefined
+ privileged reg666 (spr566): undefined
+ privileged reg667 (spr567): undefined
+ privileged reg668 (spr568): undefined
+ privileged reg669 (spr569): undefined
+ privileged reg670 (spr570): undefined
+ privileged reg671 (spr571): undefined
+ privileged reg672 (spr572): undefined
+ privileged reg673 (spr573): undefined
+ privileged reg674 (spr574): undefined
+ privileged reg675 (spr575): undefined
+ privileged reg676 (spr576): undefined
+ privileged reg677 (spr577): undefined
+ privileged reg678 (spr578): undefined
+ privileged reg679 (spr579): undefined
+ privileged reg680 (spr580): undefined
+ privileged reg681 (spr581): undefined
+ privileged reg682 (spr582): undefined
+ privileged reg683 (spr583): undefined
+ privileged reg684 (spr584): undefined
+ privileged reg685 (spr585): undefined
+ privileged reg686 (spr586): undefined
+ privileged reg687 (spr587): undefined
+ privileged reg688 (spr588): undefined
+ privileged reg689 (spr589): undefined
+ privileged reg690 (spr590): undefined
+ privileged reg691 (spr591): undefined
+ privileged reg692 (spr592): undefined
+ privileged reg693 (spr593): undefined
+ privileged reg694 (spr594): undefined
+ privileged reg695 (spr595): undefined
+ privileged reg696 (spr596): undefined
+ privileged reg697 (spr597): undefined
+ privileged reg698 (spr598): undefined
+ privileged reg699 (spr599): undefined
+ privileged reg700 (spr600): undefined
+ privileged reg701 (spr601): undefined
+ privileged reg702 (spr602): undefined
+ privileged reg703 (spr603): undefined
+ privileged reg704 (spr604): undefined
+ privileged reg705 (spr605): undefined
+ privileged reg706 (spr606): undefined
+ privileged reg707 (spr607): undefined
+ privileged reg708 (spr608): undefined
+ privileged reg709 (spr609): undefined
+ privileged reg710 (spr610): undefined
+ privileged reg711 (spr611): undefined
+ privileged reg712 (spr612): undefined
+ privileged reg713 (spr613): undefined
+ privileged reg714 (spr614): undefined
+ privileged reg715 (spr615): undefined
+ privileged reg716 (spr616): undefined
+ privileged reg717 (spr617): undefined
+ privileged reg718 (spr618): undefined
+ privileged reg719 (spr619): undefined
+ privileged reg720 (spr620): undefined
+ privileged reg721 (spr621): undefined
+ privileged reg722 (spr622): undefined
+ privileged reg723 (spr623): undefined
+ privileged reg724 (spr624): undefined
+ privileged reg725 (spr625): undefined
+ privileged reg726 (spr626): undefined
+ privileged reg727 (spr627): undefined
+ privileged reg728 (spr628): undefined
+ privileged reg729 (spr629): undefined
+ privileged reg730 (spr630): undefined
+ privileged reg731 (spr631): undefined
+ privileged reg732 (spr632): undefined
+ privileged reg733 (spr633): undefined
+ privileged reg734 (spr634): undefined
+ privileged reg735 (spr635): undefined
+ privileged reg736 (spr636): undefined
+ privileged reg737 (spr637): undefined
+ privileged reg738 (spr638): undefined
+ privileged reg739 (spr639): undefined
+ privileged reg740 (spr640): undefined
+ privileged reg741 (spr641): undefined
+ privileged reg742 (spr642): undefined
+ privileged reg743 (spr643): undefined
+ privileged reg744 (spr644): undefined
+ privileged reg745 (spr645): undefined
+ privileged reg746 (spr646): undefined
+ privileged reg747 (spr647): undefined
+ privileged reg748 (spr648): undefined
+ privileged reg749 (spr649): undefined
+ privileged reg750 (spr650): undefined
+ privileged reg751 (spr651): undefined
+ privileged reg752 (spr652): undefined
+ privileged reg753 (spr653): undefined
+ privileged reg754 (spr654): undefined
+ privileged reg755 (spr655): undefined
+ privileged reg756 (spr656): undefined
+ privileged reg757 (spr657): undefined
+ privileged reg758 (spr658): undefined
+ privileged reg759 (spr659): undefined
+ privileged reg760 (spr660): undefined
+ privileged reg761 (spr661): undefined
+ privileged reg762 (spr662): undefined
+ privileged reg763 (spr663): undefined
+ privileged reg764 (spr664): undefined
+ privileged reg765 (spr665): undefined
+ privileged reg766 (spr666): undefined
+ privileged reg767 (spr667): undefined
+ privileged reg768 (spr668): undefined
+ privileged reg769 (spr669): undefined
+ privileged reg770 (spr670): undefined
+ privileged reg771 (spr671): undefined
+ privileged reg772 (spr672): undefined
+ privileged reg773 (spr673): undefined
+ privileged reg774 (spr674): undefined
+ privileged reg775 (spr675): undefined
+ privileged reg776 (spr676): undefined
+ privileged reg777 (spr677): undefined
+ privileged reg778 (spr678): undefined
+ privileged reg779 (spr679): undefined
+ privileged reg780 (spr680): undefined
+ privileged reg781 (spr681): undefined
+ privileged reg782 (spr682): undefined
+ privileged reg783 (spr683): undefined
+ privileged reg784 (spr684): undefined
+ privileged reg785 (spr685): undefined
+ privileged reg786 (spr686): undefined
+ privileged reg787 (spr687): undefined
+ privileged reg788 (spr688): undefined
+ privileged reg789 (spr689): undefined
+ privileged reg790 (spr690): undefined
+ privileged reg791 (spr691): undefined
+ privileged reg792 (spr692): undefined
+ privileged reg793 (spr693): undefined
+ privileged reg794 (spr694): undefined
+ privileged reg795 (spr695): undefined
+ privileged reg796 (spr696): undefined
+ privileged reg797 (spr697): undefined
+ privileged reg798 (spr698): undefined
+ privileged reg799 (spr699): undefined
+ privileged reg800 (spr700): undefined
+ privileged reg801 (spr701): undefined
+ privileged reg802 (spr702): undefined
+ privileged reg803 (spr703): undefined
+ privileged reg804 (spr704): undefined
+ privileged reg805 (spr705): undefined
+ privileged reg806 (spr706): undefined
+ privileged reg807 (spr707): undefined
+ privileged reg808 (spr708): undefined
+ privileged reg809 (spr709): undefined
+ privileged reg810 (spr710): undefined
+ privileged reg811 (spr711): undefined
+ privileged reg812 (spr712): undefined
+ privileged reg813 (spr713): undefined
+ privileged reg814 (spr714): undefined
+ privileged reg815 (spr715): undefined
+ privileged reg816 (spr716): undefined
+ privileged reg817 (spr717): undefined
+ privileged reg818 (spr718): undefined
+ privileged reg819 (spr719): undefined
+ privileged reg820 (spr720): undefined
+ privileged reg821 (spr721): undefined
+ privileged reg822 (spr722): undefined
+ privileged reg823 (spr723): undefined
+ privileged reg824 (spr724): undefined
+ privileged reg825 (spr725): undefined
+ privileged reg826 (spr726): undefined
+ privileged reg827 (spr727): undefined
+ privileged reg828 (spr728): undefined
+ privileged reg829 (spr729): undefined
+ privileged reg830 (spr730): undefined
+ privileged reg831 (spr731): undefined
+ privileged reg832 (spr732): undefined
+ privileged reg833 (spr733): undefined
+ privileged reg834 (spr734): undefined
+ privileged reg835 (spr735): undefined
+ privileged reg836 (spr736): undefined
+ privileged reg837 (spr737): undefined
+ privileged reg838 (spr738): undefined
+ privileged reg839 (spr739): undefined
+ privileged reg840 (spr740): undefined
+ privileged reg841 (spr741): undefined
+ privileged reg842 (spr742): undefined
+ privileged reg843 (spr743): undefined
+ privileged reg844 (spr744): undefined
+ privileged reg845 (spr745): undefined
+ privileged reg846 (spr746): undefined
+ privileged reg847 (spr747): undefined
+ privileged reg848 (spr748): undefined
+ privileged reg849 (spr749): undefined
+ privileged reg850 (spr750): undefined
+ privileged reg851 (spr751): undefined
+ privileged reg852 (spr752): undefined
+ privileged reg853 (spr753): undefined
+ privileged reg854 (spr754): undefined
+ privileged reg855 (spr755): undefined
+ privileged reg856 (spr756): undefined
+ privileged reg857 (spr757): undefined
+ privileged reg858 (spr758): undefined
+ privileged reg859 (spr759): undefined
+ privileged reg860 (spr760): undefined
+ privileged reg861 (spr761): undefined
+ privileged reg862 (spr762): undefined
+ privileged reg863 (spr763): undefined
+ privileged reg864 (spr764): undefined
+ privileged reg865 (spr765): undefined
+ privileged reg866 (spr766): undefined
+ privileged reg867 (spr767): undefined
+ privileged reg868 (spr768): undefined
+ privileged reg869 (spr769): undefined
+ privileged reg870 (spr770): undefined
+ privileged reg871 (spr771): undefined
+ privileged reg872 (spr772): undefined
+ privileged reg873 (spr773): undefined
+ privileged reg874 (spr774): undefined
+ privileged reg875 (spr775): undefined
+ privileged reg876 (spr776): undefined
+ privileged reg877 (spr777): undefined
+ privileged reg878 (spr778): undefined
+ privileged reg879 (spr779): undefined
+ privileged reg880 (spr780): undefined
+ privileged reg881 (spr781): undefined
+ privileged reg882 (spr782): undefined
+ privileged reg883 (spr783): undefined
+ privileged reg884 (spr784): undefined
+ privileged reg885 (spr785): undefined
+ privileged reg886 (spr786): undefined
+ privileged reg887 (spr787): undefined
+ privileged reg888 (spr788): undefined
+ privileged reg889 (spr789): undefined
+ privileged reg890 (spr790): undefined
+ privileged reg891 (spr791): undefined
+ privileged reg892 (spr792): undefined
+ privileged reg893 (spr793): undefined
+ privileged reg894 (spr794): undefined
+ privileged reg895 (spr795): undefined
+ privileged reg896 (spr796): undefined
+ privileged reg897 (spr797): undefined
+ privileged reg898 (spr798): undefined
+ privileged reg899 (spr799): undefined
+ privileged reg900 (spr800): undefined
+ privileged reg901 (spr801): undefined
+ privileged reg902 (spr802): undefined
+ privileged reg903 (spr803): undefined
+ privileged reg904 (spr804): undefined
+ privileged reg905 (spr805): undefined
+ privileged reg906 (spr806): undefined
+ privileged reg907 (spr807): undefined
+ privileged reg908 (spr808): undefined
+ privileged reg909 (spr809): undefined
+ privileged reg910 (spr810): undefined
+ privileged reg911 (spr811): undefined
+ privileged reg912 (spr812): undefined
+ privileged reg913 (spr813): undefined
+ privileged reg914 (spr814): undefined
+ privileged reg915 (spr815): undefined
+ privileged reg916 (spr816): undefined
+ privileged reg917 (spr817): undefined
+ privileged reg918 (spr818): undefined
+ privileged reg919 (spr819): undefined
+ privileged reg920 (spr820): undefined
+ privileged reg921 (spr821): undefined
+ privileged reg922 (spr822): undefined
+ privileged reg923 (spr823): undefined
+ privileged reg924 (spr824): undefined
+ privileged reg925 (spr825): undefined
+ privileged reg926 (spr826): undefined
+ privileged reg927 (spr827): undefined
+ privileged reg928 (spr828): undefined
+ privileged reg929 (spr829): undefined
+ privileged reg930 (spr830): undefined
+ privileged reg931 (spr831): undefined
+ privileged reg932 (spr832): undefined
+ privileged reg933 (spr833): undefined
+ privileged reg934 (spr834): undefined
+ privileged reg935 (spr835): undefined
+ privileged reg936 (spr836): undefined
+ privileged reg937 (spr837): undefined
+ privileged reg938 (spr838): undefined
+ privileged reg939 (spr839): undefined
+ privileged reg940 (spr840): undefined
+ privileged reg941 (spr841): undefined
+ privileged reg942 (spr842): undefined
+ privileged reg943 (spr843): undefined
+ privileged reg944 (spr844): undefined
+ privileged reg945 (spr845): undefined
+ privileged reg946 (spr846): undefined
+ privileged reg947 (spr847): undefined
+ privileged reg948 (spr848): undefined
+ privileged reg949 (spr849): undefined
+ privileged reg950 (spr850): undefined
+ privileged reg951 (spr851): undefined
+ privileged reg952 (spr852): undefined
+ privileged reg953 (spr853): undefined
+ privileged reg954 (spr854): undefined
+ privileged reg955 (spr855): undefined
+ privileged reg956 (spr856): undefined
+ privileged reg957 (spr857): undefined
+ privileged reg958 (spr858): undefined
+ privileged reg959 (spr859): undefined
+ privileged reg960 (spr860): undefined
+ privileged reg961 (spr861): undefined
+ privileged reg962 (spr862): undefined
+ privileged reg963 (spr863): undefined
+ privileged reg964 (spr864): undefined
+ privileged reg965 (spr865): undefined
+ privileged reg966 (spr866): undefined
+ privileged reg967 (spr867): undefined
+ privileged reg968 (spr868): undefined
+ privileged reg969 (spr869): undefined
+ privileged reg970 (spr870): undefined
+ privileged reg971 (spr871): undefined
+ privileged reg972 (spr872): undefined
+ privileged reg973 (spr873): undefined
+ privileged reg974 (spr874): undefined
+ privileged reg975 (spr875): undefined
+ privileged reg976 (spr876): undefined
+ privileged reg977 (spr877): undefined
+ privileged reg978 (spr878): undefined
+ privileged reg979 (spr879): undefined
+ privileged reg980 (spr880): undefined
+ privileged reg981 (spr881): undefined
+ privileged reg982 (spr882): undefined
+ privileged reg983 (spr883): undefined
+ privileged reg984 (spr884): undefined
+ privileged reg985 (spr885): undefined
+ privileged reg986 (spr886): undefined
+ privileged reg987 (spr887): undefined
+ privileged reg988 (spr888): undefined
+ privileged reg989 (spr889): undefined
+ privileged reg990 (spr890): undefined
+ privileged reg991 (spr891): undefined
+ privileged reg992 (spr892): undefined
+ privileged reg993 (spr893): undefined
+ privileged reg994 (spr894): undefined
+ privileged reg995 (spr895): undefined
+ privileged reg996 (spr896): undefined
+ privileged reg997 (spr897): undefined
+ privileged reg998 (spr898): undefined
+ privileged reg999 (spr899): undefined
+ vector reg1124 (vr0): undefined
+ vector reg1125 (vr1): undefined
+ vector reg1126 (vr2): undefined
+ vector reg1127 (vr3): undefined
+ vector reg1128 (vr4): undefined
+ vector reg1129 (vr5): undefined
+ vector reg1130 (vr6): undefined
+ vector reg1131 (vr7): undefined
+ vector reg1132 (vr8): undefined
+ vector reg1133 (vr9): undefined
+ vector reg1134 (vr10): undefined
+ vector reg1135 (vr11): undefined
+ vector reg1136 (vr12): undefined
+ vector reg1137 (vr13): undefined
+ vector reg1138 (vr14): undefined
+ vector reg1139 (vr15): undefined
+ vector reg1140 (vr16): undefined
+ vector reg1141 (vr17): undefined
+ vector reg1142 (vr18): undefined
+ vector reg1143 (vr19): undefined
+ vector reg1144 (vr20): undefined
+ vector reg1145 (vr21): undefined
+ vector reg1146 (vr22): undefined
+ vector reg1147 (vr23): undefined
+ vector reg1148 (vr24): undefined
+ vector reg1149 (vr25): undefined
+ vector reg1150 (vr26): undefined
+ vector reg1151 (vr27): undefined
+ vector reg1152 (vr28): undefined
+ vector reg1153 (vr29): undefined
+ vector reg1154 (vr30): undefined
+ vector reg1155 (vr31): undefined
+EOF
+
+# EM_S390 (ELFCLASS32) (function bar 0x4004d8)
+# Note. Only in .eh_frame, there is no .debug_frame.
+# Same as PPC above but with -m31.
+testfiles testfiles390
+testrun_compare ${abs_builddir}/addrcfi -e testfiles390 0x4004d8 <<\EOF
+.eh_frame has 0x4004d8 => [0x4004d8, 0x4004e8):
+ return address in reg14
+ CFA location expression: bregx(15,96)
+ integer reg0 (%r0): undefined
+ integer reg1 (%r1): undefined
+ integer reg2 (%r2): undefined
+ integer reg3 (%r3): undefined
+ integer reg4 (%r4): undefined
+ integer reg5 (%r5): undefined
+ integer reg6 (%r6): same_value
+ integer reg7 (%r7): same_value
+ integer reg8 (%r8): same_value
+ integer reg9 (%r9): same_value
+ integer reg10 (%r10): same_value
+ integer reg11 (%r11): same_value
+ integer reg12 (%r12): same_value
+ integer reg13 (%r13): same_value
+ integer reg14 (%r14): same_value
+ integer reg15 (%r15): same_value
+ FPU reg16 (%f0): undefined
+ FPU reg17 (%f2): undefined
+ FPU reg18 (%f4): undefined
+ FPU reg19 (%f6): undefined
+ FPU reg20 (%f1): undefined
+ FPU reg21 (%f3): undefined
+ FPU reg22 (%f5): undefined
+ FPU reg23 (%f7): undefined
+ FPU reg24 (%f8): same_value
+ FPU reg25 (%f10): same_value
+ FPU reg26 (%f12): same_value
+ FPU reg27 (%f14): same_value
+ FPU reg28 (%f9): same_value
+ FPU reg29 (%f11): same_value
+ FPU reg30 (%f13): same_value
+ FPU reg31 (%f15): same_value
+ control reg32 (%c0): undefined
+ control reg33 (%c1): undefined
+ control reg34 (%c2): undefined
+ control reg35 (%c3): undefined
+ control reg36 (%c4): undefined
+ control reg37 (%c5): undefined
+ control reg38 (%c6): undefined
+ control reg39 (%c7): undefined
+ control reg40 (%c8): undefined
+ control reg41 (%c9): undefined
+ control reg42 (%c10): undefined
+ control reg43 (%c11): undefined
+ control reg44 (%c12): undefined
+ control reg45 (%c13): undefined
+ control reg46 (%c14): undefined
+ control reg47 (%c15): undefined
+ access reg48 (%a0): undefined
+ access reg49 (%a1): undefined
+ access reg50 (%a2): undefined
+ access reg51 (%a3): undefined
+ access reg52 (%a4): undefined
+ access reg53 (%a5): undefined
+ access reg54 (%a6): undefined
+ access reg55 (%a7): undefined
+ access reg56 (%a8): undefined
+ access reg57 (%a9): undefined
+ access reg58 (%a10): undefined
+ access reg59 (%a11): undefined
+ access reg60 (%a12): undefined
+ access reg61 (%a13): undefined
+ access reg62 (%a14): undefined
+ access reg63 (%a15): undefined
+ control reg64 (%pswm): undefined
+ control reg65 (%pswa): undefined
+handle_cfi no CFI (.debug_frame): no error
+EOF
+
+# EM_S390 (ELFCLASS64) (function bar 0x0000000080000510)
+# Note. Only in .eh_frame, there is no .debug_frame.
+# Same as s390 above but without -m31.
+testfiles testfiles390x
+testrun_compare ${abs_builddir}/addrcfi -e testfiles390x 0x0000000080000510 <<\EOF
+.eh_frame has 0x80000510 => [0x80000510, 0x80000524):
+ return address in reg14
+ CFA location expression: bregx(15,160)
+ integer reg0 (%r0): undefined
+ integer reg1 (%r1): undefined
+ integer reg2 (%r2): undefined
+ integer reg3 (%r3): undefined
+ integer reg4 (%r4): undefined
+ integer reg5 (%r5): undefined
+ integer reg6 (%r6): same_value
+ integer reg7 (%r7): same_value
+ integer reg8 (%r8): same_value
+ integer reg9 (%r9): same_value
+ integer reg10 (%r10): same_value
+ integer reg11 (%r11): same_value
+ integer reg12 (%r12): same_value
+ integer reg13 (%r13): same_value
+ integer reg14 (%r14): same_value
+ integer reg15 (%r15): same_value
+ FPU reg16 (%f0): undefined
+ FPU reg17 (%f2): undefined
+ FPU reg18 (%f4): undefined
+ FPU reg19 (%f6): undefined
+ FPU reg20 (%f1): undefined
+ FPU reg21 (%f3): undefined
+ FPU reg22 (%f5): undefined
+ FPU reg23 (%f7): undefined
+ FPU reg24 (%f8): same_value
+ FPU reg25 (%f10): same_value
+ FPU reg26 (%f12): same_value
+ FPU reg27 (%f14): same_value
+ FPU reg28 (%f9): same_value
+ FPU reg29 (%f11): same_value
+ FPU reg30 (%f13): same_value
+ FPU reg31 (%f15): same_value
+ control reg32 (%c0): undefined
+ control reg33 (%c1): undefined
+ control reg34 (%c2): undefined
+ control reg35 (%c3): undefined
+ control reg36 (%c4): undefined
+ control reg37 (%c5): undefined
+ control reg38 (%c6): undefined
+ control reg39 (%c7): undefined
+ control reg40 (%c8): undefined
+ control reg41 (%c9): undefined
+ control reg42 (%c10): undefined
+ control reg43 (%c11): undefined
+ control reg44 (%c12): undefined
+ control reg45 (%c13): undefined
+ control reg46 (%c14): undefined
+ control reg47 (%c15): undefined
+ access reg48 (%a0): undefined
+ access reg49 (%a1): undefined
+ access reg50 (%a2): undefined
+ access reg51 (%a3): undefined
+ access reg52 (%a4): undefined
+ access reg53 (%a5): undefined
+ access reg54 (%a6): undefined
+ access reg55 (%a7): undefined
+ access reg56 (%a8): undefined
+ access reg57 (%a9): undefined
+ access reg58 (%a10): undefined
+ access reg59 (%a11): undefined
+ access reg60 (%a12): undefined
+ access reg61 (%a13): undefined
+ access reg62 (%a14): undefined
+ access reg63 (%a15): undefined
+ control reg64 (%pswm): undefined
+ control reg65 (%pswa): undefined
+handle_cfi no CFI (.debug_frame): no error
+EOF
+
+# EM_ARM (function bar 0x00008510)
+# Note. Only in .debug_frame, the .eh_frame is actually empty.
+# Same as s390 and ppc above.
+testfiles testfilearm
+testrun_compare ${abs_builddir}/addrcfi -e testfilearm 0x00008510 <<\EOF
+dwarf_cfi_addrframe (.eh_frame): no matching address range
+.debug_frame has 0x8510 => [0x8510, 0x8524):
+ return address in reg14
+ CFA location expression: bregx(13)
+ integer reg0 (r0): undefined
+ integer reg1 (r1): undefined
+ integer reg2 (r2): undefined
+ integer reg3 (r3): undefined
+ integer reg4 (r4): same_value
+ integer reg5 (r5): same_value
+ integer reg6 (r6): same_value
+ integer reg7 (r7): same_value
+ integer reg8 (r8): same_value
+ integer reg9 (r9): undefined
+ integer reg10 (r10): same_value
+ integer reg11 (r11): same_value
+ integer reg12 (r12): undefined
+ integer reg13 (sp): location expression: call_frame_cfa stack_value
+ integer reg14 (lr): same_value
+ integer reg15 (pc): location expression: regx(14)
+ FPA reg16 (f0): undefined
+ FPA reg17 (f1): undefined
+ FPA reg18 (f2): undefined
+ FPA reg19 (f3): undefined
+ FPA reg20 (f4): undefined
+ FPA reg21 (f5): undefined
+ FPA reg22 (f6): undefined
+ FPA reg23 (f7): undefined
+ FPA reg96 (f0): undefined
+ FPA reg97 (f1): undefined
+ FPA reg98 (f2): undefined
+ FPA reg99 (f3): undefined
+ FPA reg100 (f4): undefined
+ FPA reg101 (f5): undefined
+ FPA reg102 (f6): undefined
+ FPA reg103 (f7): undefined
+ integer reg128 (spsr): undefined
+ VFP reg256 (d0): undefined
+ VFP reg257 (d1): undefined
+ VFP reg258 (d2): undefined
+ VFP reg259 (d3): undefined
+ VFP reg260 (d4): undefined
+ VFP reg261 (d5): undefined
+ VFP reg262 (d6): undefined
+ VFP reg263 (d7): undefined
+ VFP reg264 (d8): same_value
+ VFP reg265 (d9): same_value
+ VFP reg266 (d10): same_value
+ VFP reg267 (d11): same_value
+ VFP reg268 (d12): same_value
+ VFP reg269 (d13): same_value
+ VFP reg270 (d14): same_value
+ VFP reg271 (d15): same_value
+ VFP reg272 (d16): undefined
+ VFP reg273 (d17): undefined
+ VFP reg274 (d18): undefined
+ VFP reg275 (d19): undefined
+ VFP reg276 (d20): undefined
+ VFP reg277 (d21): undefined
+ VFP reg278 (d22): undefined
+ VFP reg279 (d23): undefined
+ VFP reg280 (d24): undefined
+ VFP reg281 (d25): undefined
+ VFP reg282 (d26): undefined
+ VFP reg283 (d27): undefined
+ VFP reg284 (d28): undefined
+ VFP reg285 (d29): undefined
+ VFP reg286 (d30): undefined
+ VFP reg287 (d31): undefined
+EOF
+
+# EM_AARCH64 (function bar 0x400550)
+# Same as arm, 390 and ppc above.
+# Note missing coverage in .eh_frame.
+testfiles testfileaarch64
+testrun_compare ${abs_builddir}/addrcfi -e testfileaarch64 0x400550 <<\EOF
+dwarf_cfi_addrframe (.eh_frame): no matching address range
+.debug_frame has 0x400550 => [0x400550, 0x400568):
+ return address in reg30
+ CFA location expression: bregx(31)
+ integer reg0 (x0): undefined
+ integer reg1 (x1): undefined
+ integer reg2 (x2): undefined
+ integer reg3 (x3): undefined
+ integer reg4 (x4): undefined
+ integer reg5 (x5): undefined
+ integer reg6 (x6): undefined
+ integer reg7 (x7): undefined
+ integer reg8 (x8): undefined
+ integer reg9 (x9): undefined
+ integer reg10 (x10): undefined
+ integer reg11 (x11): undefined
+ integer reg12 (x12): undefined
+ integer reg13 (x13): undefined
+ integer reg14 (x14): undefined
+ integer reg15 (x15): undefined
+ integer reg16 (x16): undefined
+ integer reg17 (x17): undefined
+ integer reg18 (x18): undefined
+ integer reg19 (x19): same_value
+ integer reg20 (x20): same_value
+ integer reg21 (x21): same_value
+ integer reg22 (x22): same_value
+ integer reg23 (x23): same_value
+ integer reg24 (x24): same_value
+ integer reg25 (x25): same_value
+ integer reg26 (x26): same_value
+ integer reg27 (x27): same_value
+ integer reg28 (x28): same_value
+ integer reg29 (x29): same_value
+ integer reg30 (x30): same_value
+ integer reg31 (sp): undefined
+ integer reg33 (elr): undefined
+ FP/SIMD reg64 (v0): undefined
+ FP/SIMD reg65 (v1): undefined
+ FP/SIMD reg66 (v2): undefined
+ FP/SIMD reg67 (v3): undefined
+ FP/SIMD reg68 (v4): undefined
+ FP/SIMD reg69 (v5): undefined
+ FP/SIMD reg70 (v6): undefined
+ FP/SIMD reg71 (v7): undefined
+ FP/SIMD reg72 (v8): same_value
+ FP/SIMD reg73 (v9): same_value
+ FP/SIMD reg74 (v10): same_value
+ FP/SIMD reg75 (v11): same_value
+ FP/SIMD reg76 (v12): same_value
+ FP/SIMD reg77 (v13): same_value
+ FP/SIMD reg78 (v14): same_value
+ FP/SIMD reg79 (v15): same_value
+ FP/SIMD reg80 (v16): undefined
+ FP/SIMD reg81 (v17): undefined
+ FP/SIMD reg82 (v18): undefined
+ FP/SIMD reg83 (v19): undefined
+ FP/SIMD reg84 (v20): undefined
+ FP/SIMD reg85 (v21): undefined
+ FP/SIMD reg86 (v22): undefined
+ FP/SIMD reg87 (v23): undefined
+ FP/SIMD reg88 (v24): undefined
+ FP/SIMD reg89 (v25): undefined
+ FP/SIMD reg90 (v26): undefined
+ FP/SIMD reg91 (v27): undefined
+ FP/SIMD reg92 (v28): undefined
+ FP/SIMD reg93 (v29): undefined
+ FP/SIMD reg94 (v30): undefined
+ FP/SIMD reg95 (v31): undefined
+EOF
+
+# EM_X86_64/ELFCLASS32 (function bar 0x00400390)
+#
+# Note. Only in .eh_frame, there is no .debug_frame.
+# Same as PPC above but with -mx32.
+testfiles testfile-x32
+testrun_compare ${abs_builddir}/addrcfi -e testfile-x32 0x00400390 <<\EOF
+.eh_frame has 0x400390 => [0x400390, 0x40039c):
+ return address in reg16
+ CFA location expression: bregx(7,8)
+ integer reg0 (%rax): same_value
+ integer reg1 (%rdx): undefined
+ integer reg2 (%rcx): undefined
+ integer reg3 (%rbx): undefined
+ integer reg4 (%rsi): undefined
+ integer reg5 (%rdi): undefined
+ integer reg6 (%rbp): same_value
+ integer reg7 (%rsp): location expression: call_frame_cfa stack_value
+ integer reg8 (%r8): undefined
+ integer reg9 (%r9): undefined
+ integer reg10 (%r10): undefined
+ integer reg11 (%r11): undefined
+ integer reg12 (%r12): same_value
+ integer reg13 (%r13): same_value
+ integer reg14 (%r14): same_value
+ integer reg15 (%r15): same_value
+ integer reg16 (%rip): location expression: call_frame_cfa plus_uconst(-8)
+ SSE reg17 (%xmm0): undefined
+ SSE reg18 (%xmm1): undefined
+ SSE reg19 (%xmm2): undefined
+ SSE reg20 (%xmm3): undefined
+ SSE reg21 (%xmm4): undefined
+ SSE reg22 (%xmm5): undefined
+ SSE reg23 (%xmm6): undefined
+ SSE reg24 (%xmm7): undefined
+ SSE reg25 (%xmm8): undefined
+ SSE reg26 (%xmm9): undefined
+ SSE reg27 (%xmm10): undefined
+ SSE reg28 (%xmm11): undefined
+ SSE reg29 (%xmm12): undefined
+ SSE reg30 (%xmm13): undefined
+ SSE reg31 (%xmm14): undefined
+ SSE reg32 (%xmm15): undefined
+ x87 reg33 (%st0): undefined
+ x87 reg34 (%st1): undefined
+ x87 reg35 (%st2): undefined
+ x87 reg36 (%st3): undefined
+ x87 reg37 (%st4): undefined
+ x87 reg38 (%st5): undefined
+ x87 reg39 (%st6): undefined
+ x87 reg40 (%st7): undefined
+ MMX reg41 (%mm0): undefined
+ MMX reg42 (%mm1): undefined
+ MMX reg43 (%mm2): undefined
+ MMX reg44 (%mm3): undefined
+ MMX reg45 (%mm4): undefined
+ MMX reg46 (%mm5): undefined
+ MMX reg47 (%mm6): undefined
+ MMX reg48 (%mm7): undefined
+ integer reg49 (%rflags): undefined
+ segment reg50 (%es): undefined
+ segment reg51 (%cs): undefined
+ segment reg52 (%ss): undefined
+ segment reg53 (%ds): undefined
+ segment reg54 (%fs): undefined
+ segment reg55 (%gs): undefined
+ segment reg58 (%fs.base): undefined
+ segment reg59 (%gs.base): undefined
+ control reg62 (%tr): undefined
+ control reg63 (%ldtr): undefined
+ control reg64 (%mxcsr): undefined
+ control reg65 (%fcw): undefined
+ control reg66 (%fsw): undefined
+handle_cfi no CFI (.debug_frame): no error
+EOF
diff --git a/tests/run-addrname-test.sh b/tests/run-addrname-test.sh
new file mode 100755
index 0000000..90e19df
--- /dev/null
+++ b/tests/run-addrname-test.sh
@@ -0,0 +1,360 @@
+#! /bin/sh
+# Copyright (C) 2007, 2008 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
+
+testfiles testfile34 testfile38 testfile41 testfile49
+
+testrun_compare ${abs_top_builddir}/src/addr2line -f -e testfile34 \
+ 0x08048074 0x08048075 0x08048076 \
+ 0x08049078 0x08048080 0x08049080 <<\EOF
+foo
+??:0
+bar
+??:0
+_etext
+??:0
+data1
+??:0
+??
+??:0
+_end
+??:0
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile38 0x02 0x10a 0x211 0x31a <<\EOF
+t1_global_outer+0x2
+??:0
+t2_global_symbol+0x2
+??:0
+t3_global_after_0+0x1
+??:0
+(.text)+0x31a
+??:0
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile41 0x1 0x104 <<\EOF
+small_global_at_large_global+0x1
+??:0
+small_global_first_at_large_global+0x1
+??:0
+EOF
+
+testfiles testfile12 testfile14
+tempfiles testmaps
+
+cat > testmaps <<EOF
+00400000-00401000 r-xp 00000000 fd:01 4006812 `pwd`/testfile14
+00500000-00501000 rw-p 00000000 fd:01 4006812 `pwd`/testfile14
+01000000-01001000 r-xp 00000000 fd:01 1234567 `pwd`/testfile12
+01100000-01011000 rw-p 00000000 fd:01 1234567 `pwd`/testfile12
+2aaaaaaab000-2aaaaaaad000 rw-p 2aaaaaaab000 00:00 0
+2aaaaaae2000-2aaaaaae3000 rw-p 2aaaaaae2000 00:00 0
+7fff61068000-7fff6107d000 rw-p 7ffffffea000 00:00 0 [stack]
+7fff611fe000-7fff61200000 r-xp 7fff611fe000 00:00 0 [vdso]
+ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps 0x40047c 0x10009db <<\EOF
+caller+0x14
+/home/drepper/local/elfutils-build/20050425/v.c:11
+foo+0xb
+/home/drepper/local/elfutils-build/20030710/u.c:5
+EOF
+
+# .section .text
+# nop #0
+#sizeless_foo:
+# nop #1
+# nop #2
+#sized_bar:
+# nop #3
+# nop #4
+#sizeless_baz:
+# nop #5
+# nop #6
+# .size sized_bar, . - sized_bar
+# nop #7
+# nop #8
+#sizeless_x:
+# nop #9
+# .org 0x100
+# nop #0
+# .globl global_outer
+#global_outer:
+# nop #1
+# nop #2
+# .globl global_in_global
+#global_in_global:
+# nop #3
+# nop #4
+# .size global_in_global, . - global_in_global
+#local_in_global:
+# nop #5
+# nop #6
+# .size local_in_global, . - local_in_global
+# nop #7
+# nop #8
+#.Lsizeless1:
+# nop #9
+# nop #10
+# .size global_outer, . - global_outer
+# nop #11
+# .org 0x200
+# nop #0
+#local_outer:
+# nop #1
+# nop #2
+# .globl global_in_local
+#global_in_local:
+# nop #3
+# nop #4
+# .size global_in_local, . - global_in_local
+#local_in_local:
+# nop #5
+# nop #6
+# .size local_in_local, . - local_in_local
+# nop #7
+# nop #8
+#.Lsizeless2:
+# nop #9
+# nop #10
+# .size local_outer, . - local_outer
+# nop #11
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile49 \
+ 0 1 2 3 4 5 6 7 8 9 \
+ 0x100 0x101 0x102 0x103 0x104 0x105 \
+ 0x106 0x107 0x108 0x109 0x10a 0x10b \
+ 0x200 0x201 0x202 0x203 0x204 0x205 \
+ 0x206 0x207 0x208 0x209 0x20a 0x20b <<\EOF
+(.text)+0
+??:0
+sizeless_foo
+??:0
+sizeless_foo+0x1
+??:0
+sized_bar
+??:0
+sized_bar+0x1
+??:0
+sized_bar+0x2
+??:0
+sized_bar+0x3
+??:0
+(.text)+0x7
+??:0
+(.text)+0x8
+??:0
+sizeless_x
+??:0
+sizeless_x+0xf7
+??:0
+global_outer
+??:0
+global_outer+0x1
+??:0
+global_in_global
+??:0
+global_in_global+0x1
+??:0
+global_outer+0x4
+??:0
+global_outer+0x5
+??:0
+global_outer+0x6
+??:0
+global_outer+0x7
+??:0
+global_outer+0x8
+??:0
+global_outer+0x9
+??:0
+(.text)+0x10b
+??:0
+(.text)+0x200
+??:0
+local_outer
+??:0
+local_outer+0x1
+??:0
+global_in_local
+??:0
+global_in_local+0x1
+??:0
+local_in_local
+??:0
+local_in_local+0x1
+??:0
+local_outer+0x6
+??:0
+local_outer+0x7
+??:0
+local_outer+0x8
+??:0
+local_outer+0x9
+??:0
+(.text)+0x20b
+??:0
+EOF
+
+# .macro global label size
+#\label: .globl \label
+# .size \label, \size
+# .endm
+# .macro weak label size
+#\label: .weak \label
+# .size \label, \size
+# .endm
+# .macro local label size
+#\label: .size \label, \size
+# .endm
+# .macro offset val
+# .ifne (. - _start) - \val
+# .err
+# .endif
+# .byte \val
+# .endm
+#
+#_start:
+# offset 0
+#
+# local glocal, 1
+# weak gweak, 1
+# global gglobal1, 2
+# global gglobal2, 1
+# global gglobal3, 1
+# offset 1
+# /* Symbols end here. */
+# offset 2
+# /* gglobal1 ends here. */
+# offset 3
+#
+# local g0local, 0
+# weak g0weak, 0
+# global g0global1, 0
+# global g0global2, 0
+# offset 4
+#
+# local wlocal, 1
+# weak wweak1, 2
+# weak wweak2, 1
+# weak wweak3, 1
+# offset 5
+# /* Symbols end here. */
+# offset 6
+# /* wweak1 ends here. */
+# offset 7
+#
+# local w0local, 0
+# weak w0weak1, 0
+# weak w0weak2, 0
+# offset 8
+#
+# local llocal1, 2
+# local llocal2, 1
+# local llocal3, 1
+# offset 9
+# /* Symbols end here. */
+# offset 10
+# /* llocal1 ends here. */
+# offset 11
+#
+# local l0local1, 0
+# local l0local2, 0
+# offset 12
+testfiles testfile64
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile64 1 4 5 8 9 c <<\EOF
+gglobal2
+??:0
+g0global2
+??:0
+wweak2
+??:0
+w0weak2
+??:0
+llocal2
+??:0
+l0local2
+??:0
+EOF
+
+testfiles testfile65
+testrun_compare ${abs_top_builddir}/src/addr2line -S --core=testfile65 0x7fff94bffa30 <<\EOF
+__vdso_time
+??:0
+EOF
+
+# .section ".text"
+# .globl _start
+# .section ".opd","aw"
+#_start: .quad .L._start,.TOC.@tocbase
+# .previous
+# .type _start, @function
+#.L._start:
+# .byte 0x7d, 0x82, 0x10, 0x08
+# .size _start,.-.L._start
+testfiles testfile66 testfile66.core
+testrun_compare ${abs_top_builddir}/src/addr2line -x -e testfile66 _start 0x2d8 0x2db 0x2dc 0x103d0 0x103d3 0x103d4<<EOF
+_start (.text)
+??:0
+_start (.text)
+??:0
+_start+0x3 (.text)
+??:0
+()+0x2dc
+??:0
+_start (.opd)
+??:0
+_start+0x3 (.opd)
+??:0
+()+0x103d4
+??:0
+EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -x -e testfile66 --core=testfile66.core _start 0x461b02d8 0x461c03d0<<\EOF
+_start (.text)
+??:0
+_start (.text)
+??:0
+_start (.opd)
+??:0
+EOF
+
+testfiles testfile69.core testfile69.so
+testrun_compare ${abs_top_builddir}/src/addr2line --core=./testfile69.core -S 0x7f0bc6a33535 0x7f0bc6a33546 <<\EOF
+libstatic+0x9
+??:0
+libglobal+0x9
+??:0
+EOF
+
+testfiles testfile70.exec testfile70.core
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile70.exec --core=testfile70.core 0x7ff2cfe9b6b5 <<\EOF
+main+0x9
+??:0
+EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S --core=testfile70.core -e testfile70.exec 0x7ff2cfe9b6b5 <<\EOF
+main+0x9
+??:0
+EOF
+
+testfiles test-core-lib.so test-core.core test-core.exec
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e test-core.exec --core=test-core.core 0x7f67f2aaf619 <<\EOF
+libfunc+0x9
+??:0
+EOF
+
+exit 0
diff --git a/tests/run-addrscopes.sh b/tests/run-addrscopes.sh
new file mode 100755
index 0000000..8f1bf0e
--- /dev/null
+++ b/tests/run-addrscopes.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2005, 2014 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
+
+testfiles testfile22
+
+testrun_compare ${abs_builddir}/addrscopes -e testfile22 0x8048353 <<\EOF
+0x8048353:
+ tests/foo.c (0x11): 0x8048348 (tests/foo.c:5) .. 0x804837c (tests/foo.c:16)
+ global [ be]
+ function (0x2e): 0x8048348 (tests/foo.c:5) .. 0x8048359 (tests/foo.c:11)
+ local [ 8f]
+EOF
+
+test_cleanup
+
+testfiles testfile24
+testrun_compare ${abs_builddir}/addrscopes -e testfile24 0x804834e <<\EOF
+0x804834e:
+ inline-test.c (0x11): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x8048360 (/home/roland/build/stock-elfutils/inline-test.c:16)
+ add (0x1d): 0x804834e (/home/roland/build/stock-elfutils/inline-test.c:3) .. 0x804834f
+ y [ 9d]
+ x [ a2]
+ x (abstract)
+ y (abstract)
+EOF
+
+exit 0
diff --git a/tests/run-aggregate-size.sh b/tests/run-aggregate-size.sh
new file mode 100755
index 0000000..08d57bb
--- /dev/null
+++ b/tests/run-aggregate-size.sh
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2014 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
+
+# char c;
+# int i;
+# long l;
+#
+# void *v;
+#
+# struct s
+# {
+# char *a;
+# int i;
+# } s;
+#
+# char ca[16];
+# int ia[32];
+# void *va[64];
+# struct s sa[8];
+
+# On x86_64 (LP64):
+# gcc -g -c -o testfile-sizes1.o sizes.c
+# clang -g -c -o testfile-sizes2.o sizes.c
+
+# const char c;
+# volatile int i;
+# const volatile long l;
+#
+# void * restrict v;
+#
+# struct s
+# {
+# const char *a;
+# volatile int i;
+# } s;
+#
+# const char ca[16];
+# volatile int ia[32];
+# const volatile void * const volatile restrict va[64];
+# struct s sa[8];
+# double d3d[3][4][5];
+#
+# typedef const int foo;
+# typedef volatile foo bar;
+# foo f;
+# bar b;
+#
+# gcc -std=c99 -g -c -o testfile-sizes3.o sizes.c
+
+# The file testfile-size4.o is hand-crafted.
+
+testfiles testfile-sizes1.o testfile-sizes2.o testfile-sizes3.o testfile-sizes4.o
+
+testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes1.o <<\EOF
+c size 1
+i size 4
+l size 8
+v size 8
+s size 16
+ca size 16
+ia size 128
+va size 512
+sa size 128
+EOF
+
+testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes2.o <<\EOF
+c size 1
+i size 4
+l size 8
+v size 8
+s size 16
+ca size 16
+ia size 128
+va size 512
+sa size 128
+EOF
+
+testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes3.o <<\EOF
+c size 1
+i size 4
+l size 8
+v size 8
+s size 16
+ca size 16
+ia size 128
+va size 512
+sa size 128
+d3d size 480
+f size 4
+b size 4
+EOF
+
+testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes4.o <<\EOF
+v size 257
+EOF
+
+exit 0
diff --git a/tests/run-alldts.sh b/tests/run-alldts.sh
new file mode 100755
index 0000000..6a9a9ec
--- /dev/null
+++ b/tests/run-alldts.sh
@@ -0,0 +1,98 @@
+#! /bin/sh
+# Copyright (C) 2011 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
+
+tempfiles testfile-alldts
+
+# This will produce "testfile-alldts" file
+testrun ${abs_builddir}/alldts
+
+testrun_compare ${abs_top_builddir}/src/readelf -d testfile-alldts <<\EOF
+
+Dynamic segment contains 66 entries:
+ Addr: 0x000001a0 Offset: 0x000078 Link to section: [ 0] ''
+ Type Value
+ NULL
+ NEEDED Shared library: [(null)]
+ PLTRELSZ 3735928559 (bytes)
+ PLTGOT 0xdeadbeef
+ HASH 0xdeadbeef
+ STRTAB 0xdeadbeef
+ SYMTAB 0xdeadbeef
+ RELA 0xdeadbeef
+ RELASZ 3735928559 (bytes)
+ RELAENT 3735928559 (bytes)
+ STRSZ 3735928559 (bytes)
+ SYMENT 3735928559 (bytes)
+ INIT 0xdeadbeef
+ FINI 0xdeadbeef
+ SONAME Library soname: [(null)]
+ RPATH Library rpath: [(null)]
+ SYMBOLIC 0xdeadbeef
+ REL 0xdeadbeef
+ RELSZ 3735928559 (bytes)
+ RELENT 3735928559 (bytes)
+ PLTREL ???
+ DEBUG
+ TEXTREL
+ JMPREL 0xdeadbeef
+ BIND_NOW
+ INIT_ARRAY 0xdeadbeef
+ FINI_ARRAY 0xdeadbeef
+ INIT_ARRAYSZ 3735928559 (bytes)
+ FINI_ARRAYSZ 3735928559 (bytes)
+ RUNPATH Library runpath: [(null)]
+ FLAGS ORIGIN SYMBOLIC TEXTREL BIND_NOW 0xdeadbee0
+ PREINIT_ARRAY 0xdeadbeef
+ PREINIT_ARRAY 0xdeadbeef
+ PREINIT_ARRAYSZ 0xdeadbeef
+ VERSYM 0xdeadbeef
+ GNU_PRELINKED 0xdeadbeef
+ GNU_CONFLICTSZ 3735928559 (bytes)
+ GNU_LIBLISTSZ 3735928559 (bytes)
+ CHECKSUM 0xdeadbeef
+ PLTPADSZ 3735928559 (bytes)
+ MOVEENT 3735928559 (bytes)
+ MOVESZ 3735928559 (bytes)
+ FEATURE_1 PARINIT CONFEXP 0xdeadbeec
+ POSFLAG_1 LAZYLOAD GROUPPERM 0xdeadbeec
+ SYMINSZ 3735928559 (bytes)
+ SYMINENT 3735928559 (bytes)
+ GNU_HASH 0xdeadbeef
+ TLSDESC_PLT 0xdeadbeef
+ TLSDESC_GOT 0xdeadbeef
+ GNU_CONFLICT 0xdeadbeef
+ GNU_LIBLIST 0xdeadbeef
+ CONFIG 0xdeadbeef
+ DEPAUDIT 0xdeadbeef
+ AUDIT 0xdeadbeef
+ PLTPAD 0xdeadbeef
+ MOVETAB 0xdeadbeef
+ SYMINFO 0xdeadbeef
+ RELACOUNT 3735928559
+ RELCOUNT 3735928559
+ FLAGS_1 NOW GLOBAL GROUP NODELETE INITFIRST NOOPEN ORIGIN TRANS INTERPOSE NODEFLIB NODUMP CONFALT DISPRELDNE DISPRELPND 0xdeac0000
+ VERDEF 0xdeadbeef
+ VERDEFNUM 3735928559
+ VERNEED 0xdeadbeef
+ VERNEEDNUM 3735928559
+ AUXILIARY 0xdeadbeef
+ FILTER 0xdeadbeef
+EOF
+
+exit 0
diff --git a/tests/run-allfcts-multi.sh b/tests/run-allfcts-multi.sh
new file mode 100755
index 0000000..ef7bb30
--- /dev/null
+++ b/tests/run-allfcts-multi.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2013 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-dwz-multi.sh
+testfiles libtestfile_multi_shared.so testfile_multi_main testfile_multi.dwz
+testfiles testfile-dwzstr testfile-dwzstr.multi
+
+testrun_compare ${abs_builddir}/allfcts testfile_multi_main libtestfile_multi_shared.so testfile-dwzstr <<\EOF
+/home/mark/src/tests/dwz/main.c:3:main
+/home/mark/src/tests/dwz/shared.c:3:call_foo
+/home/mark/src/tests/main.c:8:main
+EOF
+
+# - test-offset-loop.c
+#
+# #include <stdbool.h>
+# #include <string.h>
+# #include <errno.h>
+# void padding (int x, int y, int z) { }
+# static inline bool is_error (int err) { return err != 0; }
+# static inline int get_errno (void) { return errno; }
+# int main () { return is_error (get_errno ()); }
+#
+# gcc -g -O2 test-offset-loop.c -o test-offset-loop
+# cp test-offset-loop test-offset-loop2
+# dwz test-offset-loop test-offset-loop2 -m test-offset-loop.alt
+
+testfiles test-offset-loop test-offset-loop.alt
+tempfiles allfcts.out
+
+# Use head to capture output because the output could be infinite...
+testrun ${abs_builddir}/allfcts test-offset-loop | head -n 20 > allfcts.out
+testrun_compare cat allfcts.out <<\EOF
+/tmp/test-offset-loop.c:6:get_errno
+/tmp/test-offset-loop.c:5:is_error
+/tmp/test-offset-loop.c:4:padding
+/tmp/test-offset-loop.c:7:main
+EOF
+
+# allfcts has a too simple mechanism for setting the alt file.
+# check that if we don't set it, things still work (because libdw will
+# find the alt file for us).
+mkdir subdir
+mv test-offset-loop test-offset-loop.alt subdir/
+testrun ${abs_builddir}/allfcts subdir/test-offset-loop > allfcts.out
+testrun_compare cat allfcts.out <<\EOF
+Warning: no alt file found.
+/tmp/test-offset-loop.c:6:get_errno
+/tmp/test-offset-loop.c:5:is_error
+/tmp/test-offset-loop.c:4:padding
+/tmp/test-offset-loop.c:7:main
+EOF
+
+rm -rf subdir
+
+exit 0
diff --git a/tests/run-allfcts.sh b/tests/run-allfcts.sh
new file mode 100755
index 0000000..6eaf13c
--- /dev/null
+++ b/tests/run-allfcts.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2005, 2013 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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
+
+testfiles testfile testfile2 testfile8
+
+testrun_compare ${abs_builddir}/allfcts testfile testfile2 testfile8 <<\EOF
+/home/drepper/gnu/new-bu/build/ttt/m.c:5:main
+/home/drepper/gnu/new-bu/build/ttt/b.c:4:bar
+/home/drepper/gnu/new-bu/build/ttt/f.c:3:foo
+/shoggoth/drepper/b.c:4:bar
+/shoggoth/drepper/f.c:3:foo
+/shoggoth/drepper/m.c:5:main
+/home/drepper/gnu/elfutils/build/src/../../src/strip.c:107:main
+/home/drepper/gnu/elfutils/build/src/../../src/strip.c:159:print_version
+/home/drepper/gnu/elfutils/build/src/../../src/strip.c:173:parse_opt
+/home/drepper/gnu/elfutils/build/src/../../src/strip.c:201:more_help
+/home/drepper/gnu/elfutils/build/src/../../src/strip.c:217:process_file
+/usr/include/sys/stat.h:375:stat64
+/home/drepper/gnu/elfutils/build/src/../../src/strip.c:291:crc32_file
+/home/drepper/gnu/elfutils/build/src/../../src/strip.c:313:handle_elf
+EOF
+
+# = nested_funcs.c =
+#
+# static int
+# foo (int x)
+# {
+# int bar (int y)
+# {
+# return x - y;
+# }
+#
+# return bar (x * 2);
+# }
+#
+# int
+# main (int argc, char ** argv)
+# {
+# return foo (argc);
+# }
+#
+# gcc -g -o nested_funcs nested_funcs.c
+
+# = class_func.cxx =
+#
+# namespace foobar
+# {
+# class Foo
+# {
+# public:
+# int bar(int x);
+# };
+#
+# int Foo::bar(int x) { return x - 42; }
+# };
+#
+# int
+# main (int argc, char **argv)
+# {
+# foobar::Foo foo;
+#
+# return foo.bar (42);
+# }
+#
+# clang++ -g -o class_func class_func.cxx
+
+testfiles testfile_nested_funcs testfile_class_func
+
+testrun_compare ${abs_builddir}/allfcts testfile_nested_funcs testfile_class_func <<\EOF
+/home/mark/src/tests/nested/nested_funcs.c:2:foo
+/home/mark/src/tests/nested/nested_funcs.c:4:bar
+/home/mark/src/tests/nested/nested_funcs.c:13:main
+/home/mark/src/tests/nested/class_func.cxx:6:bar
+/home/mark/src/tests/nested/class_func.cxx:13:main
+EOF
+
+exit 0
diff --git a/tests/run-allregs.sh b/tests/run-allregs.sh
new file mode 100755
index 0000000..7ddd452
--- /dev/null
+++ b/tests/run-allregs.sh
@@ -0,0 +1,2905 @@
+#! /bin/sh
+# Copyright (C) 2005, 2006, 2007, 2012, 2013 Red Hat, Inc.
+# Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
+# 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
+
+regs_test()
+{
+ tempfiles good.regs
+ cat > good.regs
+ testfiles "$@"
+ for f; do testrun_compare ${abs_builddir}/allregs -e $f < good.regs; done
+ test_cleanup
+}
+
+regs_test testfile11 <<\EOF
+integer registers:
+ 0: %eax (eax), signed 32 bits
+ 1: %ecx (ecx), signed 32 bits
+ 2: %edx (edx), signed 32 bits
+ 3: %ebx (ebx), signed 32 bits
+ 4: %esp (esp), address 32 bits
+ 5: %ebp (ebp), address 32 bits
+ 6: %esi (esi), signed 32 bits
+ 7: %edi (edi), signed 32 bits
+ 8: %eip (eip), address 32 bits
+ 9: %eflags (eflags), unsigned 32 bits
+ 10: %trapno (trapno), unsigned 32 bits
+FPU-control registers:
+ 37: %fctrl (fctrl), unsigned 16 bits
+ 38: %fstat (fstat), unsigned 16 bits
+ 39: %mxcsr (mxcsr), unsigned 32 bits
+MMX registers:
+ 29: %mm0 (mm0), unsigned 64 bits
+ 30: %mm1 (mm1), unsigned 64 bits
+ 31: %mm2 (mm2), unsigned 64 bits
+ 32: %mm3 (mm3), unsigned 64 bits
+ 33: %mm4 (mm4), unsigned 64 bits
+ 34: %mm5 (mm5), unsigned 64 bits
+ 35: %mm6 (mm6), unsigned 64 bits
+ 36: %mm7 (mm7), unsigned 64 bits
+SSE registers:
+ 21: %xmm0 (xmm0), unsigned 128 bits
+ 22: %xmm1 (xmm1), unsigned 128 bits
+ 23: %xmm2 (xmm2), unsigned 128 bits
+ 24: %xmm3 (xmm3), unsigned 128 bits
+ 25: %xmm4 (xmm4), unsigned 128 bits
+ 26: %xmm5 (xmm5), unsigned 128 bits
+ 27: %xmm6 (xmm6), unsigned 128 bits
+ 28: %xmm7 (xmm7), unsigned 128 bits
+segment registers:
+ 40: %es (es), unsigned 16 bits
+ 41: %cs (cs), unsigned 16 bits
+ 42: %ss (ss), unsigned 16 bits
+ 43: %ds (ds), unsigned 16 bits
+ 44: %fs (fs), unsigned 16 bits
+ 45: %gs (gs), unsigned 16 bits
+x87 registers:
+ 11: %st0 (st0), float 80 bits
+ 12: %st1 (st1), float 80 bits
+ 13: %st2 (st2), float 80 bits
+ 14: %st3 (st3), float 80 bits
+ 15: %st4 (st4), float 80 bits
+ 16: %st5 (st5), float 80 bits
+ 17: %st6 (st6), float 80 bits
+ 18: %st7 (st7), float 80 bits
+EOF
+
+regs_test testfile12 <<\EOF
+integer registers:
+ 0: %rax (rax), signed 64 bits
+ 1: %rdx (rdx), signed 64 bits
+ 2: %rcx (rcx), signed 64 bits
+ 3: %rbx (rbx), signed 64 bits
+ 4: %rsi (rsi), signed 64 bits
+ 5: %rdi (rdi), signed 64 bits
+ 6: %rbp (rbp), address 64 bits
+ 7: %rsp (rsp), address 64 bits
+ 8: %r8 (r8), signed 64 bits
+ 9: %r9 (r9), signed 64 bits
+ 10: %r10 (r10), signed 64 bits
+ 11: %r11 (r11), signed 64 bits
+ 12: %r12 (r12), signed 64 bits
+ 13: %r13 (r13), signed 64 bits
+ 14: %r14 (r14), signed 64 bits
+ 15: %r15 (r15), signed 64 bits
+ 16: %rip (rip), address 64 bits
+ 49: %rflags (rflags), unsigned 64 bits
+MMX registers:
+ 41: %mm0 (mm0), unsigned 64 bits
+ 42: %mm1 (mm1), unsigned 64 bits
+ 43: %mm2 (mm2), unsigned 64 bits
+ 44: %mm3 (mm3), unsigned 64 bits
+ 45: %mm4 (mm4), unsigned 64 bits
+ 46: %mm5 (mm5), unsigned 64 bits
+ 47: %mm6 (mm6), unsigned 64 bits
+ 48: %mm7 (mm7), unsigned 64 bits
+SSE registers:
+ 17: %xmm0 (xmm0), unsigned 128 bits
+ 18: %xmm1 (xmm1), unsigned 128 bits
+ 19: %xmm2 (xmm2), unsigned 128 bits
+ 20: %xmm3 (xmm3), unsigned 128 bits
+ 21: %xmm4 (xmm4), unsigned 128 bits
+ 22: %xmm5 (xmm5), unsigned 128 bits
+ 23: %xmm6 (xmm6), unsigned 128 bits
+ 24: %xmm7 (xmm7), unsigned 128 bits
+ 25: %xmm8 (xmm8), unsigned 128 bits
+ 26: %xmm9 (xmm9), unsigned 128 bits
+ 27: %xmm10 (xmm10), unsigned 128 bits
+ 28: %xmm11 (xmm11), unsigned 128 bits
+ 29: %xmm12 (xmm12), unsigned 128 bits
+ 30: %xmm13 (xmm13), unsigned 128 bits
+ 31: %xmm14 (xmm14), unsigned 128 bits
+ 32: %xmm15 (xmm15), unsigned 128 bits
+control registers:
+ 62: %tr (tr), unsigned 64 bits
+ 63: %ldtr (ldtr), unsigned 64 bits
+ 64: %mxcsr (mxcsr), unsigned 64 bits
+ 65: %fcw (fcw), unsigned 16 bits
+ 66: %fsw (fsw), unsigned 16 bits
+segment registers:
+ 50: %es (es), unsigned 16 bits
+ 51: %cs (cs), unsigned 16 bits
+ 52: %ss (ss), unsigned 16 bits
+ 53: %ds (ds), unsigned 16 bits
+ 54: %fs (fs), unsigned 16 bits
+ 55: %gs (gs), unsigned 16 bits
+ 58: %fs.base (fs.base), address 64 bits
+ 59: %gs.base (gs.base), address 64 bits
+x87 registers:
+ 33: %st0 (st0), float 80 bits
+ 34: %st1 (st1), float 80 bits
+ 35: %st2 (st2), float 80 bits
+ 36: %st3 (st3), float 80 bits
+ 37: %st4 (st4), float 80 bits
+ 38: %st5 (st5), float 80 bits
+ 39: %st6 (st6), float 80 bits
+ 40: %st7 (st7), float 80 bits
+EOF
+
+regs_test testfile2 <<\EOF
+integer registers:
+ 0: r0 (r0), signed 32 bits
+ 1: r1 (r1), signed 32 bits
+ 2: r2 (r2), signed 32 bits
+ 3: r3 (r3), signed 32 bits
+ 4: r4 (r4), signed 32 bits
+ 5: r5 (r5), signed 32 bits
+ 6: r6 (r6), signed 32 bits
+ 7: r7 (r7), signed 32 bits
+ 8: r8 (r8), signed 32 bits
+ 9: r9 (r9), signed 32 bits
+ 10: r10 (r10), signed 32 bits
+ 11: r11 (r11), signed 32 bits
+ 12: r12 (r12), signed 32 bits
+ 13: r13 (r13), signed 32 bits
+ 14: r14 (r14), signed 32 bits
+ 15: r15 (r15), signed 32 bits
+ 16: r16 (r16), signed 32 bits
+ 17: r17 (r17), signed 32 bits
+ 18: r18 (r18), signed 32 bits
+ 19: r19 (r19), signed 32 bits
+ 20: r20 (r20), signed 32 bits
+ 21: r21 (r21), signed 32 bits
+ 22: r22 (r22), signed 32 bits
+ 23: r23 (r23), signed 32 bits
+ 24: r24 (r24), signed 32 bits
+ 25: r25 (r25), signed 32 bits
+ 26: r26 (r26), signed 32 bits
+ 27: r27 (r27), signed 32 bits
+ 28: r28 (r28), signed 32 bits
+ 29: r29 (r29), signed 32 bits
+ 30: r30 (r30), signed 32 bits
+ 31: r31 (r31), signed 32 bits
+ 64: cr (cr), unsigned 32 bits
+ 66: msr (msr), unsigned 32 bits
+FPU registers:
+ 32: f0 (f0), float 64 bits
+ 33: f1 (f1), float 64 bits
+ 34: f2 (f2), float 64 bits
+ 35: f3 (f3), float 64 bits
+ 36: f4 (f4), float 64 bits
+ 37: f5 (f5), float 64 bits
+ 38: f6 (f6), float 64 bits
+ 39: f7 (f7), float 64 bits
+ 40: f8 (f8), float 64 bits
+ 41: f9 (f9), float 64 bits
+ 42: f10 (f10), float 64 bits
+ 43: f11 (f11), float 64 bits
+ 44: f12 (f12), float 64 bits
+ 45: f13 (f13), float 64 bits
+ 46: f14 (f14), float 64 bits
+ 47: f15 (f15), float 64 bits
+ 48: f16 (f16), float 64 bits
+ 49: f17 (f17), float 64 bits
+ 50: f18 (f18), float 64 bits
+ 51: f19 (f19), float 64 bits
+ 52: f20 (f20), float 64 bits
+ 53: f21 (f21), float 64 bits
+ 54: f22 (f22), float 64 bits
+ 55: f23 (f23), float 64 bits
+ 56: f24 (f24), float 64 bits
+ 57: f25 (f25), float 64 bits
+ 58: f26 (f26), float 64 bits
+ 59: f27 (f27), float 64 bits
+ 60: f28 (f28), float 64 bits
+ 61: f29 (f29), float 64 bits
+ 62: f30 (f30), float 64 bits
+ 63: f31 (f31), float 64 bits
+ 65: fpscr (fpscr), unsigned 32 bits
+privileged registers:
+ 70: sr0 (sr0), unsigned 32 bits
+ 71: sr1 (sr1), unsigned 32 bits
+ 72: sr2 (sr2), unsigned 32 bits
+ 73: sr3 (sr3), unsigned 32 bits
+ 74: sr4 (sr4), unsigned 32 bits
+ 75: sr5 (sr5), unsigned 32 bits
+ 76: sr6 (sr6), unsigned 32 bits
+ 77: sr7 (sr7), unsigned 32 bits
+ 78: sr8 (sr8), unsigned 32 bits
+ 79: sr9 (sr9), unsigned 32 bits
+ 80: sr10 (sr10), unsigned 32 bits
+ 81: sr11 (sr11), unsigned 32 bits
+ 82: sr12 (sr12), unsigned 32 bits
+ 83: sr13 (sr13), unsigned 32 bits
+ 84: sr14 (sr14), unsigned 32 bits
+ 85: sr15 (sr15), unsigned 32 bits
+ 100: mq (mq), unsigned 32 bits
+ 101: xer (xer), unsigned 32 bits
+ 102: spr2 (spr2), unsigned 32 bits
+ 103: spr3 (spr3), unsigned 32 bits
+ 104: spr4 (spr4), unsigned 32 bits
+ 105: spr5 (spr5), unsigned 32 bits
+ 106: spr6 (spr6), unsigned 32 bits
+ 107: spr7 (spr7), unsigned 32 bits
+ 108: lr (lr), unsigned 32 bits
+ 109: ctr (ctr), unsigned 32 bits
+ 110: spr10 (spr10), unsigned 32 bits
+ 111: spr11 (spr11), unsigned 32 bits
+ 112: spr12 (spr12), unsigned 32 bits
+ 113: spr13 (spr13), unsigned 32 bits
+ 114: tfhar (tfhar), unsigned 32 bits
+ 115: tfiar (tfiar), unsigned 32 bits
+ 116: texasr (texasr), unsigned 32 bits
+ 117: spr17 (spr17), unsigned 32 bits
+ 118: dsisr (dsisr), unsigned 32 bits
+ 119: dar (dar), unsigned 32 bits
+ 120: spr20 (spr20), unsigned 32 bits
+ 121: spr21 (spr21), unsigned 32 bits
+ 122: dec (dec), unsigned 32 bits
+ 123: spr23 (spr23), unsigned 32 bits
+ 124: spr24 (spr24), unsigned 32 bits
+ 125: spr25 (spr25), unsigned 32 bits
+ 126: spr26 (spr26), unsigned 32 bits
+ 127: spr27 (spr27), unsigned 32 bits
+ 128: spr28 (spr28), unsigned 32 bits
+ 129: spr29 (spr29), unsigned 32 bits
+ 130: spr30 (spr30), unsigned 32 bits
+ 131: spr31 (spr31), unsigned 32 bits
+ 132: spr32 (spr32), unsigned 32 bits
+ 133: spr33 (spr33), unsigned 32 bits
+ 134: spr34 (spr34), unsigned 32 bits
+ 135: spr35 (spr35), unsigned 32 bits
+ 136: spr36 (spr36), unsigned 32 bits
+ 137: spr37 (spr37), unsigned 32 bits
+ 138: spr38 (spr38), unsigned 32 bits
+ 139: spr39 (spr39), unsigned 32 bits
+ 140: spr40 (spr40), unsigned 32 bits
+ 141: spr41 (spr41), unsigned 32 bits
+ 142: spr42 (spr42), unsigned 32 bits
+ 143: spr43 (spr43), unsigned 32 bits
+ 144: spr44 (spr44), unsigned 32 bits
+ 145: spr45 (spr45), unsigned 32 bits
+ 146: spr46 (spr46), unsigned 32 bits
+ 147: spr47 (spr47), unsigned 32 bits
+ 148: spr48 (spr48), unsigned 32 bits
+ 149: spr49 (spr49), unsigned 32 bits
+ 150: spr50 (spr50), unsigned 32 bits
+ 151: spr51 (spr51), unsigned 32 bits
+ 152: spr52 (spr52), unsigned 32 bits
+ 153: spr53 (spr53), unsigned 32 bits
+ 154: spr54 (spr54), unsigned 32 bits
+ 155: spr55 (spr55), unsigned 32 bits
+ 156: spr56 (spr56), unsigned 32 bits
+ 157: spr57 (spr57), unsigned 32 bits
+ 158: spr58 (spr58), unsigned 32 bits
+ 159: spr59 (spr59), unsigned 32 bits
+ 160: spr60 (spr60), unsigned 32 bits
+ 161: spr61 (spr61), unsigned 32 bits
+ 162: spr62 (spr62), unsigned 32 bits
+ 163: spr63 (spr63), unsigned 32 bits
+ 164: spr64 (spr64), unsigned 32 bits
+ 165: spr65 (spr65), unsigned 32 bits
+ 166: spr66 (spr66), unsigned 32 bits
+ 167: spr67 (spr67), unsigned 32 bits
+ 168: spr68 (spr68), unsigned 32 bits
+ 169: spr69 (spr69), unsigned 32 bits
+ 170: spr70 (spr70), unsigned 32 bits
+ 171: spr71 (spr71), unsigned 32 bits
+ 172: spr72 (spr72), unsigned 32 bits
+ 173: spr73 (spr73), unsigned 32 bits
+ 174: spr74 (spr74), unsigned 32 bits
+ 175: spr75 (spr75), unsigned 32 bits
+ 176: spr76 (spr76), unsigned 32 bits
+ 177: spr77 (spr77), unsigned 32 bits
+ 178: spr78 (spr78), unsigned 32 bits
+ 179: spr79 (spr79), unsigned 32 bits
+ 180: spr80 (spr80), unsigned 32 bits
+ 181: spr81 (spr81), unsigned 32 bits
+ 182: spr82 (spr82), unsigned 32 bits
+ 183: spr83 (spr83), unsigned 32 bits
+ 184: spr84 (spr84), unsigned 32 bits
+ 185: spr85 (spr85), unsigned 32 bits
+ 186: spr86 (spr86), unsigned 32 bits
+ 187: spr87 (spr87), unsigned 32 bits
+ 188: spr88 (spr88), unsigned 32 bits
+ 189: spr89 (spr89), unsigned 32 bits
+ 190: spr90 (spr90), unsigned 32 bits
+ 191: spr91 (spr91), unsigned 32 bits
+ 192: spr92 (spr92), unsigned 32 bits
+ 193: spr93 (spr93), unsigned 32 bits
+ 194: spr94 (spr94), unsigned 32 bits
+ 195: spr95 (spr95), unsigned 32 bits
+ 196: spr96 (spr96), unsigned 32 bits
+ 197: spr97 (spr97), unsigned 32 bits
+ 198: spr98 (spr98), unsigned 32 bits
+ 199: spr99 (spr99), unsigned 32 bits
+ 200: spr100 (spr100), unsigned 32 bits
+ 201: spr101 (spr101), unsigned 32 bits
+ 202: spr102 (spr102), unsigned 32 bits
+ 203: spr103 (spr103), unsigned 32 bits
+ 204: spr104 (spr104), unsigned 32 bits
+ 205: spr105 (spr105), unsigned 32 bits
+ 206: spr106 (spr106), unsigned 32 bits
+ 207: spr107 (spr107), unsigned 32 bits
+ 208: spr108 (spr108), unsigned 32 bits
+ 209: spr109 (spr109), unsigned 32 bits
+ 210: spr110 (spr110), unsigned 32 bits
+ 211: spr111 (spr111), unsigned 32 bits
+ 212: spr112 (spr112), unsigned 32 bits
+ 213: spr113 (spr113), unsigned 32 bits
+ 214: spr114 (spr114), unsigned 32 bits
+ 215: spr115 (spr115), unsigned 32 bits
+ 216: spr116 (spr116), unsigned 32 bits
+ 217: spr117 (spr117), unsigned 32 bits
+ 218: spr118 (spr118), unsigned 32 bits
+ 219: spr119 (spr119), unsigned 32 bits
+ 220: spr120 (spr120), unsigned 32 bits
+ 221: spr121 (spr121), unsigned 32 bits
+ 222: spr122 (spr122), unsigned 32 bits
+ 223: spr123 (spr123), unsigned 32 bits
+ 224: spr124 (spr124), unsigned 32 bits
+ 225: spr125 (spr125), unsigned 32 bits
+ 226: spr126 (spr126), unsigned 32 bits
+ 227: spr127 (spr127), unsigned 32 bits
+ 228: spr128 (spr128), unsigned 32 bits
+ 229: spr129 (spr129), unsigned 32 bits
+ 230: spr130 (spr130), unsigned 32 bits
+ 231: spr131 (spr131), unsigned 32 bits
+ 232: spr132 (spr132), unsigned 32 bits
+ 233: spr133 (spr133), unsigned 32 bits
+ 234: spr134 (spr134), unsigned 32 bits
+ 235: spr135 (spr135), unsigned 32 bits
+ 236: spr136 (spr136), unsigned 32 bits
+ 237: spr137 (spr137), unsigned 32 bits
+ 238: spr138 (spr138), unsigned 32 bits
+ 239: spr139 (spr139), unsigned 32 bits
+ 240: spr140 (spr140), unsigned 32 bits
+ 241: spr141 (spr141), unsigned 32 bits
+ 242: spr142 (spr142), unsigned 32 bits
+ 243: spr143 (spr143), unsigned 32 bits
+ 244: spr144 (spr144), unsigned 32 bits
+ 245: spr145 (spr145), unsigned 32 bits
+ 246: spr146 (spr146), unsigned 32 bits
+ 247: spr147 (spr147), unsigned 32 bits
+ 248: spr148 (spr148), unsigned 32 bits
+ 249: spr149 (spr149), unsigned 32 bits
+ 250: spr150 (spr150), unsigned 32 bits
+ 251: spr151 (spr151), unsigned 32 bits
+ 252: spr152 (spr152), unsigned 32 bits
+ 253: spr153 (spr153), unsigned 32 bits
+ 254: spr154 (spr154), unsigned 32 bits
+ 255: spr155 (spr155), unsigned 32 bits
+ 256: spr156 (spr156), unsigned 32 bits
+ 257: spr157 (spr157), unsigned 32 bits
+ 258: spr158 (spr158), unsigned 32 bits
+ 259: spr159 (spr159), unsigned 32 bits
+ 260: spr160 (spr160), unsigned 32 bits
+ 261: spr161 (spr161), unsigned 32 bits
+ 262: spr162 (spr162), unsigned 32 bits
+ 263: spr163 (spr163), unsigned 32 bits
+ 264: spr164 (spr164), unsigned 32 bits
+ 265: spr165 (spr165), unsigned 32 bits
+ 266: spr166 (spr166), unsigned 32 bits
+ 267: spr167 (spr167), unsigned 32 bits
+ 268: spr168 (spr168), unsigned 32 bits
+ 269: spr169 (spr169), unsigned 32 bits
+ 270: spr170 (spr170), unsigned 32 bits
+ 271: spr171 (spr171), unsigned 32 bits
+ 272: spr172 (spr172), unsigned 32 bits
+ 273: spr173 (spr173), unsigned 32 bits
+ 274: spr174 (spr174), unsigned 32 bits
+ 275: spr175 (spr175), unsigned 32 bits
+ 276: spr176 (spr176), unsigned 32 bits
+ 277: spr177 (spr177), unsigned 32 bits
+ 278: spr178 (spr178), unsigned 32 bits
+ 279: spr179 (spr179), unsigned 32 bits
+ 280: spr180 (spr180), unsigned 32 bits
+ 281: spr181 (spr181), unsigned 32 bits
+ 282: spr182 (spr182), unsigned 32 bits
+ 283: spr183 (spr183), unsigned 32 bits
+ 284: spr184 (spr184), unsigned 32 bits
+ 285: spr185 (spr185), unsigned 32 bits
+ 286: spr186 (spr186), unsigned 32 bits
+ 287: spr187 (spr187), unsigned 32 bits
+ 288: spr188 (spr188), unsigned 32 bits
+ 289: spr189 (spr189), unsigned 32 bits
+ 290: spr190 (spr190), unsigned 32 bits
+ 291: spr191 (spr191), unsigned 32 bits
+ 292: spr192 (spr192), unsigned 32 bits
+ 293: spr193 (spr193), unsigned 32 bits
+ 294: spr194 (spr194), unsigned 32 bits
+ 295: spr195 (spr195), unsigned 32 bits
+ 296: spr196 (spr196), unsigned 32 bits
+ 297: spr197 (spr197), unsigned 32 bits
+ 298: spr198 (spr198), unsigned 32 bits
+ 299: spr199 (spr199), unsigned 32 bits
+ 300: spr200 (spr200), unsigned 32 bits
+ 301: spr201 (spr201), unsigned 32 bits
+ 302: spr202 (spr202), unsigned 32 bits
+ 303: spr203 (spr203), unsigned 32 bits
+ 304: spr204 (spr204), unsigned 32 bits
+ 305: spr205 (spr205), unsigned 32 bits
+ 306: spr206 (spr206), unsigned 32 bits
+ 307: spr207 (spr207), unsigned 32 bits
+ 308: spr208 (spr208), unsigned 32 bits
+ 309: spr209 (spr209), unsigned 32 bits
+ 310: spr210 (spr210), unsigned 32 bits
+ 311: spr211 (spr211), unsigned 32 bits
+ 312: spr212 (spr212), unsigned 32 bits
+ 313: spr213 (spr213), unsigned 32 bits
+ 314: spr214 (spr214), unsigned 32 bits
+ 315: spr215 (spr215), unsigned 32 bits
+ 316: spr216 (spr216), unsigned 32 bits
+ 317: spr217 (spr217), unsigned 32 bits
+ 318: spr218 (spr218), unsigned 32 bits
+ 319: spr219 (spr219), unsigned 32 bits
+ 320: spr220 (spr220), unsigned 32 bits
+ 321: spr221 (spr221), unsigned 32 bits
+ 322: spr222 (spr222), unsigned 32 bits
+ 323: spr223 (spr223), unsigned 32 bits
+ 324: spr224 (spr224), unsigned 32 bits
+ 325: spr225 (spr225), unsigned 32 bits
+ 326: spr226 (spr226), unsigned 32 bits
+ 327: spr227 (spr227), unsigned 32 bits
+ 328: spr228 (spr228), unsigned 32 bits
+ 329: spr229 (spr229), unsigned 32 bits
+ 330: spr230 (spr230), unsigned 32 bits
+ 331: spr231 (spr231), unsigned 32 bits
+ 332: spr232 (spr232), unsigned 32 bits
+ 333: spr233 (spr233), unsigned 32 bits
+ 334: spr234 (spr234), unsigned 32 bits
+ 335: spr235 (spr235), unsigned 32 bits
+ 336: spr236 (spr236), unsigned 32 bits
+ 337: spr237 (spr237), unsigned 32 bits
+ 338: spr238 (spr238), unsigned 32 bits
+ 339: spr239 (spr239), unsigned 32 bits
+ 340: spr240 (spr240), unsigned 32 bits
+ 341: spr241 (spr241), unsigned 32 bits
+ 342: spr242 (spr242), unsigned 32 bits
+ 343: spr243 (spr243), unsigned 32 bits
+ 344: spr244 (spr244), unsigned 32 bits
+ 345: spr245 (spr245), unsigned 32 bits
+ 346: spr246 (spr246), unsigned 32 bits
+ 347: spr247 (spr247), unsigned 32 bits
+ 348: spr248 (spr248), unsigned 32 bits
+ 349: spr249 (spr249), unsigned 32 bits
+ 350: spr250 (spr250), unsigned 32 bits
+ 351: spr251 (spr251), unsigned 32 bits
+ 352: spr252 (spr252), unsigned 32 bits
+ 353: spr253 (spr253), unsigned 32 bits
+ 354: spr254 (spr254), unsigned 32 bits
+ 355: spr255 (spr255), unsigned 32 bits
+ 357: spr257 (spr257), unsigned 32 bits
+ 358: spr258 (spr258), unsigned 32 bits
+ 359: spr259 (spr259), unsigned 32 bits
+ 360: spr260 (spr260), unsigned 32 bits
+ 361: spr261 (spr261), unsigned 32 bits
+ 362: spr262 (spr262), unsigned 32 bits
+ 363: spr263 (spr263), unsigned 32 bits
+ 364: spr264 (spr264), unsigned 32 bits
+ 365: spr265 (spr265), unsigned 32 bits
+ 366: spr266 (spr266), unsigned 32 bits
+ 367: spr267 (spr267), unsigned 32 bits
+ 368: spr268 (spr268), unsigned 32 bits
+ 369: spr269 (spr269), unsigned 32 bits
+ 370: spr270 (spr270), unsigned 32 bits
+ 371: spr271 (spr271), unsigned 32 bits
+ 372: spr272 (spr272), unsigned 32 bits
+ 373: spr273 (spr273), unsigned 32 bits
+ 374: spr274 (spr274), unsigned 32 bits
+ 375: spr275 (spr275), unsigned 32 bits
+ 376: spr276 (spr276), unsigned 32 bits
+ 377: spr277 (spr277), unsigned 32 bits
+ 378: spr278 (spr278), unsigned 32 bits
+ 379: spr279 (spr279), unsigned 32 bits
+ 380: spr280 (spr280), unsigned 32 bits
+ 381: spr281 (spr281), unsigned 32 bits
+ 382: spr282 (spr282), unsigned 32 bits
+ 383: spr283 (spr283), unsigned 32 bits
+ 384: spr284 (spr284), unsigned 32 bits
+ 385: spr285 (spr285), unsigned 32 bits
+ 386: spr286 (spr286), unsigned 32 bits
+ 387: spr287 (spr287), unsigned 32 bits
+ 388: spr288 (spr288), unsigned 32 bits
+ 389: spr289 (spr289), unsigned 32 bits
+ 390: spr290 (spr290), unsigned 32 bits
+ 391: spr291 (spr291), unsigned 32 bits
+ 392: spr292 (spr292), unsigned 32 bits
+ 393: spr293 (spr293), unsigned 32 bits
+ 394: spr294 (spr294), unsigned 32 bits
+ 395: spr295 (spr295), unsigned 32 bits
+ 396: spr296 (spr296), unsigned 32 bits
+ 397: spr297 (spr297), unsigned 32 bits
+ 398: spr298 (spr298), unsigned 32 bits
+ 399: spr299 (spr299), unsigned 32 bits
+ 400: spr300 (spr300), unsigned 32 bits
+ 401: spr301 (spr301), unsigned 32 bits
+ 402: spr302 (spr302), unsigned 32 bits
+ 403: spr303 (spr303), unsigned 32 bits
+ 404: spr304 (spr304), unsigned 32 bits
+ 405: spr305 (spr305), unsigned 32 bits
+ 406: spr306 (spr306), unsigned 32 bits
+ 407: spr307 (spr307), unsigned 32 bits
+ 408: spr308 (spr308), unsigned 32 bits
+ 409: spr309 (spr309), unsigned 32 bits
+ 410: spr310 (spr310), unsigned 32 bits
+ 411: spr311 (spr311), unsigned 32 bits
+ 412: spr312 (spr312), unsigned 32 bits
+ 413: spr313 (spr313), unsigned 32 bits
+ 414: spr314 (spr314), unsigned 32 bits
+ 415: spr315 (spr315), unsigned 32 bits
+ 416: spr316 (spr316), unsigned 32 bits
+ 417: spr317 (spr317), unsigned 32 bits
+ 418: spr318 (spr318), unsigned 32 bits
+ 419: spr319 (spr319), unsigned 32 bits
+ 420: spr320 (spr320), unsigned 32 bits
+ 421: spr321 (spr321), unsigned 32 bits
+ 422: spr322 (spr322), unsigned 32 bits
+ 423: spr323 (spr323), unsigned 32 bits
+ 424: spr324 (spr324), unsigned 32 bits
+ 425: spr325 (spr325), unsigned 32 bits
+ 426: spr326 (spr326), unsigned 32 bits
+ 427: spr327 (spr327), unsigned 32 bits
+ 428: spr328 (spr328), unsigned 32 bits
+ 429: spr329 (spr329), unsigned 32 bits
+ 430: spr330 (spr330), unsigned 32 bits
+ 431: spr331 (spr331), unsigned 32 bits
+ 432: spr332 (spr332), unsigned 32 bits
+ 433: spr333 (spr333), unsigned 32 bits
+ 434: spr334 (spr334), unsigned 32 bits
+ 435: spr335 (spr335), unsigned 32 bits
+ 436: spr336 (spr336), unsigned 32 bits
+ 437: spr337 (spr337), unsigned 32 bits
+ 438: spr338 (spr338), unsigned 32 bits
+ 439: spr339 (spr339), unsigned 32 bits
+ 440: spr340 (spr340), unsigned 32 bits
+ 441: spr341 (spr341), unsigned 32 bits
+ 442: spr342 (spr342), unsigned 32 bits
+ 443: spr343 (spr343), unsigned 32 bits
+ 444: spr344 (spr344), unsigned 32 bits
+ 445: spr345 (spr345), unsigned 32 bits
+ 446: spr346 (spr346), unsigned 32 bits
+ 447: spr347 (spr347), unsigned 32 bits
+ 448: spr348 (spr348), unsigned 32 bits
+ 449: spr349 (spr349), unsigned 32 bits
+ 450: spr350 (spr350), unsigned 32 bits
+ 451: spr351 (spr351), unsigned 32 bits
+ 452: spr352 (spr352), unsigned 32 bits
+ 453: spr353 (spr353), unsigned 32 bits
+ 454: spr354 (spr354), unsigned 32 bits
+ 455: spr355 (spr355), unsigned 32 bits
+ 456: spr356 (spr356), unsigned 32 bits
+ 457: spr357 (spr357), unsigned 32 bits
+ 458: spr358 (spr358), unsigned 32 bits
+ 459: spr359 (spr359), unsigned 32 bits
+ 460: spr360 (spr360), unsigned 32 bits
+ 461: spr361 (spr361), unsigned 32 bits
+ 462: spr362 (spr362), unsigned 32 bits
+ 463: spr363 (spr363), unsigned 32 bits
+ 464: spr364 (spr364), unsigned 32 bits
+ 465: spr365 (spr365), unsigned 32 bits
+ 466: spr366 (spr366), unsigned 32 bits
+ 467: spr367 (spr367), unsigned 32 bits
+ 468: spr368 (spr368), unsigned 32 bits
+ 469: spr369 (spr369), unsigned 32 bits
+ 470: spr370 (spr370), unsigned 32 bits
+ 471: spr371 (spr371), unsigned 32 bits
+ 472: spr372 (spr372), unsigned 32 bits
+ 473: spr373 (spr373), unsigned 32 bits
+ 474: spr374 (spr374), unsigned 32 bits
+ 475: spr375 (spr375), unsigned 32 bits
+ 476: spr376 (spr376), unsigned 32 bits
+ 477: spr377 (spr377), unsigned 32 bits
+ 478: spr378 (spr378), unsigned 32 bits
+ 479: spr379 (spr379), unsigned 32 bits
+ 480: spr380 (spr380), unsigned 32 bits
+ 481: spr381 (spr381), unsigned 32 bits
+ 482: spr382 (spr382), unsigned 32 bits
+ 483: spr383 (spr383), unsigned 32 bits
+ 484: spr384 (spr384), unsigned 32 bits
+ 485: spr385 (spr385), unsigned 32 bits
+ 486: spr386 (spr386), unsigned 32 bits
+ 487: spr387 (spr387), unsigned 32 bits
+ 488: spr388 (spr388), unsigned 32 bits
+ 489: spr389 (spr389), unsigned 32 bits
+ 490: spr390 (spr390), unsigned 32 bits
+ 491: spr391 (spr391), unsigned 32 bits
+ 492: spr392 (spr392), unsigned 32 bits
+ 493: spr393 (spr393), unsigned 32 bits
+ 494: spr394 (spr394), unsigned 32 bits
+ 495: spr395 (spr395), unsigned 32 bits
+ 496: spr396 (spr396), unsigned 32 bits
+ 497: spr397 (spr397), unsigned 32 bits
+ 498: spr398 (spr398), unsigned 32 bits
+ 499: spr399 (spr399), unsigned 32 bits
+ 500: spr400 (spr400), unsigned 32 bits
+ 501: spr401 (spr401), unsigned 32 bits
+ 502: spr402 (spr402), unsigned 32 bits
+ 503: spr403 (spr403), unsigned 32 bits
+ 504: spr404 (spr404), unsigned 32 bits
+ 505: spr405 (spr405), unsigned 32 bits
+ 506: spr406 (spr406), unsigned 32 bits
+ 507: spr407 (spr407), unsigned 32 bits
+ 508: spr408 (spr408), unsigned 32 bits
+ 509: spr409 (spr409), unsigned 32 bits
+ 510: spr410 (spr410), unsigned 32 bits
+ 511: spr411 (spr411), unsigned 32 bits
+ 512: spr412 (spr412), unsigned 32 bits
+ 513: spr413 (spr413), unsigned 32 bits
+ 514: spr414 (spr414), unsigned 32 bits
+ 515: spr415 (spr415), unsigned 32 bits
+ 516: spr416 (spr416), unsigned 32 bits
+ 517: spr417 (spr417), unsigned 32 bits
+ 518: spr418 (spr418), unsigned 32 bits
+ 519: spr419 (spr419), unsigned 32 bits
+ 520: spr420 (spr420), unsigned 32 bits
+ 521: spr421 (spr421), unsigned 32 bits
+ 522: spr422 (spr422), unsigned 32 bits
+ 523: spr423 (spr423), unsigned 32 bits
+ 524: spr424 (spr424), unsigned 32 bits
+ 525: spr425 (spr425), unsigned 32 bits
+ 526: spr426 (spr426), unsigned 32 bits
+ 527: spr427 (spr427), unsigned 32 bits
+ 528: spr428 (spr428), unsigned 32 bits
+ 529: spr429 (spr429), unsigned 32 bits
+ 530: spr430 (spr430), unsigned 32 bits
+ 531: spr431 (spr431), unsigned 32 bits
+ 532: spr432 (spr432), unsigned 32 bits
+ 533: spr433 (spr433), unsigned 32 bits
+ 534: spr434 (spr434), unsigned 32 bits
+ 535: spr435 (spr435), unsigned 32 bits
+ 536: spr436 (spr436), unsigned 32 bits
+ 537: spr437 (spr437), unsigned 32 bits
+ 538: spr438 (spr438), unsigned 32 bits
+ 539: spr439 (spr439), unsigned 32 bits
+ 540: spr440 (spr440), unsigned 32 bits
+ 541: spr441 (spr441), unsigned 32 bits
+ 542: spr442 (spr442), unsigned 32 bits
+ 543: spr443 (spr443), unsigned 32 bits
+ 544: spr444 (spr444), unsigned 32 bits
+ 545: spr445 (spr445), unsigned 32 bits
+ 546: spr446 (spr446), unsigned 32 bits
+ 547: spr447 (spr447), unsigned 32 bits
+ 548: spr448 (spr448), unsigned 32 bits
+ 549: spr449 (spr449), unsigned 32 bits
+ 550: spr450 (spr450), unsigned 32 bits
+ 551: spr451 (spr451), unsigned 32 bits
+ 552: spr452 (spr452), unsigned 32 bits
+ 553: spr453 (spr453), unsigned 32 bits
+ 554: spr454 (spr454), unsigned 32 bits
+ 555: spr455 (spr455), unsigned 32 bits
+ 556: spr456 (spr456), unsigned 32 bits
+ 557: spr457 (spr457), unsigned 32 bits
+ 558: spr458 (spr458), unsigned 32 bits
+ 559: spr459 (spr459), unsigned 32 bits
+ 560: spr460 (spr460), unsigned 32 bits
+ 561: spr461 (spr461), unsigned 32 bits
+ 562: spr462 (spr462), unsigned 32 bits
+ 563: spr463 (spr463), unsigned 32 bits
+ 564: spr464 (spr464), unsigned 32 bits
+ 565: spr465 (spr465), unsigned 32 bits
+ 566: spr466 (spr466), unsigned 32 bits
+ 567: spr467 (spr467), unsigned 32 bits
+ 568: spr468 (spr468), unsigned 32 bits
+ 569: spr469 (spr469), unsigned 32 bits
+ 570: spr470 (spr470), unsigned 32 bits
+ 571: spr471 (spr471), unsigned 32 bits
+ 572: spr472 (spr472), unsigned 32 bits
+ 573: spr473 (spr473), unsigned 32 bits
+ 574: spr474 (spr474), unsigned 32 bits
+ 575: spr475 (spr475), unsigned 32 bits
+ 576: spr476 (spr476), unsigned 32 bits
+ 577: spr477 (spr477), unsigned 32 bits
+ 578: spr478 (spr478), unsigned 32 bits
+ 579: spr479 (spr479), unsigned 32 bits
+ 580: spr480 (spr480), unsigned 32 bits
+ 581: spr481 (spr481), unsigned 32 bits
+ 582: spr482 (spr482), unsigned 32 bits
+ 583: spr483 (spr483), unsigned 32 bits
+ 584: spr484 (spr484), unsigned 32 bits
+ 585: spr485 (spr485), unsigned 32 bits
+ 586: spr486 (spr486), unsigned 32 bits
+ 587: spr487 (spr487), unsigned 32 bits
+ 588: spr488 (spr488), unsigned 32 bits
+ 589: spr489 (spr489), unsigned 32 bits
+ 590: spr490 (spr490), unsigned 32 bits
+ 591: spr491 (spr491), unsigned 32 bits
+ 592: spr492 (spr492), unsigned 32 bits
+ 593: spr493 (spr493), unsigned 32 bits
+ 594: spr494 (spr494), unsigned 32 bits
+ 595: spr495 (spr495), unsigned 32 bits
+ 596: spr496 (spr496), unsigned 32 bits
+ 597: spr497 (spr497), unsigned 32 bits
+ 598: spr498 (spr498), unsigned 32 bits
+ 599: spr499 (spr499), unsigned 32 bits
+ 600: spr500 (spr500), unsigned 32 bits
+ 601: spr501 (spr501), unsigned 32 bits
+ 602: spr502 (spr502), unsigned 32 bits
+ 603: spr503 (spr503), unsigned 32 bits
+ 604: spr504 (spr504), unsigned 32 bits
+ 605: spr505 (spr505), unsigned 32 bits
+ 606: spr506 (spr506), unsigned 32 bits
+ 607: spr507 (spr507), unsigned 32 bits
+ 608: spr508 (spr508), unsigned 32 bits
+ 609: spr509 (spr509), unsigned 32 bits
+ 610: spr510 (spr510), unsigned 32 bits
+ 611: spr511 (spr511), unsigned 32 bits
+ 613: spr513 (spr513), unsigned 32 bits
+ 614: spr514 (spr514), unsigned 32 bits
+ 615: spr515 (spr515), unsigned 32 bits
+ 616: spr516 (spr516), unsigned 32 bits
+ 617: spr517 (spr517), unsigned 32 bits
+ 618: spr518 (spr518), unsigned 32 bits
+ 619: spr519 (spr519), unsigned 32 bits
+ 620: spr520 (spr520), unsigned 32 bits
+ 621: spr521 (spr521), unsigned 32 bits
+ 622: spr522 (spr522), unsigned 32 bits
+ 623: spr523 (spr523), unsigned 32 bits
+ 624: spr524 (spr524), unsigned 32 bits
+ 625: spr525 (spr525), unsigned 32 bits
+ 626: spr526 (spr526), unsigned 32 bits
+ 627: spr527 (spr527), unsigned 32 bits
+ 628: spr528 (spr528), unsigned 32 bits
+ 629: spr529 (spr529), unsigned 32 bits
+ 630: spr530 (spr530), unsigned 32 bits
+ 631: spr531 (spr531), unsigned 32 bits
+ 632: spr532 (spr532), unsigned 32 bits
+ 633: spr533 (spr533), unsigned 32 bits
+ 634: spr534 (spr534), unsigned 32 bits
+ 635: spr535 (spr535), unsigned 32 bits
+ 636: spr536 (spr536), unsigned 32 bits
+ 637: spr537 (spr537), unsigned 32 bits
+ 638: spr538 (spr538), unsigned 32 bits
+ 639: spr539 (spr539), unsigned 32 bits
+ 640: spr540 (spr540), unsigned 32 bits
+ 641: spr541 (spr541), unsigned 32 bits
+ 642: spr542 (spr542), unsigned 32 bits
+ 643: spr543 (spr543), unsigned 32 bits
+ 644: spr544 (spr544), unsigned 32 bits
+ 645: spr545 (spr545), unsigned 32 bits
+ 646: spr546 (spr546), unsigned 32 bits
+ 647: spr547 (spr547), unsigned 32 bits
+ 648: spr548 (spr548), unsigned 32 bits
+ 649: spr549 (spr549), unsigned 32 bits
+ 650: spr550 (spr550), unsigned 32 bits
+ 651: spr551 (spr551), unsigned 32 bits
+ 652: spr552 (spr552), unsigned 32 bits
+ 653: spr553 (spr553), unsigned 32 bits
+ 654: spr554 (spr554), unsigned 32 bits
+ 655: spr555 (spr555), unsigned 32 bits
+ 656: spr556 (spr556), unsigned 32 bits
+ 657: spr557 (spr557), unsigned 32 bits
+ 658: spr558 (spr558), unsigned 32 bits
+ 659: spr559 (spr559), unsigned 32 bits
+ 660: spr560 (spr560), unsigned 32 bits
+ 661: spr561 (spr561), unsigned 32 bits
+ 662: spr562 (spr562), unsigned 32 bits
+ 663: spr563 (spr563), unsigned 32 bits
+ 664: spr564 (spr564), unsigned 32 bits
+ 665: spr565 (spr565), unsigned 32 bits
+ 666: spr566 (spr566), unsigned 32 bits
+ 667: spr567 (spr567), unsigned 32 bits
+ 668: spr568 (spr568), unsigned 32 bits
+ 669: spr569 (spr569), unsigned 32 bits
+ 670: spr570 (spr570), unsigned 32 bits
+ 671: spr571 (spr571), unsigned 32 bits
+ 672: spr572 (spr572), unsigned 32 bits
+ 673: spr573 (spr573), unsigned 32 bits
+ 674: spr574 (spr574), unsigned 32 bits
+ 675: spr575 (spr575), unsigned 32 bits
+ 676: spr576 (spr576), unsigned 32 bits
+ 677: spr577 (spr577), unsigned 32 bits
+ 678: spr578 (spr578), unsigned 32 bits
+ 679: spr579 (spr579), unsigned 32 bits
+ 680: spr580 (spr580), unsigned 32 bits
+ 681: spr581 (spr581), unsigned 32 bits
+ 682: spr582 (spr582), unsigned 32 bits
+ 683: spr583 (spr583), unsigned 32 bits
+ 684: spr584 (spr584), unsigned 32 bits
+ 685: spr585 (spr585), unsigned 32 bits
+ 686: spr586 (spr586), unsigned 32 bits
+ 687: spr587 (spr587), unsigned 32 bits
+ 688: spr588 (spr588), unsigned 32 bits
+ 689: spr589 (spr589), unsigned 32 bits
+ 690: spr590 (spr590), unsigned 32 bits
+ 691: spr591 (spr591), unsigned 32 bits
+ 692: spr592 (spr592), unsigned 32 bits
+ 693: spr593 (spr593), unsigned 32 bits
+ 694: spr594 (spr594), unsigned 32 bits
+ 695: spr595 (spr595), unsigned 32 bits
+ 696: spr596 (spr596), unsigned 32 bits
+ 697: spr597 (spr597), unsigned 32 bits
+ 698: spr598 (spr598), unsigned 32 bits
+ 699: spr599 (spr599), unsigned 32 bits
+ 700: spr600 (spr600), unsigned 32 bits
+ 701: spr601 (spr601), unsigned 32 bits
+ 702: spr602 (spr602), unsigned 32 bits
+ 703: spr603 (spr603), unsigned 32 bits
+ 704: spr604 (spr604), unsigned 32 bits
+ 705: spr605 (spr605), unsigned 32 bits
+ 706: spr606 (spr606), unsigned 32 bits
+ 707: spr607 (spr607), unsigned 32 bits
+ 708: spr608 (spr608), unsigned 32 bits
+ 709: spr609 (spr609), unsigned 32 bits
+ 710: spr610 (spr610), unsigned 32 bits
+ 711: spr611 (spr611), unsigned 32 bits
+ 712: spr612 (spr612), unsigned 32 bits
+ 713: spr613 (spr613), unsigned 32 bits
+ 714: spr614 (spr614), unsigned 32 bits
+ 715: spr615 (spr615), unsigned 32 bits
+ 716: spr616 (spr616), unsigned 32 bits
+ 717: spr617 (spr617), unsigned 32 bits
+ 718: spr618 (spr618), unsigned 32 bits
+ 719: spr619 (spr619), unsigned 32 bits
+ 720: spr620 (spr620), unsigned 32 bits
+ 721: spr621 (spr621), unsigned 32 bits
+ 722: spr622 (spr622), unsigned 32 bits
+ 723: spr623 (spr623), unsigned 32 bits
+ 724: spr624 (spr624), unsigned 32 bits
+ 725: spr625 (spr625), unsigned 32 bits
+ 726: spr626 (spr626), unsigned 32 bits
+ 727: spr627 (spr627), unsigned 32 bits
+ 728: spr628 (spr628), unsigned 32 bits
+ 729: spr629 (spr629), unsigned 32 bits
+ 730: spr630 (spr630), unsigned 32 bits
+ 731: spr631 (spr631), unsigned 32 bits
+ 732: spr632 (spr632), unsigned 32 bits
+ 733: spr633 (spr633), unsigned 32 bits
+ 734: spr634 (spr634), unsigned 32 bits
+ 735: spr635 (spr635), unsigned 32 bits
+ 736: spr636 (spr636), unsigned 32 bits
+ 737: spr637 (spr637), unsigned 32 bits
+ 738: spr638 (spr638), unsigned 32 bits
+ 739: spr639 (spr639), unsigned 32 bits
+ 740: spr640 (spr640), unsigned 32 bits
+ 741: spr641 (spr641), unsigned 32 bits
+ 742: spr642 (spr642), unsigned 32 bits
+ 743: spr643 (spr643), unsigned 32 bits
+ 744: spr644 (spr644), unsigned 32 bits
+ 745: spr645 (spr645), unsigned 32 bits
+ 746: spr646 (spr646), unsigned 32 bits
+ 747: spr647 (spr647), unsigned 32 bits
+ 748: spr648 (spr648), unsigned 32 bits
+ 749: spr649 (spr649), unsigned 32 bits
+ 750: spr650 (spr650), unsigned 32 bits
+ 751: spr651 (spr651), unsigned 32 bits
+ 752: spr652 (spr652), unsigned 32 bits
+ 753: spr653 (spr653), unsigned 32 bits
+ 754: spr654 (spr654), unsigned 32 bits
+ 755: spr655 (spr655), unsigned 32 bits
+ 756: spr656 (spr656), unsigned 32 bits
+ 757: spr657 (spr657), unsigned 32 bits
+ 758: spr658 (spr658), unsigned 32 bits
+ 759: spr659 (spr659), unsigned 32 bits
+ 760: spr660 (spr660), unsigned 32 bits
+ 761: spr661 (spr661), unsigned 32 bits
+ 762: spr662 (spr662), unsigned 32 bits
+ 763: spr663 (spr663), unsigned 32 bits
+ 764: spr664 (spr664), unsigned 32 bits
+ 765: spr665 (spr665), unsigned 32 bits
+ 766: spr666 (spr666), unsigned 32 bits
+ 767: spr667 (spr667), unsigned 32 bits
+ 768: spr668 (spr668), unsigned 32 bits
+ 769: spr669 (spr669), unsigned 32 bits
+ 770: spr670 (spr670), unsigned 32 bits
+ 771: spr671 (spr671), unsigned 32 bits
+ 772: spr672 (spr672), unsigned 32 bits
+ 773: spr673 (spr673), unsigned 32 bits
+ 774: spr674 (spr674), unsigned 32 bits
+ 775: spr675 (spr675), unsigned 32 bits
+ 776: spr676 (spr676), unsigned 32 bits
+ 777: spr677 (spr677), unsigned 32 bits
+ 778: spr678 (spr678), unsigned 32 bits
+ 779: spr679 (spr679), unsigned 32 bits
+ 780: spr680 (spr680), unsigned 32 bits
+ 781: spr681 (spr681), unsigned 32 bits
+ 782: spr682 (spr682), unsigned 32 bits
+ 783: spr683 (spr683), unsigned 32 bits
+ 784: spr684 (spr684), unsigned 32 bits
+ 785: spr685 (spr685), unsigned 32 bits
+ 786: spr686 (spr686), unsigned 32 bits
+ 787: spr687 (spr687), unsigned 32 bits
+ 788: spr688 (spr688), unsigned 32 bits
+ 789: spr689 (spr689), unsigned 32 bits
+ 790: spr690 (spr690), unsigned 32 bits
+ 791: spr691 (spr691), unsigned 32 bits
+ 792: spr692 (spr692), unsigned 32 bits
+ 793: spr693 (spr693), unsigned 32 bits
+ 794: spr694 (spr694), unsigned 32 bits
+ 795: spr695 (spr695), unsigned 32 bits
+ 796: spr696 (spr696), unsigned 32 bits
+ 797: spr697 (spr697), unsigned 32 bits
+ 798: spr698 (spr698), unsigned 32 bits
+ 799: spr699 (spr699), unsigned 32 bits
+ 800: spr700 (spr700), unsigned 32 bits
+ 801: spr701 (spr701), unsigned 32 bits
+ 802: spr702 (spr702), unsigned 32 bits
+ 803: spr703 (spr703), unsigned 32 bits
+ 804: spr704 (spr704), unsigned 32 bits
+ 805: spr705 (spr705), unsigned 32 bits
+ 806: spr706 (spr706), unsigned 32 bits
+ 807: spr707 (spr707), unsigned 32 bits
+ 808: spr708 (spr708), unsigned 32 bits
+ 809: spr709 (spr709), unsigned 32 bits
+ 810: spr710 (spr710), unsigned 32 bits
+ 811: spr711 (spr711), unsigned 32 bits
+ 812: spr712 (spr712), unsigned 32 bits
+ 813: spr713 (spr713), unsigned 32 bits
+ 814: spr714 (spr714), unsigned 32 bits
+ 815: spr715 (spr715), unsigned 32 bits
+ 816: spr716 (spr716), unsigned 32 bits
+ 817: spr717 (spr717), unsigned 32 bits
+ 818: spr718 (spr718), unsigned 32 bits
+ 819: spr719 (spr719), unsigned 32 bits
+ 820: spr720 (spr720), unsigned 32 bits
+ 821: spr721 (spr721), unsigned 32 bits
+ 822: spr722 (spr722), unsigned 32 bits
+ 823: spr723 (spr723), unsigned 32 bits
+ 824: spr724 (spr724), unsigned 32 bits
+ 825: spr725 (spr725), unsigned 32 bits
+ 826: spr726 (spr726), unsigned 32 bits
+ 827: spr727 (spr727), unsigned 32 bits
+ 828: spr728 (spr728), unsigned 32 bits
+ 829: spr729 (spr729), unsigned 32 bits
+ 830: spr730 (spr730), unsigned 32 bits
+ 831: spr731 (spr731), unsigned 32 bits
+ 832: spr732 (spr732), unsigned 32 bits
+ 833: spr733 (spr733), unsigned 32 bits
+ 834: spr734 (spr734), unsigned 32 bits
+ 835: spr735 (spr735), unsigned 32 bits
+ 836: spr736 (spr736), unsigned 32 bits
+ 837: spr737 (spr737), unsigned 32 bits
+ 838: spr738 (spr738), unsigned 32 bits
+ 839: spr739 (spr739), unsigned 32 bits
+ 840: spr740 (spr740), unsigned 32 bits
+ 841: spr741 (spr741), unsigned 32 bits
+ 842: spr742 (spr742), unsigned 32 bits
+ 843: spr743 (spr743), unsigned 32 bits
+ 844: spr744 (spr744), unsigned 32 bits
+ 845: spr745 (spr745), unsigned 32 bits
+ 846: spr746 (spr746), unsigned 32 bits
+ 847: spr747 (spr747), unsigned 32 bits
+ 848: spr748 (spr748), unsigned 32 bits
+ 849: spr749 (spr749), unsigned 32 bits
+ 850: spr750 (spr750), unsigned 32 bits
+ 851: spr751 (spr751), unsigned 32 bits
+ 852: spr752 (spr752), unsigned 32 bits
+ 853: spr753 (spr753), unsigned 32 bits
+ 854: spr754 (spr754), unsigned 32 bits
+ 855: spr755 (spr755), unsigned 32 bits
+ 856: spr756 (spr756), unsigned 32 bits
+ 857: spr757 (spr757), unsigned 32 bits
+ 858: spr758 (spr758), unsigned 32 bits
+ 859: spr759 (spr759), unsigned 32 bits
+ 860: spr760 (spr760), unsigned 32 bits
+ 861: spr761 (spr761), unsigned 32 bits
+ 862: spr762 (spr762), unsigned 32 bits
+ 863: spr763 (spr763), unsigned 32 bits
+ 864: spr764 (spr764), unsigned 32 bits
+ 865: spr765 (spr765), unsigned 32 bits
+ 866: spr766 (spr766), unsigned 32 bits
+ 867: spr767 (spr767), unsigned 32 bits
+ 868: spr768 (spr768), unsigned 32 bits
+ 869: spr769 (spr769), unsigned 32 bits
+ 870: spr770 (spr770), unsigned 32 bits
+ 871: spr771 (spr771), unsigned 32 bits
+ 872: spr772 (spr772), unsigned 32 bits
+ 873: spr773 (spr773), unsigned 32 bits
+ 874: spr774 (spr774), unsigned 32 bits
+ 875: spr775 (spr775), unsigned 32 bits
+ 876: spr776 (spr776), unsigned 32 bits
+ 877: spr777 (spr777), unsigned 32 bits
+ 878: spr778 (spr778), unsigned 32 bits
+ 879: spr779 (spr779), unsigned 32 bits
+ 880: spr780 (spr780), unsigned 32 bits
+ 881: spr781 (spr781), unsigned 32 bits
+ 882: spr782 (spr782), unsigned 32 bits
+ 883: spr783 (spr783), unsigned 32 bits
+ 884: spr784 (spr784), unsigned 32 bits
+ 885: spr785 (spr785), unsigned 32 bits
+ 886: spr786 (spr786), unsigned 32 bits
+ 887: spr787 (spr787), unsigned 32 bits
+ 888: spr788 (spr788), unsigned 32 bits
+ 889: spr789 (spr789), unsigned 32 bits
+ 890: spr790 (spr790), unsigned 32 bits
+ 891: spr791 (spr791), unsigned 32 bits
+ 892: spr792 (spr792), unsigned 32 bits
+ 893: spr793 (spr793), unsigned 32 bits
+ 894: spr794 (spr794), unsigned 32 bits
+ 895: spr795 (spr795), unsigned 32 bits
+ 896: spr796 (spr796), unsigned 32 bits
+ 897: spr797 (spr797), unsigned 32 bits
+ 898: spr798 (spr798), unsigned 32 bits
+ 899: spr799 (spr799), unsigned 32 bits
+ 900: spr800 (spr800), unsigned 32 bits
+ 901: spr801 (spr801), unsigned 32 bits
+ 902: spr802 (spr802), unsigned 32 bits
+ 903: spr803 (spr803), unsigned 32 bits
+ 904: spr804 (spr804), unsigned 32 bits
+ 905: spr805 (spr805), unsigned 32 bits
+ 906: spr806 (spr806), unsigned 32 bits
+ 907: spr807 (spr807), unsigned 32 bits
+ 908: spr808 (spr808), unsigned 32 bits
+ 909: spr809 (spr809), unsigned 32 bits
+ 910: spr810 (spr810), unsigned 32 bits
+ 911: spr811 (spr811), unsigned 32 bits
+ 912: spr812 (spr812), unsigned 32 bits
+ 913: spr813 (spr813), unsigned 32 bits
+ 914: spr814 (spr814), unsigned 32 bits
+ 915: spr815 (spr815), unsigned 32 bits
+ 916: spr816 (spr816), unsigned 32 bits
+ 917: spr817 (spr817), unsigned 32 bits
+ 918: spr818 (spr818), unsigned 32 bits
+ 919: spr819 (spr819), unsigned 32 bits
+ 920: spr820 (spr820), unsigned 32 bits
+ 921: spr821 (spr821), unsigned 32 bits
+ 922: spr822 (spr822), unsigned 32 bits
+ 923: spr823 (spr823), unsigned 32 bits
+ 924: spr824 (spr824), unsigned 32 bits
+ 925: spr825 (spr825), unsigned 32 bits
+ 926: spr826 (spr826), unsigned 32 bits
+ 927: spr827 (spr827), unsigned 32 bits
+ 928: spr828 (spr828), unsigned 32 bits
+ 929: spr829 (spr829), unsigned 32 bits
+ 930: spr830 (spr830), unsigned 32 bits
+ 931: spr831 (spr831), unsigned 32 bits
+ 932: spr832 (spr832), unsigned 32 bits
+ 933: spr833 (spr833), unsigned 32 bits
+ 934: spr834 (spr834), unsigned 32 bits
+ 935: spr835 (spr835), unsigned 32 bits
+ 936: spr836 (spr836), unsigned 32 bits
+ 937: spr837 (spr837), unsigned 32 bits
+ 938: spr838 (spr838), unsigned 32 bits
+ 939: spr839 (spr839), unsigned 32 bits
+ 940: spr840 (spr840), unsigned 32 bits
+ 941: spr841 (spr841), unsigned 32 bits
+ 942: spr842 (spr842), unsigned 32 bits
+ 943: spr843 (spr843), unsigned 32 bits
+ 944: spr844 (spr844), unsigned 32 bits
+ 945: spr845 (spr845), unsigned 32 bits
+ 946: spr846 (spr846), unsigned 32 bits
+ 947: spr847 (spr847), unsigned 32 bits
+ 948: spr848 (spr848), unsigned 32 bits
+ 949: spr849 (spr849), unsigned 32 bits
+ 950: spr850 (spr850), unsigned 32 bits
+ 951: spr851 (spr851), unsigned 32 bits
+ 952: spr852 (spr852), unsigned 32 bits
+ 953: spr853 (spr853), unsigned 32 bits
+ 954: spr854 (spr854), unsigned 32 bits
+ 955: spr855 (spr855), unsigned 32 bits
+ 956: spr856 (spr856), unsigned 32 bits
+ 957: spr857 (spr857), unsigned 32 bits
+ 958: spr858 (spr858), unsigned 32 bits
+ 959: spr859 (spr859), unsigned 32 bits
+ 960: spr860 (spr860), unsigned 32 bits
+ 961: spr861 (spr861), unsigned 32 bits
+ 962: spr862 (spr862), unsigned 32 bits
+ 963: spr863 (spr863), unsigned 32 bits
+ 964: spr864 (spr864), unsigned 32 bits
+ 965: spr865 (spr865), unsigned 32 bits
+ 966: spr866 (spr866), unsigned 32 bits
+ 967: spr867 (spr867), unsigned 32 bits
+ 968: spr868 (spr868), unsigned 32 bits
+ 969: spr869 (spr869), unsigned 32 bits
+ 970: spr870 (spr870), unsigned 32 bits
+ 971: spr871 (spr871), unsigned 32 bits
+ 972: spr872 (spr872), unsigned 32 bits
+ 973: spr873 (spr873), unsigned 32 bits
+ 974: spr874 (spr874), unsigned 32 bits
+ 975: spr875 (spr875), unsigned 32 bits
+ 976: spr876 (spr876), unsigned 32 bits
+ 977: spr877 (spr877), unsigned 32 bits
+ 978: spr878 (spr878), unsigned 32 bits
+ 979: spr879 (spr879), unsigned 32 bits
+ 980: spr880 (spr880), unsigned 32 bits
+ 981: spr881 (spr881), unsigned 32 bits
+ 982: spr882 (spr882), unsigned 32 bits
+ 983: spr883 (spr883), unsigned 32 bits
+ 984: spr884 (spr884), unsigned 32 bits
+ 985: spr885 (spr885), unsigned 32 bits
+ 986: spr886 (spr886), unsigned 32 bits
+ 987: spr887 (spr887), unsigned 32 bits
+ 988: spr888 (spr888), unsigned 32 bits
+ 989: spr889 (spr889), unsigned 32 bits
+ 990: spr890 (spr890), unsigned 32 bits
+ 991: spr891 (spr891), unsigned 32 bits
+ 992: spr892 (spr892), unsigned 32 bits
+ 993: spr893 (spr893), unsigned 32 bits
+ 994: spr894 (spr894), unsigned 32 bits
+ 995: spr895 (spr895), unsigned 32 bits
+ 996: spr896 (spr896), unsigned 32 bits
+ 997: spr897 (spr897), unsigned 32 bits
+ 998: spr898 (spr898), unsigned 32 bits
+ 999: spr899 (spr899), unsigned 32 bits
+vector registers:
+ 67: vscr (vscr), unsigned 32 bits
+ 356: vrsave (vrsave), unsigned 32 bits
+ 612: spefscr (spefscr), unsigned 32 bits
+ 1124: vr0 (vr0), unsigned 128 bits
+ 1125: vr1 (vr1), unsigned 128 bits
+ 1126: vr2 (vr2), unsigned 128 bits
+ 1127: vr3 (vr3), unsigned 128 bits
+ 1128: vr4 (vr4), unsigned 128 bits
+ 1129: vr5 (vr5), unsigned 128 bits
+ 1130: vr6 (vr6), unsigned 128 bits
+ 1131: vr7 (vr7), unsigned 128 bits
+ 1132: vr8 (vr8), unsigned 128 bits
+ 1133: vr9 (vr9), unsigned 128 bits
+ 1134: vr10 (vr10), unsigned 128 bits
+ 1135: vr11 (vr11), unsigned 128 bits
+ 1136: vr12 (vr12), unsigned 128 bits
+ 1137: vr13 (vr13), unsigned 128 bits
+ 1138: vr14 (vr14), unsigned 128 bits
+ 1139: vr15 (vr15), unsigned 128 bits
+ 1140: vr16 (vr16), unsigned 128 bits
+ 1141: vr17 (vr17), unsigned 128 bits
+ 1142: vr18 (vr18), unsigned 128 bits
+ 1143: vr19 (vr19), unsigned 128 bits
+ 1144: vr20 (vr20), unsigned 128 bits
+ 1145: vr21 (vr21), unsigned 128 bits
+ 1146: vr22 (vr22), unsigned 128 bits
+ 1147: vr23 (vr23), unsigned 128 bits
+ 1148: vr24 (vr24), unsigned 128 bits
+ 1149: vr25 (vr25), unsigned 128 bits
+ 1150: vr26 (vr26), unsigned 128 bits
+ 1151: vr27 (vr27), unsigned 128 bits
+ 1152: vr28 (vr28), unsigned 128 bits
+ 1153: vr29 (vr29), unsigned 128 bits
+ 1154: vr30 (vr30), unsigned 128 bits
+ 1155: vr31 (vr31), unsigned 128 bits
+EOF
+
+regs_test testfile23 <<\EOF
+integer registers:
+ 0: r0 (r0), signed 64 bits
+ 1: r1 (r1), signed 64 bits
+ 2: r2 (r2), signed 64 bits
+ 3: r3 (r3), signed 64 bits
+ 4: r4 (r4), signed 64 bits
+ 5: r5 (r5), signed 64 bits
+ 6: r6 (r6), signed 64 bits
+ 7: r7 (r7), signed 64 bits
+ 8: r8 (r8), signed 64 bits
+ 9: r9 (r9), signed 64 bits
+ 10: r10 (r10), signed 64 bits
+ 11: r11 (r11), signed 64 bits
+ 12: r12 (r12), signed 64 bits
+ 13: r13 (r13), signed 64 bits
+ 14: r14 (r14), signed 64 bits
+ 15: r15 (r15), signed 64 bits
+ 16: r16 (r16), signed 64 bits
+ 17: r17 (r17), signed 64 bits
+ 18: r18 (r18), signed 64 bits
+ 19: r19 (r19), signed 64 bits
+ 20: r20 (r20), signed 64 bits
+ 21: r21 (r21), signed 64 bits
+ 22: r22 (r22), signed 64 bits
+ 23: r23 (r23), signed 64 bits
+ 24: r24 (r24), signed 64 bits
+ 25: r25 (r25), signed 64 bits
+ 26: r26 (r26), signed 64 bits
+ 27: r27 (r27), signed 64 bits
+ 28: r28 (r28), signed 64 bits
+ 29: r29 (r29), signed 64 bits
+ 30: r30 (r30), signed 64 bits
+ 31: r31 (r31), signed 64 bits
+ 64: cr (cr), unsigned 64 bits
+ 66: msr (msr), unsigned 64 bits
+FPU registers:
+ 32: f0 (f0), float 64 bits
+ 33: f1 (f1), float 64 bits
+ 34: f2 (f2), float 64 bits
+ 35: f3 (f3), float 64 bits
+ 36: f4 (f4), float 64 bits
+ 37: f5 (f5), float 64 bits
+ 38: f6 (f6), float 64 bits
+ 39: f7 (f7), float 64 bits
+ 40: f8 (f8), float 64 bits
+ 41: f9 (f9), float 64 bits
+ 42: f10 (f10), float 64 bits
+ 43: f11 (f11), float 64 bits
+ 44: f12 (f12), float 64 bits
+ 45: f13 (f13), float 64 bits
+ 46: f14 (f14), float 64 bits
+ 47: f15 (f15), float 64 bits
+ 48: f16 (f16), float 64 bits
+ 49: f17 (f17), float 64 bits
+ 50: f18 (f18), float 64 bits
+ 51: f19 (f19), float 64 bits
+ 52: f20 (f20), float 64 bits
+ 53: f21 (f21), float 64 bits
+ 54: f22 (f22), float 64 bits
+ 55: f23 (f23), float 64 bits
+ 56: f24 (f24), float 64 bits
+ 57: f25 (f25), float 64 bits
+ 58: f26 (f26), float 64 bits
+ 59: f27 (f27), float 64 bits
+ 60: f28 (f28), float 64 bits
+ 61: f29 (f29), float 64 bits
+ 62: f30 (f30), float 64 bits
+ 63: f31 (f31), float 64 bits
+ 65: fpscr (fpscr), unsigned 64 bits
+privileged registers:
+ 70: sr0 (sr0), unsigned 64 bits
+ 71: sr1 (sr1), unsigned 64 bits
+ 72: sr2 (sr2), unsigned 64 bits
+ 73: sr3 (sr3), unsigned 64 bits
+ 74: sr4 (sr4), unsigned 64 bits
+ 75: sr5 (sr5), unsigned 64 bits
+ 76: sr6 (sr6), unsigned 64 bits
+ 77: sr7 (sr7), unsigned 64 bits
+ 78: sr8 (sr8), unsigned 64 bits
+ 79: sr9 (sr9), unsigned 64 bits
+ 80: sr10 (sr10), unsigned 64 bits
+ 81: sr11 (sr11), unsigned 64 bits
+ 82: sr12 (sr12), unsigned 64 bits
+ 83: sr13 (sr13), unsigned 64 bits
+ 84: sr14 (sr14), unsigned 64 bits
+ 85: sr15 (sr15), unsigned 64 bits
+ 100: spr0 (spr0), unsigned 64 bits
+ 101: xer (xer), unsigned 64 bits
+ 102: spr2 (spr2), unsigned 64 bits
+ 103: spr3 (spr3), unsigned 64 bits
+ 104: spr4 (spr4), unsigned 64 bits
+ 105: spr5 (spr5), unsigned 64 bits
+ 106: spr6 (spr6), unsigned 64 bits
+ 107: spr7 (spr7), unsigned 64 bits
+ 108: lr (lr), unsigned 64 bits
+ 109: ctr (ctr), unsigned 64 bits
+ 110: spr10 (spr10), unsigned 64 bits
+ 111: spr11 (spr11), unsigned 64 bits
+ 112: spr12 (spr12), unsigned 64 bits
+ 113: spr13 (spr13), unsigned 64 bits
+ 114: tfhar (tfhar), unsigned 64 bits
+ 115: tfiar (tfiar), unsigned 64 bits
+ 116: texasr (texasr), unsigned 64 bits
+ 117: spr17 (spr17), unsigned 64 bits
+ 118: dsisr (dsisr), unsigned 64 bits
+ 119: dar (dar), unsigned 64 bits
+ 120: spr20 (spr20), unsigned 64 bits
+ 121: spr21 (spr21), unsigned 64 bits
+ 122: dec (dec), unsigned 64 bits
+ 123: spr23 (spr23), unsigned 64 bits
+ 124: spr24 (spr24), unsigned 64 bits
+ 125: spr25 (spr25), unsigned 64 bits
+ 126: spr26 (spr26), unsigned 64 bits
+ 127: spr27 (spr27), unsigned 64 bits
+ 128: spr28 (spr28), unsigned 64 bits
+ 129: spr29 (spr29), unsigned 64 bits
+ 130: spr30 (spr30), unsigned 64 bits
+ 131: spr31 (spr31), unsigned 64 bits
+ 132: spr32 (spr32), unsigned 64 bits
+ 133: spr33 (spr33), unsigned 64 bits
+ 134: spr34 (spr34), unsigned 64 bits
+ 135: spr35 (spr35), unsigned 64 bits
+ 136: spr36 (spr36), unsigned 64 bits
+ 137: spr37 (spr37), unsigned 64 bits
+ 138: spr38 (spr38), unsigned 64 bits
+ 139: spr39 (spr39), unsigned 64 bits
+ 140: spr40 (spr40), unsigned 64 bits
+ 141: spr41 (spr41), unsigned 64 bits
+ 142: spr42 (spr42), unsigned 64 bits
+ 143: spr43 (spr43), unsigned 64 bits
+ 144: spr44 (spr44), unsigned 64 bits
+ 145: spr45 (spr45), unsigned 64 bits
+ 146: spr46 (spr46), unsigned 64 bits
+ 147: spr47 (spr47), unsigned 64 bits
+ 148: spr48 (spr48), unsigned 64 bits
+ 149: spr49 (spr49), unsigned 64 bits
+ 150: spr50 (spr50), unsigned 64 bits
+ 151: spr51 (spr51), unsigned 64 bits
+ 152: spr52 (spr52), unsigned 64 bits
+ 153: spr53 (spr53), unsigned 64 bits
+ 154: spr54 (spr54), unsigned 64 bits
+ 155: spr55 (spr55), unsigned 64 bits
+ 156: spr56 (spr56), unsigned 64 bits
+ 157: spr57 (spr57), unsigned 64 bits
+ 158: spr58 (spr58), unsigned 64 bits
+ 159: spr59 (spr59), unsigned 64 bits
+ 160: spr60 (spr60), unsigned 64 bits
+ 161: spr61 (spr61), unsigned 64 bits
+ 162: spr62 (spr62), unsigned 64 bits
+ 163: spr63 (spr63), unsigned 64 bits
+ 164: spr64 (spr64), unsigned 64 bits
+ 165: spr65 (spr65), unsigned 64 bits
+ 166: spr66 (spr66), unsigned 64 bits
+ 167: spr67 (spr67), unsigned 64 bits
+ 168: spr68 (spr68), unsigned 64 bits
+ 169: spr69 (spr69), unsigned 64 bits
+ 170: spr70 (spr70), unsigned 64 bits
+ 171: spr71 (spr71), unsigned 64 bits
+ 172: spr72 (spr72), unsigned 64 bits
+ 173: spr73 (spr73), unsigned 64 bits
+ 174: spr74 (spr74), unsigned 64 bits
+ 175: spr75 (spr75), unsigned 64 bits
+ 176: spr76 (spr76), unsigned 64 bits
+ 177: spr77 (spr77), unsigned 64 bits
+ 178: spr78 (spr78), unsigned 64 bits
+ 179: spr79 (spr79), unsigned 64 bits
+ 180: spr80 (spr80), unsigned 64 bits
+ 181: spr81 (spr81), unsigned 64 bits
+ 182: spr82 (spr82), unsigned 64 bits
+ 183: spr83 (spr83), unsigned 64 bits
+ 184: spr84 (spr84), unsigned 64 bits
+ 185: spr85 (spr85), unsigned 64 bits
+ 186: spr86 (spr86), unsigned 64 bits
+ 187: spr87 (spr87), unsigned 64 bits
+ 188: spr88 (spr88), unsigned 64 bits
+ 189: spr89 (spr89), unsigned 64 bits
+ 190: spr90 (spr90), unsigned 64 bits
+ 191: spr91 (spr91), unsigned 64 bits
+ 192: spr92 (spr92), unsigned 64 bits
+ 193: spr93 (spr93), unsigned 64 bits
+ 194: spr94 (spr94), unsigned 64 bits
+ 195: spr95 (spr95), unsigned 64 bits
+ 196: spr96 (spr96), unsigned 64 bits
+ 197: spr97 (spr97), unsigned 64 bits
+ 198: spr98 (spr98), unsigned 64 bits
+ 199: spr99 (spr99), unsigned 64 bits
+ 200: spr100 (spr100), unsigned 64 bits
+ 201: spr101 (spr101), unsigned 64 bits
+ 202: spr102 (spr102), unsigned 64 bits
+ 203: spr103 (spr103), unsigned 64 bits
+ 204: spr104 (spr104), unsigned 64 bits
+ 205: spr105 (spr105), unsigned 64 bits
+ 206: spr106 (spr106), unsigned 64 bits
+ 207: spr107 (spr107), unsigned 64 bits
+ 208: spr108 (spr108), unsigned 64 bits
+ 209: spr109 (spr109), unsigned 64 bits
+ 210: spr110 (spr110), unsigned 64 bits
+ 211: spr111 (spr111), unsigned 64 bits
+ 212: spr112 (spr112), unsigned 64 bits
+ 213: spr113 (spr113), unsigned 64 bits
+ 214: spr114 (spr114), unsigned 64 bits
+ 215: spr115 (spr115), unsigned 64 bits
+ 216: spr116 (spr116), unsigned 64 bits
+ 217: spr117 (spr117), unsigned 64 bits
+ 218: spr118 (spr118), unsigned 64 bits
+ 219: spr119 (spr119), unsigned 64 bits
+ 220: spr120 (spr120), unsigned 64 bits
+ 221: spr121 (spr121), unsigned 64 bits
+ 222: spr122 (spr122), unsigned 64 bits
+ 223: spr123 (spr123), unsigned 64 bits
+ 224: spr124 (spr124), unsigned 64 bits
+ 225: spr125 (spr125), unsigned 64 bits
+ 226: spr126 (spr126), unsigned 64 bits
+ 227: spr127 (spr127), unsigned 64 bits
+ 228: spr128 (spr128), unsigned 64 bits
+ 229: spr129 (spr129), unsigned 64 bits
+ 230: spr130 (spr130), unsigned 64 bits
+ 231: spr131 (spr131), unsigned 64 bits
+ 232: spr132 (spr132), unsigned 64 bits
+ 233: spr133 (spr133), unsigned 64 bits
+ 234: spr134 (spr134), unsigned 64 bits
+ 235: spr135 (spr135), unsigned 64 bits
+ 236: spr136 (spr136), unsigned 64 bits
+ 237: spr137 (spr137), unsigned 64 bits
+ 238: spr138 (spr138), unsigned 64 bits
+ 239: spr139 (spr139), unsigned 64 bits
+ 240: spr140 (spr140), unsigned 64 bits
+ 241: spr141 (spr141), unsigned 64 bits
+ 242: spr142 (spr142), unsigned 64 bits
+ 243: spr143 (spr143), unsigned 64 bits
+ 244: spr144 (spr144), unsigned 64 bits
+ 245: spr145 (spr145), unsigned 64 bits
+ 246: spr146 (spr146), unsigned 64 bits
+ 247: spr147 (spr147), unsigned 64 bits
+ 248: spr148 (spr148), unsigned 64 bits
+ 249: spr149 (spr149), unsigned 64 bits
+ 250: spr150 (spr150), unsigned 64 bits
+ 251: spr151 (spr151), unsigned 64 bits
+ 252: spr152 (spr152), unsigned 64 bits
+ 253: spr153 (spr153), unsigned 64 bits
+ 254: spr154 (spr154), unsigned 64 bits
+ 255: spr155 (spr155), unsigned 64 bits
+ 256: spr156 (spr156), unsigned 64 bits
+ 257: spr157 (spr157), unsigned 64 bits
+ 258: spr158 (spr158), unsigned 64 bits
+ 259: spr159 (spr159), unsigned 64 bits
+ 260: spr160 (spr160), unsigned 64 bits
+ 261: spr161 (spr161), unsigned 64 bits
+ 262: spr162 (spr162), unsigned 64 bits
+ 263: spr163 (spr163), unsigned 64 bits
+ 264: spr164 (spr164), unsigned 64 bits
+ 265: spr165 (spr165), unsigned 64 bits
+ 266: spr166 (spr166), unsigned 64 bits
+ 267: spr167 (spr167), unsigned 64 bits
+ 268: spr168 (spr168), unsigned 64 bits
+ 269: spr169 (spr169), unsigned 64 bits
+ 270: spr170 (spr170), unsigned 64 bits
+ 271: spr171 (spr171), unsigned 64 bits
+ 272: spr172 (spr172), unsigned 64 bits
+ 273: spr173 (spr173), unsigned 64 bits
+ 274: spr174 (spr174), unsigned 64 bits
+ 275: spr175 (spr175), unsigned 64 bits
+ 276: spr176 (spr176), unsigned 64 bits
+ 277: spr177 (spr177), unsigned 64 bits
+ 278: spr178 (spr178), unsigned 64 bits
+ 279: spr179 (spr179), unsigned 64 bits
+ 280: spr180 (spr180), unsigned 64 bits
+ 281: spr181 (spr181), unsigned 64 bits
+ 282: spr182 (spr182), unsigned 64 bits
+ 283: spr183 (spr183), unsigned 64 bits
+ 284: spr184 (spr184), unsigned 64 bits
+ 285: spr185 (spr185), unsigned 64 bits
+ 286: spr186 (spr186), unsigned 64 bits
+ 287: spr187 (spr187), unsigned 64 bits
+ 288: spr188 (spr188), unsigned 64 bits
+ 289: spr189 (spr189), unsigned 64 bits
+ 290: spr190 (spr190), unsigned 64 bits
+ 291: spr191 (spr191), unsigned 64 bits
+ 292: spr192 (spr192), unsigned 64 bits
+ 293: spr193 (spr193), unsigned 64 bits
+ 294: spr194 (spr194), unsigned 64 bits
+ 295: spr195 (spr195), unsigned 64 bits
+ 296: spr196 (spr196), unsigned 64 bits
+ 297: spr197 (spr197), unsigned 64 bits
+ 298: spr198 (spr198), unsigned 64 bits
+ 299: spr199 (spr199), unsigned 64 bits
+ 300: spr200 (spr200), unsigned 64 bits
+ 301: spr201 (spr201), unsigned 64 bits
+ 302: spr202 (spr202), unsigned 64 bits
+ 303: spr203 (spr203), unsigned 64 bits
+ 304: spr204 (spr204), unsigned 64 bits
+ 305: spr205 (spr205), unsigned 64 bits
+ 306: spr206 (spr206), unsigned 64 bits
+ 307: spr207 (spr207), unsigned 64 bits
+ 308: spr208 (spr208), unsigned 64 bits
+ 309: spr209 (spr209), unsigned 64 bits
+ 310: spr210 (spr210), unsigned 64 bits
+ 311: spr211 (spr211), unsigned 64 bits
+ 312: spr212 (spr212), unsigned 64 bits
+ 313: spr213 (spr213), unsigned 64 bits
+ 314: spr214 (spr214), unsigned 64 bits
+ 315: spr215 (spr215), unsigned 64 bits
+ 316: spr216 (spr216), unsigned 64 bits
+ 317: spr217 (spr217), unsigned 64 bits
+ 318: spr218 (spr218), unsigned 64 bits
+ 319: spr219 (spr219), unsigned 64 bits
+ 320: spr220 (spr220), unsigned 64 bits
+ 321: spr221 (spr221), unsigned 64 bits
+ 322: spr222 (spr222), unsigned 64 bits
+ 323: spr223 (spr223), unsigned 64 bits
+ 324: spr224 (spr224), unsigned 64 bits
+ 325: spr225 (spr225), unsigned 64 bits
+ 326: spr226 (spr226), unsigned 64 bits
+ 327: spr227 (spr227), unsigned 64 bits
+ 328: spr228 (spr228), unsigned 64 bits
+ 329: spr229 (spr229), unsigned 64 bits
+ 330: spr230 (spr230), unsigned 64 bits
+ 331: spr231 (spr231), unsigned 64 bits
+ 332: spr232 (spr232), unsigned 64 bits
+ 333: spr233 (spr233), unsigned 64 bits
+ 334: spr234 (spr234), unsigned 64 bits
+ 335: spr235 (spr235), unsigned 64 bits
+ 336: spr236 (spr236), unsigned 64 bits
+ 337: spr237 (spr237), unsigned 64 bits
+ 338: spr238 (spr238), unsigned 64 bits
+ 339: spr239 (spr239), unsigned 64 bits
+ 340: spr240 (spr240), unsigned 64 bits
+ 341: spr241 (spr241), unsigned 64 bits
+ 342: spr242 (spr242), unsigned 64 bits
+ 343: spr243 (spr243), unsigned 64 bits
+ 344: spr244 (spr244), unsigned 64 bits
+ 345: spr245 (spr245), unsigned 64 bits
+ 346: spr246 (spr246), unsigned 64 bits
+ 347: spr247 (spr247), unsigned 64 bits
+ 348: spr248 (spr248), unsigned 64 bits
+ 349: spr249 (spr249), unsigned 64 bits
+ 350: spr250 (spr250), unsigned 64 bits
+ 351: spr251 (spr251), unsigned 64 bits
+ 352: spr252 (spr252), unsigned 64 bits
+ 353: spr253 (spr253), unsigned 64 bits
+ 354: spr254 (spr254), unsigned 64 bits
+ 355: spr255 (spr255), unsigned 64 bits
+ 357: spr257 (spr257), unsigned 64 bits
+ 358: spr258 (spr258), unsigned 64 bits
+ 359: spr259 (spr259), unsigned 64 bits
+ 360: spr260 (spr260), unsigned 64 bits
+ 361: spr261 (spr261), unsigned 64 bits
+ 362: spr262 (spr262), unsigned 64 bits
+ 363: spr263 (spr263), unsigned 64 bits
+ 364: spr264 (spr264), unsigned 64 bits
+ 365: spr265 (spr265), unsigned 64 bits
+ 366: spr266 (spr266), unsigned 64 bits
+ 367: spr267 (spr267), unsigned 64 bits
+ 368: spr268 (spr268), unsigned 64 bits
+ 369: spr269 (spr269), unsigned 64 bits
+ 370: spr270 (spr270), unsigned 64 bits
+ 371: spr271 (spr271), unsigned 64 bits
+ 372: spr272 (spr272), unsigned 64 bits
+ 373: spr273 (spr273), unsigned 64 bits
+ 374: spr274 (spr274), unsigned 64 bits
+ 375: spr275 (spr275), unsigned 64 bits
+ 376: spr276 (spr276), unsigned 64 bits
+ 377: spr277 (spr277), unsigned 64 bits
+ 378: spr278 (spr278), unsigned 64 bits
+ 379: spr279 (spr279), unsigned 64 bits
+ 380: spr280 (spr280), unsigned 64 bits
+ 381: spr281 (spr281), unsigned 64 bits
+ 382: spr282 (spr282), unsigned 64 bits
+ 383: spr283 (spr283), unsigned 64 bits
+ 384: spr284 (spr284), unsigned 64 bits
+ 385: spr285 (spr285), unsigned 64 bits
+ 386: spr286 (spr286), unsigned 64 bits
+ 387: spr287 (spr287), unsigned 64 bits
+ 388: spr288 (spr288), unsigned 64 bits
+ 389: spr289 (spr289), unsigned 64 bits
+ 390: spr290 (spr290), unsigned 64 bits
+ 391: spr291 (spr291), unsigned 64 bits
+ 392: spr292 (spr292), unsigned 64 bits
+ 393: spr293 (spr293), unsigned 64 bits
+ 394: spr294 (spr294), unsigned 64 bits
+ 395: spr295 (spr295), unsigned 64 bits
+ 396: spr296 (spr296), unsigned 64 bits
+ 397: spr297 (spr297), unsigned 64 bits
+ 398: spr298 (spr298), unsigned 64 bits
+ 399: spr299 (spr299), unsigned 64 bits
+ 400: spr300 (spr300), unsigned 64 bits
+ 401: spr301 (spr301), unsigned 64 bits
+ 402: spr302 (spr302), unsigned 64 bits
+ 403: spr303 (spr303), unsigned 64 bits
+ 404: spr304 (spr304), unsigned 64 bits
+ 405: spr305 (spr305), unsigned 64 bits
+ 406: spr306 (spr306), unsigned 64 bits
+ 407: spr307 (spr307), unsigned 64 bits
+ 408: spr308 (spr308), unsigned 64 bits
+ 409: spr309 (spr309), unsigned 64 bits
+ 410: spr310 (spr310), unsigned 64 bits
+ 411: spr311 (spr311), unsigned 64 bits
+ 412: spr312 (spr312), unsigned 64 bits
+ 413: spr313 (spr313), unsigned 64 bits
+ 414: spr314 (spr314), unsigned 64 bits
+ 415: spr315 (spr315), unsigned 64 bits
+ 416: spr316 (spr316), unsigned 64 bits
+ 417: spr317 (spr317), unsigned 64 bits
+ 418: spr318 (spr318), unsigned 64 bits
+ 419: spr319 (spr319), unsigned 64 bits
+ 420: spr320 (spr320), unsigned 64 bits
+ 421: spr321 (spr321), unsigned 64 bits
+ 422: spr322 (spr322), unsigned 64 bits
+ 423: spr323 (spr323), unsigned 64 bits
+ 424: spr324 (spr324), unsigned 64 bits
+ 425: spr325 (spr325), unsigned 64 bits
+ 426: spr326 (spr326), unsigned 64 bits
+ 427: spr327 (spr327), unsigned 64 bits
+ 428: spr328 (spr328), unsigned 64 bits
+ 429: spr329 (spr329), unsigned 64 bits
+ 430: spr330 (spr330), unsigned 64 bits
+ 431: spr331 (spr331), unsigned 64 bits
+ 432: spr332 (spr332), unsigned 64 bits
+ 433: spr333 (spr333), unsigned 64 bits
+ 434: spr334 (spr334), unsigned 64 bits
+ 435: spr335 (spr335), unsigned 64 bits
+ 436: spr336 (spr336), unsigned 64 bits
+ 437: spr337 (spr337), unsigned 64 bits
+ 438: spr338 (spr338), unsigned 64 bits
+ 439: spr339 (spr339), unsigned 64 bits
+ 440: spr340 (spr340), unsigned 64 bits
+ 441: spr341 (spr341), unsigned 64 bits
+ 442: spr342 (spr342), unsigned 64 bits
+ 443: spr343 (spr343), unsigned 64 bits
+ 444: spr344 (spr344), unsigned 64 bits
+ 445: spr345 (spr345), unsigned 64 bits
+ 446: spr346 (spr346), unsigned 64 bits
+ 447: spr347 (spr347), unsigned 64 bits
+ 448: spr348 (spr348), unsigned 64 bits
+ 449: spr349 (spr349), unsigned 64 bits
+ 450: spr350 (spr350), unsigned 64 bits
+ 451: spr351 (spr351), unsigned 64 bits
+ 452: spr352 (spr352), unsigned 64 bits
+ 453: spr353 (spr353), unsigned 64 bits
+ 454: spr354 (spr354), unsigned 64 bits
+ 455: spr355 (spr355), unsigned 64 bits
+ 456: spr356 (spr356), unsigned 64 bits
+ 457: spr357 (spr357), unsigned 64 bits
+ 458: spr358 (spr358), unsigned 64 bits
+ 459: spr359 (spr359), unsigned 64 bits
+ 460: spr360 (spr360), unsigned 64 bits
+ 461: spr361 (spr361), unsigned 64 bits
+ 462: spr362 (spr362), unsigned 64 bits
+ 463: spr363 (spr363), unsigned 64 bits
+ 464: spr364 (spr364), unsigned 64 bits
+ 465: spr365 (spr365), unsigned 64 bits
+ 466: spr366 (spr366), unsigned 64 bits
+ 467: spr367 (spr367), unsigned 64 bits
+ 468: spr368 (spr368), unsigned 64 bits
+ 469: spr369 (spr369), unsigned 64 bits
+ 470: spr370 (spr370), unsigned 64 bits
+ 471: spr371 (spr371), unsigned 64 bits
+ 472: spr372 (spr372), unsigned 64 bits
+ 473: spr373 (spr373), unsigned 64 bits
+ 474: spr374 (spr374), unsigned 64 bits
+ 475: spr375 (spr375), unsigned 64 bits
+ 476: spr376 (spr376), unsigned 64 bits
+ 477: spr377 (spr377), unsigned 64 bits
+ 478: spr378 (spr378), unsigned 64 bits
+ 479: spr379 (spr379), unsigned 64 bits
+ 480: spr380 (spr380), unsigned 64 bits
+ 481: spr381 (spr381), unsigned 64 bits
+ 482: spr382 (spr382), unsigned 64 bits
+ 483: spr383 (spr383), unsigned 64 bits
+ 484: spr384 (spr384), unsigned 64 bits
+ 485: spr385 (spr385), unsigned 64 bits
+ 486: spr386 (spr386), unsigned 64 bits
+ 487: spr387 (spr387), unsigned 64 bits
+ 488: spr388 (spr388), unsigned 64 bits
+ 489: spr389 (spr389), unsigned 64 bits
+ 490: spr390 (spr390), unsigned 64 bits
+ 491: spr391 (spr391), unsigned 64 bits
+ 492: spr392 (spr392), unsigned 64 bits
+ 493: spr393 (spr393), unsigned 64 bits
+ 494: spr394 (spr394), unsigned 64 bits
+ 495: spr395 (spr395), unsigned 64 bits
+ 496: spr396 (spr396), unsigned 64 bits
+ 497: spr397 (spr397), unsigned 64 bits
+ 498: spr398 (spr398), unsigned 64 bits
+ 499: spr399 (spr399), unsigned 64 bits
+ 500: spr400 (spr400), unsigned 64 bits
+ 501: spr401 (spr401), unsigned 64 bits
+ 502: spr402 (spr402), unsigned 64 bits
+ 503: spr403 (spr403), unsigned 64 bits
+ 504: spr404 (spr404), unsigned 64 bits
+ 505: spr405 (spr405), unsigned 64 bits
+ 506: spr406 (spr406), unsigned 64 bits
+ 507: spr407 (spr407), unsigned 64 bits
+ 508: spr408 (spr408), unsigned 64 bits
+ 509: spr409 (spr409), unsigned 64 bits
+ 510: spr410 (spr410), unsigned 64 bits
+ 511: spr411 (spr411), unsigned 64 bits
+ 512: spr412 (spr412), unsigned 64 bits
+ 513: spr413 (spr413), unsigned 64 bits
+ 514: spr414 (spr414), unsigned 64 bits
+ 515: spr415 (spr415), unsigned 64 bits
+ 516: spr416 (spr416), unsigned 64 bits
+ 517: spr417 (spr417), unsigned 64 bits
+ 518: spr418 (spr418), unsigned 64 bits
+ 519: spr419 (spr419), unsigned 64 bits
+ 520: spr420 (spr420), unsigned 64 bits
+ 521: spr421 (spr421), unsigned 64 bits
+ 522: spr422 (spr422), unsigned 64 bits
+ 523: spr423 (spr423), unsigned 64 bits
+ 524: spr424 (spr424), unsigned 64 bits
+ 525: spr425 (spr425), unsigned 64 bits
+ 526: spr426 (spr426), unsigned 64 bits
+ 527: spr427 (spr427), unsigned 64 bits
+ 528: spr428 (spr428), unsigned 64 bits
+ 529: spr429 (spr429), unsigned 64 bits
+ 530: spr430 (spr430), unsigned 64 bits
+ 531: spr431 (spr431), unsigned 64 bits
+ 532: spr432 (spr432), unsigned 64 bits
+ 533: spr433 (spr433), unsigned 64 bits
+ 534: spr434 (spr434), unsigned 64 bits
+ 535: spr435 (spr435), unsigned 64 bits
+ 536: spr436 (spr436), unsigned 64 bits
+ 537: spr437 (spr437), unsigned 64 bits
+ 538: spr438 (spr438), unsigned 64 bits
+ 539: spr439 (spr439), unsigned 64 bits
+ 540: spr440 (spr440), unsigned 64 bits
+ 541: spr441 (spr441), unsigned 64 bits
+ 542: spr442 (spr442), unsigned 64 bits
+ 543: spr443 (spr443), unsigned 64 bits
+ 544: spr444 (spr444), unsigned 64 bits
+ 545: spr445 (spr445), unsigned 64 bits
+ 546: spr446 (spr446), unsigned 64 bits
+ 547: spr447 (spr447), unsigned 64 bits
+ 548: spr448 (spr448), unsigned 64 bits
+ 549: spr449 (spr449), unsigned 64 bits
+ 550: spr450 (spr450), unsigned 64 bits
+ 551: spr451 (spr451), unsigned 64 bits
+ 552: spr452 (spr452), unsigned 64 bits
+ 553: spr453 (spr453), unsigned 64 bits
+ 554: spr454 (spr454), unsigned 64 bits
+ 555: spr455 (spr455), unsigned 64 bits
+ 556: spr456 (spr456), unsigned 64 bits
+ 557: spr457 (spr457), unsigned 64 bits
+ 558: spr458 (spr458), unsigned 64 bits
+ 559: spr459 (spr459), unsigned 64 bits
+ 560: spr460 (spr460), unsigned 64 bits
+ 561: spr461 (spr461), unsigned 64 bits
+ 562: spr462 (spr462), unsigned 64 bits
+ 563: spr463 (spr463), unsigned 64 bits
+ 564: spr464 (spr464), unsigned 64 bits
+ 565: spr465 (spr465), unsigned 64 bits
+ 566: spr466 (spr466), unsigned 64 bits
+ 567: spr467 (spr467), unsigned 64 bits
+ 568: spr468 (spr468), unsigned 64 bits
+ 569: spr469 (spr469), unsigned 64 bits
+ 570: spr470 (spr470), unsigned 64 bits
+ 571: spr471 (spr471), unsigned 64 bits
+ 572: spr472 (spr472), unsigned 64 bits
+ 573: spr473 (spr473), unsigned 64 bits
+ 574: spr474 (spr474), unsigned 64 bits
+ 575: spr475 (spr475), unsigned 64 bits
+ 576: spr476 (spr476), unsigned 64 bits
+ 577: spr477 (spr477), unsigned 64 bits
+ 578: spr478 (spr478), unsigned 64 bits
+ 579: spr479 (spr479), unsigned 64 bits
+ 580: spr480 (spr480), unsigned 64 bits
+ 581: spr481 (spr481), unsigned 64 bits
+ 582: spr482 (spr482), unsigned 64 bits
+ 583: spr483 (spr483), unsigned 64 bits
+ 584: spr484 (spr484), unsigned 64 bits
+ 585: spr485 (spr485), unsigned 64 bits
+ 586: spr486 (spr486), unsigned 64 bits
+ 587: spr487 (spr487), unsigned 64 bits
+ 588: spr488 (spr488), unsigned 64 bits
+ 589: spr489 (spr489), unsigned 64 bits
+ 590: spr490 (spr490), unsigned 64 bits
+ 591: spr491 (spr491), unsigned 64 bits
+ 592: spr492 (spr492), unsigned 64 bits
+ 593: spr493 (spr493), unsigned 64 bits
+ 594: spr494 (spr494), unsigned 64 bits
+ 595: spr495 (spr495), unsigned 64 bits
+ 596: spr496 (spr496), unsigned 64 bits
+ 597: spr497 (spr497), unsigned 64 bits
+ 598: spr498 (spr498), unsigned 64 bits
+ 599: spr499 (spr499), unsigned 64 bits
+ 600: spr500 (spr500), unsigned 64 bits
+ 601: spr501 (spr501), unsigned 64 bits
+ 602: spr502 (spr502), unsigned 64 bits
+ 603: spr503 (spr503), unsigned 64 bits
+ 604: spr504 (spr504), unsigned 64 bits
+ 605: spr505 (spr505), unsigned 64 bits
+ 606: spr506 (spr506), unsigned 64 bits
+ 607: spr507 (spr507), unsigned 64 bits
+ 608: spr508 (spr508), unsigned 64 bits
+ 609: spr509 (spr509), unsigned 64 bits
+ 610: spr510 (spr510), unsigned 64 bits
+ 611: spr511 (spr511), unsigned 64 bits
+ 613: spr513 (spr513), unsigned 64 bits
+ 614: spr514 (spr514), unsigned 64 bits
+ 615: spr515 (spr515), unsigned 64 bits
+ 616: spr516 (spr516), unsigned 64 bits
+ 617: spr517 (spr517), unsigned 64 bits
+ 618: spr518 (spr518), unsigned 64 bits
+ 619: spr519 (spr519), unsigned 64 bits
+ 620: spr520 (spr520), unsigned 64 bits
+ 621: spr521 (spr521), unsigned 64 bits
+ 622: spr522 (spr522), unsigned 64 bits
+ 623: spr523 (spr523), unsigned 64 bits
+ 624: spr524 (spr524), unsigned 64 bits
+ 625: spr525 (spr525), unsigned 64 bits
+ 626: spr526 (spr526), unsigned 64 bits
+ 627: spr527 (spr527), unsigned 64 bits
+ 628: spr528 (spr528), unsigned 64 bits
+ 629: spr529 (spr529), unsigned 64 bits
+ 630: spr530 (spr530), unsigned 64 bits
+ 631: spr531 (spr531), unsigned 64 bits
+ 632: spr532 (spr532), unsigned 64 bits
+ 633: spr533 (spr533), unsigned 64 bits
+ 634: spr534 (spr534), unsigned 64 bits
+ 635: spr535 (spr535), unsigned 64 bits
+ 636: spr536 (spr536), unsigned 64 bits
+ 637: spr537 (spr537), unsigned 64 bits
+ 638: spr538 (spr538), unsigned 64 bits
+ 639: spr539 (spr539), unsigned 64 bits
+ 640: spr540 (spr540), unsigned 64 bits
+ 641: spr541 (spr541), unsigned 64 bits
+ 642: spr542 (spr542), unsigned 64 bits
+ 643: spr543 (spr543), unsigned 64 bits
+ 644: spr544 (spr544), unsigned 64 bits
+ 645: spr545 (spr545), unsigned 64 bits
+ 646: spr546 (spr546), unsigned 64 bits
+ 647: spr547 (spr547), unsigned 64 bits
+ 648: spr548 (spr548), unsigned 64 bits
+ 649: spr549 (spr549), unsigned 64 bits
+ 650: spr550 (spr550), unsigned 64 bits
+ 651: spr551 (spr551), unsigned 64 bits
+ 652: spr552 (spr552), unsigned 64 bits
+ 653: spr553 (spr553), unsigned 64 bits
+ 654: spr554 (spr554), unsigned 64 bits
+ 655: spr555 (spr555), unsigned 64 bits
+ 656: spr556 (spr556), unsigned 64 bits
+ 657: spr557 (spr557), unsigned 64 bits
+ 658: spr558 (spr558), unsigned 64 bits
+ 659: spr559 (spr559), unsigned 64 bits
+ 660: spr560 (spr560), unsigned 64 bits
+ 661: spr561 (spr561), unsigned 64 bits
+ 662: spr562 (spr562), unsigned 64 bits
+ 663: spr563 (spr563), unsigned 64 bits
+ 664: spr564 (spr564), unsigned 64 bits
+ 665: spr565 (spr565), unsigned 64 bits
+ 666: spr566 (spr566), unsigned 64 bits
+ 667: spr567 (spr567), unsigned 64 bits
+ 668: spr568 (spr568), unsigned 64 bits
+ 669: spr569 (spr569), unsigned 64 bits
+ 670: spr570 (spr570), unsigned 64 bits
+ 671: spr571 (spr571), unsigned 64 bits
+ 672: spr572 (spr572), unsigned 64 bits
+ 673: spr573 (spr573), unsigned 64 bits
+ 674: spr574 (spr574), unsigned 64 bits
+ 675: spr575 (spr575), unsigned 64 bits
+ 676: spr576 (spr576), unsigned 64 bits
+ 677: spr577 (spr577), unsigned 64 bits
+ 678: spr578 (spr578), unsigned 64 bits
+ 679: spr579 (spr579), unsigned 64 bits
+ 680: spr580 (spr580), unsigned 64 bits
+ 681: spr581 (spr581), unsigned 64 bits
+ 682: spr582 (spr582), unsigned 64 bits
+ 683: spr583 (spr583), unsigned 64 bits
+ 684: spr584 (spr584), unsigned 64 bits
+ 685: spr585 (spr585), unsigned 64 bits
+ 686: spr586 (spr586), unsigned 64 bits
+ 687: spr587 (spr587), unsigned 64 bits
+ 688: spr588 (spr588), unsigned 64 bits
+ 689: spr589 (spr589), unsigned 64 bits
+ 690: spr590 (spr590), unsigned 64 bits
+ 691: spr591 (spr591), unsigned 64 bits
+ 692: spr592 (spr592), unsigned 64 bits
+ 693: spr593 (spr593), unsigned 64 bits
+ 694: spr594 (spr594), unsigned 64 bits
+ 695: spr595 (spr595), unsigned 64 bits
+ 696: spr596 (spr596), unsigned 64 bits
+ 697: spr597 (spr597), unsigned 64 bits
+ 698: spr598 (spr598), unsigned 64 bits
+ 699: spr599 (spr599), unsigned 64 bits
+ 700: spr600 (spr600), unsigned 64 bits
+ 701: spr601 (spr601), unsigned 64 bits
+ 702: spr602 (spr602), unsigned 64 bits
+ 703: spr603 (spr603), unsigned 64 bits
+ 704: spr604 (spr604), unsigned 64 bits
+ 705: spr605 (spr605), unsigned 64 bits
+ 706: spr606 (spr606), unsigned 64 bits
+ 707: spr607 (spr607), unsigned 64 bits
+ 708: spr608 (spr608), unsigned 64 bits
+ 709: spr609 (spr609), unsigned 64 bits
+ 710: spr610 (spr610), unsigned 64 bits
+ 711: spr611 (spr611), unsigned 64 bits
+ 712: spr612 (spr612), unsigned 64 bits
+ 713: spr613 (spr613), unsigned 64 bits
+ 714: spr614 (spr614), unsigned 64 bits
+ 715: spr615 (spr615), unsigned 64 bits
+ 716: spr616 (spr616), unsigned 64 bits
+ 717: spr617 (spr617), unsigned 64 bits
+ 718: spr618 (spr618), unsigned 64 bits
+ 719: spr619 (spr619), unsigned 64 bits
+ 720: spr620 (spr620), unsigned 64 bits
+ 721: spr621 (spr621), unsigned 64 bits
+ 722: spr622 (spr622), unsigned 64 bits
+ 723: spr623 (spr623), unsigned 64 bits
+ 724: spr624 (spr624), unsigned 64 bits
+ 725: spr625 (spr625), unsigned 64 bits
+ 726: spr626 (spr626), unsigned 64 bits
+ 727: spr627 (spr627), unsigned 64 bits
+ 728: spr628 (spr628), unsigned 64 bits
+ 729: spr629 (spr629), unsigned 64 bits
+ 730: spr630 (spr630), unsigned 64 bits
+ 731: spr631 (spr631), unsigned 64 bits
+ 732: spr632 (spr632), unsigned 64 bits
+ 733: spr633 (spr633), unsigned 64 bits
+ 734: spr634 (spr634), unsigned 64 bits
+ 735: spr635 (spr635), unsigned 64 bits
+ 736: spr636 (spr636), unsigned 64 bits
+ 737: spr637 (spr637), unsigned 64 bits
+ 738: spr638 (spr638), unsigned 64 bits
+ 739: spr639 (spr639), unsigned 64 bits
+ 740: spr640 (spr640), unsigned 64 bits
+ 741: spr641 (spr641), unsigned 64 bits
+ 742: spr642 (spr642), unsigned 64 bits
+ 743: spr643 (spr643), unsigned 64 bits
+ 744: spr644 (spr644), unsigned 64 bits
+ 745: spr645 (spr645), unsigned 64 bits
+ 746: spr646 (spr646), unsigned 64 bits
+ 747: spr647 (spr647), unsigned 64 bits
+ 748: spr648 (spr648), unsigned 64 bits
+ 749: spr649 (spr649), unsigned 64 bits
+ 750: spr650 (spr650), unsigned 64 bits
+ 751: spr651 (spr651), unsigned 64 bits
+ 752: spr652 (spr652), unsigned 64 bits
+ 753: spr653 (spr653), unsigned 64 bits
+ 754: spr654 (spr654), unsigned 64 bits
+ 755: spr655 (spr655), unsigned 64 bits
+ 756: spr656 (spr656), unsigned 64 bits
+ 757: spr657 (spr657), unsigned 64 bits
+ 758: spr658 (spr658), unsigned 64 bits
+ 759: spr659 (spr659), unsigned 64 bits
+ 760: spr660 (spr660), unsigned 64 bits
+ 761: spr661 (spr661), unsigned 64 bits
+ 762: spr662 (spr662), unsigned 64 bits
+ 763: spr663 (spr663), unsigned 64 bits
+ 764: spr664 (spr664), unsigned 64 bits
+ 765: spr665 (spr665), unsigned 64 bits
+ 766: spr666 (spr666), unsigned 64 bits
+ 767: spr667 (spr667), unsigned 64 bits
+ 768: spr668 (spr668), unsigned 64 bits
+ 769: spr669 (spr669), unsigned 64 bits
+ 770: spr670 (spr670), unsigned 64 bits
+ 771: spr671 (spr671), unsigned 64 bits
+ 772: spr672 (spr672), unsigned 64 bits
+ 773: spr673 (spr673), unsigned 64 bits
+ 774: spr674 (spr674), unsigned 64 bits
+ 775: spr675 (spr675), unsigned 64 bits
+ 776: spr676 (spr676), unsigned 64 bits
+ 777: spr677 (spr677), unsigned 64 bits
+ 778: spr678 (spr678), unsigned 64 bits
+ 779: spr679 (spr679), unsigned 64 bits
+ 780: spr680 (spr680), unsigned 64 bits
+ 781: spr681 (spr681), unsigned 64 bits
+ 782: spr682 (spr682), unsigned 64 bits
+ 783: spr683 (spr683), unsigned 64 bits
+ 784: spr684 (spr684), unsigned 64 bits
+ 785: spr685 (spr685), unsigned 64 bits
+ 786: spr686 (spr686), unsigned 64 bits
+ 787: spr687 (spr687), unsigned 64 bits
+ 788: spr688 (spr688), unsigned 64 bits
+ 789: spr689 (spr689), unsigned 64 bits
+ 790: spr690 (spr690), unsigned 64 bits
+ 791: spr691 (spr691), unsigned 64 bits
+ 792: spr692 (spr692), unsigned 64 bits
+ 793: spr693 (spr693), unsigned 64 bits
+ 794: spr694 (spr694), unsigned 64 bits
+ 795: spr695 (spr695), unsigned 64 bits
+ 796: spr696 (spr696), unsigned 64 bits
+ 797: spr697 (spr697), unsigned 64 bits
+ 798: spr698 (spr698), unsigned 64 bits
+ 799: spr699 (spr699), unsigned 64 bits
+ 800: spr700 (spr700), unsigned 64 bits
+ 801: spr701 (spr701), unsigned 64 bits
+ 802: spr702 (spr702), unsigned 64 bits
+ 803: spr703 (spr703), unsigned 64 bits
+ 804: spr704 (spr704), unsigned 64 bits
+ 805: spr705 (spr705), unsigned 64 bits
+ 806: spr706 (spr706), unsigned 64 bits
+ 807: spr707 (spr707), unsigned 64 bits
+ 808: spr708 (spr708), unsigned 64 bits
+ 809: spr709 (spr709), unsigned 64 bits
+ 810: spr710 (spr710), unsigned 64 bits
+ 811: spr711 (spr711), unsigned 64 bits
+ 812: spr712 (spr712), unsigned 64 bits
+ 813: spr713 (spr713), unsigned 64 bits
+ 814: spr714 (spr714), unsigned 64 bits
+ 815: spr715 (spr715), unsigned 64 bits
+ 816: spr716 (spr716), unsigned 64 bits
+ 817: spr717 (spr717), unsigned 64 bits
+ 818: spr718 (spr718), unsigned 64 bits
+ 819: spr719 (spr719), unsigned 64 bits
+ 820: spr720 (spr720), unsigned 64 bits
+ 821: spr721 (spr721), unsigned 64 bits
+ 822: spr722 (spr722), unsigned 64 bits
+ 823: spr723 (spr723), unsigned 64 bits
+ 824: spr724 (spr724), unsigned 64 bits
+ 825: spr725 (spr725), unsigned 64 bits
+ 826: spr726 (spr726), unsigned 64 bits
+ 827: spr727 (spr727), unsigned 64 bits
+ 828: spr728 (spr728), unsigned 64 bits
+ 829: spr729 (spr729), unsigned 64 bits
+ 830: spr730 (spr730), unsigned 64 bits
+ 831: spr731 (spr731), unsigned 64 bits
+ 832: spr732 (spr732), unsigned 64 bits
+ 833: spr733 (spr733), unsigned 64 bits
+ 834: spr734 (spr734), unsigned 64 bits
+ 835: spr735 (spr735), unsigned 64 bits
+ 836: spr736 (spr736), unsigned 64 bits
+ 837: spr737 (spr737), unsigned 64 bits
+ 838: spr738 (spr738), unsigned 64 bits
+ 839: spr739 (spr739), unsigned 64 bits
+ 840: spr740 (spr740), unsigned 64 bits
+ 841: spr741 (spr741), unsigned 64 bits
+ 842: spr742 (spr742), unsigned 64 bits
+ 843: spr743 (spr743), unsigned 64 bits
+ 844: spr744 (spr744), unsigned 64 bits
+ 845: spr745 (spr745), unsigned 64 bits
+ 846: spr746 (spr746), unsigned 64 bits
+ 847: spr747 (spr747), unsigned 64 bits
+ 848: spr748 (spr748), unsigned 64 bits
+ 849: spr749 (spr749), unsigned 64 bits
+ 850: spr750 (spr750), unsigned 64 bits
+ 851: spr751 (spr751), unsigned 64 bits
+ 852: spr752 (spr752), unsigned 64 bits
+ 853: spr753 (spr753), unsigned 64 bits
+ 854: spr754 (spr754), unsigned 64 bits
+ 855: spr755 (spr755), unsigned 64 bits
+ 856: spr756 (spr756), unsigned 64 bits
+ 857: spr757 (spr757), unsigned 64 bits
+ 858: spr758 (spr758), unsigned 64 bits
+ 859: spr759 (spr759), unsigned 64 bits
+ 860: spr760 (spr760), unsigned 64 bits
+ 861: spr761 (spr761), unsigned 64 bits
+ 862: spr762 (spr762), unsigned 64 bits
+ 863: spr763 (spr763), unsigned 64 bits
+ 864: spr764 (spr764), unsigned 64 bits
+ 865: spr765 (spr765), unsigned 64 bits
+ 866: spr766 (spr766), unsigned 64 bits
+ 867: spr767 (spr767), unsigned 64 bits
+ 868: spr768 (spr768), unsigned 64 bits
+ 869: spr769 (spr769), unsigned 64 bits
+ 870: spr770 (spr770), unsigned 64 bits
+ 871: spr771 (spr771), unsigned 64 bits
+ 872: spr772 (spr772), unsigned 64 bits
+ 873: spr773 (spr773), unsigned 64 bits
+ 874: spr774 (spr774), unsigned 64 bits
+ 875: spr775 (spr775), unsigned 64 bits
+ 876: spr776 (spr776), unsigned 64 bits
+ 877: spr777 (spr777), unsigned 64 bits
+ 878: spr778 (spr778), unsigned 64 bits
+ 879: spr779 (spr779), unsigned 64 bits
+ 880: spr780 (spr780), unsigned 64 bits
+ 881: spr781 (spr781), unsigned 64 bits
+ 882: spr782 (spr782), unsigned 64 bits
+ 883: spr783 (spr783), unsigned 64 bits
+ 884: spr784 (spr784), unsigned 64 bits
+ 885: spr785 (spr785), unsigned 64 bits
+ 886: spr786 (spr786), unsigned 64 bits
+ 887: spr787 (spr787), unsigned 64 bits
+ 888: spr788 (spr788), unsigned 64 bits
+ 889: spr789 (spr789), unsigned 64 bits
+ 890: spr790 (spr790), unsigned 64 bits
+ 891: spr791 (spr791), unsigned 64 bits
+ 892: spr792 (spr792), unsigned 64 bits
+ 893: spr793 (spr793), unsigned 64 bits
+ 894: spr794 (spr794), unsigned 64 bits
+ 895: spr795 (spr795), unsigned 64 bits
+ 896: spr796 (spr796), unsigned 64 bits
+ 897: spr797 (spr797), unsigned 64 bits
+ 898: spr798 (spr798), unsigned 64 bits
+ 899: spr799 (spr799), unsigned 64 bits
+ 900: spr800 (spr800), unsigned 64 bits
+ 901: spr801 (spr801), unsigned 64 bits
+ 902: spr802 (spr802), unsigned 64 bits
+ 903: spr803 (spr803), unsigned 64 bits
+ 904: spr804 (spr804), unsigned 64 bits
+ 905: spr805 (spr805), unsigned 64 bits
+ 906: spr806 (spr806), unsigned 64 bits
+ 907: spr807 (spr807), unsigned 64 bits
+ 908: spr808 (spr808), unsigned 64 bits
+ 909: spr809 (spr809), unsigned 64 bits
+ 910: spr810 (spr810), unsigned 64 bits
+ 911: spr811 (spr811), unsigned 64 bits
+ 912: spr812 (spr812), unsigned 64 bits
+ 913: spr813 (spr813), unsigned 64 bits
+ 914: spr814 (spr814), unsigned 64 bits
+ 915: spr815 (spr815), unsigned 64 bits
+ 916: spr816 (spr816), unsigned 64 bits
+ 917: spr817 (spr817), unsigned 64 bits
+ 918: spr818 (spr818), unsigned 64 bits
+ 919: spr819 (spr819), unsigned 64 bits
+ 920: spr820 (spr820), unsigned 64 bits
+ 921: spr821 (spr821), unsigned 64 bits
+ 922: spr822 (spr822), unsigned 64 bits
+ 923: spr823 (spr823), unsigned 64 bits
+ 924: spr824 (spr824), unsigned 64 bits
+ 925: spr825 (spr825), unsigned 64 bits
+ 926: spr826 (spr826), unsigned 64 bits
+ 927: spr827 (spr827), unsigned 64 bits
+ 928: spr828 (spr828), unsigned 64 bits
+ 929: spr829 (spr829), unsigned 64 bits
+ 930: spr830 (spr830), unsigned 64 bits
+ 931: spr831 (spr831), unsigned 64 bits
+ 932: spr832 (spr832), unsigned 64 bits
+ 933: spr833 (spr833), unsigned 64 bits
+ 934: spr834 (spr834), unsigned 64 bits
+ 935: spr835 (spr835), unsigned 64 bits
+ 936: spr836 (spr836), unsigned 64 bits
+ 937: spr837 (spr837), unsigned 64 bits
+ 938: spr838 (spr838), unsigned 64 bits
+ 939: spr839 (spr839), unsigned 64 bits
+ 940: spr840 (spr840), unsigned 64 bits
+ 941: spr841 (spr841), unsigned 64 bits
+ 942: spr842 (spr842), unsigned 64 bits
+ 943: spr843 (spr843), unsigned 64 bits
+ 944: spr844 (spr844), unsigned 64 bits
+ 945: spr845 (spr845), unsigned 64 bits
+ 946: spr846 (spr846), unsigned 64 bits
+ 947: spr847 (spr847), unsigned 64 bits
+ 948: spr848 (spr848), unsigned 64 bits
+ 949: spr849 (spr849), unsigned 64 bits
+ 950: spr850 (spr850), unsigned 64 bits
+ 951: spr851 (spr851), unsigned 64 bits
+ 952: spr852 (spr852), unsigned 64 bits
+ 953: spr853 (spr853), unsigned 64 bits
+ 954: spr854 (spr854), unsigned 64 bits
+ 955: spr855 (spr855), unsigned 64 bits
+ 956: spr856 (spr856), unsigned 64 bits
+ 957: spr857 (spr857), unsigned 64 bits
+ 958: spr858 (spr858), unsigned 64 bits
+ 959: spr859 (spr859), unsigned 64 bits
+ 960: spr860 (spr860), unsigned 64 bits
+ 961: spr861 (spr861), unsigned 64 bits
+ 962: spr862 (spr862), unsigned 64 bits
+ 963: spr863 (spr863), unsigned 64 bits
+ 964: spr864 (spr864), unsigned 64 bits
+ 965: spr865 (spr865), unsigned 64 bits
+ 966: spr866 (spr866), unsigned 64 bits
+ 967: spr867 (spr867), unsigned 64 bits
+ 968: spr868 (spr868), unsigned 64 bits
+ 969: spr869 (spr869), unsigned 64 bits
+ 970: spr870 (spr870), unsigned 64 bits
+ 971: spr871 (spr871), unsigned 64 bits
+ 972: spr872 (spr872), unsigned 64 bits
+ 973: spr873 (spr873), unsigned 64 bits
+ 974: spr874 (spr874), unsigned 64 bits
+ 975: spr875 (spr875), unsigned 64 bits
+ 976: spr876 (spr876), unsigned 64 bits
+ 977: spr877 (spr877), unsigned 64 bits
+ 978: spr878 (spr878), unsigned 64 bits
+ 979: spr879 (spr879), unsigned 64 bits
+ 980: spr880 (spr880), unsigned 64 bits
+ 981: spr881 (spr881), unsigned 64 bits
+ 982: spr882 (spr882), unsigned 64 bits
+ 983: spr883 (spr883), unsigned 64 bits
+ 984: spr884 (spr884), unsigned 64 bits
+ 985: spr885 (spr885), unsigned 64 bits
+ 986: spr886 (spr886), unsigned 64 bits
+ 987: spr887 (spr887), unsigned 64 bits
+ 988: spr888 (spr888), unsigned 64 bits
+ 989: spr889 (spr889), unsigned 64 bits
+ 990: spr890 (spr890), unsigned 64 bits
+ 991: spr891 (spr891), unsigned 64 bits
+ 992: spr892 (spr892), unsigned 64 bits
+ 993: spr893 (spr893), unsigned 64 bits
+ 994: spr894 (spr894), unsigned 64 bits
+ 995: spr895 (spr895), unsigned 64 bits
+ 996: spr896 (spr896), unsigned 64 bits
+ 997: spr897 (spr897), unsigned 64 bits
+ 998: spr898 (spr898), unsigned 64 bits
+ 999: spr899 (spr899), unsigned 64 bits
+vector registers:
+ 67: vscr (vscr), unsigned 32 bits
+ 356: vrsave (vrsave), unsigned 32 bits
+ 612: spefscr (spefscr), unsigned 32 bits
+ 1124: vr0 (vr0), unsigned 128 bits
+ 1125: vr1 (vr1), unsigned 128 bits
+ 1126: vr2 (vr2), unsigned 128 bits
+ 1127: vr3 (vr3), unsigned 128 bits
+ 1128: vr4 (vr4), unsigned 128 bits
+ 1129: vr5 (vr5), unsigned 128 bits
+ 1130: vr6 (vr6), unsigned 128 bits
+ 1131: vr7 (vr7), unsigned 128 bits
+ 1132: vr8 (vr8), unsigned 128 bits
+ 1133: vr9 (vr9), unsigned 128 bits
+ 1134: vr10 (vr10), unsigned 128 bits
+ 1135: vr11 (vr11), unsigned 128 bits
+ 1136: vr12 (vr12), unsigned 128 bits
+ 1137: vr13 (vr13), unsigned 128 bits
+ 1138: vr14 (vr14), unsigned 128 bits
+ 1139: vr15 (vr15), unsigned 128 bits
+ 1140: vr16 (vr16), unsigned 128 bits
+ 1141: vr17 (vr17), unsigned 128 bits
+ 1142: vr18 (vr18), unsigned 128 bits
+ 1143: vr19 (vr19), unsigned 128 bits
+ 1144: vr20 (vr20), unsigned 128 bits
+ 1145: vr21 (vr21), unsigned 128 bits
+ 1146: vr22 (vr22), unsigned 128 bits
+ 1147: vr23 (vr23), unsigned 128 bits
+ 1148: vr24 (vr24), unsigned 128 bits
+ 1149: vr25 (vr25), unsigned 128 bits
+ 1150: vr26 (vr26), unsigned 128 bits
+ 1151: vr27 (vr27), unsigned 128 bits
+ 1152: vr28 (vr28), unsigned 128 bits
+ 1153: vr29 (vr29), unsigned 128 bits
+ 1154: vr30 (vr30), unsigned 128 bits
+ 1155: vr31 (vr31), unsigned 128 bits
+EOF
+
+regs_test testfile26 <<\EOF
+integer registers:
+ 0: %r0 (r0), signed 32 bits
+ 1: %r1 (r1), signed 32 bits
+ 2: %r2 (r2), signed 32 bits
+ 3: %r3 (r3), signed 32 bits
+ 4: %r4 (r4), signed 32 bits
+ 5: %r5 (r5), signed 32 bits
+ 6: %r6 (r6), signed 32 bits
+ 7: %r7 (r7), signed 32 bits
+ 8: %r8 (r8), signed 32 bits
+ 9: %r9 (r9), signed 32 bits
+ 10: %r10 (r10), signed 32 bits
+ 11: %r11 (r11), signed 32 bits
+ 12: %r12 (r12), signed 32 bits
+ 13: %r13 (r13), signed 32 bits
+ 14: %r14 (r14), signed 32 bits
+ 15: %r15 (r15), signed 32 bits
+FPU registers:
+ 16: %f0 (f0), float 64 bits
+ 17: %f2 (f2), float 64 bits
+ 18: %f4 (f4), float 64 bits
+ 19: %f6 (f6), float 64 bits
+ 20: %f1 (f1), float 64 bits
+ 21: %f3 (f3), float 64 bits
+ 22: %f5 (f5), float 64 bits
+ 23: %f7 (f7), float 64 bits
+ 24: %f8 (f8), float 64 bits
+ 25: %f10 (f10), float 64 bits
+ 26: %f12 (f12), float 64 bits
+ 27: %f14 (f14), float 64 bits
+ 28: %f9 (f9), float 64 bits
+ 29: %f11 (f11), float 64 bits
+ 30: %f13 (f13), float 64 bits
+ 31: %f15 (f15), float 64 bits
+access registers:
+ 48: %a0 (a0), unsigned 32 bits
+ 49: %a1 (a1), unsigned 32 bits
+ 50: %a2 (a2), unsigned 32 bits
+ 51: %a3 (a3), unsigned 32 bits
+ 52: %a4 (a4), unsigned 32 bits
+ 53: %a5 (a5), unsigned 32 bits
+ 54: %a6 (a6), unsigned 32 bits
+ 55: %a7 (a7), unsigned 32 bits
+ 56: %a8 (a8), unsigned 32 bits
+ 57: %a9 (a9), unsigned 32 bits
+ 58: %a10 (a10), unsigned 32 bits
+ 59: %a11 (a11), unsigned 32 bits
+ 60: %a12 (a12), unsigned 32 bits
+ 61: %a13 (a13), unsigned 32 bits
+ 62: %a14 (a14), unsigned 32 bits
+ 63: %a15 (a15), unsigned 32 bits
+control registers:
+ 32: %c0 (c0), unsigned 32 bits
+ 33: %c1 (c1), unsigned 32 bits
+ 34: %c2 (c2), unsigned 32 bits
+ 35: %c3 (c3), unsigned 32 bits
+ 36: %c4 (c4), unsigned 32 bits
+ 37: %c5 (c5), unsigned 32 bits
+ 38: %c6 (c6), unsigned 32 bits
+ 39: %c7 (c7), unsigned 32 bits
+ 40: %c8 (c8), unsigned 32 bits
+ 41: %c9 (c9), unsigned 32 bits
+ 42: %c10 (c10), unsigned 32 bits
+ 43: %c11 (c11), unsigned 32 bits
+ 44: %c12 (c12), unsigned 32 bits
+ 45: %c13 (c13), unsigned 32 bits
+ 46: %c14 (c14), unsigned 32 bits
+ 47: %c15 (c15), unsigned 32 bits
+ 64: %pswm (pswm), unsigned 32 bits
+ 65: %pswa (pswa), address 32 bits
+EOF
+
+regs_test testfile27 <<\EOF
+integer registers:
+ 0: %r0 (r0), signed 64 bits
+ 1: %r1 (r1), signed 64 bits
+ 2: %r2 (r2), signed 64 bits
+ 3: %r3 (r3), signed 64 bits
+ 4: %r4 (r4), signed 64 bits
+ 5: %r5 (r5), signed 64 bits
+ 6: %r6 (r6), signed 64 bits
+ 7: %r7 (r7), signed 64 bits
+ 8: %r8 (r8), signed 64 bits
+ 9: %r9 (r9), signed 64 bits
+ 10: %r10 (r10), signed 64 bits
+ 11: %r11 (r11), signed 64 bits
+ 12: %r12 (r12), signed 64 bits
+ 13: %r13 (r13), signed 64 bits
+ 14: %r14 (r14), signed 64 bits
+ 15: %r15 (r15), signed 64 bits
+FPU registers:
+ 16: %f0 (f0), float 64 bits
+ 17: %f2 (f2), float 64 bits
+ 18: %f4 (f4), float 64 bits
+ 19: %f6 (f6), float 64 bits
+ 20: %f1 (f1), float 64 bits
+ 21: %f3 (f3), float 64 bits
+ 22: %f5 (f5), float 64 bits
+ 23: %f7 (f7), float 64 bits
+ 24: %f8 (f8), float 64 bits
+ 25: %f10 (f10), float 64 bits
+ 26: %f12 (f12), float 64 bits
+ 27: %f14 (f14), float 64 bits
+ 28: %f9 (f9), float 64 bits
+ 29: %f11 (f11), float 64 bits
+ 30: %f13 (f13), float 64 bits
+ 31: %f15 (f15), float 64 bits
+access registers:
+ 48: %a0 (a0), unsigned 32 bits
+ 49: %a1 (a1), unsigned 32 bits
+ 50: %a2 (a2), unsigned 32 bits
+ 51: %a3 (a3), unsigned 32 bits
+ 52: %a4 (a4), unsigned 32 bits
+ 53: %a5 (a5), unsigned 32 bits
+ 54: %a6 (a6), unsigned 32 bits
+ 55: %a7 (a7), unsigned 32 bits
+ 56: %a8 (a8), unsigned 32 bits
+ 57: %a9 (a9), unsigned 32 bits
+ 58: %a10 (a10), unsigned 32 bits
+ 59: %a11 (a11), unsigned 32 bits
+ 60: %a12 (a12), unsigned 32 bits
+ 61: %a13 (a13), unsigned 32 bits
+ 62: %a14 (a14), unsigned 32 bits
+ 63: %a15 (a15), unsigned 32 bits
+control registers:
+ 32: %c0 (c0), unsigned 64 bits
+ 33: %c1 (c1), unsigned 64 bits
+ 34: %c2 (c2), unsigned 64 bits
+ 35: %c3 (c3), unsigned 64 bits
+ 36: %c4 (c4), unsigned 64 bits
+ 37: %c5 (c5), unsigned 64 bits
+ 38: %c6 (c6), unsigned 64 bits
+ 39: %c7 (c7), unsigned 64 bits
+ 40: %c8 (c8), unsigned 64 bits
+ 41: %c9 (c9), unsigned 64 bits
+ 42: %c10 (c10), unsigned 64 bits
+ 43: %c11 (c11), unsigned 64 bits
+ 44: %c12 (c12), unsigned 64 bits
+ 45: %c13 (c13), unsigned 64 bits
+ 46: %c14 (c14), unsigned 64 bits
+ 47: %c15 (c15), unsigned 64 bits
+ 64: %pswm (pswm), unsigned 64 bits
+ 65: %pswa (pswa), address 64 bits
+EOF
+
+regs_test testfile30 <<\EOF
+integer registers:
+ 0: %g0 (g0), signed 32 bits
+ 1: %g1 (g1), signed 32 bits
+ 2: %g2 (g2), signed 32 bits
+ 3: %g3 (g3), signed 32 bits
+ 4: %g4 (g4), signed 32 bits
+ 5: %g5 (g5), signed 32 bits
+ 6: %g6 (g6), signed 32 bits
+ 7: %g7 (g7), signed 32 bits
+ 8: %o0 (o0), signed 32 bits
+ 9: %o1 (o1), signed 32 bits
+ 10: %o2 (o2), signed 32 bits
+ 11: %o3 (o3), signed 32 bits
+ 12: %o4 (o4), signed 32 bits
+ 13: %o5 (o5), signed 32 bits
+ 14: %o6 (o6), address 32 bits
+ 15: %o7 (o7), signed 32 bits
+ 16: %l0 (l0), signed 32 bits
+ 17: %l1 (l1), signed 32 bits
+ 18: %l2 (l2), signed 32 bits
+ 19: %l3 (l3), signed 32 bits
+ 20: %l4 (l4), signed 32 bits
+ 21: %l5 (l5), signed 32 bits
+ 22: %l6 (l6), signed 32 bits
+ 23: %l7 (l7), signed 32 bits
+ 24: %i0 (i0), signed 32 bits
+ 25: %i1 (i1), signed 32 bits
+ 26: %i2 (i2), signed 32 bits
+ 27: %i3 (i3), signed 32 bits
+ 28: %i4 (i4), signed 32 bits
+ 29: %i5 (i5), signed 32 bits
+ 30: %i6 (i6), address 32 bits
+ 31: %i7 (i7), signed 32 bits
+FPU registers:
+ 32: %f0 (f0), float 32 bits
+ 33: %f1 (f1), float 32 bits
+ 34: %f2 (f2), float 32 bits
+ 35: %f3 (f3), float 32 bits
+ 36: %f4 (f4), float 32 bits
+ 37: %f5 (f5), float 32 bits
+ 38: %f6 (f6), float 32 bits
+ 39: %f7 (f7), float 32 bits
+ 40: %f8 (f8), float 32 bits
+ 41: %f9 (f9), float 32 bits
+ 42: %f10 (f10), float 32 bits
+ 43: %f11 (f11), float 32 bits
+ 44: %f12 (f12), float 32 bits
+ 45: %f13 (f13), float 32 bits
+ 46: %f14 (f14), float 32 bits
+ 47: %f15 (f15), float 32 bits
+ 48: %f16 (f16), float 32 bits
+ 49: %f17 (f17), float 32 bits
+ 50: %f18 (f18), float 32 bits
+ 51: %f19 (f19), float 32 bits
+ 52: %f20 (f20), float 32 bits
+ 53: %f21 (f21), float 32 bits
+ 54: %f22 (f22), float 32 bits
+ 55: %f23 (f23), float 32 bits
+ 56: %f24 (f24), float 32 bits
+ 57: %f25 (f25), float 32 bits
+ 58: %f26 (f26), float 32 bits
+ 59: %f27 (f27), float 32 bits
+ 60: %f28 (f28), float 32 bits
+ 61: %f29 (f29), float 32 bits
+ 62: %f30 (f30), float 32 bits
+ 63: %f31 (f31), float 32 bits
+control registers:
+ 64: %y (y), unsigned 32 bits
+ 65: %psr (psr), unsigned 32 bits
+ 66: %wim (wim), unsigned 32 bits
+ 67: %tbr (tbr), unsigned 32 bits
+ 68: %pc (pc), address 32 bits
+ 69: %npc (npc), address 32 bits
+ 70: %fsr (fsr), unsigned 32 bits
+ 71: %csr (csr), unsigned 32 bits
+EOF
+
+regs_test testfile31 <<\EOF
+integer registers:
+ 0: %g0 (g0), signed 64 bits
+ 1: %g1 (g1), signed 64 bits
+ 2: %g2 (g2), signed 64 bits
+ 3: %g3 (g3), signed 64 bits
+ 4: %g4 (g4), signed 64 bits
+ 5: %g5 (g5), signed 64 bits
+ 6: %g6 (g6), signed 64 bits
+ 7: %g7 (g7), signed 64 bits
+ 8: %o0 (o0), signed 64 bits
+ 9: %o1 (o1), signed 64 bits
+ 10: %o2 (o2), signed 64 bits
+ 11: %o3 (o3), signed 64 bits
+ 12: %o4 (o4), signed 64 bits
+ 13: %o5 (o5), signed 64 bits
+ 14: %o6 (o6), address 64 bits
+ 15: %o7 (o7), signed 64 bits
+ 16: %l0 (l0), signed 64 bits
+ 17: %l1 (l1), signed 64 bits
+ 18: %l2 (l2), signed 64 bits
+ 19: %l3 (l3), signed 64 bits
+ 20: %l4 (l4), signed 64 bits
+ 21: %l5 (l5), signed 64 bits
+ 22: %l6 (l6), signed 64 bits
+ 23: %l7 (l7), signed 64 bits
+ 24: %i0 (i0), signed 64 bits
+ 25: %i1 (i1), signed 64 bits
+ 26: %i2 (i2), signed 64 bits
+ 27: %i3 (i3), signed 64 bits
+ 28: %i4 (i4), signed 64 bits
+ 29: %i5 (i5), signed 64 bits
+ 30: %i6 (i6), address 64 bits
+ 31: %i7 (i7), signed 64 bits
+FPU registers:
+ 32: %f0 (f0), float 32 bits
+ 33: %f1 (f1), float 32 bits
+ 34: %f2 (f2), float 32 bits
+ 35: %f3 (f3), float 32 bits
+ 36: %f4 (f4), float 32 bits
+ 37: %f5 (f5), float 32 bits
+ 38: %f6 (f6), float 32 bits
+ 39: %f7 (f7), float 32 bits
+ 40: %f8 (f8), float 32 bits
+ 41: %f9 (f9), float 32 bits
+ 42: %f10 (f10), float 32 bits
+ 43: %f11 (f11), float 32 bits
+ 44: %f12 (f12), float 32 bits
+ 45: %f13 (f13), float 32 bits
+ 46: %f14 (f14), float 32 bits
+ 47: %f15 (f15), float 32 bits
+ 48: %f16 (f16), float 32 bits
+ 49: %f17 (f17), float 32 bits
+ 50: %f18 (f18), float 32 bits
+ 51: %f19 (f19), float 32 bits
+ 52: %f20 (f20), float 32 bits
+ 53: %f21 (f21), float 32 bits
+ 54: %f22 (f22), float 32 bits
+ 55: %f23 (f23), float 32 bits
+ 56: %f24 (f24), float 32 bits
+ 57: %f25 (f25), float 32 bits
+ 58: %f26 (f26), float 32 bits
+ 59: %f27 (f27), float 32 bits
+ 60: %f28 (f28), float 32 bits
+ 61: %f29 (f29), float 32 bits
+ 62: %f30 (f30), float 32 bits
+ 63: %f31 (f31), float 32 bits
+ 64: %f32 (f32), float 64 bits
+ 65: %f34 (f34), float 64 bits
+ 66: %f36 (f36), float 64 bits
+ 67: %f38 (f38), float 64 bits
+ 68: %f40 (f40), float 64 bits
+ 69: %f42 (f42), float 64 bits
+ 70: %f44 (f44), float 64 bits
+ 71: %f46 (f46), float 64 bits
+ 72: %f48 (f48), float 64 bits
+ 73: %f50 (f50), float 64 bits
+ 74: %f52 (f52), float 64 bits
+ 75: %f54 (f54), float 64 bits
+ 76: %f56 (f56), float 64 bits
+ 77: %f58 (f58), float 64 bits
+ 78: %f60 (f60), float 64 bits
+ 79: %f62 (f62), float 64 bits
+control registers:
+ 80: %pc (pc), address 64 bits
+ 81: %npc (npc), address 64 bits
+ 82: %state (state), unsigned 64 bits
+ 83: %fsr (fsr), unsigned 64 bits
+ 84: %fprs (fprs), unsigned 64 bits
+ 85: %y (y), unsigned 64 bits
+EOF
+
+regs_test testfile10 <<\EOF
+integer registers:
+ 0: $v0 (v0), signed 64 bits
+ 1: $t0 (t0), signed 64 bits
+ 2: $t1 (t1), signed 64 bits
+ 3: $t2 (t2), signed 64 bits
+ 4: $t3 (t3), signed 64 bits
+ 5: $t4 (t4), signed 64 bits
+ 6: $t5 (t5), signed 64 bits
+ 7: $t6 (t6), signed 64 bits
+ 8: $t7 (t7), signed 64 bits
+ 9: $s0 (s0), signed 64 bits
+ 10: $s1 (s1), signed 64 bits
+ 11: $s2 (s2), signed 64 bits
+ 12: $s3 (s3), signed 64 bits
+ 13: $s4 (s4), signed 64 bits
+ 14: $s5 (s5), signed 64 bits
+ 15: $s6 (s6), signed 64 bits
+ 16: $a0 (a0), signed 64 bits
+ 17: $a1 (a1), signed 64 bits
+ 18: $a2 (a2), signed 64 bits
+ 19: $a3 (a3), signed 64 bits
+ 20: $a4 (a4), signed 64 bits
+ 21: $a5 (a5), signed 64 bits
+ 22: $t8 (t8), signed 64 bits
+ 23: $t9 (t9), signed 64 bits
+ 24: $t10 (t10), signed 64 bits
+ 25: $t11 (t11), signed 64 bits
+ 26: $ra (ra), address 64 bits
+ 27: $t12 (t12), signed 64 bits
+ 28: $at (at), signed 64 bits
+ 29: $gp (gp), address 64 bits
+ 30: $sp (sp), address 64 bits
+ 31: $zero (zero), signed 64 bits
+ 64: $pc (pc), address 64 bits
+ 66: $unique (unique), address 64 bits
+FPU registers:
+ 32: $f0 (f0), float 64 bits
+ 33: $f1 (f1), float 64 bits
+ 34: $f2 (f2), float 64 bits
+ 35: $f3 (f3), float 64 bits
+ 36: $f4 (f4), float 64 bits
+ 37: $f5 (f5), float 64 bits
+ 38: $f6 (f6), float 64 bits
+ 39: $f7 (f7), float 64 bits
+ 40: $f8 (f8), float 64 bits
+ 41: $f9 (f9), float 64 bits
+ 42: $f10 (f10), float 64 bits
+ 43: $f11 (f11), float 64 bits
+ 44: $f12 (f12), float 64 bits
+ 45: $f13 (f13), float 64 bits
+ 46: $f14 (f14), float 64 bits
+ 47: $f15 (f15), float 64 bits
+ 48: $f16 (f16), float 64 bits
+ 49: $f17 (f17), float 64 bits
+ 50: $f18 (f18), float 64 bits
+ 51: $f19 (f19), float 64 bits
+ 52: $f20 (f20), float 64 bits
+ 53: $f21 (f21), float 64 bits
+ 54: $f22 (f22), float 64 bits
+ 55: $f23 (f23), float 64 bits
+ 56: $f24 (f24), float 64 bits
+ 57: $f25 (f25), float 64 bits
+ 58: $f26 (f26), float 64 bits
+ 59: $f27 (f27), float 64 bits
+ 60: $f28 (f28), float 64 bits
+ 61: $f29 (f29), float 64 bits
+ 62: $f30 (f30), float 64 bits
+ 63: $fpcr (fpcr), unsigned 64 bits
+EOF
+
+regs_test testfile60 <<\EOF
+integer registers:
+ 0: r0 (r0), signed 64 bits
+ 1: r1 (r1), signed 64 bits
+ 2: r2 (r2), signed 64 bits
+ 3: r3 (r3), signed 64 bits
+ 4: r4 (r4), signed 64 bits
+ 5: r5 (r5), signed 64 bits
+ 6: r6 (r6), signed 64 bits
+ 7: r7 (r7), signed 64 bits
+ 8: r8 (r8), signed 64 bits
+ 9: r9 (r9), signed 64 bits
+ 10: r10 (r10), signed 64 bits
+ 11: r11 (r11), signed 64 bits
+ 12: r12 (r12), signed 64 bits
+ 13: r13 (r13), signed 64 bits
+ 14: r14 (r14), signed 64 bits
+ 15: r15 (r15), signed 64 bits
+ 16: r16 (r16), signed 64 bits
+ 17: r17 (r17), signed 64 bits
+ 18: r18 (r18), signed 64 bits
+ 19: r19 (r19), signed 64 bits
+ 20: r20 (r20), signed 64 bits
+ 21: r21 (r21), signed 64 bits
+ 22: r22 (r22), signed 64 bits
+ 23: r23 (r23), signed 64 bits
+ 24: r24 (r24), signed 64 bits
+ 25: r25 (r25), signed 64 bits
+ 26: r26 (r26), signed 64 bits
+ 27: r27 (r27), signed 64 bits
+ 28: r28 (r28), signed 64 bits
+ 29: r29 (r29), signed 64 bits
+ 30: r30 (r30), signed 64 bits
+ 31: r31 (r31), signed 64 bits
+ 32: r32 (r32), signed 64 bits
+ 33: r33 (r33), signed 64 bits
+ 34: r34 (r34), signed 64 bits
+ 35: r35 (r35), signed 64 bits
+ 36: r36 (r36), signed 64 bits
+ 37: r37 (r37), signed 64 bits
+ 38: r38 (r38), signed 64 bits
+ 39: r39 (r39), signed 64 bits
+ 40: r40 (r40), signed 64 bits
+ 41: r41 (r41), signed 64 bits
+ 42: r42 (r42), signed 64 bits
+ 43: r43 (r43), signed 64 bits
+ 44: r44 (r44), signed 64 bits
+ 45: r45 (r45), signed 64 bits
+ 46: r46 (r46), signed 64 bits
+ 47: r47 (r47), signed 64 bits
+ 48: r48 (r48), signed 64 bits
+ 49: r49 (r49), signed 64 bits
+ 50: r50 (r50), signed 64 bits
+ 51: r51 (r51), signed 64 bits
+ 52: r52 (r52), signed 64 bits
+ 53: tp (tp), address 64 bits
+ 54: sp (sp), address 64 bits
+ 55: lr (lr), address 64 bits
+ 56: sn (sn), unsigned 64 bits
+ 57: idn0 (idn0), unsigned 64 bits
+ 58: idn1 (idn1), unsigned 64 bits
+ 59: udn0 (udn0), unsigned 64 bits
+ 60: udn1 (udn1), unsigned 64 bits
+ 61: udn2 (udn2), unsigned 64 bits
+ 62: udn3 (udn3), unsigned 64 bits
+ 63: zero (zero), unsigned 64 bits
+ 64: pc (pc), address 64 bits
+EOF
+
+regs_test testfile61 <<\EOF
+integer registers:
+ 0: r0 (r0), signed 32 bits
+ 1: r1 (r1), signed 32 bits
+ 2: r2 (r2), signed 32 bits
+ 3: r3 (r3), signed 32 bits
+ 4: r4 (r4), signed 32 bits
+ 5: r5 (r5), signed 32 bits
+ 6: r6 (r6), signed 32 bits
+ 7: r7 (r7), signed 32 bits
+ 8: r8 (r8), signed 32 bits
+ 9: r9 (r9), signed 32 bits
+ 10: r10 (r10), signed 32 bits
+ 11: r11 (r11), signed 32 bits
+ 12: r12 (r12), signed 32 bits
+ 13: sp (sp), address 32 bits
+ 14: lr (lr), address 32 bits
+ 15: pc (pc), address 32 bits
+ 128: spsr (spsr), unsigned 32 bits
+FPA registers:
+ 16: f0 (f0), float 96 bits
+ 17: f1 (f1), float 96 bits
+ 18: f2 (f2), float 96 bits
+ 19: f3 (f3), float 96 bits
+ 20: f4 (f4), float 96 bits
+ 21: f5 (f5), float 96 bits
+ 22: f6 (f6), float 96 bits
+ 23: f7 (f7), float 96 bits
+ 96: f0 (f0), float 96 bits
+ 97: f1 (f1), float 96 bits
+ 98: f2 (f2), float 96 bits
+ 99: f3 (f3), float 96 bits
+ 100: f4 (f4), float 96 bits
+ 101: f5 (f5), float 96 bits
+ 102: f6 (f6), float 96 bits
+ 103: f7 (f7), float 96 bits
+VFP registers:
+ 256: d0 (d0), float 64 bits
+ 257: d1 (d1), float 64 bits
+ 258: d2 (d2), float 64 bits
+ 259: d3 (d3), float 64 bits
+ 260: d4 (d4), float 64 bits
+ 261: d5 (d5), float 64 bits
+ 262: d6 (d6), float 64 bits
+ 263: d7 (d7), float 64 bits
+ 264: d8 (d8), float 64 bits
+ 265: d9 (d9), float 64 bits
+ 266: d10 (d10), float 64 bits
+ 267: d11 (d11), float 64 bits
+ 268: d12 (d12), float 64 bits
+ 269: d13 (d13), float 64 bits
+ 270: d14 (d14), float 64 bits
+ 271: d15 (d15), float 64 bits
+ 272: d16 (d16), float 64 bits
+ 273: d17 (d17), float 64 bits
+ 274: d18 (d18), float 64 bits
+ 275: d19 (d19), float 64 bits
+ 276: d20 (d20), float 64 bits
+ 277: d21 (d21), float 64 bits
+ 278: d22 (d22), float 64 bits
+ 279: d23 (d23), float 64 bits
+ 280: d24 (d24), float 64 bits
+ 281: d25 (d25), float 64 bits
+ 282: d26 (d26), float 64 bits
+ 283: d27 (d27), float 64 bits
+ 284: d28 (d28), float 64 bits
+ 285: d29 (d29), float 64 bits
+ 286: d30 (d30), float 64 bits
+ 287: d31 (d31), float 64 bits
+EOF
+
+# See run-readelf-mixed-corenote.sh for instructions to regenerate
+# this core file.
+regs_test testfile_aarch64_core <<\EOF
+integer registers:
+ 0: x0 (x0), signed 64 bits
+ 1: x1 (x1), signed 64 bits
+ 2: x2 (x2), signed 64 bits
+ 3: x3 (x3), signed 64 bits
+ 4: x4 (x4), signed 64 bits
+ 5: x5 (x5), signed 64 bits
+ 6: x6 (x6), signed 64 bits
+ 7: x7 (x7), signed 64 bits
+ 8: x8 (x8), signed 64 bits
+ 9: x9 (x9), signed 64 bits
+ 10: x10 (x10), signed 64 bits
+ 11: x11 (x11), signed 64 bits
+ 12: x12 (x12), signed 64 bits
+ 13: x13 (x13), signed 64 bits
+ 14: x14 (x14), signed 64 bits
+ 15: x15 (x15), signed 64 bits
+ 16: x16 (x16), signed 64 bits
+ 17: x17 (x17), signed 64 bits
+ 18: x18 (x18), signed 64 bits
+ 19: x19 (x19), signed 64 bits
+ 20: x20 (x20), signed 64 bits
+ 21: x21 (x21), signed 64 bits
+ 22: x22 (x22), signed 64 bits
+ 23: x23 (x23), signed 64 bits
+ 24: x24 (x24), signed 64 bits
+ 25: x25 (x25), signed 64 bits
+ 26: x26 (x26), signed 64 bits
+ 27: x27 (x27), signed 64 bits
+ 28: x28 (x28), signed 64 bits
+ 29: x29 (x29), signed 64 bits
+ 30: x30 (x30), signed 64 bits
+ 31: sp (sp), address 64 bits
+ 33: elr (elr), address 64 bits
+FP/SIMD registers:
+ 64: v0 (v0), unsigned 128 bits
+ 65: v1 (v1), unsigned 128 bits
+ 66: v2 (v2), unsigned 128 bits
+ 67: v3 (v3), unsigned 128 bits
+ 68: v4 (v4), unsigned 128 bits
+ 69: v5 (v5), unsigned 128 bits
+ 70: v6 (v6), unsigned 128 bits
+ 71: v7 (v7), unsigned 128 bits
+ 72: v8 (v8), unsigned 128 bits
+ 73: v9 (v9), unsigned 128 bits
+ 74: v10 (v10), unsigned 128 bits
+ 75: v11 (v11), unsigned 128 bits
+ 76: v12 (v12), unsigned 128 bits
+ 77: v13 (v13), unsigned 128 bits
+ 78: v14 (v14), unsigned 128 bits
+ 79: v15 (v15), unsigned 128 bits
+ 80: v16 (v16), unsigned 128 bits
+ 81: v17 (v17), unsigned 128 bits
+ 82: v18 (v18), unsigned 128 bits
+ 83: v19 (v19), unsigned 128 bits
+ 84: v20 (v20), unsigned 128 bits
+ 85: v21 (v21), unsigned 128 bits
+ 86: v22 (v22), unsigned 128 bits
+ 87: v23 (v23), unsigned 128 bits
+ 88: v24 (v24), unsigned 128 bits
+ 89: v25 (v25), unsigned 128 bits
+ 90: v26 (v26), unsigned 128 bits
+ 91: v27 (v27), unsigned 128 bits
+ 92: v28 (v28), unsigned 128 bits
+ 93: v29 (v29), unsigned 128 bits
+ 94: v30 (v30), unsigned 128 bits
+ 95: v31 (v31), unsigned 128 bits
+EOF
+
+# See run-readelf-mixed-corenote.sh for instructions to regenerate
+# this core file.
+regs_test testfile-x32-core <<\EOF
+integer registers:
+ 0: %rax (rax), signed 64 bits
+ 1: %rdx (rdx), signed 64 bits
+ 2: %rcx (rcx), signed 64 bits
+ 3: %rbx (rbx), signed 64 bits
+ 4: %rsi (rsi), signed 64 bits
+ 5: %rdi (rdi), signed 64 bits
+ 6: %rbp (rbp), address 64 bits
+ 7: %rsp (rsp), address 64 bits
+ 8: %r8 (r8), signed 64 bits
+ 9: %r9 (r9), signed 64 bits
+ 10: %r10 (r10), signed 64 bits
+ 11: %r11 (r11), signed 64 bits
+ 12: %r12 (r12), signed 64 bits
+ 13: %r13 (r13), signed 64 bits
+ 14: %r14 (r14), signed 64 bits
+ 15: %r15 (r15), signed 64 bits
+ 16: %rip (rip), address 64 bits
+ 49: %rflags (rflags), unsigned 64 bits
+MMX registers:
+ 41: %mm0 (mm0), unsigned 64 bits
+ 42: %mm1 (mm1), unsigned 64 bits
+ 43: %mm2 (mm2), unsigned 64 bits
+ 44: %mm3 (mm3), unsigned 64 bits
+ 45: %mm4 (mm4), unsigned 64 bits
+ 46: %mm5 (mm5), unsigned 64 bits
+ 47: %mm6 (mm6), unsigned 64 bits
+ 48: %mm7 (mm7), unsigned 64 bits
+SSE registers:
+ 17: %xmm0 (xmm0), unsigned 128 bits
+ 18: %xmm1 (xmm1), unsigned 128 bits
+ 19: %xmm2 (xmm2), unsigned 128 bits
+ 20: %xmm3 (xmm3), unsigned 128 bits
+ 21: %xmm4 (xmm4), unsigned 128 bits
+ 22: %xmm5 (xmm5), unsigned 128 bits
+ 23: %xmm6 (xmm6), unsigned 128 bits
+ 24: %xmm7 (xmm7), unsigned 128 bits
+ 25: %xmm8 (xmm8), unsigned 128 bits
+ 26: %xmm9 (xmm9), unsigned 128 bits
+ 27: %xmm10 (xmm10), unsigned 128 bits
+ 28: %xmm11 (xmm11), unsigned 128 bits
+ 29: %xmm12 (xmm12), unsigned 128 bits
+ 30: %xmm13 (xmm13), unsigned 128 bits
+ 31: %xmm14 (xmm14), unsigned 128 bits
+ 32: %xmm15 (xmm15), unsigned 128 bits
+control registers:
+ 62: %tr (tr), unsigned 64 bits
+ 63: %ldtr (ldtr), unsigned 64 bits
+ 64: %mxcsr (mxcsr), unsigned 64 bits
+ 65: %fcw (fcw), unsigned 16 bits
+ 66: %fsw (fsw), unsigned 16 bits
+segment registers:
+ 50: %es (es), unsigned 16 bits
+ 51: %cs (cs), unsigned 16 bits
+ 52: %ss (ss), unsigned 16 bits
+ 53: %ds (ds), unsigned 16 bits
+ 54: %fs (fs), unsigned 16 bits
+ 55: %gs (gs), unsigned 16 bits
+ 58: %fs.base (fs.base), address 64 bits
+ 59: %gs.base (gs.base), address 64 bits
+x87 registers:
+ 33: %st0 (st0), float 80 bits
+ 34: %st1 (st1), float 80 bits
+ 35: %st2 (st2), float 80 bits
+ 36: %st3 (st3), float 80 bits
+ 37: %st4 (st4), float 80 bits
+ 38: %st5 (st5), float 80 bits
+ 39: %st6 (st6), float 80 bits
+ 40: %st7 (st7), float 80 bits
+EOF
+
+# See run-readelf-mixed-corenote.sh for instructions to regenerate
+# this core file.
+regs_test testfile-m68k-core <<\EOF
+integer registers:
+ 0: %d0 (d0), signed 32 bits
+ 1: %d1 (d1), signed 32 bits
+ 2: %d2 (d2), signed 32 bits
+ 3: %d3 (d3), signed 32 bits
+ 4: %d4 (d4), signed 32 bits
+ 5: %d5 (d5), signed 32 bits
+ 6: %d6 (d6), signed 32 bits
+ 7: %d7 (d7), signed 32 bits
+ 8: %a0 (a0), address 32 bits
+ 9: %a1 (a1), address 32 bits
+ 10: %a2 (a2), address 32 bits
+ 11: %a3 (a3), address 32 bits
+ 12: %a4 (a4), address 32 bits
+ 13: %a5 (a5), address 32 bits
+ 14: %a6 (a6), address 32 bits
+ 15: %a7 (a7), address 32 bits
+ 24: %pc (pc), address 32 bits
+FPU registers:
+ 16: %fp0 (fp0), float 96 bits
+ 17: %fp1 (fp1), float 96 bits
+ 18: %fp2 (fp2), float 96 bits
+ 19: %fp3 (fp3), float 96 bits
+ 20: %fp4 (fp4), float 96 bits
+ 21: %fp5 (fp5), float 96 bits
+ 22: %fp6 (fp6), float 96 bits
+ 23: %fp7 (fp7), float 96 bits
+EOF
+exit 0
diff --git a/tests/run-ar.sh b/tests/run-ar.sh
new file mode 100755
index 0000000..fb9394d
--- /dev/null
+++ b/tests/run-ar.sh
@@ -0,0 +1,40 @@
+#! /bin/bash
+# Copyright (C) 2017 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
+
+tempfiles objects.list test.ar
+
+echo Make a sorted list of the just build src .o files.
+(cd ${abs_top_builddir}/src; ls *.o | sort) > objects.list
+cat objects.list
+
+echo Create a new ar file with the .o files.
+testrun ${abs_top_builddir}/src/ar -r test.ar \
+ $(echo ${abs_top_builddir}/src/*.o | sort)
+
+echo List the ar file contents.
+testrun_compare ${abs_top_builddir}/src/ar -t test.ar < objects.list
+
+echo Delete all objects again.
+testrun ${abs_top_builddir}/src/ar -d test.ar $(cat objects.list)
+
+echo Check new ar file is now empty
+testrun_compare ${abs_top_builddir}/src/ar -t test.ar << EOF
+EOF
+
+exit 0
diff --git a/tests/run-arextract.sh b/tests/run-arextract.sh
new file mode 100755
index 0000000..44f4a52
--- /dev/null
+++ b/tests/run-arextract.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2005, 2006 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+tempfiles arextract.test
+
+archive=${abs_top_builddir}/libelf/libelf.a
+if test -f $archive; then
+ # The file is really available (i.e., no shared-only built).
+ echo -n "Extracting symbols... $ac_c"
+
+ # The files we are looking at.
+ for f in ${abs_top_builddir}/libelf/*.o; do
+ testrun ${abs_builddir}/arextract $archive `basename $f` arextract.test || exit 1
+ cmp $f arextract.test || {
+ echo "Extraction of $1 failed"
+ exit 1
+ }
+ done
+
+ echo "done"
+fi
+
+exit 0
diff --git a/tests/run-arsymtest.sh b/tests/run-arsymtest.sh
new file mode 100755
index 0000000..b0fdfcd
--- /dev/null
+++ b/tests/run-arsymtest.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2006 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+lib=${abs_top_builddir}/libelf/libelf.a
+okfile=arsymtest.ok
+tmpfile=arsymtest.tmp
+testfile=arsymtest.test
+
+tempfiles $okfile $tmpfile $testfile
+
+result=77
+if test -f $lib; then
+ # Generate list using `nm' we check against.
+ ${NM} -s $lib |
+ sed -e '1,/^Arch/d' -e '/^$/,$d' |
+ sort > $okfile
+
+ # Now run our program using libelf.
+ testrun ${abs_builddir}/arsymtest $lib $tmpfile || exit 1
+ sort $tmpfile > $testfile
+
+ # Compare the outputs.
+ if cmp $okfile $testfile; then
+ result=0
+ else
+ result=1
+ fi
+fi
+
+exit $result
diff --git a/tests/run-backtrace-core-aarch64.sh b/tests/run-backtrace-core-aarch64.sh
new file mode 100755
index 0000000..a29a661
--- /dev/null
+++ b/tests/run-backtrace-core-aarch64.sh
@@ -0,0 +1,23 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+# backtrace.aarch64.exe is a -static binary of backtrace-child.
+# backtrace.aarch64.core was generated by running the static backtrace-child
+# with --gencore.
+check_core aarch64
diff --git a/tests/run-backtrace-core-i386.sh b/tests/run-backtrace-core-i386.sh
new file mode 100755
index 0000000..7294ec3
--- /dev/null
+++ b/tests/run-backtrace-core-i386.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+check_core i386
diff --git a/tests/run-backtrace-core-ppc.sh b/tests/run-backtrace-core-ppc.sh
new file mode 100755
index 0000000..555ac35
--- /dev/null
+++ b/tests/run-backtrace-core-ppc.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+# executable generated by:
+#
+# gcc -D_GNU_SOURCE -I. -I.. -I../lib -m32 -pthread -static -g \
+# -o backtrace.ppc.exec backtrace-child.c
+#
+# core generated by:
+#
+# ./backtrace.ppc.exec --gencore
+
+check_core ppc
diff --git a/tests/run-backtrace-core-s390.sh b/tests/run-backtrace-core-s390.sh
new file mode 100755
index 0000000..d3b6dc9
--- /dev/null
+++ b/tests/run-backtrace-core-s390.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+check_core s390
diff --git a/tests/run-backtrace-core-s390x.sh b/tests/run-backtrace-core-s390x.sh
new file mode 100755
index 0000000..c3e236d
--- /dev/null
+++ b/tests/run-backtrace-core-s390x.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+check_core s390x
diff --git a/tests/run-backtrace-core-sparc.sh b/tests/run-backtrace-core-sparc.sh
new file mode 100755
index 0000000..60399ba
--- /dev/null
+++ b/tests/run-backtrace-core-sparc.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Copyright (C) 2015 Oracle, 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/backtrace-subr.sh
+
+check_core sparc
diff --git a/tests/run-backtrace-core-x32.sh b/tests/run-backtrace-core-x32.sh
new file mode 100755
index 0000000..2ad76bc
--- /dev/null
+++ b/tests/run-backtrace-core-x32.sh
@@ -0,0 +1,23 @@
+#! /bin/bash
+# Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
+# 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/backtrace-subr.sh
+
+# backtrace.x32.exec is created by
+# gcc -mx32 -static -o backtrace.x32.exec backtrace_child-backtrace-child.o -lpthread
+# backtrace.x32.core was generated by running "backtrace.x32.exec --gencore"
+check_core x32
diff --git a/tests/run-backtrace-core-x86_64.sh b/tests/run-backtrace-core-x86_64.sh
new file mode 100755
index 0000000..d00cd6d
--- /dev/null
+++ b/tests/run-backtrace-core-x86_64.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+check_core x86_64
diff --git a/tests/run-backtrace-data.sh b/tests/run-backtrace-data.sh
new file mode 100755
index 0000000..34a4f01
--- /dev/null
+++ b/tests/run-backtrace-data.sh
@@ -0,0 +1,28 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+# This test really cannot be run under valgrind, it tries to introspect
+# its own maps and registers and will find valgrinds instead.
+unset VALGRIND_CMD
+
+tempfiles data.{bt,err}
+(set +ex; testrun ${abs_builddir}/backtrace-data 1>data.bt 2>data.err; true)
+cat data.{bt,err}
+check_unsupported data.err data
+check_all data.{bt,err} data
diff --git a/tests/run-backtrace-demangle.sh b/tests/run-backtrace-demangle.sh
new file mode 100755
index 0000000..2d25324
--- /dev/null
+++ b/tests/run-backtrace-demangle.sh
@@ -0,0 +1,58 @@
+#! /bin/bash
+# Copyright (C) 2014, 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/>.
+
+if test -n "$ELFUTILS_DISABLE_DEMANGLE"; then
+ echo "demangler unsupported"
+ exit 77
+fi
+
+. $srcdir/backtrace-subr.sh
+
+child=testfile-backtrace-demangle
+testfiles $child{,.core}
+tempfiles $child.{bt,err}
+
+# Disable valgrind while dumping because of a bug unmapping libc.so.
+# https://bugs.kde.org/show_bug.cgi?id=327427
+SAVED_VALGRIND_CMD="$VALGRIND_CMD"
+unset VALGRIND_CMD
+
+# There can be more than 3 frames, but depending on the system/installed
+# glibc we might not be able to unwind fully till the end.
+# cxxfunc -> f -> main
+# Expect to see the top two and a warning that there are more frames
+# (exit code 1)
+testrun ${abs_top_builddir}/src/stack -n 2 -e $child --core $child.core >$child.bt 2>$child.err || exitcode=$?
+cat $child.{bt,err}
+
+if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
+ VALGRIND_CMD="$SAVED_VALGRIND_CMD"
+ export VALGRIND_CMD
+fi
+
+if test $exitcode != 1 || ! grep "shown max number of frames" $child.err; then
+ echo >&2 $2: expected more than 2 frames
+ false
+fi
+if ! grep -w f $child.bt; then
+ echo >&2 $2: no f
+ false
+fi
+if ! grep ' cxxfunc(int)' $child.bt; then
+ echo >&2 $2: no cxxfunc
+ false
+fi
diff --git a/tests/run-backtrace-dwarf.sh b/tests/run-backtrace-dwarf.sh
new file mode 100755
index 0000000..8834048
--- /dev/null
+++ b/tests/run-backtrace-dwarf.sh
@@ -0,0 +1,30 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+# This test really cannot be run under valgrind, it tries to introspect
+# itself through ptrace and will find bits and pieces of valgrind.
+# On top of that valgrind also tries to read all the unwind info and
+# will warn and complain about various opcodes it doesn't understand...
+unset VALGRIND_CMD
+
+tempfiles dwarf.{bt,err}
+(set +ex; testrun ${abs_builddir}/backtrace-dwarf 1>dwarf.bt 2>dwarf.err; true)
+cat dwarf.{bt,err}
+check_native_unsupported dwarf.err dwarf
+check_main dwarf.bt dwarf
diff --git a/tests/run-backtrace-fp-core-aarch64.sh b/tests/run-backtrace-fp-core-aarch64.sh
new file mode 100755
index 0000000..fda88d3
--- /dev/null
+++ b/tests/run-backtrace-fp-core-aarch64.sh
@@ -0,0 +1,28 @@
+#! /bin/bash
+# Copyright (C) 2017 The Qt Company
+# 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/backtrace-subr.sh
+
+# The binary is generated by compiling with eh_frame CFI, but with frame
+# pointers.
+#
+# gcc -static -O2 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables \
+# -D_GNU_SOURCE -pthread -o tests/backtrace.aarch64.fp.exec -I. -Ilib \
+# tests/backtrace-child.c
+# The core is generated by calling the binary with --gencore
+
+check_core aarch64.fp
diff --git a/tests/run-backtrace-fp-core-i386.sh b/tests/run-backtrace-fp-core-i386.sh
new file mode 100755
index 0000000..c58ff53
--- /dev/null
+++ b/tests/run-backtrace-fp-core-i386.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+# Copyright (C) 2017 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/backtrace-subr.sh
+
+# The binary is generated by compiling backtrace-child without unwind
+# information, but with -fno-omit-frame-pointer.
+#
+# gcc -static -O2 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables \
+# -D_GNU_SOURCE -pthread -o tests/backtrace.i386.fp.exec -I. -Ilib \
+# tests/backtrace-child.c
+#
+# The core is generated by calling tests/backtrace.i386.fp.exec --gencore
+
+check_core i386.fp
diff --git a/tests/run-backtrace-fp-core-ppc64le.sh b/tests/run-backtrace-fp-core-ppc64le.sh
new file mode 100755
index 0000000..326ca34
--- /dev/null
+++ b/tests/run-backtrace-fp-core-ppc64le.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+# Copyright (C) 2017 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/backtrace-subr.sh
+
+# The binary is generated by compiling backtrace-child without unwind
+# information, but with -fno-omit-frame-pointer.
+#
+# gcc -static -O2 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables \
+# -D_GNU_SOURCE -pthread -o tests/backtrace.ppc64le.fp.exec -I. -Ilib \
+# tests/backtrace-child.c
+#
+# The core is generated by calling tests/backtrace.ppc64le.fp.exec --gencore
+
+check_core ppc64le.fp
diff --git a/tests/run-backtrace-fp-core-x86_64.sh b/tests/run-backtrace-fp-core-x86_64.sh
new file mode 100755
index 0000000..348eb18
--- /dev/null
+++ b/tests/run-backtrace-fp-core-x86_64.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+# Copyright (C) 2017 The Qt Company
+# 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/backtrace-subr.sh
+
+# The binary is generated by compiling with eh_frame CFI, but with frame
+# pointers.
+#
+# gcc -static -O2 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables \
+# -D_GNU_SOURCE -pthread -o tests/backtrace.x86_64.fp.exec -I. -Ilib \
+# tests/backtrace-child.c
+#
+# The core is generated by calling the binary with --gencore
+
+check_core x86_64.fp
diff --git a/tests/run-backtrace-native-biarch.sh b/tests/run-backtrace-native-biarch.sh
new file mode 100755
index 0000000..2afe38a
--- /dev/null
+++ b/tests/run-backtrace-native-biarch.sh
@@ -0,0 +1,25 @@
+#! /bin/bash
+# Copyright (C) 2013, 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/>.
+
+if test -n "$ELFUTILS_DISABLE_BIARCH"; then
+ echo "biarch testing disabled"
+ exit 77
+fi
+
+. $srcdir/backtrace-subr.sh
+
+check_native backtrace-child-biarch
diff --git a/tests/run-backtrace-native-core-biarch.sh b/tests/run-backtrace-native-core-biarch.sh
new file mode 100755
index 0000000..02552ce
--- /dev/null
+++ b/tests/run-backtrace-native-core-biarch.sh
@@ -0,0 +1,25 @@
+#! /bin/bash
+# Copyright (C) 2013, 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/>.
+
+if test -n "$ELFUTILS_DISABLE_BIARCH"; then
+ echo "biarch testing disabled"
+ exit 77
+fi
+
+. $srcdir/backtrace-subr.sh
+
+check_native_core backtrace-child-biarch
diff --git a/tests/run-backtrace-native-core.sh b/tests/run-backtrace-native-core.sh
new file mode 100755
index 0000000..cb025a5
--- /dev/null
+++ b/tests/run-backtrace-native-core.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+check_native_core backtrace-child
diff --git a/tests/run-backtrace-native.sh b/tests/run-backtrace-native.sh
new file mode 100755
index 0000000..ddae345
--- /dev/null
+++ b/tests/run-backtrace-native.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Copyright (C) 2013 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/backtrace-subr.sh
+
+check_native backtrace-child
diff --git a/tests/run-bug1-test.sh b/tests/run-bug1-test.sh
new file mode 100755
index 0000000..1e78a18
--- /dev/null
+++ b/tests/run-bug1-test.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2006 Red Hat, Inc.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2006.
+#
+# 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
+
+testfiles testfile28 testfile28.rdwr
+
+testrun ${abs_builddir}/rdwrmmap testfile28
+
+cmp testfile28 testfile28.rdwr
+
+test_cleanup
+
+testfiles testfile29 testfile29.rdwr
+
+testrun ${abs_builddir}/rdwrmmap testfile29
+
+cmp testfile29 testfile29.rdwr
+
+exit 0
diff --git a/tests/run-buildid.sh b/tests/run-buildid.sh
new file mode 100755
index 0000000..31cec24
--- /dev/null
+++ b/tests/run-buildid.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2014 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
+
+# Just some random testfiles, four with, one without build-id,
+# and one without shdrs forcing reading the notes through phdrs.
+# eu-strip --strip-sections -g --output=testfile42_noshdrs testfile42
+# See also run-debugaltlink.sh.
+testfiles testfile42 testfile_multi.dwz testfile-dwzstr.multi \
+ test-offset-loop.alt testfile14 testfile42_noshdrs
+
+testrun_compare ${abs_builddir}/buildid testfile42 testfile42_noshdrs \
+ testfile_multi.dwz testfile-dwzstr.multi \
+ test-offset-loop.alt testfile14 <<\EOF
+testfile42: build ID: d826d96c4d097bdc5c254b1f7344a907e36b0439
+testfile42_noshdrs: build ID: d826d96c4d097bdc5c254b1f7344a907e36b0439
+testfile_multi.dwz: build ID: a0d6c06e0d912d74033b6fe2808753cae8f6f594
+testfile-dwzstr.multi: build ID: 6da22627dae55c1d62cf9122827c665e240a056b
+test-offset-loop.alt: build ID: 066bbf1a7bc5676f5015ee1966a088f23bdb83ae
+testfile14: <no NT_GNU_BUILD_ID note>
+EOF
+
+exit 0
diff --git a/tests/run-compress-test.sh b/tests/run-compress-test.sh
new file mode 100755
index 0000000..a6a298f
--- /dev/null
+++ b/tests/run-compress-test.sh
@@ -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
diff --git a/tests/run-debugaltlink.sh b/tests/run-debugaltlink.sh
new file mode 100755
index 0000000..fa7dd26
--- /dev/null
+++ b/tests/run-debugaltlink.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2014 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
+
+# Just some random testfiles, four with, one without .gnu_debugaltlink
+testfiles testfile42 testfile_multi_main testfile-dwzstr \
+ test-offset-loop libtestfile_multi_shared.so
+
+testrun_compare ${abs_builddir}/debugaltlink testfile42 \
+ testfile_multi_main testfile-dwzstr \
+ test-offset-loop libtestfile_multi_shared.so <<\EOF
+testfile42: <no .gnu_debugaltlink section>
+testfile_multi_main: testfile_multi.dwz, build ID: a0d6c06e0d912d74033b6fe2808753cae8f6f594
+testfile-dwzstr: testfile-dwzstr.multi, build ID: 6da22627dae55c1d62cf9122827c665e240a056b
+test-offset-loop: test-offset-loop.alt, build ID: 066bbf1a7bc5676f5015ee1966a088f23bdb83ae
+libtestfile_multi_shared.so: testfile_multi.dwz, build ID: a0d6c06e0d912d74033b6fe2808753cae8f6f594
+EOF
+
+exit 0
diff --git a/tests/run-debuglink.sh b/tests/run-debuglink.sh
new file mode 100755
index 0000000..42a816c
--- /dev/null
+++ b/tests/run-debuglink.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2014 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
+
+# Just some random testfiles, two with, one without .gnu_debuglink
+testfiles testfile36 testfile52-32.so testfile42
+
+testrun_compare ${abs_builddir}/debuglink testfile36 testfile52-32.so testfile42 <<\EOF
+testfile36: testfile36.debug, crc: 8c5c20a3
+testfile52-32.so: testfile52-32.so.debug, crc: b835a71d
+testfile42: <no gnu_debuglink file>
+EOF
+
+exit 0
diff --git a/tests/run-deleted.sh b/tests/run-deleted.sh
new file mode 100755
index 0000000..0f64762
--- /dev/null
+++ b/tests/run-deleted.sh
@@ -0,0 +1,52 @@
+#! /bin/bash
+# Copyright (C) 2014 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/backtrace-subr.sh
+
+tempfiles deleted deleted-lib.so
+cp -p ${abs_builddir}/deleted ${abs_builddir}/deleted-lib.so .
+
+# We don't want to run the deleted process under valgrind then
+# stack will see the valgrind process backtrace.
+OLD_VALGRIND_CMD="$VALGRIND_CMD"
+unset VALGRIND_CMD
+
+pid=$(testrun ${abs_builddir}/deleted)
+sleep 1
+rm -f deleted deleted-lib.so
+tempfiles bt bt.err
+
+set VALGRIND_CMD="$OLD_VALGRIND_CMD"
+# It may have non-zero exit code with:
+# .../elfutils/src/stack: dwfl_thread_getframes tid 26376 at 0x4006c8 in .../elfutils/tests/deleted: no matching address range
+testrun ${abs_top_builddir}/src/stack -p $pid 1>bt 2>bt.err || true
+cat bt bt.err
+kill -9 $pid
+wait
+check_native_unsupported bt.err deleted
+if grep -q -E ': dwfl_linux_proc_attach pid ([[:digit:]]+): Function not implemented$' bt.err; then
+ echo >&2 deleted: OS not supported
+ exit 77
+fi
+# For PPC64 we need access to the OPD table which we get through the shdrs
+# (see backends/ppc64_init.c) but for the deleted-lib we only have phdrs.
+# So we don't have the name of the function. But since we should find
+# the EH_FRAME through phdrs just fine, we can unwind into main.
+if test "`uname -m`" != "ppc64"; then
+ grep -qw libfunc bt
+fi
+grep -qw main bt
diff --git a/tests/run-disasm-bpf.sh b/tests/run-disasm-bpf.sh
new file mode 100755
index 0000000..8ca89d5
--- /dev/null
+++ b/tests/run-disasm-bpf.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2016 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
+
+# This test file is created with
+#
+# #include <linux/bpf.h>
+# #include <stdio.h>
+#
+# int main()
+# {
+# int i;
+#
+# printf("\t.text\n");
+#
+# for (i = 0; i < 256; ++i)
+# if (i == (BPF_LD | BPF_IMM | BPF_DW))
+# printf("\t.byte\t%d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n", i);
+# else
+# {
+# int regs = 0;
+# switch (BPF_CLASS(i))
+# {
+# case BPF_ALU:
+# case BPF_ALU64:
+# if (BPF_SRC(i) == BPF_X
+# && BPF_OP(i) != BPF_NEG
+# && BPF_OP(i) != BPF_END)
+# regs = 0x21;
+# break;
+# case BPF_LDX:
+# case BPF_STX:
+# regs = 0x21;
+# break;
+# }
+# printf("\t.byte\t%d, %d, 0, 0, 0, 0, 0, 0\n", i, regs);
+# }
+#
+# return 0;
+# }
+#
+# $ ./a.out | as -o z1.o
+# $ objcopy -j .text z1.o z2.o
+#
+# Then emacs hexl edit e_machine to 0xf7.
+
+testfiles testfile-bpf-dis1.o testfile-bpf-dis1.expect
+testrun_compare ${abs_top_builddir}/src/objdump -d testfile-bpf-dis1.o < testfile-bpf-dis1.expect
diff --git a/tests/run-disasm-x86-64.sh b/tests/run-disasm-x86-64.sh
new file mode 100755
index 0000000..a6be62b
--- /dev/null
+++ b/tests/run-disasm-x86-64.sh
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Copyright (C) 2007, 2008 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
+
+# Run x86-64 test.
+case "`uname -m`" in
+ x86_64)
+ tempfiles testfile45.o
+ testfiles testfile45.S testfile45.expect
+ gcc -m64 -c -o testfile45.o testfile45.S
+ testrun_compare ${abs_top_builddir}/src/objdump -d testfile45.o < testfile45.expect
+ ;;
+esac
diff --git a/tests/run-disasm-x86.sh b/tests/run-disasm-x86.sh
new file mode 100755
index 0000000..28a3df7
--- /dev/null
+++ b/tests/run-disasm-x86.sh
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Copyright (C) 2007, 2008 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
+
+# Run x86 test.
+case "`uname -m`" in
+ x86_64 | i?86 )
+ tempfiles testfile44.o
+ testfiles testfile44.S testfile44.expect
+ gcc -m32 -c -o testfile44.o testfile44.S
+ testrun_compare ${abs_top_builddir}/src/objdump -d testfile44.o < testfile44.expect
+ ;;
+esac
diff --git a/tests/run-dwarf-getmacros.sh b/tests/run-dwarf-getmacros.sh
new file mode 100755
index 0000000..0a488fa
--- /dev/null
+++ b/tests/run-dwarf-getmacros.sh
@@ -0,0 +1,710 @@
+#! /bin/sh
+# Copyright (C) 2009, 2014 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
+
+testfiles testfile51
+
+testrun_compare ${abs_builddir}/dwarf-getmacros testfile51 0xb <<\EOF
+file /home/petr/proj/elfutils/pending/elfutils/tests/decom/x.c
+ __STDC__ 1
+ __STDC_HOSTED__ 1
+ __GNUC__ 4
+ __GNUC_MINOR__ 3
+ __GNUC_PATCHLEVEL__ 2
+ __GNUC_RH_RELEASE__ 7
+ __SIZE_TYPE__ long unsigned int
+ __PTRDIFF_TYPE__ long int
+ __WCHAR_TYPE__ int
+ __WINT_TYPE__ unsigned int
+ __INTMAX_TYPE__ long int
+ __UINTMAX_TYPE__ long unsigned int
+ __GXX_ABI_VERSION 1002
+ __SCHAR_MAX__ 127
+ __SHRT_MAX__ 32767
+ __INT_MAX__ 2147483647
+ __LONG_MAX__ 9223372036854775807L
+ __LONG_LONG_MAX__ 9223372036854775807LL
+ __WCHAR_MAX__ 2147483647
+ __CHAR_BIT__ 8
+ __INTMAX_MAX__ 9223372036854775807L
+ __FLT_EVAL_METHOD__ 0
+ __DEC_EVAL_METHOD__ 2
+ __FLT_RADIX__ 2
+ __FLT_MANT_DIG__ 24
+ __FLT_DIG__ 6
+ __FLT_MIN_EXP__ (-125)
+ __FLT_MIN_10_EXP__ (-37)
+ __FLT_MAX_EXP__ 128
+ __FLT_MAX_10_EXP__ 38
+ __FLT_MAX__ 3.40282347e+38F
+ __FLT_MIN__ 1.17549435e-38F
+ __FLT_EPSILON__ 1.19209290e-7F
+ __FLT_DENORM_MIN__ 1.40129846e-45F
+ __FLT_HAS_DENORM__ 1
+ __FLT_HAS_INFINITY__ 1
+ __FLT_HAS_QUIET_NAN__ 1
+ __DBL_MANT_DIG__ 53
+ __DBL_DIG__ 15
+ __DBL_MIN_EXP__ (-1021)
+ __DBL_MIN_10_EXP__ (-307)
+ __DBL_MAX_EXP__ 1024
+ __DBL_MAX_10_EXP__ 308
+ __DBL_MAX__ 1.7976931348623157e+308
+ __DBL_MIN__ 2.2250738585072014e-308
+ __DBL_EPSILON__ 2.2204460492503131e-16
+ __DBL_DENORM_MIN__ 4.9406564584124654e-324
+ __DBL_HAS_DENORM__ 1
+ __DBL_HAS_INFINITY__ 1
+ __DBL_HAS_QUIET_NAN__ 1
+ __LDBL_MANT_DIG__ 64
+ __LDBL_DIG__ 18
+ __LDBL_MIN_EXP__ (-16381)
+ __LDBL_MIN_10_EXP__ (-4931)
+ __LDBL_MAX_EXP__ 16384
+ __LDBL_MAX_10_EXP__ 4932
+ __DECIMAL_DIG__ 21
+ __LDBL_MAX__ 1.18973149535723176502e+4932L
+ __LDBL_MIN__ 3.36210314311209350626e-4932L
+ __LDBL_EPSILON__ 1.08420217248550443401e-19L
+ __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+ __LDBL_HAS_DENORM__ 1
+ __LDBL_HAS_INFINITY__ 1
+ __LDBL_HAS_QUIET_NAN__ 1
+ __DEC32_MANT_DIG__ 7
+ __DEC32_MIN_EXP__ (-95)
+ __DEC32_MAX_EXP__ 96
+ __DEC32_MIN__ 1E-95DF
+ __DEC32_MAX__ 9.999999E96DF
+ __DEC32_EPSILON__ 1E-6DF
+ __DEC32_DEN__ 0.000001E-95DF
+ __DEC64_MANT_DIG__ 16
+ __DEC64_MIN_EXP__ (-383)
+ __DEC64_MAX_EXP__ 384
+ __DEC64_MIN__ 1E-383DD
+ __DEC64_MAX__ 9.999999999999999E384DD
+ __DEC64_EPSILON__ 1E-15DD
+ __DEC64_DEN__ 0.000000000000001E-383DD
+ __DEC128_MANT_DIG__ 34
+ __DEC128_MIN_EXP__ (-6143)
+ __DEC128_MAX_EXP__ 6144
+ __DEC128_MIN__ 1E-6143DL
+ __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+ __DEC128_EPSILON__ 1E-33DL
+ __DEC128_DEN__ 0.000000000000000000000000000000001E-6143DL
+ __REGISTER_PREFIX__
+ __USER_LABEL_PREFIX__
+ __VERSION__ "4.3.2 20081105 (Red Hat 4.3.2-7)"
+ __GNUC_GNU_INLINE__ 1
+ _LP64 1
+ __LP64__ 1
+ __NO_INLINE__ 1
+ __FINITE_MATH_ONLY__ 0
+ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+ __SIZEOF_INT__ 4
+ __SIZEOF_LONG__ 8
+ __SIZEOF_LONG_LONG__ 8
+ __SIZEOF_SHORT__ 2
+ __SIZEOF_FLOAT__ 4
+ __SIZEOF_DOUBLE__ 8
+ __SIZEOF_LONG_DOUBLE__ 16
+ __SIZEOF_SIZE_T__ 8
+ __SIZEOF_WCHAR_T__ 4
+ __SIZEOF_WINT_T__ 4
+ __SIZEOF_PTRDIFF_T__ 8
+ __SIZEOF_POINTER__ 8
+ __amd64 1
+ __amd64__ 1
+ __x86_64 1
+ __x86_64__ 1
+ __k8 1
+ __k8__ 1
+ __MMX__ 1
+ __SSE__ 1
+ __SSE2__ 1
+ __SSE_MATH__ 1
+ __SSE2_MATH__ 1
+ __gnu_linux__ 1
+ __linux 1
+ __linux__ 1
+ linux 1
+ __unix 1
+ __unix__ 1
+ unix 1
+ __ELF__ 1
+ __DECIMAL_BID_FORMAT__ 1
+ macro1 ble
+/file
+EOF
+
+testrun_compare ${abs_builddir}/dwarf-getmacros testfile51 0x84 <<\EOF
+file /home/petr/proj/elfutils/pending/elfutils/tests/decom/y.c
+ __STDC__ 1
+ __STDC_HOSTED__ 1
+ __GNUC__ 4
+ __GNUC_MINOR__ 3
+ __GNUC_PATCHLEVEL__ 2
+ __GNUC_RH_RELEASE__ 7
+ __SIZE_TYPE__ long unsigned int
+ __PTRDIFF_TYPE__ long int
+ __WCHAR_TYPE__ int
+ __WINT_TYPE__ unsigned int
+ __INTMAX_TYPE__ long int
+ __UINTMAX_TYPE__ long unsigned int
+ __GXX_ABI_VERSION 1002
+ __SCHAR_MAX__ 127
+ __SHRT_MAX__ 32767
+ __INT_MAX__ 2147483647
+ __LONG_MAX__ 9223372036854775807L
+ __LONG_LONG_MAX__ 9223372036854775807LL
+ __WCHAR_MAX__ 2147483647
+ __CHAR_BIT__ 8
+ __INTMAX_MAX__ 9223372036854775807L
+ __FLT_EVAL_METHOD__ 0
+ __DEC_EVAL_METHOD__ 2
+ __FLT_RADIX__ 2
+ __FLT_MANT_DIG__ 24
+ __FLT_DIG__ 6
+ __FLT_MIN_EXP__ (-125)
+ __FLT_MIN_10_EXP__ (-37)
+ __FLT_MAX_EXP__ 128
+ __FLT_MAX_10_EXP__ 38
+ __FLT_MAX__ 3.40282347e+38F
+ __FLT_MIN__ 1.17549435e-38F
+ __FLT_EPSILON__ 1.19209290e-7F
+ __FLT_DENORM_MIN__ 1.40129846e-45F
+ __FLT_HAS_DENORM__ 1
+ __FLT_HAS_INFINITY__ 1
+ __FLT_HAS_QUIET_NAN__ 1
+ __DBL_MANT_DIG__ 53
+ __DBL_DIG__ 15
+ __DBL_MIN_EXP__ (-1021)
+ __DBL_MIN_10_EXP__ (-307)
+ __DBL_MAX_EXP__ 1024
+ __DBL_MAX_10_EXP__ 308
+ __DBL_MAX__ 1.7976931348623157e+308
+ __DBL_MIN__ 2.2250738585072014e-308
+ __DBL_EPSILON__ 2.2204460492503131e-16
+ __DBL_DENORM_MIN__ 4.9406564584124654e-324
+ __DBL_HAS_DENORM__ 1
+ __DBL_HAS_INFINITY__ 1
+ __DBL_HAS_QUIET_NAN__ 1
+ __LDBL_MANT_DIG__ 64
+ __LDBL_DIG__ 18
+ __LDBL_MIN_EXP__ (-16381)
+ __LDBL_MIN_10_EXP__ (-4931)
+ __LDBL_MAX_EXP__ 16384
+ __LDBL_MAX_10_EXP__ 4932
+ __DECIMAL_DIG__ 21
+ __LDBL_MAX__ 1.18973149535723176502e+4932L
+ __LDBL_MIN__ 3.36210314311209350626e-4932L
+ __LDBL_EPSILON__ 1.08420217248550443401e-19L
+ __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+ __LDBL_HAS_DENORM__ 1
+ __LDBL_HAS_INFINITY__ 1
+ __LDBL_HAS_QUIET_NAN__ 1
+ __DEC32_MANT_DIG__ 7
+ __DEC32_MIN_EXP__ (-95)
+ __DEC32_MAX_EXP__ 96
+ __DEC32_MIN__ 1E-95DF
+ __DEC32_MAX__ 9.999999E96DF
+ __DEC32_EPSILON__ 1E-6DF
+ __DEC32_DEN__ 0.000001E-95DF
+ __DEC64_MANT_DIG__ 16
+ __DEC64_MIN_EXP__ (-383)
+ __DEC64_MAX_EXP__ 384
+ __DEC64_MIN__ 1E-383DD
+ __DEC64_MAX__ 9.999999999999999E384DD
+ __DEC64_EPSILON__ 1E-15DD
+ __DEC64_DEN__ 0.000000000000001E-383DD
+ __DEC128_MANT_DIG__ 34
+ __DEC128_MIN_EXP__ (-6143)
+ __DEC128_MAX_EXP__ 6144
+ __DEC128_MIN__ 1E-6143DL
+ __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+ __DEC128_EPSILON__ 1E-33DL
+ __DEC128_DEN__ 0.000000000000000000000000000000001E-6143DL
+ __REGISTER_PREFIX__
+ __USER_LABEL_PREFIX__
+ __VERSION__ "4.3.2 20081105 (Red Hat 4.3.2-7)"
+ __GNUC_GNU_INLINE__ 1
+ _LP64 1
+ __LP64__ 1
+ __NO_INLINE__ 1
+ __FINITE_MATH_ONLY__ 0
+ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+ __SIZEOF_INT__ 4
+ __SIZEOF_LONG__ 8
+ __SIZEOF_LONG_LONG__ 8
+ __SIZEOF_SHORT__ 2
+ __SIZEOF_FLOAT__ 4
+ __SIZEOF_DOUBLE__ 8
+ __SIZEOF_LONG_DOUBLE__ 16
+ __SIZEOF_SIZE_T__ 8
+ __SIZEOF_WCHAR_T__ 4
+ __SIZEOF_WINT_T__ 4
+ __SIZEOF_PTRDIFF_T__ 8
+ __SIZEOF_POINTER__ 8
+ __amd64 1
+ __amd64__ 1
+ __x86_64 1
+ __x86_64__ 1
+ __k8 1
+ __k8__ 1
+ __MMX__ 1
+ __SSE__ 1
+ __SSE2__ 1
+ __SSE_MATH__ 1
+ __SSE2_MATH__ 1
+ __gnu_linux__ 1
+ __linux 1
+ __linux__ 1
+ linux 1
+ __unix 1
+ __unix__ 1
+ unix 1
+ __ELF__ 1
+ __DECIMAL_BID_FORMAT__ 1
+ macro2 ble
+/file
+EOF
+
+testfiles testfile-macros
+
+testrun_compare ${abs_builddir}/dwarf-getmacros testfile-macros 0xb <<\EOF
+__STDC__ 1
+__STDC_HOSTED__ 1
+__GNUC__ 4
+__GNUC_MINOR__ 7
+__GNUC_PATCHLEVEL__ 0
+__VERSION__ "4.7.0 20120507 (Red Hat 4.7.0-5)"
+__GNUC_RH_RELEASE__ 5
+__ATOMIC_RELAXED 0
+__ATOMIC_SEQ_CST 5
+__ATOMIC_ACQUIRE 2
+__ATOMIC_RELEASE 3
+__ATOMIC_ACQ_REL 4
+__ATOMIC_CONSUME 1
+__FINITE_MATH_ONLY__ 0
+_LP64 1
+__LP64__ 1
+__SIZEOF_INT__ 4
+__SIZEOF_LONG__ 8
+__SIZEOF_LONG_LONG__ 8
+__SIZEOF_SHORT__ 2
+__SIZEOF_FLOAT__ 4
+__SIZEOF_DOUBLE__ 8
+__SIZEOF_LONG_DOUBLE__ 16
+__SIZEOF_SIZE_T__ 8
+__CHAR_BIT__ 8
+__BIGGEST_ALIGNMENT__ 16
+__ORDER_LITTLE_ENDIAN__ 1234
+__ORDER_BIG_ENDIAN__ 4321
+__ORDER_PDP_ENDIAN__ 3412
+__BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+__FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+__SIZEOF_POINTER__ 8
+__SIZE_TYPE__ long unsigned int
+__PTRDIFF_TYPE__ long int
+__WCHAR_TYPE__ int
+__WINT_TYPE__ unsigned int
+__INTMAX_TYPE__ long int
+__UINTMAX_TYPE__ long unsigned int
+__CHAR16_TYPE__ short unsigned int
+__CHAR32_TYPE__ unsigned int
+__SIG_ATOMIC_TYPE__ int
+__INT8_TYPE__ signed char
+__INT16_TYPE__ short int
+__INT32_TYPE__ int
+__INT64_TYPE__ long int
+__UINT8_TYPE__ unsigned char
+__UINT16_TYPE__ short unsigned int
+__UINT32_TYPE__ unsigned int
+__UINT64_TYPE__ long unsigned int
+__INT_LEAST8_TYPE__ signed char
+__INT_LEAST16_TYPE__ short int
+__INT_LEAST32_TYPE__ int
+__INT_LEAST64_TYPE__ long int
+__UINT_LEAST8_TYPE__ unsigned char
+__UINT_LEAST16_TYPE__ short unsigned int
+__UINT_LEAST32_TYPE__ unsigned int
+__UINT_LEAST64_TYPE__ long unsigned int
+__INT_FAST8_TYPE__ signed char
+__INT_FAST16_TYPE__ long int
+__INT_FAST32_TYPE__ long int
+__INT_FAST64_TYPE__ long int
+__UINT_FAST8_TYPE__ unsigned char
+__UINT_FAST16_TYPE__ long unsigned int
+__UINT_FAST32_TYPE__ long unsigned int
+__UINT_FAST64_TYPE__ long unsigned int
+__INTPTR_TYPE__ long int
+__UINTPTR_TYPE__ long unsigned int
+__GXX_ABI_VERSION 1002
+__SCHAR_MAX__ 127
+__SHRT_MAX__ 32767
+__INT_MAX__ 2147483647
+__LONG_MAX__ 9223372036854775807L
+__LONG_LONG_MAX__ 9223372036854775807LL
+__WCHAR_MAX__ 2147483647
+__WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
+__WINT_MAX__ 4294967295U
+__WINT_MIN__ 0U
+__PTRDIFF_MAX__ 9223372036854775807L
+__SIZE_MAX__ 18446744073709551615UL
+__INTMAX_MAX__ 9223372036854775807L
+__INTMAX_C(c) c ## L
+__UINTMAX_MAX__ 18446744073709551615UL
+__UINTMAX_C(c) c ## UL
+__SIG_ATOMIC_MAX__ 2147483647
+__SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
+__INT8_MAX__ 127
+__INT16_MAX__ 32767
+__INT32_MAX__ 2147483647
+__INT64_MAX__ 9223372036854775807L
+__UINT8_MAX__ 255
+__UINT16_MAX__ 65535
+__UINT32_MAX__ 4294967295U
+__UINT64_MAX__ 18446744073709551615UL
+__INT_LEAST8_MAX__ 127
+__INT8_C(c) c
+__INT_LEAST16_MAX__ 32767
+__INT16_C(c) c
+__INT_LEAST32_MAX__ 2147483647
+__INT32_C(c) c
+__INT_LEAST64_MAX__ 9223372036854775807L
+__INT64_C(c) c ## L
+__UINT_LEAST8_MAX__ 255
+__UINT8_C(c) c
+__UINT_LEAST16_MAX__ 65535
+__UINT16_C(c) c
+__UINT_LEAST32_MAX__ 4294967295U
+__UINT32_C(c) c ## U
+__UINT_LEAST64_MAX__ 18446744073709551615UL
+__UINT64_C(c) c ## UL
+__INT_FAST8_MAX__ 127
+__INT_FAST16_MAX__ 9223372036854775807L
+__INT_FAST32_MAX__ 9223372036854775807L
+__INT_FAST64_MAX__ 9223372036854775807L
+__UINT_FAST8_MAX__ 255
+__UINT_FAST16_MAX__ 18446744073709551615UL
+__UINT_FAST32_MAX__ 18446744073709551615UL
+__UINT_FAST64_MAX__ 18446744073709551615UL
+__INTPTR_MAX__ 9223372036854775807L
+__UINTPTR_MAX__ 18446744073709551615UL
+__FLT_EVAL_METHOD__ 0
+__DEC_EVAL_METHOD__ 2
+__FLT_RADIX__ 2
+__FLT_MANT_DIG__ 24
+__FLT_DIG__ 6
+__FLT_MIN_EXP__ (-125)
+__FLT_MIN_10_EXP__ (-37)
+__FLT_MAX_EXP__ 128
+__FLT_MAX_10_EXP__ 38
+__FLT_DECIMAL_DIG__ 9
+__FLT_MAX__ 3.40282346638528859812e+38F
+__FLT_MIN__ 1.17549435082228750797e-38F
+__FLT_EPSILON__ 1.19209289550781250000e-7F
+__FLT_DENORM_MIN__ 1.40129846432481707092e-45F
+__FLT_HAS_DENORM__ 1
+__FLT_HAS_INFINITY__ 1
+__FLT_HAS_QUIET_NAN__ 1
+__DBL_MANT_DIG__ 53
+__DBL_DIG__ 15
+__DBL_MIN_EXP__ (-1021)
+__DBL_MIN_10_EXP__ (-307)
+__DBL_MAX_EXP__ 1024
+__DBL_MAX_10_EXP__ 308
+__DBL_DECIMAL_DIG__ 17
+__DBL_MAX__ ((double)1.79769313486231570815e+308L)
+__DBL_MIN__ ((double)2.22507385850720138309e-308L)
+__DBL_EPSILON__ ((double)2.22044604925031308085e-16L)
+__DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L)
+__DBL_HAS_DENORM__ 1
+__DBL_HAS_INFINITY__ 1
+__DBL_HAS_QUIET_NAN__ 1
+__LDBL_MANT_DIG__ 64
+__LDBL_DIG__ 18
+__LDBL_MIN_EXP__ (-16381)
+__LDBL_MIN_10_EXP__ (-4931)
+__LDBL_MAX_EXP__ 16384
+__LDBL_MAX_10_EXP__ 4932
+__DECIMAL_DIG__ 21
+__LDBL_MAX__ 1.18973149535723176502e+4932L
+__LDBL_MIN__ 3.36210314311209350626e-4932L
+__LDBL_EPSILON__ 1.08420217248550443401e-19L
+__LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+__LDBL_HAS_DENORM__ 1
+__LDBL_HAS_INFINITY__ 1
+__LDBL_HAS_QUIET_NAN__ 1
+__DEC32_MANT_DIG__ 7
+__DEC32_MIN_EXP__ (-94)
+__DEC32_MAX_EXP__ 97
+__DEC32_MIN__ 1E-95DF
+__DEC32_MAX__ 9.999999E96DF
+__DEC32_EPSILON__ 1E-6DF
+__DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
+__DEC64_MANT_DIG__ 16
+__DEC64_MIN_EXP__ (-382)
+__DEC64_MAX_EXP__ 385
+__DEC64_MIN__ 1E-383DD
+__DEC64_MAX__ 9.999999999999999E384DD
+__DEC64_EPSILON__ 1E-15DD
+__DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
+__DEC128_MANT_DIG__ 34
+__DEC128_MIN_EXP__ (-6142)
+__DEC128_MAX_EXP__ 6145
+__DEC128_MIN__ 1E-6143DL
+__DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+__DEC128_EPSILON__ 1E-33DL
+__DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
+__REGISTER_PREFIX__
+__USER_LABEL_PREFIX__
+__GNUC_GNU_INLINE__ 1
+__NO_INLINE__ 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+__GCC_ATOMIC_BOOL_LOCK_FREE 2
+__GCC_ATOMIC_CHAR_LOCK_FREE 2
+__GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
+__GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
+__GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+__GCC_ATOMIC_SHORT_LOCK_FREE 2
+__GCC_ATOMIC_INT_LOCK_FREE 2
+__GCC_ATOMIC_LONG_LOCK_FREE 2
+__GCC_ATOMIC_LLONG_LOCK_FREE 2
+__GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
+__GCC_ATOMIC_POINTER_LOCK_FREE 2
+__GCC_HAVE_DWARF2_CFI_ASM 1
+__PRAGMA_REDEFINE_EXTNAME 1
+__SIZEOF_INT128__ 16
+__SIZEOF_WCHAR_T__ 4
+__SIZEOF_WINT_T__ 4
+__SIZEOF_PTRDIFF_T__ 8
+__amd64 1
+__amd64__ 1
+__x86_64 1
+__x86_64__ 1
+__k8 1
+__k8__ 1
+__MMX__ 1
+__SSE__ 1
+__SSE2__ 1
+__SSE_MATH__ 1
+__SSE2_MATH__ 1
+__gnu_linux__ 1
+__linux 1
+__linux__ 1
+linux 1
+__unix 1
+__unix__ 1
+unix 1
+__ELF__ 1
+__DECIMAL_BID_FORMAT__ 1
+file /home/mark/src/tests/macro.c
+ file /usr/include/string.h
+ _STRING_H 1
+ file /usr/include/features.h
+ include 0x5d8
+ _FEATURES_H 1
+ __KERNEL_STRICT_NAMES
+ __USE_ANSI 1
+ __GNUC_PREREQ(maj,min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+ _BSD_SOURCE 1
+ _SVID_SOURCE 1
+ _POSIX_SOURCE 1
+ _POSIX_C_SOURCE 200809L
+ __USE_POSIX_IMPLICITLY 1
+ __USE_POSIX 1
+ __USE_POSIX2 1
+ __USE_POSIX199309 1
+ __USE_POSIX199506 1
+ __USE_XOPEN2K 1
+ __USE_ISOC95 1
+ __USE_ISOC99 1
+ __USE_XOPEN2K8 1
+ _ATFILE_SOURCE 1
+ __USE_MISC 1
+ __USE_BSD 1
+ __USE_SVID 1
+ __USE_ATFILE 1
+ __USE_FORTIFY_LEVEL 0
+ /include
+ file /usr/include/stdc-predef.h
+ include 0x733
+ _STDC_PREDEF_H 1
+ __STDC_IEC_559__ 1
+ __STDC_IEC_559_COMPLEX__ 1
+ __STDC_ISO_10646__ 201103L
+ __STDC_NO_THREADS__ 1
+ /include
+ /file
+ include 0x755
+ __GNU_LIBRARY__ 6
+ __GLIBC__ 2
+ __GLIBC_MINOR__ 15
+ __GLIBC_PREREQ(maj,min) ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
+ __GLIBC_HAVE_LONG_LONG 1
+ /include
+ file /usr/include/sys/cdefs.h
+ include 0x783
+ _SYS_CDEFS_H 1
+ __LEAF , __leaf__
+ __LEAF_ATTR __attribute__ ((__leaf__))
+ __THROW __attribute__ ((__nothrow__ __LEAF))
+ __THROWNL __attribute__ ((__nothrow__))
+ __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
+ __P(args) args
+ __PMT(args) args
+ __CONCAT(x,y) x ## y
+ __STRING(x) #x
+ __ptr_t void *
+ __long_double_t long double
+ __BEGIN_DECLS
+ __END_DECLS
+ __BEGIN_NAMESPACE_STD
+ __END_NAMESPACE_STD
+ __USING_NAMESPACE_STD(name)
+ __BEGIN_NAMESPACE_C99
+ __END_NAMESPACE_C99
+ __USING_NAMESPACE_C99(name)
+ __bounded
+ __unbounded
+ __ptrvalue
+ __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
+ __bos0(ptr) __builtin_object_size (ptr, 0)
+ __fortify_function __extern_always_inline __attribute_artificial__
+ __warndecl(name,msg) extern void name (void) __attribute__((__warning__ (msg)))
+ __warnattr(msg) __attribute__((__warning__ (msg)))
+ __errordecl(name,msg) extern void name (void) __attribute__((__error__ (msg)))
+ __flexarr []
+ __REDIRECT(name,proto,alias) name proto __asm__ (__ASMNAME (#alias))
+ __REDIRECT_NTH(name,proto,alias) name proto __asm__ (__ASMNAME (#alias)) __THROW
+ __REDIRECT_NTHNL(name,proto,alias) name proto __asm__ (__ASMNAME (#alias)) __THROWNL
+ __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+ __ASMNAME2(prefix,cname) __STRING (prefix) cname
+ __attribute_malloc__ __attribute__ ((__malloc__))
+ __attribute_pure__ __attribute__ ((__pure__))
+ __attribute_const__ __attribute__ ((__const__))
+ __attribute_used__ __attribute__ ((__used__))
+ __attribute_noinline__ __attribute__ ((__noinline__))
+ __attribute_deprecated__ __attribute__ ((__deprecated__))
+ __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
+ __attribute_format_strfmon__(a,b) __attribute__ ((__format__ (__strfmon__, a, b)))
+ __nonnull(params) __attribute__ ((__nonnull__ params))
+ __attribute_warn_unused_result__ __attribute__ ((__warn_unused_result__))
+ __wur
+ __always_inline __inline __attribute__ ((__always_inline__))
+ __attribute_artificial__ __attribute__ ((__artificial__))
+ __extern_inline extern __inline
+ __extern_always_inline extern __always_inline
+ __va_arg_pack() __builtin_va_arg_pack ()
+ __va_arg_pack_len() __builtin_va_arg_pack_len ()
+ __restrict_arr __restrict
+ __glibc_unlikely(cond) __builtin_expect((cond), 0)
+ /include
+ file /usr/include/bits/wordsize.h
+ include 0x8fa
+ __WORDSIZE 64
+ __WORDSIZE_TIME64_COMPAT32 1
+ __SYSCALL_WORDSIZE 64
+ /include
+ /file
+ include 0x910
+ __LDBL_REDIR1(name,proto,alias) name proto
+ __LDBL_REDIR(name,proto) name proto
+ __LDBL_REDIR1_NTH(name,proto,alias) name proto __THROW
+ __LDBL_REDIR_NTH(name,proto) name proto __THROW
+ __LDBL_REDIR_DECL(name)
+ __REDIRECT_LDBL(name,proto,alias) __REDIRECT (name, proto, alias)
+ __REDIRECT_NTH_LDBL(name,proto,alias) __REDIRECT_NTH (name, proto, alias)
+ /include
+ /file
+ file /usr/include/gnu/stubs.h
+ file /usr/include/gnu/stubs-64.h
+ include 0x945
+ __stub_bdflush
+ __stub_chflags
+ __stub_fattach
+ __stub_fchflags
+ __stub_fdetach
+ __stub_getmsg
+ __stub_gtty
+ __stub_lchmod
+ __stub_putmsg
+ __stub_revoke
+ __stub_setlogin
+ __stub_sigreturn
+ __stub_sstk
+ __stub_stty
+ /include
+ /file
+ /file
+ /file
+ include 0x99d
+ __need_size_t
+ __need_NULL
+ /include
+ file /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/stddef.h
+ include 0x9ad
+ __size_t__
+ __SIZE_T__
+ _SIZE_T
+ _SYS_SIZE_T_H
+ _T_SIZE_
+ _T_SIZE
+ __SIZE_T
+ _SIZE_T_
+ _BSD_SIZE_T_
+ _SIZE_T_DEFINED_
+ _SIZE_T_DEFINED
+ _BSD_SIZE_T_DEFINED_
+ _SIZE_T_DECLARED
+ ___int_size_t_h
+ _GCC_SIZE_T
+ _SIZET_
+ __size_t
+ NULL ((void *)0)
+ /include
+ /file
+ file /usr/include/xlocale.h
+ _XLOCALE_H 1
+ /file
+ /file
+ HELLO "world"
+/file
+EOF
+
+testfiles testfile-macros-0xff
+testrun_compare ${abs_builddir}/dwarf-getmacros testfile-macros-0xff 0xb <<\EOF
+invalid opcode
+EOF
+testrun_compare ${abs_builddir}/dwarf-getmacros testfile-macros-0xff 0xb '' <<\EOF
+opcode 255 with 0 arguments
+file /home/petr/proj/elfutils/master/elfutils/x.c
+ FOO 0
+/file
+EOF
+
+exit 0
diff --git a/tests/run-dwarf-getstring.sh b/tests/run-dwarf-getstring.sh
new file mode 100755
index 0000000..f18f628
--- /dev/null
+++ b/tests/run-dwarf-getstring.sh
@@ -0,0 +1,125 @@
+#! /bin/sh
+# Copyright (C) 2011 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
+
+testfiles testfile11
+
+testrun_compare ${abs_builddir}/dwarf-getstring testfile11 <<\EOF
+_ZNSbIwSt11char_traitsIwESaIwEE13_S_copy_charsEPwS3_S3_
+itimerspec
+_G_int32_t
+_IO_last_state
+antiquities
+_ZNSbIwSt11char_traitsIwESaIwEEpLEw
+insert
+_ZNSbIwSt11char_traitsIwESaIwEE12_M_leak_hardEv
+__lockkind
+_ZNKSbIwSt11char_traitsIwESaIwEE8capacityEv
+_ZNSs7_M_leakEv
+_M_ref_count
+_ZNSt11char_traitsIwE6assignEPwjw
+_ZNKSs13find_first_ofEPKcj
+._14
+._15
+._16
+._17
+_ZNKSs16find_last_not_ofEPKcj
+_G_iconv_t
+_ZN10__gnu_test9gnu_obj_2IlEaSERKS1_
+_ZN11random_dataaSERKS_
+_ZNSt11char_traitsIcE7not_eofERKi
+__class_type_info
+tm_sec
+_ZNKSbIwSt11char_traitsIwESaIwEE5c_strEv
+__rlim64_t
+seek
+pthread_mutex_t
+_ZNSs5eraseEN9__gnu_cxx17__normal_iteratorIPcSsEE
+_ZNSsaSEc
+__not_va_list__
+_ZNKSs12find_last_ofEPKcj
+_ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_S2_S2_
+__gconv_info
+_ZNSt11__ios_flags12_S_showpointE
+output_iterator_tag
+gnu_obj_2<long int>
+_ZNSs6insertEjRKSsjj
+_ZN13__type_traitsIbEaSERKS0_
+_ZNKSbIwSt11char_traitsIwESaIwEE4copyEPwjj
+_ZNSs9_M_mutateEjjj
+__ios_flags
+short unsigned int
+_ZNKSs4findEPKcj
+compare
+_ZNSbIwSt11char_traitsIwESaIwEE4_Rep7_M_grabERKS1_S5_
+tm_yday
+unsigned char
+__stacksize
+__gconv_init_fct
+_IO_FILE
+__counter
+._26
+._27
+bidirectional_iterator_tag
+._29
+it_value
+const_iterator
+_ZNSt11__ios_flags6_S_outE
+_M_set_leaked
+_Is_integer<unsigned int>
+__value
+timeval
+_IO_jump_t
+_ZN11sched_paramaSERKS_
+__normal_iterator<char*,std::basic_string<char, std::char_traits<char>, std::allocator<char> > >
+_ZNSs4_Rep7_M_grabERKSaIcES2_
+_wide_vtable
+__codecvt_destr
+_STL_mutex_lock
+_ZNSt24__default_alloc_templateILb1ELi0EE17_S_freelist_indexEj
+_ZNSbIwSt11char_traitsIwESaIwEE7replaceEjjjw
+_ZN17__gconv_step_dataaSERKS_
+__w_stopval
+__int64_t
+__type_traits<double>
+~_Lock
+_ZNKSbIwSt11char_traitsIwESaIwEE5beginEv
+ptrdiff_t
+test
+_Integral
+cookie_seek_function_t
+__vmi_class_type_info
+_ZNSs7replaceEjjjc
+__int32_t
+register_t
+~_STL_auto_lock
+_ZNKSbIwSt11char_traitsIwESaIwEE16find_last_not_ofEPKwjj
+__arg
+_ZNSs7replaceEjjPKcj
+_ZNSbIwSt11char_traitsIwESaIwEE7replaceEjjRKS2_jj
+_ZNKSbIwSt11char_traitsIwESaIwEE12find_last_ofEPKwjj
+_ZN11_Is_integerImEaSERKS0_
+__default_alloc_template
+_S_hex
+__statep
+_ZNSt11char_traitsIwE2ltERKwS2_
+_M_p
+_ZNKSs4sizeEv
+EOF
+
+exit 0
diff --git a/tests/run-dwarf-ranges.sh b/tests/run-dwarf-ranges.sh
new file mode 100755
index 0000000..d202ed3
--- /dev/null
+++ b/tests/run-dwarf-ranges.sh
@@ -0,0 +1,27 @@
+#! /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
+
+testfiles debug-ranges-no-lowpc.o
+
+testrun_compare ${abs_builddir}/dwarf-ranges debug-ranges-no-lowpc.o 0xb <<\EOF
+1..2 (base 0)
+3..4 (base 0)
+EOF
+
+exit 0
diff --git a/tests/run-dwelfgnucompressed.sh b/tests/run-dwelfgnucompressed.sh
new file mode 100755
index 0000000..b93a56f
--- /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/run-dwfl-addr-sect.sh b/tests/run-dwfl-addr-sect.sh
new file mode 100755
index 0000000..80da008
--- /dev/null
+++ b/tests/run-dwfl-addr-sect.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2007-2009 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
+
+testfiles testfile43 testfile50
+
+testrun_compare ${abs_builddir}/dwfl-addr-sect -e testfile43 0x64 0x8 0x98 <<\EOF
+address 0x64 => module "" section 4 + 0
+address 0x8 => module "" section 1 + 0x8
+address 0x98 => module "" section 7 + 0
+EOF
+
+testrun_compare ${abs_builddir}/dwfl-addr-sect -e testfile50 0x1 <<\EOF
+address 0x1 => module "" section 1 + 0x1
+EOF
+
+exit 0
diff --git a/tests/run-dwfl-bug-offline-rel.sh b/tests/run-dwfl-bug-offline-rel.sh
new file mode 100755
index 0000000..fa476c4
--- /dev/null
+++ b/tests/run-dwfl-bug-offline-rel.sh
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Copyright (C) 2007 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
+
+testfiles testfile36 testfile36.debug
+
+testrun_compare ${abs_builddir}/dwflmodtest -e testfile36 <<\EOF
+module: 00000000..00002308 testfile36 (null)
+module: 00000000 DWARF 0 (no error)
+module: 00000000..00002308 testfile36 testfile36.debug
+EOF
+
+exit 0
diff --git a/tests/run-dwfl-report-elf-align.sh b/tests/run-dwfl-report-elf-align.sh
new file mode 100755
index 0000000..3849753
--- /dev/null
+++ b/tests/run-dwfl-report-elf-align.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+testfiles testfile-dwfl-report-elf-align-shlib.so
+
+# /proc/PID/maps when the process was running:
+# 7f3560c92000-7f3560c93000 r-xp 00000000 fd:02 25037063 testfile-dwfl-report-elf-align-shlib.so
+# 7f3560c93000-7f3560e92000 ---p 00001000 fd:02 25037063 testfile-dwfl-report-elf-align-shlib.so
+# 7f3560e92000-7f3560e93000 rw-p 00000000 fd:02 25037063 testfile-dwfl-report-elf-align-shlib.so
+# testfile-dwfl-report-elf-align-shlib.so:
+# Program Headers:
+# Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
+# LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x00065c 0x00065c R E 0x200000
+# LOAD 0x000660 0x0000000000200660 0x0000000000200660 0x0001f0 0x000200 RW 0x200000
+# Symbol table '.dynsym' contains 12 entries:
+# Num: Value Size Type Bind Vis Ndx Name
+# 8: 000000000000057c 11 FUNC GLOBAL DEFAULT 11 shlib
+# GDB output showing proper relocation:
+# #1 0x00007f3560c92585 in shlib () from ./testfile-dwfl-report-elf-align-shlib.so
+#
+# 0x7f3560c92000 is VMA address of first byte of testfile-dwfl-report-elf-align-shlib.so.
+# 0x7f3560c92585 = 0x7f3560c92000 + 0x585
+# where 0x585 is any address inside the shlib function: 0x57c .. 0x57c + 11 -1
+
+testrun ${abs_builddir}/dwfl-report-elf-align ./testfile-dwfl-report-elf-align-shlib.so \
+ 0x7f3560c92000 0x7f3560c92585 shlib
+
+exit 0
diff --git a/tests/run-dwfllines.sh b/tests/run-dwfllines.sh
new file mode 100755
index 0000000..b384de0
--- /dev/null
+++ b/tests/run-dwfllines.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+testfiles testfile testfile2
+
+testrun_compare ${abs_builddir}/dwfllines -e testfile <<\EOF
+mod: CU: [b] m.c
+0 0x804842c /home/drepper/gnu/new-bu/build/ttt/m.c:5:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+1 0x8048432 /home/drepper/gnu/new-bu/build/ttt/m.c:6:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+2 0x804844d /home/drepper/gnu/new-bu/build/ttt/m.c:7:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+3 0x8048458 /home/drepper/gnu/new-bu/build/ttt/m.c:8:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+4 0x804845a /home/drepper/gnu/new-bu/build/ttt/m.c:8:0
+ time: 0, len: 0, idx: 0, b: 1, e: 1, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+mod: CU: [ca] b.c
+0 0x804845c /home/drepper/gnu/new-bu/build/ttt/b.c:4:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+1 0x804845f /home/drepper/gnu/new-bu/build/ttt/b.c:5:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+2 0x8048464 /home/drepper/gnu/new-bu/build/ttt/b.c:6:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+3 0x8048466 /home/drepper/gnu/new-bu/build/ttt/b.c:6:0
+ time: 0, len: 0, idx: 0, b: 1, e: 1, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+mod: CU: [15fc] f.c
+0 0x8048468 /home/drepper/gnu/new-bu/build/ttt/f.c:3:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+1 0x804846b /home/drepper/gnu/new-bu/build/ttt/f.c:4:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+2 0x8048470 /home/drepper/gnu/new-bu/build/ttt/f.c:5:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+3 0x8048472 /home/drepper/gnu/new-bu/build/ttt/f.c:5:0
+ time: 0, len: 0, idx: 0, b: 1, e: 1, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+EOF
+
+testrun_compare ${abs_builddir}/dwfllines -e testfile2 <<\EOF
+mod: CU: [b] b.c
+0 0x10000470 /shoggoth/drepper/b.c:4:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+1 0x1000047c /shoggoth/drepper/b.c:5:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+2 0x10000480 /shoggoth/drepper/b.c:6:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+3 0x10000490 /shoggoth/drepper/b.c:6:0
+ time: 0, len: 0, idx: 0, b: 1, e: 1, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+mod: CU: [97d] f.c
+0 0x10000490 /shoggoth/drepper/f.c:3:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+1 0x1000049c /shoggoth/drepper/f.c:4:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+2 0x100004a0 /shoggoth/drepper/f.c:5:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+3 0x100004b0 /shoggoth/drepper/f.c:5:0
+ time: 0, len: 0, idx: 0, b: 1, e: 1, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+mod: CU: [9e4] m.c
+0 0x100004b0 /shoggoth/drepper/m.c:5:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+1 0x100004cc /shoggoth/drepper/m.c:6:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+2 0x100004e8 /shoggoth/drepper/m.c:7:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+3 0x100004f4 /shoggoth/drepper/m.c:8:0
+ time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+4 0x10000514 /shoggoth/drepper/m.c:8:0
+ time: 0, len: 0, idx: 0, b: 1, e: 1, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
+EOF
+
+testrun_on_self_quiet ${abs_builddir}/dwfllines -e
+
+exit 0
diff --git a/tests/run-dwflsyms.sh b/tests/run-dwflsyms.sh
new file mode 100755
index 0000000..9726bcf
--- /dev/null
+++ b/tests/run-dwflsyms.sh
@@ -0,0 +1,826 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+# Tests dwfl_module_{addrsym,getsym,relocate_address}
+# See run-readelf-s.sh for how to generate test binaries.
+# In addition, *_pl files were created from their base file
+# with prelink -N, and *_plr with prelink -r 0x4200000000.
+
+testfiles testfilebaztab
+testfiles testfilebazdbg testfilebazdbg.debug
+testfiles testfilebazdbg_pl
+testfiles testfilebazdbg_plr
+testfiles testfilebazdyn
+testfiles testfilebazmdb
+testfiles testfilebazmin
+testfiles testfilebazmin_pl
+testfiles testfilebazmin_plr
+testfiles testfilebasmin
+testfiles testfilebaxmin
+
+tempfiles testfile.dynsym.in testfile.symtab.in testfile.minsym.in dwflsyms.out
+tempfiles testfile.symtab_pl.in testfile.minsym_pl.in
+
+cat > testfile.symtab.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: SECTION LOCAL (0) 0x254
+ 3: SECTION LOCAL (0) 0x274
+ 4: SECTION LOCAL (0) 0x298
+ 5: SECTION LOCAL (0) 0x2d8
+ 6: SECTION LOCAL (0) 0x428
+ 7: SECTION LOCAL (0) 0x4f2
+ 8: SECTION LOCAL (0) 0x510
+ 9: SECTION LOCAL (0) 0x530
+ 10: SECTION LOCAL (0) 0x638
+ 11: SECTION LOCAL (0) 0x680
+ 12: SECTION LOCAL (0) 0x6a0
+ 13: SECTION LOCAL (0) 0x6e0
+ 14: SECTION LOCAL (0) 0x8f4
+ 15: SECTION LOCAL (0) 0x900
+ 16: SECTION LOCAL (0) 0x904
+ 17: SECTION LOCAL (0) 0x948
+ 18: SECTION LOCAL (0) 0x200dd0
+ 19: SECTION LOCAL (0) 0x200dd8
+ 20: SECTION LOCAL (0) 0x200de0
+ 21: SECTION LOCAL (0) 0x200de8
+ 22: SECTION LOCAL (0) 0x200df0
+ 23: SECTION LOCAL (0) 0x200fc0
+ 24: SECTION LOCAL (0) 0x201000
+ 25: SECTION LOCAL (0) 0x201030
+ 26: SECTION LOCAL (0) 0x20103c
+ 27: SECTION LOCAL (0) 0
+ 28: SECTION LOCAL (0) 0
+ 29: SECTION LOCAL (0) 0
+ 30: SECTION LOCAL (0) 0
+ 31: SECTION LOCAL (0) 0
+ 32: SECTION LOCAL (0) 0
+ 33: FILE LOCAL crtstuff.c (0) 0
+ 34: OBJECT LOCAL __JCR_LIST__ (0) 0x200de0
+ 35: FUNC LOCAL deregister_tm_clones (0) 0x710, rel: 0x710 (.text)
+ 36: FUNC LOCAL register_tm_clones (0) 0x740, rel: 0x740 (.text)
+ 37: FUNC LOCAL __do_global_dtors_aux (0) 0x780, rel: 0x780 (.text)
+ 38: OBJECT LOCAL completed.6137 (1) 0x20103c
+ 39: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x200dd8
+ 40: FUNC LOCAL frame_dummy (0) 0x7c0, rel: 0x7c0 (.text)
+ 41: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x200dd0
+ 42: FILE LOCAL foo.c (0) 0
+ 43: FILE LOCAL bar.c (0) 0
+ 44: OBJECT LOCAL b1 (4) 0x201034
+ 45: FUNC LOCAL foo (20) 0x814, rel: 0x814 (.text)
+ 46: FILE LOCAL crtstuff.c (0) 0
+ 47: OBJECT LOCAL __FRAME_END__ (0) 0xa58
+ 48: OBJECT LOCAL __JCR_END__ (0) 0x200de0
+ 49: FILE LOCAL (0) 0
+ 50: NOTYPE LOCAL __init_array_end (0) 0x200dd8
+ 51: OBJECT LOCAL _DYNAMIC (0) 0x200df0
+ 52: NOTYPE LOCAL __init_array_start (0) 0x200dd0
+ 53: OBJECT LOCAL _GLOBAL_OFFSET_TABLE_ (0) 0x201000
+ 54: FUNC GLOBAL __libc_csu_fini (2) 0x8f0, rel: 0x8f0 (.text)
+ 55: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 56: NOTYPE WEAK data_start (0) 0x201030
+ 57: NOTYPE GLOBAL _edata (0) 0x20103c
+ 58: FUNC GLOBAL bar (44) 0x828, rel: 0x828 (.text)
+ 59: FUNC GLOBAL _fini (0) 0x8f4, rel: 0x8f4 (.fini)
+ 60: FUNC GLOBAL __libc_start_main@@GLIBC_2.2.5 (0) 0
+ 61: NOTYPE GLOBAL __data_start (0) 0x201030
+ 62: NOTYPE WEAK __gmon_start__ (0) 0
+ 63: OBJECT GLOBAL __dso_handle (0) 0x200de8
+ 64: OBJECT GLOBAL _IO_stdin_used (4) 0x900
+ 65: OBJECT GLOBAL b2 (4) 0x201038
+ 66: FUNC GLOBAL __libc_csu_init (137) 0x860, rel: 0x860 (.text)
+ 67: NOTYPE GLOBAL _end (0) 0x201040
+ 68: FUNC GLOBAL _start (0) 0x6e0, rel: 0x6e0 (.text)
+ 69: NOTYPE GLOBAL __bss_start (0) 0x20103c
+ 70: FUNC GLOBAL main (35) 0x7f0, rel: 0x7f0 (.text)
+ 71: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 72: OBJECT GLOBAL __TMC_END__ (0) 0x201040
+ 73: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 74: FUNC WEAK __cxa_finalize@@GLIBC_2.2.5 (0) 0
+ 75: FUNC GLOBAL _init (0) 0x680, rel: 0x680 (.init)
+EOF
+
+cat > testfile.symtab_pl.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x3000000238
+ 2: SECTION LOCAL (0) 0x3000000254
+ 3: SECTION LOCAL (0) 0x3000000274
+ 4: SECTION LOCAL (0) 0x3000000298
+ 5: SECTION LOCAL (0) 0x30000002d8
+ 6: SECTION LOCAL (0) 0x3000000428
+ 7: SECTION LOCAL (0) 0x30000004f2
+ 8: SECTION LOCAL (0) 0x3000000510
+ 9: SECTION LOCAL (0) 0x3000000530
+ 10: SECTION LOCAL (0) 0x3000000638
+ 11: SECTION LOCAL (0) 0x3000000680
+ 12: SECTION LOCAL (0) 0x30000006a0
+ 13: SECTION LOCAL (0) 0x30000006e0
+ 14: SECTION LOCAL (0) 0x30000008f4
+ 15: SECTION LOCAL (0) 0x3000000900
+ 16: SECTION LOCAL (0) 0x3000000904
+ 17: SECTION LOCAL (0) 0x3000000948
+ 18: SECTION LOCAL (0) 0x3000200dd0
+ 19: SECTION LOCAL (0) 0x3000200dd8
+ 20: SECTION LOCAL (0) 0x3000200de0
+ 21: SECTION LOCAL (0) 0x3000200de8
+ 22: SECTION LOCAL (0) 0x3000200df0
+ 23: SECTION LOCAL (0) 0x3000200fc0
+ 24: SECTION LOCAL (0) 0x3000201000
+ 25: SECTION LOCAL (0) 0x3000201030
+ 26: SECTION LOCAL (0) 0x300020103c
+ 27: SECTION LOCAL (0) 0
+ 28: SECTION LOCAL (0) 0
+ 29: SECTION LOCAL (0) 0
+ 30: SECTION LOCAL (0) 0
+ 31: SECTION LOCAL (0) 0
+ 32: SECTION LOCAL (0) 0
+ 33: FILE LOCAL crtstuff.c (0) 0
+ 34: OBJECT LOCAL __JCR_LIST__ (0) 0x3000200de0
+ 35: FUNC LOCAL deregister_tm_clones (0) 0x3000000710, rel: 0x710 (.text)
+ 36: FUNC LOCAL register_tm_clones (0) 0x3000000740, rel: 0x740 (.text)
+ 37: FUNC LOCAL __do_global_dtors_aux (0) 0x3000000780, rel: 0x780 (.text)
+ 38: OBJECT LOCAL completed.6137 (1) 0x300020103c
+ 39: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x3000200dd8
+ 40: FUNC LOCAL frame_dummy (0) 0x30000007c0, rel: 0x7c0 (.text)
+ 41: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x3000200dd0
+ 42: FILE LOCAL foo.c (0) 0
+ 43: FILE LOCAL bar.c (0) 0
+ 44: OBJECT LOCAL b1 (4) 0x3000201034
+ 45: FUNC LOCAL foo (20) 0x3000000814, rel: 0x814 (.text)
+ 46: FILE LOCAL crtstuff.c (0) 0
+ 47: OBJECT LOCAL __FRAME_END__ (0) 0x3000000a58
+ 48: OBJECT LOCAL __JCR_END__ (0) 0x3000200de0
+ 49: FILE LOCAL (0) 0
+ 50: NOTYPE LOCAL __init_array_end (0) 0x3000200dd8
+ 51: OBJECT LOCAL _DYNAMIC (0) 0x3000200df0
+ 52: NOTYPE LOCAL __init_array_start (0) 0x3000200dd0
+ 53: OBJECT LOCAL _GLOBAL_OFFSET_TABLE_ (0) 0x3000201000
+ 54: FUNC GLOBAL __libc_csu_fini (2) 0x30000008f0, rel: 0x8f0 (.text)
+ 55: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 56: NOTYPE WEAK data_start (0) 0x3000201030
+ 57: NOTYPE GLOBAL _edata (0) 0x300020103c
+ 58: FUNC GLOBAL bar (44) 0x3000000828, rel: 0x828 (.text)
+ 59: FUNC GLOBAL _fini (0) 0x30000008f4, rel: 0x8f4 (.fini)
+ 60: FUNC GLOBAL __libc_start_main@@GLIBC_2.2.5 (0) 0
+ 61: NOTYPE GLOBAL __data_start (0) 0x3000201030
+ 62: NOTYPE WEAK __gmon_start__ (0) 0
+ 63: OBJECT GLOBAL __dso_handle (0) 0x3000200de8
+ 64: OBJECT GLOBAL _IO_stdin_used (4) 0x3000000900
+ 65: OBJECT GLOBAL b2 (4) 0x3000201038
+ 66: FUNC GLOBAL __libc_csu_init (137) 0x3000000860, rel: 0x860 (.text)
+ 67: NOTYPE GLOBAL _end (0) 0x3000201040
+ 68: FUNC GLOBAL _start (0) 0x30000006e0, rel: 0x6e0 (.text)
+ 69: NOTYPE GLOBAL __bss_start (0) 0x300020103c
+ 70: FUNC GLOBAL main (35) 0x30000007f0, rel: 0x7f0 (.text)
+ 71: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 72: OBJECT GLOBAL __TMC_END__ (0) 0x3000201040
+ 73: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 74: FUNC WEAK __cxa_finalize@@GLIBC_2.2.5 (0) 0
+ 75: FUNC GLOBAL _init (0) 0x3000000680, rel: 0x680 (.init)
+EOF
+
+cat > testfile.dynsym.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 3: FUNC GLOBAL __libc_start_main (0) 0
+ 4: NOTYPE WEAK __gmon_start__ (0) 0
+ 5: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 6: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 7: FUNC WEAK __cxa_finalize (0) 0
+ 8: NOTYPE GLOBAL _edata (0) 0x20103c
+ 9: NOTYPE GLOBAL _end (0) 0x201040
+ 10: FUNC GLOBAL __libc_csu_init (137) 0x860, rel: 0x860 (.text)
+ 11: NOTYPE GLOBAL __bss_start (0) 0x20103c
+ 12: FUNC GLOBAL main (35) 0x7f0, rel: 0x7f0 (.text)
+ 13: FUNC GLOBAL __libc_csu_fini (2) 0x8f0, rel: 0x8f0 (.text)
+EOF
+
+cat > testfile.minsym.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: FUNC LOCAL deregister_tm_clones (0) 0x710, rel: 0x710 (.text)
+ 3: FUNC LOCAL register_tm_clones (0) 0x740, rel: 0x740 (.text)
+ 4: FUNC LOCAL __do_global_dtors_aux (0) 0x780, rel: 0x780 (.text)
+ 5: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x200dd8
+ 6: FUNC LOCAL frame_dummy (0) 0x7c0, rel: 0x7c0 (.text)
+ 7: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x200dd0
+ 8: FUNC LOCAL foo (20) 0x814, rel: 0x814 (.text)
+ 9: NOTYPE LOCAL __init_array_end (0) 0x200dd8
+ 10: NOTYPE LOCAL __init_array_start (0) 0x200dd0
+ 11: SECTION LOCAL (0) 0x238
+ 12: SECTION LOCAL (0) 0x254
+ 13: SECTION LOCAL (0) 0x274
+ 14: SECTION LOCAL (0) 0x298
+ 15: SECTION LOCAL (0) 0x2d8
+ 16: SECTION LOCAL (0) 0x428
+ 17: SECTION LOCAL (0) 0x4f2
+ 18: SECTION LOCAL (0) 0x510
+ 19: SECTION LOCAL (0) 0x530
+ 20: SECTION LOCAL (0) 0x638
+ 21: SECTION LOCAL (0) 0x680
+ 22: SECTION LOCAL (0) 0x6a0
+ 23: SECTION LOCAL (0) 0x6e0
+ 24: SECTION LOCAL (0) 0x8f4
+ 25: SECTION LOCAL (0) 0x900
+ 26: SECTION LOCAL (0) 0x904
+ 27: SECTION LOCAL (0) 0x948
+ 28: SECTION LOCAL (0) 0x200dd0
+ 29: SECTION LOCAL (0) 0x200dd8
+ 30: SECTION LOCAL (0) 0x200de0
+ 31: SECTION LOCAL (0) 0x200de8
+ 32: SECTION LOCAL (0) 0x200df0
+ 33: SECTION LOCAL (0) 0x200fc0
+ 34: SECTION LOCAL (0) 0x201000
+ 35: SECTION LOCAL (0) 0x201030
+ 36: SECTION LOCAL (0) 0x20103c
+ 37: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 38: FUNC GLOBAL __libc_start_main (0) 0
+ 39: NOTYPE WEAK __gmon_start__ (0) 0
+ 40: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 41: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 42: FUNC WEAK __cxa_finalize (0) 0
+ 43: NOTYPE GLOBAL _edata (0) 0x20103c
+ 44: NOTYPE GLOBAL _end (0) 0x201040
+ 45: FUNC GLOBAL __libc_csu_init (137) 0x860, rel: 0x860 (.text)
+ 46: NOTYPE GLOBAL __bss_start (0) 0x20103c
+ 47: FUNC GLOBAL main (35) 0x7f0, rel: 0x7f0 (.text)
+ 48: FUNC GLOBAL __libc_csu_fini (2) 0x8f0, rel: 0x8f0 (.text)
+ 49: FUNC GLOBAL bar (44) 0x828, rel: 0x828 (.text)
+ 50: FUNC GLOBAL _fini (0) 0x8f4, rel: 0x8f4 (.fini)
+ 51: FUNC GLOBAL _start (0) 0x6e0, rel: 0x6e0 (.text)
+ 52: FUNC GLOBAL _init (0) 0x680, rel: 0x680 (.init)
+EOF
+
+cat > testfile.minsym_pl.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x3000000238
+ 2: FUNC LOCAL deregister_tm_clones (0) 0x3000000710, rel: 0x710 (.text)
+ 3: FUNC LOCAL register_tm_clones (0) 0x3000000740, rel: 0x740 (.text)
+ 4: FUNC LOCAL __do_global_dtors_aux (0) 0x3000000780, rel: 0x780 (.text)
+ 5: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x3000200dd8
+ 6: FUNC LOCAL frame_dummy (0) 0x30000007c0, rel: 0x7c0 (.text)
+ 7: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x3000200dd0
+ 8: FUNC LOCAL foo (20) 0x3000000814, rel: 0x814 (.text)
+ 9: NOTYPE LOCAL __init_array_end (0) 0x3000200dd8
+ 10: NOTYPE LOCAL __init_array_start (0) 0x3000200dd0
+ 11: SECTION LOCAL (0) 0x3000000238
+ 12: SECTION LOCAL (0) 0x3000000254
+ 13: SECTION LOCAL (0) 0x3000000274
+ 14: SECTION LOCAL (0) 0x3000000298
+ 15: SECTION LOCAL (0) 0x30000002d8
+ 16: SECTION LOCAL (0) 0x3000000428
+ 17: SECTION LOCAL (0) 0x30000004f2
+ 18: SECTION LOCAL (0) 0x3000000510
+ 19: SECTION LOCAL (0) 0x3000000530
+ 20: SECTION LOCAL (0) 0x3000000638
+ 21: SECTION LOCAL (0) 0x3000000680
+ 22: SECTION LOCAL (0) 0x30000006a0
+ 23: SECTION LOCAL (0) 0x30000006e0
+ 24: SECTION LOCAL (0) 0x30000008f4
+ 25: SECTION LOCAL (0) 0x3000000900
+ 26: SECTION LOCAL (0) 0x3000000904
+ 27: SECTION LOCAL (0) 0x3000000948
+ 28: SECTION LOCAL (0) 0x3000200dd0
+ 29: SECTION LOCAL (0) 0x3000200dd8
+ 30: SECTION LOCAL (0) 0x3000200de0
+ 31: SECTION LOCAL (0) 0x3000200de8
+ 32: SECTION LOCAL (0) 0x3000200df0
+ 33: SECTION LOCAL (0) 0x3000200fc0
+ 34: SECTION LOCAL (0) 0x3000201000
+ 35: SECTION LOCAL (0) 0x3000201030
+ 36: SECTION LOCAL (0) 0x300020103c
+ 37: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 38: FUNC GLOBAL __libc_start_main (0) 0
+ 39: NOTYPE WEAK __gmon_start__ (0) 0
+ 40: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 41: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 42: FUNC WEAK __cxa_finalize (0) 0
+ 43: NOTYPE GLOBAL _edata (0) 0x300020103c
+ 44: NOTYPE GLOBAL _end (0) 0x3000201040
+ 45: FUNC GLOBAL __libc_csu_init (137) 0x3000000860, rel: 0x860 (.text)
+ 46: NOTYPE GLOBAL __bss_start (0) 0x300020103c
+ 47: FUNC GLOBAL main (35) 0x30000007f0, rel: 0x7f0 (.text)
+ 48: FUNC GLOBAL __libc_csu_fini (2) 0x30000008f0, rel: 0x8f0 (.text)
+ 49: FUNC GLOBAL bar (44) 0x3000000828, rel: 0x828 (.text)
+ 50: FUNC GLOBAL _fini (0) 0x30000008f4, rel: 0x8f4 (.fini)
+ 51: FUNC GLOBAL _start (0) 0x30000006e0, rel: 0x6e0 (.text)
+ 52: FUNC GLOBAL _init (0) 0x3000000680, rel: 0x680 (.init)
+EOF
+
+cat testfile.symtab.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebaztab
+
+cat testfile.symtab.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdbg
+
+cat testfile.symtab_pl.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdbg_pl
+
+sed s/0x3000/0x4200/g testfile.symtab_pl.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdbg_plr
+
+cat testfile.dynsym.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdyn
+
+cat testfile.symtab.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazmdb
+
+cat testfile.minsym.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazmin
+
+cat testfile.minsym_pl.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazmin_pl
+
+sed s/0x3000/0x4200/g testfile.minsym_pl.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazmin_plr
+
+testrun_compare ${abs_builddir}/dwflsyms -e testfilebasmin <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: FUNC LOCAL foo (18) 0x400168, rel: 0x400168 (.text)
+ 2: SECTION LOCAL (0) 0x400120
+ 3: SECTION LOCAL (0) 0x400144
+ 4: SECTION LOCAL (0) 0x4001c0
+ 5: SECTION LOCAL (0) 0x600258
+ 6: FUNC GLOBAL _start (21) 0x4001a8, rel: 0x4001a8 (.text)
+ 7: FUNC GLOBAL main (33) 0x400144, rel: 0x400144 (.text)
+ 8: FUNC GLOBAL bar (44) 0x40017a, rel: 0x40017a (.text)
+EOF
+
+testrun_compare ${abs_builddir}/dwflsyms -e testfilebaxmin <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: FUNC LOCAL deregister_tm_clones (0) 0x400430, rel: 0x400430 (.text)
+ 2: FUNC LOCAL register_tm_clones (0) 0x400460, rel: 0x400460 (.text)
+ 3: FUNC LOCAL __do_global_dtors_aux (0) 0x4004a0, rel: 0x4004a0 (.text)
+ 4: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x600e18
+ 5: FUNC LOCAL frame_dummy (0) 0x4004c0, rel: 0x4004c0 (.text)
+ 6: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x600e10
+ 7: FUNC LOCAL foo (20) 0x4004f0, rel: 0x4004f0 (.text)
+ 8: NOTYPE LOCAL __init_array_end (0) 0x600e18
+ 9: NOTYPE LOCAL __init_array_start (0) 0x600e10
+ 10: SECTION LOCAL (0) 0x400238
+ 11: SECTION LOCAL (0) 0x400254
+ 12: SECTION LOCAL (0) 0x400274
+ 13: SECTION LOCAL (0) 0x400298
+ 14: SECTION LOCAL (0) 0x4002b8
+ 15: SECTION LOCAL (0) 0x400300
+ 16: SECTION LOCAL (0) 0x400338
+ 17: SECTION LOCAL (0) 0x400340
+ 18: SECTION LOCAL (0) 0x400360
+ 19: SECTION LOCAL (0) 0x400378
+ 20: SECTION LOCAL (0) 0x4003a8
+ 21: SECTION LOCAL (0) 0x4003d0
+ 22: SECTION LOCAL (0) 0x400400
+ 23: SECTION LOCAL (0) 0x4005c4
+ 24: SECTION LOCAL (0) 0x4005d0
+ 25: SECTION LOCAL (0) 0x4005e0
+ 26: SECTION LOCAL (0) 0x400628
+ 27: SECTION LOCAL (0) 0x600e10
+ 28: SECTION LOCAL (0) 0x600e18
+ 29: SECTION LOCAL (0) 0x600e20
+ 30: SECTION LOCAL (0) 0x600e28
+ 31: SECTION LOCAL (0) 0x600ff8
+ 32: SECTION LOCAL (0) 0x601000
+ 33: SECTION LOCAL (0) 0x601028
+ 34: SECTION LOCAL (0) 0x601034
+ 35: FUNC GLOBAL __libc_start_main (0) 0
+ 36: NOTYPE WEAK __gmon_start__ (0) 0
+ 37: FUNC GLOBAL __libc_csu_fini (2) 0x4005c0, rel: 0x4005c0 (.text)
+ 38: FUNC GLOBAL bar (40) 0x400504, rel: 0x400504 (.text)
+ 39: FUNC GLOBAL _fini (0) 0x4005c4, rel: 0x4005c4 (.fini)
+ 40: FUNC GLOBAL __libc_csu_init (101) 0x400550, rel: 0x400550 (.text)
+ 41: FUNC GLOBAL _start (0) 0x400400, rel: 0x400400 (.text)
+ 42: FUNC GLOBAL main (35) 0x40052c, rel: 0x40052c (.text)
+ 43: FUNC GLOBAL _init (0) 0x4003a8, rel: 0x4003a8 (.init)
+EOF
+
+testfiles testfile66
+testrun_compare ${abs_builddir}/dwflsyms -e testfile66 <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x190
+ 2: SECTION LOCAL (0) 0x1a4
+ 3: SECTION LOCAL (0) 0x1c8
+ 4: SECTION LOCAL (0) 0x1f8
+ 5: SECTION LOCAL (0) 0x288
+ 6: SECTION LOCAL (0) 0x2a8
+ 7: SECTION LOCAL (0) 0x2d8
+ 8: SECTION LOCAL (0) 0x102e0
+ 9: SECTION LOCAL (0) 0x103d0
+ 10: SECTION LOCAL (0) 0x103e8
+ 11: SECTION LOCAL (0) 0x103e8
+ 12: OBJECT LOCAL _DYNAMIC (0) 0x102e0
+ 13: FUNC GLOBAL _start (4) 0x103d0, rel: 0x103d0 (.opd) [0x2d8, rel: 0 (.text)]
+ 14: NOTYPE GLOBAL __bss_start (0) 0x103f0
+ 15: NOTYPE GLOBAL _edata (0) 0x103f0
+ 16: NOTYPE GLOBAL _end (0) 0x103f0
+EOF
+
+testfiles testfile66.core
+testrun_compare ${abs_builddir}/dwflsyms -e testfile66 --core=testfile66.core <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0xfffb1af0410
+ 2: NOTYPE GLOBAL __kernel_datapage_offset (0) 0xfffb1af05dc
+ 3: OBJECT GLOBAL LINUX_2.6.15 (0) 0
+ 4: NOTYPE GLOBAL __kernel_clock_getres (64) 0xfffb1af052c
+ 5: NOTYPE GLOBAL __kernel_get_tbfreq (24) 0xfffb1af0620
+ 6: NOTYPE GLOBAL __kernel_gettimeofday (84) 0xfffb1af0440
+ 7: NOTYPE GLOBAL __kernel_sync_dicache (20) 0xfffb1af06c4
+ 8: NOTYPE GLOBAL __kernel_sync_dicache_p5 (20) 0xfffb1af06c4
+ 9: NOTYPE GLOBAL __kernel_sigtramp_rt64 (12) 0xfffb1af0418
+ 10: NOTYPE GLOBAL __kernel_clock_gettime (152) 0xfffb1af0494
+ 11: NOTYPE GLOBAL __kernel_get_syscall_map (44) 0xfffb1af05f4
+ld64.so.1: Callback returned failure
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x461b0190
+ 2: SECTION LOCAL (0) 0x461b01a4
+ 3: SECTION LOCAL (0) 0x461b01c8
+ 4: SECTION LOCAL (0) 0x461b01f8
+ 5: SECTION LOCAL (0) 0x461b0288
+ 6: SECTION LOCAL (0) 0x461b02a8
+ 7: SECTION LOCAL (0) 0x461b02d8
+ 8: SECTION LOCAL (0) 0x461c02e0
+ 9: SECTION LOCAL (0) 0x461c03d0
+ 10: SECTION LOCAL (0) 0x461c03e8
+ 11: SECTION LOCAL (0) 0x461c03e8
+ 12: OBJECT LOCAL _DYNAMIC (0) 0x102e0
+ 13: FUNC GLOBAL _start (4) 0x461c03d0, rel: 0x103d0 (.opd) [0x461b02d8, rel: 0 (.text)]
+ 14: NOTYPE GLOBAL __bss_start (0) 0x103f0
+ 15: NOTYPE GLOBAL _edata (0) 0x103f0
+ 16: NOTYPE GLOBAL _end (0) 0x103f0
+EOF
+
+# Test the already present dot-prefixed names do not get duplicated.
+testfiles hello_ppc64.ko
+testrun_compare ${abs_builddir}/dwflsyms -e hello_ppc64.ko <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0
+ 2: SECTION LOCAL (0) 0x94
+ 3: SECTION LOCAL (0) 0xba
+ 4: SECTION LOCAL (0) 0xd0
+ 5: SECTION LOCAL (0) 0x13a
+ 6: SECTION LOCAL (0) 0x13a
+ 7: SECTION LOCAL (0) 0x150
+ 8: SECTION LOCAL (0) 0x170
+ 9: SECTION LOCAL (0) 0x188
+ 10: SECTION LOCAL (0) 0x410
+ 11: SECTION LOCAL (0) 0x434
+ 12: SECTION LOCAL (0) 0x438
+ 13: SECTION LOCAL (0) 0x438
+ 14: SECTION LOCAL (0) 0
+ 15: SECTION LOCAL (0) 0
+ 16: SECTION LOCAL (0) 0
+ 17: SECTION LOCAL (0) 0
+ 18: SECTION LOCAL (0) 0
+ 19: SECTION LOCAL (0) 0
+ 20: SECTION LOCAL (0) 0
+ 21: SECTION LOCAL (0) 0
+ 22: SECTION LOCAL (0) 0
+ 23: SECTION LOCAL (0) 0
+ 24: FILE LOCAL init.c (0) 0
+ 25: FILE LOCAL exit.c (0) 0
+ 26: FILE LOCAL hello.mod.c (0) 0
+ 27: OBJECT LOCAL __mod_srcversion23 (35) 0xd0
+ 28: OBJECT LOCAL __module_depends (9) 0xf8
+ 29: OBJECT LOCAL __mod_vermagic5 (50) 0x108
+ 30: OBJECT GLOBAL __this_module (648) 0x188
+ 31: FUNC GLOBAL .cleanup_module (72) 0x4c, rel: 0x4c (.text)
+ 32: FUNC GLOBAL cleanup_module (24) 0x160, rel: 0x10 (.opd)
+ 33: NOTYPE GLOBAL .printk (0) 0
+ 34: FUNC GLOBAL init_module (24) 0x150, rel: 0 (.opd)
+ 35: NOTYPE GLOBAL ._mcount (0) 0
+ 36: FUNC GLOBAL .init_module (76) 0, rel: 0 (.text)
+ 37: NOTYPE GLOBAL _mcount (0) 0
+EOF
+
+# Same test files as above, but now generated on ppc64.
+# ppc64 uses function descriptors to make things more "interesting".
+
+testfiles testfilebaztabppc64
+testfiles testfilebazdbgppc64 testfilebazdbgppc64.debug
+testfiles testfilebazdbgppc64_pl
+testfiles testfilebazdbgppc64_plr
+testfiles testfilebazdynppc64
+testfiles testfilebazmdbppc64
+testfiles testfilebazminppc64
+testfiles testfilebazminppc64_pl
+testfiles testfilebazminppc64_plr
+
+cat > testfile.symtab.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: SECTION LOCAL (0) 0x24c
+ 3: SECTION LOCAL (0) 0x26c
+ 4: SECTION LOCAL (0) 0x290
+ 5: SECTION LOCAL (0) 0x2c0
+ 6: SECTION LOCAL (0) 0x3e0
+ 7: SECTION LOCAL (0) 0x488
+ 8: SECTION LOCAL (0) 0x4a0
+ 9: SECTION LOCAL (0) 0x4c0
+ 10: SECTION LOCAL (0) 0x820
+ 11: SECTION LOCAL (0) 0x850
+ 12: SECTION LOCAL (0) 0x8a0
+ 13: SECTION LOCAL (0) 0xd30
+ 14: SECTION LOCAL (0) 0xd4c
+ 15: SECTION LOCAL (0) 0xd50
+ 16: SECTION LOCAL (0) 0xd70
+ 17: SECTION LOCAL (0) 0x1fde0
+ 18: SECTION LOCAL (0) 0x1fde8
+ 19: SECTION LOCAL (0) 0x1fdf0
+ 20: SECTION LOCAL (0) 0x1fdf8
+ 21: SECTION LOCAL (0) 0x1fe20
+ 22: SECTION LOCAL (0) 0x20000
+ 23: SECTION LOCAL (0) 0x20010
+ 24: SECTION LOCAL (0) 0x200d8
+ 25: SECTION LOCAL (0) 0x20110
+ 26: SECTION LOCAL (0) 0x20158
+ 27: SECTION LOCAL (0) 0
+ 28: SECTION LOCAL (0) 0
+ 29: SECTION LOCAL (0) 0
+ 30: SECTION LOCAL (0) 0
+ 31: SECTION LOCAL (0) 0
+ 32: SECTION LOCAL (0) 0
+ 33: SECTION LOCAL (0) 0
+ 34: FILE LOCAL crtstuff.c (0) 0
+ 35: OBJECT LOCAL __JCR_LIST__ (0) 0x1fdf0
+ 36: FUNC LOCAL deregister_tm_clones (0) 0x20040, rel: 0x20040 (.opd) [0x910, rel: 0x70 (.text)]
+ 37: FUNC LOCAL register_tm_clones (0) 0x20050, rel: 0x20050 (.opd) [0x980, rel: 0xe0 (.text)]
+ 38: FUNC LOCAL __do_global_dtors_aux (0) 0x20060, rel: 0x20060 (.opd) [0x9f0, rel: 0x150 (.text)]
+ 39: OBJECT LOCAL completed.7711 (1) 0x20158
+ 40: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x1fde8
+ 41: FUNC LOCAL frame_dummy (0) 0x20070, rel: 0x20070 (.opd) [0xa50, rel: 0x1b0 (.text)]
+ 42: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x1fde0
+ 43: FILE LOCAL foo.c (0) 0
+ 44: FILE LOCAL bar.c (0) 0
+ 45: OBJECT LOCAL b1 (4) 0x20004
+ 46: FUNC LOCAL foo (76) 0x20090, rel: 0x20090 (.opd) [0xb34, rel: 0x294 (.text)]
+ 47: FILE LOCAL crtstuff.c (0) 0
+ 48: OBJECT LOCAL __FRAME_END__ (0) 0xe18
+ 49: OBJECT LOCAL __JCR_END__ (0) 0x1fdf0
+ 50: FILE LOCAL (0) 0
+ 51: NOTYPE LOCAL __glink_PLTresolve (0) 0xce8
+ 52: NOTYPE LOCAL 00000011.plt_call.__libc_start_main@@GLIBC_2.3 (0) 0x8a0
+ 53: NOTYPE LOCAL 00000011.plt_call.__cxa_finalize@@GLIBC_2.3 (0) 0x8b4
+ 54: NOTYPE LOCAL __init_array_end (0) 0x1fde8
+ 55: OBJECT LOCAL _DYNAMIC (0) 0x1fe20
+ 56: NOTYPE LOCAL __init_array_start (0) 0x1fde0
+ 57: FUNC GLOBAL __libc_csu_fini (16) 0x200c0, rel: 0x200c0 (.opd) [0xcd0, rel: 0x430 (.text)]
+ 58: FUNC GLOBAL __libc_start_main@@GLIBC_2.3 (0) 0
+ 59: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 60: NOTYPE WEAK data_start (0) 0x20000
+ 61: NOTYPE GLOBAL _edata (0) 0x20110
+ 62: FUNC GLOBAL bar (116) 0x200a0, rel: 0x200a0 (.opd) [0xb80, rel: 0x2e0 (.text)]
+ 63: FUNC GLOBAL _fini (0) 0x20030, rel: 0x20030 (.opd) [0xd30, rel: 0 (.fini)]
+ 64: NOTYPE GLOBAL __data_start (0) 0x20000
+ 65: NOTYPE WEAK __gmon_start__ (0) 0
+ 66: OBJECT GLOBAL __dso_handle (0) 0x1fe18
+ 67: OBJECT GLOBAL _IO_stdin_used (4) 0xd4c
+ 68: OBJECT GLOBAL b2 (4) 0x20008
+ 69: FUNC WEAK __cxa_finalize@@GLIBC_2.3 (0) 0
+ 70: FUNC GLOBAL __libc_csu_init (204) 0x200b0, rel: 0x200b0 (.opd) [0xc00, rel: 0x360 (.text)]
+ 71: NOTYPE GLOBAL _end (0) 0x20160
+ 72: FUNC GLOBAL _start (60) 0x20010, rel: 0x20010 (.opd) [0x8c8, rel: 0x28 (.text)]
+ 73: NOTYPE GLOBAL __bss_start (0) 0x20110
+ 74: FUNC GLOBAL main (128) 0x20080, rel: 0x20080 (.opd) [0xab4, rel: 0x214 (.text)]
+ 75: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 76: OBJECT GLOBAL __TMC_END__ (0) 0x20010
+ 77: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 78: FUNC GLOBAL _init (0) 0x20020, rel: 0x20020 (.opd) [0x850, rel: 0 (.init)]
+EOF
+
+cat > testfile.symtab_pl.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x8001000238
+ 2: SECTION LOCAL (0) 0x800100024c
+ 3: SECTION LOCAL (0) 0x800100026c
+ 4: SECTION LOCAL (0) 0x8001000290
+ 5: SECTION LOCAL (0) 0x80010002c0
+ 6: SECTION LOCAL (0) 0x80010003e0
+ 7: SECTION LOCAL (0) 0x8001000488
+ 8: SECTION LOCAL (0) 0x80010004a0
+ 9: SECTION LOCAL (0) 0x80010004c0
+ 10: SECTION LOCAL (0) 0x8001000820
+ 11: SECTION LOCAL (0) 0x8001000850
+ 12: SECTION LOCAL (0) 0x80010008a0
+ 13: SECTION LOCAL (0) 0x8001000d30
+ 14: SECTION LOCAL (0) 0x8001000d4c
+ 15: SECTION LOCAL (0) 0x8001000d50
+ 16: SECTION LOCAL (0) 0x8001000d70
+ 17: SECTION LOCAL (0) 0x800101fde0
+ 18: SECTION LOCAL (0) 0x800101fde8
+ 19: SECTION LOCAL (0) 0x800101fdf0
+ 20: SECTION LOCAL (0) 0x800101fdf8
+ 21: SECTION LOCAL (0) 0x800101fe20
+ 22: SECTION LOCAL (0) 0x8001020000
+ 23: SECTION LOCAL (0) 0x8001020010
+ 24: SECTION LOCAL (0) 0x80010200d8
+ 25: SECTION LOCAL (0) 0x8001020110
+ 26: SECTION LOCAL (0) 0x8001020158
+ 27: SECTION LOCAL (0) 0
+ 28: SECTION LOCAL (0) 0
+ 29: SECTION LOCAL (0) 0
+ 30: SECTION LOCAL (0) 0
+ 31: SECTION LOCAL (0) 0
+ 32: SECTION LOCAL (0) 0
+ 33: SECTION LOCAL (0) 0
+ 34: FILE LOCAL crtstuff.c (0) 0
+ 35: OBJECT LOCAL __JCR_LIST__ (0) 0x800101fdf0
+ 36: FUNC LOCAL deregister_tm_clones (0) 0x8001020040, rel: 0x20040 (.opd) [0x8001000910, rel: 0x70 (.text)]
+ 37: FUNC LOCAL register_tm_clones (0) 0x8001020050, rel: 0x20050 (.opd) [0x8001000980, rel: 0xe0 (.text)]
+ 38: FUNC LOCAL __do_global_dtors_aux (0) 0x8001020060, rel: 0x20060 (.opd) [0x80010009f0, rel: 0x150 (.text)]
+ 39: OBJECT LOCAL completed.7711 (1) 0x8001020158
+ 40: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x800101fde8
+ 41: FUNC LOCAL frame_dummy (0) 0x8001020070, rel: 0x20070 (.opd) [0x8001000a50, rel: 0x1b0 (.text)]
+ 42: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x800101fde0
+ 43: FILE LOCAL foo.c (0) 0
+ 44: FILE LOCAL bar.c (0) 0
+ 45: OBJECT LOCAL b1 (4) 0x8001020004
+ 46: FUNC LOCAL foo (76) 0x8001020090, rel: 0x20090 (.opd) [0x8001000b34, rel: 0x294 (.text)]
+ 47: FILE LOCAL crtstuff.c (0) 0
+ 48: OBJECT LOCAL __FRAME_END__ (0) 0x8001000e18
+ 49: OBJECT LOCAL __JCR_END__ (0) 0x800101fdf0
+ 50: FILE LOCAL (0) 0
+ 51: NOTYPE LOCAL __glink_PLTresolve (0) 0x8001000ce8
+ 52: NOTYPE LOCAL 00000011.plt_call.__libc_start_main@@GLIBC_2.3 (0) 0x80010008a0
+ 53: NOTYPE LOCAL 00000011.plt_call.__cxa_finalize@@GLIBC_2.3 (0) 0x80010008b4
+ 54: NOTYPE LOCAL __init_array_end (0) 0x800101fde8
+ 55: OBJECT LOCAL _DYNAMIC (0) 0x800101fe20
+ 56: NOTYPE LOCAL __init_array_start (0) 0x800101fde0
+ 57: FUNC GLOBAL __libc_csu_fini (16) 0x80010200c0, rel: 0x200c0 (.opd) [0x8001000cd0, rel: 0x430 (.text)]
+ 58: FUNC GLOBAL __libc_start_main@@GLIBC_2.3 (0) 0
+ 59: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 60: NOTYPE WEAK data_start (0) 0x8001020000
+ 61: NOTYPE GLOBAL _edata (0) 0x8001020110
+ 62: FUNC GLOBAL bar (116) 0x80010200a0, rel: 0x200a0 (.opd) [0x8001000b80, rel: 0x2e0 (.text)]
+ 63: FUNC GLOBAL _fini (0) 0x8001020030, rel: 0x20030 (.opd) [0x8001000d30, rel: 0 (.fini)]
+ 64: NOTYPE GLOBAL __data_start (0) 0x8001020000
+ 65: NOTYPE WEAK __gmon_start__ (0) 0
+ 66: OBJECT GLOBAL __dso_handle (0) 0x800101fe18
+ 67: OBJECT GLOBAL _IO_stdin_used (4) 0x8001000d4c
+ 68: OBJECT GLOBAL b2 (4) 0x8001020008
+ 69: FUNC WEAK __cxa_finalize@@GLIBC_2.3 (0) 0
+ 70: FUNC GLOBAL __libc_csu_init (204) 0x80010200b0, rel: 0x200b0 (.opd) [0x8001000c00, rel: 0x360 (.text)]
+ 71: NOTYPE GLOBAL _end (0) 0x8001020160
+ 72: FUNC GLOBAL _start (60) 0x8001020010, rel: 0x20010 (.opd) [0x80010008c8, rel: 0x28 (.text)]
+ 73: NOTYPE GLOBAL __bss_start (0) 0x8001020110
+ 74: FUNC GLOBAL main (128) 0x8001020080, rel: 0x20080 (.opd) [0x8001000ab4, rel: 0x214 (.text)]
+ 75: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 76: OBJECT GLOBAL __TMC_END__ (0) 0x8001020010
+ 77: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 78: FUNC GLOBAL _init (0) 0x8001020020, rel: 0x20020 (.opd) [0x8001000850, rel: 0 (.init)]
+EOF
+
+cat > testfile.dynsym.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: SECTION LOCAL (0) 0x1fdf0
+ 3: FUNC GLOBAL __libc_start_main (0) 0
+ 4: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 5: NOTYPE WEAK __gmon_start__ (0) 0
+ 6: FUNC WEAK __cxa_finalize (0) 0
+ 7: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 8: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 9: NOTYPE GLOBAL _edata (0) 0x20110
+ 10: NOTYPE GLOBAL _end (0) 0x20160
+ 11: NOTYPE GLOBAL __bss_start (0) 0x20110
+EOF
+
+cat > testfile.minsym.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: SECTION LOCAL (0) 0x1fdf0
+ 3: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x1fde8
+ 4: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x1fde0
+ 5: NOTYPE LOCAL __glink_PLTresolve (0) 0xce8
+ 6: NOTYPE LOCAL 00000011.plt_call.__libc_start_main@@GLIBC_2.3 (0) 0x8a0
+ 7: NOTYPE LOCAL 00000011.plt_call.__cxa_finalize@@GLIBC_2.3 (0) 0x8b4
+ 8: NOTYPE LOCAL __init_array_end (0) 0x1fde8
+ 9: NOTYPE LOCAL __init_array_start (0) 0x1fde0
+ 10: SECTION LOCAL (0) 0x238
+ 11: SECTION LOCAL (0) 0x24c
+ 12: SECTION LOCAL (0) 0x26c
+ 13: SECTION LOCAL (0) 0x290
+ 14: SECTION LOCAL (0) 0x2c0
+ 15: SECTION LOCAL (0) 0x3e0
+ 16: SECTION LOCAL (0) 0x488
+ 17: SECTION LOCAL (0) 0x4a0
+ 18: SECTION LOCAL (0) 0x4c0
+ 19: SECTION LOCAL (0) 0x820
+ 20: SECTION LOCAL (0) 0x850
+ 21: SECTION LOCAL (0) 0x8a0
+ 22: SECTION LOCAL (0) 0xd30
+ 23: SECTION LOCAL (0) 0xd4c
+ 24: SECTION LOCAL (0) 0xd50
+ 25: SECTION LOCAL (0) 0xd70
+ 26: SECTION LOCAL (0) 0x1fde0
+ 27: SECTION LOCAL (0) 0x1fde8
+ 28: SECTION LOCAL (0) 0x1fdf0
+ 29: SECTION LOCAL (0) 0x1fdf8
+ 30: SECTION LOCAL (0) 0x1fe20
+ 31: SECTION LOCAL (0) 0x20000
+ 32: SECTION LOCAL (0) 0x20010
+ 33: SECTION LOCAL (0) 0x200d8
+ 34: SECTION LOCAL (0) 0x20110
+ 35: SECTION LOCAL (0) 0x20158
+ 36: FUNC GLOBAL __libc_start_main (0) 0
+ 37: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 38: NOTYPE WEAK __gmon_start__ (0) 0
+ 39: FUNC WEAK __cxa_finalize (0) 0
+ 40: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 41: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 42: NOTYPE GLOBAL _edata (0) 0x20110
+ 43: NOTYPE GLOBAL _end (0) 0x20160
+ 44: NOTYPE GLOBAL __bss_start (0) 0x20110
+EOF
+
+cat > testfile.minsym_pl.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x8001000238
+ 2: SECTION LOCAL (0) 0x800101fdf0
+ 3: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x800101fde8
+ 4: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x800101fde0
+ 5: NOTYPE LOCAL __glink_PLTresolve (0) 0x8001000ce8
+ 6: NOTYPE LOCAL 00000011.plt_call.__libc_start_main@@GLIBC_2.3 (0) 0x80010008a0
+ 7: NOTYPE LOCAL 00000011.plt_call.__cxa_finalize@@GLIBC_2.3 (0) 0x80010008b4
+ 8: NOTYPE LOCAL __init_array_end (0) 0x800101fde8
+ 9: NOTYPE LOCAL __init_array_start (0) 0x800101fde0
+ 10: SECTION LOCAL (0) 0x8001000238
+ 11: SECTION LOCAL (0) 0x800100024c
+ 12: SECTION LOCAL (0) 0x800100026c
+ 13: SECTION LOCAL (0) 0x8001000290
+ 14: SECTION LOCAL (0) 0x80010002c0
+ 15: SECTION LOCAL (0) 0x80010003e0
+ 16: SECTION LOCAL (0) 0x8001000488
+ 17: SECTION LOCAL (0) 0x80010004a0
+ 18: SECTION LOCAL (0) 0x80010004c0
+ 19: SECTION LOCAL (0) 0x8001000820
+ 20: SECTION LOCAL (0) 0x8001000850
+ 21: SECTION LOCAL (0) 0x80010008a0
+ 22: SECTION LOCAL (0) 0x8001000d30
+ 23: SECTION LOCAL (0) 0x8001000d4c
+ 24: SECTION LOCAL (0) 0x8001000d50
+ 25: SECTION LOCAL (0) 0x8001000d70
+ 26: SECTION LOCAL (0) 0x800101fde0
+ 27: SECTION LOCAL (0) 0x800101fde8
+ 28: SECTION LOCAL (0) 0x800101fdf0
+ 29: SECTION LOCAL (0) 0x800101fdf8
+ 30: SECTION LOCAL (0) 0x800101fe20
+ 31: SECTION LOCAL (0) 0x8001020000
+ 32: SECTION LOCAL (0) 0x8001020010
+ 33: SECTION LOCAL (0) 0x80010200d8
+ 34: SECTION LOCAL (0) 0x8001020110
+ 35: SECTION LOCAL (0) 0x8001020158
+ 36: FUNC GLOBAL __libc_start_main (0) 0
+ 37: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 38: NOTYPE WEAK __gmon_start__ (0) 0
+ 39: FUNC WEAK __cxa_finalize (0) 0
+ 40: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 41: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 42: NOTYPE GLOBAL _edata (0) 0x8001020110
+ 43: NOTYPE GLOBAL _end (0) 0x8001020160
+ 44: NOTYPE GLOBAL __bss_start (0) 0x8001020110
+EOF
+
+cat testfile.symtab.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebaztabppc64
+
+cat testfile.symtab.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdbgppc64
+
+cat testfile.symtab_pl.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdbgppc64_pl
+
+sed s/0x8001/0x4200/g testfile.symtab_pl.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdbgppc64_plr
+
+cat testfile.dynsym.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdynppc64
+
+cat testfile.symtab.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazmdbppc64
+
+cat testfile.minsym.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazminppc64
+
+cat testfile.minsym_pl.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazminppc64_pl
+
+sed s/0x8001/0x4200/g testfile.minsym_pl.in \
+ | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazminppc64_plr
+
+exit 0
diff --git a/tests/run-early-offscn.sh b/tests/run-early-offscn.sh
new file mode 100755
index 0000000..3757bcf
--- /dev/null
+++ b/tests/run-early-offscn.sh
@@ -0,0 +1,24 @@
+#! /bin/sh
+# Copyright (C) 2008 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
+
+testfiles testfile
+
+testrun ${abs_builddir}/early-offscn testfile 0x500
+
+exit 0
diff --git a/tests/run-ecp-test.sh b/tests/run-ecp-test.sh
new file mode 100755
index 0000000..d5e376a
--- /dev/null
+++ b/tests/run-ecp-test.sh
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Copyright (C) 2002, 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Jakub Jelinek <jakub@redhat.com>, 2002.
+#
+# 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
+
+testfiles testfile10
+tempfiles testfile10.tmp
+
+testrun ${abs_builddir}/ecp testfile10 testfile10.tmp
+
+cmp testfile10 testfile10.tmp
+
+exit 0
diff --git a/tests/run-ecp-test2.sh b/tests/run-ecp-test2.sh
new file mode 100755
index 0000000..864e0a5
--- /dev/null
+++ b/tests/run-ecp-test2.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+# Copyright (C) 2002, 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Jakub Jelinek <jakub@redhat.com>, 2002.
+#
+# 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
+
+testfiles testfile2
+tempfiles testfile2.tmp
+
+testrun ${abs_builddir}/ecp testfile2 testfile2.tmp
+
+exit 0
diff --git a/tests/run-elf_cntl_gelf_getshdr.sh b/tests/run-elf_cntl_gelf_getshdr.sh
new file mode 100755
index 0000000..94b477c
--- /dev/null
+++ b/tests/run-elf_cntl_gelf_getshdr.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+
+tempfiles test_shdr.out
+
+# However we open the elf file, the shdrs should be the same.
+testrun ${abs_builddir}/test-elf_cntl_gelf_getshdr READ ${abs_builddir}/test-elf_cntl_gelf_getshdr \
+ > test_shdr.out
+
+testrun_compare ${abs_builddir}/test-elf_cntl_gelf_getshdr MMAP ${abs_builddir}/test-elf_cntl_gelf_getshdr \
+ < test_shdr.out
+
+testrun_compare ${abs_builddir}/test-elf_cntl_gelf_getshdr FDREAD ${abs_builddir}/test-elf_cntl_gelf_getshdr \
+ < test_shdr.out
diff --git a/tests/run-elfgetchdr.sh b/tests/run-elfgetchdr.sh
new file mode 100755
index 0000000..7a422f3
--- /dev/null
+++ b/tests/run-elfgetchdr.sh
@@ -0,0 +1,188 @@
+#! /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 zgnu64 funcs.o start.o
+
+# gas --compress-debug-sections=zlib-gabi -32 -g -o start.o start.s
+# gas --compress-debug-sections=zlib-gabi -32 -g -o funcs.o funcs.s
+# ld --compress-debug-sections=zlib-gabi -melf_i386 -g -o zgabi32 funcs.o start.o
+
+# gas --compress-debug-sections=zlib-gabi -64 -g -o start.o start.s
+# gas --compress-debug-sections=zlib-gabi -64 -g -o funcs.o funcs.s
+# ld --compress-debug-sections=zlib-gabi -g -o zgabi64 funcs.o start.o
+
+testfiles testfile-zgnu64
+testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgnu64 <<\EOF
+section 1: NOT Compressed
+section 2: GNU Compressed size: 60
+section 3: GNU Compressed size: aa
+section 4: NOT Compressed
+section 5: GNU Compressed size: 8d
+section 6: NOT Compressed
+section 7: NOT Compressed
+section 8: NOT Compressed
+EOF
+
+testfiles testfile-zgabi64
+testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgabi64 <<\EOF
+section 1: NOT Compressed
+section 2: ELF Compressed ch_type: 1, ch_size: 60, ch_addralign: 10
+section 3: ELF Compressed ch_type: 1, ch_size: aa, ch_addralign: 1
+section 4: NOT Compressed
+section 5: ELF Compressed ch_type: 1, ch_size: 8d, ch_addralign: 1
+section 6: NOT Compressed
+section 7: NOT Compressed
+section 8: NOT Compressed
+EOF
+
+testfiles testfile-zgnu32
+testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgnu32 <<\EOF
+section 1: NOT Compressed
+section 2: GNU Compressed size: 40
+section 3: GNU Compressed size: 9a
+section 4: NOT Compressed
+section 5: GNU Compressed size: 85
+section 6: NOT Compressed
+section 7: NOT Compressed
+section 8: NOT Compressed
+EOF
+
+testfiles testfile-zgabi32
+testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgabi32 <<\EOF
+section 1: NOT Compressed
+section 2: ELF Compressed ch_type: 1, ch_size: 40, ch_addralign: 8
+section 3: ELF Compressed ch_type: 1, ch_size: 9a, ch_addralign: 1
+section 4: NOT Compressed
+section 5: ELF Compressed ch_type: 1, ch_size: 85, ch_addralign: 1
+section 6: NOT Compressed
+section 7: NOT Compressed
+section 8: NOT Compressed
+EOF
+
+testfiles testfile-zgnu64be
+testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgnu64be <<\EOF
+section 1: NOT Compressed
+section 2: NOT Compressed
+section 3: GNU Compressed size: 60
+section 4: GNU Compressed size: 7e
+section 5: NOT Compressed
+section 6: GNU Compressed size: 8d
+section 7: NOT Compressed
+section 8: NOT Compressed
+section 9: NOT Compressed
+EOF
+
+testfiles testfile-zgabi64be
+testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgabi64be <<\EOF
+section 1: NOT Compressed
+section 2: NOT Compressed
+section 3: ELF Compressed ch_type: 1, ch_size: 60, ch_addralign: 10
+section 4: ELF Compressed ch_type: 1, ch_size: 7e, ch_addralign: 1
+section 5: NOT Compressed
+section 6: ELF Compressed ch_type: 1, ch_size: 8d, ch_addralign: 1
+section 7: NOT Compressed
+section 8: NOT Compressed
+section 9: NOT Compressed
+EOF
+
+testfiles testfile-zgnu32be
+testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgnu32be <<\EOF
+section 1: NOT Compressed
+section 2: NOT Compressed
+section 3: GNU Compressed size: 40
+section 4: GNU Compressed size: 6e
+section 5: NOT Compressed
+section 6: GNU Compressed size: 85
+section 7: NOT Compressed
+section 8: NOT Compressed
+section 9: NOT Compressed
+EOF
+
+testfiles testfile-zgabi32be
+testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgabi32be <<\EOF
+section 1: NOT Compressed
+section 2: NOT Compressed
+section 3: ELF Compressed ch_type: 1, ch_size: 40, ch_addralign: 8
+section 4: ELF Compressed ch_type: 1, ch_size: 6e, ch_addralign: 1
+section 5: NOT Compressed
+section 6: ELF Compressed ch_type: 1, ch_size: 85, ch_addralign: 1
+section 7: NOT Compressed
+section 8: NOT Compressed
+section 9: NOT Compressed
+EOF
+
+exit 0
diff --git a/tests/run-elfgetzdata.sh b/tests/run-elfgetzdata.sh
new file mode 100755
index 0000000..e2df308
--- /dev/null
+++ b/tests/run-elfgetzdata.sh
@@ -0,0 +1,214 @@
+#! /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}/tests/elfgetzdata read testfile-zgnu64 <<\EOF
+1: .text, NOT compressed
+2: .zdebug_aranges, GNU compressed, size: 60
+3: .zdebug_info, GNU compressed, size: aa
+4: .debug_abbrev, NOT compressed
+5: .zdebug_line, GNU compressed, size: 8d
+6: .shstrtab, NOT compressed
+7: .symtab, NOT compressed
+8: .strtab, NOT compressed
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata mmap testfile-zgnu64 <<\EOF
+1: .text, NOT compressed
+2: .zdebug_aranges, GNU compressed, size: 60
+3: .zdebug_info, GNU compressed, size: aa
+4: .debug_abbrev, NOT compressed
+5: .zdebug_line, GNU compressed, size: 8d
+6: .shstrtab, NOT compressed
+7: .symtab, NOT compressed
+8: .strtab, NOT compressed
+EOF
+
+testfiles testfile-zgnu64be
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata read testfile-zgnu64be <<\EOF
+1: .text, NOT compressed
+2: .eh_frame, NOT compressed
+3: .zdebug_aranges, GNU compressed, size: 60
+4: .zdebug_info, GNU compressed, size: 7e
+5: .debug_abbrev, NOT compressed
+6: .zdebug_line, GNU compressed, size: 8d
+7: .shstrtab, NOT compressed
+8: .symtab, NOT compressed
+9: .strtab, NOT compressed
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata mmap testfile-zgnu64be <<\EOF
+1: .text, NOT compressed
+2: .eh_frame, NOT compressed
+3: .zdebug_aranges, GNU compressed, size: 60
+4: .zdebug_info, GNU compressed, size: 7e
+5: .debug_abbrev, NOT compressed
+6: .zdebug_line, GNU compressed, size: 8d
+7: .shstrtab, NOT compressed
+8: .symtab, NOT compressed
+9: .strtab, NOT compressed
+EOF
+
+testfiles testfile-zgabi64
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata read testfile-zgabi64 <<\EOF
+1: .text, NOT compressed
+2: .debug_aranges, ELF compressed, size: 60
+3: .debug_info, ELF compressed, size: aa
+4: .debug_abbrev, NOT compressed
+5: .debug_line, ELF compressed, size: 8d
+6: .shstrtab, NOT compressed
+7: .symtab, NOT compressed
+8: .strtab, NOT compressed
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata mmap testfile-zgabi64 <<\EOF
+1: .text, NOT compressed
+2: .debug_aranges, ELF compressed, size: 60
+3: .debug_info, ELF compressed, size: aa
+4: .debug_abbrev, NOT compressed
+5: .debug_line, ELF compressed, size: 8d
+6: .shstrtab, NOT compressed
+7: .symtab, NOT compressed
+8: .strtab, NOT compressed
+EOF
+
+testfiles testfile-zgabi64be
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata read testfile-zgabi64be <<\EOF
+1: .text, NOT compressed
+2: .eh_frame, NOT compressed
+3: .debug_aranges, ELF compressed, size: 60
+4: .debug_info, ELF compressed, size: 7e
+5: .debug_abbrev, NOT compressed
+6: .debug_line, ELF compressed, size: 8d
+7: .shstrtab, NOT compressed
+8: .symtab, NOT compressed
+9: .strtab, NOT compressed
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata mmap testfile-zgabi64be <<\EOF
+1: .text, NOT compressed
+2: .eh_frame, NOT compressed
+3: .debug_aranges, ELF compressed, size: 60
+4: .debug_info, ELF compressed, size: 7e
+5: .debug_abbrev, NOT compressed
+6: .debug_line, ELF compressed, size: 8d
+7: .shstrtab, NOT compressed
+8: .symtab, NOT compressed
+9: .strtab, NOT compressed
+EOF
+
+testfiles testfile-zgnu32
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata read testfile-zgnu32 <<\EOF
+1: .text, NOT compressed
+2: .zdebug_aranges, GNU compressed, size: 40
+3: .zdebug_info, GNU compressed, size: 9a
+4: .debug_abbrev, NOT compressed
+5: .zdebug_line, GNU compressed, size: 85
+6: .shstrtab, NOT compressed
+7: .symtab, NOT compressed
+8: .strtab, NOT compressed
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata mmap testfile-zgnu32 <<\EOF
+1: .text, NOT compressed
+2: .zdebug_aranges, GNU compressed, size: 40
+3: .zdebug_info, GNU compressed, size: 9a
+4: .debug_abbrev, NOT compressed
+5: .zdebug_line, GNU compressed, size: 85
+6: .shstrtab, NOT compressed
+7: .symtab, NOT compressed
+8: .strtab, NOT compressed
+EOF
+
+testfiles testfile-zgnu32be
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata read testfile-zgnu32be <<\EOF
+1: .text, NOT compressed
+2: .eh_frame, NOT compressed
+3: .zdebug_aranges, GNU compressed, size: 40
+4: .zdebug_info, GNU compressed, size: 6e
+5: .debug_abbrev, NOT compressed
+6: .zdebug_line, GNU compressed, size: 85
+7: .shstrtab, NOT compressed
+8: .symtab, NOT compressed
+9: .strtab, NOT compressed
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata mmap testfile-zgnu32be <<\EOF
+1: .text, NOT compressed
+2: .eh_frame, NOT compressed
+3: .zdebug_aranges, GNU compressed, size: 40
+4: .zdebug_info, GNU compressed, size: 6e
+5: .debug_abbrev, NOT compressed
+6: .zdebug_line, GNU compressed, size: 85
+7: .shstrtab, NOT compressed
+8: .symtab, NOT compressed
+9: .strtab, NOT compressed
+EOF
+
+testfiles testfile-zgabi32
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata read testfile-zgabi32 <<\EOF
+1: .text, NOT compressed
+2: .debug_aranges, ELF compressed, size: 40
+3: .debug_info, ELF compressed, size: 9a
+4: .debug_abbrev, NOT compressed
+5: .debug_line, ELF compressed, size: 85
+6: .shstrtab, NOT compressed
+7: .symtab, NOT compressed
+8: .strtab, NOT compressed
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata mmap testfile-zgabi32 <<\EOF
+1: .text, NOT compressed
+2: .debug_aranges, ELF compressed, size: 40
+3: .debug_info, ELF compressed, size: 9a
+4: .debug_abbrev, NOT compressed
+5: .debug_line, ELF compressed, size: 85
+6: .shstrtab, NOT compressed
+7: .symtab, NOT compressed
+8: .strtab, NOT compressed
+EOF
+
+testfiles testfile-zgabi32be
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata read testfile-zgabi32be <<\EOF
+1: .text, NOT compressed
+2: .eh_frame, NOT compressed
+3: .debug_aranges, ELF compressed, size: 40
+4: .debug_info, ELF compressed, size: 6e
+5: .debug_abbrev, NOT compressed
+6: .debug_line, ELF compressed, size: 85
+7: .shstrtab, NOT compressed
+8: .symtab, NOT compressed
+9: .strtab, NOT compressed
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfgetzdata mmap testfile-zgabi32be <<\EOF
+1: .text, NOT compressed
+2: .eh_frame, NOT compressed
+3: .debug_aranges, ELF compressed, size: 40
+4: .debug_info, ELF compressed, size: 6e
+5: .debug_abbrev, NOT compressed
+6: .debug_line, ELF compressed, size: 85
+7: .shstrtab, NOT compressed
+8: .symtab, NOT compressed
+9: .strtab, NOT compressed
+EOF
+
+exit 0
diff --git a/tests/run-elflint-self.sh b/tests/run-elflint-self.sh
new file mode 100755
index 0000000..58fa7d0
--- /dev/null
+++ b/tests/run-elflint-self.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# Copyright (C) 2005, 2007, 2017 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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
+
+testrun_on_self ${abs_top_builddir}/src/elflint --quiet --gnu-ld
+testrun_on_self_compressed ${abs_top_builddir}/src/elflint --quiet --gnu-ld
diff --git a/tests/run-elflint-test.sh b/tests/run-elflint-test.sh
new file mode 100755
index 0000000..caf172a
--- /dev/null
+++ b/tests/run-elflint-test.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2005, 2007, 2008, 2015 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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
+
+testfiles testfile18
+
+testrun_compare ${abs_top_builddir}/src/elflint --gnu-ld testfile18 <<\EOF
+section [ 8] '.rela.dyn': relocation 1: copy relocation against symbol of type FUNC
+EOF
+
+testfiles testfile32
+testrun ${abs_top_builddir}/src/elflint -q testfile32
+
+testfiles testfile33
+testrun ${abs_top_builddir}/src/elflint -q testfile33
+
+testfiles testfile42
+testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile42
+
+# Contains debuginfo, compress it, recheck
+tempfiles testfile42z
+testrun ${abs_top_builddir}/src/elfcompress -f -q -o testfile42z testfile42
+testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile42z
+
+testfiles testfile46
+testrun ${abs_top_builddir}/src/elflint -q testfile46
+
+# see also run-readelf-d.sh
+testfiles testlib_dynseg.so
+testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testlib_dynseg.so
+
+# s390x has SHT_HASH with sh_entsize 8 (really should be 4, but see common.h)
+# This was wrongly checked when comparing .gnu.hash and .hash.
+# Simple "int main (int argc, char **argv) { return 0; }"
+# gcc -Xlinker --hash-style=both -o testfile-s390x-hash-both s390x-hash-both.c
+testfiles testfile-s390x-hash-both
+testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile-s390x-hash-both
+
+# Compress the symtab/strtab just because and recheck
+tempfiles testfile-s390x-hash-bothz
+testrun ${abs_top_builddir}/src/elfcompress -f -q --name='.s??tab' -o testfile-s390x-hash-bothz testfile-s390x-hash-both
+testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile-s390x-hash-bothz
+
+exit 0
diff --git a/tests/run-elfputzdata.sh b/tests/run-elfputzdata.sh
new file mode 100755
index 0000000..b882b3f
--- /dev/null
+++ b/tests/run-elfputzdata.sh
@@ -0,0 +1,340 @@
+#! /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
+
+# Random ELF32 testfile
+testfiles testfile4
+
+testrun_compare ${abs_top_builddir}/tests/elfputzdata gnu testfile4 <<\EOF
+Cannot compress 1 .interp
+Cannot compress 2 .note.ABI-tag
+Cannot compress 3 .hash
+Cannot compress 4 .dynsym
+Cannot compress 5 .dynstr
+Cannot compress 6 .gnu.version
+Cannot compress 7 .gnu.version_r
+Cannot compress 8 .rel.got
+Cannot compress 9 .rel.plt
+Cannot compress 10 .init
+Cannot compress 11 .plt
+Cannot compress 12 .text
+Cannot compress 13 .fini
+Cannot compress 14 .rodata
+Cannot compress 15 .data
+Cannot compress 16 .eh_frame
+Cannot compress 17 .gcc_except_table
+Cannot compress 18 .ctors
+Cannot compress 19 .dtors
+Cannot compress 20 .got
+Cannot compress 21 .dynamic
+Lets compress 22 .sbss, size: 0
+Cannot compress 23 .bss
+Lets compress 24 .stab, size: 21540
+Lets compress 25 .stabstr, size: 57297
+Lets compress 26 .comment, size: 648
+Lets compress 27 .debug_aranges, size: 56
+Lets compress 28 .debug_pubnames, size: 93
+Lets compress 29 .debug_info, size: 960
+Lets compress 30 .debug_abbrev, size: 405
+Lets compress 31 .debug_line, size: 189
+Lets compress 32 .note, size: 240
+Lets compress 33 .shstrtab, size: 320
+Lets compress 34 .symtab, size: 5488
+Lets compress 35 .strtab, size: 5727
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfputzdata elf testfile4 <<\EOF
+Cannot compress 1 .interp
+Cannot compress 2 .note.ABI-tag
+Cannot compress 3 .hash
+Cannot compress 4 .dynsym
+Cannot compress 5 .dynstr
+Cannot compress 6 .gnu.version
+Cannot compress 7 .gnu.version_r
+Cannot compress 8 .rel.got
+Cannot compress 9 .rel.plt
+Cannot compress 10 .init
+Cannot compress 11 .plt
+Cannot compress 12 .text
+Cannot compress 13 .fini
+Cannot compress 14 .rodata
+Cannot compress 15 .data
+Cannot compress 16 .eh_frame
+Cannot compress 17 .gcc_except_table
+Cannot compress 18 .ctors
+Cannot compress 19 .dtors
+Cannot compress 20 .got
+Cannot compress 21 .dynamic
+Lets compress 22 .sbss, size: 0
+Cannot compress 23 .bss
+Lets compress 24 .stab, size: 21540
+Lets compress 25 .stabstr, size: 57297
+Lets compress 26 .comment, size: 648
+Lets compress 27 .debug_aranges, size: 56
+Lets compress 28 .debug_pubnames, size: 93
+Lets compress 29 .debug_info, size: 960
+Lets compress 30 .debug_abbrev, size: 405
+Lets compress 31 .debug_line, size: 189
+Lets compress 32 .note, size: 240
+Lets compress 33 .shstrtab, size: 320
+Lets compress 34 .symtab, size: 5488
+Lets compress 35 .strtab, size: 5727
+EOF
+
+# Random ELF64 testfile
+testfiles testfile12
+
+testrun_compare ${abs_top_builddir}/tests/elfputzdata gnu testfile12 <<\EOF
+Cannot compress 1 .hash
+Cannot compress 2 .dynsym
+Cannot compress 3 .dynstr
+Cannot compress 4 .gnu.version
+Cannot compress 5 .gnu.version_r
+Cannot compress 6 .rela.dyn
+Cannot compress 7 .rela.plt
+Cannot compress 8 .init
+Cannot compress 9 .plt
+Cannot compress 10 .text
+Cannot compress 11 .fini
+Cannot compress 12 .rodata
+Cannot compress 13 .eh_frame_hdr
+Cannot compress 14 .eh_frame
+Cannot compress 15 .data
+Cannot compress 16 .dynamic
+Cannot compress 17 .ctors
+Cannot compress 18 .dtors
+Cannot compress 19 .jcr
+Cannot compress 20 .got
+Cannot compress 21 .bss
+Lets compress 22 .comment, size: 246
+Lets compress 23 .debug_aranges, size: 192
+Lets compress 24 .debug_pubnames, size: 26
+Lets compress 25 .debug_info, size: 3468
+Lets compress 26 .debug_abbrev, size: 341
+Lets compress 27 .debug_line, size: 709
+Lets compress 28 .debug_frame, size: 56
+Lets compress 29 .debug_str, size: 2235
+Lets compress 30 .debug_macinfo, size: 10518
+Lets compress 31 .shstrtab, size: 308
+Lets compress 32 .symtab, size: 1944
+Lets compress 33 .strtab, size: 757
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfputzdata elf testfile12 <<\EOF
+Cannot compress 1 .hash
+Cannot compress 2 .dynsym
+Cannot compress 3 .dynstr
+Cannot compress 4 .gnu.version
+Cannot compress 5 .gnu.version_r
+Cannot compress 6 .rela.dyn
+Cannot compress 7 .rela.plt
+Cannot compress 8 .init
+Cannot compress 9 .plt
+Cannot compress 10 .text
+Cannot compress 11 .fini
+Cannot compress 12 .rodata
+Cannot compress 13 .eh_frame_hdr
+Cannot compress 14 .eh_frame
+Cannot compress 15 .data
+Cannot compress 16 .dynamic
+Cannot compress 17 .ctors
+Cannot compress 18 .dtors
+Cannot compress 19 .jcr
+Cannot compress 20 .got
+Cannot compress 21 .bss
+Lets compress 22 .comment, size: 246
+Lets compress 23 .debug_aranges, size: 192
+Lets compress 24 .debug_pubnames, size: 26
+Lets compress 25 .debug_info, size: 3468
+Lets compress 26 .debug_abbrev, size: 341
+Lets compress 27 .debug_line, size: 709
+Lets compress 28 .debug_frame, size: 56
+Lets compress 29 .debug_str, size: 2235
+Lets compress 30 .debug_macinfo, size: 10518
+Lets compress 31 .shstrtab, size: 308
+Lets compress 32 .symtab, size: 1944
+Lets compress 33 .strtab, size: 757
+EOF
+
+# Random ELF64BE testfile
+testfiles testfileppc64
+
+testrun_compare ${abs_top_builddir}/tests/elfputzdata gnu testfileppc64 <<\EOF
+Cannot compress 1 .interp
+Cannot compress 2 .note.ABI-tag
+Cannot compress 3 .note.gnu.build-id
+Cannot compress 4 .gnu.hash
+Cannot compress 5 .dynsym
+Cannot compress 6 .dynstr
+Cannot compress 7 .gnu.version
+Cannot compress 8 .gnu.version_r
+Cannot compress 9 .rela.plt
+Cannot compress 10 .init
+Cannot compress 11 .text
+Cannot compress 12 .fini
+Cannot compress 13 .rodata
+Cannot compress 14 .eh_frame_hdr
+Cannot compress 15 .eh_frame
+Cannot compress 16 .init_array
+Cannot compress 17 .fini_array
+Cannot compress 18 .jcr
+Cannot compress 19 .dynamic
+Cannot compress 20 .data
+Cannot compress 21 .opd
+Cannot compress 22 .got
+Cannot compress 23 .plt
+Cannot compress 24 .bss
+Lets compress 25 .comment, size: 88
+Lets compress 26 .debug_aranges, size: 96
+Lets compress 27 .debug_info, size: 363
+Lets compress 28 .debug_abbrev, size: 315
+Lets compress 29 .debug_line, size: 119
+Lets compress 30 .debug_frame, size: 96
+Lets compress 31 .debug_str, size: 174
+Lets compress 32 .debug_loc, size: 171
+Lets compress 33 .debug_ranges, size: 32
+Lets compress 34 .shstrtab, size: 352
+Lets compress 35 .symtab, size: 1800
+Lets compress 36 .strtab, size: 602
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfputzdata elf testfileppc64 <<\EOF
+Cannot compress 1 .interp
+Cannot compress 2 .note.ABI-tag
+Cannot compress 3 .note.gnu.build-id
+Cannot compress 4 .gnu.hash
+Cannot compress 5 .dynsym
+Cannot compress 6 .dynstr
+Cannot compress 7 .gnu.version
+Cannot compress 8 .gnu.version_r
+Cannot compress 9 .rela.plt
+Cannot compress 10 .init
+Cannot compress 11 .text
+Cannot compress 12 .fini
+Cannot compress 13 .rodata
+Cannot compress 14 .eh_frame_hdr
+Cannot compress 15 .eh_frame
+Cannot compress 16 .init_array
+Cannot compress 17 .fini_array
+Cannot compress 18 .jcr
+Cannot compress 19 .dynamic
+Cannot compress 20 .data
+Cannot compress 21 .opd
+Cannot compress 22 .got
+Cannot compress 23 .plt
+Cannot compress 24 .bss
+Lets compress 25 .comment, size: 88
+Lets compress 26 .debug_aranges, size: 96
+Lets compress 27 .debug_info, size: 363
+Lets compress 28 .debug_abbrev, size: 315
+Lets compress 29 .debug_line, size: 119
+Lets compress 30 .debug_frame, size: 96
+Lets compress 31 .debug_str, size: 174
+Lets compress 32 .debug_loc, size: 171
+Lets compress 33 .debug_ranges, size: 32
+Lets compress 34 .shstrtab, size: 352
+Lets compress 35 .symtab, size: 1800
+Lets compress 36 .strtab, size: 602
+EOF
+
+# Random ELF32BE testfile
+testfiles testfileppc32
+
+testrun_compare ${abs_top_builddir}/tests/elfputzdata gnu testfileppc32 <<\EOF
+Cannot compress 1 .interp
+Cannot compress 2 .note.ABI-tag
+Cannot compress 3 .note.gnu.build-id
+Cannot compress 4 .gnu.hash
+Cannot compress 5 .dynsym
+Cannot compress 6 .dynstr
+Cannot compress 7 .gnu.version
+Cannot compress 8 .gnu.version_r
+Cannot compress 9 .rela.dyn
+Cannot compress 10 .rela.plt
+Cannot compress 11 .init
+Cannot compress 12 .text
+Cannot compress 13 .fini
+Cannot compress 14 .rodata
+Cannot compress 15 .eh_frame_hdr
+Cannot compress 16 .eh_frame
+Cannot compress 17 .init_array
+Cannot compress 18 .fini_array
+Cannot compress 19 .jcr
+Cannot compress 20 .got2
+Cannot compress 21 .dynamic
+Cannot compress 22 .got
+Cannot compress 23 .plt
+Cannot compress 24 .data
+Cannot compress 25 .sdata
+Cannot compress 26 .bss
+Lets compress 27 .comment, size: 88
+Lets compress 28 .debug_aranges, size: 64
+Lets compress 29 .debug_info, size: 319
+Lets compress 30 .debug_abbrev, size: 318
+Lets compress 31 .debug_line, size: 109
+Lets compress 32 .debug_frame, size: 64
+Lets compress 33 .debug_str, size: 179
+Lets compress 34 .debug_loc, size: 99
+Lets compress 35 .debug_ranges, size: 16
+Lets compress 36 .shstrtab, size: 370
+Lets compress 37 .symtab, size: 1232
+Lets compress 38 .strtab, size: 569
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/elfputzdata elf testfileppc32 <<\EOF
+Cannot compress 1 .interp
+Cannot compress 2 .note.ABI-tag
+Cannot compress 3 .note.gnu.build-id
+Cannot compress 4 .gnu.hash
+Cannot compress 5 .dynsym
+Cannot compress 6 .dynstr
+Cannot compress 7 .gnu.version
+Cannot compress 8 .gnu.version_r
+Cannot compress 9 .rela.dyn
+Cannot compress 10 .rela.plt
+Cannot compress 11 .init
+Cannot compress 12 .text
+Cannot compress 13 .fini
+Cannot compress 14 .rodata
+Cannot compress 15 .eh_frame_hdr
+Cannot compress 16 .eh_frame
+Cannot compress 17 .init_array
+Cannot compress 18 .fini_array
+Cannot compress 19 .jcr
+Cannot compress 20 .got2
+Cannot compress 21 .dynamic
+Cannot compress 22 .got
+Cannot compress 23 .plt
+Cannot compress 24 .data
+Cannot compress 25 .sdata
+Cannot compress 26 .bss
+Lets compress 27 .comment, size: 88
+Lets compress 28 .debug_aranges, size: 64
+Lets compress 29 .debug_info, size: 319
+Lets compress 30 .debug_abbrev, size: 318
+Lets compress 31 .debug_line, size: 109
+Lets compress 32 .debug_frame, size: 64
+Lets compress 33 .debug_str, size: 179
+Lets compress 34 .debug_loc, size: 99
+Lets compress 35 .debug_ranges, size: 16
+Lets compress 36 .shstrtab, size: 370
+Lets compress 37 .symtab, size: 1232
+Lets compress 38 .strtab, size: 569
+EOF
+
+exit 0
diff --git a/tests/run-elfstrmerge-test.sh b/tests/run-elfstrmerge-test.sh
new file mode 100755
index 0000000..d08b6fc
--- /dev/null
+++ b/tests/run-elfstrmerge-test.sh
@@ -0,0 +1,40 @@
+#! /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
+
+# Merge string tables of file and check result with elflint.
+testrun_elfcompress()
+{
+ testfile="$1"
+ testfiles ${testfile}
+
+ mergedfile="${testfile}.merged"
+ tempfiles ${mergedfile}
+
+ echo "merging string tables ${testfile} -> ${mergedfile}"
+ testrun ${abs_top_builddir}/tests/elfstrmerge -o ${mergedfile} ${testfile}
+ testrun ${abs_top_builddir}/src/elflint --gnu-ld ${mergedfile}
+}
+
+# Random ELF32 testfile with extra STT_SECTION symbols
+testrun_elfcompress testfile4
+
+# Random ELF64 testfile with extra STT_SECTION symbols
+testrun_elfcompress testfile12
+
+exit 0
diff --git a/tests/run-exprlocs-self.sh b/tests/run-exprlocs-self.sh
new file mode 100755
index 0000000..73d3ab9
--- /dev/null
+++ b/tests/run-exprlocs-self.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# Copyright (C) 2017 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
+
+# Just makes sure exprlocs doesn't crash, triggers self-check/asserts
+# or leaks memory under valgrind.
+testrun_on_self_quiet ${abs_top_builddir}/tests/varlocs --exprlocs -e
diff --git a/tests/run-exprlocs.sh b/tests/run-exprlocs.sh
new file mode 100755
index 0000000..379ca52
--- /dev/null
+++ b/tests/run-exprlocs.sh
@@ -0,0 +1,180 @@
+#! /bin/sh
+# Copyright (C) 2017 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
+
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77589
+#
+# program repro
+# type small_stride
+# character*40 long_string
+# integer small_pad
+# end type small_stride
+# type(small_stride), dimension (20), target :: unpleasant
+# character*40, pointer, dimension(:):: c40pt
+# integer i
+# do i = 0,19
+# unpleasant(i+1)%small_pad = i+1
+# unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
+# end do
+# c40pt => unpleasant%long_string
+# print *, c40pt ! break-here
+# end program repro
+#
+# Needs GCC7+
+# gfortran -o testfile-stridex dwarf-stridex.f90 -Wall -g
+
+testfiles testfile-stridex
+
+testrun_compare ${abs_top_builddir}/tests/varlocs --exprlocs -e testfile-stridex <<\EOF
+module 'testfile-stridex'
+[b] CU 'dwarf-stridex.f90'@400717
+ producer (strp)
+ language (data1)
+ identifier_case (data1)
+ name (strp)
+ comp_dir (strp)
+ low_pc (addr)
+ high_pc (data8)
+ stmt_list (sec_offset)
+ [2e] base_type "integer(kind=8)"
+ byte_size (data1)
+ encoding (data1)
+ name (strp)
+ [35] structure_type "small_stride"
+ name (strp)
+ byte_size (data1)
+ decl_file (data1)
+ decl_line (data1)
+ sibling (ref4)
+ [41] member "long_string"
+ name (strp)
+ decl_file (data1)
+ decl_line (data1)
+ type (ref4)
+ data_member_location (data1) {plus_uconst(0)}
+ [4d] member "small_pad"
+ name (strp)
+ decl_file (data1)
+ decl_line (data1)
+ type (ref4)
+ data_member_location (data1) {plus_uconst(40)}
+ [5a] string_type
+ byte_size (data1)
+ [5c] base_type "integer(kind=4)"
+ byte_size (data1)
+ encoding (data1)
+ name (strp)
+ [63] const_type
+ type (ref4)
+ [68] subprogram "main"
+ external (flag_present)
+ name (strp)
+ decl_file (data1)
+ decl_line (data1)
+ type (ref4)
+ low_pc (addr)
+ high_pc (data8)
+ frame_base (exprloc) {call_frame_cfa {bregx(7,8)}}
+ GNU_all_tail_call_sites (flag_present)
+ sibling (ref4)
+ [89] formal_parameter "argc"
+ name (strp)
+ decl_file (data1)
+ decl_line (data1)
+ type (ref4)
+ location (exprloc) {fbreg(-20)}
+ [97] formal_parameter "argv"
+ name (strp)
+ decl_file (data1)
+ decl_line (data1)
+ type (ref4)
+ location (exprloc) {fbreg(-32), deref}
+ [a7] pointer_type
+ byte_size (data1)
+ type (ref4)
+ [ad] base_type "character(kind=1)"
+ byte_size (data1)
+ encoding (data1)
+ name (strp)
+ [b4] subprogram "repro"
+ name (strp)
+ decl_file (data1)
+ decl_line (data1)
+ main_subprogram (flag_present)
+ calling_convention (data1)
+ low_pc (addr)
+ high_pc (data8)
+ frame_base (exprloc) {call_frame_cfa {bregx(7,8)}}
+ GNU_all_tail_call_sites (flag_present)
+ sibling (ref4)
+ [d2] variable "c40pt"
+ name (strp)
+ decl_file (data1)
+ decl_line (data1)
+ type (ref4)
+ location (exprloc) {fbreg(-128)}
+ [e1] variable "span.0"
+ name (strp)
+ type (ref4)
+ artificial (flag_present)
+ location (exprloc) {fbreg(-80)}
+ [ee] variable "i"
+ name (string)
+ decl_file (data1)
+ decl_line (data1)
+ type (ref4)
+ location (exprloc) {fbreg(-68)}
+ [fb] variable "unpleasant"
+ name (strp)
+ decl_file (data1)
+ decl_line (data1)
+ type (ref4)
+ location (exprloc) {fbreg(-1008)}
+ [10a] lexical_block
+ low_pc (addr)
+ high_pc (data8)
+ sibling (ref4)
+ [11f] lexical_block
+ low_pc (addr)
+ high_pc (data8)
+ [131] lexical_block
+ low_pc (addr)
+ high_pc (data8)
+ [142] lexical_block
+ low_pc (addr)
+ high_pc (data8)
+ [153] lexical_block
+ low_pc (addr)
+ high_pc (data8)
+ [167] array_type
+ data_location (exprloc) {push_object_address, deref}
+ associated (exprloc) {push_object_address, deref, lit0, ne}
+ type (ref4)
+ sibling (ref4)
+ [178] subrange_type
+ lower_bound (exprloc) {push_object_address, plus_uconst(32), deref}
+ upper_bound (exprloc) {push_object_address, plus_uconst(40), deref}
+ byte_stride (exprloc) {push_object_address, plus_uconst(24), deref, GNU_variable_value([e1]) {fbreg(-80)}, mul}
+ [18f] array_type
+ type (ref4)
+ [194] subrange_type
+ type (ref4)
+ upper_bound (sdata)
+EOF
+
+exit 0
diff --git a/tests/run-find-prologues.sh b/tests/run-find-prologues.sh
new file mode 100755
index 0000000..160f07d
--- /dev/null
+++ b/tests/run-find-prologues.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2005 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
+
+testfiles testfile testfile11 testfile22 testfile24 \
+ testfile25 testfile3 testfile4 testfile5 testfile6
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile <<\EOF
+main 0x000000000804842c 0x0000000008048432
+bar 0x000000000804845c 0x000000000804845f
+foo 0x0000000008048468 0x000000000804846b
+EOF
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile11 <<\EOF
+main 0x00000000080489b8 0x00000000080489cd
+gnu_obj_2 0x0000000008048c9e 0x0000000008048ca4
+gnu_obj_3 0x0000000008048cd8 0x0000000008048cde
+gnu_obj_2 0x0000000008048cf4 0x0000000008048cfa
+~invalid_argument 0x0000000008048d2e 0x0000000008048d34
+gnu_obj_1 0x0000000008048d62 0x0000000008048d65
+gnu_obj_1 0x0000000008048d8a 0x0000000008048d8d
+~invalid_argument 0x0000000008048db2 0x0000000008048db8
+EOF
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile22 <<\EOF
+function 0x0000000008048348 0x000000000804834e
+main 0x000000000804835b 0x0000000008048377
+EOF
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile24 <<\EOF
+incr 0x0000000008048348 0x000000000804834e
+main 0x0000000008048354 0x0000000008048360
+EOF
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile25 <<\EOF
+incr 0x0000000008048348 0x000000000804834c
+EOF
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile3 <<\EOF
+main 0x000000000804842c 0x0000000008048433
+bar 0x0000000008048458 0x000000000804845b
+foo 0x0000000008048464 0x0000000008048467
+EOF
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile4 <<\EOF
+get 0x00000000080493fc 0x0000000008049402
+main 0x0000000008049498 0x000000000804949e
+a 0x000000000804d85c 0x000000000804d85c
+__tfPCc 0x000000000804d86c 0x000000000804d872
+__tfCc 0x000000000804d8a4 0x000000000804d8a4
+EOF
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile5 <<\EOF
+bar 0x000000000804842c 0x000000000804842f
+foo 0x0000000008048438 0x000000000804843b
+main 0x0000000008048444 0x000000000804844a
+EOF
+
+testrun_compare ${abs_builddir}/find-prologues -e testfile6 <<\EOF
+main 0x00000000080489b8 0x00000000080489cd
+gnu_obj_2 0x0000000008048c9e 0x0000000008048ca4
+gnu_obj_3 0x0000000008048cd8 0x0000000008048cde
+gnu_obj_2 0x0000000008048cf4 0x0000000008048cfa
+~invalid_argument 0x0000000008048d2e 0x0000000008048d34
+gnu_obj_1 0x0000000008048d62 0x0000000008048d65
+gnu_obj_1 0x0000000008048d8a 0x0000000008048d8d
+~invalid_argument 0x0000000008048db2 0x0000000008048db8
+EOF
+
+exit 0
diff --git a/tests/run-funcretval.sh b/tests/run-funcretval.sh
new file mode 100755
index 0000000..779bd47
--- /dev/null
+++ b/tests/run-funcretval.sh
@@ -0,0 +1,153 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+# The following files were obtaining by compiling funcretval_test.c
+# from this directory as follows:
+#
+# gcc -g funcretval_test.c -o funcretval_test_<YOURARCH>
+#
+# Pass -DFLOAT128 if the given arch supports __float128.
+
+testfiles funcretval_test_aarch64
+
+# funcretval_test_aarch64 was built with additional flag:
+# -DAARCH64_BUG_1032854
+# hence no fun_vec_double_8.
+testrun_compare ${abs_top_builddir}/tests/funcretval \
+ -e funcretval_test_aarch64 <<\EOF
+() fun_char: return value location: {0x50, 0}
+() fun_short: return value location: {0x50, 0}
+() fun_int: return value location: {0x50, 0}
+() fun_ptr: return value location: {0x50, 0}
+() fun_iptr: return value location: {0x50, 0}
+() fun_long: return value location: {0x50, 0}
+() fun_int128: return value location: {0x50, 0} {0x93, 0x8} {0x51, 0} {0x93, 0x8}
+() fun_large_struct1: return value location: {0x70, 0}
+() fun_large_struct2: return value location: {0x70, 0}
+() fun_float: return value location: {0x90, 0x40}
+() fun_float_complex: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4}
+() fun_double: return value location: {0x90, 0x40}
+() fun_double_complex: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_long_double: return value location: {0x90, 0x40}
+() fun_long_double_complex: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_vec_char_8: return value location: {0x90, 0x40}
+() fun_vec_short_8: return value location: {0x90, 0x40}
+() fun_vec_int_8: return value location: {0x90, 0x40}
+() fun_vec_long_8: return value location: {0x90, 0x40}
+() fun_vec_float_8: return value location: {0x90, 0x40}
+() fun_vec_char_16: return value location: {0x90, 0x40}
+() fun_vec_short_16: return value location: {0x90, 0x40}
+() fun_vec_int_16: return value location: {0x90, 0x40}
+() fun_vec_long_16: return value location: {0x90, 0x40}
+() fun_vec_int128_16: return value location: {0x90, 0x40}
+() fun_vec_float_16: return value location: {0x90, 0x40}
+() fun_vec_double_16: return value location: {0x90, 0x40}
+() fun_hfa1_float: return value location: {0x90, 0x40}
+() fun_hfa1_double: return value location: {0x90, 0x40}
+() fun_hfa1_long_double: return value location: {0x90, 0x40}
+() fun_hfa1_float_a: return value location: {0x90, 0x40}
+() fun_hfa1_double_a: return value location: {0x90, 0x40}
+() fun_hfa1_long_double_a: return value location: {0x90, 0x40}
+() fun_hfa2_float: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4}
+() fun_hfa2_double: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_hfa2_long_double: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hfa2_float_a: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4}
+() fun_hfa2_double_a: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_hfa2_long_double_a: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hfa3_float: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4} {0x90, 0x42} {0x93, 0x4}
+() fun_hfa3_double: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_hfa3_long_double: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hfa3_float_a: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4} {0x90, 0x42} {0x93, 0x4}
+() fun_hfa3_double_a: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_hfa3_long_double_a: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hfa4_float: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4} {0x90, 0x42} {0x93, 0x4} {0x90, 0x43} {0x93, 0x4}
+() fun_hfa4_double: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8} {0x90, 0x43} {0x93, 0x8}
+() fun_hfa4_long_double: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_hfa4_float_a: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4} {0x90, 0x42} {0x93, 0x4} {0x90, 0x43} {0x93, 0x4}
+() fun_hfa4_double_a: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8} {0x90, 0x43} {0x93, 0x8}
+() fun_hfa4_long_double_a: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_nfa5_float: return value location: {0x70, 0}
+() fun_nfa5_double: return value location: {0x70, 0}
+() fun_nfa5_long_double: return value location: {0x70, 0}
+() fun_nfa5_float_a: return value location: {0x70, 0}
+() fun_nfa5_double_a: return value location: {0x70, 0}
+() fun_nfa5_long_double_a: return value location: {0x70, 0}
+() fun_hva1_vec_char_8: return value location: {0x90, 0x40}
+() fun_hva1_vec_short_8: return value location: {0x90, 0x40}
+() fun_hva1_vec_int_8: return value location: {0x90, 0x40}
+() fun_hva1_vec_long_8: return value location: {0x90, 0x40}
+() fun_hva1_vec_float_8: return value location: {0x90, 0x40}
+() fun_hva1_vec_double_8: return value location: {0x90, 0x40}
+() fun_hva1_vec_char_16_t: return value location: {0x90, 0x40}
+() fun_hva1_vec_short_16_t: return value location: {0x90, 0x40}
+() fun_hva1_vec_int_16_t: return value location: {0x90, 0x40}
+() fun_hva1_vec_long_16_t: return value location: {0x90, 0x40}
+() fun_hva1_vec_int128_16_t: return value location: {0x90, 0x40}
+() fun_hva1_vec_float_16_t: return value location: {0x90, 0x40}
+() fun_hva1_vec_double_16_t: return value location: {0x90, 0x40}
+() fun_hva2_vec_char_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_hva2_vec_short_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_hva2_vec_int_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_hva2_vec_long_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_hva2_vec_float_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_hva2_vec_double_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() fun_hva2_vec_char_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hva2_vec_short_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hva2_vec_int_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hva2_vec_long_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hva2_vec_int128_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hva2_vec_float_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hva2_vec_double_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10}
+() fun_hva3_vec_char_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_hva3_vec_short_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_hva3_vec_int_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_hva3_vec_long_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_hva3_vec_float_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_hva3_vec_double_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_hva3_vec_char_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hva3_vec_short_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hva3_vec_int_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hva3_vec_long_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hva3_vec_int128_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hva3_vec_float_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hva3_vec_double_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_hva4_vec_char_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8} {0x90, 0x43} {0x93, 0x8}
+() fun_hva4_vec_short_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8} {0x90, 0x43} {0x93, 0x8}
+() fun_hva4_vec_int_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8} {0x90, 0x43} {0x93, 0x8}
+() fun_hva4_vec_long_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8} {0x90, 0x43} {0x93, 0x8}
+() fun_hva4_vec_float_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8} {0x90, 0x43} {0x93, 0x8}
+() fun_hva4_vec_double_8: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8} {0x90, 0x43} {0x93, 0x8}
+() fun_hva4_vec_char_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_hva4_vec_short_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_hva4_vec_int_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_hva4_vec_long_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_hva4_vec_int128_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_hva4_vec_float_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_hva4_vec_double_16_t: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10} {0x90, 0x43} {0x93, 0x10}
+() fun_mixed_hfa3_cff: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4} {0x90, 0x42} {0x93, 0x4}
+() fun_mixed_hfa3_cdd: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_mixed_hfa3_cldld: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_mixed_hfa3_fcf: return value location: {0x90, 0x40} {0x93, 0x4} {0x90, 0x41} {0x93, 0x4} {0x90, 0x42} {0x93, 0x4}
+() fun_mixed_hfa3_dcd: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8} {0x90, 0x42} {0x93, 0x8}
+() fun_mixed_hfa3_ldcld: return value location: {0x90, 0x40} {0x93, 0x10} {0x90, 0x41} {0x93, 0x10} {0x90, 0x42} {0x93, 0x10}
+() fun_mixed_hfa2_fltsht_t: return value location: {0x90, 0x40} {0x93, 0x8} {0x90, 0x41} {0x93, 0x8}
+() main: return value location: {0x50, 0}
+EOF
+
+exit 0
diff --git a/tests/run-funcscopes.sh b/tests/run-funcscopes.sh
new file mode 100755
index 0000000..367729a
--- /dev/null
+++ b/tests/run-funcscopes.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2005, 2014 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
+
+testfiles testfile25
+
+testrun_compare ${abs_builddir}/funcscopes -e testfile25 incr <<\EOF
+testfile25: 0x8048000 .. 0x8049528
+ inline-test.c (0x11): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x804834e (/home/roland/build/stock-elfutils/inline-test.c:9)
+ incr (0x2e): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x804834e (/home/roland/build/stock-elfutils/inline-test.c:9)
+ x [ 66]
+EOF
+
+exit 0
diff --git a/tests/run-get-aranges.sh b/tests/run-get-aranges.sh
new file mode 100755
index 0000000..62cae5f
--- /dev/null
+++ b/tests/run-get-aranges.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+testfiles testfile testfile2
+
+testrun_compare ${abs_builddir}/get-aranges testfile testfile2 <<\EOF
+0x804842b: not in range
+CU name: "m.c"
+CU name: "m.c"
+CU name: "m.c"
+0x804845a: not in range
+0x804845b: not in range
+CU name: "b.c"
+CU name: "b.c"
+CU name: "b.c"
+0x8048466: not in range
+0x8048467: not in range
+CU name: "f.c"
+CU name: "f.c"
+CU name: "f.c"
+0x8048472: not in range
+ [ 0] start: 0x804842c, length: 46, cu: 11
+CU name: "m.c"
+ [ 1] start: 0x804845c, length: 10, cu: 202
+CU name: "b.c"
+ [ 2] start: 0x8048468, length: 10, cu: 5628
+CU name: "f.c"
+0x804842b: not in range
+0x804842c: not in range
+0x804843c: not in range
+0x8048459: not in range
+0x804845a: not in range
+0x804845b: not in range
+0x804845c: not in range
+0x8048460: not in range
+0x8048465: not in range
+0x8048466: not in range
+0x8048467: not in range
+0x8048468: not in range
+0x8048470: not in range
+0x8048471: not in range
+0x8048472: not in range
+ [ 0] start: 0x10000470, length: 32, cu: 11
+CU name: "b.c"
+ [ 1] start: 0x10000490, length: 32, cu: 2429
+CU name: "f.c"
+ [ 2] start: 0x100004b0, length: 100, cu: 2532
+CU name: "m.c"
+EOF
+
+exit 0
diff --git a/tests/run-get-files.sh b/tests/run-get-files.sh
new file mode 100755
index 0000000..a2f2373
--- /dev/null
+++ b/tests/run-get-files.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2004, 2005, 2007 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+testfiles testfile testfile2
+
+testrun_compare ${abs_builddir}/get-files testfile testfile2 <<\EOF
+cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 191
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
+ file[0] = "???"
+ file[1] = "/home/drepper/gnu/new-bu/build/ttt/m.c"
+cuhl = 11, o = 114, asz = 4, osz = 4, ncu = 5617
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
+ file[0] = "???"
+ file[1] = "/home/drepper/gnu/new-bu/build/ttt/b.c"
+ file[2] = "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h"
+ file[3] = "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h"
+ file[4] = "/usr/include/bits/types.h"
+ file[5] = "/usr/include/bits/sched.h"
+ file[6] = "/usr/include/bits/pthreadtypes.h"
+ file[7] = "/usr/include/stdio.h"
+ file[8] = "/usr/include/libio.h"
+ file[9] = "/usr/include/wchar.h"
+ file[10] = "/usr/include/_G_config.h"
+ file[11] = "/usr/include/gconv.h"
+cuhl = 11, o = 412, asz = 4, osz = 4, ncu = 5752
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
+ file[0] = "???"
+ file[1] = "/home/drepper/gnu/new-bu/build/ttt/f.c"
+cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 2418
+ dirs[0] = "/shoggoth/drepper"
+ file[0] = "???"
+ file[1] = "/shoggoth/drepper/b.c"
+ file[2] = "/home/geoffk/objs/laurel-000912-branch/lib/gcc-lib/powerpc-unknown-linux-gnu/2.96-laurel-000912/include/stddef.h"
+ file[3] = "/home/geoffk/objs/laurel-000912-branch/lib/gcc-lib/powerpc-unknown-linux-gnu/2.96-laurel-000912/include/stdarg.h"
+ file[4] = "/shoggoth/drepper/<built-in>"
+ file[5] = "/usr/include/bits/types.h"
+ file[6] = "/usr/include/stdio.h"
+ file[7] = "/usr/include/libio.h"
+ file[8] = "/usr/include/_G_config.h"
+cuhl = 11, o = 213, asz = 4, osz = 4, ncu = 2521
+ dirs[0] = "/shoggoth/drepper"
+ file[0] = "???"
+ file[1] = "/shoggoth/drepper/f.c"
+cuhl = 11, o = 267, asz = 4, osz = 4, ncu = 2680
+ dirs[0] = "/shoggoth/drepper"
+ file[0] = "???"
+ file[1] = "/shoggoth/drepper/m.c"
+EOF
+
+exit 0
diff --git a/tests/run-get-lines.sh b/tests/run-get-lines.sh
new file mode 100755
index 0000000..fb48c77
--- /dev/null
+++ b/tests/run-get-lines.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2004, 2005, 2013 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+testfiles testfile testfile2 testfilenolines
+
+testrun_compare ${abs_builddir}/get-lines testfile testfile2 <<\EOF
+cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 191
+ 5 lines
+804842c: /home/drepper/gnu/new-bu/build/ttt/m.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+8048432: /home/drepper/gnu/new-bu/build/ttt/m.c:6:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+804844d: /home/drepper/gnu/new-bu/build/ttt/m.c:7:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+8048458: /home/drepper/gnu/new-bu/build/ttt/m.c:8:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+804845a: /home/drepper/gnu/new-bu/build/ttt/m.c:8:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
+cuhl = 11, o = 114, asz = 4, osz = 4, ncu = 5617
+ 4 lines
+804845c: /home/drepper/gnu/new-bu/build/ttt/b.c:4:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+804845f: /home/drepper/gnu/new-bu/build/ttt/b.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+8048464: /home/drepper/gnu/new-bu/build/ttt/b.c:6:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+8048466: /home/drepper/gnu/new-bu/build/ttt/b.c:6:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
+cuhl = 11, o = 412, asz = 4, osz = 4, ncu = 5752
+ 4 lines
+8048468: /home/drepper/gnu/new-bu/build/ttt/f.c:3:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+804846b: /home/drepper/gnu/new-bu/build/ttt/f.c:4:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+8048470: /home/drepper/gnu/new-bu/build/ttt/f.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+8048472: /home/drepper/gnu/new-bu/build/ttt/f.c:5:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
+cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 2418
+ 4 lines
+10000470: /shoggoth/drepper/b.c:4:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+1000047c: /shoggoth/drepper/b.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+10000480: /shoggoth/drepper/b.c:6:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+10000490: /shoggoth/drepper/b.c:6:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
+cuhl = 11, o = 213, asz = 4, osz = 4, ncu = 2521
+ 4 lines
+10000490: /shoggoth/drepper/f.c:3:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+1000049c: /shoggoth/drepper/f.c:4:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+100004a0: /shoggoth/drepper/f.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+100004b0: /shoggoth/drepper/f.c:5:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
+cuhl = 11, o = 267, asz = 4, osz = 4, ncu = 2680
+ 5 lines
+100004b0: /shoggoth/drepper/m.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+100004cc: /shoggoth/drepper/m.c:6:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+100004e8: /shoggoth/drepper/m.c:7:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+100004f4: /shoggoth/drepper/m.c:8:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+10000514: /shoggoth/drepper/m.c:8:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
+EOF
+
+# - lines.c
+# int ft;
+#
+# int
+# main (int argc, char **argv)
+# {
+# return ft - 42;
+# }
+#
+# - nolines.c
+# int ft = 42;
+#
+# gcc -g -c lines.c
+# gcc -g -c nolines.c
+# gcc -g -o testfilenolines lines.o nolines.o
+
+testrun_compare ${abs_builddir}/get-lines testfilenolines <<\EOF
+cuhl = 11, o = 0, asz = 8, osz = 4, ncu = 169
+ 4 lines
+400474: /home/mark/src/tests/lines.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+40047f: /home/mark/src/tests/lines.c:6:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+400488: /home/mark/src/tests/lines.c:7:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
+40048a: /home/mark/src/tests/lines.c:7:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
+cuhl = 11, o = 125, asz = 8, osz = 4, ncu = 243
+ 0 lines
+EOF
+
+exit 0
diff --git a/tests/run-get-pubnames.sh b/tests/run-get-pubnames.sh
new file mode 100755
index 0000000..912793e
--- /dev/null
+++ b/tests/run-get-pubnames.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2003, 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+testfiles testfile testfile2
+
+testrun_compare ${abs_builddir}/get-pubnames testfile testfile2 <<\EOF
+ [ 0] "main", die: 104, cu: 11
+CU name: "m.c"
+object name: "main"
+ [ 1] "a", die: 174, cu: 11
+CU name: "m.c"
+object name: "a"
+ [ 2] "bar", die: 295, cu: 202
+CU name: "b.c"
+object name: "bar"
+ [ 3] "foo", die: 5721, cu: 5628
+CU name: "f.c"
+object name: "foo"
+ [ 0] "bar", die: 72, cu: 11
+CU name: "b.c"
+object name: "bar"
+ [ 1] "foo", die: 2490, cu: 2429
+CU name: "f.c"
+object name: "foo"
+ [ 2] "main", die: 2593, cu: 2532
+CU name: "m.c"
+object name: "main"
+ [ 3] "a", die: 2663, cu: 2532
+CU name: "m.c"
+object name: "a"
+EOF
+
+exit 0
diff --git a/tests/run-getsrc-die.sh b/tests/run-getsrc-die.sh
new file mode 100755
index 0000000..4da16e7
--- /dev/null
+++ b/tests/run-getsrc-die.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2014 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-addr2line-test.sh run-addr2line-i-test.sh run-addr2line-i-lex-test.sh
+# Output/files/lines matched should equal what is done through addr2line
+# which uses dwfl_module_getsrc. This test uses dwarf_addrdie and
+# dwarf_getsrc_die
+testfiles testfile testfile-inlines testfile-lex-inlines
+
+testrun_compare ${abs_top_builddir}/tests/getsrc_die testfile 0x08048468 0x0804845c <<\EOF
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/getsrc_die testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f1 0x00000000000005f2 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:6
+/tmp/x.cpp:10
+/tmp/x.cpp:11
+/tmp/x.cpp:5
+/tmp/x.cpp:10
+/tmp/x.cpp:5
+/tmp/x.cpp:10
+/tmp/x.cpp:10
+/tmp/x.cpp:5
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/getsrc_die testfile-lex-inlines 0x0000000000000680 0x0000000000000681 0x0000000000000690 0x0000000000000691 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:5
+/tmp/x.cpp:5
+/tmp/x.cpp:5
+EOF
+
+exit 0
diff --git a/tests/run-lfs-symbols.sh b/tests/run-lfs-symbols.sh
new file mode 100755
index 0000000..f089440
--- /dev/null
+++ b/tests/run-lfs-symbols.sh
@@ -0,0 +1,86 @@
+#! /bin/bash
+# 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
+
+if ! grep -q -F '#define _FILE_OFFSET_BITS' ${abs_top_builddir}/config.h; then
+ echo "LFS testing is irrelevent on this system"
+ exit 77
+fi
+
+# #include <stdio.h>
+# int main () {
+# FILE *f = fopen ("/dev/null", "r");
+# return f == NULL;
+# }
+#
+# Built for Linux i686, without setting _FILE_OFFSET_BITS.
+# $ gcc -m32 -O2 nolfs.c -o testfile-nolfs
+testfiles testfile-nolfs
+
+LFS_FORMAT='BEGIN {
+ while ((getline < "%s") > 0)
+ /^\w/ && bad[$0]
+ FS="@"
+}
+/@@GLIBC_/ && $1 in bad { print $1 }'
+
+LFS=$(printf "$LFS_FORMAT" "${abs_srcdir}/lfs-symbols")
+
+makeprint() {
+ make print-$1 -C $2 |& awk -F= "/^$1=/{ print \$2 }"
+}
+
+testrun_lfs() {
+ bad=$(testrun ${abs_top_builddir}/src/nm -u "$1" | awk "$LFS")
+ if [ -n "$bad" ]; then
+ echo "$1 contains non-lfs symbols:" $bad
+ exit_status=1
+ fi
+}
+
+# First sanity-check that LFS detection works.
+exit_status=0
+testrun_lfs ./testfile-nolfs
+if [ $exit_status -eq 0 ]; then
+ echo "Didn't detect any problem with testfile-nolfs!"
+ exit 99
+fi
+
+exit_status=0
+
+# Check all normal build targets.
+for dir in libelf libdw libasm libcpu src; do
+ dir=${abs_top_builddir}/$dir
+ for program in $(makeprint PROGRAMS $dir); do
+ testrun_lfs $dir/$program
+ done
+done
+
+# Check all libebl modules.
+dir=${abs_top_builddir}/backends
+for module in $(makeprint modules $dir); do
+ testrun_lfs $dir/libebl_$module.so
+done
+
+# Check all test programs.
+dir=${abs_builddir}
+for program in $(makeprint check_PROGRAMS $dir); do
+ testrun_lfs $dir/$program
+done
+
+exit $exit_status
diff --git a/tests/run-line2addr.sh b/tests/run-line2addr.sh
new file mode 100755
index 0000000..3b6c445
--- /dev/null
+++ b/tests/run-line2addr.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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
+
+testfiles testfile testfile2 testfile8 testfile14 testfile23
+
+testrun_compare ${abs_builddir}/line2addr -e testfile f.c:4 testfile f.c:8 <<\EOF
+f.c:4 -> 0x804846b (/home/drepper/gnu/new-bu/build/ttt/f.c:4)
+EOF
+
+testrun_compare ${abs_builddir}/line2addr -e testfile2 m.c:6 b.c:1 <<\EOF
+m.c:6 -> 0x100004cc (/shoggoth/drepper/m.c:6)
+b.c:1 -> 0x10000470 (/shoggoth/drepper/b.c:4)
+EOF
+
+testrun_compare ${abs_builddir}/line2addr -e testfile8 strip.c:953 strip.c:365 <<\EOF
+strip.c:953 -> (.text)+0x169f (/home/drepper/gnu/elfutils/build/src/../../src/strip.c:953)
+strip.c:953 -> (.text)+0x16aa (/home/drepper/gnu/elfutils/build/src/../../src/strip.c:953)
+strip.c:365 -> (.text)+0x278b (/home/drepper/gnu/elfutils/build/src/../../src/strip.c:365)
+strip.c:365 -> (.text)+0x2797 (/home/drepper/gnu/elfutils/build/src/../../src/strip.c:365)
+EOF
+
+testrun_compare ${abs_builddir}/line2addr -e testfile14 v.c:6 <<\EOF
+v.c:6 -> 0x400468 (/home/drepper/local/elfutils-build/20050425/v.c:6)
+v.c:6 -> 0x400487 (/home/drepper/local/elfutils-build/20050425/v.c:6)
+EOF
+
+testrun_compare ${abs_builddir}/line2addr -e testfile23 foo.c:2 foo.c:6 <<\EOF
+foo.c:2 -> (.init.text)+0xc (/home/roland/stock-elfutils-build/foo.c:2)
+foo.c:6 -> (.text)+0xc (/home/roland/stock-elfutils-build/foo.c:6)
+EOF
+
+exit 0
diff --git a/tests/run-linkmap-cut.sh b/tests/run-linkmap-cut.sh
new file mode 100755
index 0000000..de2bc7c
--- /dev/null
+++ b/tests/run-linkmap-cut.sh
@@ -0,0 +1,32 @@
+#! /bin/bash
+# Copyright (C) 2014 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
+
+# The core file has patched:
+# * _r_debug.r_map.l_next.l_next (vma 0x3fdf621718, offset 0x7718) = NULL,
+# therefore all libraries after the main executable and vDSO are removed.
+# * NT_FILE absolute filenames are relativized to: ./////basename
+
+testfiles linkmap-cut-lib.so linkmap-cut linkmap-cut.core
+tempfiles bt
+# It may have non-zero exit code with:
+# .../elfutils/src/stack: dwfl_thread_getframes tid 3130 at 0x3fdf821d64 in /usr/lib64/libc-2.18.so: no matching address range
+testrun ${abs_top_builddir}/src/stack --core=linkmap-cut.core -e linkmap-cut -m >bt || true
+cat bt
+grep -q '^#0 0x00007f08bc24d681 libfunc - .////////////////////////////////////linkmap-cut-lib\.so$' bt
+grep -q '^#1 0x00000000004006b4 main - linkmap-cut$' bt
diff --git a/tests/run-low_high_pc.sh b/tests/run-low_high_pc.sh
new file mode 100755
index 0000000..ab5f2c3
--- /dev/null
+++ b/tests/run-low_high_pc.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2005 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
+
+# int
+# main (int argc, char **argv)
+# {
+# return 0;
+# }
+# gcc -g -o main main.c
+testfiles testfile_low_high_pc
+
+testrun ${abs_builddir}/low_high_pc -e ./testfile_low_high_pc
+testrun ${abs_builddir}/low_high_pc -e ${abs_builddir}/low_high_pc
+testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/src/strip
+testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/src/strip.o
+testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/libelf/libelf.so
+
+exit 0
diff --git a/tests/run-macro-test.sh b/tests/run-macro-test.sh
new file mode 100755
index 0000000..79b0d88
--- /dev/null
+++ b/tests/run-macro-test.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+
+# #include <string.h>
+#
+# #define HELLO "world"
+#
+# int
+# main(int argc, char ** argv)
+# {
+# return strlen (HELLO);
+# }
+#
+# gcc -gdwarf-4 -g3 -o testfile-macros macro.c
+# gcc -gstrict-dwarf -gdwarf-4 -g3 -o testfile-macinfo macro.c
+
+testfiles testfile-macinfo testfile-macros
+tempfiles readelf.macros.out
+
+status=0
+
+testrun ${abs_top_builddir}/src/readelf --debug-dump=info testfile-macinfo \
+ | grep macro_info > readelf.macros.out ||
+ { echo "*** failure readelf --debug-dump=info testfile-macinfo"; status=1; }
+testrun_compare cat readelf.macros.out <<\EOF
+ macro_info (sec_offset) 0
+EOF
+
+testrun ${abs_top_builddir}/src/readelf --debug-dump=info testfile-macros \
+ | grep GNU_macros > readelf.macros.out ||
+ { echo "*** failure readelf --debug-dump=info testfile-macros"; status=1; }
+testrun_compare cat readelf.macros.out <<\EOF
+ GNU_macros (sec_offset) 0
+EOF
+
+exit $status
diff --git a/tests/run-native-test.sh b/tests/run-native-test.sh
new file mode 100755
index 0000000..d19007f
--- /dev/null
+++ b/tests/run-native-test.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2005, 2006, 2013 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
+
+# This tests all the miscellaneous components of backend support
+# against whatever this build is running on. A platform will fail
+# this test if it is missing parts of the backend implementation.
+#
+# As new backend code is added to satisfy the test, be sure to update
+# the fixed test cases (run-allregs.sh et al) to test that backend
+# in all builds.
+
+tempfiles native.c native
+echo 'main () { while (1) pause (); }' > native.c
+
+native=0
+kill_native()
+{
+ test $native -eq 0 || {
+ kill -9 $native 2> /dev/null || :
+ wait $native 2> /dev/null || :
+ }
+ native=0
+}
+
+native_cleanup()
+{
+ kill_native
+ test_cleanup
+}
+
+native_exit()
+{
+ native_cleanup
+ exit_cleanup
+}
+
+trap native_cleanup 1 2 15
+trap native_exit 0
+
+for cc in "$HOSTCC" "$HOST_CC" cc gcc "$CC"; do
+ test "x$cc" != x || continue
+ $cc -o native -g native.c > /dev/null 2>&1 &&
+ # Some shell versions don't do this right without the braces.
+ { ./native > /dev/null 2>&1 & native=$! ; } &&
+ sleep 1 && kill -0 $native 2> /dev/null &&
+ break ||
+ native=0
+done
+
+native_test()
+{
+ # Try the build against itself, i.e. $config_host.
+ testrun "$@" -e $1 > /dev/null
+
+ # Try the build against a presumed native process, running this sh.
+ # For tests requiring debug information, this may not test anything.
+ testrun "$@" -p $$ > /dev/null
+
+ # Try the build against the trivial native program we just built with -g.
+ test $native -eq 0 || testrun "$@" -p $native > /dev/null
+}
+
+native_test ${abs_builddir}/allregs
+native_test ${abs_builddir}/funcretval
+
+# We do this explicitly rather than letting the trap 0 cover it,
+# because as of version 3.1 bash prints the "Killed" report for
+# $native when we do the kill inside the exit handler.
+native_cleanup
+
+exit 0
diff --git a/tests/run-nm-self.sh b/tests/run-nm-self.sh
new file mode 100755
index 0000000..6a31afc
--- /dev/null
+++ b/tests/run-nm-self.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2012, 2014 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
+
+# Test different command line combinations on the nm binary itself.
+# Test on nm ET_REL, ET_EXEC and ET_DYN files.
+ET_REL=${abs_top_builddir}/src/nm.o
+ET_EXEC=${abs_top_builddir}/src/nm
+ET_DYN=${abs_top_builddir}/libelf/libelf.so
+for what_arg in --debug-syms --defined-only --dynamic --extern-only; do
+ for format_arg in --format=bsd --format=sysv --format=posix; do
+ for out_arg in --numeric-sort --no-sort --reverse-sort; do
+ for self_file in $ET_REL $ET_EXEC $ET_DYN; do
+ # --dynamic doesn't make sense for ET_REL.
+ if ! test "$what_arg" = "--dynamic" -a "$self_file" = "$ET_REL"; then
+ testrun ${abs_top_builddir}/src/nm $what_arg $format_arg $out_arg $self_file > /dev/null
+ fi
+ done
+ done
+ done
+done
diff --git a/tests/run-peel-type.sh b/tests/run-peel-type.sh
new file mode 100755
index 0000000..668e316
--- /dev/null
+++ b/tests/run-peel-type.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2017 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-aggregate-size.sh for how to generate testfiles.
+
+testfiles testfile-sizes1.o testfile-sizes2.o testfile-sizes3.o
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes1.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+EOF
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes2.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+EOF
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes3.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+d3d raw type array_type
+f raw type base_type
+b raw type base_type
+EOF
+
+exit 0
diff --git a/tests/run-prelink-addr-test.sh b/tests/run-prelink-addr-test.sh
new file mode 100755
index 0000000..3398c0d
--- /dev/null
+++ b/tests/run-prelink-addr-test.sh
@@ -0,0 +1,252 @@
+#! /bin/sh
+# Copyright (C) 2011-2013 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
+
+
+# testfile52.c:
+# #include <stdlib.h>
+# int foo() { exit(0); }
+#
+# gcc -m32 -g -shared testfile52-32.c -o testfile52-32.so
+# eu-strip -f testfile52-32.so.debug testfile52-32.so
+# cp testfile52-32.so testfile52-32.prelink.so
+# prelink -N testfile52-32.prelink.so
+# cp testfile52-32.so testfile52-32.noshdrs.so
+# prelink -r 0x42000000 testfile52-32.noshdrs.so
+# eu-strip --remove-comment --strip-sections testfile52-32.noshdrs.so
+
+testfiles testfile52-32.so testfile52-32.so.debug
+testfiles testfile52-32.prelink.so testfile52-32.noshdrs.so
+tempfiles testmaps52-32 testfile52-32.noshdrs.so.debug
+ln -snf testfile52-32.so.debug testfile52-32.noshdrs.so.debug
+
+cat > testmaps52-32 <<EOF
+00111000-00112000 r-xp 00000000 fd:01 1 `pwd`/testfile52-32.so
+00112000-00113000 rw-p 00000000 fd:01 1 `pwd`/testfile52-32.so
+41000000-41001000 r-xp 00000000 fd:01 2 `pwd`/testfile52-32.prelink.so
+41001000-41002000 rw-p 00000000 fd:01 2 `pwd`/testfile52-32.prelink.so
+42000000-42001000 r-xp 00000000 fd:01 3 `pwd`/testfile52-32.noshdrs.so
+42001000-42002000 rw-p 00000000 fd:01 3 `pwd`/testfile52-32.noshdrs.so
+EOF
+
+# Prior to commit 1743d7f, libdwfl would fail on the second address,
+# because it didn't notice that prelink added a 0x20-byte offset from
+# what the .debug file reports.
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps52-32 \
+ 0x11140c 0x4100042d 0x4200040e <<\EOF
+foo
+/home/jistone/src/elfutils/tests/testfile52-32.c:2
+foo+0x1
+/home/jistone/src/elfutils/tests/testfile52-32.c:2
+foo+0x2
+/home/jistone/src/elfutils/tests/testfile52-32.c:2
+EOF
+
+# Repeat testfile52 for -m64. The particular REL>RELA issue doesn't exist, but
+# we'll make sure the rest works anyway.
+testfiles testfile52-64.so testfile52-64.so.debug
+testfiles testfile52-64.prelink.so testfile52-64.noshdrs.so
+tempfiles testmaps52-64 testfile52-64.noshdrs.so.debug
+ln -snf testfile52-64.so.debug testfile52-64.noshdrs.so.debug
+
+cat > testmaps52-64 <<EOF
+1000000000-1000001000 r-xp 00000000 fd:11 1 `pwd`/testfile52-64.so
+1000001000-1000200000 ---p 00001000 fd:11 1 `pwd`/testfile52-64.so
+1000200000-1000201000 rw-p 00000000 fd:11 1 `pwd`/testfile52-64.so
+3000000000-3000001000 r-xp 00000000 fd:11 2 `pwd`/testfile52-64.prelink.so
+3000001000-3000200000 ---p 00001000 fd:11 2 `pwd`/testfile52-64.prelink.so
+3000200000-3000201000 rw-p 00000000 fd:11 2 `pwd`/testfile52-64.prelink.so
+3800000000-3800001000 r-xp 00000000 fd:11 3 `pwd`/testfile52-64.noshdrs.so
+3800001000-3800200000 ---p 00001000 fd:11 3 `pwd`/testfile52-64.noshdrs.so
+3800200000-3800201000 rw-p 00000000 fd:11 3 `pwd`/testfile52-64.noshdrs.so
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps52-64 \
+ 0x100000056c 0x300000056d 0x380000056e <<\EOF
+foo
+/home/jistone/src/elfutils/tests/testfile52-64.c:2
+foo+0x1
+/home/jistone/src/elfutils/tests/testfile52-64.c:2
+foo+0x2
+/home/jistone/src/elfutils/tests/testfile52-64.c:2
+EOF
+
+
+# testfile53.c:
+# char foo[0x1000];
+# int main() { return 0; }
+#
+# gcc -m32 -g testfile53-32.c -o testfile53-32
+# eu-strip -f testfile53-32.debug testfile53-32
+# cp testfile53-32 testfile53-32.prelink
+# prelink -N testfile53-32.prelink
+testfiles testfile53-32 testfile53-32.debug testfile53-32.prelink
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-32 0x8048394 0x8048395 <<\EOF
+main
+/home/jistone/src/elfutils/tests/testfile53-32.c:2
+main+0x1
+/home/jistone/src/elfutils/tests/testfile53-32.c:2
+EOF
+
+# prelink shuffled some of the sections, but .text is in the same place.
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-32.prelink 0x8048396 0x8048397 <<\EOF
+main+0x2
+/home/jistone/src/elfutils/tests/testfile53-32.c:2
+main+0x3
+/home/jistone/src/elfutils/tests/testfile53-32.c:2
+EOF
+
+# Repeat testfile53 in 64-bit, except use foo[0x800] to achieve the same
+# prelink section shuffling.
+testfiles testfile53-64 testfile53-64.debug testfile53-64.prelink
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-64 0x400474 0x400475 <<\EOF
+main
+/home/jistone/src/elfutils/tests/testfile53-64.c:2
+main+0x1
+/home/jistone/src/elfutils/tests/testfile53-64.c:2
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-64.prelink 0x400476 0x400477 <<\EOF
+main+0x2
+/home/jistone/src/elfutils/tests/testfile53-64.c:2
+main+0x3
+/home/jistone/src/elfutils/tests/testfile53-64.c:2
+EOF
+
+
+# testfile54.c:
+# extern void * stdin;
+# static void * pstdin = &stdin;
+# void * const foo = &pstdin;
+#
+# gcc -m32 -g -shared -nostartfiles testfile54-32.c -o testfile54-32.so
+# eu-strip -f testfile54-32.so.debug testfile54-32.so
+# cp testfile54-32.so testfile54-32.prelink.so
+# prelink -N testfile54-32.prelink.so
+# cp testfile54-32.so testfile54-32.noshdrs.so
+# prelink -r 0x42000000 testfile54-32.noshdrs.so
+# eu-strip --remove-comment --strip-sections testfile54-32.noshdrs.so
+testfiles testfile54-32.so testfile54-32.so.debug
+testfiles testfile54-32.prelink.so testfile54-32.noshdrs.so
+tempfiles testmaps54-32
+
+# Note we have no testfile54-32.noshdrs.so.debug link here, so
+# this is testing finding the symbols in .dynsym via PT_DYNAMIC.
+
+cat > testmaps54-32 <<EOF
+00111000-00112000 r--p 00000000 fd:01 1 `pwd`/testfile54-32.so
+00112000-00113000 rw-p 00000000 fd:01 1 `pwd`/testfile54-32.so
+41000000-41001000 r--p 00000000 fd:01 2 `pwd`/testfile54-32.prelink.so
+41001000-41002000 rw-p 00000000 fd:01 2 `pwd`/testfile54-32.prelink.so
+42000000-42001000 r--p 00000000 fd:01 3 `pwd`/testfile54-32.noshdrs.so
+42001000-42002000 rw-p 00000000 fd:01 3 `pwd`/testfile54-32.noshdrs.so
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps54-32 \
+ 0x1111fc 0x1122a4 0x410001fd 0x410012a5 0x420001fe <<\EOF
+foo
+??:0
+pstdin
+??:0
+foo+0x1
+??:0
+pstdin+0x1
+??:0
+foo+0x2
+??:0
+EOF
+
+# Repeat testfile64 in 64-bit
+testfiles testfile54-64.so testfile54-64.so.debug
+testfiles testfile54-64.prelink.so testfile54-64.noshdrs.so
+tempfiles testmaps54-64
+
+# Note we have no testfile54-64.noshdrs.so.debug link here, so
+# this is testing finding the symbols in .dynsym via PT_DYNAMIC.
+
+cat > testmaps54-64 <<EOF
+1000000000-1000001000 r--p 00000000 fd:11 1 `pwd`/testfile54-64.so
+1000001000-1000200000 ---p 00001000 fd:11 1 `pwd`/testfile54-64.so
+1000200000-1000201000 rw-p 00000000 fd:11 1 `pwd`/testfile54-64.so
+3000000000-3000001000 r--p 00000000 fd:11 2 `pwd`/testfile54-64.prelink.so
+3000001000-3000200000 ---p 00001000 fd:11 2 `pwd`/testfile54-64.prelink.so
+3000200000-3000201000 rw-p 00000000 fd:11 2 `pwd`/testfile54-64.prelink.so
+3800000000-3800001000 r--p 00000000 fd:11 3 `pwd`/testfile54-64.noshdrs.so
+3800001000-3800200000 ---p 00001000 fd:11 3 `pwd`/testfile54-64.noshdrs.so
+3800200000-3800201000 rw-p 00000000 fd:11 3 `pwd`/testfile54-64.noshdrs.so
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps54-64 \
+ 0x10000002f8 0x1000200448 0x30000002f9 0x3000200449 0x38000002fa <<\EOF
+foo
+??:0
+pstdin
+??:0
+foo+0x1
+??:0
+pstdin+0x1
+??:0
+foo+0x2
+??:0
+EOF
+
+
+# testfile55.c:
+# extern void *stdin;
+# int main() { return !stdin; }
+#
+# gcc -m32 -g testfile55-32.c -o testfile55-32
+# eu-strip -f testfile55-32.debug testfile55-32
+# cp testfile55-32 testfile55-32.prelink
+# prelink -N testfile55-32.prelink
+testfiles testfile55-32 testfile55-32.debug testfile55-32.prelink
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-32 0x80483b4 0x80483b5 <<\EOF
+main
+/home/jistone/src/elfutils/tests/testfile55-32.c:2
+main+0x1
+/home/jistone/src/elfutils/tests/testfile55-32.c:2
+EOF
+
+# prelink splits .bss into .dynbss+.bss, so the start of .bss changes, but the
+# total size remains the same, and .text doesn't move at all.
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-32.prelink 0x80483b6 0x80483b7 <<\EOF
+main+0x2
+/home/jistone/src/elfutils/tests/testfile55-32.c:2
+main+0x3
+/home/jistone/src/elfutils/tests/testfile55-32.c:2
+EOF
+
+# Repeat testfile55 in 64-bit
+testfiles testfile55-64 testfile55-64.debug testfile55-64.prelink
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-64 0x4004b4 0x4004b5 <<\EOF
+main
+/home/jistone/src/elfutils/tests/testfile55-64.c:2
+main+0x1
+/home/jistone/src/elfutils/tests/testfile55-64.c:2
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-64.prelink 0x4004b6 0x4004b7 <<\EOF
+main+0x2
+/home/jistone/src/elfutils/tests/testfile55-64.c:2
+main+0x3
+/home/jistone/src/elfutils/tests/testfile55-64.c:2
+EOF
diff --git a/tests/run-ranlib-test.sh b/tests/run-ranlib-test.sh
new file mode 100755
index 0000000..0b34cbb
--- /dev/null
+++ b/tests/run-ranlib-test.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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
+
+tempfiles ranlib-test.a ranlib-test.a-copy
+
+cat > ranlib-test.a <<"EOF"
+!<arch>
+foo/ 1124128960 500 500 100664 4 `
+foo
+bar/ 1124128965 500 500 100664 4 `
+bar
+EOF
+
+cp ranlib-test.a ranlib-test.a-copy
+
+testrun ${abs_top_builddir}/src/ranlib ranlib-test.a
+
+# The ranlib call should not have changed anything.
+cmp ranlib-test.a ranlib-test.a-copy
+
+exit 0
diff --git a/tests/run-ranlib-test2.sh b/tests/run-ranlib-test2.sh
new file mode 100755
index 0000000..dbc57ec
--- /dev/null
+++ b/tests/run-ranlib-test2.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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
+
+original=${original:-testfile19}
+indexed=${indexed:-testfile19.index}
+
+testfiles $original $indexed
+
+testrun ${abs_top_builddir}/src/ranlib $original
+
+if test -z "$noindex"; then
+ # The date in the index is different. The reference file has it blanked
+ # out, we do the same here.
+ echo " " |
+ dd of=$original seek=24 bs=1 count=12 conv=notrunc 2>/dev/null
+fi
+
+cmp $original $indexed
+
+exit 0
diff --git a/tests/run-ranlib-test3.sh b/tests/run-ranlib-test3.sh
new file mode 100755
index 0000000..1fc21cd
--- /dev/null
+++ b/tests/run-ranlib-test3.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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/>.
+
+
+original=testfile20
+indexed=testfile20.index
+. $srcdir/run-ranlib-test2.sh
diff --git a/tests/run-ranlib-test4.sh b/tests/run-ranlib-test4.sh
new file mode 100755
index 0000000..8070415
--- /dev/null
+++ b/tests/run-ranlib-test4.sh
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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/>.
+
+
+original=testfile21
+indexed=testfile21.index
+noindex=1
+. $srcdir/run-ranlib-test2.sh
diff --git a/tests/run-readelf-A.sh b/tests/run-readelf-A.sh
new file mode 100755
index 0000000..b7432be
--- /dev/null
+++ b/tests/run-readelf-A.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2014 Red Hat, Inc.
+# Copyright (C) 2016 Oracle, 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-addrcfi.sh for testfilearm.
+
+# = testfileppc32attrs.s =
+# .gnu_attribute 8,1
+# .gnu_attribute 12,1
+#
+# gcc -m32 -c testfileppc32attrs.s
+
+# = testfilesparc64attrs.s =
+# .gnu_attribute 4,0x0aaaaaaa
+# .gnu_attribute 8,0x00000055
+#
+# gcc -c testfilesparc64attrs.s
+
+# = testfileppc64attrs.s =
+# .gnu_attribute 4,3
+#
+# gcc -c testfileppc64attrs.s
+
+testfiles testfilearm testfileppc32attrs.o testfilesparc64attrs.o testfileppc64attrs.o
+
+testrun_compare ${abs_top_builddir}/src/readelf -A testfilearm <<\EOF
+
+Object attributes section [27] '.ARM.attributes' of 53 bytes at offset 0x718:
+ Owner Size
+ aeabi 52
+ File: 42
+ CPU_name: 7-A
+ CPU_arch: v7
+ CPU_arch_profile: Application
+ ARM_ISA_use: Yes
+ THUMB_ISA_use: Thumb-2
+ VFP_arch: VFPv3-D16
+ ABI_PCS_wchar_t: 4
+ ABI_FP_rounding: Needed
+ ABI_FP_denormal: Needed
+ ABI_FP_exceptions: Needed
+ ABI_FP_number_model: IEEE 754
+ ABI_align8_needed: Yes
+ ABI_align8_preserved: Yes, except leaf SP
+ ABI_enum_size: int
+ ABI_HardFP_use: SP and DP
+ ABI_VFP_args: VFP registers
+ CPU_unaligned_access: v6
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf -A testfileppc32attrs.o <<\EOF
+
+Object attributes section [ 4] '.gnu.attributes' of 18 bytes at offset 0x34:
+ Owner Size
+ gnu 17
+ File: 9
+ GNU_Power_ABI_Vector: Generic
+ GNU_Power_ABI_Struct_Return: r3/r4
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf -A testfilesparc64attrs.o <<\EOF
+
+Object attributes section [ 4] '.gnu.attributes' of 21 bytes at offset 0x40:
+ Owner Size
+ gnu 20
+ File: 12
+ GNU_Sparc_HWCAPS: div32,v8plus,vis,asi_blk_init,vis3,random,fjfmau,asi_cache_sparing,des,camellia,sha1,sha512,mont,cbcond
+ GNU_Sparc_HWCAPS2: fjathplus,adp,mwait,xmont
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf -A testfileppc64attrs.o <<\EOF
+
+Object attributes section [ 4] '.gnu.attributes' of 16 bytes at offset 0x40:
+ Owner Size
+ gnu 15
+ File: 7
+ GNU_Power_ABI_FP: Single-precision hard float
+EOF
+
+exit 0
diff --git a/tests/run-readelf-aranges.sh b/tests/run-readelf-aranges.sh
new file mode 100755
index 0000000..3fc3c54
--- /dev/null
+++ b/tests/run-readelf-aranges.sh
@@ -0,0 +1,161 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+# Tests readelf --debug-dump=aranges and --debug-dump=decodedaranges
+#
+# - foobarbaz.h
+#
+# int bar ();
+# int baz (int i);
+#
+# - bar.c
+#
+# #include "foobarbaz.h"
+#
+# static int bi;
+#
+# static int
+# barbaz (int i)
+# {
+# return i * 2 - 1;
+# }
+#
+# __attribute__ ((constructor)) void
+# nobar ()
+# {
+# bi = 1;
+# }
+#
+# int
+# bar ()
+# {
+# bi++;
+# return barbaz (bi);
+# }
+#
+# - foo.c
+#
+# include "foobarbaz.h"
+#
+# static int fi = 0;
+#
+# static int
+# foo (int i, int j)
+# {
+# if (i > j)
+# return i - j + fi;
+# else
+# return (2 * j) - i + fi;
+# }
+#
+# int
+# main (int argc, char **argv)
+# {
+# int a = bar ();
+# int b = baz (a + argc);
+# int r = foo (a, b) - 1;
+#
+# return r - 48;
+# }
+#
+# - baz.c
+# include "foobarbaz.h"
+#
+# static int bj;
+#
+# static int
+# bazbaz (int j)
+# {
+# return bj * j - bar ();
+# }
+#
+# __attribute__ ((constructor)) void
+# nobaz ()
+# {
+# bj = 1;
+# }
+#
+# int
+# baz (int i)
+# {
+# if (i < 0)
+# return bazbaz (i);
+# else
+# {
+# while (i-- > 0)
+# bj += bar ();
+# }
+# return bazbaz (i);
+# }
+#
+# gcc -g -O2 -m32 -c baz.c
+# gcc -g -O2 -m32 -c bar.c
+# gcc -g -O2 -m32 -c foo.c
+# gcc -g -O2 -m32 -o testfilefoobarbaz foo.o bar.o baz.o
+
+testfiles testfilefoobarbaz
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=aranges testfilefoobarbaz <<EOF
+
+DWARF section [27] '.debug_aranges' at offset 0x1044:
+
+Table at offset 0:
+
+ Length: 28
+ DWARF version: 2
+ CU offset: 0
+ Address size: 4
+ Segment size: 0
+
+ 0x080482f0 <main>..0x08048323 <main+0x33>
+
+Table at offset 32:
+
+ Length: 36
+ DWARF version: 2
+ CU offset: 136
+ Address size: 4
+ Segment size: 0
+
+ 0x08048440 <bar>..0x08048451 <bar+0x11>
+ 0x08048330 <nobar>..0x0804833a <nobar+0xa>
+
+Table at offset 72:
+
+ Length: 36
+ DWARF version: 2
+ CU offset: 1d1
+ Address size: 4
+ Segment size: 0
+
+ 0x08048460 <baz>..0x080484bb <baz+0x5b>
+ 0x08048340 <nobaz>..0x0804834a <nobaz+0xa>
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=decodedaranges testfilefoobarbaz <<\EOF
+
+DWARF section [27] '.debug_aranges' at offset 0x1044 contains 5 entries:
+ [0] start: 0x080482f0, length: 52, CU DIE offset: 11
+ [1] start: 0x08048330, length: 11, CU DIE offset: 321
+ [2] start: 0x08048340, length: 11, CU DIE offset: 476
+ [3] start: 0x08048440, length: 18, CU DIE offset: 321
+ [4] start: 0x08048460, length: 92, CU DIE offset: 476
+EOF
+
+exit 0
diff --git a/tests/run-readelf-d.sh b/tests/run-readelf-d.sh
new file mode 100755
index 0000000..d0b6ed2
--- /dev/null
+++ b/tests/run-readelf-d.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+
+# #include <stdio.h>
+#
+# __thread int i;
+#
+# void print_i ()
+# {
+# printf("%d\n", i);
+# }
+#
+# gcc -fPIC -shared -o testlib_dynseg.so testlib_dynseg.c
+# With ld --version
+# GNU gold (GNU Binutils 2.22.52.20120402) 1.11
+
+testfiles testlib_dynseg.so
+
+testrun_compare ${abs_top_builddir}/src/readelf -d testlib_dynseg.so <<\EOF
+
+Dynamic segment contains 28 entries:
+ Addr: 0x00000000000017e0 Offset: 0x0007e0 Link to section: [ 3] '.dynstr'
+ Type Value
+ PLTGOT 0x00000000000019c8
+ PLTRELSZ 72 (bytes)
+ JMPREL 0x0000000000000568
+ PLTREL RELA
+ RELA 0x00000000000004d8
+ RELASZ 144 (bytes)
+ RELAENT 24 (bytes)
+ RELACOUNT 1
+ SYMTAB 0x0000000000000228
+ SYMENT 24 (bytes)
+ STRTAB 0x0000000000000360
+ STRSZ 190 (bytes)
+ GNU_HASH 0x0000000000000420
+ NEEDED Shared library: [libc.so.6]
+ NEEDED Shared library: [ld-linux-x86-64.so.2]
+ INIT 0x00000000000005b0
+ FINI 0x0000000000000748
+ VERSYM 0x0000000000000460
+ VERDEF 0x000000000000047c
+ VERDEFNUM 1
+ VERNEED 0x0000000000000498
+ VERNEEDNUM 2
+ NULL
+ NULL
+ NULL
+ NULL
+ NULL
+ NULL
+EOF
+
+exit 0
diff --git a/tests/run-readelf-dwz-multi.sh b/tests/run-readelf-dwz-multi.sh
new file mode 100755
index 0000000..4f317ac
--- /dev/null
+++ b/tests/run-readelf-dwz-multi.sh
@@ -0,0 +1,332 @@
+#! /bin/sh
+# Copyright (C) 2012, 2013 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
+
+# common.h
+#
+# #include <stdio.h>
+#
+# struct foobar
+# {
+# int foo;
+# struct foobar *bar;
+# };
+#
+# extern int call_foo(struct foobar *foobar_struct_ptr);
+
+# main.c
+#
+# #include "common.h"
+#
+# int main(int argc, char ** argv)
+# {
+# struct foobar b;
+# b.foo = 42;
+# b.bar = &b;
+#
+# return call_foo(b.bar);
+# }
+
+# shared.c
+#
+# #include "common.h"
+#
+# int call_foo(struct foobar *fb)
+# {
+# return fb->bar->foo - 42;
+# }
+
+# gcc -fPIC -g -c -Wall shared.c
+# gcc -shared -o libtestfile_multi_shared.so shared.o
+# gcc -g -o testfile_multi_main -L. -ltestfile_multi_shared main.c -Wl,-rpath,.
+# dwz -m testfile_multi.dwz testfile_multi_main libtestfile_multi_shared.so
+
+# main.c
+#
+# struct foobarbaz
+# {
+# int counter;
+# char *bookstore;
+# };
+#
+# int
+# main (int argc, char **argv)
+# {
+# struct foobarbaz fbb;
+# return 0;
+# }
+
+# gcc -g -o testfile-dwzstr main.c
+# cp testfile-dwzstr testfile-dwzstr.alt
+# dwz -m testfile-dwzstr.multi testfile-dwzstr testfile-dwzstr.alt
+
+testfiles libtestfile_multi_shared.so testfile_multi_main testfile_multi.dwz
+testfiles testfile-dwzstr testfile-dwzstr.multi
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info testfile_multi_main <<\EOF
+
+DWARF section [28] '.debug_info' at offset 0x1078:
+ [Offset]
+ Compilation unit at offset 0:
+ Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
+ [ b] compile_unit abbrev: 6
+ producer (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -mtune=generic -march=x86-64 -g"
+ language (data1) C89 (1)
+ name (strp) "main.c"
+ comp_dir (GNU_strp_alt) "/home/mark/src/tests/dwz"
+ low_pc (addr) 0x00000000004006ac <main>
+ high_pc (udata) 44 (0x00000000004006d8)
+ stmt_list (sec_offset) 0
+ [ 26] imported_unit abbrev: 5
+ import (GNU_ref_alt) [ b]
+ [ 2b] pointer_type abbrev: 1
+ byte_size (data1) 8
+ type (GNU_ref_alt) [ 53]
+ [ 31] subprogram abbrev: 3
+ external (flag_present) yes
+ name (strp) "main"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 3
+ prototyped (flag_present) yes
+ type (GNU_ref_alt) [ 3e]
+ low_pc (addr) 0x00000000004006ac <main>
+ high_pc (udata) 44 (0x00000000004006d8)
+ frame_base (exprloc)
+ [ 0] call_frame_cfa
+ GNU_all_tail_call_sites (flag_present) yes
+ sibling (ref_udata) [ 6e]
+ [ 48] formal_parameter abbrev: 8
+ name (strp) "argc"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 3
+ type (GNU_ref_alt) [ 3e]
+ location (exprloc)
+ [ 0] fbreg -36
+ [ 56] formal_parameter abbrev: 4
+ name (strp) "argv"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 3
+ type (ref_udata) [ 6e]
+ location (exprloc)
+ [ 0] fbreg -48
+ [ 61] variable abbrev: 7
+ name (string) "b"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 5
+ type (GNU_ref_alt) [ 5a]
+ location (exprloc)
+ [ 0] fbreg -32
+ [ 6e] pointer_type abbrev: 2
+ byte_size (data1) 8
+ type (ref_udata) [ 2b]
+EOF
+
+# Same as above, but find alt debug file in a .dwz subdir.
+mkdir .dwz
+mv testfile_multi.dwz .dwz
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info testfile_multi_main <<\EOF
+
+DWARF section [28] '.debug_info' at offset 0x1078:
+ [Offset]
+ Compilation unit at offset 0:
+ Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
+ [ b] compile_unit abbrev: 6
+ producer (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -mtune=generic -march=x86-64 -g"
+ language (data1) C89 (1)
+ name (strp) "main.c"
+ comp_dir (GNU_strp_alt) "/home/mark/src/tests/dwz"
+ low_pc (addr) 0x00000000004006ac <main>
+ high_pc (udata) 44 (0x00000000004006d8)
+ stmt_list (sec_offset) 0
+ [ 26] imported_unit abbrev: 5
+ import (GNU_ref_alt) [ b]
+ [ 2b] pointer_type abbrev: 1
+ byte_size (data1) 8
+ type (GNU_ref_alt) [ 53]
+ [ 31] subprogram abbrev: 3
+ external (flag_present) yes
+ name (strp) "main"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 3
+ prototyped (flag_present) yes
+ type (GNU_ref_alt) [ 3e]
+ low_pc (addr) 0x00000000004006ac <main>
+ high_pc (udata) 44 (0x00000000004006d8)
+ frame_base (exprloc)
+ [ 0] call_frame_cfa
+ GNU_all_tail_call_sites (flag_present) yes
+ sibling (ref_udata) [ 6e]
+ [ 48] formal_parameter abbrev: 8
+ name (strp) "argc"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 3
+ type (GNU_ref_alt) [ 3e]
+ location (exprloc)
+ [ 0] fbreg -36
+ [ 56] formal_parameter abbrev: 4
+ name (strp) "argv"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 3
+ type (ref_udata) [ 6e]
+ location (exprloc)
+ [ 0] fbreg -48
+ [ 61] variable abbrev: 7
+ name (string) "b"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 5
+ type (GNU_ref_alt) [ 5a]
+ location (exprloc)
+ [ 0] fbreg -32
+ [ 6e] pointer_type abbrev: 2
+ byte_size (data1) 8
+ type (ref_udata) [ 2b]
+EOF
+mv .dwz/testfile_multi.dwz .
+rmdir .dwz
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info libtestfile_multi_shared.so <<\EOF
+
+DWARF section [25] '.debug_info' at offset 0x106c:
+ [Offset]
+ Compilation unit at offset 0:
+ Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
+ [ b] compile_unit abbrev: 3
+ producer (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -fpreprocessed -mtune=generic -march=x86-64 -g -fPIC"
+ language (data1) C89 (1)
+ name (strp) "shared.c"
+ comp_dir (GNU_strp_alt) "/home/mark/src/tests/dwz"
+ low_pc (addr) +0x0000000000000670 <call_foo>
+ high_pc (udata) 23 (+0x0000000000000687)
+ stmt_list (sec_offset) 0
+ [ 26] imported_unit abbrev: 2
+ import (GNU_ref_alt) [ b]
+ [ 2b] subprogram abbrev: 1
+ external (flag_present) yes
+ name (strp) "call_foo"
+ decl_file (data1) shared.c (1)
+ decl_line (data1) 3
+ prototyped (flag_present) yes
+ type (GNU_ref_alt) [ 3e]
+ low_pc (addr) +0x0000000000000670 <call_foo>
+ high_pc (udata) 23 (+0x0000000000000687)
+ frame_base (exprloc)
+ [ 0] call_frame_cfa
+ GNU_all_call_sites (flag_present) yes
+ [ 41] formal_parameter abbrev: 4
+ name (string) "fb"
+ decl_file (data1) shared.c (1)
+ decl_line (data1) 3
+ type (GNU_ref_alt) [ 76]
+ location (exprloc)
+ [ 0] fbreg -24
+EOF
+
+# Same as above, but find alt debug file in a .dwz subdir.
+mkdir .dwz
+mv testfile_multi.dwz .dwz
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info libtestfile_multi_shared.so <<\EOF
+
+DWARF section [25] '.debug_info' at offset 0x106c:
+ [Offset]
+ Compilation unit at offset 0:
+ Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
+ [ b] compile_unit abbrev: 3
+ producer (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -fpreprocessed -mtune=generic -march=x86-64 -g -fPIC"
+ language (data1) C89 (1)
+ name (strp) "shared.c"
+ comp_dir (GNU_strp_alt) "/home/mark/src/tests/dwz"
+ low_pc (addr) +0x0000000000000670 <call_foo>
+ high_pc (udata) 23 (+0x0000000000000687)
+ stmt_list (sec_offset) 0
+ [ 26] imported_unit abbrev: 2
+ import (GNU_ref_alt) [ b]
+ [ 2b] subprogram abbrev: 1
+ external (flag_present) yes
+ name (strp) "call_foo"
+ decl_file (data1) shared.c (1)
+ decl_line (data1) 3
+ prototyped (flag_present) yes
+ type (GNU_ref_alt) [ 3e]
+ low_pc (addr) +0x0000000000000670 <call_foo>
+ high_pc (udata) 23 (+0x0000000000000687)
+ frame_base (exprloc)
+ [ 0] call_frame_cfa
+ GNU_all_call_sites (flag_present) yes
+ [ 41] formal_parameter abbrev: 4
+ name (string) "fb"
+ decl_file (data1) shared.c (1)
+ decl_line (data1) 3
+ type (GNU_ref_alt) [ 76]
+ location (exprloc)
+ [ 0] fbreg -24
+EOF
+mv .dwz/testfile_multi.dwz .
+rmdir .dwz
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info testfile-dwzstr <<\EOF
+
+DWARF section [28] '.debug_info' at offset 0x1088:
+ [Offset]
+ Compilation unit at offset 0:
+ Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
+ [ b] compile_unit abbrev: 5
+ producer (GNU_strp_alt) "GNU C 4.7.2 20121109 (Red Hat 4.7.2-8) -mtune=generic -march=x86-64 -g"
+ language (data1) C89 (1)
+ name (GNU_strp_alt) "main.c"
+ comp_dir (GNU_strp_alt) "/home/mark/src/tests"
+ low_pc (addr) 0x00000000004004ec <main>
+ high_pc (udata) 18 (0x00000000004004fe)
+ stmt_list (sec_offset) 0
+ [ 26] imported_unit abbrev: 2
+ import (GNU_ref_alt) [ b]
+ [ 2b] subprogram abbrev: 4
+ external (flag_present) yes
+ name (GNU_strp_alt) "main"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 8
+ prototyped (flag_present) yes
+ type (GNU_ref_alt) [ 30]
+ low_pc (addr) 0x00000000004004ec <main>
+ high_pc (udata) 18 (0x00000000004004fe)
+ frame_base (exprloc)
+ [ 0] call_frame_cfa
+ GNU_all_call_sites (flag_present) yes
+ [ 41] formal_parameter abbrev: 1
+ name (GNU_strp_alt) "argc"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 8
+ type (GNU_ref_alt) [ 30]
+ location (exprloc)
+ [ 0] fbreg -36
+ [ 4f] formal_parameter abbrev: 1
+ name (GNU_strp_alt) "argv"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 8
+ type (GNU_ref_alt) [ 41]
+ location (exprloc)
+ [ 0] fbreg -48
+ [ 5d] variable abbrev: 3
+ name (string) "fbb"
+ decl_file (data1) main.c (1)
+ decl_line (data1) 10
+ type (GNU_ref_alt) [ 14]
+ location (exprloc)
+ [ 0] fbreg -32
+EOF
+
+exit 0
diff --git a/tests/run-readelf-gdb_index.sh b/tests/run-readelf-gdb_index.sh
new file mode 100755
index 0000000..fcbc3c5
--- /dev/null
+++ b/tests/run-readelf-gdb_index.sh
@@ -0,0 +1,130 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+
+# common.h
+# struct foo
+# {
+# const char *bar;
+# };
+#
+# extern char *global;
+# int say (struct foo *prefix);
+
+# hello.c
+# #include "common.h"
+#
+# static char *hello = "Hello";
+#
+# int
+# main (int argc, char **argv)
+# {
+# struct foo baz;
+# global = hello;
+# baz.bar = global;
+# return say(&baz);
+# }
+
+# world.c
+# #include "common.h"
+#
+# char *global;
+#
+# static int hello (const char *bar)
+# {
+# return bar == global;
+# }
+#
+# int
+# say (struct foo *prefix)
+# {
+# return hello (prefix->bar);
+# }
+
+# gcc -g -fdebug-types-section -c hello.c
+# gcc -g -fdebug-types-section -c world.c
+# gcc -g -fdebug-types-section -o testfilegdbindex7 hello.o world.o
+# gdb testfilegdbindex7
+# (gdb) save gdb-index .
+# objcopy --add-section .gdb_index=testfilegdbindex7.gdb-index --set-section-flags .gdb_index=readonly testfilegdbindex7 testfilegdbindex7
+
+testfiles testfilegdbindex5 testfilegdbindex7
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=gdb_index testfilegdbindex5 <<\EOF
+
+GDB section [33] '.gdb_index' at offset 0xe76 contains 8383 bytes :
+ Version: 5
+ CU offset: 0x18
+ TU offset: 0x38
+ address offset: 0x50
+ symbol offset: 0x78
+ constant offset: 0x2078
+
+ CU list at offset 0x18 contains 2 entries:
+ [ 0] start: 00000000, length: 184
+ [ 1] start: 0x0000b8, length: 204
+
+ TU list at offset 0x38 contains 1 entries:
+ [ 0] CU offset: 0, type offset: 29, signature: 0x87e03f92cc37cdf0
+
+ Address list at offset 0x50 contains 2 entries:
+ [ 0] 0x000000000040049c <main>..0x00000000004004d1 <main+0x35>, CU index: 0
+ [ 1] 0x00000000004004d4 <hello>..0x000000000040050b <say+0x1c>, CU index: 1
+
+ Symbol table at offset 0x50 contains 1024 slots:
+ [ 123] symbol: global, CUs: 1
+ [ 489] symbol: main, CUs: 0
+ [ 518] symbol: char, CUs: 0
+ [ 661] symbol: foo, CUs: 0T
+ [ 741] symbol: hello, CUs: 0, 1
+ [ 746] symbol: say, CUs: 1
+ [ 754] symbol: int, CUs: 0
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=gdb_index testfilegdbindex7 <<\EOF
+
+GDB section [33] '.gdb_index' at offset 0xe76 contains 8399 bytes :
+ Version: 7
+ CU offset: 0x18
+ TU offset: 0x38
+ address offset: 0x50
+ symbol offset: 0x78
+ constant offset: 0x2078
+
+ CU list at offset 0x18 contains 2 entries:
+ [ 0] start: 00000000, length: 184
+ [ 1] start: 0x0000b8, length: 204
+
+ TU list at offset 0x38 contains 1 entries:
+ [ 0] CU offset: 0, type offset: 29, signature: 0x87e03f92cc37cdf0
+
+ Address list at offset 0x50 contains 2 entries:
+ [ 0] 0x000000000040049c <main>..0x00000000004004d1 <main+0x35>, CU index: 0
+ [ 1] 0x00000000004004d4 <hello>..0x000000000040050b <say+0x1c>, CU index: 1
+
+ Symbol table at offset 0x50 contains 1024 slots:
+ [ 123] symbol: global, CUs: 1 (var:G)
+ [ 489] symbol: main, CUs: 0 (func:G)
+ [ 518] symbol: char, CUs: 0 (type:S)
+ [ 661] symbol: foo, CUs: 0T (type:S)
+ [ 741] symbol: hello, CUs: 0 (var:S), 1 (func:S)
+ [ 746] symbol: say, CUs: 1 (func:G)
+ [ 754] symbol: int, CUs: 0 (type:S)
+EOF
+
+exit 0
diff --git a/tests/run-readelf-line.sh b/tests/run-readelf-line.sh
new file mode 100755
index 0000000..32bcf9d
--- /dev/null
+++ b/tests/run-readelf-line.sh
@@ -0,0 +1,259 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+# Tests readelf --debug-dump=line and --debug-dump=decodedline
+# See run-readelf-aranges for testfiles.
+
+testfiles testfilefoobarbaz
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=line testfilefoobarbaz <<EOF
+
+DWARF section [30] '.debug_line' at offset 0x15f6:
+
+Table at offset 0:
+
+ Length: 83
+ DWARF version: 2
+ Prologue length: 43
+ Minimum instruction length: 1
+ Maximum operations per instruction: 1
+ Initial value if 'is_stmt': 1
+ Line base: -5
+ Line range: 14
+ Opcode base: 13
+
+Opcodes:
+ [ 1] 0 arguments
+ [ 2] 1 argument
+ [ 3] 1 argument
+ [ 4] 1 argument
+ [ 5] 1 argument
+ [ 6] 0 arguments
+ [ 7] 0 arguments
+ [ 8] 0 arguments
+ [ 9] 1 argument
+ [10] 0 arguments
+ [11] 0 arguments
+ [12] 1 argument
+
+Directory table:
+
+File name table:
+ Entry Dir Time Size Name
+ 1 0 0 0 foo.c
+ 2 0 0 0 foobarbaz.h
+
+Line number statements:
+ [ 35] extended opcode 2: set address to 0x80482f0 <main>
+ [ 3c] advance line by constant 15 to 16
+ [ 3e] copy
+ [ 3f] special opcode 159: address+10 = 0x80482fa <main+0xa>, line+1 = 17
+ [ 40] special opcode 117: address+7 = 0x8048301 <main+0x11>, line+1 = 18
+ [ 41] advance line by constant -9 to 9
+ [ 43] special opcode 200: address+13 = 0x804830e <main+0x1e>, line+0 = 9
+ [ 44] special opcode 48: address+2 = 0x8048310 <main+0x20>, line+2 = 11
+ [ 45] special opcode 58: address+3 = 0x8048313 <main+0x23>, line-2 = 9
+ [ 46] special opcode 48: address+2 = 0x8048315 <main+0x25>, line+2 = 11
+ [ 47] special opcode 44: address+2 = 0x8048317 <main+0x27>, line-2 = 9
+ [ 48] advance line by constant 13 to 22
+ [ 4a] special opcode 46: address+2 = 0x8048319 <main+0x29>, line+0 = 22
+ [ 4b] advance line by constant -13 to 9
+ [ 4d] special opcode 60: address+3 = 0x804831c <main+0x2c>, line+0 = 9
+ [ 4e] advance line by constant 12 to 21
+ [ 50] special opcode 60: address+3 = 0x804831f <main+0x2f>, line+0 = 21
+ [ 51] special opcode 61: address+3 = 0x8048322 <main+0x32>, line+1 = 22
+ [ 52] advance address by 2 to 0x8048324
+ [ 54] extended opcode 1: end of sequence
+
+Table at offset 87:
+
+ Length: 72
+ DWARF version: 2
+ Prologue length: 28
+ Minimum instruction length: 1
+ Maximum operations per instruction: 1
+ Initial value if 'is_stmt': 1
+ Line base: -5
+ Line range: 14
+ Opcode base: 13
+
+Opcodes:
+ [ 1] 0 arguments
+ [ 2] 1 argument
+ [ 3] 1 argument
+ [ 4] 1 argument
+ [ 5] 1 argument
+ [ 6] 0 arguments
+ [ 7] 0 arguments
+ [ 8] 0 arguments
+ [ 9] 1 argument
+ [10] 0 arguments
+ [11] 0 arguments
+ [12] 1 argument
+
+Directory table:
+
+File name table:
+ Entry Dir Time Size Name
+ 1 0 0 0 bar.c
+
+Line number statements:
+ [ 7d] extended opcode 2: set address to 0x8048330 <nobar>
+ [ 84] advance line by constant 12 to 13
+ [ 86] copy
+ [ 87] special opcode 19: address+0 = 0x8048330 <nobar>, line+1 = 14
+ [ 88] advance address by 11 to 0x804833b
+ [ 8a] extended opcode 1: end of sequence
+ [ 8d] extended opcode 2: set address to 0x8048440 <bar>
+ [ 94] advance line by constant 18 to 19
+ [ 96] copy
+ [ 97] special opcode 19: address+0 = 0x8048440 <bar>, line+1 = 20
+ [ 98] advance line by constant -12 to 8
+ [ 9a] special opcode 200: address+13 = 0x804844d <bar+0xd>, line+0 = 8
+ [ 9b] advance line by constant 14 to 22
+ [ 9d] special opcode 74: address+4 = 0x8048451 <bar+0x11>, line+0 = 22
+ [ 9e] advance address by 1 to 0x8048452
+ [ a0] extended opcode 1: end of sequence
+
+Table at offset 163:
+
+ Length: 106
+ DWARF version: 2
+ Prologue length: 43
+ Minimum instruction length: 1
+ Maximum operations per instruction: 1
+ Initial value if 'is_stmt': 1
+ Line base: -5
+ Line range: 14
+ Opcode base: 13
+
+Opcodes:
+ [ 1] 0 arguments
+ [ 2] 1 argument
+ [ 3] 1 argument
+ [ 4] 1 argument
+ [ 5] 1 argument
+ [ 6] 0 arguments
+ [ 7] 0 arguments
+ [ 8] 0 arguments
+ [ 9] 1 argument
+ [10] 0 arguments
+ [11] 0 arguments
+ [12] 1 argument
+
+Directory table:
+
+File name table:
+ Entry Dir Time Size Name
+ 1 0 0 0 baz.c
+ 2 0 0 0 foobarbaz.h
+
+Line number statements:
+ [ d8] extended opcode 2: set address to 0x8048340 <nobaz>
+ [ df] advance line by constant 12 to 13
+ [ e1] copy
+ [ e2] special opcode 19: address+0 = 0x8048340 <nobaz>, line+1 = 14
+ [ e3] advance address by 11 to 0x804834b
+ [ e5] extended opcode 1: end of sequence
+ [ e8] extended opcode 2: set address to 0x8048460 <baz>
+ [ ef] advance line by constant 18 to 19
+ [ f1] copy
+ [ f2] special opcode 74: address+4 = 0x8048464 <baz+0x4>, line+0 = 19
+ [ f3] special opcode 75: address+4 = 0x8048468 <baz+0x8>, line+1 = 20
+ [ f4] extended opcode 4: set discriminator to 1
+ [ f8] special opcode 78: address+4 = 0x804846c <baz+0xc>, line+4 = 24
+ [ f9] special opcode 187: address+12 = 0x8048478 <baz+0x18>, line+1 = 25
+ [ fa] special opcode 87: address+5 = 0x804847d <baz+0x1d>, line-1 = 24
+ [ fb] special opcode 61: address+3 = 0x8048480 <baz+0x20>, line+1 = 25
+ [ fc] special opcode 101: address+6 = 0x8048486 <baz+0x26>, line-1 = 24
+ [ fd] special opcode 61: address+3 = 0x8048489 <baz+0x29>, line+1 = 25
+ [ fe] special opcode 87: address+5 = 0x804848e <baz+0x2e>, line-1 = 24
+ [ ff] advance line by constant -16 to 8
+ [ 101] special opcode 46: address+2 = 0x8048490 <baz+0x30>, line+0 = 8
+ [ 102] advance line by constant 20 to 28
+ [ 104] special opcode 186: address+12 = 0x804849c <baz+0x3c>, line+0 = 28
+ [ 105] advance line by constant -20 to 8
+ [ 107] special opcode 88: address+5 = 0x80484a1 <baz+0x41>, line+0 = 8
+ [ 108] advance line by constant 13 to 21
+ [ 10a] advance address by constant 17 to 0x80484b2 <baz+0x52>
+ [ 10b] special opcode 32: address+1 = 0x80484b3 <baz+0x53>, line+0 = 21
+ [ 10c] advance address by 9 to 0x80484bc
+ [ 10e] extended opcode 1: end of sequence
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=decodedline testfilefoobarbaz <<\EOF
+
+DWARF section [30] '.debug_line' at offset 0x15f6:
+
+ CU [b] foo.c
+ line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End)
+ /home/mark/src/tests/foobarbaz/foo.c (mtime: 0, length: 0)
+ 16:0 S 0 0 0 0x080482f0 <main>
+ 17:0 S 0 0 0 0x080482fa <main+0xa>
+ 18:0 S 0 0 0 0x08048301 <main+0x11>
+ 9:0 S 0 0 0 0x0804830e <main+0x1e>
+ 11:0 S 0 0 0 0x08048310 <main+0x20>
+ 9:0 S 0 0 0 0x08048313 <main+0x23>
+ 11:0 S 0 0 0 0x08048315 <main+0x25>
+ 9:0 S 0 0 0 0x08048317 <main+0x27>
+ 22:0 S 0 0 0 0x08048319 <main+0x29>
+ 9:0 S 0 0 0 0x0804831c <main+0x2c>
+ 21:0 S 0 0 0 0x0804831f <main+0x2f>
+ 22:0 S 0 0 0 0x08048322 <main+0x32>
+ 22:0 S * 0 0 0 0x08048323 <main+0x33>
+
+ CU [141] bar.c
+ line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End)
+ /home/mark/src/tests/foobarbaz/bar.c (mtime: 0, length: 0)
+ 13:0 S 0 0 0 0x08048330 <nobar>
+ 14:0 S 0 0 0 0x08048330 <nobar>
+ 14:0 S * 0 0 0 0x0804833a <nobar+0xa>
+
+ 19:0 S 0 0 0 0x08048440 <bar>
+ 20:0 S 0 0 0 0x08048440 <bar>
+ 8:0 S 0 0 0 0x0804844d <bar+0xd>
+ 22:0 S 0 0 0 0x08048451 <bar+0x11>
+ 22:0 S * 0 0 0 0x08048451 <bar+0x11>
+
+ CU [1dc] baz.c
+ line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End)
+ /home/mark/src/tests/foobarbaz/baz.c (mtime: 0, length: 0)
+ 13:0 S 0 0 0 0x08048340 <nobaz>
+ 14:0 S 0 0 0 0x08048340 <nobaz>
+ 14:0 S * 0 0 0 0x0804834a <nobaz+0xa>
+
+ 19:0 S 0 0 0 0x08048460 <baz>
+ 19:0 S 0 0 0 0x08048464 <baz+0x4>
+ 20:0 S 0 0 0 0x08048468 <baz+0x8>
+ 24:0 S 1 0 0 0x0804846c <baz+0xc>
+ 25:0 S 0 0 0 0x08048478 <baz+0x18>
+ 24:0 S 0 0 0 0x0804847d <baz+0x1d>
+ 25:0 S 0 0 0 0x08048480 <baz+0x20>
+ 24:0 S 0 0 0 0x08048486 <baz+0x26>
+ 25:0 S 0 0 0 0x08048489 <baz+0x29>
+ 24:0 S 0 0 0 0x0804848e <baz+0x2e>
+ 8:0 S 0 0 0 0x08048490 <baz+0x30>
+ 28:0 S 0 0 0 0x0804849c <baz+0x3c>
+ 8:0 S 0 0 0 0x080484a1 <baz+0x41>
+ 21:0 S 0 0 0 0x080484b3 <baz+0x53>
+ 21:0 S * 0 0 0 0x080484bb <baz+0x5b>
+
+EOF
+
+exit 0
diff --git a/tests/run-readelf-loc.sh b/tests/run-readelf-loc.sh
new file mode 100755
index 0000000..e5152df
--- /dev/null
+++ b/tests/run-readelf-loc.sh
@@ -0,0 +1,170 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+# - hello.c
+# int say (const char *prefix);
+#
+# static char *
+# subject (char *word, int count)
+# {
+# return count > 0 ? word : (word + count);
+# }
+#
+# int
+# main (int argc, char **argv)
+# {
+# return say (subject (argv[0], argc));
+# }
+#
+# - world.c
+# static int
+# sad (char c)
+# {
+# return c > 0 ? c : c + 1;
+# }
+#
+# static int
+# happy (const char *w)
+# {
+# return sad (w[1]);
+# }
+#
+# int
+# say (const char *prefix)
+# {
+# const char *world = "World";
+# return prefix ? sad (prefix[0]) : happy (world);
+# }
+#
+# gcc -g -O2 -c hello.c
+# gcc -g -O2 -c world.c
+# gcc -g -o testfileloc hello.o world.o
+
+testfiles testfileloc
+
+# Process values as offsets from base addresses and resolve to symbols.
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=loc --debug-dump=ranges \
+ testfileloc<<\EOF
+
+DWARF section [33] '.debug_loc' at offset 0xd2a:
+
+ CU [ b] base: 0x0000000000400480 <main>
+ [ 0] range 0, d
+ 0x0000000000400480 <main>..
+ 0x000000000040048c <main+0xc>
+ [ 0] reg5
+ [ 23] range 5, d
+ 0x0000000000400485 <main+0x5>..
+ 0x000000000040048c <main+0xc>
+ [ 0] reg5
+
+ CU [ e0] base: 0x00000000004004a0 <say>
+ [ 46] range 12, 1a
+ 0x00000000004004b2 <say+0x12>..
+ 0x00000000004004b9 <say+0x19>
+ [ 0] breg5 0
+
+DWARF section [34] '.debug_ranges' at offset 0xd94:
+
+ CU [ b] base: 0x0000000000400480 <main>
+ [ 0] range 0, 2
+ 0x0000000000400480 <main>..
+ 0x0000000000400481 <main+0x1>
+ range 5, d
+ 0x0000000000400485 <main+0x5>..
+ 0x000000000040048c <main+0xc>
+
+ CU [ e0] base: 0x00000000004004a0 <say>
+ [ 30] range d, f
+ 0x00000000004004ad <say+0xd>..
+ 0x00000000004004ae <say+0xe>
+ range 12, 1a
+ 0x00000000004004b2 <say+0x12>..
+ 0x00000000004004b9 <say+0x19>
+EOF
+
+# Don't resolve addresses to symbols.
+testrun_compare ${abs_top_builddir}/src/readelf -N --debug-dump=loc --debug-dump=ranges \
+ testfileloc<<\EOF
+
+DWARF section [33] '.debug_loc' at offset 0xd2a:
+
+ CU [ b] base: 0x0000000000400480
+ [ 0] range 0, d
+ 0x0000000000400480..
+ 0x000000000040048c
+ [ 0] reg5
+ [ 23] range 5, d
+ 0x0000000000400485..
+ 0x000000000040048c
+ [ 0] reg5
+
+ CU [ e0] base: 0x00000000004004a0
+ [ 46] range 12, 1a
+ 0x00000000004004b2..
+ 0x00000000004004b9
+ [ 0] breg5 0
+
+DWARF section [34] '.debug_ranges' at offset 0xd94:
+
+ CU [ b] base: 0x0000000000400480
+ [ 0] range 0, 2
+ 0x0000000000400480..
+ 0x0000000000400481
+ range 5, d
+ 0x0000000000400485..
+ 0x000000000040048c
+
+ CU [ e0] base: 0x00000000004004a0
+ [ 30] range d, f
+ 0x00000000004004ad..
+ 0x00000000004004ae
+ range 12, 1a
+ 0x00000000004004b2..
+ 0x00000000004004b9
+EOF
+
+# Produce "raw" unprocessed content.
+testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc --debug-dump=ranges \
+ testfileloc<<\EOF
+
+DWARF section [33] '.debug_loc' at offset 0xd2a:
+
+ CU [ b] base: 0x0000000000400480
+ [ 0] range 0, d
+ [ 0] reg5
+ [ 23] range 5, d
+ [ 0] reg5
+
+ CU [ e0] base: 0x00000000004004a0
+ [ 46] range 12, 1a
+ [ 0] breg5 0
+
+DWARF section [34] '.debug_ranges' at offset 0xd94:
+
+ CU [ b] base: 0x0000000000400480
+ [ 0] range 0, 2
+ range 5, d
+
+ CU [ e0] base: 0x00000000004004a0
+ [ 30] range d, f
+ range 12, 1a
+EOF
+
+exit 0
diff --git a/tests/run-readelf-macro.sh b/tests/run-readelf-macro.sh
new file mode 100755
index 0000000..8693203
--- /dev/null
+++ b/tests/run-readelf-macro.sh
@@ -0,0 +1,345 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+
+# common.h
+# #define ONE 1
+# #define TWO 2
+# #define THREE 3
+#
+# #define WORLD "World"
+#
+# int say (const char *prefix);
+#
+# #define A 'a'
+# #define B b
+# #define C "C"
+#
+# #ifdef THREE
+# #undef THREE
+# #define THREE(ARG1,ARG2,ARG3) ARG3
+# #endif
+
+# hello.c
+# #include "common.h"
+#
+# int
+# main (int argc, char **argv)
+# {
+# return say (WORLD);
+# }
+
+# world.c
+# #include "common.h"
+#
+# int
+# say (const char *prefix)
+# {
+# return prefix ? ONE : TWO;
+# }
+
+# gcc -g3 -c hello.c
+# gcc -g3 -c world.c
+# gcc -g3 -o testfilemacro hello.o world.o
+
+testfiles testfilemacro
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=macro testfilemacro <<\EOF
+
+DWARF section [32] '.debug_macro' at offset 0x2480:
+
+ Offset: 0x0
+ Version: 4
+ Flag: 0x2
+ Offset length: 4
+ .debug_line offset: 0x0
+
+ #include offset 0x1a
+ start_file 0, [1] /home/mark/src/tests/hello.c
+ start_file 1, [2] /home/mark/src/tests/common.h
+ #include offset 0x582
+ end_file
+ end_file
+
+ Offset: 0x1a
+ Version: 4
+ Flag: 0x0
+ Offset length: 4
+
+ #define __STDC__ 1, line 1 (indirect)
+ #define __STDC_HOSTED__ 1, line 1 (indirect)
+ #define __GNUC__ 4, line 1 (indirect)
+ #define __GNUC_MINOR__ 7, line 1 (indirect)
+ #define __GNUC_PATCHLEVEL__ 1, line 1 (indirect)
+ #define __VERSION__ "4.7.1 20120629 (Red Hat 4.7.1-1)", line 1 (indirect)
+ #define __GNUC_RH_RELEASE__ 1, line 1 (indirect)
+ #define __ATOMIC_RELAXED 0, line 1 (indirect)
+ #define __ATOMIC_SEQ_CST 5, line 1 (indirect)
+ #define __ATOMIC_ACQUIRE 2, line 1 (indirect)
+ #define __ATOMIC_RELEASE 3, line 1 (indirect)
+ #define __ATOMIC_ACQ_REL 4, line 1 (indirect)
+ #define __ATOMIC_CONSUME 1, line 1 (indirect)
+ #define __FINITE_MATH_ONLY__ 0, line 1 (indirect)
+ #define _LP64 1, line 1 (indirect)
+ #define __LP64__ 1, line 1 (indirect)
+ #define __SIZEOF_INT__ 4, line 1 (indirect)
+ #define __SIZEOF_LONG__ 8, line 1 (indirect)
+ #define __SIZEOF_LONG_LONG__ 8, line 1 (indirect)
+ #define __SIZEOF_SHORT__ 2, line 1 (indirect)
+ #define __SIZEOF_FLOAT__ 4, line 1 (indirect)
+ #define __SIZEOF_DOUBLE__ 8, line 1 (indirect)
+ #define __SIZEOF_LONG_DOUBLE__ 16, line 1 (indirect)
+ #define __SIZEOF_SIZE_T__ 8, line 1 (indirect)
+ #define __CHAR_BIT__ 8, line 1 (indirect)
+ #define __BIGGEST_ALIGNMENT__ 16, line 1 (indirect)
+ #define __ORDER_LITTLE_ENDIAN__ 1234, line 1 (indirect)
+ #define __ORDER_BIG_ENDIAN__ 4321, line 1 (indirect)
+ #define __ORDER_PDP_ENDIAN__ 3412, line 1 (indirect)
+ #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__, line 1 (indirect)
+ #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__, line 1 (indirect)
+ #define __SIZEOF_POINTER__ 8, line 1 (indirect)
+ #define __SIZE_TYPE__ long unsigned int, line 1 (indirect)
+ #define __PTRDIFF_TYPE__ long int, line 1 (indirect)
+ #define __WCHAR_TYPE__ int, line 1 (indirect)
+ #define __WINT_TYPE__ unsigned int, line 1 (indirect)
+ #define __INTMAX_TYPE__ long int, line 1 (indirect)
+ #define __UINTMAX_TYPE__ long unsigned int, line 1 (indirect)
+ #define __CHAR16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __CHAR32_TYPE__ unsigned int, line 1 (indirect)
+ #define __SIG_ATOMIC_TYPE__ int, line 1 (indirect)
+ #define __INT8_TYPE__ signed char, line 1 (indirect)
+ #define __INT16_TYPE__ short int, line 1 (indirect)
+ #define __INT32_TYPE__ int, line 1 (indirect)
+ #define __INT64_TYPE__ long int, line 1 (indirect)
+ #define __UINT8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __UINT32_TYPE__ unsigned int, line 1 (indirect)
+ #define __UINT64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INT_LEAST8_TYPE__ signed char, line 1 (indirect)
+ #define __INT_LEAST16_TYPE__ short int, line 1 (indirect)
+ #define __INT_LEAST32_TYPE__ int, line 1 (indirect)
+ #define __INT_LEAST64_TYPE__ long int, line 1 (indirect)
+ #define __UINT_LEAST8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT_LEAST16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __UINT_LEAST32_TYPE__ unsigned int, line 1 (indirect)
+ #define __UINT_LEAST64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INT_FAST8_TYPE__ signed char, line 1 (indirect)
+ #define __INT_FAST16_TYPE__ long int, line 1 (indirect)
+ #define __INT_FAST32_TYPE__ long int, line 1 (indirect)
+ #define __INT_FAST64_TYPE__ long int, line 1 (indirect)
+ #define __UINT_FAST8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT_FAST16_TYPE__ long unsigned int, line 1 (indirect)
+ #define __UINT_FAST32_TYPE__ long unsigned int, line 1 (indirect)
+ #define __UINT_FAST64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INTPTR_TYPE__ long int, line 1 (indirect)
+ #define __UINTPTR_TYPE__ long unsigned int, line 1 (indirect)
+ #define __GXX_ABI_VERSION 1002, line 1 (indirect)
+ #define __SCHAR_MAX__ 127, line 1 (indirect)
+ #define __SHRT_MAX__ 32767, line 1 (indirect)
+ #define __INT_MAX__ 2147483647, line 1 (indirect)
+ #define __LONG_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __LONG_LONG_MAX__ 9223372036854775807LL, line 1 (indirect)
+ #define __WCHAR_MAX__ 2147483647, line 1 (indirect)
+ #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1), line 1 (indirect)
+ #define __WINT_MAX__ 4294967295U, line 1 (indirect)
+ #define __WINT_MIN__ 0U, line 1 (indirect)
+ #define __PTRDIFF_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __SIZE_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INTMAX_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INTMAX_C(c) c ## L, line 1 (indirect)
+ #define __UINTMAX_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINTMAX_C(c) c ## UL, line 1 (indirect)
+ #define __SIG_ATOMIC_MAX__ 2147483647, line 1 (indirect)
+ #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1), line 1 (indirect)
+ #define __INT8_MAX__ 127, line 1 (indirect)
+ #define __INT16_MAX__ 32767, line 1 (indirect)
+ #define __INT32_MAX__ 2147483647, line 1 (indirect)
+ #define __INT64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINT8_MAX__ 255, line 1 (indirect)
+ #define __UINT16_MAX__ 65535, line 1 (indirect)
+ #define __UINT32_MAX__ 4294967295U, line 1 (indirect)
+ #define __UINT64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INT_LEAST8_MAX__ 127, line 1 (indirect)
+ #define __INT8_C(c) c, line 1 (indirect)
+ #define __INT_LEAST16_MAX__ 32767, line 1 (indirect)
+ #define __INT16_C(c) c, line 1 (indirect)
+ #define __INT_LEAST32_MAX__ 2147483647, line 1 (indirect)
+ #define __INT32_C(c) c, line 1 (indirect)
+ #define __INT_LEAST64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT64_C(c) c ## L, line 1 (indirect)
+ #define __UINT_LEAST8_MAX__ 255, line 1 (indirect)
+ #define __UINT8_C(c) c, line 1 (indirect)
+ #define __UINT_LEAST16_MAX__ 65535, line 1 (indirect)
+ #define __UINT16_C(c) c, line 1 (indirect)
+ #define __UINT_LEAST32_MAX__ 4294967295U, line 1 (indirect)
+ #define __UINT32_C(c) c ## U, line 1 (indirect)
+ #define __UINT_LEAST64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT64_C(c) c ## UL, line 1 (indirect)
+ #define __INT_FAST8_MAX__ 127, line 1 (indirect)
+ #define __INT_FAST16_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT_FAST32_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT_FAST64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINT_FAST8_MAX__ 255, line 1 (indirect)
+ #define __UINT_FAST16_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT_FAST32_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT_FAST64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INTPTR_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINTPTR_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __FLT_EVAL_METHOD__ 0, line 1 (indirect)
+ #define __DEC_EVAL_METHOD__ 2, line 1 (indirect)
+ #define __FLT_RADIX__ 2, line 1 (indirect)
+ #define __FLT_MANT_DIG__ 24, line 1 (indirect)
+ #define __FLT_DIG__ 6, line 1 (indirect)
+ #define __FLT_MIN_EXP__ (-125), line 1 (indirect)
+ #define __FLT_MIN_10_EXP__ (-37), line 1 (indirect)
+ #define __FLT_MAX_EXP__ 128, line 1 (indirect)
+ #define __FLT_MAX_10_EXP__ 38, line 1 (indirect)
+ #define __FLT_DECIMAL_DIG__ 9, line 1 (indirect)
+ #define __FLT_MAX__ 3.40282346638528859812e+38F, line 1 (indirect)
+ #define __FLT_MIN__ 1.17549435082228750797e-38F, line 1 (indirect)
+ #define __FLT_EPSILON__ 1.19209289550781250000e-7F, line 1 (indirect)
+ #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F, line 1 (indirect)
+ #define __FLT_HAS_DENORM__ 1, line 1 (indirect)
+ #define __FLT_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __FLT_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __DBL_MANT_DIG__ 53, line 1 (indirect)
+ #define __DBL_DIG__ 15, line 1 (indirect)
+ #define __DBL_MIN_EXP__ (-1021), line 1 (indirect)
+ #define __DBL_MIN_10_EXP__ (-307), line 1 (indirect)
+ #define __DBL_MAX_EXP__ 1024, line 1 (indirect)
+ #define __DBL_MAX_10_EXP__ 308, line 1 (indirect)
+ #define __DBL_DECIMAL_DIG__ 17, line 1 (indirect)
+ #define __DBL_MAX__ ((double)1.79769313486231570815e+308L), line 1 (indirect)
+ #define __DBL_MIN__ ((double)2.22507385850720138309e-308L), line 1 (indirect)
+ #define __DBL_EPSILON__ ((double)2.22044604925031308085e-16L), line 1 (indirect)
+ #define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L), line 1 (indirect)
+ #define __DBL_HAS_DENORM__ 1, line 1 (indirect)
+ #define __DBL_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __DBL_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __LDBL_MANT_DIG__ 64, line 1 (indirect)
+ #define __LDBL_DIG__ 18, line 1 (indirect)
+ #define __LDBL_MIN_EXP__ (-16381), line 1 (indirect)
+ #define __LDBL_MIN_10_EXP__ (-4931), line 1 (indirect)
+ #define __LDBL_MAX_EXP__ 16384, line 1 (indirect)
+ #define __LDBL_MAX_10_EXP__ 4932, line 1 (indirect)
+ #define __DECIMAL_DIG__ 21, line 1 (indirect)
+ #define __LDBL_MAX__ 1.18973149535723176502e+4932L, line 1 (indirect)
+ #define __LDBL_MIN__ 3.36210314311209350626e-4932L, line 1 (indirect)
+ #define __LDBL_EPSILON__ 1.08420217248550443401e-19L, line 1 (indirect)
+ #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L, line 1 (indirect)
+ #define __LDBL_HAS_DENORM__ 1, line 1 (indirect)
+ #define __LDBL_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __LDBL_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __DEC32_MANT_DIG__ 7, line 1 (indirect)
+ #define __DEC32_MIN_EXP__ (-94), line 1 (indirect)
+ #define __DEC32_MAX_EXP__ 97, line 1 (indirect)
+ #define __DEC32_MIN__ 1E-95DF, line 1 (indirect)
+ #define __DEC32_MAX__ 9.999999E96DF, line 1 (indirect)
+ #define __DEC32_EPSILON__ 1E-6DF, line 1 (indirect)
+ #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF, line 1 (indirect)
+ #define __DEC64_MANT_DIG__ 16, line 1 (indirect)
+ #define __DEC64_MIN_EXP__ (-382), line 1 (indirect)
+ #define __DEC64_MAX_EXP__ 385, line 1 (indirect)
+ #define __DEC64_MIN__ 1E-383DD, line 1 (indirect)
+ #define __DEC64_MAX__ 9.999999999999999E384DD, line 1 (indirect)
+ #define __DEC64_EPSILON__ 1E-15DD, line 1 (indirect)
+ #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD, line 1 (indirect)
+ #define __DEC128_MANT_DIG__ 34, line 1 (indirect)
+ #define __DEC128_MIN_EXP__ (-6142), line 1 (indirect)
+ #define __DEC128_MAX_EXP__ 6145, line 1 (indirect)
+ #define __DEC128_MIN__ 1E-6143DL, line 1 (indirect)
+ #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL, line 1 (indirect)
+ #define __DEC128_EPSILON__ 1E-33DL, line 1 (indirect)
+ #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL, line 1 (indirect)
+ #define __REGISTER_PREFIX__ , line 1 (indirect)
+ #define __USER_LABEL_PREFIX__ , line 1 (indirect)
+ #define __GNUC_GNU_INLINE__ 1, line 1 (indirect)
+ #define __NO_INLINE__ 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1, line 1 (indirect)
+ #define __GCC_ATOMIC_BOOL_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_SHORT_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_INT_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_LONG_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_LLONG_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1, line 1 (indirect)
+ #define __GCC_ATOMIC_POINTER_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_HAVE_DWARF2_CFI_ASM 1, line 1 (indirect)
+ #define __PRAGMA_REDEFINE_EXTNAME 1, line 1 (indirect)
+ #define __SIZEOF_INT128__ 16, line 1 (indirect)
+ #define __SIZEOF_WCHAR_T__ 4, line 1 (indirect)
+ #define __SIZEOF_WINT_T__ 4, line 1 (indirect)
+ #define __SIZEOF_PTRDIFF_T__ 8, line 1 (indirect)
+ #define __amd64 1, line 1 (indirect)
+ #define __amd64__ 1, line 1 (indirect)
+ #define __x86_64 1, line 1 (indirect)
+ #define __x86_64__ 1, line 1 (indirect)
+ #define __k8 1, line 1 (indirect)
+ #define __k8__ 1, line 1 (indirect)
+ #define __MMX__ 1, line 1 (indirect)
+ #define __SSE__ 1, line 1 (indirect)
+ #define __SSE2__ 1, line 1 (indirect)
+ #define __SSE_MATH__ 1, line 1 (indirect)
+ #define __SSE2_MATH__ 1, line 1 (indirect)
+ #define __gnu_linux__ 1, line 1 (indirect)
+ #define __linux 1, line 1 (indirect)
+ #define __linux__ 1, line 1 (indirect)
+ #define linux 1, line 1 (indirect)
+ #define __unix 1, line 1 (indirect)
+ #define __unix__ 1, line 1 (indirect)
+ #define unix 1, line 1 (indirect)
+ #define __ELF__ 1, line 1 (indirect)
+ #define __DECIMAL_BID_FORMAT__ 1, line 1 (indirect)
+
+ Offset: 0x582
+ Version: 4
+ Flag: 0x0
+ Offset length: 4
+
+ #define ONE 1, line 1 (indirect)
+ #define TWO 2, line 2 (indirect)
+ #define THREE 3, line 3 (indirect)
+ #define WORLD "World", line 5 (indirect)
+ #define A 'a', line 9 (indirect)
+ #define B b, line 10
+ #define C "C", line 11 (indirect)
+ #undef THREE, line 14 (indirect)
+ #define THREE(ARG1,ARG2,ARG3) ARG3, line 15 (indirect)
+
+ Offset: 0x5bc
+ Version: 4
+ Flag: 0x2
+ Offset length: 4
+ .debug_line offset: 0x47
+
+ #include offset 0x1a
+ start_file 0, [1] /home/mark/src/tests/world.c
+ start_file 1, [2] /home/mark/src/tests/common.h
+ #include offset 0x582
+ end_file
+ end_file
+
+EOF
+
+exit 0
diff --git a/tests/run-readelf-mixed-corenote.sh b/tests/run-readelf-mixed-corenote.sh
new file mode 100755
index 0000000..86171c4
--- /dev/null
+++ b/tests/run-readelf-mixed-corenote.sh
@@ -0,0 +1,649 @@
+#! /bin/sh
+# Copyright (C) 2012, 2013, 2014 Red Hat, Inc.
+# Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
+# 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
+
+testfiles testfile63
+
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile63 <<\EOF
+
+Note segment of 892 bytes at offset 0x274:
+ Owner Data size Type
+ CORE 148 PRSTATUS
+ info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
+ sigpend: <>
+ sighold: <>
+ pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063
+ utime: 0.000000, stime: 0.010000, cutime: 0.000000, cstime: 0.000000
+ orig_r0: -1, fpvalid: 1
+ r0: 1 r1: -1091672508 r2: -1091672500
+ r3: 0 r4: 0 r5: 0
+ r6: 33728 r7: 0 r8: 0
+ r9: 0 r10: -1225703496 r11: -1091672844
+ r12: 0 sp: 0xbeee64f4 lr: 0xb6dc3f48
+ pc: 0x00008500 spsr: 0x60000010
+ CORE 124 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400500
+ uid: 0, gid: 0, pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063
+ fname: a.out, psargs: ./a.out
+ CORE 144 AUXV
+ HWCAP: 0xe8d7 <swp half thumb fast-mult vfp edsp>
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x8034
+ PHENT: 32
+ PHNUM: 8
+ BASE: 0xb6eee000
+ FLAGS: 0
+ ENTRY: 0x83c0
+ UID: 0
+ EUID: 0
+ GID: 0
+ EGID: 0
+ SECURE: 0
+ RANDOM: 0xbeee674e
+ EXECFN: 0xbeee6ff4
+ PLATFORM: 0xbeee675e
+ NULL
+ CORE 116 FPREGSET
+ f0: 0x000000000000000000000000 f1: 0x000000000000000000000000
+ f2: 0x000000000000000000000000 f3: 0x000000000000000000000000
+ f4: 0x000000000000000000000000 f5: 0x000000000000000000000000
+ f6: 0x000000000000000000000000 f7: 0x000000000000000000000000
+ LINUX 260 ARM_VFP
+ fpscr: 0x00000000
+ d0: 0x0000000000000000 d1: 0x0000000000000000
+ d2: 0x0000000000000000 d3: 0x0000000000000000
+ d4: 0x0000000000000000 d5: 0x0000000000000000
+ d6: 0x0000000000000000 d7: 0x0000000000000000
+ d8: 0x0000000000000000 d9: 0x0000000000000000
+ d10: 0x0000000000000000 d11: 0x0000000000000000
+ d12: 0x0000000000000000 d13: 0x0000000000000000
+ d14: 0x0000000000000000 d15: 0x0000000000000000
+ d16: 0x0000000000000000 d17: 0x0000000000000000
+ d18: 0x0000000000000000 d19: 0x0000000000000000
+ d20: 0x0000000000000000 d21: 0x0000000000000000
+ d22: 0x0000000000000000 d23: 0x0000000000000000
+ d24: 0x0000000000000000 d25: 0x0000000000000000
+ d26: 0x0000000000000000 d27: 0x0000000000000000
+ d28: 0x0000000000000000 d29: 0x0000000000000000
+ d30: 0x0000000000000000 d31: 0x0000000000000000
+EOF
+
+testfiles testfile67
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile67 <<\EOF
+
+Note segment of 1044 bytes at offset 0xe8:
+ Owner Data size Type
+ CORE 336 PRSTATUS
+ info.si_signo: 4, info.si_code: 0, info.si_errno: 0, cursig: 4
+ sigpend: <>
+ sighold: <>
+ pid: 805, ppid: 804, pgrp: 804, sid: 699
+ utime: 0.000042, stime: 0.000103, cutime: 0.000000, cstime: 0.000000
+ orig_r2: 2571552016, fpvalid: 1
+ pswm: 0x0705c00180000000 pswa: 0x00000000800000d6
+ r0: 4393751543808 r1: 4398002544388
+ r2: 11 r3: 2571578208
+ r4: 2571702016 r5: 4398003235624
+ r6: 2571580768 r7: 2571702016
+ r8: 2571578208 r9: 2571552016
+ r10: 2571552016 r11: 0
+ r12: 4398003499008 r13: 2148274656
+ r14: 0 r15: 4398040761216
+ a0: 0x000003ff a1: 0xfd54a6f0 a2: 0x00000000 a3: 0x00000000
+ a4: 0x00000000 a5: 0x00000000 a6: 0x00000000 a7: 0x00000000
+ a8: 0x00000000 a9: 0x00000000 a10: 0x00000000 a11: 0x00000000
+ a12: 0x00000000 a13: 0x00000000 a14: 0x00000000 a15: 0x00000000
+ CORE 136 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000400400
+ uid: 0, gid: 0, pid: 805, ppid: 804, pgrp: 804, sid: 699
+ fname: 1, psargs: ./1
+ CORE 304 AUXV
+ SYSINFO_EHDR: 0
+ HWCAP: 0x37f
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x80000040
+ PHENT: 56
+ PHNUM: 2
+ BASE: 0
+ FLAGS: 0
+ ENTRY: 0x800000d4
+ UID: 0
+ EUID: 0
+ GID: 0
+ EGID: 0
+ SECURE: 0
+ RANDOM: 0x3ffffa8463c
+ EXECFN: 0x3ffffa85ff4
+ PLATFORM: 0x3ffffa8464c
+ NULL
+ CORE 136 FPREGSET
+ fpc: 0x00000000
+ f0: 0x0000000000000040 f1: 0x4b00000000000000
+ f2: 0x0000000000000041 f3: 0x3ad50b5555555600
+ f4: 0x0000000000000000 f5: 0x0000000000000000
+ f6: 0x0000000000000000 f7: 0x0000000000000000
+ f8: 0x0000000000000000 f9: 0x0000000000000000
+ f10: 0x0000000000000000 f11: 0x0000000000000000
+ f12: 0x0000000000000000 f13: 0x0000000000000000
+ f14: 0x0000000000000000 f15: 0x0000000000000000
+ LINUX 8 S390_LAST_BREAK
+ last_break: 0x000003fffd75ccbe
+ LINUX 4 S390_SYSTEM_CALL
+ system_call: 0
+EOF
+
+testfiles testfile68
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile68 <<\EOF
+
+Note segment of 852 bytes at offset 0x94:
+ Owner Data size Type
+ CORE 224 PRSTATUS
+ info.si_signo: 4, info.si_code: 0, info.si_errno: 0, cursig: 4
+ sigpend: <>
+ sighold: <>
+ pid: 839, ppid: 838, pgrp: 838, sid: 699
+ utime: 0.000043, stime: 0.000102, cutime: 0.000000, cstime: 0.000000
+ orig_r2: -1723388288, fpvalid: 1
+ pswm: 0x070dc000 pswa: 0x8040009a
+ r0: 0 r1: -43966716 r2: 11 r3: -1723238816
+ r4: -1723265280 r5: -43275480 r6: -1723245280 r7: -1723265280
+ r8: -1723238816 r9: -1723388288 r10: -1723388288 r11: 0
+ r12: -43012096 r13: -2146692640 r14: 0 r15: 2139883440
+ a0: 0x000003ff a1: 0xfd54a6f0 a2: 0x00000000 a3: 0x00000000
+ a4: 0x00000000 a5: 0x00000000 a6: 0x00000000 a7: 0x00000000
+ a8: 0x00000000 a9: 0x00000000 a10: 0x00000000 a11: 0x00000000
+ a12: 0x00000000 a13: 0x00000000 a14: 0x00000000 a15: 0x00000000
+ CORE 124 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400400
+ uid: 0, gid: 0, pid: 839, ppid: 838, pgrp: 838, sid: 699
+ fname: 2, psargs: ./2
+ CORE 152 AUXV
+ SYSINFO_EHDR: 0
+ HWCAP: 0x37f
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x400034
+ PHENT: 32
+ PHNUM: 2
+ BASE: 0
+ FLAGS: 0
+ ENTRY: 0x400098
+ UID: 0
+ EUID: 0
+ GID: 0
+ EGID: 0
+ SECURE: 0
+ RANDOM: 0x7f8c090c
+ EXECFN: 0x7f8c1ff4
+ PLATFORM: 0x7f8c091c
+ NULL
+ CORE 136 FPREGSET
+ fpc: 0x00000000
+ f0: 0x0000000000000040 f1: 0x4b00000000000000
+ f2: 0x0000000000000041 f3: 0x3ad50b5555555600
+ f4: 0x0000000000000000 f5: 0x0000000000000000
+ f6: 0x0000000000000000 f7: 0x0000000000000000
+ f8: 0x0000000000000000 f9: 0x0000000000000000
+ f10: 0x0000000000000000 f11: 0x0000000000000000
+ f12: 0x0000000000000000 f13: 0x0000000000000000
+ f14: 0x0000000000000000 f15: 0x0000000000000000
+ LINUX 8 S390_LAST_BREAK
+ last_break: 0xfd75ccbe
+ LINUX 4 S390_SYSTEM_CALL
+ system_call: 0
+ LINUX 64 S390_HIGH_GPRS
+ high_r0: 0x000003ff, high_r1: 0x000003ff, high_r2: 0x00000000
+ high_r3: 0x00000000, high_r4: 0x00000000, high_r5: 0x000003ff
+ high_r6: 0x00000000, high_r7: 0x00000000, high_r8: 0x00000000
+ high_r9: 0x00000000, high_r10: 0x00000000, high_r11: 0x00000000
+ high_r12: 0x000003ff, high_r13: 0x00000000, high_r14: 0x00000000
+ high_r15: 0x00000000
+EOF
+
+# To reproduce this core dump, do this on x86_64 machine with Linux
+# 3.7 or later:
+# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
+# $ ./a.out
+testfiles testfile71
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile71 <<\EOF
+
+Note segment of 1476 bytes at offset 0x430:
+ Owner Data size Type
+ CORE 336 PRSTATUS
+ info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
+ sigpend: <>
+ sighold: <>
+ pid: 9664, ppid: 2868, pgrp: 9664, sid: 2868
+ utime: 0.000000, stime: 0.004000, cutime: 0.000000, cstime: 0.000000
+ orig_rax: -1, fpvalid: 0
+ r15: 0 r14: 0
+ r13: 140734971656848 r12: 4195328
+ rbp: 0x00007fff69fe39b0 rbx: 0
+ r11: 266286012928 r10: 140734971656256
+ r9: 0 r8: 266289790592
+ rax: 305419896 rcx: 4195584
+ rdx: 140734971656872 rsi: 140734971656856
+ rdi: 1 rip: 0x00000000004004f9
+ rflags: 0x0000000000010246 rsp: 0x00007fff69fe39b0
+ fs.base: 0x00007fa1c8933740 gs.base: 0x0000000000000000
+ cs: 0x0033 ss: 0x002b ds: 0x0000 es: 0x0000 fs: 0x0000 gs: 0x0000
+ CORE 136 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000000200
+ uid: 1000, gid: 1000, pid: 9664, ppid: 2868, pgrp: 9664, sid: 2868
+ fname: a.out, psargs: ./a.out
+ CORE 128 SIGINFO
+ si_signo: 11, si_errno: 0, si_code: 1
+ fault address: 0x12345678
+ CORE 304 AUXV
+ SYSINFO_EHDR: 0x7fff69ffe000
+ HWCAP: 0xafebfbff <fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss tm pbe>
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x400040
+ PHENT: 56
+ PHNUM: 9
+ BASE: 0
+ FLAGS: 0
+ ENTRY: 0x400400
+ UID: 1000
+ EUID: 1000
+ GID: 1000
+ EGID: 1000
+ SECURE: 0
+ RANDOM: 0x7fff69fe3d19
+ EXECFN: 0x7fff69fe4ff0
+ PLATFORM: 0x7fff69fe3d29
+ NULL
+ CORE 469 FILE
+ 10 files:
+ 00400000-00401000 00000000 4096 /home/petr/a.out
+ 00600000-00601000 00000000 4096 /home/petr/a.out
+ 00601000-00602000 00001000 4096 /home/petr/a.out
+ 3dffa00000-3dffa21000 00000000 135168 /usr/lib64/ld-2.17.so
+ 3dffc20000-3dffc21000 00020000 4096 /usr/lib64/ld-2.17.so
+ 3dffc21000-3dffc22000 00021000 4096 /usr/lib64/ld-2.17.so
+ 3dffe00000-3dfffb6000 00000000 1794048 /usr/lib64/libc-2.17.so
+ 3dfffb6000-3e001b6000 001b6000 2097152 /usr/lib64/libc-2.17.so
+ 3e001b6000-3e001ba000 001b6000 16384 /usr/lib64/libc-2.17.so
+ 3e001ba000-3e001bc000 001ba000 8192 /usr/lib64/libc-2.17.so
+EOF
+
+# To reproduce this core dump, do this on an aarch64 machine:
+# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
+# $ ./a.out
+testfiles testfile_aarch64_core
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile_aarch64_core <<\EOF
+
+Note segment of 2512 bytes at offset 0x270:
+ Owner Data size Type
+ CORE 392 PRSTATUS
+ info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
+ sigpend: <>
+ sighold: <>
+ pid: 16547, ppid: 3822, pgrp: 16547, sid: 3822
+ utime: 0.010000, stime: 0.000000, cutime: 0.000000, cstime: 0.000000
+ pc: 0x0000000000400548, pstate: 0x0000000060000000, fpvalid: 1
+ x0: 305419896 x1: 548685596648
+ x2: 548685596664 x3: 4195648
+ x4: 0 x5: 548536191688
+ x6: 0 x7: -6341196323062964528
+ x8: 135 x9: 4294967295
+ x10: 4195026 x11: 184256
+ x12: 144 x13: 15
+ x14: 548536635328 x15: 0
+ x16: 548534815304 x17: 4262024
+ x18: 548685596000 x19: 0
+ x20: 0 x21: 4195296
+ x22: 0 x23: 0
+ x24: 0 x25: 0
+ x26: 0 x27: 0
+ x28: 0 x29: 548685596320
+ x30: 548534815544 sp: 0x0000007fc035c6a0
+ CORE 136 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000400400
+ uid: 0, gid: 0, pid: 16547, ppid: 3822, pgrp: 16547, sid: 3822
+ fname: a.out, psargs: ./a.out
+ CORE 128 SIGINFO
+ si_signo: 11, si_errno: 0, si_code: 1
+ fault address: 0x12345678
+ CORE 304 AUXV
+ SYSINFO_EHDR: 0x7fb7500000
+ HWCAP: 0x3
+ PAGESZ: 65536
+ CLKTCK: 100
+ PHDR: 0x400040
+ PHENT: 56
+ PHNUM: 7
+ BASE: 0x7fb7520000
+ FLAGS: 0
+ ENTRY: 0x4003e0
+ UID: 0
+ EUID: 0
+ GID: 0
+ EGID: 0
+ SECURE: 0
+ RANDOM: 0x7fc035c9e8
+ EXECFN: 0x7fc035fff0
+ PLATFORM: 0x7fc035c9f8
+ NULL
+ CORE 306 FILE
+ 6 files:
+ 00400000-00410000 00000000 65536 /root/elfutils/build/a.out
+ 00410000-00420000 00000000 65536 /root/elfutils/build/a.out
+ 7fb7370000-7fb74d0000 00000000 1441792 /usr/lib64/libc-2.17.so
+ 7fb74d0000-7fb74f0000 00150000 131072 /usr/lib64/libc-2.17.so
+ 7fb7520000-7fb7540000 00000000 131072 /usr/lib64/ld-2.17.so
+ 7fb7540000-7fb7550000 00010000 65536 /usr/lib64/ld-2.17.so
+ CORE 528 FPREGSET
+ fpsr: 0x00000000, fpcr: 0x00000000
+ v0: 0x00000000000af54b000000000000fe02
+ v1: 0x00000000000000000000000000000000
+ v2: 0x00000000000000000000000000000000
+ v3: 0x00000000000000000000000000000000
+ v4: 0x00000000000000000000000000000000
+ v5: 0x00000000000000000000000000000000
+ v6: 0x00000000000000000000000000000000
+ v7: 0x00000000000000000000000000000000
+ v8: 0x00000000000000000000000000000000
+ v9: 0x00000000000000000000000000000000
+ v10: 0x00000000000000000000000000000000
+ v11: 0x00000000000000000000000000000000
+ v12: 0x00000000000000000000000000000000
+ v13: 0x00000000000000000000000000000000
+ v14: 0x00000000000000000000000000000000
+ v15: 0x00000000000000000000000000000000
+ v16: 0x00000000000000000000000000000000
+ v17: 0x00000000000000000000000000000000
+ v18: 0x00000000000000000000000000000000
+ v19: 0x00000000000000000000000000000000
+ v20: 0x00000000000000000000000000000000
+ v21: 0x00000000000000000000000000000000
+ v22: 0x00000000000000000000000000000000
+ v23: 0x00000000000000000000000000000000
+ v24: 0x00000000000000000000000000000000
+ v25: 0x00000000000000000000000000000000
+ v26: 0x00000000000000000000000000000000
+ v27: 0x00000000000000000000000000000000
+ v28: 0x00000000000000000000000000000000
+ v29: 0x00000000000000000000000000000000
+ v30: 0x00000000000000000000000000000000
+ v31: 0x00000000000000000000000000000000
+ LINUX 8 ARM_TLS
+ tls: 0x0000007fb73606f0
+ LINUX 264 ARM_HW_BREAK
+ dbg_info: 0x00000610
+ DBGBVR0_EL1: 0x0000000000000000, DBGBCR0_EL1: 0x00000000
+ DBGBVR1_EL1: 0x0000000000000000, DBGBCR1_EL1: 0x00000000
+ DBGBVR2_EL1: 0x0000000000000000, DBGBCR2_EL1: 0x00000000
+ DBGBVR3_EL1: 0x0000000000000000, DBGBCR3_EL1: 0x00000000
+ DBGBVR4_EL1: 0x0000000000000000, DBGBCR4_EL1: 0x00000000
+ DBGBVR5_EL1: 0x0000000000000000, DBGBCR5_EL1: 0x00000000
+ DBGBVR6_EL1: 0x0000000000000000, DBGBCR6_EL1: 0x00000000
+ DBGBVR7_EL1: 0x0000000000000000, DBGBCR7_EL1: 0x00000000
+ DBGBVR8_EL1: 0x0000000000000000, DBGBCR8_EL1: 0x00000000
+ DBGBVR9_EL1: 0x0000000000000000, DBGBCR9_EL1: 0x00000000
+ DBGBVR10_EL1: 0x0000000000000000, DBGBCR10_EL1: 0x00000000
+ DBGBVR11_EL1: 0x0000000000000000, DBGBCR11_EL1: 0x00000000
+ DBGBVR12_EL1: 0x0000000000000000, DBGBCR12_EL1: 0x00000000
+ DBGBVR13_EL1: 0x0000000000000000, DBGBCR13_EL1: 0x00000000
+ DBGBVR14_EL1: 0x0000000000000000, DBGBCR14_EL1: 0x00000000
+ DBGBVR15_EL1: 0x0000000000000000, DBGBCR15_EL1: 0x00000000
+ LINUX 264 ARM_HW_WATCH
+ dbg_info: 0x00000610
+ DBGWVR0_EL1: 0x0000000000000000, DBGWCR0_EL1: 0x00000000
+ DBGWVR1_EL1: 0x0000000000000000, DBGWCR1_EL1: 0x00000000
+ DBGWVR2_EL1: 0x0000000000000000, DBGWCR2_EL1: 0x00000000
+ DBGWVR3_EL1: 0x0000000000000000, DBGWCR3_EL1: 0x00000000
+ DBGWVR4_EL1: 0x0000000000000000, DBGWCR4_EL1: 0x00000000
+ DBGWVR5_EL1: 0x0000000000000000, DBGWCR5_EL1: 0x00000000
+ DBGWVR6_EL1: 0x0000000000000000, DBGWCR6_EL1: 0x00000000
+ DBGWVR7_EL1: 0x0000000000000000, DBGWCR7_EL1: 0x00000000
+ DBGWVR8_EL1: 0x0000000000000000, DBGWCR8_EL1: 0x00000000
+ DBGWVR9_EL1: 0x0000000000000000, DBGWCR9_EL1: 0x00000000
+ DBGWVR10_EL1: 0x0000000000000000, DBGWCR10_EL1: 0x00000000
+ DBGWVR11_EL1: 0x0000000000000000, DBGWCR11_EL1: 0x00000000
+ DBGWVR12_EL1: 0x0000000000000000, DBGWCR12_EL1: 0x00000000
+ DBGWVR13_EL1: 0x0000000000000000, DBGWCR13_EL1: 0x00000000
+ DBGWVR14_EL1: 0x0000000000000000, DBGWCR14_EL1: 0x00000000
+ DBGWVR15_EL1: 0x0000000000000000, DBGWCR15_EL1: 0x00000000
+EOF
+
+# To reproduce this core dump, do this on an i686 machine:
+# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
+# $ ./a.out
+testfiles testfile_i686_core
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile_i686_core <<\EOF
+
+Note segment of 1000 bytes at offset 0x214:
+ Owner Data size Type
+ CORE 144 PRSTATUS
+ info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
+ sigpend: <>
+ sighold: <>
+ pid: 27395, ppid: 1130, pgrp: 27395, sid: 1130
+ utime: 0.000000, stime: 0.001000, cutime: 0.000000, cstime: 0.000000
+ orig_eax: -1, fpvalid: 0
+ ebx: 1334976512 ecx: -1239415396 edx: -1079283900
+ esi: 0 edi: 0 ebp: 0xbfab6f18
+ eax: 305419896 eip: 0x08048408 eflags: 0x00010246
+ esp: 0xbfab6f18
+ ds: 0x007b es: 0x007b fs: 0x0000 gs: 0x0033 cs: 0x0073 ss: 0x007b
+ CORE 124 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00000200
+ uid: 1000, gid: 1000, pid: 27395, ppid: 1130, pgrp: 27395, sid: 1130
+ fname: a.out, psargs: ./a.out
+ CORE 128 SIGINFO
+ si_signo: 11, si_errno: 0, si_code: 1
+ fault address: 0x12345678
+ CORE 160 AUXV
+ SYSINFO: 0xb77fc414
+ SYSINFO_EHDR: 0xb77fc000
+ HWCAP: 0x780abfd <fpu de pse tsc msr pae mce cx8 apic sep pge cmov mmx fxsr sse sse2>
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x8048034
+ PHENT: 32
+ PHNUM: 9
+ BASE: 0
+ FLAGS: 0
+ ENTRY: 0x80482f0
+ UID: 1000
+ EUID: 1000
+ GID: 1000
+ EGID: 1000
+ SECURE: 0
+ RANDOM: 0xbfab70eb
+ EXECFN: 0xbfab7ff4
+ PLATFORM: 0xbfab70fb
+ NULL
+ CORE 275 FILE
+ 9 files:
+ 08048000-08049000 00000000 4096 /tmp/a.out
+ 08049000-0804a000 00000000 4096 /tmp/a.out
+ 0804a000-0804b000 00001000 4096 /tmp/a.out
+ 4f744000-4f763000 00000000 126976 /usr/lib/ld-2.18.so
+ 4f764000-4f765000 0001f000 4096 /usr/lib/ld-2.18.so
+ 4f765000-4f766000 00020000 4096 /usr/lib/ld-2.18.so
+ 4f768000-4f920000 00000000 1802240 /usr/lib/libc-2.18.so
+ 4f920000-4f922000 001b8000 8192 /usr/lib/libc-2.18.so
+ 4f922000-4f923000 001ba000 4096 /usr/lib/libc-2.18.so
+ LINUX 48 386_TLS
+ index: 6, base: 0xb77da700, limit: 0x000fffff, flags: 0x00000051
+ index: 7, base: 0x00000000, limit: 0x00000000, flags: 0x00000028
+ index: 8, base: 0x00000000, limit: 0x00000000, flags: 0x00000028
+EOF
+
+# To reproduce this core dump, do this on x86_64 machine with Linux
+# 3.7 or later:
+# $ gcc -mx32 -x c <(echo 'int main () { return *(int *)0x12345678; }')
+# $ ./a.out
+testfiles testfile-x32-core
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile-x32-core <<\EOF
+
+Note segment of 2548 bytes at offset 0x234:
+ Owner Data size Type
+ CORE 296 PRSTATUS
+ info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
+ sigpend: <>
+ sighold: <>
+ pid: 6885, ppid: 2792, pgrp: 6885, sid: 2792
+ utime: 0.000000, stime: 0.001000, cutime: 0.000000, cstime: 0.000000
+ orig_rax: -1, fpvalid: 1
+ r15: 0 r14: 0
+ r13: 4290830656 r12: 4194960
+ rbp: 0x00000000ffc0e070 rbx: 0
+ r11: 4145779200 r10: 0
+ r9: 4149627024 r8: 4149551744
+ rax: 305419896 rcx: 4195216
+ rdx: 4290830668 rsi: 4290830660
+ rdi: 1 rip: 0x0000000000400380
+ rflags: 0x0000000000010246 rsp: 0x00000000ffc0e070
+ fs.base: 0x00000000f7754700 gs.base: 0x0000000000000000
+ cs: 0x0033 ss: 0x002b ds: 0x002b es: 0x002b fs: 0x0063 gs: 0x0000
+ CORE 124 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00406600
+ uid: 1000, gid: 1000, pid: 6885, ppid: 2792, pgrp: 6885, sid: 2792
+ fname: a.out, psargs: ./a.out
+ CORE 128 SIGINFO
+ si_signo: 11, si_errno: 0, si_code: 1
+ fault address: 0x12345678
+ CORE 152 AUXV
+ SYSINFO_EHDR: 0xffd49000
+ HWCAP: 0xbfebfbff <fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe>
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x400034
+ PHENT: 32
+ PHNUM: 8
+ BASE: 0xf7555000
+ FLAGS: 0
+ ENTRY: 0x400290
+ UID: 1000
+ EUID: 1000
+ GID: 1000
+ EGID: 1000
+ SECURE: 0
+ RANDOM: 0xffc0e2cb
+ EXECFN: 0xffc0fff0
+ PLATFORM: 0xffc0e2db
+ NULL
+ CORE 361 FILE
+ 9 files:
+ 00400000-00401000 00000000 4096 /export/home/hjl/bugs/gdb/x32-1/a.out
+ 00600000-00601000 00000000 4096 /export/home/hjl/bugs/gdb/x32-1/a.out
+ f71a2000-f734f000 00000000 1757184 /usr/libx32/libc-2.20.so
+ f734f000-f754e000 001ad000 2093056 /usr/libx32/libc-2.20.so
+ f754e000-f7551000 001ac000 12288 /usr/libx32/libc-2.20.so
+ f7551000-f7552000 001af000 4096 /usr/libx32/libc-2.20.so
+ f7555000-f7575000 00000000 131072 /usr/libx32/ld-2.20.so
+ f7774000-f7775000 0001f000 4096 /usr/libx32/ld-2.20.so
+ f7775000-f7776000 00020000 4096 /usr/libx32/ld-2.20.so
+ CORE 512 FPREGSET
+ xmm0: 0x0000000000000000000000000000ff00
+ xmm1: 0x2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f
+ xmm2: 0x00000000000000000000000000000000
+ xmm3: 0x0000000000000000ff00000000000000
+ xmm4: 0x000000000000000000ff000000000000
+ xmm5: 0x00000000000000000000000000000000
+ xmm6: 0x00000000000000000000000000000000
+ xmm7: 0x00000000000000000000000000000000
+ xmm8: 0x00000000000000000000000000000000
+ xmm9: 0x00000000000000000000000000000000
+ xmm10: 0x00000000000000000000000000000000
+ xmm11: 0x00000000000000000000000000000000
+ xmm12: 0x00000000000000000000000000000000
+ xmm13: 0x00000000000000000000000000000000
+ xmm14: 0x00000000000000000000000000000000
+ xmm15: 0x00000000000000000000000000000000
+ st0: 0x00000000000000000000 st1: 0x00000000000000000000
+ st2: 0x00000000000000000000 st3: 0x00000000000000000000
+ st4: 0x00000000000000000000 st5: 0x00000000000000000000
+ st6: 0x00000000000000000000 st7: 0x00000000000000000000
+ mxcsr: 0x0000ffff00001f80
+ fcw: 0x037f fsw: 0x0000
+ LINUX 832 X86_XSTATE
+EOF
+
+# To reproduce this core dump, do this on an m68k machine:
+# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
+# $ ./a.out
+testfiles testfile-m68k-core
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile-m68k-core <<\EOF
+
+Note segment of 1056 bytes at offset 0x1f4:
+ Owner Data size Type
+ CORE 154 PRSTATUS
+ info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
+ sigpend: <>
+ sighold: <>
+ pid: 1963, ppid: 1084, pgrp: 1963, sid: 1084
+ utime: 0.000000, stime: 0.010000, cutime: 0.000000, cstime: 0.000000
+ fpvalid: 1
+ d1: 1 d2: 0 d3: -2146476616 d4: -2146476616
+ d5: 0 d6: -2147393212 d7: -2144827216 a0: 0x12345678
+ a1: 0xefe71460 a2: 0x00000000 a3: 0x80288df8 a4: 0x80000340
+ a5: 0xc017a000 a6: 0xefe71434 d0: -1073595312 a7: 0xefe71434
+ pc: 0x800003fe
+ CORE 124 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400600
+ uid: 1000, gid: 501, pid: 1963, ppid: 1084, pgrp: 1963, sid: 1084
+ fname: a.out, psargs: ./a.out
+ CORE 128 SIGINFO
+ si_signo: 11, si_errno: 0, si_code: 1
+ fault address: 0x12345678
+ CORE 136 AUXV
+ HWCAP: 0
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x80000034
+ PHENT: 32
+ PHNUM: 9
+ BASE: 0xc0000000
+ FLAGS: 0
+ ENTRY: 0x80000340
+ UID: 1000
+ EUID: 1000
+ GID: 501
+ EGID: 501
+ SECURE: 0
+ RANDOM: 0xefe716d9
+ EXECFN: 0xefe71ff4
+ NULL
+ CORE 281 FILE
+ 10 files:
+ 80000000-80001000 00000000 4096 /tmp/a.out
+ 80003000-80004000 00001000 4096 /tmp/a.out
+ 80004000-80005000 00002000 4096 /tmp/a.out
+ c0000000-c001c000 00000000 114688 /lib/ld-2.23.so
+ c001f000-c0020000 0001d000 4096 /lib/ld-2.23.so
+ c0020000-c0021000 0001e000 4096 /lib/ld-2.23.so
+ c0032000-c0177000 00000000 1331200 /lib/libc-2.23.so
+ c0177000-c0178000 00145000 4096 /lib/libc-2.23.so
+ c0178000-c017a000 00144000 8192 /lib/libc-2.23.so
+ c017a000-c017e000 00146000 16384 /lib/libc-2.23.so
+ CORE 108 FPREGSET
+ fp0: 0x7fff0000ffffffffffffffff fp1: 0x7fff0000ffffffffffffffff
+ fp2: 0x7fff0000ffffffffffffffff fp3: 0x7fff0000ffffffffffffffff
+ fp4: 0x7fff0000ffffffffffffffff fp5: 0x7fff0000ffffffffffffffff
+ fp6: 0x7fff0000ffffffffffffffff fp7: 0x7fff0000ffffffffffffffff
+EOF
+
+exit 0
diff --git a/tests/run-readelf-s.sh b/tests/run-readelf-s.sh
new file mode 100755
index 0000000..82c3417
--- /dev/null
+++ b/tests/run-readelf-s.sh
@@ -0,0 +1,389 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+# Tests readelf -s and readelf --elf-section -s
+# See also run-dwflsyms.sh
+#
+# - bar.c
+#
+# static int b1 = 1;
+# int b2 = 1;
+#
+# static int
+# foo (int a)
+# {
+# return a + b2;
+# }
+#
+# int bar (int b)
+# {
+# return b - foo (b - b1);
+# }
+#
+# - foo.c
+#
+# extern int bar (int b);
+# extern int b2;
+#
+# int
+# main (int argc, char ** argv)
+# {
+# return bar (argc + b2);
+# }
+#
+# gcc -pie -g -c foo.c
+# gcc -pie -g -c bar.c
+# gcc -pie -g -o baz foo.o bar.o
+#
+# - testfilebaztab (dynsym + symtab)
+# cp baz testfilebaztab
+#
+# - testfilebazdbg (dynsym + .debug file)
+# eu-strip --remove-comment -f testfilebazdbg.debug baz
+# cp baz testfilebazdbg
+#
+#- testfilebazdyn (dynsym only)
+# objcopy --remove-section=.gnu_debuglink baz testfilebazdyn
+#
+# - testfilebazmdb (dynsym + gnu_debugdata + .debug)
+# This is how rpmbuild does it:
+# nm -D baz --format=posix --defined-only | awk '{ print $1 }' | sort > dynsyms
+# nm baz.debug --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > funcsyms
+# comm -13 dynsyms funcsyms > keep_symbols
+# objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols=keep_symbols baz.debug mini_debuginfo
+# rm -f mini_debuginfo.xz
+# xz mini_debuginfo
+# objcopy --add-section .gnu_debugdata=mini_debuginfo.xz baz
+# cp baz testfilebazmdb
+#
+# - testfilebazmin (dynsym + gnu_debugdata)
+# objcopy --remove-section=.gnu_debuglink baz testfilebazmin
+#
+#
+# Special auxiliary only, can happen with static binaries.
+# - start.c
+#
+# extern int main (int argc, char ** argv);
+# void _start (void) { for (;;) main (1, 0); }
+#
+# gcc -g -c start.c
+# gcc -static -nostdlib -o bas foo.o bar.o start.o
+#
+# eu-strip --remove-comment -f bas.debug bas
+# nm bas.debug --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > funcsyms
+# objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols=funcsyms bas.debug mini_debuginfo
+# rm -f mini_debuginfo.xz
+# xz mini_debuginfo
+# objcopy --add-section .gnu_debugdata=mini_debuginfo.xz bas
+# rm bas.debug
+# mv bas testfilebasmin
+#
+#
+# Make sure that find_aux_sym doesn't corrupt relocations, avoiding a kernel
+# heuristic that forces ET_EXEC->ET_DYN. NB: ld.gold doesn't seem to produce
+# the mismatched load addrs between the main file and the mini_debuginfo, so
+# this is forcing ld.bfd.
+#
+# gcc -g -o bax foo.c bar.c -fuse-ld=bfd
+# eu-strip --remove-comment -f bax.debug bax
+# nm -D bax --format=posix --defined-only | awk '{ print $1 }' | sort > dynsyms
+# nm bax.debug --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > funcsyms
+# comm -13 dynsyms funcsyms > keep_symbols
+# objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols=keep_symbols bax.debug mini_debuginfo
+# rm -f mini_debuginfo.xz
+# xz mini_debuginfo
+# objcopy --add-section .gnu_debugdata=mini_debuginfo.xz bax
+# objcopy --remove-section=.gnu_debuglink bax testfilebaxmin
+
+
+testfiles testfilebaztab
+testfiles testfilebazdbg testfilebazdbg.debug
+testfiles testfilebazdyn
+testfiles testfilebazmdb
+testfiles testfilebazmin
+testfiles testfilebasmin
+testfiles testfilebaxmin
+
+tempfiles testfile.dynsym.in testfile.symtab.in testfile.minsym.in
+
+cat > testfile.dynsym.in <<\EOF
+
+Symbol table [ 5] '.dynsym' contains 14 entries:
+ 2 local symbols String table: [ 6] '.dynstr'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 0000000000000238 0 SECTION LOCAL DEFAULT 1
+ 2: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _ITM_deregisterTMCloneTable
+ 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UNDEF __libc_start_main@GLIBC_2.2.5 (2)
+ 4: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF __gmon_start__
+ 5: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _Jv_RegisterClasses
+ 6: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _ITM_registerTMCloneTable
+ 7: 0000000000000000 0 FUNC WEAK DEFAULT UNDEF __cxa_finalize@GLIBC_2.2.5 (2)
+ 8: 000000000020103c 0 NOTYPE GLOBAL DEFAULT 25 _edata
+ 9: 0000000000201040 0 NOTYPE GLOBAL DEFAULT 26 _end
+ 10: 0000000000000860 137 FUNC GLOBAL DEFAULT 13 __libc_csu_init
+ 11: 000000000020103c 0 NOTYPE GLOBAL DEFAULT 26 __bss_start
+ 12: 00000000000007f0 35 FUNC GLOBAL DEFAULT 13 main
+ 13: 00000000000008f0 2 FUNC GLOBAL DEFAULT 13 __libc_csu_fini
+EOF
+
+cat > testfile.symtab.in <<\EOF
+
+Symbol table [34] '.symtab' contains 76 entries:
+ 54 local symbols String table: [35] '.strtab'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 0000000000000238 0 SECTION LOCAL DEFAULT 1
+ 2: 0000000000000254 0 SECTION LOCAL DEFAULT 2
+ 3: 0000000000000274 0 SECTION LOCAL DEFAULT 3
+ 4: 0000000000000298 0 SECTION LOCAL DEFAULT 4
+ 5: 00000000000002d8 0 SECTION LOCAL DEFAULT 5
+ 6: 0000000000000428 0 SECTION LOCAL DEFAULT 6
+ 7: 00000000000004f2 0 SECTION LOCAL DEFAULT 7
+ 8: 0000000000000510 0 SECTION LOCAL DEFAULT 8
+ 9: 0000000000000530 0 SECTION LOCAL DEFAULT 9
+ 10: 0000000000000638 0 SECTION LOCAL DEFAULT 10
+ 11: 0000000000000680 0 SECTION LOCAL DEFAULT 11
+ 12: 00000000000006a0 0 SECTION LOCAL DEFAULT 12
+ 13: 00000000000006e0 0 SECTION LOCAL DEFAULT 13
+ 14: 00000000000008f4 0 SECTION LOCAL DEFAULT 14
+ 15: 0000000000000900 0 SECTION LOCAL DEFAULT 15
+ 16: 0000000000000904 0 SECTION LOCAL DEFAULT 16
+ 17: 0000000000000948 0 SECTION LOCAL DEFAULT 17
+ 18: 0000000000200dd0 0 SECTION LOCAL DEFAULT 18
+ 19: 0000000000200dd8 0 SECTION LOCAL DEFAULT 19
+ 20: 0000000000200de0 0 SECTION LOCAL DEFAULT 20
+ 21: 0000000000200de8 0 SECTION LOCAL DEFAULT 21
+ 22: 0000000000200df0 0 SECTION LOCAL DEFAULT 22
+ 23: 0000000000200fc0 0 SECTION LOCAL DEFAULT 23
+ 24: 0000000000201000 0 SECTION LOCAL DEFAULT 24
+ 25: 0000000000201030 0 SECTION LOCAL DEFAULT 25
+ 26: 000000000020103c 0 SECTION LOCAL DEFAULT 26
+ 27: 0000000000000000 0 SECTION LOCAL DEFAULT 27
+ 28: 0000000000000000 0 SECTION LOCAL DEFAULT 28
+ 29: 0000000000000000 0 SECTION LOCAL DEFAULT 29
+ 30: 0000000000000000 0 SECTION LOCAL DEFAULT 30
+ 31: 0000000000000000 0 SECTION LOCAL DEFAULT 31
+ 32: 0000000000000000 0 SECTION LOCAL DEFAULT 32
+ 33: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
+ 34: 0000000000200de0 0 OBJECT LOCAL DEFAULT 20 __JCR_LIST__
+ 35: 0000000000000710 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones
+ 36: 0000000000000740 0 FUNC LOCAL DEFAULT 13 register_tm_clones
+ 37: 0000000000000780 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux
+ 38: 000000000020103c 1 OBJECT LOCAL DEFAULT 26 completed.6137
+ 39: 0000000000200dd8 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fini_array_entry
+ 40: 00000000000007c0 0 FUNC LOCAL DEFAULT 13 frame_dummy
+ 41: 0000000000200dd0 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_entry
+ 42: 0000000000000000 0 FILE LOCAL DEFAULT ABS foo.c
+ 43: 0000000000000000 0 FILE LOCAL DEFAULT ABS bar.c
+ 44: 0000000000201034 4 OBJECT LOCAL DEFAULT 25 b1
+ 45: 0000000000000814 20 FUNC LOCAL DEFAULT 13 foo
+ 46: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
+ 47: 0000000000000a58 0 OBJECT LOCAL DEFAULT 17 __FRAME_END__
+ 48: 0000000000200de0 0 OBJECT LOCAL DEFAULT 20 __JCR_END__
+ 49: 0000000000000000 0 FILE LOCAL DEFAULT ABS
+ 50: 0000000000200dd8 0 NOTYPE LOCAL DEFAULT 18 __init_array_end
+ 51: 0000000000200df0 0 OBJECT LOCAL DEFAULT 22 _DYNAMIC
+ 52: 0000000000200dd0 0 NOTYPE LOCAL DEFAULT 18 __init_array_start
+ 53: 0000000000201000 0 OBJECT LOCAL DEFAULT 24 _GLOBAL_OFFSET_TABLE_
+ 54: 00000000000008f0 2 FUNC GLOBAL DEFAULT 13 __libc_csu_fini
+ 55: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _ITM_deregisterTMCloneTable
+ 56: 0000000000201030 0 NOTYPE WEAK DEFAULT 25 data_start
+ 57: 000000000020103c 0 NOTYPE GLOBAL DEFAULT 25 _edata
+ 58: 0000000000000828 44 FUNC GLOBAL DEFAULT 13 bar
+ 59: 00000000000008f4 0 FUNC GLOBAL DEFAULT 14 _fini
+ 60: 0000000000000000 0 FUNC GLOBAL DEFAULT UNDEF __libc_start_main@@GLIBC_2.2.5
+ 61: 0000000000201030 0 NOTYPE GLOBAL DEFAULT 25 __data_start
+ 62: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF __gmon_start__
+ 63: 0000000000200de8 0 OBJECT GLOBAL HIDDEN 21 __dso_handle
+ 64: 0000000000000900 4 OBJECT GLOBAL DEFAULT 15 _IO_stdin_used
+ 65: 0000000000201038 4 OBJECT GLOBAL DEFAULT 25 b2
+ 66: 0000000000000860 137 FUNC GLOBAL DEFAULT 13 __libc_csu_init
+ 67: 0000000000201040 0 NOTYPE GLOBAL DEFAULT 26 _end
+ 68: 00000000000006e0 0 FUNC GLOBAL DEFAULT 13 _start
+ 69: 000000000020103c 0 NOTYPE GLOBAL DEFAULT 26 __bss_start
+ 70: 00000000000007f0 35 FUNC GLOBAL DEFAULT 13 main
+ 71: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _Jv_RegisterClasses
+ 72: 0000000000201040 0 OBJECT GLOBAL HIDDEN 25 __TMC_END__
+ 73: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _ITM_registerTMCloneTable
+ 74: 0000000000000000 0 FUNC WEAK DEFAULT UNDEF __cxa_finalize@@GLIBC_2.2.5
+ 75: 0000000000000680 0 FUNC GLOBAL DEFAULT 11 _init
+EOF
+
+cat > testfile.minsym.in <<\EOF
+
+Symbol table [28] '.symtab' contains 40 entries:
+ 36 local symbols String table: [29] '.strtab'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 0000000000000710 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones
+ 2: 0000000000000740 0 FUNC LOCAL DEFAULT 13 register_tm_clones
+ 3: 0000000000000780 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux
+ 4: 0000000000200dd8 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fini_array_entry
+ 5: 00000000000007c0 0 FUNC LOCAL DEFAULT 13 frame_dummy
+ 6: 0000000000200dd0 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_entry
+ 7: 0000000000000814 20 FUNC LOCAL DEFAULT 13 foo
+ 8: 0000000000200dd8 0 NOTYPE LOCAL DEFAULT 18 __init_array_end
+ 9: 0000000000200dd0 0 NOTYPE LOCAL DEFAULT 18 __init_array_start
+ 10: 0000000000000238 0 SECTION LOCAL DEFAULT 1
+ 11: 0000000000000254 0 SECTION LOCAL DEFAULT 2
+ 12: 0000000000000274 0 SECTION LOCAL DEFAULT 3
+ 13: 0000000000000298 0 SECTION LOCAL DEFAULT 4
+ 14: 00000000000002d8 0 SECTION LOCAL DEFAULT 5
+ 15: 0000000000000428 0 SECTION LOCAL DEFAULT 6
+ 16: 00000000000004f2 0 SECTION LOCAL DEFAULT 7
+ 17: 0000000000000510 0 SECTION LOCAL DEFAULT 8
+ 18: 0000000000000530 0 SECTION LOCAL DEFAULT 9
+ 19: 0000000000000638 0 SECTION LOCAL DEFAULT 10
+ 20: 0000000000000680 0 SECTION LOCAL DEFAULT 11
+ 21: 00000000000006a0 0 SECTION LOCAL DEFAULT 12
+ 22: 00000000000006e0 0 SECTION LOCAL DEFAULT 13
+ 23: 00000000000008f4 0 SECTION LOCAL DEFAULT 14
+ 24: 0000000000000900 0 SECTION LOCAL DEFAULT 15
+ 25: 0000000000000904 0 SECTION LOCAL DEFAULT 16
+ 26: 0000000000000948 0 SECTION LOCAL DEFAULT 17
+ 27: 0000000000200dd0 0 SECTION LOCAL DEFAULT 18
+ 28: 0000000000200dd8 0 SECTION LOCAL DEFAULT 19
+ 29: 0000000000200de0 0 SECTION LOCAL DEFAULT 20
+ 30: 0000000000200de8 0 SECTION LOCAL DEFAULT 21
+ 31: 0000000000200df0 0 SECTION LOCAL DEFAULT 22
+ 32: 0000000000200fc0 0 SECTION LOCAL DEFAULT 23
+ 33: 0000000000201000 0 SECTION LOCAL DEFAULT 24
+ 34: 0000000000201030 0 SECTION LOCAL DEFAULT 25
+ 35: 000000000020103c 0 SECTION LOCAL DEFAULT 26
+ 36: 0000000000000828 44 FUNC GLOBAL DEFAULT 13 bar
+ 37: 00000000000008f4 0 FUNC GLOBAL DEFAULT 14 _fini
+ 38: 00000000000006e0 0 FUNC GLOBAL DEFAULT 13 _start
+ 39: 0000000000000680 0 FUNC GLOBAL DEFAULT 11 _init
+EOF
+
+# Display all symbol tables.
+cat testfile.dynsym.in testfile.symtab.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebaztab
+
+# Display just .dynsym
+cat testfile.dynsym.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf \
+ --symbols=.dynsym testfilebaztab
+
+# Display just .symtab
+cat testfile.symtab.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf \
+ --symbols=.symtab testfilebaztab
+
+cat testfile.dynsym.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazdbg
+
+cat testfile.symtab.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazdbg.debug
+
+cat testfile.dynsym.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazdyn
+
+cat testfile.dynsym.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazmdb
+
+cat testfile.minsym.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf --elf-section -s testfilebazmdb
+
+cat testfile.dynsym.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazmin
+
+cat testfile.minsym.in \
+ | testrun_compare ${abs_top_builddir}/src/readelf --elf-section -s testfilebazmin
+
+testrun_compare ${abs_top_builddir}/src/readelf -s testfilebasmin <<EOF
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf --elf-section -s testfilebasmin <<\EOF
+
+Symbol table [ 6] '.symtab' contains 9 entries:
+ 6 local symbols String table: [ 7] '.strtab'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 0000000000400168 18 FUNC LOCAL DEFAULT 2 foo
+ 2: 0000000000400120 0 SECTION LOCAL DEFAULT 1
+ 3: 0000000000400144 0 SECTION LOCAL DEFAULT 2
+ 4: 00000000004001c0 0 SECTION LOCAL DEFAULT 3
+ 5: 0000000000600258 0 SECTION LOCAL DEFAULT 4
+ 6: 00000000004001a8 21 FUNC GLOBAL DEFAULT 2 _start
+ 7: 0000000000400144 33 FUNC GLOBAL DEFAULT 2 main
+ 8: 000000000040017a 44 FUNC GLOBAL DEFAULT 2 bar
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf -s testfilebaxmin <<EOF
+
+Symbol table [ 5] '.dynsym' contains 3 entries:
+ 1 local symbol String table: [ 6] '.dynstr'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 0000000000000000 0 FUNC GLOBAL DEFAULT UNDEF __libc_start_main@GLIBC_2.2.5 (2)
+ 2: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF __gmon_start__
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf --elf-section -s testfilebaxmin <<\EOF
+
+Symbol table [27] '.symtab' contains 42 entries:
+ 35 local symbols String table: [28] '.strtab'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 0000000000400430 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones
+ 2: 0000000000400460 0 FUNC LOCAL DEFAULT 13 register_tm_clones
+ 3: 00000000004004a0 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux
+ 4: 0000000000600e18 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fini_array_entry
+ 5: 00000000004004c0 0 FUNC LOCAL DEFAULT 13 frame_dummy
+ 6: 0000000000600e10 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_entry
+ 7: 00000000004004f0 20 FUNC LOCAL DEFAULT 13 foo
+ 8: 0000000000600e18 0 NOTYPE LOCAL DEFAULT 18 __init_array_end
+ 9: 0000000000600e10 0 NOTYPE LOCAL DEFAULT 18 __init_array_start
+ 10: 0000000000400238 0 SECTION LOCAL DEFAULT 1
+ 11: 0000000000400254 0 SECTION LOCAL DEFAULT 2
+ 12: 0000000000400274 0 SECTION LOCAL DEFAULT 3
+ 13: 0000000000400298 0 SECTION LOCAL DEFAULT 4
+ 14: 00000000004002b8 0 SECTION LOCAL DEFAULT 5
+ 15: 0000000000400300 0 SECTION LOCAL DEFAULT 6
+ 16: 0000000000400338 0 SECTION LOCAL DEFAULT 7
+ 17: 0000000000400340 0 SECTION LOCAL DEFAULT 8
+ 18: 0000000000400360 0 SECTION LOCAL DEFAULT 9
+ 19: 0000000000400378 0 SECTION LOCAL DEFAULT 10
+ 20: 00000000004003a8 0 SECTION LOCAL DEFAULT 11
+ 21: 00000000004003d0 0 SECTION LOCAL DEFAULT 12
+ 22: 0000000000400400 0 SECTION LOCAL DEFAULT 13
+ 23: 00000000004005c4 0 SECTION LOCAL DEFAULT 14
+ 24: 00000000004005d0 0 SECTION LOCAL DEFAULT 15
+ 25: 00000000004005e0 0 SECTION LOCAL DEFAULT 16
+ 26: 0000000000400628 0 SECTION LOCAL DEFAULT 17
+ 27: 0000000000600e10 0 SECTION LOCAL DEFAULT 18
+ 28: 0000000000600e18 0 SECTION LOCAL DEFAULT 19
+ 29: 0000000000600e20 0 SECTION LOCAL DEFAULT 20
+ 30: 0000000000600e28 0 SECTION LOCAL DEFAULT 21
+ 31: 0000000000600ff8 0 SECTION LOCAL DEFAULT 22
+ 32: 0000000000601000 0 SECTION LOCAL DEFAULT 23
+ 33: 0000000000601028 0 SECTION LOCAL DEFAULT 24
+ 34: 0000000000601034 0 SECTION LOCAL DEFAULT 25
+ 35: 00000000004005c0 2 FUNC GLOBAL DEFAULT 13 __libc_csu_fini
+ 36: 0000000000400504 40 FUNC GLOBAL DEFAULT 13 bar
+ 37: 00000000004005c4 0 FUNC GLOBAL DEFAULT 14 _fini
+ 38: 0000000000400550 101 FUNC GLOBAL DEFAULT 13 __libc_csu_init
+ 39: 0000000000400400 0 FUNC GLOBAL DEFAULT 13 _start
+ 40: 000000000040052c 35 FUNC GLOBAL DEFAULT 13 main
+ 41: 00000000004003a8 0 FUNC GLOBAL DEFAULT 11 _init
+EOF
+
+exit 0
diff --git a/tests/run-readelf-self.sh b/tests/run-readelf-self.sh
new file mode 100755
index 0000000..7ffb357
--- /dev/null
+++ b/tests/run-readelf-self.sh
@@ -0,0 +1,21 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+
+# Just makes sure readelf doesn't crash
+testrun_on_self_quiet ${abs_top_builddir}/src/readelf -a -w
diff --git a/tests/run-readelf-test1.sh b/tests/run-readelf-test1.sh
new file mode 100755
index 0000000..4725049
--- /dev/null
+++ b/tests/run-readelf-test1.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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
+
+original=${original:-testfile11}
+stripped=${stripped:-testfile7}
+debugout=${debugfile:+-f testfile.debug.temp -F $debugfile}
+
+testfiles testfile3
+
+tempfiles testfile.temp
+
+testrun ${abs_top_builddir}/src/readelf -r testfile3 > testfile.temp
+
+diff -u - testfile.temp <<EOF
+
+Relocation section [ 8] '.rel.got' for section [19] '.got' at offset 0x294 contains 1 entry:
+ Offset Type Value Name
+ 0x08049544 386_GLOB_DAT 0000000000 __gmon_start__
+
+Relocation section [ 9] '.rel.plt' for section [11] '.plt' at offset 0x29c contains 4 entries:
+ Offset Type Value Name
+ 0x08049534 386_JMP_SLOT 0x080482e4 __register_frame_info
+ 0x08049538 386_JMP_SLOT 0x080482f4 __deregister_frame_info
+ 0x0804953c 386_JMP_SLOT 0x08048304 __libc_start_main
+ 0x08049540 386_JMP_SLOT 0x08048314 __cxa_finalize
+EOF
+
+exit 0
diff --git a/tests/run-readelf-test2.sh b/tests/run-readelf-test2.sh
new file mode 100755
index 0000000..9030624
--- /dev/null
+++ b/tests/run-readelf-test2.sh
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Copyright (C) 2007 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
+
+testfiles testfile28
+
+testrun_compare ${abs_top_builddir}/src/readelf -x .strtab testfile28 <<\EOF
+
+Hex dump of section [6] '.strtab', 1 bytes at offset 0x290:
+ 0x00000000 00 .
+EOF
+
+exit 0
diff --git a/tests/run-readelf-test3.sh b/tests/run-readelf-test3.sh
new file mode 100755
index 0000000..cc0a191
--- /dev/null
+++ b/tests/run-readelf-test3.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2007 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
+
+testfiles testfile40.debug
+
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile40.debug <<\EOF
+
+Note section [ 6] '.note' of 60 bytes at offset 0x120:
+ Owner Data size Type
+ GNU 20 GNU_BUILD_ID
+ Build ID: 34072edcd87ef6728f4b4a7956167b2fcfc3f1d3
+ Linux 4 <unknown>: 0
+EOF
+
+exit 0
diff --git a/tests/run-readelf-test4.sh b/tests/run-readelf-test4.sh
new file mode 100755
index 0000000..ca0526a
--- /dev/null
+++ b/tests/run-readelf-test4.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2007 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
+
+testfiles testfile19.index
+
+testrun_compare ${abs_top_builddir}/src/readelf -c testfile19.index <<\EOF
+
+Index of archive 'testfile19.index' has 4 entries:
+Archive member 'u1.o' contains:
+ a
+Archive member 'u2.o' contains:
+ aa
+Archive member 'u3.o' contains:
+ a
+EOF
+
+exit 0
diff --git a/tests/run-readelf-twofiles.sh b/tests/run-readelf-twofiles.sh
new file mode 100755
index 0000000..46eec7b
--- /dev/null
+++ b/tests/run-readelf-twofiles.sh
@@ -0,0 +1,24 @@
+#! /bin/sh
+# Copyright (C) 2011 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
+
+testfiles testfile14
+
+testrun >/dev/null ${abs_top_builddir}/src/readelf -w testfile14 testfile14
+
+exit 0
diff --git a/tests/run-readelf-variant.sh b/tests/run-readelf-variant.sh
new file mode 100755
index 0000000..dcc0d5e
--- /dev/null
+++ b/tests/run-readelf-variant.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2017 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
+
+# Tests exprloc for an Ada record variants byte_size.
+
+# = pck.ads
+#
+# with System;
+#
+# package Pck is
+#
+# type One_To_Five is range 1 .. 5;
+#
+# type Rec (Discr : One_To_Five) is
+# record
+# case Discr is
+# when 1 => Field1 : Integer;
+# when 4 => null;
+# when 3 => Field3 : Boolean;
+# when 5 => null;
+# when others => null;
+# end case;
+# end record;
+#
+# procedure Do_Nothing (A : System.Address);
+#
+# end Pck;
+
+# = pck.adb
+#
+# package body Pck is
+#
+# procedure Do_Nothing (A : System.Address) is
+# begin
+# null;
+# end Do_Nothing;
+#
+# end Pck;
+
+# = foo.adb
+#
+# with Pck; use Pck;
+#
+# procedure Foo is
+#
+# R : Rec (1);
+#
+# begin
+# Do_Nothing (R'Address);
+# end Foo;
+
+# gnatmake -g -fgnat-encodings=minimal foo.adb -cargs
+
+testfiles testfile-ada-variant
+
+tempfiles testfile.temp testfile2.temp
+
+testrun ${abs_top_builddir}/src/readelf --debug-dump=info \
+ testfile-ada-variant > testfile.temp
+
+grep -A6 byte_size testfile.temp | grep -A6 exprloc > testfile2.temp
+
+diff -u testfile2.temp - <<EOF
+ byte_size (exprloc)
+ [ 0] push_object_address
+ [ 1] deref_size 1
+ [ 3] call4 [ 95]
+ [ 8] plus_uconst 7
+ [10] const1s -4
+ [12] and
+EOF
+
+exit 0
diff --git a/tests/run-readelf-vmcoreinfo.sh b/tests/run-readelf-vmcoreinfo.sh
new file mode 100755
index 0000000..b1732fc
--- /dev/null
+++ b/tests/run-readelf-vmcoreinfo.sh
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+
+testfiles testfile62
+
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile62 <<\EOF
+
+Note segment of 2104 bytes at offset 0x158:
+ Owner Data size Type
+ CORE 336 PRSTATUS
+ info.si_signo: 0, info.si_code: 0, info.si_errno: 0, cursig: 0
+ sigpend: <>
+ sighold: <>
+ pid: 3519, ppid: 0, pgrp: 0, sid: 0
+ utime: 0.000000, stime: 0.000000, cutime: 0.000000, cstime: 0.000000
+ orig_rax: -1, fpvalid: 0
+ r15: 662 r14: 4
+ r13: -2119649152 r12: 0
+ rbp: 0xffff880067e39e48 rbx: 99
+ r11: -131940469531936 r10: -2124150080
+ r9: -131940469531936 r8: 0
+ rax: 16 rcx: 7813
+ rdx: 0 rsi: 0
+ rdi: 99 rip: 0xffffffff812ba86f
+ rflags: 0x0000000000010096 rsp: 0xffff880067e39e48
+ fs.base: 0x00007f95a7b09720 gs.base: 0x0000000000000000
+ cs: 0x0010 ss: 0x0018 ds: 0x0000 es: 0x0000 fs: 0x0000 gs: 0x0000
+ CORE 336 PRSTATUS
+ info.si_signo: 0, info.si_code: 0, info.si_errno: 0, cursig: 0
+ sigpend: <>
+ sighold: <>
+ pid: 0, ppid: 0, pgrp: 0, sid: 0
+ utime: 0.000000, stime: 0.000000, cutime: 0.000000, cstime: 0.000000
+ orig_rax: -1, fpvalid: 0
+ r15: 0 r14: 0
+ r13: 1348173392195389970 r12: 1
+ rbp: 0xffff88007a829e48 rbx: 16
+ r11: -131940468065880 r10: 435505529489
+ r9: 158960 r8: 0
+ rax: 16 rcx: 1
+ rdx: 0 rsi: 3
+ rdi: -131939339960320 rip: 0xffffffff810118bb
+ rflags: 0x0000000000000046 rsp: 0xffff88007a829e38
+ fs.base: 0x0000000000000000 gs.base: 0x0000000000000000
+ cs: 0x0010 ss: 0x0018 ds: 0x0000 es: 0x0000 fs: 0x0000 gs: 0x0000
+ VMCOREINFO 1366 <unknown>: 0
+ OSRELEASE=2.6.35.11-83.fc14.x86_64
+ PAGESIZE=4096
+ SYMBOL(init_uts_ns)=ffffffff81a4c5b0
+ SYMBOL(node_online_map)=ffffffff81b840b0
+ SYMBOL(swapper_pg_dir)=ffffffff81a42000
+ SYMBOL(_stext)=ffffffff81000190
+ SYMBOL(vmlist)=ffffffff81db07e8
+ SYMBOL(mem_section)=ffffffff81dbab00
+ LENGTH(mem_section)=4096
+ SIZE(mem_section)=32
+ OFFSET(mem_section.section_mem_map)=0
+ SIZE(page)=56
+ SIZE(pglist_data)=81664
+ SIZE(zone)=1792
+ SIZE(free_area)=88
+ SIZE(list_head)=16
+ SIZE(nodemask_t)=64
+ OFFSET(page.flags)=0
+ OFFSET(page._count)=8
+ OFFSET(page.mapping)=24
+ OFFSET(page.lru)=40
+ OFFSET(pglist_data.node_zones)=0
+ OFFSET(pglist_data.nr_zones)=81472
+ OFFSET(pglist_data.node_start_pfn)=81496
+ OFFSET(pglist_data.node_spanned_pages)=81512
+ OFFSET(pglist_data.node_id)=81520
+ OFFSET(zone.free_area)=112
+ OFFSET(zone.vm_stat)=1328
+ OFFSET(zone.spanned_pages)=1704
+ OFFSET(free_area.free_list)=0
+ OFFSET(list_head.next)=0
+ OFFSET(list_head.prev)=8
+ OFFSET(vm_struct.addr)=8
+ LENGTH(zone.free_area)=11
+ SYMBOL(log_buf)=ffffffff81a532a8
+ SYMBOL(log_end)=ffffffff81d0bc50
+ SYMBOL(log_buf_len)=ffffffff81a532a4
+ SYMBOL(logged_chars)=ffffffff81d0bd70
+ LENGTH(free_area.free_list)=5
+ NUMBER(NR_FREE_PAGES)=0
+ NUMBER(PG_lru)=5
+ NUMBER(PG_private)=11
+ NUMBER(PG_swapcache)=16
+ SYMBOL(phys_base)=ffffffff81a4a010
+ SYMBOL(init_level4_pgt)=ffffffff81a42000
+ SYMBOL(node_data)=ffffffff81b80df0
+ LENGTH(node_data)=512
+ CRASHTIME=1348173392
+
+EOF
+
+exit 0
diff --git a/tests/run-readelf-z.sh b/tests/run-readelf-z.sh
new file mode 100755
index 0000000..6dbd2f1
--- /dev/null
+++ b/tests/run-readelf-z.sh
@@ -0,0 +1,202 @@
+#! /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 -S testfile-zgnu64 <<\EOF
+There are 9 section headers, starting at offset 0x3e0:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+ [Compression Size Al]
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .text PROGBITS 0000000000400078 00000078 0000002a 0 AX 0 0 1
+[ 2] .zdebug_aranges PROGBITS 0000000000000000 00000260 00000032 0 0 0 16
+ [GNU ZLIB 00000060 ]
+[ 3] .zdebug_info PROGBITS 0000000000000000 00000292 0000006f 0 0 0 1
+ [GNU ZLIB 000000aa ]
+[ 4] .debug_abbrev PROGBITS 0000000000000000 00000301 00000028 0 0 0 1
+[ 5] .zdebug_line PROGBITS 0000000000000000 00000329 0000005b 0 0 0 1
+ [GNU ZLIB 0000008d ]
+[ 6] .shstrtab STRTAB 0000000000000000 00000384 00000059 0 0 0 1
+[ 7] .symtab SYMTAB 0000000000000000 000000a8 00000168 24 8 8 8
+[ 8] .strtab STRTAB 0000000000000000 00000210 0000004b 0 0 0 1
+
+EOF
+
+testfiles testfile-zgnu64be
+testrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgnu64be <<\EOF
+There are 10 section headers, starting at offset 0x438:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+ [Compression Size Al]
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .text PROGBITS 0000000010000078 00000078 00000074 0 AX 0 0 8
+[ 2] .eh_frame PROGBITS 00000000100000ec 000000ec 00000000 0 A 0 0 4
+[ 3] .zdebug_aranges PROGBITS 0000000000000000 000002c0 00000034 0 0 0 16
+ [GNU ZLIB 00000060 ]
+[ 4] .zdebug_info PROGBITS 0000000000000000 000002f4 00000059 0 0 0 1
+ [GNU ZLIB 0000007e ]
+[ 5] .debug_abbrev PROGBITS 0000000000000000 0000034d 00000028 0 0 0 1
+[ 6] .zdebug_line PROGBITS 0000000000000000 00000375 0000005b 0 0 0 1
+ [GNU ZLIB 0000008d ]
+[ 7] .shstrtab STRTAB 0000000000000000 000003d0 00000063 0 0 0 1
+[ 8] .symtab SYMTAB 0000000000000000 000000f0 00000180 24 9 9 8
+[ 9] .strtab STRTAB 0000000000000000 00000270 00000044 0 0 0 1
+
+EOF
+
+testfiles testfile-zgabi64
+testrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgabi64 <<\EOF
+There are 9 section headers, starting at offset 0x400:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+ [Compression Size Al]
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .text PROGBITS 0000000000400078 00000078 0000002a 0 AX 0 0 1
+[ 2] .debug_aranges PROGBITS 0000000000000000 00000260 0000003e 0 C 0 0 16
+ [ELF ZLIB (1) 00000060 16]
+[ 3] .debug_info PROGBITS 0000000000000000 0000029e 0000007b 0 C 0 0 1
+ [ELF ZLIB (1) 000000aa 1]
+[ 4] .debug_abbrev PROGBITS 0000000000000000 00000319 00000028 0 0 0 1
+[ 5] .debug_line PROGBITS 0000000000000000 00000341 00000067 0 C 0 0 1
+ [ELF ZLIB (1) 0000008d 1]
+[ 6] .shstrtab STRTAB 0000000000000000 000003a8 00000056 0 0 0 1
+[ 7] .symtab SYMTAB 0000000000000000 000000a8 00000168 24 8 8 8
+[ 8] .strtab STRTAB 0000000000000000 00000210 0000004b 0 0 0 1
+
+EOF
+
+testfiles testfile-zgabi64be
+testrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgabi64be <<\EOF
+There are 10 section headers, starting at offset 0x458:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+ [Compression Size Al]
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .text PROGBITS 0000000010000078 00000078 00000074 0 AX 0 0 8
+[ 2] .eh_frame PROGBITS 00000000100000ec 000000ec 00000000 0 A 0 0 4
+[ 3] .debug_aranges PROGBITS 0000000000000000 000002c0 00000040 0 C 0 0 16
+ [ELF ZLIB (1) 00000060 16]
+[ 4] .debug_info PROGBITS 0000000000000000 00000300 00000065 0 C 0 0 1
+ [ELF ZLIB (1) 0000007e 1]
+[ 5] .debug_abbrev PROGBITS 0000000000000000 00000365 00000028 0 0 0 1
+[ 6] .debug_line PROGBITS 0000000000000000 0000038d 00000067 0 C 0 0 1
+ [ELF ZLIB (1) 0000008d 1]
+[ 7] .shstrtab STRTAB 0000000000000000 000003f4 00000060 0 0 0 1
+[ 8] .symtab SYMTAB 0000000000000000 000000f0 00000180 24 9 9 8
+[ 9] .strtab STRTAB 0000000000000000 00000270 00000044 0 0 0 1
+
+EOF
+
+testfiles testfile-zgnu32
+testrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgnu32 <<\EOF
+There are 9 section headers, starting at offset 0x33c:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+ [Compression Size Al]
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .text PROGBITS 08048054 000054 00002a 0 AX 0 0 1
+[ 2] .zdebug_aranges PROGBITS 00000000 0001c0 000031 0 0 0 8
+ [GNU ZLIB 000040 ]
+[ 3] .zdebug_info PROGBITS 00000000 0001f1 00006f 0 0 0 1
+ [GNU ZLIB 00009a ]
+[ 4] .debug_abbrev PROGBITS 00000000 000260 000028 0 0 0 1
+[ 5] .zdebug_line PROGBITS 00000000 000288 00005a 0 0 0 1
+ [GNU ZLIB 000085 ]
+[ 6] .shstrtab STRTAB 00000000 0002e2 000059 0 0 0 1
+[ 7] .symtab SYMTAB 00000000 000080 0000f0 16 8 8 4
+[ 8] .strtab STRTAB 00000000 000170 00004b 0 0 0 1
+
+EOF
+
+testfiles testfile-zgnu32be
+testrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgnu32be <<\EOF
+There are 10 section headers, starting at offset 0x390:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+ [Compression Size Al]
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .text PROGBITS 01800054 000054 000074 0 AX 0 0 1
+[ 2] .eh_frame PROGBITS 018000c8 0000c8 000000 0 A 0 0 4
+[ 3] .zdebug_aranges PROGBITS 00000000 000220 000033 0 0 0 8
+ [GNU ZLIB 000040 ]
+[ 4] .zdebug_info PROGBITS 00000000 000253 000058 0 0 0 1
+ [GNU ZLIB 00006e ]
+[ 5] .debug_abbrev PROGBITS 00000000 0002ab 000028 0 0 0 1
+[ 6] .zdebug_line PROGBITS 00000000 0002d3 000059 0 0 0 1
+ [GNU ZLIB 000085 ]
+[ 7] .shstrtab STRTAB 00000000 00032c 000063 0 0 0 1
+[ 8] .symtab SYMTAB 00000000 0000c8 000110 16 9 9 4
+[ 9] .strtab STRTAB 00000000 0001d8 000045 0 0 0 1
+
+EOF
+
+testfiles testfile-zgabi32
+testrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgabi32 <<\EOF
+There are 9 section headers, starting at offset 0x338:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+ [Compression Size Al]
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .text PROGBITS 08048054 000054 00002a 0 AX 0 0 1
+[ 2] .debug_aranges PROGBITS 00000000 0001c0 000031 0 C 0 0 8
+ [ELF ZLIB (1) 000040 8]
+[ 3] .debug_info PROGBITS 00000000 0001f1 00006f 0 C 0 0 1
+ [ELF ZLIB (1) 00009a 1]
+[ 4] .debug_abbrev PROGBITS 00000000 000260 000028 0 0 0 1
+[ 5] .debug_line PROGBITS 00000000 000288 00005a 0 C 0 0 1
+ [ELF ZLIB (1) 000085 1]
+[ 6] .shstrtab STRTAB 00000000 0002e2 000056 0 0 0 1
+[ 7] .symtab SYMTAB 00000000 000080 0000f0 16 8 8 4
+[ 8] .strtab STRTAB 00000000 000170 00004b 0 0 0 1
+
+EOF
+
+testfiles testfile-zgabi32be
+testrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgabi32be <<\EOF
+There are 10 section headers, starting at offset 0x38c:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+ [Compression Size Al]
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .text PROGBITS 01800054 000054 000074 0 AX 0 0 1
+[ 2] .eh_frame PROGBITS 018000c8 0000c8 000000 0 A 0 0 4
+[ 3] .debug_aranges PROGBITS 00000000 000220 000033 0 C 0 0 8
+ [ELF ZLIB (1) 000040 8]
+[ 4] .debug_info PROGBITS 00000000 000253 000058 0 C 0 0 1
+ [ELF ZLIB (1) 00006e 1]
+[ 5] .debug_abbrev PROGBITS 00000000 0002ab 000028 0 0 0 1
+[ 6] .debug_line PROGBITS 00000000 0002d3 000059 0 C 0 0 1
+ [ELF ZLIB (1) 000085 1]
+[ 7] .shstrtab STRTAB 00000000 00032c 000060 0 0 0 1
+[ 8] .symtab SYMTAB 00000000 0000c8 000110 16 9 9 4
+[ 9] .strtab STRTAB 00000000 0001d8 000045 0 0 0 1
+
+EOF
+
+exit 0
diff --git a/tests/run-readelf-zdebug-rel.sh b/tests/run-readelf-zdebug-rel.sh
new file mode 100755
index 0000000..ccccd82
--- /dev/null
+++ b/tests/run-readelf-zdebug-rel.sh
@@ -0,0 +1,149 @@
+#! /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
+
+# - testfile-zdebug-rel.c
+# #define UINT64_MAX 18446744073709551615UL
+#
+# int
+# main (int argc, char **argv)
+# {
+# unsigned long a = UINT64_MAX - 8;
+# unsigned long b = 42 + argc;
+#
+# if ( a + b < b )
+# argc = a + argc;
+# else
+# b--;
+#
+# return a - b;
+# }
+#
+# gcc -Og -g -Xassembler --compress-debug-sections=none \
+# -c -o testfile-debug-rel.o testfile-zdebug-rel.c
+# gcc -Og -g -Xassembler --compress-debug-sections=zlib-gnu \
+# -c -o testfile-debug-rel-g.o testfile-zdebug-rel.c
+# gcc -Og -g -Xassembler --compress-debug-sections=zlib-gabi \
+# -c -o testfile-debug-rel-z.o testfile-zdebug-rel.c
+
+testfiles testfile-debug-rel.o testfile-debug-rel-g.o testfile-debug-rel-z.o
+tempfiles readelf.out
+tempfiles info.out loc.out
+
+cat > info.out << \EOF
+
+DWARF section [ 4] '.debug_info' at offset 0x58:
+ [Offset]
+ Compilation unit at offset 0:
+ Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
+ [ b] compile_unit abbrev: 1
+ producer (strp) "GNU C11 5.3.1 20151207 (Red Hat 5.3.1-2) -mtune=generic -march=x86-64 -g -Og"
+ language (data1) C99 (12)
+ name (strp) "testfile-zdebug-rel.c"
+ comp_dir (strp) "/tmp"
+ low_pc (addr) 000000000000000000
+ high_pc (data8) 24 (0x0000000000000018)
+ stmt_list (sec_offset) 0
+ [ 2d] subprogram abbrev: 2
+ external (flag_present) yes
+ name (strp) "main"
+ decl_file (data1) testfile-zdebug-rel.c (1)
+ decl_line (data1) 4
+ prototyped (flag_present) yes
+ type (ref4) [ 80]
+ low_pc (addr) 000000000000000000
+ high_pc (data8) 24 (0x0000000000000018)
+ frame_base (exprloc)
+ [ 0] call_frame_cfa
+ GNU_all_call_sites (flag_present) yes
+ sibling (ref4) [ 80]
+ [ 4e] formal_parameter abbrev: 3
+ name (strp) "argc"
+ decl_file (data1) testfile-zdebug-rel.c (1)
+ decl_line (data1) 4
+ type (ref4) [ 80]
+ location (sec_offset) location list [ 0]
+ [ 5d] formal_parameter abbrev: 4
+ name (strp) "argv"
+ decl_file (data1) testfile-zdebug-rel.c (1)
+ decl_line (data1) 4
+ type (ref4) [ 87]
+ location (exprloc)
+ [ 0] reg4
+ [ 6a] variable abbrev: 5
+ name (string) "a"
+ decl_file (data1) testfile-zdebug-rel.c (1)
+ decl_line (data1) 6
+ type (ref4) [ 9a]
+ const_value (sdata) -9
+ [ 74] variable abbrev: 6
+ name (string) "b"
+ decl_file (data1) testfile-zdebug-rel.c (1)
+ decl_line (data1) 7
+ type (ref4) [ 9a]
+ location (exprloc)
+ [ 0] reg5
+ [ 80] base_type abbrev: 7
+ byte_size (data1) 4
+ encoding (data1) signed (5)
+ name (string) "int"
+ [ 87] pointer_type abbrev: 8
+ byte_size (data1) 8
+ type (ref4) [ 8d]
+ [ 8d] pointer_type abbrev: 8
+ byte_size (data1) 8
+ type (ref4) [ 93]
+ [ 93] base_type abbrev: 9
+ byte_size (data1) 1
+ encoding (data1) signed_char (6)
+ name (strp) "char"
+ [ 9a] base_type abbrev: 9
+ byte_size (data1) 8
+ encoding (data1) unsigned (7)
+ name (strp) "long unsigned int"
+EOF
+
+cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel.o
+
+cat info.out | sed -e "s/'.debug_info'/'.zdebug_info'/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-g.o
+
+cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-z.o
+
+cat > loc.out << \EOF
+
+DWARF section [ 7] '.debug_loc' at offset 0x185:
+
+ CU [ b] base: 000000000000000000
+ [ 0] range 0, 3
+ [ 0] reg5
+ range 3, 10
+ [ 0] breg5 -42
+ [ 2] stack_value
+ range 10, 18
+ [ 0] GNU_entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+EOF
+
+cat loc.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel.o
+
+cat loc.out | sed -e "s/'.debug_loc' at offset 0x185/'.zdebug_loc' at offset 0x138/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-g.o
+
+cat loc.out | sed -e "s/at offset 0x185/at offset 0x150/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-z.o
+
+exit 0
diff --git a/tests/run-readelf-zdebug.sh b/tests/run-readelf-zdebug.sh
new file mode 100755
index 0000000..28128ad
--- /dev/null
+++ b/tests/run-readelf-zdebug.sh
@@ -0,0 +1,546 @@
+#! /bin/sh
+# Copyright (C) 2014 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
+
+# - testfile-zdebug.c
+# #define UINT64_MAX 18446744073709551615UL
+#
+# int
+# main (int argc, char **argv)
+# {
+# unsigned long a = UINT64_MAX - 8;
+# unsigned long b = 42 + argc;
+#
+# if ( a + b < b )
+# argc = a + argc;
+# else
+# b--;
+#
+# return a - b;
+# }
+#
+# gcc -g3 -O3 -fuse-ld=gold -Xlinker --compress-debug-sections=none \
+# -fno-asynchronous-unwind-tables -o testfile-debug testfile-zdebug.c
+# gcc -g3 -O3 -fuse-ld=gold -Xlinker --compress-debug-sections=zlib \
+# -fno-asynchronous-unwind-tables -o testfile-zdebug testfile-zdebug.c
+
+testfiles testfile-debug testfile-zdebug
+tempfiles readelf.out
+tempfiles loc.out aranges.out ranges.out macro.out line.out frame.out
+
+cat > loc.out << \EOF
+
+DWARF section [30] '.debug_loc' at offset 0xa17:
+
+ CU [ b] base: 000000000000000000
+ [ 0] range 4003c0, 4003c3
+ [ 0] reg5
+ range 4003c3, 4003d6
+ [ 0] breg5 -42
+ [ 2] stack_value
+ range 4003d6, 4003d9
+ [ 0] GNU_entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+EOF
+
+cat loc.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug
+
+cat loc.out | sed -e "s/.debug_loc' at offset 0xa17/.zdebug_loc' at offset 0x1a27/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-zdebug
+
+cat > aranges.out << \EOF
+
+DWARF section [31] '.debug_aranges' at offset 0xa65:
+
+Table at offset 0:
+
+ Length: 44
+ DWARF version: 2
+ CU offset: 0
+ Address size: 8
+ Segment size: 0
+
+ 0x00000000004003c0..0x0000000000000019
+EOF
+
+cat aranges.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=aranges testfile-debug
+
+cat aranges.out | sed -e "s/.debug_aranges' at offset 0xa65/.zdebug_aranges' at offset 0x1a5f/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=aranges testfile-zdebug
+
+cat > ranges.out << \EOF
+
+DWARF section [32] '.debug_ranges' at offset 0xa95:
+
+ CU [ b] base: 000000000000000000
+ [ 0] range 4003c0, 4003d9
+EOF
+
+cat ranges.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=ranges testfile-debug
+
+cat ranges.out | sed -e "s/.debug_ranges' at offset 0xa95/.zdebug_ranges' at offset 0x1a87/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=ranges testfile-zdebug
+
+cat > macro.out << \EOF
+
+DWARF section [33] '.debug_macro' at offset 0xab5:
+
+ Offset: 0x0
+ Version: 4
+ Flag: 0x2
+ Offset length: 4
+ .debug_line offset: 0x0
+
+ #include offset 0x17
+ start_file 0, [1] /tmp/testfile-zdebug.c
+ #define UINT64_MAX 18446744073709551615UL, line 1 (indirect)
+ end_file
+
+ Offset: 0x17
+ Version: 4
+ Flag: 0x0
+ Offset length: 4
+
+ #define __STDC__ 1, line 1 (indirect)
+ #define __STDC_HOSTED__ 1, line 1 (indirect)
+ #define __GNUC__ 4, line 1 (indirect)
+ #define __GNUC_MINOR__ 8, line 1 (indirect)
+ #define __GNUC_PATCHLEVEL__ 2, line 1 (indirect)
+ #define __VERSION__ "4.8.2 20140120 (Red Hat 4.8.2-15)", line 1 (indirect)
+ #define __GNUC_RH_RELEASE__ 15, line 1 (indirect)
+ #define __ATOMIC_RELAXED 0, line 1 (indirect)
+ #define __ATOMIC_SEQ_CST 5, line 1 (indirect)
+ #define __ATOMIC_ACQUIRE 2, line 1 (indirect)
+ #define __ATOMIC_RELEASE 3, line 1 (indirect)
+ #define __ATOMIC_ACQ_REL 4, line 1 (indirect)
+ #define __ATOMIC_CONSUME 1, line 1 (indirect)
+ #define __OPTIMIZE__ 1, line 1 (indirect)
+ #define __FINITE_MATH_ONLY__ 0, line 1 (indirect)
+ #define _LP64 1, line 1 (indirect)
+ #define __LP64__ 1, line 1 (indirect)
+ #define __SIZEOF_INT__ 4, line 1 (indirect)
+ #define __SIZEOF_LONG__ 8, line 1 (indirect)
+ #define __SIZEOF_LONG_LONG__ 8, line 1 (indirect)
+ #define __SIZEOF_SHORT__ 2, line 1 (indirect)
+ #define __SIZEOF_FLOAT__ 4, line 1 (indirect)
+ #define __SIZEOF_DOUBLE__ 8, line 1 (indirect)
+ #define __SIZEOF_LONG_DOUBLE__ 16, line 1 (indirect)
+ #define __SIZEOF_SIZE_T__ 8, line 1 (indirect)
+ #define __CHAR_BIT__ 8, line 1 (indirect)
+ #define __BIGGEST_ALIGNMENT__ 16, line 1 (indirect)
+ #define __ORDER_LITTLE_ENDIAN__ 1234, line 1 (indirect)
+ #define __ORDER_BIG_ENDIAN__ 4321, line 1 (indirect)
+ #define __ORDER_PDP_ENDIAN__ 3412, line 1 (indirect)
+ #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__, line 1 (indirect)
+ #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__, line 1 (indirect)
+ #define __SIZEOF_POINTER__ 8, line 1 (indirect)
+ #define __SIZE_TYPE__ long unsigned int, line 1 (indirect)
+ #define __PTRDIFF_TYPE__ long int, line 1 (indirect)
+ #define __WCHAR_TYPE__ int, line 1 (indirect)
+ #define __WINT_TYPE__ unsigned int, line 1 (indirect)
+ #define __INTMAX_TYPE__ long int, line 1 (indirect)
+ #define __UINTMAX_TYPE__ long unsigned int, line 1 (indirect)
+ #define __CHAR16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __CHAR32_TYPE__ unsigned int, line 1 (indirect)
+ #define __SIG_ATOMIC_TYPE__ int, line 1 (indirect)
+ #define __INT8_TYPE__ signed char, line 1 (indirect)
+ #define __INT16_TYPE__ short int, line 1 (indirect)
+ #define __INT32_TYPE__ int, line 1 (indirect)
+ #define __INT64_TYPE__ long int, line 1 (indirect)
+ #define __UINT8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __UINT32_TYPE__ unsigned int, line 1 (indirect)
+ #define __UINT64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INT_LEAST8_TYPE__ signed char, line 1 (indirect)
+ #define __INT_LEAST16_TYPE__ short int, line 1 (indirect)
+ #define __INT_LEAST32_TYPE__ int, line 1 (indirect)
+ #define __INT_LEAST64_TYPE__ long int, line 1 (indirect)
+ #define __UINT_LEAST8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT_LEAST16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __UINT_LEAST32_TYPE__ unsigned int, line 1 (indirect)
+ #define __UINT_LEAST64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INT_FAST8_TYPE__ signed char, line 1 (indirect)
+ #define __INT_FAST16_TYPE__ long int, line 1 (indirect)
+ #define __INT_FAST32_TYPE__ long int, line 1 (indirect)
+ #define __INT_FAST64_TYPE__ long int, line 1 (indirect)
+ #define __UINT_FAST8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT_FAST16_TYPE__ long unsigned int, line 1 (indirect)
+ #define __UINT_FAST32_TYPE__ long unsigned int, line 1 (indirect)
+ #define __UINT_FAST64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INTPTR_TYPE__ long int, line 1 (indirect)
+ #define __UINTPTR_TYPE__ long unsigned int, line 1 (indirect)
+ #define __GXX_ABI_VERSION 1002, line 1 (indirect)
+ #define __SCHAR_MAX__ 127, line 1 (indirect)
+ #define __SHRT_MAX__ 32767, line 1 (indirect)
+ #define __INT_MAX__ 2147483647, line 1 (indirect)
+ #define __LONG_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __LONG_LONG_MAX__ 9223372036854775807LL, line 1 (indirect)
+ #define __WCHAR_MAX__ 2147483647, line 1 (indirect)
+ #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1), line 1 (indirect)
+ #define __WINT_MAX__ 4294967295U, line 1 (indirect)
+ #define __WINT_MIN__ 0U, line 1 (indirect)
+ #define __PTRDIFF_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __SIZE_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INTMAX_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INTMAX_C(c) c ## L, line 1 (indirect)
+ #define __UINTMAX_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINTMAX_C(c) c ## UL, line 1 (indirect)
+ #define __SIG_ATOMIC_MAX__ 2147483647, line 1 (indirect)
+ #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1), line 1 (indirect)
+ #define __INT8_MAX__ 127, line 1 (indirect)
+ #define __INT16_MAX__ 32767, line 1 (indirect)
+ #define __INT32_MAX__ 2147483647, line 1 (indirect)
+ #define __INT64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINT8_MAX__ 255, line 1 (indirect)
+ #define __UINT16_MAX__ 65535, line 1 (indirect)
+ #define __UINT32_MAX__ 4294967295U, line 1 (indirect)
+ #define __UINT64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INT_LEAST8_MAX__ 127, line 1 (indirect)
+ #define __INT8_C(c) c, line 1 (indirect)
+ #define __INT_LEAST16_MAX__ 32767, line 1 (indirect)
+ #define __INT16_C(c) c, line 1 (indirect)
+ #define __INT_LEAST32_MAX__ 2147483647, line 1 (indirect)
+ #define __INT32_C(c) c, line 1 (indirect)
+ #define __INT_LEAST64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT64_C(c) c ## L, line 1 (indirect)
+ #define __UINT_LEAST8_MAX__ 255, line 1 (indirect)
+ #define __UINT8_C(c) c, line 1 (indirect)
+ #define __UINT_LEAST16_MAX__ 65535, line 1 (indirect)
+ #define __UINT16_C(c) c, line 1 (indirect)
+ #define __UINT_LEAST32_MAX__ 4294967295U, line 1 (indirect)
+ #define __UINT32_C(c) c ## U, line 1 (indirect)
+ #define __UINT_LEAST64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT64_C(c) c ## UL, line 1 (indirect)
+ #define __INT_FAST8_MAX__ 127, line 1 (indirect)
+ #define __INT_FAST16_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT_FAST32_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT_FAST64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINT_FAST8_MAX__ 255, line 1 (indirect)
+ #define __UINT_FAST16_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT_FAST32_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT_FAST64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INTPTR_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINTPTR_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __FLT_EVAL_METHOD__ 0, line 1 (indirect)
+ #define __DEC_EVAL_METHOD__ 2, line 1 (indirect)
+ #define __FLT_RADIX__ 2, line 1 (indirect)
+ #define __FLT_MANT_DIG__ 24, line 1 (indirect)
+ #define __FLT_DIG__ 6, line 1 (indirect)
+ #define __FLT_MIN_EXP__ (-125), line 1 (indirect)
+ #define __FLT_MIN_10_EXP__ (-37), line 1 (indirect)
+ #define __FLT_MAX_EXP__ 128, line 1 (indirect)
+ #define __FLT_MAX_10_EXP__ 38, line 1 (indirect)
+ #define __FLT_DECIMAL_DIG__ 9, line 1 (indirect)
+ #define __FLT_MAX__ 3.40282346638528859812e+38F, line 1 (indirect)
+ #define __FLT_MIN__ 1.17549435082228750797e-38F, line 1 (indirect)
+ #define __FLT_EPSILON__ 1.19209289550781250000e-7F, line 1 (indirect)
+ #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F, line 1 (indirect)
+ #define __FLT_HAS_DENORM__ 1, line 1 (indirect)
+ #define __FLT_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __FLT_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __DBL_MANT_DIG__ 53, line 1 (indirect)
+ #define __DBL_DIG__ 15, line 1 (indirect)
+ #define __DBL_MIN_EXP__ (-1021), line 1 (indirect)
+ #define __DBL_MIN_10_EXP__ (-307), line 1 (indirect)
+ #define __DBL_MAX_EXP__ 1024, line 1 (indirect)
+ #define __DBL_MAX_10_EXP__ 308, line 1 (indirect)
+ #define __DBL_DECIMAL_DIG__ 17, line 1 (indirect)
+ #define __DBL_MAX__ ((double)1.79769313486231570815e+308L), line 1 (indirect)
+ #define __DBL_MIN__ ((double)2.22507385850720138309e-308L), line 1 (indirect)
+ #define __DBL_EPSILON__ ((double)2.22044604925031308085e-16L), line 1 (indirect)
+ #define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L), line 1 (indirect)
+ #define __DBL_HAS_DENORM__ 1, line 1 (indirect)
+ #define __DBL_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __DBL_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __LDBL_MANT_DIG__ 64, line 1 (indirect)
+ #define __LDBL_DIG__ 18, line 1 (indirect)
+ #define __LDBL_MIN_EXP__ (-16381), line 1 (indirect)
+ #define __LDBL_MIN_10_EXP__ (-4931), line 1 (indirect)
+ #define __LDBL_MAX_EXP__ 16384, line 1 (indirect)
+ #define __LDBL_MAX_10_EXP__ 4932, line 1 (indirect)
+ #define __DECIMAL_DIG__ 21, line 1 (indirect)
+ #define __LDBL_MAX__ 1.18973149535723176502e+4932L, line 1 (indirect)
+ #define __LDBL_MIN__ 3.36210314311209350626e-4932L, line 1 (indirect)
+ #define __LDBL_EPSILON__ 1.08420217248550443401e-19L, line 1 (indirect)
+ #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L, line 1 (indirect)
+ #define __LDBL_HAS_DENORM__ 1, line 1 (indirect)
+ #define __LDBL_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __LDBL_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __DEC32_MANT_DIG__ 7, line 1 (indirect)
+ #define __DEC32_MIN_EXP__ (-94), line 1 (indirect)
+ #define __DEC32_MAX_EXP__ 97, line 1 (indirect)
+ #define __DEC32_MIN__ 1E-95DF, line 1 (indirect)
+ #define __DEC32_MAX__ 9.999999E96DF, line 1 (indirect)
+ #define __DEC32_EPSILON__ 1E-6DF, line 1 (indirect)
+ #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF, line 1 (indirect)
+ #define __DEC64_MANT_DIG__ 16, line 1 (indirect)
+ #define __DEC64_MIN_EXP__ (-382), line 1 (indirect)
+ #define __DEC64_MAX_EXP__ 385, line 1 (indirect)
+ #define __DEC64_MIN__ 1E-383DD, line 1 (indirect)
+ #define __DEC64_MAX__ 9.999999999999999E384DD, line 1 (indirect)
+ #define __DEC64_EPSILON__ 1E-15DD, line 1 (indirect)
+ #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD, line 1 (indirect)
+ #define __DEC128_MANT_DIG__ 34, line 1 (indirect)
+ #define __DEC128_MIN_EXP__ (-6142), line 1 (indirect)
+ #define __DEC128_MAX_EXP__ 6145, line 1 (indirect)
+ #define __DEC128_MIN__ 1E-6143DL, line 1 (indirect)
+ #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL, line 1 (indirect)
+ #define __DEC128_EPSILON__ 1E-33DL, line 1 (indirect)
+ #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL, line 1 (indirect)
+ #define __REGISTER_PREFIX__ , line 1 (indirect)
+ #define __USER_LABEL_PREFIX__ , line 1 (indirect)
+ #define __GNUC_GNU_INLINE__ 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1, line 1 (indirect)
+ #define __GCC_ATOMIC_BOOL_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_SHORT_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_INT_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_LONG_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_LLONG_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1, line 1 (indirect)
+ #define __GCC_ATOMIC_POINTER_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_HAVE_DWARF2_CFI_ASM 1, line 1 (indirect)
+ #define __PRAGMA_REDEFINE_EXTNAME 1, line 1 (indirect)
+ #define __SIZEOF_INT128__ 16, line 1 (indirect)
+ #define __SIZEOF_WCHAR_T__ 4, line 1 (indirect)
+ #define __SIZEOF_WINT_T__ 4, line 1 (indirect)
+ #define __SIZEOF_PTRDIFF_T__ 8, line 1 (indirect)
+ #define __amd64 1, line 1 (indirect)
+ #define __amd64__ 1, line 1 (indirect)
+ #define __x86_64 1, line 1 (indirect)
+ #define __x86_64__ 1, line 1 (indirect)
+ #define __ATOMIC_HLE_ACQUIRE 65536, line 1 (indirect)
+ #define __ATOMIC_HLE_RELEASE 131072, line 1 (indirect)
+ #define __k8 1, line 1 (indirect)
+ #define __k8__ 1, line 1 (indirect)
+ #define __code_model_small__ 1, line 1 (indirect)
+ #define __MMX__ 1, line 1 (indirect)
+ #define __SSE__ 1, line 1 (indirect)
+ #define __SSE2__ 1, line 1 (indirect)
+ #define __FXSR__ 1, line 1 (indirect)
+ #define __SSE_MATH__ 1, line 1 (indirect)
+ #define __SSE2_MATH__ 1, line 1 (indirect)
+ #define __gnu_linux__ 1, line 1 (indirect)
+ #define __linux 1, line 1 (indirect)
+ #define __linux__ 1, line 1 (indirect)
+ #define linux 1, line 1 (indirect)
+ #define __unix 1, line 1 (indirect)
+ #define __unix__ 1, line 1 (indirect)
+ #define unix 1, line 1 (indirect)
+ #define __ELF__ 1, line 1 (indirect)
+ #define __DECIMAL_BID_FORMAT__ 1, line 1 (indirect)
+
+EOF
+
+cat macro.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=macro testfile-debug
+
+cat macro.out | sed -e "s/.debug_macro' at offset 0xab5/.zdebug_macro' at offset 0x1aa7/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=macro testfile-zdebug
+
+cat > line.out << \EOF
+
+DWARF section [34] '.debug_line' at offset 0x104c:
+
+Table at offset 0:
+
+ Length: 70
+ DWARF version: 2
+ Prologue length: 40
+ Minimum instruction length: 1
+ Maximum operations per instruction: 1
+ Initial value if 'is_stmt': 1
+ Line base: -5
+ Line range: 14
+ Opcode base: 13
+
+Opcodes:
+ [ 1] 0 arguments
+ [ 2] 1 argument
+ [ 3] 1 argument
+ [ 4] 1 argument
+ [ 5] 1 argument
+ [ 6] 0 arguments
+ [ 7] 0 arguments
+ [ 8] 0 arguments
+ [ 9] 1 argument
+ [10] 0 arguments
+ [11] 0 arguments
+ [12] 1 argument
+
+Directory table:
+
+File name table:
+ Entry Dir Time Size Name
+ 1 0 0 0 testfile-zdebug.c
+
+Line number statements:
+ [ 32] extended opcode 2: set address to 0x4003c0
+ [ 3d] special opcode 22: address+0 = 0x4003c0, line+4 = 5
+ [ 3e] special opcode 20: address+0 = 0x4003c0, line+2 = 7
+ [ 3f] special opcode 104: address+6 = 0x4003c6, line+2 = 9
+ [ 40] special opcode 77: address+4 = 0x4003ca, line+3 = 12
+ [ 41] special opcode 62: address+3 = 0x4003cd, line+2 = 14
+ [ 42] special opcode 86: address+5 = 0x4003d2, line-2 = 12
+ [ 43] special opcode 76: address+4 = 0x4003d6, line+2 = 14
+ [ 44] special opcode 47: address+2 = 0x4003d8, line+1 = 15
+ [ 45] advance address by 1 to 0x4003d9
+ [ 47] extended opcode 1: end of sequence
+EOF
+
+cat line.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=line testfile-debug
+
+cat line.out | sed -e "s/.debug_line' at offset 0x104c/.zdebug_line' at offset 0x1d53/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=line testfile-zdebug
+
+
+cat > frame.out << \EOF
+
+Call frame information section [16] '.eh_frame' at offset 0x5b8:
+
+ [ 0] CIE length=20
+ CIE_id: 0
+ version: 1
+ augmentation: "zR"
+ code_alignment_factor: 1
+ data_alignment_factor: -8
+ return_address_register: 16
+ Augmentation data: 0x1b (FDE address encoding: sdata4 pcrel)
+
+ Program:
+ def_cfa r7 (rsp) at offset 8
+ offset r16 (rip) at cfa-8
+ nop
+ nop
+
+ [ 18] FDE length=20 cie=[ 0]
+ CIE_pointer: 28
+ initial_location: 0x00000000ffffff08 (offset: 0x4e0)
+ address_range: 0x2 (end offset: 0x4e2)
+
+ Program:
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+
+ [ 30] FDE length=44 cie=[ 0]
+ CIE_pointer: 52
+ initial_location: 0x00000000ffffff00 (offset: 0x4f0)
+ address_range: 0x89 (end offset: 0x579)
+
+ Program:
+ advance_loc 17 to 0x501
+ offset r12 (r12) at cfa-40
+ offset r6 (rbp) at cfa-48
+ advance_loc 31 to 0x520
+ def_cfa_offset 64
+ offset r3 (rbx) at cfa-56
+ offset r15 (r15) at cfa-16
+ offset r14 (r14) at cfa-24
+ offset r13 (r13) at cfa-32
+ advance_loc1 88 to 0x578
+ def_cfa_offset 8
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+
+ [ 60] FDE length=36 cie=[ 0]
+ CIE_pointer: 100
+ initial_location: 0x00000000fffffd80 (offset: 0x3a0)
+ address_range: 0x20 (end offset: 0x3c0)
+
+ Program:
+ def_cfa_offset 16
+ advance_loc 6 to 0x3a6
+ def_cfa_offset 24
+ advance_loc 10 to 0x3b0
+ def_cfa_expression 11
+ [ 0] breg7 8
+ [ 2] breg16 0
+ [ 4] lit15
+ [ 5] and
+ [ 6] lit11
+ [ 7] ge
+ [ 8] lit3
+ [ 9] shl
+ [10] plus
+ nop
+ nop
+ nop
+ nop
+
+ [ 88] Zero terminator
+
+Call frame search table section [17] '.eh_frame_hdr':
+ version: 1
+ eh_frame_ptr_enc: 0x1b (sdata4 pcrel)
+ fde_count_enc: 0x3 (udata4)
+ table_enc: 0x3b (sdata4 datarel)
+ eh_frame_ptr: 0xffffffffffffff70 (offset: 0x5b8)
+ fde_count: 3
+ Table:
+ 0xfffffd5c (offset: 0x3a0) -> 0xffffffd4 fde=[ 60]
+ 0xfffffe9c (offset: 0x4e0) -> 0xffffff8c fde=[ 18]
+ 0xfffffeac (offset: 0x4f0) -> 0xffffffa4 fde=[ 30]
+
+DWARF section [36] '.debug_frame' at offset 0x29b8:
+
+ [ 0] CIE length=20
+ CIE_id: 18446744073709551615
+ version: 1
+ augmentation: ""
+ code_alignment_factor: 1
+ data_alignment_factor: -8
+ return_address_register: 16
+
+ Program:
+ def_cfa r7 (rsp) at offset 8
+ offset r16 (rip) at cfa-8
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+
+ [ 18] FDE length=20 cie=[ 0]
+ CIE_pointer: 0
+ initial_location: 0x00000000004003c0
+ address_range: 0x19
+
+ Program:
+EOF
+
+cat frame.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=frame testfile-debug
+
+cat frame.out | sed -e "s/.debug_frame' at offset 0x29b8/.zdebug_frame' at offset 0x2728/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=frame testfile-zdebug
+
+
diff --git a/tests/run-readelf-zp.sh b/tests/run-readelf-zp.sh
new file mode 100755
index 0000000..872126c
--- /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 0000000..994528c
--- /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
diff --git a/tests/run-rerequest_tag.sh b/tests/run-rerequest_tag.sh
new file mode 100755
index 0000000..f437284
--- /dev/null
+++ b/tests/run-rerequest_tag.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+# Copyright (C) 2011 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
+
+testfiles testfile56 testfile57
+
+testrun ${abs_builddir}/rerequest_tag testfile56
+testrun ${abs_builddir}/rerequest_tag testfile57
+
+exit 0
diff --git a/tests/run-show-abbrev.sh b/tests/run-show-abbrev.sh
new file mode 100755
index 0000000..40d0e36
--- /dev/null
+++ b/tests/run-show-abbrev.sh
@@ -0,0 +1,352 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+testfiles testfile testfile2
+
+testrun_compare ${abs_builddir}/show-abbrev testfile testfile2 <<\EOF
+abbrev[0]: code = 1, tag = 17, children = 1
+abbrev[0]: attr[0]: code = 16, form = 6, offset = 0
+abbrev[0]: attr[1]: code = 18, form = 1, offset = 2
+abbrev[0]: attr[2]: code = 17, form = 1, offset = 4
+abbrev[0]: attr[3]: code = 3, form = 8, offset = 6
+abbrev[0]: attr[4]: code = 27, form = 8, offset = 8
+abbrev[0]: attr[5]: code = 37, form = 8, offset = 10
+abbrev[0]: attr[6]: code = 19, form = 11, offset = 12
+abbrev[19]: code = 2, tag = 46, children = 1
+abbrev[19]: attr[0]: code = 1, form = 19, offset = 19
+abbrev[19]: attr[1]: code = 63, form = 12, offset = 21
+abbrev[19]: attr[2]: code = 3, form = 8, offset = 23
+abbrev[19]: attr[3]: code = 58, form = 11, offset = 25
+abbrev[19]: attr[4]: code = 59, form = 11, offset = 27
+abbrev[19]: attr[5]: code = 39, form = 12, offset = 29
+abbrev[19]: attr[6]: code = 73, form = 19, offset = 31
+abbrev[19]: attr[7]: code = 17, form = 1, offset = 33
+abbrev[19]: attr[8]: code = 18, form = 1, offset = 35
+abbrev[19]: attr[9]: code = 64, form = 10, offset = 37
+abbrev[44]: code = 3, tag = 46, children = 1
+abbrev[44]: attr[0]: code = 1, form = 19, offset = 44
+abbrev[44]: attr[1]: code = 63, form = 12, offset = 46
+abbrev[44]: attr[2]: code = 3, form = 8, offset = 48
+abbrev[44]: attr[3]: code = 58, form = 11, offset = 50
+abbrev[44]: attr[4]: code = 59, form = 11, offset = 52
+abbrev[44]: attr[5]: code = 73, form = 19, offset = 54
+abbrev[44]: attr[6]: code = 60, form = 12, offset = 56
+abbrev[63]: code = 4, tag = 24, children = 0
+abbrev[68]: code = 5, tag = 46, children = 1
+abbrev[68]: attr[0]: code = 63, form = 12, offset = 68
+abbrev[68]: attr[1]: code = 3, form = 8, offset = 70
+abbrev[68]: attr[2]: code = 58, form = 11, offset = 72
+abbrev[68]: attr[3]: code = 59, form = 11, offset = 74
+abbrev[68]: attr[4]: code = 73, form = 19, offset = 76
+abbrev[68]: attr[5]: code = 60, form = 12, offset = 78
+abbrev[85]: code = 6, tag = 36, children = 0
+abbrev[85]: attr[0]: code = 3, form = 8, offset = 85
+abbrev[85]: attr[1]: code = 11, form = 11, offset = 87
+abbrev[85]: attr[2]: code = 62, form = 11, offset = 89
+abbrev[96]: code = 7, tag = 52, children = 0
+abbrev[96]: attr[0]: code = 3, form = 8, offset = 96
+abbrev[96]: attr[1]: code = 58, form = 11, offset = 98
+abbrev[96]: attr[2]: code = 59, form = 11, offset = 100
+abbrev[96]: attr[3]: code = 73, form = 19, offset = 102
+abbrev[96]: attr[4]: code = 63, form = 12, offset = 104
+abbrev[96]: attr[5]: code = 2, form = 10, offset = 106
+abbrev[0]: code = 1, tag = 17, children = 1
+abbrev[0]: attr[0]: code = 16, form = 6, offset = 114
+abbrev[0]: attr[1]: code = 18, form = 1, offset = 116
+abbrev[0]: attr[2]: code = 17, form = 1, offset = 118
+abbrev[0]: attr[3]: code = 3, form = 8, offset = 120
+abbrev[0]: attr[4]: code = 27, form = 8, offset = 122
+abbrev[0]: attr[5]: code = 37, form = 8, offset = 124
+abbrev[0]: attr[6]: code = 19, form = 11, offset = 126
+abbrev[19]: code = 2, tag = 46, children = 0
+abbrev[19]: attr[0]: code = 63, form = 12, offset = 133
+abbrev[19]: attr[1]: code = 3, form = 8, offset = 135
+abbrev[19]: attr[2]: code = 58, form = 11, offset = 137
+abbrev[19]: attr[3]: code = 59, form = 11, offset = 139
+abbrev[19]: attr[4]: code = 39, form = 12, offset = 141
+abbrev[19]: attr[5]: code = 73, form = 19, offset = 143
+abbrev[19]: attr[6]: code = 17, form = 1, offset = 145
+abbrev[19]: attr[7]: code = 18, form = 1, offset = 147
+abbrev[19]: attr[8]: code = 64, form = 10, offset = 149
+abbrev[42]: code = 3, tag = 36, children = 0
+abbrev[42]: attr[0]: code = 3, form = 8, offset = 156
+abbrev[42]: attr[1]: code = 11, form = 11, offset = 158
+abbrev[42]: attr[2]: code = 62, form = 11, offset = 160
+abbrev[53]: code = 4, tag = 22, children = 0
+abbrev[53]: attr[0]: code = 3, form = 8, offset = 167
+abbrev[53]: attr[1]: code = 58, form = 11, offset = 169
+abbrev[53]: attr[2]: code = 59, form = 11, offset = 171
+abbrev[53]: attr[3]: code = 73, form = 19, offset = 173
+abbrev[66]: code = 5, tag = 15, children = 0
+abbrev[66]: attr[0]: code = 11, form = 11, offset = 180
+abbrev[73]: code = 6, tag = 15, children = 0
+abbrev[73]: attr[0]: code = 11, form = 11, offset = 187
+abbrev[73]: attr[1]: code = 73, form = 19, offset = 189
+abbrev[82]: code = 7, tag = 19, children = 1
+abbrev[82]: attr[0]: code = 1, form = 19, offset = 196
+abbrev[82]: attr[1]: code = 11, form = 11, offset = 198
+abbrev[82]: attr[2]: code = 58, form = 11, offset = 200
+abbrev[82]: attr[3]: code = 59, form = 11, offset = 202
+abbrev[95]: code = 8, tag = 13, children = 0
+abbrev[95]: attr[0]: code = 3, form = 8, offset = 209
+abbrev[95]: attr[1]: code = 58, form = 11, offset = 211
+abbrev[95]: attr[2]: code = 59, form = 11, offset = 213
+abbrev[95]: attr[3]: code = 73, form = 19, offset = 215
+abbrev[95]: attr[4]: code = 56, form = 10, offset = 217
+abbrev[110]: code = 9, tag = 1, children = 1
+abbrev[110]: attr[0]: code = 1, form = 19, offset = 224
+abbrev[110]: attr[1]: code = 73, form = 19, offset = 226
+abbrev[119]: code = 10, tag = 33, children = 0
+abbrev[119]: attr[0]: code = 73, form = 19, offset = 233
+abbrev[119]: attr[1]: code = 47, form = 11, offset = 235
+abbrev[128]: code = 11, tag = 19, children = 1
+abbrev[128]: attr[0]: code = 1, form = 19, offset = 242
+abbrev[128]: attr[1]: code = 3, form = 8, offset = 244
+abbrev[128]: attr[2]: code = 11, form = 11, offset = 246
+abbrev[128]: attr[3]: code = 58, form = 11, offset = 248
+abbrev[128]: attr[4]: code = 59, form = 11, offset = 250
+abbrev[143]: code = 12, tag = 19, children = 0
+abbrev[143]: attr[0]: code = 3, form = 8, offset = 257
+abbrev[143]: attr[1]: code = 60, form = 12, offset = 259
+abbrev[152]: code = 13, tag = 13, children = 0
+abbrev[152]: attr[0]: code = 3, form = 8, offset = 266
+abbrev[152]: attr[1]: code = 58, form = 11, offset = 268
+abbrev[152]: attr[2]: code = 59, form = 5, offset = 270
+abbrev[152]: attr[3]: code = 73, form = 19, offset = 272
+abbrev[152]: attr[4]: code = 56, form = 10, offset = 274
+abbrev[167]: code = 14, tag = 22, children = 0
+abbrev[167]: attr[0]: code = 3, form = 8, offset = 281
+abbrev[167]: attr[1]: code = 58, form = 11, offset = 283
+abbrev[167]: attr[2]: code = 59, form = 5, offset = 285
+abbrev[167]: attr[3]: code = 73, form = 19, offset = 287
+abbrev[180]: code = 15, tag = 23, children = 1
+abbrev[180]: attr[0]: code = 1, form = 19, offset = 294
+abbrev[180]: attr[1]: code = 11, form = 11, offset = 296
+abbrev[180]: attr[2]: code = 58, form = 11, offset = 298
+abbrev[180]: attr[3]: code = 59, form = 11, offset = 300
+abbrev[193]: code = 16, tag = 13, children = 0
+abbrev[193]: attr[0]: code = 3, form = 8, offset = 307
+abbrev[193]: attr[1]: code = 58, form = 11, offset = 309
+abbrev[193]: attr[2]: code = 59, form = 11, offset = 311
+abbrev[193]: attr[3]: code = 73, form = 19, offset = 313
+abbrev[206]: code = 17, tag = 4, children = 1
+abbrev[206]: attr[0]: code = 1, form = 19, offset = 320
+abbrev[206]: attr[1]: code = 11, form = 11, offset = 322
+abbrev[206]: attr[2]: code = 58, form = 11, offset = 324
+abbrev[206]: attr[3]: code = 59, form = 11, offset = 326
+abbrev[219]: code = 18, tag = 40, children = 0
+abbrev[219]: attr[0]: code = 3, form = 8, offset = 333
+abbrev[219]: attr[1]: code = 28, form = 11, offset = 335
+abbrev[228]: code = 19, tag = 38, children = 0
+abbrev[228]: attr[0]: code = 73, form = 19, offset = 342
+abbrev[235]: code = 20, tag = 21, children = 1
+abbrev[235]: attr[0]: code = 1, form = 19, offset = 349
+abbrev[235]: attr[1]: code = 39, form = 12, offset = 351
+abbrev[235]: attr[2]: code = 73, form = 19, offset = 353
+abbrev[246]: code = 21, tag = 5, children = 0
+abbrev[246]: attr[0]: code = 73, form = 19, offset = 360
+abbrev[253]: code = 22, tag = 21, children = 1
+abbrev[253]: attr[0]: code = 1, form = 19, offset = 367
+abbrev[253]: attr[1]: code = 39, form = 12, offset = 369
+abbrev[262]: code = 23, tag = 33, children = 0
+abbrev[262]: attr[0]: code = 73, form = 19, offset = 376
+abbrev[262]: attr[1]: code = 47, form = 6, offset = 378
+abbrev[271]: code = 24, tag = 22, children = 0
+abbrev[271]: attr[0]: code = 3, form = 8, offset = 385
+abbrev[271]: attr[1]: code = 58, form = 11, offset = 387
+abbrev[271]: attr[2]: code = 59, form = 11, offset = 389
+abbrev[282]: code = 25, tag = 4, children = 1
+abbrev[282]: attr[0]: code = 1, form = 19, offset = 396
+abbrev[282]: attr[1]: code = 3, form = 8, offset = 398
+abbrev[282]: attr[2]: code = 11, form = 11, offset = 400
+abbrev[282]: attr[3]: code = 58, form = 11, offset = 402
+abbrev[282]: attr[4]: code = 59, form = 11, offset = 404
+abbrev[0]: code = 1, tag = 17, children = 1
+abbrev[0]: attr[0]: code = 16, form = 6, offset = 412
+abbrev[0]: attr[1]: code = 18, form = 1, offset = 414
+abbrev[0]: attr[2]: code = 17, form = 1, offset = 416
+abbrev[0]: attr[3]: code = 3, form = 8, offset = 418
+abbrev[0]: attr[4]: code = 27, form = 8, offset = 420
+abbrev[0]: attr[5]: code = 37, form = 8, offset = 422
+abbrev[0]: attr[6]: code = 19, form = 11, offset = 424
+abbrev[19]: code = 2, tag = 46, children = 0
+abbrev[19]: attr[0]: code = 63, form = 12, offset = 431
+abbrev[19]: attr[1]: code = 3, form = 8, offset = 433
+abbrev[19]: attr[2]: code = 58, form = 11, offset = 435
+abbrev[19]: attr[3]: code = 59, form = 11, offset = 437
+abbrev[19]: attr[4]: code = 39, form = 12, offset = 439
+abbrev[19]: attr[5]: code = 73, form = 19, offset = 441
+abbrev[19]: attr[6]: code = 17, form = 1, offset = 443
+abbrev[19]: attr[7]: code = 18, form = 1, offset = 445
+abbrev[19]: attr[8]: code = 64, form = 10, offset = 447
+abbrev[42]: code = 3, tag = 36, children = 0
+abbrev[42]: attr[0]: code = 3, form = 8, offset = 454
+abbrev[42]: attr[1]: code = 11, form = 11, offset = 456
+abbrev[42]: attr[2]: code = 62, form = 11, offset = 458
+abbrev[0]: code = 1, tag = 17, children = 1
+abbrev[0]: attr[0]: code = 16, form = 6, offset = 0
+abbrev[0]: attr[1]: code = 18, form = 1, offset = 2
+abbrev[0]: attr[2]: code = 17, form = 1, offset = 4
+abbrev[0]: attr[3]: code = 3, form = 8, offset = 6
+abbrev[0]: attr[4]: code = 27, form = 8, offset = 8
+abbrev[0]: attr[5]: code = 37, form = 8, offset = 10
+abbrev[0]: attr[6]: code = 19, form = 11, offset = 12
+abbrev[19]: code = 2, tag = 46, children = 0
+abbrev[19]: attr[0]: code = 63, form = 12, offset = 19
+abbrev[19]: attr[1]: code = 3, form = 8, offset = 21
+abbrev[19]: attr[2]: code = 58, form = 11, offset = 23
+abbrev[19]: attr[3]: code = 59, form = 11, offset = 25
+abbrev[19]: attr[4]: code = 39, form = 12, offset = 27
+abbrev[19]: attr[5]: code = 73, form = 19, offset = 29
+abbrev[19]: attr[6]: code = 17, form = 1, offset = 31
+abbrev[19]: attr[7]: code = 18, form = 1, offset = 33
+abbrev[19]: attr[8]: code = 64, form = 10, offset = 35
+abbrev[42]: code = 3, tag = 36, children = 0
+abbrev[42]: attr[0]: code = 3, form = 8, offset = 42
+abbrev[42]: attr[1]: code = 11, form = 11, offset = 44
+abbrev[42]: attr[2]: code = 62, form = 11, offset = 46
+abbrev[53]: code = 4, tag = 22, children = 0
+abbrev[53]: attr[0]: code = 3, form = 8, offset = 53
+abbrev[53]: attr[1]: code = 58, form = 11, offset = 55
+abbrev[53]: attr[2]: code = 59, form = 11, offset = 57
+abbrev[53]: attr[3]: code = 73, form = 19, offset = 59
+abbrev[66]: code = 5, tag = 1, children = 1
+abbrev[66]: attr[0]: code = 1, form = 19, offset = 66
+abbrev[66]: attr[1]: code = 3, form = 8, offset = 68
+abbrev[66]: attr[2]: code = 73, form = 19, offset = 70
+abbrev[77]: code = 6, tag = 33, children = 0
+abbrev[77]: attr[0]: code = 73, form = 19, offset = 77
+abbrev[77]: attr[1]: code = 47, form = 11, offset = 79
+abbrev[86]: code = 7, tag = 19, children = 1
+abbrev[86]: attr[0]: code = 1, form = 19, offset = 86
+abbrev[86]: attr[1]: code = 3, form = 8, offset = 88
+abbrev[86]: attr[2]: code = 11, form = 11, offset = 90
+abbrev[86]: attr[3]: code = 58, form = 11, offset = 92
+abbrev[86]: attr[4]: code = 59, form = 11, offset = 94
+abbrev[101]: code = 8, tag = 13, children = 0
+abbrev[101]: attr[0]: code = 3, form = 8, offset = 101
+abbrev[101]: attr[1]: code = 58, form = 11, offset = 103
+abbrev[101]: attr[2]: code = 59, form = 11, offset = 105
+abbrev[101]: attr[3]: code = 73, form = 19, offset = 107
+abbrev[101]: attr[4]: code = 56, form = 10, offset = 109
+abbrev[116]: code = 9, tag = 15, children = 0
+abbrev[116]: attr[0]: code = 11, form = 11, offset = 116
+abbrev[123]: code = 10, tag = 15, children = 0
+abbrev[123]: attr[0]: code = 11, form = 11, offset = 123
+abbrev[123]: attr[1]: code = 73, form = 19, offset = 125
+abbrev[132]: code = 11, tag = 19, children = 1
+abbrev[132]: attr[0]: code = 1, form = 19, offset = 132
+abbrev[132]: attr[1]: code = 11, form = 11, offset = 134
+abbrev[132]: attr[2]: code = 58, form = 11, offset = 136
+abbrev[132]: attr[3]: code = 59, form = 11, offset = 138
+abbrev[145]: code = 12, tag = 1, children = 1
+abbrev[145]: attr[0]: code = 1, form = 19, offset = 145
+abbrev[145]: attr[1]: code = 73, form = 19, offset = 147
+abbrev[154]: code = 13, tag = 22, children = 0
+abbrev[154]: attr[0]: code = 3, form = 8, offset = 154
+abbrev[154]: attr[1]: code = 58, form = 11, offset = 156
+abbrev[154]: attr[2]: code = 59, form = 5, offset = 158
+abbrev[154]: attr[3]: code = 73, form = 19, offset = 160
+abbrev[167]: code = 14, tag = 19, children = 0
+abbrev[167]: attr[0]: code = 3, form = 8, offset = 167
+abbrev[167]: attr[1]: code = 60, form = 12, offset = 169
+abbrev[176]: code = 15, tag = 22, children = 0
+abbrev[176]: attr[0]: code = 3, form = 8, offset = 176
+abbrev[176]: attr[1]: code = 58, form = 11, offset = 178
+abbrev[176]: attr[2]: code = 59, form = 11, offset = 180
+abbrev[187]: code = 16, tag = 21, children = 1
+abbrev[187]: attr[0]: code = 1, form = 19, offset = 187
+abbrev[187]: attr[1]: code = 39, form = 12, offset = 189
+abbrev[187]: attr[2]: code = 73, form = 19, offset = 191
+abbrev[198]: code = 17, tag = 5, children = 0
+abbrev[198]: attr[0]: code = 73, form = 19, offset = 198
+abbrev[205]: code = 18, tag = 38, children = 0
+abbrev[205]: attr[0]: code = 73, form = 19, offset = 205
+abbrev[0]: code = 1, tag = 17, children = 1
+abbrev[0]: attr[0]: code = 16, form = 6, offset = 213
+abbrev[0]: attr[1]: code = 18, form = 1, offset = 215
+abbrev[0]: attr[2]: code = 17, form = 1, offset = 217
+abbrev[0]: attr[3]: code = 3, form = 8, offset = 219
+abbrev[0]: attr[4]: code = 27, form = 8, offset = 221
+abbrev[0]: attr[5]: code = 37, form = 8, offset = 223
+abbrev[0]: attr[6]: code = 19, form = 11, offset = 225
+abbrev[19]: code = 2, tag = 46, children = 0
+abbrev[19]: attr[0]: code = 63, form = 12, offset = 232
+abbrev[19]: attr[1]: code = 3, form = 8, offset = 234
+abbrev[19]: attr[2]: code = 58, form = 11, offset = 236
+abbrev[19]: attr[3]: code = 59, form = 11, offset = 238
+abbrev[19]: attr[4]: code = 39, form = 12, offset = 240
+abbrev[19]: attr[5]: code = 73, form = 19, offset = 242
+abbrev[19]: attr[6]: code = 17, form = 1, offset = 244
+abbrev[19]: attr[7]: code = 18, form = 1, offset = 246
+abbrev[19]: attr[8]: code = 64, form = 10, offset = 248
+abbrev[42]: code = 3, tag = 36, children = 0
+abbrev[42]: attr[0]: code = 3, form = 8, offset = 255
+abbrev[42]: attr[1]: code = 11, form = 11, offset = 257
+abbrev[42]: attr[2]: code = 62, form = 11, offset = 259
+abbrev[0]: code = 1, tag = 17, children = 1
+abbrev[0]: attr[0]: code = 16, form = 6, offset = 267
+abbrev[0]: attr[1]: code = 18, form = 1, offset = 269
+abbrev[0]: attr[2]: code = 17, form = 1, offset = 271
+abbrev[0]: attr[3]: code = 3, form = 8, offset = 273
+abbrev[0]: attr[4]: code = 27, form = 8, offset = 275
+abbrev[0]: attr[5]: code = 37, form = 8, offset = 277
+abbrev[0]: attr[6]: code = 19, form = 11, offset = 279
+abbrev[19]: code = 2, tag = 46, children = 1
+abbrev[19]: attr[0]: code = 1, form = 19, offset = 286
+abbrev[19]: attr[1]: code = 63, form = 12, offset = 288
+abbrev[19]: attr[2]: code = 3, form = 8, offset = 290
+abbrev[19]: attr[3]: code = 58, form = 11, offset = 292
+abbrev[19]: attr[4]: code = 59, form = 11, offset = 294
+abbrev[19]: attr[5]: code = 39, form = 12, offset = 296
+abbrev[19]: attr[6]: code = 73, form = 19, offset = 298
+abbrev[19]: attr[7]: code = 17, form = 1, offset = 300
+abbrev[19]: attr[8]: code = 18, form = 1, offset = 302
+abbrev[19]: attr[9]: code = 64, form = 10, offset = 304
+abbrev[44]: code = 3, tag = 46, children = 1
+abbrev[44]: attr[0]: code = 1, form = 19, offset = 311
+abbrev[44]: attr[1]: code = 63, form = 12, offset = 313
+abbrev[44]: attr[2]: code = 3, form = 8, offset = 315
+abbrev[44]: attr[3]: code = 58, form = 11, offset = 317
+abbrev[44]: attr[4]: code = 59, form = 11, offset = 319
+abbrev[44]: attr[5]: code = 73, form = 19, offset = 321
+abbrev[44]: attr[6]: code = 60, form = 12, offset = 323
+abbrev[63]: code = 4, tag = 24, children = 0
+abbrev[68]: code = 5, tag = 46, children = 1
+abbrev[68]: attr[0]: code = 63, form = 12, offset = 335
+abbrev[68]: attr[1]: code = 3, form = 8, offset = 337
+abbrev[68]: attr[2]: code = 58, form = 11, offset = 339
+abbrev[68]: attr[3]: code = 59, form = 11, offset = 341
+abbrev[68]: attr[4]: code = 73, form = 19, offset = 343
+abbrev[68]: attr[5]: code = 60, form = 12, offset = 345
+abbrev[85]: code = 6, tag = 36, children = 0
+abbrev[85]: attr[0]: code = 3, form = 8, offset = 352
+abbrev[85]: attr[1]: code = 11, form = 11, offset = 354
+abbrev[85]: attr[2]: code = 62, form = 11, offset = 356
+abbrev[96]: code = 7, tag = 52, children = 0
+abbrev[96]: attr[0]: code = 3, form = 8, offset = 363
+abbrev[96]: attr[1]: code = 58, form = 11, offset = 365
+abbrev[96]: attr[2]: code = 59, form = 11, offset = 367
+abbrev[96]: attr[3]: code = 73, form = 19, offset = 369
+abbrev[96]: attr[4]: code = 63, form = 12, offset = 371
+abbrev[96]: attr[5]: code = 2, form = 10, offset = 373
+EOF
+
+exit 0
diff --git a/tests/run-show-die-info.sh b/tests/run-show-die-info.sh
new file mode 100755
index 0000000..f92ee48
--- /dev/null
+++ b/tests/run-show-die-info.sh
@@ -0,0 +1,985 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+testfiles testfile5 testfile2
+
+testrun_compare ${abs_builddir}/show-die-info testfile5 testfile2 <<\EOF
+file: testfile5
+New CU: off = 0, hsize = 11, ab = 0, as = 4, os = 4
+ DW_TAG_compile_unit
+ Name : b.c
+ Offset : 11
+ CU offset : 11
+ Attrs : name stmt_list low_pc high_pc language comp_dir producer
+ low PC : 0x804842c
+ high PC : 0x8048436
+ language : 1
+ directory : /home/drepper/gnu/new-bu/build/ttt
+ producer : GNU C 2.96 20000731 (Red Hat Linux 7.0)
+ DW_TAG_subprogram
+ Name : bar
+ Offset : 104
+ CU offset : 104
+ Attrs : name low_pc high_pc prototyped decl_file decl_line external frame_base type
+ low PC : 0x804842c
+ high PC : 0x8048436
+ DW_TAG_base_type
+ Name : int
+ Offset : 127
+ CU offset : 127
+ Attrs : name byte_size encoding
+ byte size : 4
+New CU: off = 135, hsize = 11, ab = 54, as = 4, os = 4
+ DW_TAG_compile_unit
+ Name : f.c
+ Offset : 146
+ CU offset : 11
+ Attrs : name stmt_list low_pc high_pc language comp_dir producer
+ low PC : 0x8048438
+ high PC : 0x8048442
+ language : 1
+ directory : /home/drepper/gnu/new-bu/build/ttt
+ producer : GNU C 2.96 20000731 (Red Hat Linux 7.0)
+ DW_TAG_subprogram
+ Name : foo
+ Offset : 239
+ CU offset : 104
+ Attrs : name low_pc high_pc prototyped decl_file decl_line external frame_base type
+ low PC : 0x8048438
+ high PC : 0x8048442
+ DW_TAG_base_type
+ Name : int
+ Offset : 262
+ CU offset : 127
+ Attrs : name byte_size encoding
+ byte size : 4
+New CU: off = 270, hsize = 11, ab = 108, as = 4, os = 4
+ DW_TAG_compile_unit
+ Name : m.c
+ Offset : 281
+ CU offset : 11
+ Attrs : name stmt_list low_pc high_pc language comp_dir producer
+ low PC : 0x8048444
+ high PC : 0x8048472
+ language : 1
+ directory : /home/drepper/gnu/new-bu/build/ttt
+ producer : GNU C 2.96 20000731 (Red Hat Linux 7.0)
+ DW_TAG_subprogram
+ Name : main
+ Offset : 374
+ CU offset : 104
+ Attrs : sibling name low_pc high_pc prototyped decl_file decl_line external frame_base type
+ low PC : 0x8048444
+ high PC : 0x8048472
+ DW_TAG_subprogram
+ Name : bar
+ Offset : 402
+ CU offset : 132
+ Attrs : sibling name decl_file decl_line declaration external type
+ DW_TAG_unspecified_parameters
+ Name : * NO NAME *
+ Offset : 419
+ CU offset : 149
+ Attrs :
+ DW_TAG_subprogram
+ Name : foo
+ Offset : 421
+ CU offset : 151
+ Attrs : name decl_file decl_line declaration external type
+ DW_TAG_unspecified_parameters
+ Name : * NO NAME *
+ Offset : 434
+ CU offset : 164
+ Attrs :
+ DW_TAG_base_type
+ Name : int
+ Offset : 437
+ CU offset : 167
+ Attrs : name byte_size encoding
+ byte size : 4
+ DW_TAG_variable
+ Name : a
+ Offset : 444
+ CU offset : 174
+ Attrs : location name decl_file decl_line external type
+file: testfile2
+New CU: off = 0, hsize = 11, ab = 0, as = 4, os = 4
+ DW_TAG_compile_unit
+ Name : b.c
+ Offset : 11
+ CU offset : 11
+ Attrs : name stmt_list low_pc high_pc language comp_dir producer
+ low PC : 0x10000470
+ high PC : 0x10000490
+ language : 1
+ directory : /shoggoth/drepper
+ producer : GNU C 2.96-laurel-000912
+ DW_TAG_subprogram
+ Name : bar
+ Offset : 72
+ CU offset : 72
+ Attrs : name low_pc high_pc prototyped decl_file decl_line external frame_base type
+ low PC : 0x10000470
+ high PC : 0x10000490
+ DW_TAG_base_type
+ Name : int
+ Offset : 95
+ CU offset : 95
+ Attrs : name byte_size encoding
+ byte size : 4
+ DW_TAG_typedef
+ Name : size_t
+ Offset : 102
+ CU offset : 102
+ Attrs : name decl_file decl_line type
+ DW_TAG_base_type
+ Name : unsigned int
+ Offset : 116
+ CU offset : 116
+ Attrs : name byte_size encoding
+ byte size : 4
+ DW_TAG_typedef
+ Name : __gnuc_va_list
+ Offset : 132
+ CU offset : 132
+ Attrs : name decl_file decl_line type
+ DW_TAG_array_type
+ Name : __builtin_va_list
+ Offset : 154
+ CU offset : 154
+ Attrs : sibling name type
+ DW_TAG_subrange_type
+ Name : * NO NAME *
+ Offset : 181
+ CU offset : 181
+ Attrs : upper_bound type
+ DW_TAG_base_type
+ Name : unsigned int
+ Offset : 188
+ CU offset : 188
+ Attrs : name byte_size encoding
+ byte size : 4
+ DW_TAG_structure_type
+ Name : __va_list_tag
+ Offset : 204
+ CU offset : 204
+ Attrs : sibling name byte_size decl_file decl_line
+ byte size : 12
+ DW_TAG_member
+ Name : gpr
+ Offset : 226
+ CU offset : 226
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : fpr
+ Offset : 240
+ CU offset : 240
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : overflow_arg_area
+ Offset : 254
+ CU offset : 254
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : reg_save_area
+ Offset : 282
+ CU offset : 282
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_base_type
+ Name : unsigned char
+ Offset : 307
+ CU offset : 307
+ Attrs : name byte_size encoding
+ byte size : 1
+ DW_TAG_pointer_type
+ Name : * NO NAME *
+ Offset : 324
+ CU offset : 324
+ Attrs : byte_size
+ byte size : 4
+ DW_TAG_typedef
+ Name : __u_char
+ Offset : 326
+ CU offset : 326
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __u_short
+ Offset : 342
+ CU offset : 342
+ Attrs : name decl_file decl_line type
+ DW_TAG_base_type
+ Name : short unsigned int
+ Offset : 359
+ CU offset : 359
+ Attrs : name byte_size encoding
+ byte size : 2
+ DW_TAG_typedef
+ Name : __u_int
+ Offset : 381
+ CU offset : 381
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __u_long
+ Offset : 396
+ CU offset : 396
+ Attrs : name decl_file decl_line type
+ DW_TAG_base_type
+ Name : long unsigned int
+ Offset : 412
+ CU offset : 412
+ Attrs : name byte_size encoding
+ byte size : 4
+ DW_TAG_typedef
+ Name : __u_quad_t
+ Offset : 433
+ CU offset : 433
+ Attrs : name decl_file decl_line type
+ DW_TAG_base_type
+ Name : long long unsigned int
+ Offset : 451
+ CU offset : 451
+ Attrs : name byte_size encoding
+ byte size : 8
+ DW_TAG_typedef
+ Name : __quad_t
+ Offset : 477
+ CU offset : 477
+ Attrs : name decl_file decl_line type
+ DW_TAG_base_type
+ Name : long long int
+ Offset : 493
+ CU offset : 493
+ Attrs : name byte_size encoding
+ byte size : 8
+ DW_TAG_typedef
+ Name : __int8_t
+ Offset : 510
+ CU offset : 510
+ Attrs : name decl_file decl_line type
+ DW_TAG_base_type
+ Name : signed char
+ Offset : 526
+ CU offset : 526
+ Attrs : name byte_size encoding
+ byte size : 1
+ DW_TAG_typedef
+ Name : __uint8_t
+ Offset : 541
+ CU offset : 541
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __int16_t
+ Offset : 558
+ CU offset : 558
+ Attrs : name decl_file decl_line type
+ DW_TAG_base_type
+ Name : short int
+ Offset : 575
+ CU offset : 575
+ Attrs : name byte_size encoding
+ byte size : 2
+ DW_TAG_typedef
+ Name : __uint16_t
+ Offset : 588
+ CU offset : 588
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __int32_t
+ Offset : 606
+ CU offset : 606
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __uint32_t
+ Offset : 623
+ CU offset : 623
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __int64_t
+ Offset : 641
+ CU offset : 641
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __uint64_t
+ Offset : 658
+ CU offset : 658
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __qaddr_t
+ Offset : 676
+ CU offset : 676
+ Attrs : name decl_file decl_line type
+ DW_TAG_pointer_type
+ Name : * NO NAME *
+ Offset : 693
+ CU offset : 693
+ Attrs : byte_size type
+ byte size : 4
+ DW_TAG_typedef
+ Name : __dev_t
+ Offset : 699
+ CU offset : 699
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __uid_t
+ Offset : 714
+ CU offset : 714
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __gid_t
+ Offset : 729
+ CU offset : 729
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __ino_t
+ Offset : 744
+ CU offset : 744
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __mode_t
+ Offset : 759
+ CU offset : 759
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __nlink_t
+ Offset : 775
+ CU offset : 775
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __off_t
+ Offset : 792
+ CU offset : 792
+ Attrs : name decl_file decl_line type
+ DW_TAG_base_type
+ Name : long int
+ Offset : 807
+ CU offset : 807
+ Attrs : name byte_size encoding
+ byte size : 4
+ DW_TAG_typedef
+ Name : __loff_t
+ Offset : 819
+ CU offset : 819
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __pid_t
+ Offset : 835
+ CU offset : 835
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __ssize_t
+ Offset : 850
+ CU offset : 850
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __rlim_t
+ Offset : 867
+ CU offset : 867
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __rlim64_t
+ Offset : 883
+ CU offset : 883
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __id_t
+ Offset : 901
+ CU offset : 901
+ Attrs : name decl_file decl_line type
+ DW_TAG_structure_type
+ Name : * NO NAME *
+ Offset : 915
+ CU offset : 915
+ Attrs : sibling byte_size decl_file decl_line
+ byte size : 8
+ DW_TAG_member
+ Name : __val
+ Offset : 923
+ CU offset : 923
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_array_type
+ Name : * NO NAME *
+ Offset : 940
+ CU offset : 940
+ Attrs : sibling type
+ DW_TAG_subrange_type
+ Name : * NO NAME *
+ Offset : 949
+ CU offset : 949
+ Attrs : upper_bound type
+ DW_TAG_typedef
+ Name : __fsid_t
+ Offset : 956
+ CU offset : 956
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __daddr_t
+ Offset : 972
+ CU offset : 972
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __caddr_t
+ Offset : 989
+ CU offset : 989
+ Attrs : name decl_file decl_line type
+ DW_TAG_pointer_type
+ Name : * NO NAME *
+ Offset : 1006
+ CU offset : 1006
+ Attrs : byte_size type
+ byte size : 4
+ DW_TAG_base_type
+ Name : char
+ Offset : 1012
+ CU offset : 1012
+ Attrs : name byte_size encoding
+ byte size : 1
+ DW_TAG_typedef
+ Name : __time_t
+ Offset : 1020
+ CU offset : 1020
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __swblk_t
+ Offset : 1036
+ CU offset : 1036
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __clock_t
+ Offset : 1053
+ CU offset : 1053
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __fd_mask
+ Offset : 1070
+ CU offset : 1070
+ Attrs : name decl_file decl_line type
+ DW_TAG_structure_type
+ Name : * NO NAME *
+ Offset : 1087
+ CU offset : 1087
+ Attrs : sibling byte_size decl_file decl_line
+ byte size : 128
+ DW_TAG_member
+ Name : __fds_bits
+ Offset : 1095
+ CU offset : 1095
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_array_type
+ Name : * NO NAME *
+ Offset : 1117
+ CU offset : 1117
+ Attrs : sibling type
+ DW_TAG_subrange_type
+ Name : * NO NAME *
+ Offset : 1126
+ CU offset : 1126
+ Attrs : upper_bound type
+ DW_TAG_typedef
+ Name : __fd_set
+ Offset : 1133
+ CU offset : 1133
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __key_t
+ Offset : 1149
+ CU offset : 1149
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __ipc_pid_t
+ Offset : 1164
+ CU offset : 1164
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __blkcnt_t
+ Offset : 1183
+ CU offset : 1183
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __blkcnt64_t
+ Offset : 1201
+ CU offset : 1201
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __fsblkcnt_t
+ Offset : 1221
+ CU offset : 1221
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __fsblkcnt64_t
+ Offset : 1241
+ CU offset : 1241
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __fsfilcnt_t
+ Offset : 1263
+ CU offset : 1263
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __fsfilcnt64_t
+ Offset : 1283
+ CU offset : 1283
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __ino64_t
+ Offset : 1305
+ CU offset : 1305
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __off64_t
+ Offset : 1322
+ CU offset : 1322
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __t_scalar_t
+ Offset : 1339
+ CU offset : 1339
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __t_uscalar_t
+ Offset : 1359
+ CU offset : 1359
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : __intptr_t
+ Offset : 1380
+ CU offset : 1380
+ Attrs : name decl_file decl_line type
+ DW_TAG_structure_type
+ Name : _IO_FILE
+ Offset : 1398
+ CU offset : 1398
+ Attrs : sibling name byte_size decl_file decl_line
+ byte size : 152
+ DW_TAG_member
+ Name : _flags
+ Offset : 1415
+ CU offset : 1415
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_read_ptr
+ Offset : 1432
+ CU offset : 1432
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_read_end
+ Offset : 1455
+ CU offset : 1455
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_read_base
+ Offset : 1478
+ CU offset : 1478
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_write_base
+ Offset : 1502
+ CU offset : 1502
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_write_ptr
+ Offset : 1527
+ CU offset : 1527
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_write_end
+ Offset : 1551
+ CU offset : 1551
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_buf_base
+ Offset : 1575
+ CU offset : 1575
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_buf_end
+ Offset : 1598
+ CU offset : 1598
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_save_base
+ Offset : 1620
+ CU offset : 1620
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_backup_base
+ Offset : 1644
+ CU offset : 1644
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _IO_save_end
+ Offset : 1670
+ CU offset : 1670
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _markers
+ Offset : 1693
+ CU offset : 1693
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _chain
+ Offset : 1712
+ CU offset : 1712
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _fileno
+ Offset : 1729
+ CU offset : 1729
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _blksize
+ Offset : 1747
+ CU offset : 1747
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _old_offset
+ Offset : 1766
+ CU offset : 1766
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _cur_column
+ Offset : 1788
+ CU offset : 1788
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _vtable_offset
+ Offset : 1810
+ CU offset : 1810
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _shortbuf
+ Offset : 1835
+ CU offset : 1835
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _lock
+ Offset : 1855
+ CU offset : 1855
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _offset
+ Offset : 1871
+ CU offset : 1871
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _unused2
+ Offset : 1889
+ CU offset : 1889
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_structure_type
+ Name : _IO_marker
+ Offset : 1909
+ CU offset : 1909
+ Attrs : sibling name byte_size decl_file decl_line
+ byte size : 12
+ DW_TAG_member
+ Name : _next
+ Offset : 1928
+ CU offset : 1928
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _sbuf
+ Offset : 1944
+ CU offset : 1944
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_member
+ Name : _pos
+ Offset : 1960
+ CU offset : 1960
+ Attrs : name data_member_location decl_file decl_line type
+ DW_TAG_pointer_type
+ Name : * NO NAME *
+ Offset : 1976
+ CU offset : 1976
+ Attrs : byte_size type
+ byte size : 4
+ DW_TAG_pointer_type
+ Name : * NO NAME *
+ Offset : 1982
+ CU offset : 1982
+ Attrs : byte_size type
+ byte size : 4
+ DW_TAG_array_type
+ Name : * NO NAME *
+ Offset : 1988
+ CU offset : 1988
+ Attrs : sibling type
+ DW_TAG_subrange_type
+ Name : * NO NAME *
+ Offset : 1997
+ CU offset : 1997
+ Attrs : upper_bound type
+ DW_TAG_pointer_type
+ Name : * NO NAME *
+ Offset : 2004
+ CU offset : 2004
+ Attrs : byte_size
+ byte size : 4
+ DW_TAG_array_type
+ Name : * NO NAME *
+ Offset : 2006
+ CU offset : 2006
+ Attrs : sibling type
+ DW_TAG_subrange_type
+ Name : * NO NAME *
+ Offset : 2015
+ CU offset : 2015
+ Attrs : upper_bound type
+ DW_TAG_typedef
+ Name : FILE
+ Offset : 2022
+ CU offset : 2022
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : wchar_t
+ Offset : 2034
+ CU offset : 2034
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : wint_t
+ Offset : 2050
+ CU offset : 2050
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : _G_int16_t
+ Offset : 2065
+ CU offset : 2065
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : _G_int32_t
+ Offset : 2083
+ CU offset : 2083
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : _G_uint16_t
+ Offset : 2101
+ CU offset : 2101
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : _G_uint32_t
+ Offset : 2120
+ CU offset : 2120
+ Attrs : name decl_file decl_line type
+ DW_TAG_structure_type
+ Name : _IO_jump_t
+ Offset : 2139
+ CU offset : 2139
+ Attrs : name declaration
+ DW_TAG_typedef
+ Name : _IO_lock_t
+ Offset : 2152
+ CU offset : 2152
+ Attrs : name decl_file decl_line
+ DW_TAG_typedef
+ Name : _IO_FILE
+ Offset : 2166
+ CU offset : 2166
+ Attrs : name decl_file decl_line type
+ DW_TAG_structure_type
+ Name : _IO_FILE_plus
+ Offset : 2182
+ CU offset : 2182
+ Attrs : name declaration
+ DW_TAG_typedef
+ Name : __io_read_fn
+ Offset : 2198
+ CU offset : 2198
+ Attrs : name decl_file decl_line type
+ DW_TAG_subroutine_type
+ Name : * NO NAME *
+ Offset : 2219
+ CU offset : 2219
+ Attrs : sibling prototyped type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2229
+ CU offset : 2229
+ Attrs : type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2234
+ CU offset : 2234
+ Attrs : type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2239
+ CU offset : 2239
+ Attrs : type
+ DW_TAG_typedef
+ Name : __io_write_fn
+ Offset : 2245
+ CU offset : 2245
+ Attrs : name decl_file decl_line type
+ DW_TAG_subroutine_type
+ Name : * NO NAME *
+ Offset : 2267
+ CU offset : 2267
+ Attrs : sibling prototyped type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2277
+ CU offset : 2277
+ Attrs : type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2282
+ CU offset : 2282
+ Attrs : type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2287
+ CU offset : 2287
+ Attrs : type
+ DW_TAG_pointer_type
+ Name : * NO NAME *
+ Offset : 2293
+ CU offset : 2293
+ Attrs : byte_size type
+ byte size : 4
+ DW_TAG_const_type
+ Name : * NO NAME *
+ Offset : 2299
+ CU offset : 2299
+ Attrs : type
+ DW_TAG_typedef
+ Name : __io_seek_fn
+ Offset : 2304
+ CU offset : 2304
+ Attrs : name decl_file decl_line type
+ DW_TAG_subroutine_type
+ Name : * NO NAME *
+ Offset : 2325
+ CU offset : 2325
+ Attrs : sibling prototyped type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2335
+ CU offset : 2335
+ Attrs : type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2340
+ CU offset : 2340
+ Attrs : type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2345
+ CU offset : 2345
+ Attrs : type
+ DW_TAG_typedef
+ Name : __io_close_fn
+ Offset : 2351
+ CU offset : 2351
+ Attrs : name decl_file decl_line type
+ DW_TAG_subroutine_type
+ Name : * NO NAME *
+ Offset : 2373
+ CU offset : 2373
+ Attrs : sibling prototyped type
+ DW_TAG_formal_parameter
+ Name : * NO NAME *
+ Offset : 2383
+ CU offset : 2383
+ Attrs : type
+ DW_TAG_typedef
+ Name : fpos_t
+ Offset : 2389
+ CU offset : 2389
+ Attrs : name decl_file decl_line type
+ DW_TAG_typedef
+ Name : off_t
+ Offset : 2403
+ CU offset : 2403
+ Attrs : name decl_file decl_line type
+New CU: off = 2418, hsize = 11, ab = 213, as = 4, os = 4
+ DW_TAG_compile_unit
+ Name : f.c
+ Offset : 2429
+ CU offset : 11
+ Attrs : name stmt_list low_pc high_pc language comp_dir producer
+ low PC : 0x10000490
+ high PC : 0x100004b0
+ language : 1
+ directory : /shoggoth/drepper
+ producer : GNU C 2.96-laurel-000912
+ DW_TAG_subprogram
+ Name : foo
+ Offset : 2490
+ CU offset : 72
+ Attrs : name low_pc high_pc prototyped decl_file decl_line external frame_base type
+ low PC : 0x10000490
+ high PC : 0x100004b0
+ DW_TAG_base_type
+ Name : int
+ Offset : 2513
+ CU offset : 95
+ Attrs : name byte_size encoding
+ byte size : 4
+New CU: off = 2521, hsize = 11, ab = 267, as = 4, os = 4
+ DW_TAG_compile_unit
+ Name : m.c
+ Offset : 2532
+ CU offset : 11
+ Attrs : name stmt_list low_pc high_pc language comp_dir producer
+ low PC : 0x100004b0
+ high PC : 0x10000514
+ language : 1
+ directory : /shoggoth/drepper
+ producer : GNU C 2.96-laurel-000912
+ DW_TAG_subprogram
+ Name : main
+ Offset : 2593
+ CU offset : 72
+ Attrs : sibling name low_pc high_pc prototyped decl_file decl_line external frame_base type
+ low PC : 0x100004b0
+ high PC : 0x10000514
+ DW_TAG_subprogram
+ Name : bar
+ Offset : 2621
+ CU offset : 100
+ Attrs : sibling name decl_file decl_line declaration external type
+ DW_TAG_unspecified_parameters
+ Name : * NO NAME *
+ Offset : 2638
+ CU offset : 117
+ Attrs :
+ DW_TAG_subprogram
+ Name : foo
+ Offset : 2640
+ CU offset : 119
+ Attrs : name decl_file decl_line declaration external type
+ DW_TAG_unspecified_parameters
+ Name : * NO NAME *
+ Offset : 2653
+ CU offset : 132
+ Attrs :
+ DW_TAG_base_type
+ Name : int
+ Offset : 2656
+ CU offset : 135
+ Attrs : name byte_size encoding
+ byte size : 4
+ DW_TAG_variable
+ Name : a
+ Offset : 2663
+ CU offset : 142
+ Attrs : location name decl_file decl_line external type
+EOF
+
+exit 0
diff --git a/tests/run-stack-d-test.sh b/tests/run-stack-d-test.sh
new file mode 100755
index 0000000..a9f0380
--- /dev/null
+++ b/tests/run-stack-d-test.sh
@@ -0,0 +1,122 @@
+#! /bin/sh
+# Copyright (C) 2014, 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
+
+# // g++ dwarfinlines.cpp -g -o testfiledwarfinlines -O2
+# int
+# fubar (int x)
+# {
+# __asm__ ( "nop" ::: );
+# return 42 / x - 2;
+# }
+#
+# void foobar (int z1, int z2)
+# {
+# __asm__ ( "nop" ::: );
+# int x = z1 + z2;
+# while (z1 + x + 1 != 42)
+# x = fubar (z1 + z2 + x);
+# }
+#
+# void bar (int z)
+# {
+# int a, b;
+# a = b = z / 2;
+# foobar(a, b);
+# }
+#
+# void foo (int x)
+# {
+# if (x > 0)
+# bar(x - 2);
+# }
+#
+# void fu (int y)
+# {
+# __asm__ ( "nop" ::: );
+# foo (y + 1);
+# }
+#
+# int
+# main (int argc, char **argv)
+# {
+# fu (argc);
+# }
+testfiles testfiledwarfinlines testfiledwarfinlines.core
+
+# Depending on whether we are running make check or make installcheck
+# the actual binary name under test might be different. It is used in
+# the error message, which we also try to match.
+if test "$elfutils_testrun" = "installed"; then
+STACKCMD=${bindir}/`program_transform stack`
+else
+STACKCMD=${abs_top_builddir}/src/stack
+fi
+
+# Disable valgrind while dumping because of a bug unmapping libc.so.
+# https://bugs.kde.org/show_bug.cgi?id=327427
+SAVED_VALGRIND_CMD="$VALGRIND_CMD"
+unset VALGRIND_CMD
+
+# Without -d the top function comes out as fu. Use --raw to not demangle.
+testrun_compare ${abs_top_builddir}/src/stack -r -n 2 -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 _Z2fui
+#1 0x00000000004004c5 main
+$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
+EOF
+
+# But when asking for source we see it is actually on line 6.
+# (Which is in function fubar, not fu). Use --raw to not demangle.
+testrun_compare ${abs_top_builddir}/src/stack -r -n 2 -s -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 _Z2fui
+ /home/mark/src/tests/dwarfinlines.cpp:6
+#1 0x00000000004004c5 main
+ /home/mark/src/tests/dwarfinlines.cpp:39
+$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
+EOF
+
+# So with --debugname we get the function correct as fubar.
+testrun_compare ${abs_top_builddir}/src/stack -n 2 -d -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 fubar
+#1 0x00000000004004c5 main
+$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
+EOF
+
+# Which now matches the source line (again 6 of course).
+testrun_compare ${abs_top_builddir}/src/stack -n 2 -s -d -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 fubar
+ /home/mark/src/tests/dwarfinlines.cpp:6
+#1 0x00000000004004c5 main
+ /home/mark/src/tests/dwarfinlines.cpp:39
+$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
+EOF
+
+if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
+ VALGRIND_CMD="$SAVED_VALGRIND_CMD"
+ export VALGRIND_CMD
+fi
+
+exit 0
diff --git a/tests/run-stack-demangled-test.sh b/tests/run-stack-demangled-test.sh
new file mode 100755
index 0000000..c26918f
--- /dev/null
+++ b/tests/run-stack-demangled-test.sh
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Copyright (C) 2014, 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/>.
+
+if test -n "$ELFUTILS_DISABLE_DEMANGLE"; then
+ echo "demangler unsupported"
+ exit 77
+fi
+
+. $srcdir/test-subr.sh
+
+# See run-stack-d-test.sh and run-stack-i-test.sh
+# Same tests, now with demangler support, no -r, and without -d.
+# Only change in output is an explit fu(int) instead of _Z2fui.
+
+testfiles testfiledwarfinlines testfiledwarfinlines.core
+
+# Depending on whether we are running make check or make installcheck
+# the actual binary name under test might be different. It is used in
+# the error message, which we also try to match.
+if test "$elfutils_testrun" = "installed"; then
+STACKCMD=${bindir}/`program_transform stack`
+else
+STACKCMD=${abs_top_builddir}/src/stack
+fi
+
+# Disable valgrind while dumping because of a bug unmapping libc.so.
+# https://bugs.kde.org/show_bug.cgi?id=327427
+SAVED_VALGRIND_CMD="$VALGRIND_CMD"
+unset VALGRIND_CMD
+
+# Without -d the top function comes out as fu.
+testrun_compare ${abs_top_builddir}/src/stack -n 2 -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 fu(int)
+#1 0x00000000004004c5 main
+$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
+EOF
+
+# But when asking for source we see it is actually on line 6.
+# (Which is in function fubar, not fu).
+testrun_compare ${abs_top_builddir}/src/stack -n 2 -s -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 fu(int)
+ /home/mark/src/tests/dwarfinlines.cpp:6
+#1 0x00000000004004c5 main
+ /home/mark/src/tests/dwarfinlines.cpp:39
+$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
+EOF
+
+# With --inlines we get all inlined calls. Note they share the same
+# address.
+testrun_compare ${abs_top_builddir}/src/stack -n 6 -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 fubar
+#1 0x00000000004006c8 foobar
+#2 0x00000000004006c8 bar
+#3 0x00000000004006c8 foo
+#4 0x00000000004006c8 fu(int)
+#5 0x00000000004004c5 main
+$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited)
+EOF
+
+# With --source we can also see where in the source the inlined frames
+# where originally called from.
+testrun_compare ${abs_top_builddir}/src/stack -n 6 -s -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 fubar
+ /home/mark/src/tests/dwarfinlines.cpp:6
+#1 0x00000000004006c8 foobar
+ /home/mark/src/tests/dwarfinlines.cpp:14
+#2 0x00000000004006c8 bar
+ /home/mark/src/tests/dwarfinlines.cpp:21
+#3 0x00000000004006c8 foo
+ /home/mark/src/tests/dwarfinlines.cpp:27
+#4 0x00000000004006c8 fu(int)
+ /home/mark/src/tests/dwarfinlines.cpp:33
+#5 0x00000000004004c5 main
+ /home/mark/src/tests/dwarfinlines.cpp:39
+$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited)
+EOF
+
+if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
+ VALGRIND_CMD="$SAVED_VALGRIND_CMD"
+ export VALGRIND_CMD
+fi
+
+exit 0
diff --git a/tests/run-stack-i-test.sh b/tests/run-stack-i-test.sh
new file mode 100755
index 0000000..3722ab0
--- /dev/null
+++ b/tests/run-stack-i-test.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2014, 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-stack-d-test.sh for dwarfinlines.cpp source.
+testfiles testfiledwarfinlines testfiledwarfinlines.core
+
+# Depending on whether we are running make check or make installcheck
+# the actual binary name under test might be different. It is used in
+# the error message, which we also try to match.
+if test "$elfutils_testrun" = "installed"; then
+STACKCMD=${bindir}/`program_transform stack`
+else
+STACKCMD=${abs_top_builddir}/src/stack
+fi
+
+# Disable valgrind while dumping because of a bug unmapping libc.so.
+# https://bugs.kde.org/show_bug.cgi?id=327427
+SAVED_VALGRIND_CMD="$VALGRIND_CMD"
+unset VALGRIND_CMD
+
+# Compare with run-stack-d-test.sh to see the output without --inlines.
+# Only two call frames are visible (there is a jump from main to fu or
+# fubar). Explicitly use --raw so demangler support being configured in
+# doesn't change the results.
+
+# With --inlines we get all inlined calls. Note they share the same
+# address.
+testrun_compare ${abs_top_builddir}/src/stack -r -n 6 -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 fubar
+#1 0x00000000004006c8 foobar
+#2 0x00000000004006c8 bar
+#3 0x00000000004006c8 foo
+#4 0x00000000004006c8 _Z2fui
+#5 0x00000000004004c5 main
+$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited)
+EOF
+
+# With --source we can also see where in the source the inlined frames
+# where originally called from.
+testrun_compare ${abs_top_builddir}/src/stack -r -n 6 -s -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
+PID 13654 - core
+TID 13654:
+#0 0x00000000004006c8 fubar
+ /home/mark/src/tests/dwarfinlines.cpp:6
+#1 0x00000000004006c8 foobar
+ /home/mark/src/tests/dwarfinlines.cpp:14
+#2 0x00000000004006c8 bar
+ /home/mark/src/tests/dwarfinlines.cpp:21
+#3 0x00000000004006c8 foo
+ /home/mark/src/tests/dwarfinlines.cpp:27
+#4 0x00000000004006c8 _Z2fui
+ /home/mark/src/tests/dwarfinlines.cpp:33
+#5 0x00000000004004c5 main
+ /home/mark/src/tests/dwarfinlines.cpp:39
+$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited)
+EOF
+
+if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
+ VALGRIND_CMD="$SAVED_VALGRIND_CMD"
+ export VALGRIND_CMD
+fi
+
+exit 0
diff --git a/tests/run-strings-test.sh b/tests/run-strings-test.sh
new file mode 100755
index 0000000..33f2d64
--- /dev/null
+++ b/tests/run-strings-test.sh
@@ -0,0 +1,470 @@
+#! /bin/sh
+# Copyright (C) 2005, 2006, 2008 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+#
+# 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
+
+files="testfile `seq 2 9 | while read n; do echo testfile$n; done`"
+testfiles $files
+
+testrun_compare ${abs_top_builddir}/src/strings -tx -f $files <<\EOF
+testfile: f4 /lib/ld-linux.so.2
+testfile: 1c9 __gmon_start__
+testfile: 1d8 libc.so.6
+testfile: 1e2 __cxa_finalize
+testfile: 1f1 __deregister_frame_info
+testfile: 209 _IO_stdin_used
+testfile: 218 __libc_start_main
+testfile: 22a __register_frame_info
+testfile: 240 GLIBC_2.1.3
+testfile: 24c GLIBC_2.0
+testfile: 338 PTRh
+testfile: 345 QVh,
+testfile2: 114 /lib/ld.so.1
+testfile2: 1f1 __gmon_start__
+testfile2: 200 __deregister_frame_info
+testfile2: 218 __register_frame_info
+testfile2: 22e libc.so.6
+testfile2: 238 __cxa_finalize
+testfile2: 247 _IO_stdin_used
+testfile2: 256 __libc_start_main
+testfile2: 268 GLIBC_2.1.3
+testfile2: 274 GLIBC_2.0
+testfile2: 488 }a[xN
+testfile2: 4a8 }a[xN
+testfile2: 50c }a[xN
+testfile2: 540 }?Kx
+testfile3: f4 /lib/ld-linux.so.2
+testfile3: 1c9 __gmon_start__
+testfile3: 1d8 libc.so.6
+testfile3: 1e2 __cxa_finalize
+testfile3: 1f1 __deregister_frame_info
+testfile3: 209 _IO_stdin_used
+testfile3: 218 __libc_start_main
+testfile3: 22a __register_frame_info
+testfile3: 240 GLIBC_2.1.3
+testfile3: 24c GLIBC_2.0
+testfile3: 338 PTRh
+testfile3: 345 QVh,
+testfile4: f4 /lib/ld-linux.so.2
+testfile4: 8e1 __gmon_start__
+testfile4: 8f0 __terminate_func
+testfile4: 901 stderr
+testfile4: 908 __tf9type_info
+testfile4: 917 __tf16__user_type_info
+testfile4: 92e __tf19__pointer_type_info
+testfile4: 948 __tf16__attr_type_info
+testfile4: 95f __tf16__func_type_info
+testfile4: 976 __vt_9type_info
+testfile4: 986 __vt_19__pointer_type_info
+testfile4: 9a1 __vt_16__attr_type_info
+testfile4: 9b9 __vt_16__func_type_info
+testfile4: 9d1 __vt_16__ptmf_type_info
+testfile4: 9e9 __vt_16__ptmd_type_info
+testfile4: a01 __vt_17__array_type_info
+testfile4: a1a __tiv
+testfile4: a20 __vt_19__builtin_type_info
+testfile4: a3b __tix
+testfile4: a41 __til
+testfile4: a47 __tii
+testfile4: a4d __tis
+testfile4: a53 __tib
+testfile4: a59 __tic
+testfile4: a5f __tiw
+testfile4: a65 __tir
+testfile4: a6b __tid
+testfile4: a71 __tif
+testfile4: a77 __tiUi
+testfile4: a7e __tiUl
+testfile4: a85 __tiUx
+testfile4: a8c __tiUs
+testfile4: a93 __tiUc
+testfile4: a9a __tiSc
+testfile4: aa1 __ti19__pointer_type_info
+testfile4: abb __ti9type_info
+testfile4: aca __ti16__attr_type_info
+testfile4: ae1 __ti19__builtin_type_info
+testfile4: afb __ti16__func_type_info
+testfile4: b12 __ti16__ptmf_type_info
+testfile4: b29 __ti16__ptmd_type_info
+testfile4: b40 __ti17__array_type_info
+testfile4: b58 __cplus_type_matcher
+testfile4: b6d __vt_13bad_exception
+testfile4: b82 __vt_9exception
+testfile4: b92 _._13bad_exception
+testfile4: ba5 __vt_8bad_cast
+testfile4: bb4 _._8bad_cast
+testfile4: bc1 __vt_10bad_typeid
+testfile4: bd3 _._10bad_typeid
+testfile4: be3 __ti9exception
+testfile4: bf2 __ti13bad_exception
+testfile4: c06 __vt_16__user_type_info
+testfile4: c1e __vt_17__class_type_info
+testfile4: c37 __vt_14__si_type_info
+testfile4: c4d __ti8bad_cast
+testfile4: c5b __ti10bad_typeid
+testfile4: c6c __ti16__user_type_info
+testfile4: c83 __ti14__si_type_info
+testfile4: c98 __ti17__class_type_info
+testfile4: cb0 libc.so.6
+testfile4: cba __register_frame
+testfile4: ccb pthread_create
+testfile4: cda pthread_getspecific
+testfile4: cee pthread_key_delete
+testfile4: d01 __cxa_finalize
+testfile4: d10 malloc
+testfile4: d17 __frame_state_for
+testfile4: d29 abort
+testfile4: d2f __register_frame_table
+testfile4: d46 fprintf
+testfile4: d4e pthread_once
+testfile4: d5b __deregister_frame_info
+testfile4: d73 pthread_key_create
+testfile4: d86 memset
+testfile4: d8d strcmp
+testfile4: d94 pthread_mutex_unlock
+testfile4: da9 __deregister_frame
+testfile4: dbc pthread_mutex_lock
+testfile4: dcf _IO_stdin_used
+testfile4: dde __libc_start_main
+testfile4: df0 strlen
+testfile4: df7 __register_frame_info_table
+testfile4: e13 __register_frame_info
+testfile4: e29 pthread_setspecific
+testfile4: e3d free
+testfile4: e42 GLIBC_2.1.3
+testfile4: e4e GLIBC_2.0
+testfile4: 1308 PTRh<
+testfile4: 194b [^_]
+testfile4: 19bf [^_]
+testfile4: 1dd9 wT9L>
+testfile4: 1f3b [^_]
+testfile4: 1fae [^_]
+testfile4: 21c1 BZQRP
+testfile4: 237f [^_]
+testfile4: 2431 JWRV
+testfile4: 2454 [^_]
+testfile4: 2506 JWRV
+testfile4: 2529 [^_]
+testfile4: 2b6c [^_]
+testfile4: 2b9d ZYPV
+testfile4: 2c28 [^_]
+testfile4: 2c4d ZYPV
+testfile4: 2ce2 [^_]
+testfile4: 2dfb X^_]
+testfile4: 2fc8 [^_]
+testfile4: 307d tq;F
+testfile4: 315a [^_]
+testfile4: 31a5 :zt 1
+testfile4: 3238 [^_]
+testfile4: 32f8 AXY_VR
+testfile4: 334a [^_]
+testfile4: 37ab [^_]
+testfile4: 38b8 sU;E
+testfile4: 38f2 QRPV
+testfile4: 3926 [^_]
+testfile4: 3bfe QRWP
+testfile4: 3e65 [^_]
+testfile4: 4136 [^_]
+testfile4: 472d [^_]
+testfile4: 47a5 0[^_]
+testfile4: 48ab [^_]
+testfile4: 4ab1 _ZPV
+testfile4: 4b53 _ZPV
+testfile4: 4bd3 _ZPV
+testfile4: 4e05 PQWj
+testfile4: 4f75 [^_]
+testfile4: 4f9b u$;E u
+testfile4: 4feb [^_]
+testfile4: 5080 [^_]
+testfile4: 50a8 }$9u
+testfile4: 5149 [^_]
+testfile4: 51b0 [^_]
+testfile4: 539b [^_]
+testfile4: 53b5 E 9E
+testfile4: 540d x!)E
+testfile4: 5598 U$ B
+testfile4: 571c [^_]
+testfile4: 5819 [^_]
+testfile4: 5922 [^_]
+testfile4: 59c2 [^_]
+testfile4: 5a62 [^_]
+testfile4: 5b02 [^_]
+testfile4: 5ba2 [^_]
+testfile4: 5c42 [^_]
+testfile4: 5ce2 [^_]
+testfile4: 6112 [^_]
+testfile4: 62bb [^_]
+testfile4: 639b [^_]
+testfile4: 6436 [^_]
+testfile4: 6468 val is zero
+testfile4: 6480 Internal Compiler Bug: No runtime type matcher.
+testfile4: 64dc 19__pointer_type_info
+testfile4: 64f2 16__attr_type_info
+testfile4: 6505 19__builtin_type_info
+testfile4: 651b 16__func_type_info
+testfile4: 652e 16__ptmf_type_info
+testfile4: 6541 16__ptmd_type_info
+testfile4: 6554 17__array_type_info
+testfile4: 6568 9exception
+testfile4: 6573 13bad_exception
+testfile4: 6583 9type_info
+testfile4: 658e 8bad_cast
+testfile4: 6598 10bad_typeid
+testfile4: 65a5 16__user_type_info
+testfile4: 65b8 14__si_type_info
+testfile4: 65c9 17__class_type_info
+testfile4: 6fc1 H. $
+testfile5: f4 /lib/ld-linux.so.2
+testfile5: 1c9 __gmon_start__
+testfile5: 1d8 libc.so.6
+testfile5: 1e2 __cxa_finalize
+testfile5: 1f1 __deregister_frame_info
+testfile5: 209 _IO_stdin_used
+testfile5: 218 __libc_start_main
+testfile5: 22a __register_frame_info
+testfile5: 240 GLIBC_2.1.3
+testfile5: 24c GLIBC_2.0
+testfile5: 338 PTRh
+testfile5: 345 QVhD
+testfile6: 114 /lib/ld-linux.so.2
+testfile6: 3d9 libstdc++.so.5
+testfile6: 3e8 _ZTVSt16invalid_argument
+testfile6: 401 _ZNSaIcEC1Ev
+testfile6: 40e _ZTSSt16invalid_argument
+testfile6: 427 _ZTVN10__cxxabiv120__si_class_type_infoE
+testfile6: 450 _ZNSsD1Ev
+testfile6: 45a _ZdlPv
+testfile6: 461 __cxa_end_catch
+testfile6: 471 __gxx_personality_v0
+testfile6: 486 _ZTISt9exception
+testfile6: 497 _ZNSaIcED1Ev
+testfile6: 4a4 _ZTISt11logic_error
+testfile6: 4b8 _ZNSt16invalid_argumentD1Ev
+testfile6: 4d4 _ZTVN10__cxxabiv117__class_type_infoE
+testfile6: 4fa __cxa_throw
+testfile6: 506 _ZNSt16invalid_argumentC1ERKSs
+testfile6: 525 _ZNSsC1EPKcRKSaIcE
+testfile6: 538 _ZNSt11logic_errorD2Ev
+testfile6: 54f _ZTVN10__cxxabiv121__vmi_class_type_infoE
+testfile6: 579 _ZNSt16invalid_argumentD0Ev
+testfile6: 595 __cxa_begin_catch
+testfile6: 5a7 __cxa_allocate_exception
+testfile6: 5c0 _ZNKSt11logic_error4whatEv
+testfile6: 5db _Jv_RegisterClasses
+testfile6: 5ef _ZTISt16invalid_argument
+testfile6: 608 __gmon_start__
+testfile6: 617 libm.so.6
+testfile6: 621 _IO_stdin_used
+testfile6: 630 libgcc_s.so.1
+testfile6: 63e _Unwind_Resume
+testfile6: 64d libc.so.6
+testfile6: 657 __libc_start_main
+testfile6: 669 GCC_3.0
+testfile6: 671 GLIBC_2.0
+testfile6: 67b GLIBCPP_3.2
+testfile6: 687 CXXABI_1.2
+testfile6: 908 PTRh
+testfile6: e48 gdb.1
+testfile6: ec8 N10__gnu_test9gnu_obj_1E
+testfile6: ee1 N10__gnu_test9gnu_obj_2IiEE
+testfile6: efd N10__gnu_test9gnu_obj_2IlEE
+testfile6: f19 St16invalid_argument
+testfile7: 114 /lib/ld-linux.so.2
+testfile7: 3d9 libstdc++.so.5
+testfile7: 3e8 _ZTVSt16invalid_argument
+testfile7: 401 _ZNSaIcEC1Ev
+testfile7: 40e _ZTSSt16invalid_argument
+testfile7: 427 _ZTVN10__cxxabiv120__si_class_type_infoE
+testfile7: 450 _ZNSsD1Ev
+testfile7: 45a _ZdlPv
+testfile7: 461 __cxa_end_catch
+testfile7: 471 __gxx_personality_v0
+testfile7: 486 _ZTISt9exception
+testfile7: 497 _ZNSaIcED1Ev
+testfile7: 4a4 _ZTISt11logic_error
+testfile7: 4b8 _ZNSt16invalid_argumentD1Ev
+testfile7: 4d4 _ZTVN10__cxxabiv117__class_type_infoE
+testfile7: 4fa __cxa_throw
+testfile7: 506 _ZNSt16invalid_argumentC1ERKSs
+testfile7: 525 _ZNSsC1EPKcRKSaIcE
+testfile7: 538 _ZNSt11logic_errorD2Ev
+testfile7: 54f _ZTVN10__cxxabiv121__vmi_class_type_infoE
+testfile7: 579 _ZNSt16invalid_argumentD0Ev
+testfile7: 595 __cxa_begin_catch
+testfile7: 5a7 __cxa_allocate_exception
+testfile7: 5c0 _ZNKSt11logic_error4whatEv
+testfile7: 5db _Jv_RegisterClasses
+testfile7: 5ef _ZTISt16invalid_argument
+testfile7: 608 __gmon_start__
+testfile7: 617 libm.so.6
+testfile7: 621 _IO_stdin_used
+testfile7: 630 libgcc_s.so.1
+testfile7: 63e _Unwind_Resume
+testfile7: 64d libc.so.6
+testfile7: 657 __libc_start_main
+testfile7: 669 GCC_3.0
+testfile7: 671 GLIBC_2.0
+testfile7: 67b GLIBCPP_3.2
+testfile7: 687 CXXABI_1.2
+testfile7: 908 PTRh
+testfile7: e48 gdb.1
+testfile7: ec8 N10__gnu_test9gnu_obj_1E
+testfile7: ee1 N10__gnu_test9gnu_obj_2IiEE
+testfile7: efd N10__gnu_test9gnu_obj_2IlEE
+testfile7: f19 St16invalid_argument
+testfile8: 79 XZh;
+testfile8: 87 YXh<
+testfile8: 14f SQh[
+testfile8: 259 t5Wj
+testfile8: 502 WRVQ
+testfile8: 1fe7 ZYPj
+testfile8: 2115 u'Pj
+testfile8: 7bba FILE
+testfile8: 7bbf preserve-dates
+testfile8: 7bce remove-comment
+testfile8: 7bdd Remove .comment section
+testfile8: 7bf6 ${prefix}/share
+testfile8: 7c06 elfutils
+testfile8: 7c0f a.out
+testfile8: 7c15 0.58
+testfile8: 7c1a strip (Red Hat %s) %s
+testfile8: 7c31 2002
+testfile8: 7c36 Ulrich Drepper
+testfile8: 7c45 Written by %s.
+testfile8: 7c55 cannot stat input file "%s"
+testfile8: 7c71 %s: INTERNAL ERROR: %s
+testfile8: 7c88 while opening "%s"
+testfile8: 7c9b handle_elf
+testfile8: 7ca6 ../../src/strip.c
+testfile8: 7cb8 shdr_info[cnt].group_idx != 0
+testfile8: 7cd6 illformed file `%s'
+testfile8: 7cea elf_ndxscn (scn) == cnt
+testfile8: 7d02 .shstrtab
+testfile8: 7d0c while writing `%s': %s
+testfile8: 7d23 ((sym->st_info) & 0xf) == 3
+testfile8: 7d3f shndxdata != ((void *)0)
+testfile8: 7d58 scn != ((void *)0)
+testfile8: 7d6b .gnu_debuglink
+testfile8: 7d7a .comment
+testfile8: 7d83 cannot open `%s'
+testfile8: 7da0 Place stripped output into FILE
+testfile8: 7dc0 Extract the removed sections into FILE
+testfile8: 7e00 Copy modified/access timestamps to the output
+testfile8: 7e40 Only one input file allowed together with '-o' and '-f'
+testfile8: 7e80 Copyright (C) %s Red Hat, Inc.
+testfile8: 7e9f This is free software; see the source for copying conditions. There is NO
+testfile8: 7eea warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+testfile8: 7f40 Report bugs to <drepper@redhat.com>.
+testfile8: 7f80 %s: File format not recognized
+testfile8: 7fa0 cannot set access and modification date of "%s"
+testfile8: 7fe0 cannot create new file `%s': %s
+testfile8: 8000 error while finishing `%s': %s
+testfile8: 8020 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0
+testfile8: 8060 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0
+testfile8: 80a0 %s: error while creating ELF header: %s
+testfile8: 80e0 %s: error while reading the file: %s
+testfile8: 8120 sec < 0xff00 || shndxdata != ((void *)0)
+testfile8: 8160 (versiondata->d_size / sizeof (GElf_Versym)) >= shdr_info[cnt].data->d_size / elsize
+testfile8: 81c0 shdr_info[cnt].shdr.sh_type == 11
+testfile8: 8200 (versiondata->d_size / sizeof (Elf32_Word)) >= shdr_info[cnt].data->d_size / elsize
+testfile8: 8260 shdr_info[cnt].shdr.sh_type == 18
+testfile8: 82a0 shdr_info[cnt].data != ((void *)0)
+testfile8: 82e0 elf_ndxscn (shdr_info[cnt].newscn) == idx
+testfile8: 8320 while create section header section: %s
+testfile8: 8360 cannot allocate section data: %s
+testfile8: 83a0 elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx
+testfile8: 83e0 while generating output file: %s
+testfile8: 8420 while preparing output for `%s'
+testfile8: 8440 shdr_info[cnt].shdr.sh_type == 2
+testfile8: 8480 shdr_info[idx].data != ((void *)0)
+testfile8: 84c0 cannot determine number of sections: %s
+testfile8: 8500 cannot get section header string table index
+testfile8: 85c0 Discard symbols from object files.
+testfile8: 85e3 [FILE...]
+testfile9: 79 XZh;
+testfile9: 87 YXh<
+testfile9: 14f SQh[
+testfile9: 259 t5Wj
+testfile9: 502 WRVQ
+testfile9: 1fe7 ZYPj
+testfile9: 2115 u'Pj
+testfile9: 3414 FILE
+testfile9: 3419 preserve-dates
+testfile9: 3428 remove-comment
+testfile9: 3437 Remove .comment section
+testfile9: 3450 ${prefix}/share
+testfile9: 3460 elfutils
+testfile9: 3469 a.out
+testfile9: 346f 0.58
+testfile9: 3474 strip (Red Hat %s) %s
+testfile9: 348b 2002
+testfile9: 3490 Ulrich Drepper
+testfile9: 349f Written by %s.
+testfile9: 34af cannot stat input file "%s"
+testfile9: 34cb %s: INTERNAL ERROR: %s
+testfile9: 34e2 while opening "%s"
+testfile9: 34f5 handle_elf
+testfile9: 3500 ../../src/strip.c
+testfile9: 3512 shdr_info[cnt].group_idx != 0
+testfile9: 3530 illformed file `%s'
+testfile9: 3544 elf_ndxscn (scn) == cnt
+testfile9: 355c .shstrtab
+testfile9: 3566 while writing `%s': %s
+testfile9: 357d ((sym->st_info) & 0xf) == 3
+testfile9: 3599 shndxdata != ((void *)0)
+testfile9: 35b2 scn != ((void *)0)
+testfile9: 35c5 .gnu_debuglink
+testfile9: 35d4 .comment
+testfile9: 35dd cannot open `%s'
+testfile9: 3600 Place stripped output into FILE
+testfile9: 3620 Extract the removed sections into FILE
+testfile9: 3660 Copy modified/access timestamps to the output
+testfile9: 36a0 Only one input file allowed together with '-o' and '-f'
+testfile9: 36e0 Copyright (C) %s Red Hat, Inc.
+testfile9: 36ff This is free software; see the source for copying conditions. There is NO
+testfile9: 374a warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+testfile9: 37a0 Report bugs to <drepper@redhat.com>.
+testfile9: 37e0 %s: File format not recognized
+testfile9: 3800 cannot set access and modification date of "%s"
+testfile9: 3840 cannot create new file `%s': %s
+testfile9: 3860 error while finishing `%s': %s
+testfile9: 3880 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0
+testfile9: 38c0 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0
+testfile9: 3900 %s: error while creating ELF header: %s
+testfile9: 3940 %s: error while reading the file: %s
+testfile9: 3980 sec < 0xff00 || shndxdata != ((void *)0)
+testfile9: 39c0 (versiondata->d_size / sizeof (GElf_Versym)) >= shdr_info[cnt].data->d_size / elsize
+testfile9: 3a20 shdr_info[cnt].shdr.sh_type == 11
+testfile9: 3a60 (versiondata->d_size / sizeof (Elf32_Word)) >= shdr_info[cnt].data->d_size / elsize
+testfile9: 3ac0 shdr_info[cnt].shdr.sh_type == 18
+testfile9: 3b00 shdr_info[cnt].data != ((void *)0)
+testfile9: 3b40 elf_ndxscn (shdr_info[cnt].newscn) == idx
+testfile9: 3b80 while create section header section: %s
+testfile9: 3bc0 cannot allocate section data: %s
+testfile9: 3c00 elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx
+testfile9: 3c40 while generating output file: %s
+testfile9: 3c80 while preparing output for `%s'
+testfile9: 3ca0 shdr_info[cnt].shdr.sh_type == 2
+testfile9: 3ce0 shdr_info[idx].data != ((void *)0)
+testfile9: 3d20 cannot determine number of sections: %s
+testfile9: 3d60 cannot get section header string table index
+testfile9: 3e20 Discard symbols from object files.
+testfile9: 3e43 [FILE...]
+EOF
+
+exit 0
diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh
new file mode 100755
index 0000000..1303819
--- /dev/null
+++ b/tests/run-strip-g.sh
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2017 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
+
+# When stripping just the debug sections/symbols we keep the symtab
+# in the main ELF file. There should be no symbols pointing into the
+# debug sections and so there should not be a copy in the debug file
+# except for a NOBITS one.
+
+tempfiles a.out strip.out debug.out readelf.out
+
+echo Create debug a.out.
+echo "int main() { return 1; }" | gcc -g -xc -
+
+echo strip -g to file with debug file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
+ { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; }
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 0; then
+ echo no symtab found in strip.out
+ exit 1
+fi
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 1; then
+ echo symtab found in debug.out
+ exit 1
+fi
+
+# arm (with data marker in .debug_frame). See tests/run-addrcfi.sh
+testfiles testfilearm
+
+echo arm strip -g to file with debug file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfilearm ||
+ { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; }
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 0; then
+ echo no symtab found in strip.out
+ exit 1
+fi
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 1; then
+ echo symtab found in debug.out
+ exit 1
+fi
+
+# aarch64 (with data marker in .debug_frame). See tests/run-addrcfi.sh
+testfiles testfileaarch64
+
+echo aarch64 strip -g to file with debug file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfileaarch64 ||
+ { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; }
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 0; then
+ echo no symtab found in strip.out
+ exit 1
+fi
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 1; then
+ echo symtab found in debug.out
+ exit 1
+fi
+
+exit 0
diff --git a/tests/run-strip-groups.sh b/tests/run-strip-groups.sh
new file mode 100755
index 0000000..1c836a4
--- /dev/null
+++ b/tests/run-strip-groups.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+#
+# g++ -gdwarf-4 -c testfile58.cxx
+# class ct
+# {
+# private:
+# int i;
+#
+# public:
+# void foo ()
+# {
+# i = 1;
+# }
+#
+# int bar ()
+# {
+# return i;
+# }
+# };
+#
+# int baz ()
+# {
+# class ct c;
+# c.foo ();
+# return c.bar ();
+# }
+
+. $srcdir/test-subr.sh
+
+infile=testfile58
+outfile=$infile.stripped
+dbgfile=$infile.debug
+
+testfiles $infile
+tempfiles $outfile $dbgfile
+
+testrun ${abs_top_builddir}/src/strip -o $outfile -f $dbgfile $infile
+testrun ${abs_top_builddir}/src/elflint -q $infile
+testrun ${abs_top_builddir}/src/elflint -q $outfile
+testrun ${abs_top_builddir}/src/elflint -q -d $dbgfile
diff --git a/tests/run-strip-nobitsalign.sh b/tests/run-strip-nobitsalign.sh
new file mode 100755
index 0000000..db9b1d9
--- /dev/null
+++ b/tests/run-strip-nobitsalign.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) Red Hat, Inc., 2016.
+# 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/>.
+
+# static unsigned char buffer[4096] __attribute((aligned (4096)));
+#
+# char
+# f (int i)
+# {
+# return buffer[i];
+# }
+#
+# int
+# main (int argc, char **argv)
+# {
+# return buffer[argc] == 0;
+# }
+
+original=testfile-nobitsalign
+stripped=testfile-nobitsalign.strip
+
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-nothing.sh b/tests/run-strip-nothing.sh
new file mode 100755
index 0000000..914fdfb
--- /dev/null
+++ b/tests/run-strip-nothing.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2017 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
+
+# If there is nothing to strip then -o output should be identical to input.
+# And there should not be an (empty) -f debug file.
+
+tempfiles a.out strip.out debug.out
+
+# Create no-debug a.out.
+echo "int main() { return 1; }" | gcc -s -xc -
+
+# strip to file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out ||
+ { echo "*** failed to strip -g -o strip.out a.out"; exit -1; }
+
+testrun ${abs_top_builddir}/src/elfcmp a.out strip.out ||
+ { echo "*** failed strip.out different from a.out"; exit -1; }
+
+# strip original
+testrun ${abs_top_builddir}/src/strip -g ||
+ { echo "*** failed to strip -g a.out"; exit -1; }
+
+testrun ${abs_top_builddir}/src/elfcmp strip.out a.out ||
+ { echo "*** failed a.out different from strip.out"; exit -1; }
+
+# strip to file with debug file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
+ { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; }
+
+testrun ${abs_top_builddir}/src/elfcmp a.out strip.out ||
+ { echo "*** failed strip.out different from a.out (with debug)"; exit -1; }
+
+test ! -f debug.out ||
+ { echo "*** failed strip.out and debug.out exist"; exit -1; }
+
+# strip original with debug file
+testrun ${abs_top_builddir}/src/strip -g -f debug.out ||
+ { echo "*** failed to strip -g -f debug.out a.out"; exit -1; }
+
+testrun ${abs_top_builddir}/src/elfcmp strip.out a.out ||
+ { echo "*** failed a.out different from strip.out (with debug)"; exit -1; }
+
+test ! -f debug.out ||
+ { echo "*** failed a.out and debug.out exist"; exit -1; }
+
+exit 0
diff --git a/tests/run-strip-reloc.sh b/tests/run-strip-reloc.sh
new file mode 100755
index 0000000..e587eab
--- /dev/null
+++ b/tests/run-strip-reloc.sh
@@ -0,0 +1,122 @@
+#! /bin/sh
+# Copyright (C) 2011, 2013 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
+
+testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko \
+ hello_aarch64.ko hello_m68k.ko
+
+tempfiles readelf.out readelf.out1 readelf.out2
+tempfiles out.stripped1 out.debug1 out.stripped2 out.debug2
+
+status=0
+runtest() {
+ infile=$1
+ is_ET_REL=$2
+ outfile1=out.stripped1
+ debugfile1=out.debug1
+ outfile2=out.stripped2
+ debugfile2=out.debug2
+
+ testrun ${abs_top_builddir}/src/strip -o $outfile1 -f $debugfile1 $infile ||
+ { echo "*** failure strip $infile"; status=1; }
+
+ testrun ${abs_top_builddir}/src/strip --reloc-debug-sections -o $outfile2 \
+ -f $debugfile2 $infile ||
+ { echo "*** failure strip --reloc-debug-sections $infile"; status=1; }
+
+ # shouldn't make any difference for stripped files.
+ testrun ${abs_top_builddir}/src/readelf -a $outfile1 > readelf.out ||
+ { echo "*** failure readelf -a outfile1 $infile"; status=1; }
+
+ testrun_compare ${abs_top_builddir}/src/readelf -a $outfile2 < readelf.out ||
+ { echo "*** failure compare stripped files $infile"; status=1; }
+
+ # debug files however should be smaller, when ET_REL.
+ SIZE1=$(stat -c%s $debugfile1)
+ SIZE2=$(stat -c%s $debugfile2)
+ test \( \( $is_ET_REL -eq 1 \) -a \( $SIZE1 -gt $SIZE2 \) \) \
+ -o \( \( $is_ET_REL -eq 0 \) -a \( $SIZE1 -eq $SIZE2 \) \) ||
+ { echo "*** failure --reloc-debug-sections not smaller $infile"; status=1; }
+
+ # Strip of DWARF section lines, offset will not match.
+ # Everything else should match.
+ testrun ${abs_top_builddir}/src/readelf -w $debugfile1 \
+ | grep -v ^DWARF\ section > readelf.out1 ||
+ { echo "*** failure readelf -w debugfile1 $infile"; status=1; }
+
+ testrun ${abs_top_builddir}/src/readelf -w $debugfile2 \
+ | grep -v ^DWARF\ section > readelf.out2 ||
+ { echo "*** failure readelf -w debugfile2 $infile"; status=1; }
+
+ testrun_compare cat readelf.out1 < readelf.out2 ||
+ { echo "*** failure readelf -w compare $infile"; status=1; }
+}
+
+# Most simple hello world kernel module for various architectures.
+# ::::::::::::::
+# Makefile
+# ::::::::::::::
+# obj-m := hello.o
+# hello-y := init.o exit.o
+#
+# all:
+# make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+# ::::::::::::::
+# init.c
+# ::::::::::::::
+# #include <linux/kernel.h>
+# #include <linux/module.h>
+#
+# int init_module(void)
+# {
+# printk(KERN_INFO "Hello, world!\n");
+# return 0;
+# }
+# ::::::::::::::
+# exit.c
+# ::::::::::::::
+# #include <linux/kernel.h>
+# #include <linux/module.h>
+#
+# void cleanup_module()
+# {
+# printk(KERN_INFO "Goodbye, World!\n");
+# }
+runtest hello_i386.ko 1
+runtest hello_x86_64.ko 1
+runtest hello_ppc64.ko 1
+runtest hello_s390.ko 1
+runtest hello_aarch64.ko 1
+runtest hello_m68k.ko 1
+
+# self test, shouldn't impact non-ET_REL files at all.
+runtest ${abs_top_builddir}/src/strip 0
+runtest ${abs_top_builddir}/src/strip.o 1
+
+# Copy ET_REL file for self-test and make sure to run with/without
+# elf section compression.
+tempfiles strip-uncompressed.o strip-compressed.o
+testrun ${abs_top_builddir}/src/elfcompress -o strip-uncompressed.o -t none \
+ ${abs_top_builddir}/src/strip.o
+testrun ${abs_top_builddir}/src/elfcompress -o strip-compressed.o -t zlib \
+ --force ${abs_top_builddir}/src/strip.o
+
+runtest strip-uncompressed.o 1
+runtest strip-compressed.o 1
+
+exit $status
diff --git a/tests/run-strip-remove-keep.sh b/tests/run-strip-remove-keep.sh
new file mode 100755
index 0000000..92647fa
--- /dev/null
+++ b/tests/run-strip-remove-keep.sh
@@ -0,0 +1,688 @@
+#! /bin/sh
+# Copyright (C) 2017 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
+
+# strip -o output and -f debug files
+tempfiles testfile.elf testfile.debug
+
+# A random 32bit testfile
+testfiles testfile
+
+# Explicitly keep .strtab (but not .symtab, so .strtab will be in both). 32bit
+echo strip --keep-section=.strtab testfile
+testrun ${abs_top_builddir}/src/strip --keep-section=.strtab -o testfile.elf -f testfile.debug testfile
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 27 section headers, starting at offset 0xaf8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp PROGBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 000108 000020 0 A 0 0 4
+[ 3] .hash HASH 08048128 000128 000030 4 A 4 0 4
+[ 4] .dynsym DYNSYM 08048158 000158 000070 16 A 5 1 4
+[ 5] .dynstr STRTAB 080481c8 0001c8 00008e 0 A 0 0 1
+[ 6] .gnu.version GNU_versym 08048256 000256 00000e 2 A 4 0 2
+[ 7] .gnu.version_r GNU_verneed 08048264 000264 000030 0 A 5 1 4
+[ 8] .rel.got REL 08048294 000294 000008 8 A 4 19 4
+[ 9] .rel.plt REL 0804829c 00029c 000020 8 A 4 11 4
+[10] .init PROGBITS 080482bc 0002bc 000018 0 AX 0 0 4
+[11] .plt PROGBITS 080482d4 0002d4 000050 4 AX 0 0 4
+[12] .text PROGBITS 08048330 000330 00018c 0 AX 0 0 16
+[13] .fini PROGBITS 080484bc 0004bc 00001e 0 AX 0 0 4
+[14] .rodata PROGBITS 080484dc 0004dc 000008 0 A 0 0 4
+[15] .data PROGBITS 080494e4 0004e4 000010 0 WA 0 0 4
+[16] .eh_frame PROGBITS 080494f4 0004f4 000004 0 WA 0 0 4
+[17] .ctors PROGBITS 080494f8 0004f8 000008 0 WA 0 0 4
+[18] .dtors PROGBITS 08049500 000500 000008 0 WA 0 0 4
+[19] .got PROGBITS 08049508 000508 000020 4 WA 0 0 4
+[20] .dynamic DYNAMIC 08049528 000528 0000a0 8 WA 5 0 4
+[21] .bss NOBITS 080495c8 0005c8 00001c 0 WA 0 0 4
+[22] .comment PROGBITS 00000000 0005c8 000170 0 0 0 1
+[23] .note NOTE 00000000 000738 0000a0 0 0 0 1
+[24] .strtab STRTAB 00000000 0007d8 000235 0 0 0 1
+[25] .gnu_debuglink PROGBITS 00000000 000a10 000014 0 0 0 4
+[26] .shstrtab STRTAB 00000000 000a24 0000d1 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 35 section headers, starting at offset 0x463c:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp NOBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 0000f4 000020 0 A 0 0 4
+[ 3] .hash NOBITS 08048128 000114 000030 4 A 4 0 4
+[ 4] .dynsym NOBITS 08048158 000114 000070 16 A 5 1 4
+[ 5] .dynstr NOBITS 080481c8 000114 00008e 0 A 0 0 1
+[ 6] .gnu.version NOBITS 08048256 000114 00000e 2 A 4 0 2
+[ 7] .gnu.version_r NOBITS 08048264 000114 000030 0 A 5 1 4
+[ 8] .rel.got NOBITS 08048294 000114 000008 8 A 4 19 4
+[ 9] .rel.plt NOBITS 0804829c 000114 000020 8 A 4 11 4
+[10] .init NOBITS 080482bc 000114 000018 0 AX 0 0 4
+[11] .plt NOBITS 080482d4 000114 000050 4 AX 0 0 4
+[12] .text NOBITS 08048330 000120 00018c 0 AX 0 0 16
+[13] .fini NOBITS 080484bc 000120 00001e 0 AX 0 0 4
+[14] .rodata NOBITS 080484dc 000120 000008 0 A 0 0 4
+[15] .data NOBITS 080494e4 000120 000010 0 WA 0 0 4
+[16] .eh_frame NOBITS 080494f4 000120 000004 0 WA 0 0 4
+[17] .ctors NOBITS 080494f8 000120 000008 0 WA 0 0 4
+[18] .dtors NOBITS 08049500 000120 000008 0 WA 0 0 4
+[19] .got NOBITS 08049508 000120 000020 4 WA 0 0 4
+[20] .dynamic NOBITS 08049528 000120 0000a0 8 WA 5 0 4
+[21] .sbss PROGBITS 080495c8 000120 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 000120 00001c 0 WA 0 0 4
+[23] .stab PROGBITS 00000000 000120 000720 12 24 0 4
+[24] .stabstr STRTAB 00000000 000840 001934 0 0 0 1
+[25] .comment NOBITS 00000000 002174 000170 0 0 0 1
+[26] .debug_aranges PROGBITS 00000000 002174 000060 0 0 0 1
+[27] .debug_pubnames PROGBITS 00000000 0021d4 000055 0 0 0 1
+[28] .debug_info PROGBITS 00000000 002229 001678 0 0 0 1
+[29] .debug_abbrev PROGBITS 00000000 0038a1 0001d2 0 0 0 1
+[30] .debug_line PROGBITS 00000000 003a73 000223 0 0 0 1
+[31] .note NOTE 00000000 003c96 0000a0 0 0 0 1
+[32] .shstrtab STRTAB 00000000 003d36 00012e 0 0 0 1
+[33] .symtab SYMTAB 00000000 003e64 0005a0 16 34 68 4
+[34] .strtab STRTAB 00000000 004404 000235 0 0 0 1
+
+EOF
+
+# Explicitly keep .symtab (pulls in .strtab, so they will both be in elf). 32bit
+echo strip --keep-section=.symtab testfile
+testrun ${abs_top_builddir}/src/strip --keep-section=.symtab -o testfile.elf -f testfile.debug testfile
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 28 section headers, starting at offset 0x1010:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp PROGBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 000108 000020 0 A 0 0 4
+[ 3] .hash HASH 08048128 000128 000030 4 A 4 0 4
+[ 4] .dynsym DYNSYM 08048158 000158 000070 16 A 5 1 4
+[ 5] .dynstr STRTAB 080481c8 0001c8 00008e 0 A 0 0 1
+[ 6] .gnu.version GNU_versym 08048256 000256 00000e 2 A 4 0 2
+[ 7] .gnu.version_r GNU_verneed 08048264 000264 000030 0 A 5 1 4
+[ 8] .rel.got REL 08048294 000294 000008 8 A 4 19 4
+[ 9] .rel.plt REL 0804829c 00029c 000020 8 A 4 11 4
+[10] .init PROGBITS 080482bc 0002bc 000018 0 AX 0 0 4
+[11] .plt PROGBITS 080482d4 0002d4 000050 4 AX 0 0 4
+[12] .text PROGBITS 08048330 000330 00018c 0 AX 0 0 16
+[13] .fini PROGBITS 080484bc 0004bc 00001e 0 AX 0 0 4
+[14] .rodata PROGBITS 080484dc 0004dc 000008 0 A 0 0 4
+[15] .data PROGBITS 080494e4 0004e4 000010 0 WA 0 0 4
+[16] .eh_frame PROGBITS 080494f4 0004f4 000004 0 WA 0 0 4
+[17] .ctors PROGBITS 080494f8 0004f8 000008 0 WA 0 0 4
+[18] .dtors PROGBITS 08049500 000500 000008 0 WA 0 0 4
+[19] .got PROGBITS 08049508 000508 000020 4 WA 0 0 4
+[20] .dynamic DYNAMIC 08049528 000528 0000a0 8 WA 5 0 4
+[21] .bss NOBITS 080495c8 0005c8 00001c 0 WA 0 0 4
+[22] .comment PROGBITS 00000000 0005c8 000170 0 0 0 1
+[23] .note NOTE 00000000 000738 0000a0 0 0 0 1
+[24] .symtab SYMTAB 00000000 0007d8 000510 16 25 59 4
+[25] .strtab STRTAB 00000000 000ce8 000235 0 0 0 1
+[26] .gnu_debuglink PROGBITS 00000000 000f20 000014 0 0 0 4
+[27] .shstrtab STRTAB 00000000 000f34 0000d9 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 35 section headers, starting at offset 0x3e64:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp NOBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 0000f4 000020 0 A 0 0 4
+[ 3] .hash NOBITS 08048128 000114 000030 4 A 4 0 4
+[ 4] .dynsym NOBITS 08048158 000114 000070 16 A 5 1 4
+[ 5] .dynstr NOBITS 080481c8 000114 00008e 0 A 0 0 1
+[ 6] .gnu.version NOBITS 08048256 000114 00000e 2 A 4 0 2
+[ 7] .gnu.version_r NOBITS 08048264 000114 000030 0 A 5 1 4
+[ 8] .rel.got NOBITS 08048294 000114 000008 8 A 4 19 4
+[ 9] .rel.plt NOBITS 0804829c 000114 000020 8 A 4 11 4
+[10] .init NOBITS 080482bc 000114 000018 0 AX 0 0 4
+[11] .plt NOBITS 080482d4 000114 000050 4 AX 0 0 4
+[12] .text NOBITS 08048330 000120 00018c 0 AX 0 0 16
+[13] .fini NOBITS 080484bc 000120 00001e 0 AX 0 0 4
+[14] .rodata NOBITS 080484dc 000120 000008 0 A 0 0 4
+[15] .data NOBITS 080494e4 000120 000010 0 WA 0 0 4
+[16] .eh_frame NOBITS 080494f4 000120 000004 0 WA 0 0 4
+[17] .ctors NOBITS 080494f8 000120 000008 0 WA 0 0 4
+[18] .dtors NOBITS 08049500 000120 000008 0 WA 0 0 4
+[19] .got NOBITS 08049508 000120 000020 4 WA 0 0 4
+[20] .dynamic NOBITS 08049528 000120 0000a0 8 WA 5 0 4
+[21] .sbss PROGBITS 080495c8 000120 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 000120 00001c 0 WA 0 0 4
+[23] .stab PROGBITS 00000000 000120 000720 12 24 0 4
+[24] .stabstr STRTAB 00000000 000840 001934 0 0 0 1
+[25] .comment NOBITS 00000000 002174 000170 0 0 0 1
+[26] .debug_aranges PROGBITS 00000000 002174 000060 0 0 0 1
+[27] .debug_pubnames PROGBITS 00000000 0021d4 000055 0 0 0 1
+[28] .debug_info PROGBITS 00000000 002229 001678 0 0 0 1
+[29] .debug_abbrev PROGBITS 00000000 0038a1 0001d2 0 0 0 1
+[30] .debug_line PROGBITS 00000000 003a73 000223 0 0 0 1
+[31] .note NOTE 00000000 003c96 0000a0 0 0 0 1
+[32] .shstrtab STRTAB 00000000 003d36 00012e 0 0 0 1
+[33] .symtab NOBITS 00000000 003e64 0005a0 16 34 68 4
+[34] .strtab NOBITS 00000000 003e64 000235 0 0 0 1
+
+EOF
+
+# A random 64bit testfile
+testfiles testfile69.so
+# Explicitly keep .strtab (but not .symtab, so .strtab will be in both). 64bit
+echo strip --keep-section=.strtab testfile69.so
+testrun ${abs_top_builddir}/src/strip --keep-section=.strtab -o testfile.elf -f testfile.debug testfile69.so
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 27 section headers, starting at offset 0xad8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym DYNSYM 00000000000001f8 000001f8 00000108 24 A 4 2 8
+[ 4] .dynstr STRTAB 0000000000000300 00000300 00000077 0 A 0 0 1
+[ 5] .gnu.version GNU_versym 0000000000000378 00000378 00000016 2 A 3 0 2
+[ 6] .gnu.version_r GNU_verneed 0000000000000390 00000390 00000020 0 A 4 1 8
+[ 7] .rela.dyn RELA 00000000000003b0 000003b0 00000060 24 A 3 0 8
+[ 8] .rela.plt RELA 0000000000000410 00000410 00000018 24 A 3 10 8
+[ 9] .init PROGBITS 0000000000000428 00000428 00000018 0 AX 0 0 4
+[10] .plt PROGBITS 0000000000000440 00000440 00000020 16 AX 0 0 16
+[11] .text PROGBITS 0000000000000460 00000460 00000128 0 AX 0 0 16
+[12] .fini PROGBITS 0000000000000588 00000588 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr PROGBITS 0000000000000598 00000598 00000024 0 A 0 0 4
+[14] .eh_frame PROGBITS 00000000000005c0 000005c0 00000084 0 A 0 0 8
+[15] .ctors PROGBITS 0000000000200648 00000648 00000010 0 WA 0 0 8
+[16] .dtors PROGBITS 0000000000200658 00000658 00000010 0 WA 0 0 8
+[17] .jcr PROGBITS 0000000000200668 00000668 00000008 0 WA 0 0 8
+[18] .data.rel.ro PROGBITS 0000000000200670 00000670 00000008 0 WA 0 0 8
+[19] .dynamic DYNAMIC 0000000000200678 00000678 00000180 16 WA 4 0 8
+[20] .got PROGBITS 00000000002007f8 000007f8 00000018 8 WA 0 0 8
+[21] .got.plt PROGBITS 0000000000200810 00000810 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 00000830 00000010 0 WA 0 0 8
+[23] .comment PROGBITS 0000000000000000 00000830 0000002c 1 MS 0 0 1
+[24] .strtab STRTAB 0000000000000000 0000085c 00000175 0 0 0 1
+[25] .gnu_debuglink PROGBITS 0000000000000000 000009d4 00000014 0 0 0 4
+[26] .shstrtab STRTAB 0000000000000000 000009e8 000000ee 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 27 section headers, starting at offset 0x918:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash NOBITS 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym NOBITS 00000000000001f8 000001b8 00000108 24 A 4 2 8
+[ 4] .dynstr NOBITS 0000000000000300 000001b8 00000077 0 A 0 0 1
+[ 5] .gnu.version NOBITS 0000000000000378 000001b8 00000016 2 A 3 0 2
+[ 6] .gnu.version_r NOBITS 0000000000000390 000001b8 00000020 0 A 4 1 8
+[ 7] .rela.dyn NOBITS 00000000000003b0 000001b8 00000060 24 A 3 0 8
+[ 8] .rela.plt NOBITS 0000000000000410 000001b8 00000018 24 A 3 10 8
+[ 9] .init NOBITS 0000000000000428 000001b8 00000018 0 AX 0 0 4
+[10] .plt NOBITS 0000000000000440 000001c0 00000020 16 AX 0 0 16
+[11] .text NOBITS 0000000000000460 000001c0 00000128 0 AX 0 0 16
+[12] .fini NOBITS 0000000000000588 000001c0 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr NOBITS 0000000000000598 000001c0 00000024 0 A 0 0 4
+[14] .eh_frame NOBITS 00000000000005c0 000001c0 00000084 0 A 0 0 8
+[15] .ctors NOBITS 0000000000200648 000001c0 00000010 0 WA 0 0 8
+[16] .dtors NOBITS 0000000000200658 000001c0 00000010 0 WA 0 0 8
+[17] .jcr NOBITS 0000000000200668 000001c0 00000008 0 WA 0 0 8
+[18] .data.rel.ro NOBITS 0000000000200670 000001c0 00000008 0 WA 0 0 8
+[19] .dynamic NOBITS 0000000000200678 000001c0 00000180 16 WA 4 0 8
+[20] .got NOBITS 00000000002007f8 000001c0 00000018 8 WA 0 0 8
+[21] .got.plt NOBITS 0000000000200810 000001c0 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 000001c0 00000010 0 WA 0 0 8
+[23] .comment NOBITS 0000000000000000 000001c0 0000002c 1 MS 0 0 1
+[24] .shstrtab STRTAB 0000000000000000 000001c0 000000e7 0 0 0 1
+[25] .symtab SYMTAB 0000000000000000 000002a8 000004f8 24 26 44 8
+[26] .strtab STRTAB 0000000000000000 000007a0 00000175 0 0 0 1
+
+EOF
+
+# Explicitly keep .symtab (pulls in .strtab, so they will both be in elf). 64bit
+# Use --remove-comment to make sure testfile.debug isn't empty.
+echo strip --keep-section=.symtab --remove-comment testfile69.so
+testrun ${abs_top_builddir}/src/strip --keep-section=.symtab --remove-comment -o testfile.elf -f testfile.debug testfile69.so
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 27 section headers, starting at offset 0xf90:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym DYNSYM 00000000000001f8 000001f8 00000108 24 A 4 2 8
+[ 4] .dynstr STRTAB 0000000000000300 00000300 00000077 0 A 0 0 1
+[ 5] .gnu.version GNU_versym 0000000000000378 00000378 00000016 2 A 3 0 2
+[ 6] .gnu.version_r GNU_verneed 0000000000000390 00000390 00000020 0 A 4 1 8
+[ 7] .rela.dyn RELA 00000000000003b0 000003b0 00000060 24 A 3 0 8
+[ 8] .rela.plt RELA 0000000000000410 00000410 00000018 24 A 3 10 8
+[ 9] .init PROGBITS 0000000000000428 00000428 00000018 0 AX 0 0 4
+[10] .plt PROGBITS 0000000000000440 00000440 00000020 16 AX 0 0 16
+[11] .text PROGBITS 0000000000000460 00000460 00000128 0 AX 0 0 16
+[12] .fini PROGBITS 0000000000000588 00000588 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr PROGBITS 0000000000000598 00000598 00000024 0 A 0 0 4
+[14] .eh_frame PROGBITS 00000000000005c0 000005c0 00000084 0 A 0 0 8
+[15] .ctors PROGBITS 0000000000200648 00000648 00000010 0 WA 0 0 8
+[16] .dtors PROGBITS 0000000000200658 00000658 00000010 0 WA 0 0 8
+[17] .jcr PROGBITS 0000000000200668 00000668 00000008 0 WA 0 0 8
+[18] .data.rel.ro PROGBITS 0000000000200670 00000670 00000008 0 WA 0 0 8
+[19] .dynamic DYNAMIC 0000000000200678 00000678 00000180 16 WA 4 0 8
+[20] .got PROGBITS 00000000002007f8 000007f8 00000018 8 WA 0 0 8
+[21] .got.plt PROGBITS 0000000000200810 00000810 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 00000830 00000010 0 WA 0 0 8
+[23] .symtab SYMTAB 0000000000000000 00000830 000004e0 24 24 43 8
+[24] .strtab STRTAB 0000000000000000 00000d10 00000175 0 0 0 1
+[25] .gnu_debuglink PROGBITS 0000000000000000 00000e88 00000014 0 0 0 4
+[26] .shstrtab STRTAB 0000000000000000 00000e9c 000000ed 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 27 section headers, starting at offset 0x2d8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash NOBITS 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym NOBITS 00000000000001f8 000001b8 00000108 24 A 4 2 8
+[ 4] .dynstr NOBITS 0000000000000300 000001b8 00000077 0 A 0 0 1
+[ 5] .gnu.version NOBITS 0000000000000378 000001b8 00000016 2 A 3 0 2
+[ 6] .gnu.version_r NOBITS 0000000000000390 000001b8 00000020 0 A 4 1 8
+[ 7] .rela.dyn NOBITS 00000000000003b0 000001b8 00000060 24 A 3 0 8
+[ 8] .rela.plt NOBITS 0000000000000410 000001b8 00000018 24 A 3 10 8
+[ 9] .init NOBITS 0000000000000428 000001b8 00000018 0 AX 0 0 4
+[10] .plt NOBITS 0000000000000440 000001c0 00000020 16 AX 0 0 16
+[11] .text NOBITS 0000000000000460 000001c0 00000128 0 AX 0 0 16
+[12] .fini NOBITS 0000000000000588 000001c0 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr NOBITS 0000000000000598 000001c0 00000024 0 A 0 0 4
+[14] .eh_frame NOBITS 00000000000005c0 000001c0 00000084 0 A 0 0 8
+[15] .ctors NOBITS 0000000000200648 000001c0 00000010 0 WA 0 0 8
+[16] .dtors NOBITS 0000000000200658 000001c0 00000010 0 WA 0 0 8
+[17] .jcr NOBITS 0000000000200668 000001c0 00000008 0 WA 0 0 8
+[18] .data.rel.ro NOBITS 0000000000200670 000001c0 00000008 0 WA 0 0 8
+[19] .dynamic NOBITS 0000000000200678 000001c0 00000180 16 WA 4 0 8
+[20] .got NOBITS 00000000002007f8 000001c0 00000018 8 WA 0 0 8
+[21] .got.plt NOBITS 0000000000200810 000001c0 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 000001c0 00000010 0 WA 0 0 8
+[23] .comment PROGBITS 0000000000000000 000001c0 0000002c 1 MS 0 0 1
+[24] .shstrtab STRTAB 0000000000000000 000001ec 000000e7 0 0 0 1
+[25] .symtab NOBITS 0000000000000000 000002d8 000004f8 24 26 44 8
+[26] .strtab NOBITS 0000000000000000 000002d8 00000175 0 0 0 1
+
+EOF
+
+# Explicitly remove .symtab (but not .strtab, so it will be in both). 32bit
+echo strip -g --remove-section=.symtab testfile
+testrun ${abs_top_builddir}/src/strip -g --remove-section=.symtab -o testfile.elf -f testfile.debug testfile
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 28 section headers, starting at offset 0xafc:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp PROGBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 000108 000020 0 A 0 0 4
+[ 3] .hash HASH 08048128 000128 000030 4 A 4 0 4
+[ 4] .dynsym DYNSYM 08048158 000158 000070 16 A 5 1 4
+[ 5] .dynstr STRTAB 080481c8 0001c8 00008e 0 A 0 0 1
+[ 6] .gnu.version GNU_versym 08048256 000256 00000e 2 A 4 0 2
+[ 7] .gnu.version_r GNU_verneed 08048264 000264 000030 0 A 5 1 4
+[ 8] .rel.got REL 08048294 000294 000008 8 A 4 19 4
+[ 9] .rel.plt REL 0804829c 00029c 000020 8 A 4 11 4
+[10] .init PROGBITS 080482bc 0002bc 000018 0 AX 0 0 4
+[11] .plt PROGBITS 080482d4 0002d4 000050 4 AX 0 0 4
+[12] .text PROGBITS 08048330 000330 00018c 0 AX 0 0 16
+[13] .fini PROGBITS 080484bc 0004bc 00001e 0 AX 0 0 4
+[14] .rodata PROGBITS 080484dc 0004dc 000008 0 A 0 0 4
+[15] .data PROGBITS 080494e4 0004e4 000010 0 WA 0 0 4
+[16] .eh_frame PROGBITS 080494f4 0004f4 000004 0 WA 0 0 4
+[17] .ctors PROGBITS 080494f8 0004f8 000008 0 WA 0 0 4
+[18] .dtors PROGBITS 08049500 000500 000008 0 WA 0 0 4
+[19] .got PROGBITS 08049508 000508 000020 4 WA 0 0 4
+[20] .dynamic DYNAMIC 08049528 000528 0000a0 8 WA 5 0 4
+[21] .sbss PROGBITS 080495c8 0005c8 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 0005c8 00001c 0 WA 0 0 4
+[23] .comment PROGBITS 00000000 0005c8 000170 0 0 0 1
+[24] .note NOTE 00000000 000738 0000a0 0 0 0 1
+[25] .strtab STRTAB 00000000 0007d8 000235 0 0 0 1
+[26] .gnu_debuglink PROGBITS 00000000 000a10 000014 0 0 0 4
+[27] .shstrtab STRTAB 00000000 000a24 0000d7 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 35 section headers, starting at offset 0x463c:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp NOBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 0000f4 000020 0 A 0 0 4
+[ 3] .hash NOBITS 08048128 000114 000030 4 A 4 0 4
+[ 4] .dynsym NOBITS 08048158 000114 000070 16 A 5 1 4
+[ 5] .dynstr NOBITS 080481c8 000114 00008e 0 A 0 0 1
+[ 6] .gnu.version NOBITS 08048256 000114 00000e 2 A 4 0 2
+[ 7] .gnu.version_r NOBITS 08048264 000114 000030 0 A 5 1 4
+[ 8] .rel.got NOBITS 08048294 000114 000008 8 A 4 19 4
+[ 9] .rel.plt NOBITS 0804829c 000114 000020 8 A 4 11 4
+[10] .init NOBITS 080482bc 000114 000018 0 AX 0 0 4
+[11] .plt NOBITS 080482d4 000114 000050 4 AX 0 0 4
+[12] .text NOBITS 08048330 000120 00018c 0 AX 0 0 16
+[13] .fini NOBITS 080484bc 000120 00001e 0 AX 0 0 4
+[14] .rodata NOBITS 080484dc 000120 000008 0 A 0 0 4
+[15] .data NOBITS 080494e4 000120 000010 0 WA 0 0 4
+[16] .eh_frame NOBITS 080494f4 000120 000004 0 WA 0 0 4
+[17] .ctors NOBITS 080494f8 000120 000008 0 WA 0 0 4
+[18] .dtors NOBITS 08049500 000120 000008 0 WA 0 0 4
+[19] .got NOBITS 08049508 000120 000020 4 WA 0 0 4
+[20] .dynamic NOBITS 08049528 000120 0000a0 8 WA 5 0 4
+[21] .sbss NOBITS 080495c8 000120 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 000120 00001c 0 WA 0 0 4
+[23] .stab PROGBITS 00000000 000120 000720 12 24 0 4
+[24] .stabstr STRTAB 00000000 000840 001934 0 0 0 1
+[25] .comment NOBITS 00000000 002174 000170 0 0 0 1
+[26] .debug_aranges PROGBITS 00000000 002174 000060 0 0 0 1
+[27] .debug_pubnames PROGBITS 00000000 0021d4 000055 0 0 0 1
+[28] .debug_info PROGBITS 00000000 002229 001678 0 0 0 1
+[29] .debug_abbrev PROGBITS 00000000 0038a1 0001d2 0 0 0 1
+[30] .debug_line PROGBITS 00000000 003a73 000223 0 0 0 1
+[31] .note NOTE 00000000 003c96 0000a0 0 0 0 1
+[32] .shstrtab STRTAB 00000000 003d36 00012e 0 0 0 1
+[33] .symtab SYMTAB 00000000 003e64 0005a0 16 34 68 4
+[34] .strtab STRTAB 00000000 004404 000235 0 0 0 1
+
+EOF
+
+# Explicitly remove both .symtab and .strtab. Keep .stab and .stabstr 32bit
+echo strip -g --remove-section=".s[yt][mr]tab" --keep-section=".stab*" testfile
+testrun ${abs_top_builddir}/src/strip -g --remove-section=".s[yt][mr]tab" --keep-section=".stab*" -o testfile.elf -f testfile.debug testfile
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 29 section headers, starting at offset 0x2920:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp PROGBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 000108 000020 0 A 0 0 4
+[ 3] .hash HASH 08048128 000128 000030 4 A 4 0 4
+[ 4] .dynsym DYNSYM 08048158 000158 000070 16 A 5 1 4
+[ 5] .dynstr STRTAB 080481c8 0001c8 00008e 0 A 0 0 1
+[ 6] .gnu.version GNU_versym 08048256 000256 00000e 2 A 4 0 2
+[ 7] .gnu.version_r GNU_verneed 08048264 000264 000030 0 A 5 1 4
+[ 8] .rel.got REL 08048294 000294 000008 8 A 4 19 4
+[ 9] .rel.plt REL 0804829c 00029c 000020 8 A 4 11 4
+[10] .init PROGBITS 080482bc 0002bc 000018 0 AX 0 0 4
+[11] .plt PROGBITS 080482d4 0002d4 000050 4 AX 0 0 4
+[12] .text PROGBITS 08048330 000330 00018c 0 AX 0 0 16
+[13] .fini PROGBITS 080484bc 0004bc 00001e 0 AX 0 0 4
+[14] .rodata PROGBITS 080484dc 0004dc 000008 0 A 0 0 4
+[15] .data PROGBITS 080494e4 0004e4 000010 0 WA 0 0 4
+[16] .eh_frame PROGBITS 080494f4 0004f4 000004 0 WA 0 0 4
+[17] .ctors PROGBITS 080494f8 0004f8 000008 0 WA 0 0 4
+[18] .dtors PROGBITS 08049500 000500 000008 0 WA 0 0 4
+[19] .got PROGBITS 08049508 000508 000020 4 WA 0 0 4
+[20] .dynamic DYNAMIC 08049528 000528 0000a0 8 WA 5 0 4
+[21] .sbss PROGBITS 080495c8 0005c8 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 0005c8 00001c 0 WA 0 0 4
+[23] .stab PROGBITS 00000000 0005c8 000720 12 24 0 4
+[24] .stabstr STRTAB 00000000 000ce8 001934 0 0 0 1
+[25] .comment PROGBITS 00000000 00261c 000170 0 0 0 1
+[26] .note NOTE 00000000 00278c 0000a0 0 0 0 1
+[27] .gnu_debuglink PROGBITS 00000000 00282c 000014 0 0 0 4
+[28] .shstrtab STRTAB 00000000 002840 0000de 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 35 section headers, starting at offset 0x25e8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp NOBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 0000f4 000020 0 A 0 0 4
+[ 3] .hash NOBITS 08048128 000114 000030 4 A 4 0 4
+[ 4] .dynsym NOBITS 08048158 000114 000070 16 A 5 1 4
+[ 5] .dynstr NOBITS 080481c8 000114 00008e 0 A 0 0 1
+[ 6] .gnu.version NOBITS 08048256 000114 00000e 2 A 4 0 2
+[ 7] .gnu.version_r NOBITS 08048264 000114 000030 0 A 5 1 4
+[ 8] .rel.got NOBITS 08048294 000114 000008 8 A 4 19 4
+[ 9] .rel.plt NOBITS 0804829c 000114 000020 8 A 4 11 4
+[10] .init NOBITS 080482bc 000114 000018 0 AX 0 0 4
+[11] .plt NOBITS 080482d4 000114 000050 4 AX 0 0 4
+[12] .text NOBITS 08048330 000120 00018c 0 AX 0 0 16
+[13] .fini NOBITS 080484bc 000120 00001e 0 AX 0 0 4
+[14] .rodata NOBITS 080484dc 000120 000008 0 A 0 0 4
+[15] .data NOBITS 080494e4 000120 000010 0 WA 0 0 4
+[16] .eh_frame NOBITS 080494f4 000120 000004 0 WA 0 0 4
+[17] .ctors NOBITS 080494f8 000120 000008 0 WA 0 0 4
+[18] .dtors NOBITS 08049500 000120 000008 0 WA 0 0 4
+[19] .got NOBITS 08049508 000120 000020 4 WA 0 0 4
+[20] .dynamic NOBITS 08049528 000120 0000a0 8 WA 5 0 4
+[21] .sbss NOBITS 080495c8 000120 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 000120 00001c 0 WA 0 0 4
+[23] .stab NOBITS 00000000 000120 000720 12 24 0 4
+[24] .stabstr NOBITS 00000000 000120 001934 0 0 0 1
+[25] .comment NOBITS 00000000 000120 000170 0 0 0 1
+[26] .debug_aranges PROGBITS 00000000 000120 000060 0 0 0 1
+[27] .debug_pubnames PROGBITS 00000000 000180 000055 0 0 0 1
+[28] .debug_info PROGBITS 00000000 0001d5 001678 0 0 0 1
+[29] .debug_abbrev PROGBITS 00000000 00184d 0001d2 0 0 0 1
+[30] .debug_line PROGBITS 00000000 001a1f 000223 0 0 0 1
+[31] .note NOTE 00000000 001c42 0000a0 0 0 0 1
+[32] .shstrtab STRTAB 00000000 001ce2 00012e 0 0 0 1
+[33] .symtab SYMTAB 00000000 001e10 0005a0 16 34 68 4
+[34] .strtab STRTAB 00000000 0023b0 000235 0 0 0 1
+
+EOF
+
+# Explicitly remove .symtab (but not .strtab, so it will be in both). 64bit
+echo strip -g --remove-section=.symtab testfile69.so
+testrun ${abs_top_builddir}/src/strip -g --remove-section=.symtab -o testfile.elf -f testfile.debug testfile69.so
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 27 section headers, starting at offset 0xad8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym DYNSYM 00000000000001f8 000001f8 00000108 24 A 4 2 8
+[ 4] .dynstr STRTAB 0000000000000300 00000300 00000077 0 A 0 0 1
+[ 5] .gnu.version GNU_versym 0000000000000378 00000378 00000016 2 A 3 0 2
+[ 6] .gnu.version_r GNU_verneed 0000000000000390 00000390 00000020 0 A 4 1 8
+[ 7] .rela.dyn RELA 00000000000003b0 000003b0 00000060 24 A 3 0 8
+[ 8] .rela.plt RELA 0000000000000410 00000410 00000018 24 A 3 10 8
+[ 9] .init PROGBITS 0000000000000428 00000428 00000018 0 AX 0 0 4
+[10] .plt PROGBITS 0000000000000440 00000440 00000020 16 AX 0 0 16
+[11] .text PROGBITS 0000000000000460 00000460 00000128 0 AX 0 0 16
+[12] .fini PROGBITS 0000000000000588 00000588 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr PROGBITS 0000000000000598 00000598 00000024 0 A 0 0 4
+[14] .eh_frame PROGBITS 00000000000005c0 000005c0 00000084 0 A 0 0 8
+[15] .ctors PROGBITS 0000000000200648 00000648 00000010 0 WA 0 0 8
+[16] .dtors PROGBITS 0000000000200658 00000658 00000010 0 WA 0 0 8
+[17] .jcr PROGBITS 0000000000200668 00000668 00000008 0 WA 0 0 8
+[18] .data.rel.ro PROGBITS 0000000000200670 00000670 00000008 0 WA 0 0 8
+[19] .dynamic DYNAMIC 0000000000200678 00000678 00000180 16 WA 4 0 8
+[20] .got PROGBITS 00000000002007f8 000007f8 00000018 8 WA 0 0 8
+[21] .got.plt PROGBITS 0000000000200810 00000810 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 00000830 00000010 0 WA 0 0 8
+[23] .comment PROGBITS 0000000000000000 00000830 0000002c 1 MS 0 0 1
+[24] .strtab STRTAB 0000000000000000 0000085c 00000175 0 0 0 1
+[25] .gnu_debuglink PROGBITS 0000000000000000 000009d4 00000014 0 0 0 4
+[26] .shstrtab STRTAB 0000000000000000 000009e8 000000ee 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 27 section headers, starting at offset 0x918:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash NOBITS 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym NOBITS 00000000000001f8 000001b8 00000108 24 A 4 2 8
+[ 4] .dynstr NOBITS 0000000000000300 000001b8 00000077 0 A 0 0 1
+[ 5] .gnu.version NOBITS 0000000000000378 000001b8 00000016 2 A 3 0 2
+[ 6] .gnu.version_r NOBITS 0000000000000390 000001b8 00000020 0 A 4 1 8
+[ 7] .rela.dyn NOBITS 00000000000003b0 000001b8 00000060 24 A 3 0 8
+[ 8] .rela.plt NOBITS 0000000000000410 000001b8 00000018 24 A 3 10 8
+[ 9] .init NOBITS 0000000000000428 000001b8 00000018 0 AX 0 0 4
+[10] .plt NOBITS 0000000000000440 000001c0 00000020 16 AX 0 0 16
+[11] .text NOBITS 0000000000000460 000001c0 00000128 0 AX 0 0 16
+[12] .fini NOBITS 0000000000000588 000001c0 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr NOBITS 0000000000000598 000001c0 00000024 0 A 0 0 4
+[14] .eh_frame NOBITS 00000000000005c0 000001c0 00000084 0 A 0 0 8
+[15] .ctors NOBITS 0000000000200648 000001c0 00000010 0 WA 0 0 8
+[16] .dtors NOBITS 0000000000200658 000001c0 00000010 0 WA 0 0 8
+[17] .jcr NOBITS 0000000000200668 000001c0 00000008 0 WA 0 0 8
+[18] .data.rel.ro NOBITS 0000000000200670 000001c0 00000008 0 WA 0 0 8
+[19] .dynamic NOBITS 0000000000200678 000001c0 00000180 16 WA 4 0 8
+[20] .got NOBITS 00000000002007f8 000001c0 00000018 8 WA 0 0 8
+[21] .got.plt NOBITS 0000000000200810 000001c0 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 000001c0 00000010 0 WA 0 0 8
+[23] .comment NOBITS 0000000000000000 000001c0 0000002c 1 MS 0 0 1
+[24] .shstrtab STRTAB 0000000000000000 000001c0 000000e7 0 0 0 1
+[25] .symtab SYMTAB 0000000000000000 000002a8 000004f8 24 26 44 8
+[26] .strtab STRTAB 0000000000000000 000007a0 00000175 0 0 0 1
+
+EOF
+
+# Explicitly remove both .symtab and .strtab. Keep .comment section. 64bit
+echo strip -g --remove-section=".s[yt][mr]tab" --keep-section=.comment testfile69.so
+testrun ${abs_top_builddir}/src/strip -g --remove-section=".s[yt][mr]tab" --keep-section=.comment -o testfile.elf -f testfile.debug testfile69.so
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 26 section headers, starting at offset 0x958:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym DYNSYM 00000000000001f8 000001f8 00000108 24 A 4 2 8
+[ 4] .dynstr STRTAB 0000000000000300 00000300 00000077 0 A 0 0 1
+[ 5] .gnu.version GNU_versym 0000000000000378 00000378 00000016 2 A 3 0 2
+[ 6] .gnu.version_r GNU_verneed 0000000000000390 00000390 00000020 0 A 4 1 8
+[ 7] .rela.dyn RELA 00000000000003b0 000003b0 00000060 24 A 3 0 8
+[ 8] .rela.plt RELA 0000000000000410 00000410 00000018 24 A 3 10 8
+[ 9] .init PROGBITS 0000000000000428 00000428 00000018 0 AX 0 0 4
+[10] .plt PROGBITS 0000000000000440 00000440 00000020 16 AX 0 0 16
+[11] .text PROGBITS 0000000000000460 00000460 00000128 0 AX 0 0 16
+[12] .fini PROGBITS 0000000000000588 00000588 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr PROGBITS 0000000000000598 00000598 00000024 0 A 0 0 4
+[14] .eh_frame PROGBITS 00000000000005c0 000005c0 00000084 0 A 0 0 8
+[15] .ctors PROGBITS 0000000000200648 00000648 00000010 0 WA 0 0 8
+[16] .dtors PROGBITS 0000000000200658 00000658 00000010 0 WA 0 0 8
+[17] .jcr PROGBITS 0000000000200668 00000668 00000008 0 WA 0 0 8
+[18] .data.rel.ro PROGBITS 0000000000200670 00000670 00000008 0 WA 0 0 8
+[19] .dynamic DYNAMIC 0000000000200678 00000678 00000180 16 WA 4 0 8
+[20] .got PROGBITS 00000000002007f8 000007f8 00000018 8 WA 0 0 8
+[21] .got.plt PROGBITS 0000000000200810 00000810 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 00000830 00000010 0 WA 0 0 8
+[23] .comment PROGBITS 0000000000000000 00000830 0000002c 1 MS 0 0 1
+[24] .gnu_debuglink PROGBITS 0000000000000000 0000085c 00000014 0 0 0 4
+[25] .shstrtab STRTAB 0000000000000000 00000870 000000e6 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 27 section headers, starting at offset 0x918:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash NOBITS 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym NOBITS 00000000000001f8 000001b8 00000108 24 A 4 2 8
+[ 4] .dynstr NOBITS 0000000000000300 000001b8 00000077 0 A 0 0 1
+[ 5] .gnu.version NOBITS 0000000000000378 000001b8 00000016 2 A 3 0 2
+[ 6] .gnu.version_r NOBITS 0000000000000390 000001b8 00000020 0 A 4 1 8
+[ 7] .rela.dyn NOBITS 00000000000003b0 000001b8 00000060 24 A 3 0 8
+[ 8] .rela.plt NOBITS 0000000000000410 000001b8 00000018 24 A 3 10 8
+[ 9] .init NOBITS 0000000000000428 000001b8 00000018 0 AX 0 0 4
+[10] .plt NOBITS 0000000000000440 000001c0 00000020 16 AX 0 0 16
+[11] .text NOBITS 0000000000000460 000001c0 00000128 0 AX 0 0 16
+[12] .fini NOBITS 0000000000000588 000001c0 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr NOBITS 0000000000000598 000001c0 00000024 0 A 0 0 4
+[14] .eh_frame NOBITS 00000000000005c0 000001c0 00000084 0 A 0 0 8
+[15] .ctors NOBITS 0000000000200648 000001c0 00000010 0 WA 0 0 8
+[16] .dtors NOBITS 0000000000200658 000001c0 00000010 0 WA 0 0 8
+[17] .jcr NOBITS 0000000000200668 000001c0 00000008 0 WA 0 0 8
+[18] .data.rel.ro NOBITS 0000000000200670 000001c0 00000008 0 WA 0 0 8
+[19] .dynamic NOBITS 0000000000200678 000001c0 00000180 16 WA 4 0 8
+[20] .got NOBITS 00000000002007f8 000001c0 00000018 8 WA 0 0 8
+[21] .got.plt NOBITS 0000000000200810 000001c0 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 000001c0 00000010 0 WA 0 0 8
+[23] .comment NOBITS 0000000000000000 000001c0 0000002c 1 MS 0 0 1
+[24] .shstrtab STRTAB 0000000000000000 000001c0 000000e7 0 0 0 1
+[25] .symtab SYMTAB 0000000000000000 000002a8 000004f8 24 26 44 8
+[26] .strtab STRTAB 0000000000000000 000007a0 00000175 0 0 0 1
+
+EOF
+
+exit 0
diff --git a/tests/run-strip-strmerge.sh b/tests/run-strip-strmerge.sh
new file mode 100755
index 0000000..aa9c1eb
--- /dev/null
+++ b/tests/run-strip-strmerge.sh
@@ -0,0 +1,79 @@
+#! /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
+
+# Generate a file with merged .shstrtab/.strtab table.
+# strip and unstrip it. Check all files with elflint.
+
+# A random ET_EXEC file
+input=${abs_top_builddir}/tests/elfstrmerge
+merged=merged.elf
+stripped=${merged}.stripped
+debugfile=${merged}.debug
+remerged=remerged.elf
+
+tempfiles $merged $stripped $debugfile $remerged
+
+echo elflint $input
+testrun ${abs_top_builddir}/src/elflint --gnu $input
+echo elfstrmerge
+testrun ${abs_top_builddir}/tests/elfstrmerge -o $merged $input
+echo elflint $merged
+testrun ${abs_top_builddir}/src/elflint --gnu $merged
+echo strip
+testrun ${abs_top_builddir}/src/strip -o $stripped -f $debugfile $merged
+echo elflint $stripped
+testrun ${abs_top_builddir}/src/elflint --gnu $stripped
+echo elflint $debugfile
+testrun ${abs_top_builddir}/src/elflint --gnu -d $debugfile
+echo unstrip
+testrun ${abs_top_builddir}/src/unstrip -o $remerged $stripped $debugfile
+echo elflint $remerged
+testrun ${abs_top_builddir}/src/elflint --gnu $remerged
+echo elfcmp
+testrun ${abs_top_builddir}/src/elfcmp $merged $remerged
+
+# A random ET_REL file
+input=${abs_top_builddir}/tests/elfstrmerge.o
+merged=merged.elf
+stripped=${merged}.stripped
+debugfile=${merged}.debug
+remerged=remerged.elf
+
+tempfiles $merged $stripped $debugfile $remerged
+
+echo elflint $input
+testrun ${abs_top_builddir}/src/elflint --gnu $input
+echo elfstrmerge
+testrun ${abs_top_builddir}/tests/elfstrmerge -o $merged $input
+echo elflint $merged
+testrun ${abs_top_builddir}/src/elflint --gnu $merged
+echo strip
+testrun ${abs_top_builddir}/src/strip -o $stripped -f $debugfile $merged
+echo elflint $stripped
+testrun ${abs_top_builddir}/src/elflint --gnu $stripped
+echo elflint $debugfile
+testrun ${abs_top_builddir}/src/elflint --gnu -d $debugfile
+echo unstrip
+testrun ${abs_top_builddir}/src/unstrip -o $remerged $stripped $debugfile
+echo elflint $remerged
+testrun ${abs_top_builddir}/src/elflint --gnu $remerged
+echo elfcmp
+testrun ${abs_top_builddir}/src/elfcmp $merged $remerged
+
+exit 0
diff --git a/tests/run-strip-test.sh b/tests/run-strip-test.sh
new file mode 100755
index 0000000..280814e
--- /dev/null
+++ b/tests/run-strip-test.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2003, 2005, 2007, 2008 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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
+
+original=${original:-testfile11}
+stripped=${stripped:-testfile7}
+debugout=${debugfile:+-f testfile.debug.temp -F $debugfile}
+
+testfiles $original
+test x$stripped = xtestfile.temp || testfiles $stripped $debugfile
+
+tempfiles testfile.temp testfile.debug.temp testfile.unstrip
+
+testrun ${abs_top_builddir}/src/strip -o testfile.temp $debugout $original
+
+status=0
+
+cmp $stripped testfile.temp || status=$?
+
+# Check elflint and the expected result.
+testrun ${abs_top_builddir}/src/elflint --gnu -q testfile.temp || status=$?
+
+test -z "$debugfile" || {
+cmp $debugfile testfile.debug.temp || status=$?
+
+# Check elflint and the expected result.
+testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile.debug.temp || status=$?
+
+# Now test unstrip recombining those files.
+testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile.temp testfile.debug.temp
+
+# Check that it came back whole.
+testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip
+}
+
+# test strip -g
+testrun ${abs_top_builddir}/src/strip -g -o testfile.temp $original
+
+# Buggy eu-strip created multiple .shstrtab sections
+shstrtab_SECS=$(testrun ${abs_top_builddir}/src/readelf -S testfile.temp | grep '.shstrtab' | wc --lines)
+test $shstrtab_SECS -eq 1 ||
+ { echo "*** failure not just one '.shstrtab' testfile.temp ($shstrtab_SECS)"; status=1; }
+
+# Now strip in-place and make sure it is smaller.
+SIZE_original=$(stat -c%s $original)
+testrun ${abs_top_builddir}/src/strip $original
+SIZE_stripped=$(stat -c%s $original)
+test $SIZE_stripped -lt $SIZE_original ||
+ { echo "*** failure in-place strip file not smaller $original"; status=1; }
+
+tempfiles testfile.sections
+testrun ${abs_top_builddir}/src/readelf -S testfile.temp > testfile.sections || status=$?
+fgrep ' .debug_' testfile.sections && status=1
+
+exit $status
diff --git a/tests/run-strip-test10.sh b/tests/run-strip-test10.sh
new file mode 100755
index 0000000..a867b1b
--- /dev/null
+++ b/tests/run-strip-test10.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
+# 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/>.
+
+original=testfile-x32
+stripped=testfile-x32-d
+debugfile=testfile-x32-debug
+
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test11.sh b/tests/run-strip-test11.sh
new file mode 100755
index 0000000..0b1b0ab
--- /dev/null
+++ b/tests/run-strip-test11.sh
@@ -0,0 +1,4 @@
+original=testfile-m68k
+stripped=testfile-m68k-s
+
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test2.sh b/tests/run-strip-test2.sh
new file mode 100755
index 0000000..9217196
--- /dev/null
+++ b/tests/run-strip-test2.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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/>.
+
+
+original=testfile8
+stripped=testfile9
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test3.sh b/tests/run-strip-test3.sh
new file mode 100755
index 0000000..fb37a76
--- /dev/null
+++ b/tests/run-strip-test3.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# Copyright (C) 1999, 2000, 2002, 2003, 2005 Red Hat, Inc.
+# This file is part of elfutils.
+# Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+#
+# 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/>.
+
+
+original=testfile12
+stripped=testfile13
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test4.sh b/tests/run-strip-test4.sh
new file mode 100755
index 0000000..64924a9
--- /dev/null
+++ b/tests/run-strip-test4.sh
@@ -0,0 +1,5 @@
+original=testfile11
+stripped=testfile37
+debugfile=testfile37.debug
+
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test5.sh b/tests/run-strip-test5.sh
new file mode 100755
index 0000000..9fa9ebe
--- /dev/null
+++ b/tests/run-strip-test5.sh
@@ -0,0 +1,5 @@
+original=testfile8
+stripped=testfile16
+debugfile=testfile16.debug
+
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test6.sh b/tests/run-strip-test6.sh
new file mode 100755
index 0000000..c59bf5e
--- /dev/null
+++ b/tests/run-strip-test6.sh
@@ -0,0 +1,5 @@
+original=testfile12
+stripped=testfile35
+debugfile=testfile35.debug
+
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test7.sh b/tests/run-strip-test7.sh
new file mode 100755
index 0000000..c65cd05
--- /dev/null
+++ b/tests/run-strip-test7.sh
@@ -0,0 +1,5 @@
+original=testfile39
+stripped=testfile40
+debugfile=testfile40.debug
+
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test8.sh b/tests/run-strip-test8.sh
new file mode 100755
index 0000000..fb9fa08
--- /dev/null
+++ b/tests/run-strip-test8.sh
@@ -0,0 +1,5 @@
+original=testfile47
+stripped=testfile48
+debugfile=testfile48.debug
+
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strip-test9.sh b/tests/run-strip-test9.sh
new file mode 100755
index 0000000..0c6fae2
--- /dev/null
+++ b/tests/run-strip-test9.sh
@@ -0,0 +1,21 @@
+#! /bin/sh
+# Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
+# 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/>.
+
+
+original=testfile-x32
+stripped=testfile-x32-s
+. $srcdir/run-strip-test.sh
diff --git a/tests/run-strptr.sh b/tests/run-strptr.sh
new file mode 100755
index 0000000..af90a02
--- /dev/null
+++ b/tests/run-strptr.sh
@@ -0,0 +1,98 @@
+#! /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
+
+# A random 32bit and 64bit testfile
+testfiles testfile testfile10
+
+testrun_compare ${abs_top_builddir}/tests/strptr testfile <<\EOF
+Strings in section 32:
+[0] ''
+[1] '.symtab'
+[9] '.strtab'
+[11] '.shstrtab'
+[1b] '.interp'
+[23] '.note.ABI-tag'
+[31] '.hash'
+[37] '.dynsym'
+[3f] '.dynstr'
+[47] '.gnu.version'
+[54] '.gnu.version_r'
+[63] '.rel.got'
+[6c] '.rel.plt'
+[75] '.init'
+[7b] '.plt'
+[80] '.text'
+[86] '.fini'
+[8c] '.rodata'
+[94] '.data'
+[9a] '.eh_frame'
+[a4] '.ctors'
+[ab] '.dtors'
+[b2] '.got'
+[b7] '.dynamic'
+[c0] '.sbss'
+[c6] '.bss'
+[cb] '.stab'
+[d1] '.stabstr'
+[da] '.comment'
+[e3] '.debug_aranges'
+[f2] '.debug_pubnames'
+[102] '.debug_info'
+[10e] '.debug_abbrev'
+[11c] '.debug_line'
+[128] '.note'
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/strptr testfile10 <<\EOF
+Strings in section 30:
+[0] ''
+[1] '.symtab'
+[9] '.strtab'
+[11] '.shstrtab'
+[1b] '.hash'
+[21] '.dynsym'
+[29] '.dynstr'
+[31] '.gnu.version'
+[3e] '.gnu.version_r'
+[4d] '.rela.dyn'
+[57] '.init'
+[5d] '.text'
+[63] '.fini'
+[69] '.eh_frame'
+[73] '.data'
+[79] '.dynamic'
+[82] '.ctors'
+[89] '.dtors'
+[90] '.jcr'
+[95] '.plt'
+[9a] '.got'
+[9f] '.sdata'
+[a6] '.sbss'
+[ac] '.bss'
+[b1] '.comment'
+[ba] '.debug_aranges'
+[c9] '.debug_pubnames'
+[d9] '.debug_abbrev'
+[e7] '.debug_line'
+[f3] '.debug_frame'
+[100] '.debug_str'
+[10b] '.rela.debug_info'
+EOF
+
+exit 0
diff --git a/tests/run-test-archive64.sh b/tests/run-test-archive64.sh
new file mode 100755
index 0000000..2d8c21d
--- /dev/null
+++ b/tests/run-test-archive64.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2012, 2014 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
+
+# The test archive was produced on an s390x machine using the
+# following command sequence:
+# echo 'int aaa(void){}' | gcc -x c /dev/stdin -c -o aaa.o
+# echo 'int bbb(void){} int bbb2(void){}' | gcc -x c /dev/stdin -c -o bbb.o
+# echo 'int ccc(void){} int ccc2(void){} int ccc3(void){}' \
+# | gcc -x c /dev/stdin -c -o ccc.o
+# ar cru testarchive64.a aaa.o bbb.o ccc.o
+testfiles testarchive64.a
+
+testrun_compare ${abs_top_builddir}/src/readelf -c testarchive64.a <<\EOF
+
+Index of archive 'testarchive64.a' has 7 entries:
+Archive member 'aaa.o' contains:
+ aaa
+Archive member 'bbb.o' contains:
+ bbb
+ bbb2
+Archive member 'ccc.o' contains:
+ ccc
+ ccc2
+ ccc3
+EOF
+
+testrun_compare ${abs_top_builddir}/src/nm -P -g testarchive64.a <<\EOF
+testarchive64.a[aaa.o]:
+aaa T 0000000000000000 0000000000000016
+testarchive64.a[bbb.o]:
+bbb T 0000000000000000 0000000000000016
+bbb2 T 0000000000000018 0000000000000016
+testarchive64.a[ccc.o]:
+ccc T 0000000000000000 0000000000000016
+ccc2 T 0000000000000018 0000000000000016
+ccc3 T 0000000000000030 0000000000000016
+EOF
+
+exit 0
diff --git a/tests/run-test-flag-nobits.sh b/tests/run-test-flag-nobits.sh
new file mode 100755
index 0000000..9bedf17
--- /dev/null
+++ b/tests/run-test-flag-nobits.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# Copyright (C) 2010 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
+
+testfiles testfile
+
+testrun ${abs_builddir}/test-flag-nobits testfile
diff --git a/tests/run-typeiter.sh b/tests/run-typeiter.sh
new file mode 100755
index 0000000..2687bab
--- /dev/null
+++ b/tests/run-typeiter.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2012, 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
+
+# struct s1
+# {
+# char c;
+# short s;
+# int i;
+# long l;
+# float f;
+# double d;
+# };
+#
+# s1 S1;
+#
+# int func (s1 *p)
+# {
+# return p->i;
+# }
+#
+# int main()
+# {
+# return func (&S1);
+# }
+#
+# g++ -gdwarf-4 -g -fdebug-types-section
+
+# echo 'struct A{ struct B {} x;};A a; A::B b;int main(){return 0;}' \
+# | g++ -x c++ -g -fdebug-types-section -o testfile-debug-types -
+
+testfiles testfile59 testfile-debug-types
+
+testrun_compare ${abs_builddir}/typeiter testfile59 <<\EOF
+ok
+EOF
+
+testrun_compare ${abs_builddir}/typeiter2 testfile59 <<\EOF
+ok s1 [25]
+EOF
+
+testrun_compare ${abs_builddir}/typeiter2 testfile-debug-types <<\EOF
+ok A [68]
+ok B [38]
+EOF
+
+exit 0
diff --git a/tests/run-unstrip-M.sh b/tests/run-unstrip-M.sh
new file mode 100755
index 0000000..614a8aa
--- /dev/null
+++ b/tests/run-unstrip-M.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2013 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
+
+# Linux /proc/PID/maps file with some non-file entries (and fake exe/lib names).
+tempfiles testmaps
+cat > testmaps <<EOF
+00400000-024aa000 r-xp 00000000 08:02 159659 /opt/TestBins/bin/arwijn
+026aa000-026b2000 rwxp 020aa000 08:02 159659 /opt/TestBins/bin/arwijn
+026b2000-026bf000 rwxp 00000000 00:00 0
+0335a000-03e6f000 rwxp 00000000 00:00 0 [heap]
+2b7b38282000-2b7b38302000 rwxs 00000000 00:06 493872 socket:[493872]
+2b7b38302000-2b7b38312000 rwxs 00000000 00:06 493872 socket:[493872]
+2b7b38312000-2b7b38b12000 r-xs 00000000 00:06 493872 socket:[493872]
+2b7b38b12000-2b7b38b22000 rwxs 00000000 00:06 493872 socket:[493872]
+2b7b38b22000-2b7b39322000 rwxs 00000000 00:06 493872 socket:[493872]
+2b7b4439f000-2b7b45ea1000 rwxp 00000000 00:00 0
+7f31e7d9f000-7f31e7f29000 r-xp 00000000 fd:00 917531 /lib64/libc-1.13.so
+7f31e7f29000-7f31e8128000 ---p 0018a000 fd:00 917531 /lib64/libc-1.13.so
+7f31e8128000-7f31e812c000 r--p 00189000 fd:00 917531 /lib64/libc-1.13.so
+7f31e812c000-7f31e812d000 rw-p 0018d000 fd:00 917531 /lib64/libc-1.13.so
+7f31e812d000-7f31e8132000 rw-p 00000000 00:00 0
+7f31ea3f9000-7f31ea3fc000 rw-s 00000000 00:09 3744 anon_inode:kvm-vcpu
+7f31ea3fc000-7f31ea3ff000 rw-s 00000000 00:09 3744 anon_inode:kvm-vcpu
+7f31ea400000-7f31ea402000 rw-p 00000000 00:00 0
+7fff26cf7000-7fff26d0c000 rwxp 00000000 00:00 0 [stack]
+7fff26dff000-7fff26e00000 r-xp 00000000 00:00 0 [vdso]
+ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
+EOF
+
+testrun_compare ${abs_top_builddir}/src/unstrip -n -M testmaps <<\EOF
+0x400000+0x22b2000 - - - /opt/TestBins/bin/arwijn
+0x7f31e7d9f000+0x38e000 - - - /lib64/libc-1.13.so
+EOF
+
+exit 0
diff --git a/tests/run-unstrip-n.sh b/tests/run-unstrip-n.sh
new file mode 100755
index 0000000..37cbd60
--- /dev/null
+++ b/tests/run-unstrip-n.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+
+# https://bugzilla.redhat.com/show_bug.cgi?id=805447
+# eu-unstrip emits garbage for librt.so.1
+#
+# #include <stdio.h>
+# #include <sys/mman.h>
+#
+# int main(int argc, char **argv)
+# {
+# // Yes, this crashes... That is the point.
+# return shm_open(argv[1], 0, 0);
+# }
+#
+# gcc -m32 -o rt_crash -lrt rt_crash.c
+
+testfiles testcore-rtlib testcore-rtlib-ppc
+
+testrun_compare ${abs_top_builddir}/src/unstrip -n --core=testcore-rtlib <<\EOF
+0x8048000+0x2000 f1c600bc36cb91bf01f9a63a634ecb79aa4c3199@0x8048178 . - [exe]
+0xf75e9000+0x1a000 29a103420abe341e92072fb14274e250e4072148@0xf75e9164 - - libpthread.so.0
+0xf7603000+0x1b0000 0b9bf374699e141e5dfc14757ff42b8c2373b4de@0xf7603184 - - libc.so.6
+0xf77b3000+0x9000 c6c5b5e35ab9589d4762ac85b4bd56b1b2720e37@0xf77b3164 - - librt.so.1
+0xf77d6000+0x1000 676560b1b765cde9c2e53f134f4ee354ea894747@0xf77d6210 . - linux-gate.so.1
+0xf77d7000+0x21000 6d2cb32650054f1c176d01d48713a4a5e5e84c1a@0xf77d7124 - - ld-linux.so.2
+EOF
+
+testrun_compare ${abs_top_builddir}/src/unstrip -n --core=testcore-rtlib-ppc <<\EOF
+0x100000+0x10000 708b900b05176964512a6b0fe90c2a0c9d73d726@0x100334 . - linux-vdso32.so.1
+0xfd50000+0x30000 3f7d21508470322d2f47acddc20ab10516edba99@0xfd50164 . - librt.so.1
+0xfdb0000+0x40000 f6ee91d4c629bc7dacc10534cb30056914e7e0b5@0xfdb0164 - - libpthread.so.0
+0xfdf0000+0x1c0000 edf3dd232e09d01b90683889bd16b9406c52d4de@0xfdf0184 - - libc.so.6
+0xffb0000+0x50000 edec437a85026a1cf8cda94003706202733130c1@0xffb0124 - - ld.so.1
+0x10000000+0x20000 979b7a26747cc09bd84a42b311b5288c704baea5@0x10000174 . - [exe]
+EOF
+
+# FAIL was 0x7f67f2caf000 for test-core-lib.so .
+# /lib64/libc.so.6 and /lib64/ld-linux-x86-64.so.2 from link map
+# do not have ELF header stored in the core file.
+# ELF headers in the core file:
+# Offset VirtAddr
+# 0x014000 0x00007f67f2caf000 ./test-core-lib.so
+# 0x03a000 0x00007fff1596c000 linux-vdso.so.1
+testfiles test-core.core test-core.exec
+rm -f test-core-lib.so
+outfile=test-core.out
+testrun_out $outfile ${abs_top_builddir}/src/unstrip -n -e test-core.exec --core=test-core.core
+outfile2=test-core.out2
+remove_files="$remove_files $outfile2"
+grep -v libc.so.6 $outfile | sort >$outfile2
+diff -u $outfile2 - <<EOF
+0x400000+0x202038 - test-core.exec - test-core.exec
+0x7f67f2aaf000+0x202000 - . - /home/jkratoch/redhat/elfutils-libregr/test-core-lib.so
+0x7fff1596c000+0x1000 a9cf37f53897b5468ee018655760be61b8633d3c@0x7fff1596c340 . - linux-vdso.so.1
+EOF
+
+test_cleanup
+
+exit 0
diff --git a/tests/run-unstrip-test.sh b/tests/run-unstrip-test.sh
new file mode 100755
index 0000000..dc7d3a4
--- /dev/null
+++ b/tests/run-unstrip-test.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2007-2010 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
+
+original=${original:-testfile12}
+stripped=${stripped:-testfile17}
+debugfile=${debugfile:-${stripped}.debug}
+
+testfiles $original $stripped $debugfile
+tempfiles testfile.unstrip testfile.inplace
+
+# These are old reference output from run-test-strip6.sh, when
+# strip left the .debug file with unchanged sh_size in
+# stripped sections that shrank in the stripped file. strip
+# no longer does that, but unstrip must still handle it.
+
+testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip $stripped $debugfile
+
+testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip
+
+# Also test modifying the file in place.
+
+rm -f testfile.inplace
+cp $debugfile testfile.inplace
+chmod 644 testfile.inplace
+testrun ${abs_top_builddir}/src/unstrip $stripped testfile.inplace
+
+testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.inplace
diff --git a/tests/run-unstrip-test2.sh b/tests/run-unstrip-test2.sh
new file mode 100755
index 0000000..44074c1
--- /dev/null
+++ b/tests/run-unstrip-test2.sh
@@ -0,0 +1,5 @@
+original=testfile11
+stripped=testfile15
+debugfile=testfile15.debug
+
+. $srcdir/run-unstrip-test.sh
diff --git a/tests/run-unstrip-test3.sh b/tests/run-unstrip-test3.sh
new file mode 100755
index 0000000..5459e72
--- /dev/null
+++ b/tests/run-unstrip-test3.sh
@@ -0,0 +1,17 @@
+# Buggy binutils objdump might strip SHF_INFO_LINK from relocation sections.
+# With gcc5 we might have a .rela.plt section with that flag set.
+#
+# int main()
+# {
+# return 0;
+# }
+#
+# gcc -o testfile-info-link -g testprog.c
+# objcopy --only-keep-debug testfile-info-link testfile-info-link.debuginfo
+# eu-strip --strip-debug -o testfile-info-link.stripped testfile-info-link
+
+original=testfile-info-link
+stripped=testfile-info-link.stripped
+debugfile=testfile-info-link.debuginfo
+
+. $srcdir/run-unstrip-test.sh
diff --git a/tests/run-unstrip-test4.sh b/tests/run-unstrip-test4.sh
new file mode 100755
index 0000000..6ca5d0e
--- /dev/null
+++ b/tests/run-unstrip-test4.sh
@@ -0,0 +1,18 @@
+# Test whether unstrip can combine a stripped kernel object that has
+# limited .symtab/.strtab data, with a separate .debuginfo binary that
+# has full .symtab/.strtab data.
+#
+# This was generated as part of a Chromium OS kernel build:
+#
+# emerge-kevin chromeos-kernel-4_4
+#
+# Setup instructions:
+#
+# https://www.chromium.org/chromium-os/developer-guide
+# https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/kernel-faq
+
+original=testfile-strtab
+stripped=testfile-strtab.stripped
+debugfile=testfile-strtab.debuginfo
+
+. $srcdir/run-unstrip-test.sh
diff --git a/tests/run-varlocs-self.sh b/tests/run-varlocs-self.sh
new file mode 100755
index 0000000..54b6a8d
--- /dev/null
+++ b/tests/run-varlocs-self.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# Copyright (C) 2017 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
+
+# Make sure varlocs doesn't crash, doesn't trigger self-check/asserts
+# or leaks running under valgrind.
+testrun_on_self_quiet ${abs_top_builddir}/tests/varlocs -e
diff --git a/tests/run-varlocs.sh b/tests/run-varlocs.sh
new file mode 100755
index 0000000..9c4b313
--- /dev/null
+++ b/tests/run-varlocs.sh
@@ -0,0 +1,128 @@
+#! /bin/sh
+# Copyright (C) 2013 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 the source files testfile_const_type.c testfile_implicit_value.c
+# testfile_entry_value.c testfile_parameter_ref.c testfile_implicit_pointer.c
+# how to regenerate the test files (needs GCC 4.8+).
+
+testfiles testfile_const_type testfile_implicit_value testfile_entry_value
+testfiles testfile_parameter_ref testfile_implicit_pointer
+
+testrun_compare ${abs_top_builddir}/tests/varlocs -e testfile_const_type <<\EOF
+module 'testfile_const_type'
+[b] CU 'const_type.c'@0
+ [33] function 'f1'@80483f0
+ frame_base: {call_frame_cfa {bregx(4,4)}}
+ [4b] parameter 'd'
+ [80483f0,804841b) {fbreg(0)}
+ [57] variable 'w'
+ [80483f0,804841b) {fbreg(0), GNU_deref_type(8){long long int,signed,64@[25]}, GNU_const_type{long long int,signed,64@[25]}(8)[0000806745230100], div, GNU_convert{long long unsigned int,unsigned,64@[2c]}, stack_value}
+ [7d] function 'main'@80482f0
+ frame_base: {call_frame_cfa {bregx(4,4)}}
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/varlocs -e testfile_implicit_value <<\EOF
+module 'testfile_implicit_value'
+[b] CU 'implicit_value.c'@0
+ [25] function 'foo'@80483f0
+ frame_base: {call_frame_cfa {bregx(4,4)}}
+ [3e] variable 'a'
+ [80483f0,80483f6) {implicit_value(8){0200000000000000}, piece(8), implicit_value(8){1500000000000000}, piece(8)}
+ [86] function 'main'@80482f0
+ frame_base: {call_frame_cfa {bregx(4,4)}}
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/varlocs -e testfile_entry_value <<\EOF
+module 'testfile_entry_value'
+[b] CU 'entry_value.c'@0
+ [29] function 'foo'@400500
+ frame_base: {call_frame_cfa {bregx(7,8)}}
+ [4a] parameter 'x'
+ [400500,400504) {reg5}
+ [55] parameter 'y'
+ [400500,400504) {reg4}
+ [68] function 'bar'@400510
+ frame_base: {call_frame_cfa {bregx(7,8)}}
+ [89] parameter 'x'
+ [400510,40051c) {reg5}
+ [40051c,40052b) {reg6}
+ [40052b,400531) {GNU_entry_value(1) {reg5}, stack_value}
+ [96] parameter 'y'
+ [400510,40051c) {reg4}
+ [40051c,40052a) {reg3}
+ [40052a,400531) {GNU_entry_value(1) {reg4}, stack_value}
+ [a3] variable 'z'
+ [400524,400528) {reg0}
+ [400528,400529) {reg12}
+ [400529,40052e) {breg0(0), breg12(0), plus, stack_value}
+ [40052e,400531) {reg0}
+ [e9] function 'main'@400400
+ frame_base: {call_frame_cfa {bregx(7,8)}}
+ [10a] parameter 'argc'
+ [400400,400406) {reg5}
+ [400406,40040a) {breg5(-1), stack_value}
+ [40040a,40040b) {GNU_entry_value(1) {reg5}, stack_value}
+ [119] parameter 'argv'
+ [400400,400403) {reg4}
+ [400403,40040b) {GNU_entry_value(1) {reg4}, stack_value}
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/varlocs -e testfile_parameter_ref <<\EOF
+module 'testfile_parameter_ref'
+[b] CU 'parameter_ref.c'@0
+ [77] function 'foo'@400510
+ frame_base: {call_frame_cfa {bregx(7,8)}}
+ [92] parameter 'x'
+ [400510,400523) {reg5}
+ [99] parameter 'y'
+ [400510,400523) {GNU_parameter_ref[42], stack_value}
+ [a5] variable 'a'
+ [400510,400523) {breg5(0), lit1, shl, stack_value}
+ [b0] variable 'b'
+ [400510,400523) {GNU_parameter_ref[42], lit1, shl, stack_value}
+ [be] variable 'c'
+ <constant value>
+ [c4] parameter 'z'
+ <constant value>
+ [cb] function 'main'@400400
+ frame_base: {call_frame_cfa {bregx(7,8)}}
+ [ec] parameter 'x'
+ [400400,400408) {reg5}
+ [400408,400421) {reg3}
+ [400421,400423) {GNU_entry_value(1) {reg5}, stack_value}
+ [f9] parameter 'argv'
+ [400400,400408) {reg4}
+ [400408,400423) {GNU_entry_value(1) {reg4}, stack_value}
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/varlocs -e testfile_implicit_pointer <<\EOF
+module 'testfile_implicit_pointer'
+[b] CU 'implicit_pointer.c'@0
+ [29] function 'foo'@400500
+ frame_base: {call_frame_cfa {bregx(7,8)}}
+ [4a] parameter 'i'
+ [400500,400503) {reg5}
+ [55] variable 'p'
+ [400500,400503) {GNU_implicit_pointer([4a],0) {reg5}}
+ [73] function 'main'@400400
+ frame_base: {call_frame_cfa {bregx(7,8)}}
+EOF
+
+
+exit 0
diff --git a/tests/run-zstrptr.sh b/tests/run-zstrptr.sh
new file mode 100755
index 0000000..254dcd8
--- /dev/null
+++ b/tests/run-zstrptr.sh
@@ -0,0 +1,167 @@
+#! /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
+
+# A random 32bit and 64bit testfile
+testfiles testfile testfile10
+
+testrun_compare ${abs_top_builddir}/tests/zstrptr testfile <<\EOF
+Strings in section 32 (compressed):
+[0] ''
+[1] '.symtab'
+[9] '.strtab'
+[11] '.shstrtab'
+[1b] '.interp'
+[23] '.note.ABI-tag'
+[31] '.hash'
+[37] '.dynsym'
+[3f] '.dynstr'
+[47] '.gnu.version'
+[54] '.gnu.version_r'
+[63] '.rel.got'
+[6c] '.rel.plt'
+[75] '.init'
+[7b] '.plt'
+[80] '.text'
+[86] '.fini'
+[8c] '.rodata'
+[94] '.data'
+[9a] '.eh_frame'
+[a4] '.ctors'
+[ab] '.dtors'
+[b2] '.got'
+[b7] '.dynamic'
+[c0] '.sbss'
+[c6] '.bss'
+[cb] '.stab'
+[d1] '.stabstr'
+[da] '.comment'
+[e3] '.debug_aranges'
+[f2] '.debug_pubnames'
+[102] '.debug_info'
+[10e] '.debug_abbrev'
+[11c] '.debug_line'
+[128] '.note'
+Strings in section 32 (uncompressed):
+[0] ''
+[1] '.symtab'
+[9] '.strtab'
+[11] '.shstrtab'
+[1b] '.interp'
+[23] '.note.ABI-tag'
+[31] '.hash'
+[37] '.dynsym'
+[3f] '.dynstr'
+[47] '.gnu.version'
+[54] '.gnu.version_r'
+[63] '.rel.got'
+[6c] '.rel.plt'
+[75] '.init'
+[7b] '.plt'
+[80] '.text'
+[86] '.fini'
+[8c] '.rodata'
+[94] '.data'
+[9a] '.eh_frame'
+[a4] '.ctors'
+[ab] '.dtors'
+[b2] '.got'
+[b7] '.dynamic'
+[c0] '.sbss'
+[c6] '.bss'
+[cb] '.stab'
+[d1] '.stabstr'
+[da] '.comment'
+[e3] '.debug_aranges'
+[f2] '.debug_pubnames'
+[102] '.debug_info'
+[10e] '.debug_abbrev'
+[11c] '.debug_line'
+[128] '.note'
+EOF
+
+testrun_compare ${abs_top_builddir}/tests/zstrptr testfile10 <<\EOF
+Strings in section 30 (compressed):
+[0] ''
+[1] '.symtab'
+[9] '.strtab'
+[11] '.shstrtab'
+[1b] '.hash'
+[21] '.dynsym'
+[29] '.dynstr'
+[31] '.gnu.version'
+[3e] '.gnu.version_r'
+[4d] '.rela.dyn'
+[57] '.init'
+[5d] '.text'
+[63] '.fini'
+[69] '.eh_frame'
+[73] '.data'
+[79] '.dynamic'
+[82] '.ctors'
+[89] '.dtors'
+[90] '.jcr'
+[95] '.plt'
+[9a] '.got'
+[9f] '.sdata'
+[a6] '.sbss'
+[ac] '.bss'
+[b1] '.comment'
+[ba] '.debug_aranges'
+[c9] '.debug_pubnames'
+[d9] '.debug_abbrev'
+[e7] '.debug_line'
+[f3] '.debug_frame'
+[100] '.debug_str'
+[10b] '.rela.debug_info'
+Strings in section 30 (uncompressed):
+[0] ''
+[1] '.symtab'
+[9] '.strtab'
+[11] '.shstrtab'
+[1b] '.hash'
+[21] '.dynsym'
+[29] '.dynstr'
+[31] '.gnu.version'
+[3e] '.gnu.version_r'
+[4d] '.rela.dyn'
+[57] '.init'
+[5d] '.text'
+[63] '.fini'
+[69] '.eh_frame'
+[73] '.data'
+[79] '.dynamic'
+[82] '.ctors'
+[89] '.dtors'
+[90] '.jcr'
+[95] '.plt'
+[9a] '.got'
+[9f] '.sdata'
+[a6] '.sbss'
+[ac] '.bss'
+[b1] '.comment'
+[ba] '.debug_aranges'
+[c9] '.debug_pubnames'
+[d9] '.debug_abbrev'
+[e7] '.debug_line'
+[f3] '.debug_frame'
+[100] '.debug_str'
+[10b] '.rela.debug_info'
+EOF
+
+exit 0
diff --git a/tests/saridx.c b/tests/saridx.c
new file mode 100644
index 0000000..8a450d8
--- /dev/null
+++ b/tests/saridx.c
@@ -0,0 +1,257 @@
+/* Copyright (C) 1998, 1999, 2000, 2002 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1998.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <error.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+
+static const char *machines[] =
+{
+#define MACHINE(name) [name] = #name
+ MACHINE (EM_NONE),
+ MACHINE (EM_M32),
+ MACHINE (EM_SPARC),
+ MACHINE (EM_386),
+ MACHINE (EM_68K),
+ MACHINE (EM_88K),
+ MACHINE (EM_860),
+ MACHINE (EM_MIPS),
+ MACHINE (EM_MIPS_RS3_LE),
+ MACHINE (EM_PARISC),
+ MACHINE (EM_VPP500),
+ MACHINE (EM_SPARC32PLUS),
+ MACHINE (EM_960),
+ MACHINE (EM_PPC),
+ MACHINE (EM_PPC64),
+ MACHINE (EM_V800),
+ MACHINE (EM_FR20),
+ MACHINE (EM_RH32),
+ MACHINE (EM_RCE),
+ MACHINE (EM_ARM),
+ MACHINE (EM_FAKE_ALPHA),
+ MACHINE (EM_SH),
+ MACHINE (EM_SPARCV9),
+ MACHINE (EM_TRICORE),
+ MACHINE (EM_ARC),
+ MACHINE (EM_H8_300),
+ MACHINE (EM_H8_300H),
+ MACHINE (EM_H8S),
+ MACHINE (EM_H8_500),
+ MACHINE (EM_IA_64),
+ MACHINE (EM_MIPS_X),
+ MACHINE (EM_COLDFIRE),
+ MACHINE (EM_68HC12),
+ MACHINE (EM_MMA),
+ MACHINE (EM_PCP),
+ MACHINE (EM_NCPU),
+ MACHINE (EM_NDR1),
+ MACHINE (EM_STARCORE),
+ MACHINE (EM_ME16),
+ MACHINE (EM_ST100),
+ MACHINE (EM_TINYJ),
+ MACHINE (EM_FX66),
+ MACHINE (EM_ST9PLUS),
+ MACHINE (EM_ST7),
+ MACHINE (EM_68HC16),
+ MACHINE (EM_68HC11),
+ MACHINE (EM_68HC08),
+ MACHINE (EM_68HC05),
+ MACHINE (EM_SVX),
+ MACHINE (EM_ST19),
+ MACHINE (EM_VAX)
+};
+
+
+int
+main (int argc, char *argv[])
+{
+ int fd;
+ Elf *elf;
+ Elf_Cmd cmd;
+ size_t n;
+ int arg = 1;
+ int verbose = 0;
+
+ /* Recognize optional verbosity flag. */
+ if (arg < argc && strcmp (argv[arg], "-v") == 0)
+ {
+ verbose = 1;
+ ++arg;
+ }
+
+ /* Any more arguments available. */
+ if (arg >= argc)
+ error (EXIT_FAILURE, 0, "No input file given");
+
+ /* Open the input file. */
+ fd = open (argv[arg], O_RDONLY);
+ if (fd == -1)
+ {
+ perror ("cannot open input file");
+ exit (1);
+ }
+
+ /* Set the ELF version we are using here. */
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ {
+ puts ("ELF library too old");
+ exit (1);
+ }
+
+ /* Start reading the file. */
+ cmd = ELF_C_READ;
+ elf = elf_begin (fd, cmd, NULL);
+ if (elf == NULL)
+ {
+ printf ("elf_begin: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* If it is no archive punt. */
+ if (elf_kind (elf) != ELF_K_AR)
+ {
+ printf ("%s is not an archive\n", argv[1]);
+ exit (1);
+ }
+
+ if (verbose)
+ {
+ /* The verbose variant. We print a lot of information. */
+ Elf *subelf;
+ char buf[100];
+ time_t t;
+
+ /* Get the elements of the archive one after the other. */
+ while ((subelf = elf_begin (fd, cmd, elf)) != NULL)
+ {
+ /* The the header for this element. */
+ Elf_Arhdr *arhdr = elf_getarhdr (subelf);
+
+ if (arhdr == NULL)
+ {
+ printf ("cannot get arhdr: %s\n", elf_errmsg (-1));
+ break;
+ }
+
+ switch (elf_kind (subelf))
+ {
+ case ELF_K_ELF:
+ fputs ("ELF file:\n", stdout);
+ break;
+
+ case ELF_K_AR:
+ fputs ("archive:\n", stdout);
+ break;
+
+ default:
+ fputs ("unknown file:\n", stdout);
+ break;
+ }
+
+ /* Print general information. */
+ t = arhdr->ar_date;
+ strftime (buf, sizeof buf, "%Y-%m-%dT%H:%M:%S%z", gmtime (&t));
+ printf (" name : \"%s\"\n"
+ " time : %s\n"
+ " uid : %ld\n"
+ " gid : %ld\n"
+ " mode : %o\n"
+ " size : %ld\n"
+ " rawname : \"%s\"\n",
+ arhdr->ar_name,
+ buf,
+ (long int) arhdr->ar_uid,
+ (long int) arhdr->ar_gid,
+ arhdr->ar_mode,
+ (long int) arhdr->ar_size,
+ arhdr->ar_rawname);
+
+ /* For ELF files we can provide some more information. */
+ if (elf_kind (subelf) == ELF_K_ELF)
+ {
+ GElf_Ehdr ehdr;
+
+ /* Get the ELF header. */
+ if (gelf_getehdr (subelf, &ehdr) == NULL)
+ printf (" *** cannot get ELF header: %s\n", elf_errmsg (-1));
+ else
+ {
+ printf (" binary class : %s\n",
+ ehdr.e_ident[EI_CLASS] == ELFCLASS32
+ ? "ELFCLASS32" : "ELFCLASS64");
+ printf (" data encoding: %s\n",
+ ehdr.e_ident[EI_DATA] == ELFDATA2LSB
+ ? "ELFDATA2LSB" : "ELFDATA2MSB");
+ printf (" binary type : %s\n",
+ ehdr.e_type == ET_REL
+ ? "relocatable"
+ : (ehdr.e_type == ET_EXEC
+ ? "executable"
+ : (ehdr.e_type == ET_DYN
+ ? "dynamic"
+ : "core file")));
+ printf (" machine : %s\n",
+ (ehdr.e_machine >= (sizeof (machines)
+ / sizeof (machines[0]))
+ || machines[ehdr.e_machine] == NULL)
+ ? "???"
+ : machines[ehdr.e_machine]);
+ }
+ }
+
+ /* Get next archive element. */
+ cmd = elf_next (subelf);
+ if (elf_end (subelf) != 0)
+ printf ("error while freeing sub-ELF descriptor: %s\n",
+ elf_errmsg (-1));
+ }
+ }
+ else
+ {
+ /* The simple version. Only print a bit of information. */
+ Elf_Arsym *arsym = elf_getarsym (elf, &n);
+
+ if (n == 0)
+ printf ("no symbol table in archive: %s\n", elf_errmsg (-1));
+ else
+ {
+ --n;
+
+ while (n-- > 0)
+ printf ("name = \"%s\", offset = %ld, hash = %lx\n",
+ arsym[n].as_name, (long int) arsym[n].as_off,
+ arsym[n].as_hash);
+ }
+ }
+
+ /* Free the ELF handle. */
+ if (elf_end (elf) != 0)
+ printf ("error while freeing ELF descriptor: %s\n", elf_errmsg (-1));
+
+ /* Close the underlying file. */
+ close (fd);
+
+ return 0;
+}
diff --git a/tests/scnnames.c b/tests/scnnames.c
new file mode 100644
index 0000000..7f26825
--- /dev/null
+++ b/tests/scnnames.c
@@ -0,0 +1,91 @@
+/* Copyright (C) 1998, 1999, 2000, 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1998.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+ Elf *elf;
+ int fd;
+ GElf_Ehdr ehdr;
+ size_t strndx;
+ Elf_Scn *scn;
+
+ if (argc < 2)
+ {
+ puts ("missing parameter");
+ exit (1);
+ }
+
+ fd = open (argv[1], O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open \"%s\": %s\n", argv[1], strerror (errno));
+ exit (1);
+ }
+
+ elf_version (EV_CURRENT);
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot open ELF file: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_kind (elf) != ELF_K_ELF)
+ {
+ printf ("\"%s\" is not an ELF file\n", argv[1]);
+ exit (1);
+ }
+
+ if (gelf_getehdr (elf, &ehdr) == NULL)
+ {
+ printf ("cannot get the ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ strndx = ehdr.e_shstrndx;
+
+ scn = NULL;
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ char *name = NULL;
+ GElf_Shdr shdr;
+
+ if (gelf_getshdr (scn, &shdr) != NULL)
+ name = elf_strptr (elf, strndx, (size_t) shdr.sh_name);
+
+ printf ("section: `%s'\n", name);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("error while freeing ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ return 0;
+}
diff --git a/tests/sectiondump.c b/tests/sectiondump.c
new file mode 100644
index 0000000..3033fed
--- /dev/null
+++ b/tests/sectiondump.c
@@ -0,0 +1,182 @@
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1998.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+/* Prototypes for local functions. */
+static int handle_section (Elf *elf, Elf_Scn *scn);
+static void print_bytes (Elf_Data *data);
+static void print_symtab (Elf *elf, Elf_Data *data);
+
+
+int
+main (int argc, char *argv[])
+{
+ Elf *elf;
+ int fd;
+ int cnt;
+
+ if (argc <= 1)
+ exit (1);
+
+ /* Open the test file. This is given as the first parameter to the
+ program. */
+ fd = open (argv[1], O_RDONLY);
+ if (fd == -1)
+ error (EXIT_FAILURE, errno, "cannot open input file `%s'", argv[1]);
+
+ /* Set the library versio we expect. */
+ elf_version (EV_CURRENT);
+
+ /* Create the ELF descriptor. */
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ error (EXIT_FAILURE, 0, "cannot create ELF descriptor: %s",
+ elf_errmsg (0));
+
+ /* Now proces all the sections mentioned in the rest of the command line. */
+ for (cnt = 2; cnt < argc; ++cnt)
+ if (handle_section (elf, elf_getscn (elf, atoi (argv[cnt]))) != 0)
+ /* When we encounter an error stop immediately. */
+ error (EXIT_FAILURE, 0, "while processing section %d: %s", cnt,
+ elf_errmsg (0));
+
+ /* Close the descriptor. */
+ if (elf_end (elf) != 0)
+ error (EXIT_FAILURE, 0, "failure while closing ELF descriptor: %s",
+ elf_errmsg (0));
+
+ return 0;
+}
+
+
+static int
+handle_section (Elf *elf, Elf_Scn *scn)
+{
+ GElf_Ehdr *ehdr;
+ GElf_Ehdr ehdr_mem;
+ GElf_Shdr *shdr;
+ GElf_Shdr shdr_mem;
+ Elf_Data *data;
+
+ /* First get the ELF and section header. */
+ ehdr = gelf_getehdr (elf, &ehdr_mem);
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ if (ehdr == NULL || shdr == NULL)
+ return 1;
+
+ /* Print the information from the ELF section header. */
+ printf ("name = %s\n"
+ "type = %" PRId32 "\n"
+ "flags = %" PRIx64 "\n"
+ "addr = %" PRIx64 "\n"
+ "offset = %" PRIx64 "\n"
+ "size = %" PRId64 "\n"
+ "link = %" PRId32 "\n"
+ "info = %" PRIx32 "\n"
+ "addralign = %" PRIx64 "\n"
+ "entsize = %" PRId64 "\n",
+ elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
+ shdr->sh_type,
+ shdr->sh_flags,
+ shdr->sh_addr,
+ shdr->sh_offset,
+ shdr->sh_size,
+ shdr->sh_link,
+ shdr->sh_info,
+ shdr->sh_addralign,
+ shdr->sh_entsize);
+
+ /* Get the section data now. */
+ data = elf_getdata (scn, NULL);
+ if (data == NULL)
+ return 1;
+
+ /* Now proces the different section types accordingly. */
+ switch (shdr->sh_type)
+ {
+ case SHT_SYMTAB:
+ print_symtab (elf, data);
+ break;
+
+ case SHT_PROGBITS:
+ default:
+ print_bytes (data);
+ break;
+ }
+
+ /* Separate form the next section. */
+ puts ("");
+
+ /* All done correctly. */
+ return 0;
+}
+
+
+static void
+print_bytes (Elf_Data *data)
+{
+ size_t size = data->d_size;
+ off_t offset = data->d_off;
+ unsigned char *buf = (unsigned char *) data->d_buf;
+ size_t cnt;
+
+ for (cnt = 0; cnt < size; cnt += 16)
+ {
+ size_t inner;
+
+ printf ("%*zx: ", sizeof (size_t) == 4 ? 8 : 16, (size_t) offset + cnt);
+
+ for (inner = 0; inner < 16 && cnt + inner < size; ++inner)
+ printf (" %02hhx", buf[cnt + inner]);
+
+ puts ("");
+ }
+}
+
+
+static void
+print_symtab (Elf *elf, Elf_Data *data)
+{
+ int class = gelf_getclass (elf);
+ size_t nsym = data->d_size / (class == ELFCLASS32
+ ? sizeof (Elf32_Sym) : sizeof (Elf64_Sym));
+ size_t cnt;
+
+ for (cnt = 0; cnt < nsym; ++cnt)
+ {
+ GElf_Sym sym_mem;
+ GElf_Sym *sym = gelf_getsym (data, cnt, &sym_mem);
+
+ printf ("%5zu: %*" PRIx64 " %6" PRIx64 " %4d\n",
+ cnt,
+ class == ELFCLASS32 ? 8 : 16,
+ sym->st_value,
+ sym->st_size,
+ GELF_ST_TYPE (sym->st_info));
+ }
+}
diff --git a/tests/show-abbrev.c b/tests/show-abbrev.c
new file mode 100644
index 0000000..b0af029
--- /dev/null
+++ b/tests/show-abbrev.c
@@ -0,0 +1,131 @@
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1998.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <fcntl.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dw)
+#include <stdio.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int cnt;
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ int fd = open (argv[cnt], O_RDONLY);
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ {
+ printf ("%s not usable: %s\n", argv[cnt], dwarf_errmsg (-1));
+ close (fd);
+ continue;
+ }
+
+ Dwarf_Off cuoff = 0;
+ Dwarf_Off old_cuoff = 0;
+ size_t hsize;
+ while (dwarf_nextcu (dbg, cuoff, &cuoff, &hsize, NULL, NULL, NULL) == 0)
+ {
+ /* Get the DIE for the CU. */
+ Dwarf_Die die;
+ if (dwarf_offdie (dbg, old_cuoff + hsize, &die) == NULL)
+ /* Something went wrong. */
+ break;
+
+ Dwarf_Off offset = 0;
+
+ while (1)
+ {
+ size_t length;
+ Dwarf_Abbrev *abbrev = dwarf_getabbrev (&die, offset, &length);
+ if (abbrev == NULL || abbrev == DWARF_END_ABBREV)
+ /* End of the list. */
+ break;
+
+ unsigned tag = dwarf_getabbrevtag (abbrev);
+ if (tag == 0)
+ {
+ printf ("dwarf_getabbrevtag at offset %llu returned error: %s\n",
+ (unsigned long long int) offset,
+ dwarf_errmsg (-1));
+ break;
+ }
+
+ unsigned code = dwarf_getabbrevcode (abbrev);
+ if (code == 0)
+ {
+ printf ("dwarf_getabbrevcode at offset %llu returned error: %s\n",
+ (unsigned long long int) offset,
+ dwarf_errmsg (-1));
+ break;
+ }
+
+ int children = dwarf_abbrevhaschildren (abbrev);
+ if (children < 0)
+ {
+ printf ("dwarf_abbrevhaschildren at offset %llu returned error: %s\n",
+ (unsigned long long int) offset,
+ dwarf_errmsg (-1));
+ break;
+ }
+
+ printf ("abbrev[%llu]: code = %u, tag = %u, children = %d\n",
+ (unsigned long long int) offset, code, tag, children);
+
+ size_t attrcnt;
+ if (dwarf_getattrcnt (abbrev, &attrcnt) != 0)
+ {
+ printf ("dwarf_getattrcnt at offset %llu returned error: %s\n",
+ (unsigned long long int) offset,
+ dwarf_errmsg (-1));
+ break;
+ }
+
+ unsigned int attr_num;
+ unsigned int attr_form;
+ Dwarf_Off aboffset;
+ size_t j;
+ for (j = 0; j < attrcnt; ++j)
+ if (dwarf_getabbrevattr (abbrev, j, &attr_num, &attr_form,
+ &aboffset))
+ printf ("dwarf_getabbrevattr for abbrev[%llu] and index %zu failed\n",
+ (unsigned long long int) offset, j);
+ else
+ printf ("abbrev[%llu]: attr[%zu]: code = %u, form = %u, offset = %" PRIu64 "\n",
+ (unsigned long long int) offset, j, attr_num,
+ attr_form, (uint64_t) aboffset);
+
+ offset += length;
+ }
+
+ old_cuoff = cuoff;
+ }
+
+ if (dwarf_end (dbg) != 0)
+ printf ("dwarf_end failed for %s: %s\n", argv[cnt],
+ dwarf_errmsg (-1));
+
+ close (fd);
+ }
+
+ return 0;
+}
diff --git a/tests/show-die-info.c b/tests/show-die-info.c
new file mode 100644
index 0000000..34e27a3
--- /dev/null
+++ b/tests/show-die-info.c
@@ -0,0 +1,358 @@
+/* Copyright (C) 1998-2002, 2004, 2006, 2012, 2015 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1998.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <dwarf.h>
+#include <inttypes.h>
+#include <libelf.h>
+#include ELFUTILS_HEADER(dw)
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "../libdw/known-dwarf.h"
+
+static const char *
+dwarf_tag_string (unsigned int tag)
+{
+ switch (tag)
+ {
+#define DWARF_ONE_KNOWN_DW_TAG(NAME, CODE) case CODE: return #NAME;
+ DWARF_ALL_KNOWN_DW_TAG
+#undef DWARF_ONE_KNOWN_DW_TAG
+ default:
+ return NULL;
+ }
+}
+
+static const char *
+dwarf_attr_string (unsigned int attrnum)
+{
+ switch (attrnum)
+ {
+#define DWARF_ONE_KNOWN_DW_AT(NAME, CODE) case CODE: return #NAME;
+ DWARF_ALL_KNOWN_DW_AT
+#undef DWARF_ONE_KNOWN_DW_AT
+ default:
+ return NULL;
+ }
+}
+
+
+void
+handle (Dwarf *dbg, Dwarf_Die *die, int n)
+{
+ Dwarf_Die child;
+ unsigned int tag;
+ const char *str;
+ char buf[30];
+ const char *name;
+ Dwarf_Off off;
+ Dwarf_Off cuoff;
+ size_t cnt;
+ Dwarf_Addr addr;
+ int i;
+
+ tag = dwarf_tag (die);
+ if (tag != DW_TAG_invalid)
+ {
+ str = dwarf_tag_string (tag);
+ if (str == NULL)
+ {
+ snprintf (buf, sizeof buf, "%#x", tag);
+ str = buf;
+ }
+ }
+ else
+ str = "* NO TAG *";
+
+ name = dwarf_diename (die);
+ if (name == 0)
+ name = "* NO NAME *";
+
+ off = dwarf_dieoffset (die);
+ cuoff = dwarf_cuoffset (die);
+
+ printf ("%*sDW_TAG_%s\n", n * 5, "", str);
+ printf ("%*s Name : %s\n", n * 5, "", name);
+ printf ("%*s Offset : %lld\n", n * 5, "", (long long int) off);
+ printf ("%*s CU offset : %lld\n", n * 5, "", (long long int) cuoff);
+
+ printf ("%*s Attrs :", n * 5, "");
+ for (cnt = 0; cnt < 0xffff; ++cnt)
+ if (dwarf_hasattr (die, cnt))
+ printf (" %s", dwarf_attr_string (cnt));
+ puts ("");
+
+ if (dwarf_hasattr (die, DW_AT_low_pc) && dwarf_lowpc (die, &addr) == 0)
+ {
+ Dwarf_Attribute attr;
+ Dwarf_Addr addr2;
+ printf ("%*s low PC : %#llx\n",
+ n * 5, "", (unsigned long long int) addr);
+
+ if (dwarf_attr (die, DW_AT_low_pc, &attr) == NULL
+ || dwarf_formaddr (&attr, &addr2) != 0
+ || addr != addr2)
+ puts ("************* DW_AT_low_pc verify failed ************");
+ else if (! dwarf_hasform (&attr, DW_FORM_addr))
+ puts ("************* DW_AT_low_pc form failed ************");
+ else if (dwarf_whatform (&attr) != DW_FORM_addr)
+ puts ("************* DW_AT_low_pc form (2) failed ************");
+ else if (dwarf_whatattr (&attr) != DW_AT_low_pc)
+ puts ("************* DW_AT_low_pc attr failed ************");
+ }
+ if (dwarf_hasattr (die, DW_AT_high_pc) && dwarf_highpc (die, &addr) == 0)
+ {
+ Dwarf_Attribute attr;
+ Dwarf_Addr addr2;
+ printf ("%*s high PC : %#llx\n",
+ n * 5, "", (unsigned long long int) addr);
+ if (dwarf_attr (die, DW_AT_high_pc, &attr) == NULL
+ || dwarf_formaddr (&attr, &addr2) != 0
+ || addr != addr2)
+ puts ("************* DW_AT_high_pc verify failed ************");
+ else if (! dwarf_hasform (&attr, DW_FORM_addr))
+ puts ("************* DW_AT_high_pc form failed ************");
+ else if (dwarf_whatform (&attr) != DW_FORM_addr)
+ puts ("************* DW_AT_high_pc form (2) failed ************");
+ else if (dwarf_whatattr (&attr) != DW_AT_high_pc)
+ puts ("************* DW_AT_high_pc attr failed ************");
+ }
+
+ if (dwarf_hasattr (die, DW_AT_byte_size) && (i = dwarf_bytesize (die)) != -1)
+ {
+ Dwarf_Attribute attr;
+ Dwarf_Word u2;
+ unsigned int u;
+ printf ("%*s byte size : %d\n", n * 5, "", i);
+ if (dwarf_attr (die, DW_AT_byte_size, &attr) == NULL
+ || dwarf_formudata (&attr, &u2) != 0
+ || i != (int) u2)
+ puts ("************* DW_AT_byte_size verify failed ************");
+ else if (! dwarf_hasform (&attr, DW_FORM_data1)
+ && ! dwarf_hasform (&attr, DW_FORM_data2)
+ && ! dwarf_hasform (&attr, DW_FORM_data4)
+ && ! dwarf_hasform (&attr, DW_FORM_data8)
+ && ! dwarf_hasform (&attr, DW_FORM_sdata)
+ && ! dwarf_hasform (&attr, DW_FORM_udata))
+ puts ("************* DW_AT_byte_size form failed ************");
+ else if ((u = dwarf_whatform (&attr)) == 0
+ || (u != DW_FORM_data1
+ && u != DW_FORM_data2
+ && u != DW_FORM_data4
+ && u != DW_FORM_data8
+ && u != DW_FORM_sdata
+ && u != DW_FORM_udata))
+ puts ("************* DW_AT_byte_size form (2) failed ************");
+ else if (dwarf_whatattr (&attr) != DW_AT_byte_size)
+ puts ("************* DW_AT_byte_size attr failed ************");
+ }
+ if (dwarf_hasattr (die, DW_AT_bit_size) && (i = dwarf_bitsize (die)) != -1)
+ {
+ Dwarf_Attribute attr;
+ Dwarf_Word u2;
+ unsigned int u;
+ printf ("%*s bit size : %d\n", n * 5, "", i);
+ if (dwarf_attr (die, DW_AT_bit_size, &attr) == NULL
+ || dwarf_formudata (&attr, &u2) != 0
+ || i != (int) u2)
+ puts ("************* DW_AT_bit_size test failed ************");
+ else if (! dwarf_hasform (&attr, DW_FORM_data1)
+ && ! dwarf_hasform (&attr, DW_FORM_data2)
+ && ! dwarf_hasform (&attr, DW_FORM_data4)
+ && ! dwarf_hasform (&attr, DW_FORM_data8)
+ && ! dwarf_hasform (&attr, DW_FORM_sdata)
+ && ! dwarf_hasform (&attr, DW_FORM_udata))
+ puts ("************* DW_AT_bit_size form failed ************");
+ else if ((u = dwarf_whatform (&attr)) == 0
+ || (u != DW_FORM_data1
+ && u != DW_FORM_data2
+ && u != DW_FORM_data4
+ && u != DW_FORM_data8
+ && u != DW_FORM_sdata
+ && u != DW_FORM_udata))
+ puts ("************* DW_AT_bit_size form (2) failed ************");
+ else if (dwarf_whatattr (&attr) != DW_AT_bit_size)
+ puts ("************* DW_AT_bit_size attr failed ************");
+ }
+ if (dwarf_hasattr (die, DW_AT_bit_offset)
+ && (i = dwarf_bitoffset (die)) != -1)
+ {
+ Dwarf_Attribute attr;
+ Dwarf_Word u2;
+ unsigned int u;
+ printf ("%*s bit offset: %d\n", n * 5, "", i);
+ if (dwarf_attr (die, DW_AT_bit_offset, &attr) == NULL
+ || dwarf_formudata (&attr, &u2) != 0
+ || i != (int) u2)
+ puts ("************* DW_AT_bit_offset test failed ************");
+ else if (! dwarf_hasform (&attr, DW_FORM_data1)
+ && ! dwarf_hasform (&attr, DW_FORM_data2)
+ && ! dwarf_hasform (&attr, DW_FORM_data4)
+ && ! dwarf_hasform (&attr, DW_FORM_data8)
+ && ! dwarf_hasform (&attr, DW_FORM_sdata)
+ && ! dwarf_hasform (&attr, DW_FORM_udata))
+ puts ("************* DW_AT_bit_offset form failed ************");
+ else if ((u = dwarf_whatform (&attr)) == 0
+ || (u != DW_FORM_data1
+ && u != DW_FORM_data2
+ && u != DW_FORM_data4
+ && u != DW_FORM_data8
+ && u != DW_FORM_sdata
+ && u != DW_FORM_udata))
+ puts ("************* DW_AT_bit_offset form (2) failed ************");
+ else if (dwarf_whatattr (&attr) != DW_AT_bit_offset)
+ puts ("************* DW_AT_bit_offset attr failed ************");
+ }
+
+ if (dwarf_hasattr (die, DW_AT_language) && (i = dwarf_srclang (die)) != -1)
+ {
+ Dwarf_Attribute attr;
+ Dwarf_Word u2;
+ unsigned int u;
+ printf ("%*s language : %d\n", n * 5, "", i);
+ if (dwarf_attr (die, DW_AT_language, &attr) == NULL
+ || dwarf_formudata (&attr, &u2) != 0
+ || i != (int) u2)
+ puts ("************* DW_AT_language test failed ************");
+ else if (! dwarf_hasform (&attr, DW_FORM_data1)
+ && ! dwarf_hasform (&attr, DW_FORM_data2)
+ && ! dwarf_hasform (&attr, DW_FORM_data4)
+ && ! dwarf_hasform (&attr, DW_FORM_data8)
+ && ! dwarf_hasform (&attr, DW_FORM_sdata)
+ && ! dwarf_hasform (&attr, DW_FORM_udata))
+ puts ("************* DW_AT_language form failed ************");
+ else if ((u = dwarf_whatform (&attr)) == 0
+ || (u != DW_FORM_data1
+ && u != DW_FORM_data2
+ && u != DW_FORM_data4
+ && u != DW_FORM_data8
+ && u != DW_FORM_sdata
+ && u != DW_FORM_udata))
+ puts ("************* DW_AT_language form (2) failed ************");
+ else if (dwarf_whatattr (&attr) != DW_AT_language)
+ puts ("************* DW_AT_language attr failed ************");
+ }
+
+ if (dwarf_hasattr (die, DW_AT_ordering)
+ && (i = dwarf_arrayorder (die)) != -1)
+ {
+ Dwarf_Attribute attr;
+ Dwarf_Word u2;
+ unsigned int u;
+ printf ("%*s ordering : %d\n", n * 5, "", i);
+ if (dwarf_attr (die, DW_AT_ordering, &attr) == NULL
+ || dwarf_formudata (&attr, &u2) != 0
+ || i != (int) u2)
+ puts ("************* DW_AT_ordering test failed ************");
+ else if (! dwarf_hasform (&attr, DW_FORM_data1)
+ && ! dwarf_hasform (&attr, DW_FORM_data2)
+ && ! dwarf_hasform (&attr, DW_FORM_data4)
+ && ! dwarf_hasform (&attr, DW_FORM_data8)
+ && ! dwarf_hasform (&attr, DW_FORM_sdata)
+ && ! dwarf_hasform (&attr, DW_FORM_udata))
+ puts ("************* DW_AT_ordering failed ************");
+ else if ((u = dwarf_whatform (&attr)) == 0
+ || (u != DW_FORM_data1
+ && u != DW_FORM_data2
+ && u != DW_FORM_data4
+ && u != DW_FORM_data8
+ && u != DW_FORM_sdata
+ && u != DW_FORM_udata))
+ puts ("************* DW_AT_ordering form (2) failed ************");
+ else if (dwarf_whatattr (&attr) != DW_AT_ordering)
+ puts ("************* DW_AT_ordering attr failed ************");
+ }
+
+ if (dwarf_hasattr (die, DW_AT_comp_dir))
+ {
+ Dwarf_Attribute attr;
+ if (dwarf_attr (die, DW_AT_comp_dir, &attr) == NULL
+ || (name = dwarf_formstring (&attr)) == NULL)
+ puts ("************* DW_AT_comp_dir attr failed ************");
+ else
+ printf ("%*s directory : %s\n", n * 5, "", name);
+ }
+
+ if (dwarf_hasattr (die, DW_AT_producer))
+ {
+ Dwarf_Attribute attr;
+ if (dwarf_attr (die, DW_AT_producer, &attr) == NULL
+ || (name = dwarf_formstring (&attr)) == NULL)
+ puts ("************* DW_AT_comp_dir attr failed ************");
+ else
+ printf ("%*s producer : %s\n", n * 5, "", name);
+ }
+
+ if (dwarf_haschildren (die) != 0 && dwarf_child (die, &child) == 0)
+ handle (dbg, &child, n + 1);
+ if (dwarf_siblingof (die, die) == 0)
+ handle (dbg, die, n);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int cnt;
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ int fd = open (argv[cnt], O_RDONLY);
+ Dwarf *dbg;
+
+ printf ("file: %s\n", basename (argv[cnt]));
+
+ dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ {
+ printf ("%s not usable\n", argv[cnt]);
+ close (fd);
+ continue;
+ }
+
+ Dwarf_Off off = 0;
+ Dwarf_Off old_off = 0;
+ size_t hsize;
+ Dwarf_Off abbrev;
+ uint8_t addresssize;
+ uint8_t offsetsize;
+ while (dwarf_nextcu (dbg, off, &off, &hsize, &abbrev, &addresssize,
+ &offsetsize) == 0)
+ {
+ printf ("New CU: off = %llu, hsize = %zu, ab = %llu, as = %" PRIu8
+ ", os = %" PRIu8 "\n",
+ (unsigned long long int) old_off, hsize,
+ (unsigned long long int) abbrev, addresssize,
+ offsetsize);
+
+ Dwarf_Die die;
+ if (dwarf_offdie (dbg, old_off + hsize, &die) != NULL)
+ handle (dbg, &die, 1);
+
+ old_off = off;
+ }
+
+ dwarf_end (dbg);
+ close (fd);
+ }
+
+ return 0;
+}
diff --git a/tests/showptable.c b/tests/showptable.c
new file mode 100644
index 0000000..a794b0e
--- /dev/null
+++ b/tests/showptable.c
@@ -0,0 +1,139 @@
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 1998.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+ Elf *elf;
+ int fd;
+ GElf_Ehdr ehdr;
+ int cnt;
+
+ if (argc < 2)
+ {
+ puts ("missing parameter");
+ exit (1);
+ }
+
+ fd = open (argv[1], O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open \"%s\": %s\n", argv[1], strerror (errno));
+ exit (1);
+ }
+
+ elf_version (EV_CURRENT);
+
+ elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot open ELF file: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_kind (elf) != ELF_K_ELF)
+ {
+ printf ("\"%s\" is not an ELF file\n", argv[1]);
+ exit (1);
+ }
+
+ if (gelf_getehdr (elf, &ehdr) == NULL)
+ {
+ printf ("cannot get the ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ printf ("idx type %*s %*s %*s %*s %*s align flags\n",
+ gelf_getclass (elf) == ELFCLASS32 ? 9 : 17, "offset",
+ gelf_getclass (elf) == ELFCLASS32 ? 10 : 18, "vaddr",
+ gelf_getclass (elf) == ELFCLASS32 ? 10 : 18, "paddr",
+ gelf_getclass (elf) == ELFCLASS32 ? 9 : 12, "filesz",
+ gelf_getclass (elf) == ELFCLASS32 ? 9 : 12, "memsz");
+
+ for (cnt = 0; cnt < ehdr.e_phnum; ++cnt)
+ {
+ static const char *typenames[] =
+ {
+ [PT_NULL] = "NULL",
+ [PT_LOAD] = "LOAD",
+ [PT_DYNAMIC] = "DYNAMIC",
+ [PT_INTERP] = "INTERP",
+ [PT_NOTE] = "NOTE",
+ [PT_SHLIB] = "SHLIB",
+ [PT_PHDR] = "PHDR"
+ };
+ GElf_Phdr mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &mem);
+ char buf[19];
+ const char *p_type = typenames[phdr->p_type];
+
+ /* If we don't know the name of the type we use the number value. */
+ if (phdr->p_type >= PT_NUM)
+ {
+ snprintf (buf, sizeof (buf), "%x", phdr->p_type);
+ p_type = buf;
+ }
+
+ printf ("%3d %-7s %#0*llx %#0*llx %#0*llx %#0*llx %#0*llx %#6llx ",
+ cnt, p_type,
+ gelf_getclass (elf) == ELFCLASS32 ? 9 : 17,
+ (unsigned long long int) phdr->p_offset,
+ gelf_getclass (elf) == ELFCLASS32 ? 10 : 18,
+ (unsigned long long int) phdr->p_vaddr,
+ gelf_getclass (elf) == ELFCLASS32 ? 10 : 18,
+ (unsigned long long int) phdr->p_paddr,
+ gelf_getclass (elf) == ELFCLASS32 ? 9 : 12,
+ (unsigned long long int) phdr->p_filesz,
+ gelf_getclass (elf) == ELFCLASS32 ? 9 : 12,
+ (unsigned long long int) phdr->p_memsz,
+ (unsigned long long int) phdr->p_align);
+
+ putc_unlocked ((phdr->p_flags & PF_X) ? 'X' : ' ', stdout);
+ putc_unlocked ((phdr->p_flags & PF_W) ? 'W' : ' ', stdout);
+ putc_unlocked ((phdr->p_flags & PF_R) ? 'R' : ' ', stdout);
+
+ putc_unlocked ('\n', stdout);
+
+ if (phdr->p_type == PT_INTERP)
+ {
+ /* We can show the user the name of the interpreter. */
+ size_t maxsize;
+ char *filedata = elf_rawfile (elf, &maxsize);
+
+ if (filedata != NULL && phdr->p_offset < maxsize)
+ printf ("\t[Requesting program interpreter: %s]\n",
+ filedata + phdr->p_offset);
+ }
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("error while freeing ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ return 0;
+}
diff --git a/tests/strptr.c b/tests/strptr.c
new file mode 100644
index 0000000..759664a
--- /dev/null
+++ b/tests/strptr.c
@@ -0,0 +1,95 @@
+/* Test program for elf_strptr function.
+ 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 <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+int
+main (int argc, char *argv[])
+{
+ if (argc != 2)
+ {
+ printf ("No ELF file given as argument");
+ exit (1);
+ }
+
+ const char *fname = argv[1];
+
+ // Initialize libelf.
+ elf_version (EV_CURRENT);
+
+ /* Read the ELF from disk now. */
+ int fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ size_t ndx;
+ if (elf_getshdrstrndx (elf, &ndx) != 0)
+ {
+ printf ("cannot get section header table index: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (ndx == SHN_UNDEF)
+ {
+ printf ("ELF file `%s' doesn't have a section header table index", fname);
+ exit (1);
+ }
+
+ printf ("Strings in section %zd:\n", ndx);
+
+ size_t off = 0;
+ const char *str = elf_strptr (elf, ndx, off);
+ while (str != NULL)
+ {
+ printf ("[%zx] '%s'\n", off, str);
+ off += strlen (str) + 1;
+ str = elf_strptr (elf, ndx, off);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ return 0;
+}
diff --git a/tests/system-elf-libelf-test.c b/tests/system-elf-libelf-test.c
new file mode 100644
index 0000000..7dfe498
--- /dev/null
+++ b/tests/system-elf-libelf-test.c
@@ -0,0 +1,35 @@
+/* Explicit test compiling with system elf.h header plus libelf header.
+
+ Copyright (C) 2016 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/>. */
+
+#include <elf.h>
+#include <stddef.h>
+#include "../libelf/libelf.h"
+
+int
+main (void)
+{
+ /* Trivial test, this is really a compile test anyway. */
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ return -1;
+
+ /* This will obviously fail. It is just to check that Elf32_Chdr and
+ elf32_getchdr are available (both at compile time and runtime). */
+ Elf32_Chdr *chdr = elf32_getchdr (NULL);
+
+ return chdr == NULL ? 0 : -1;
+}
diff --git a/tests/test-core-lib.so.bz2 b/tests/test-core-lib.so.bz2
new file mode 100755
index 0000000..bb2da88
--- /dev/null
+++ b/tests/test-core-lib.so.bz2
Binary files differ
diff --git a/tests/test-core.core.bz2 b/tests/test-core.core.bz2
new file mode 100644
index 0000000..4d4346b
--- /dev/null
+++ b/tests/test-core.core.bz2
Binary files differ
diff --git a/tests/test-core.exec.bz2 b/tests/test-core.exec.bz2
new file mode 100755
index 0000000..49ce551
--- /dev/null
+++ b/tests/test-core.exec.bz2
Binary files differ
diff --git a/tests/test-elf_cntl_gelf_getshdr.c b/tests/test-elf_cntl_gelf_getshdr.c
new file mode 100644
index 0000000..7371110
--- /dev/null
+++ b/tests/test-elf_cntl_gelf_getshdr.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 2012 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 <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <libelf.h>
+#include <stdbool.h>
+#include <inttypes.h>
+
+int
+main (int argc, char *argv[])
+{
+ if (argc != 3)
+ {
+ fprintf (stderr, "Needs two arguments.\n");
+ fprintf (stderr, "First needs to be 'READ', 'MMAP' or 'FDREAD'\n");
+ fprintf (stderr, "Second is the ELF file to read.\n");
+ exit (2); /* user error */
+ }
+
+ bool do_mmap = false;
+ bool close_fd = false;
+ if (strcmp (argv[1], "READ") == 0)
+ {
+ do_mmap = false;
+ close_fd = false;
+ }
+ else if (strcmp (argv[1], "MMAP") == 0)
+ {
+ do_mmap = true;
+ close_fd = false;
+ }
+ else if (strcmp (argv[1], "FDREAD") == 0)
+ {
+ do_mmap = false;
+ close_fd = true;
+ }
+ else
+ {
+ fprintf (stderr, "First arg needs to be 'READ', 'MMAP' or 'FDREAD'\n");
+ exit (2); /* user error */
+ }
+
+ elf_version (EV_CURRENT);
+
+ int fd = open (argv[2], O_RDONLY);
+ if (fd < 0)
+ {
+ fprintf (stderr, "Cannot open input file %s: %s\n", argv[2],
+ strerror (errno));
+ exit (2);
+ }
+
+ Elf *elf = elf_begin (fd, do_mmap ? ELF_C_READ_MMAP : ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ fprintf (stderr, "elf_begin failed for %s: %s\n", argv[2],
+ elf_errmsg (-1));
+ exit (2);
+ }
+
+ if (! do_mmap && close_fd)
+ {
+ if (elf_cntl (elf, ELF_C_FDREAD) < 0)
+ {
+ fprintf (stderr, "elf_cntl failed for %s: %s\n", argv[2],
+ elf_errmsg (-1));
+ exit (1);
+ }
+ close (fd);
+ }
+
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ printf ("Section at offset %#0" PRIx64 "\n", shdr->sh_offset);
+ }
+
+ elf_end (elf);
+ exit (0);
+}
diff --git a/tests/test-flag-nobits.c b/tests/test-flag-nobits.c
new file mode 100644
index 0000000..15d44ea
--- /dev/null
+++ b/tests/test-flag-nobits.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 2010 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 <fcntl.h>
+#include <stdlib.h>
+#include <gelf.h>
+
+int
+main (int argc, char **argv)
+{
+ if (argc != 2)
+ abort ();
+
+ elf_version (EV_CURRENT);
+
+ int fd = open (argv[1], O_RDONLY);
+ Elf *stripped = elf_begin (fd, ELF_C_READ, NULL);
+
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (stripped, scn)) != NULL)
+ elf_flagdata (elf_getdata (scn, NULL), ELF_C_SET, ELF_F_DIRTY);
+
+ elf_end (stripped);
+ return 0;
+}
diff --git a/tests/test-nlist.c b/tests/test-nlist.c
new file mode 100644
index 0000000..679c911
--- /dev/null
+++ b/tests/test-nlist.c
@@ -0,0 +1,83 @@
+/* Copyright (C) 2000, 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ 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/>. */
+
+#include <nlist.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int var = 1;
+
+int bss;
+
+
+int
+foo (int a)
+{
+ return a;
+}
+
+int
+main (int argc, char *argv[] __attribute__ ((unused)))
+{
+ struct nlist nl[6] =
+ {
+ [0] = { .n_name = "var" },
+ [1] = { .n_name = "bss" },
+ [2] = { .n_name = "main" },
+ [3] = { .n_name = "foo" },
+ [4] = { .n_name = "not-there" },
+ [5] = { .n_name = NULL },
+ };
+ int cnt;
+ int result = 0;
+
+ if (nlist (".libs/test-nlist", nl) != 0
+ && nlist ("./test-nlist", nl) != 0)
+ {
+ puts ("nlist failed");
+ exit (1);
+ }
+
+ for (cnt = 0; nl[cnt].n_name != NULL; ++cnt)
+ {
+ if (argc > 1)
+ /* For debugging. */
+ printf ("nl[%d].n_name = \"%s\"\n"
+ "nl[%d].n_value = %ld\n"
+ "nl[%d].n_scnum = %d\n"
+ "nl[%d].n_type = %u\n"
+ "nl[%d].n_sclass = %d\n"
+ "nl[%d].n_numaux = %d\n\n",
+ cnt, nl[cnt].n_name,
+ cnt, nl[cnt].n_value,
+ cnt, nl[cnt].n_scnum,
+ cnt, nl[cnt].n_type,
+ cnt, nl[cnt].n_sclass,
+ cnt, nl[cnt].n_numaux);
+
+ if ((cnt != 4 && nl[cnt].n_value == 0 && nl[cnt].n_scnum == 0
+ && nl[cnt].n_type == 0 && nl[cnt].n_sclass == 0
+ && nl[cnt].n_numaux == 0)
+ || (cnt == 4 && (nl[cnt].n_value != 0 || nl[cnt].n_scnum != 0
+ || nl[cnt].n_type != 0 || nl[cnt].n_sclass != 0
+ || nl[cnt].n_numaux != 0)))
+ result = 1;
+ }
+
+ return foo (result);
+}
diff --git a/tests/test-offset-loop.alt.bz2 b/tests/test-offset-loop.alt.bz2
new file mode 100644
index 0000000..c1906b6
--- /dev/null
+++ b/tests/test-offset-loop.alt.bz2
Binary files differ
diff --git a/tests/test-offset-loop.bz2 b/tests/test-offset-loop.bz2
new file mode 100755
index 0000000..62185c0
--- /dev/null
+++ b/tests/test-offset-loop.bz2
Binary files differ
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
new file mode 100644
index 0000000..a765db6
--- /dev/null
+++ b/tests/test-subr.sh
@@ -0,0 +1,172 @@
+#! /bin/sh
+# Copyright (C) 2005-2015, 2017 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/>.
+
+
+# This file is sourced by ". $srcdir/test-subr.sh" at the start of
+# each test script. It defines some functions they use and sets up
+# canonical sh state for test runs.
+
+set -e
+
+# Each test runs in its own directory to make sure they can run in parallel.
+test_dir="test-$$"
+mkdir -p "$test_dir"
+cd "$test_dir"
+
+#LC_ALL=C
+#export LC_ALL
+
+remove_files=
+
+# Tests that trap EXIT (0) themselves should call this explicitly.
+exit_cleanup()
+{
+ rm -f $remove_files; cd ..; rmdir $test_dir
+}
+trap exit_cleanup 0
+
+tempfiles()
+{
+ remove_files="$remove_files $*"
+}
+
+testfiles()
+{
+ for file; do
+ bunzip2 -c ${abs_srcdir}/${file}.bz2 > ${file} || exit 77
+ remove_files="$remove_files $file"
+ done
+}
+
+testrun_out()
+{
+ outfile="$1"
+ shift
+ remove_files="$remove_files $outfile"
+ testrun "$@" > $outfile 2>&1 || :
+}
+
+testrun_compare()
+{
+ outfile="${1##*/}.out"
+ testrun_out $outfile "$@"
+ diff -u $outfile -
+ # diff's exit status will kill the script.
+}
+
+test_cleanup()
+{
+ rm -f $remove_files
+ remove_files=
+}
+
+# See test-wrapper.sh, which sets the environment for this.
+testrun()
+{
+ ${elfutils_testrun}_testrun "$@"
+}
+
+built_testrun()
+{
+ LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"\
+ $VALGRIND_CMD "$@"
+}
+
+installed_testrun()
+{
+ program="$1"
+ shift
+ case "$program" in
+ ${abs_builddir}/*)
+ if [ "x$elfutils_tests_rpath" != xno ]; then
+ echo >&2 installcheck not possible with --enable-tests-rpath
+ exit 77
+ fi
+ ;;
+ ${abs_top_builddir}/src/*)
+ program=${bindir}/`program_transform ${program##*/}`
+ ;;
+ esac
+ if [ "${libdir}" != /usr/lib ] && [ "${libdir}" != /usr/lib64 ]; then
+ LD_LIBRARY_PATH="${libdir}:${libdir}/elfutils\
+${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" \
+ $VALGRIND_CMD $program ${1+"$@"}
+ else
+ $VALGRIND_CMD $program ${1+"$@"}
+ fi
+}
+
+program_transform()
+{
+ echo "$*" | sed "${program_transform_name}"
+}
+
+self_test_files=`echo ${abs_top_builddir}/src/addr2line \
+${abs_top_builddir}/src/elfcmp ${abs_top_builddir}/src/elflint \
+${abs_top_builddir}/src/nm ${abs_top_builddir}/src/objdump \
+${abs_top_builddir}/src/readelf \
+${abs_top_builddir}/src/size.o ${abs_top_builddir}/src/strip.o \
+${abs_top_builddir}/libelf/libelf.so \
+${abs_top_builddir}/libdw/libdw.so \
+${abs_top_builddir}/backends/libebl_i386.so \
+${abs_top_builddir}/backends/libebl_x86_64.so`
+
+# Provide a command to run on all self-test files with testrun.
+testrun_on_self()
+{
+ exit_status=0
+
+ for file in $self_test_files; do
+ testrun $* $file \
+ || { echo "*** failure in $* $file"; exit_status=1; }
+ done
+
+ # Only exit if something failed
+ if test $exit_status != 0; then exit $exit_status; fi
+}
+
+# Compress the files first. Compress both debug sections and symtab.
+testrun_on_self_compressed()
+{
+ exit_status=0
+
+ for file in $self_test_files; do
+ tempfiles ${file}z
+ testrun ${abs_top_builddir}/src/elfcompress -f -q -o ${file}z ${file}
+ testrun ${abs_top_builddir}/src/elfcompress -f -q --name='.s??tab' ${file}z
+
+ testrun $* ${file}z \
+ || { echo "*** failure in $* ${file}z"; exit_status=1; }
+ done
+
+ # Only exit if something failed
+ if test $exit_status != 0; then exit $exit_status; fi
+}
+
+# Same as above, but redirects stdout to /dev/null
+testrun_on_self_quiet()
+{
+ exit_status=0
+
+ for file in $self_test_files; do
+ testrun $* $file > /dev/null \
+ || { echo "*** failure in $* $file"; exit_status=1; }
+ done
+
+ # Only exit if something failed
+ if test $exit_status != 0; then exit $exit_status; fi
+}
diff --git a/tests/test-wrapper.sh b/tests/test-wrapper.sh
new file mode 100755
index 0000000..09b4d49
--- /dev/null
+++ b/tests/test-wrapper.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+
+# We don't compile in an rpath because we want "make installcheck" to
+# use the installed libraries. So for local test runs we need to point
+# the library path at this build.
+
+# This wrapper script is called by the makefile, in one of two ways:
+# $(srcdir)/test-wrapper.sh ../libelf:... run-test.sh ...
+# or:
+# $(srcdir)/test-wrapper.sh installed s,^,eu-, run-test.sh ...
+
+if [ "$1" = installed ]; then
+ shift
+ elfutils_tests_rpath=$1
+ shift
+ program_transform_name="$1"
+ shift
+ elfutils_testrun=installed
+else
+ built_library_path="$1"
+ shift
+ elfutils_testrun=built
+fi
+
+old_path="${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
+
+case "$1" in
+*.sh)
+ export built_library_path program_transform_name elfutils_testrun
+ export elfutils_tests_rpath
+ ;;
+*)
+ if [ $elfutils_testrun = built ]; then
+ LD_LIBRARY_PATH="$built_library_path$old_path"
+ elif [ $elfutils_tests_rpath = yes ]; then
+ echo >&2 installcheck not possible with --enable-tests-rpath
+ exit 77
+ elif [ "x$libdir" != x/usr/lib ] && [ "x$libdir" != x/usr/lib64 ]; then
+ LD_LIBRARY_PATH="${libdir}:${libdir}/elfutils$old_path"
+ fi
+ export LD_LIBRARY_PATH
+ ;;
+esac
+
+if [ "x$VALGRIND_CMD" != "x" ]; then
+ export VALGRIND_CMD
+fi
+
+exec "$@"
diff --git a/tests/testarchive64.a.bz2 b/tests/testarchive64.a.bz2
new file mode 100644
index 0000000..4b54603
--- /dev/null
+++ b/tests/testarchive64.a.bz2
Binary files differ
diff --git a/tests/testcore-rtlib-ppc.bz2 b/tests/testcore-rtlib-ppc.bz2
new file mode 100644
index 0000000..a3cec60
--- /dev/null
+++ b/tests/testcore-rtlib-ppc.bz2
Binary files differ
diff --git a/tests/testcore-rtlib.bz2 b/tests/testcore-rtlib.bz2
new file mode 100644
index 0000000..1dc0f1a
--- /dev/null
+++ b/tests/testcore-rtlib.bz2
Binary files differ
diff --git a/tests/testfile-ada-variant.bz2 b/tests/testfile-ada-variant.bz2
new file mode 100644
index 0000000..459774d
--- /dev/null
+++ b/tests/testfile-ada-variant.bz2
Binary files differ
diff --git a/tests/testfile-backtrace-demangle.bz2 b/tests/testfile-backtrace-demangle.bz2
new file mode 100755
index 0000000..f0294df
--- /dev/null
+++ b/tests/testfile-backtrace-demangle.bz2
Binary files differ
diff --git a/tests/testfile-backtrace-demangle.cc b/tests/testfile-backtrace-demangle.cc
new file mode 100644
index 0000000..27fff68
--- /dev/null
+++ b/tests/testfile-backtrace-demangle.cc
@@ -0,0 +1,47 @@
+/* Test program for C++ demangled unwinding.
+ Copyright (C) 2014 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/>. */
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define NOINLINE_NOCLONE __attribute__ ((noinline, noclone))
+#else
+#define NOINLINE_NOCLONE __attribute__ ((noinline))
+#endif
+
+void NOINLINE_NOCLONE
+cxxfunc (int i)
+{
+ *(volatile int *)0=0;
+ // Avoid tail call optimization.
+ asm volatile ("");
+}
+
+extern "C"
+{
+ void NOINLINE_NOCLONE
+ f (void)
+ {
+ cxxfunc(1);
+ // Avoid tail call optimization.
+ asm volatile ("");
+ }
+}
+
+int
+main()
+{
+ f();
+}
diff --git a/tests/testfile-backtrace-demangle.core.bz2 b/tests/testfile-backtrace-demangle.core.bz2
new file mode 100644
index 0000000..263c304
--- /dev/null
+++ b/tests/testfile-backtrace-demangle.core.bz2
Binary files differ
diff --git a/tests/testfile-bpf-dis1.expect.bz2 b/tests/testfile-bpf-dis1.expect.bz2
new file mode 100644
index 0000000..21b55e9
--- /dev/null
+++ b/tests/testfile-bpf-dis1.expect.bz2
Binary files differ
diff --git a/tests/testfile-bpf-dis1.o.bz2 b/tests/testfile-bpf-dis1.o.bz2
new file mode 100644
index 0000000..94bb612
--- /dev/null
+++ b/tests/testfile-bpf-dis1.o.bz2
Binary files differ
diff --git a/tests/testfile-debug-rel-g.o.bz2 b/tests/testfile-debug-rel-g.o.bz2
new file mode 100644
index 0000000..b8c94e7
--- /dev/null
+++ b/tests/testfile-debug-rel-g.o.bz2
Binary files differ
diff --git a/tests/testfile-debug-rel-z.o.bz2 b/tests/testfile-debug-rel-z.o.bz2
new file mode 100644
index 0000000..1cdac79
--- /dev/null
+++ b/tests/testfile-debug-rel-z.o.bz2
Binary files differ
diff --git a/tests/testfile-debug-rel.o.bz2 b/tests/testfile-debug-rel.o.bz2
new file mode 100644
index 0000000..a3f8dff
--- /dev/null
+++ b/tests/testfile-debug-rel.o.bz2
Binary files differ
diff --git a/tests/testfile-debug-types.bz2 b/tests/testfile-debug-types.bz2
new file mode 100755
index 0000000..a41f493
--- /dev/null
+++ b/tests/testfile-debug-types.bz2
Binary files differ
diff --git a/tests/testfile-debug.bz2 b/tests/testfile-debug.bz2
new file mode 100755
index 0000000..88e59de
--- /dev/null
+++ b/tests/testfile-debug.bz2
Binary files differ
diff --git a/tests/testfile-dwfl-report-elf-align-shlib.so.bz2 b/tests/testfile-dwfl-report-elf-align-shlib.so.bz2
new file mode 100755
index 0000000..1f35df9
--- /dev/null
+++ b/tests/testfile-dwfl-report-elf-align-shlib.so.bz2
Binary files differ
diff --git a/tests/testfile-dwzstr.bz2 b/tests/testfile-dwzstr.bz2
new file mode 100755
index 0000000..8d2d326
--- /dev/null
+++ b/tests/testfile-dwzstr.bz2
Binary files differ
diff --git a/tests/testfile-dwzstr.multi.bz2 b/tests/testfile-dwzstr.multi.bz2
new file mode 100644
index 0000000..5e84991
--- /dev/null
+++ b/tests/testfile-dwzstr.multi.bz2
Binary files differ
diff --git a/tests/testfile-info-link.bz2 b/tests/testfile-info-link.bz2
new file mode 100755
index 0000000..073b761
--- /dev/null
+++ b/tests/testfile-info-link.bz2
Binary files differ
diff --git a/tests/testfile-info-link.debuginfo.bz2 b/tests/testfile-info-link.debuginfo.bz2
new file mode 100755
index 0000000..3225d19
--- /dev/null
+++ b/tests/testfile-info-link.debuginfo.bz2
Binary files differ
diff --git a/tests/testfile-info-link.stripped.bz2 b/tests/testfile-info-link.stripped.bz2
new file mode 100755
index 0000000..dcbc9a2
--- /dev/null
+++ b/tests/testfile-info-link.stripped.bz2
Binary files differ
diff --git a/tests/testfile-inlines.bz2 b/tests/testfile-inlines.bz2
new file mode 100755
index 0000000..6a0c7c5
--- /dev/null
+++ b/tests/testfile-inlines.bz2
Binary files differ
diff --git a/tests/testfile-lex-inlines.bz2 b/tests/testfile-lex-inlines.bz2
new file mode 100755
index 0000000..716e792
--- /dev/null
+++ b/tests/testfile-lex-inlines.bz2
Binary files differ
diff --git a/tests/testfile-m68k-core.bz2 b/tests/testfile-m68k-core.bz2
new file mode 100644
index 0000000..eda79d7
--- /dev/null
+++ b/tests/testfile-m68k-core.bz2
Binary files differ
diff --git a/tests/testfile-m68k-s.bz2 b/tests/testfile-m68k-s.bz2
new file mode 100755
index 0000000..44c3799
--- /dev/null
+++ b/tests/testfile-m68k-s.bz2
Binary files differ
diff --git a/tests/testfile-m68k.bz2 b/tests/testfile-m68k.bz2
new file mode 100755
index 0000000..97a1b28
--- /dev/null
+++ b/tests/testfile-m68k.bz2
Binary files differ
diff --git a/tests/testfile-macinfo.bz2 b/tests/testfile-macinfo.bz2
new file mode 100755
index 0000000..e6cc5f1
--- /dev/null
+++ b/tests/testfile-macinfo.bz2
Binary files differ
diff --git a/tests/testfile-macros-0xff.bz2 b/tests/testfile-macros-0xff.bz2
new file mode 100755
index 0000000..a19662a
--- /dev/null
+++ b/tests/testfile-macros-0xff.bz2
Binary files differ
diff --git a/tests/testfile-macros-0xff.s b/tests/testfile-macros-0xff.s
new file mode 100644
index 0000000..7fdd35c
--- /dev/null
+++ b/tests/testfile-macros-0xff.s
@@ -0,0 +1,153 @@
+ .file "x.c"
+ .text
+.Ltext0:
+ .globl main
+ .type main, @function
+main:
+.LFB0:
+ .file 1 "x.c"
+ .loc 1 3 0
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ .loc 1 3 0
+ movl $0, %eax
+ popq %rbp
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE0:
+ .size main, .-main
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0x52
+ .value 0x4
+ .long .Ldebug_abbrev0
+ .byte 0x8
+ .uleb128 0x1
+ .long .LASF244
+ .byte 0x4
+ .string "x.c"
+ .long .LASF245
+ .quad .Ltext0
+ .quad .Letext0-.Ltext0
+ .long .Ldebug_line0
+ .long .Ldebug_macro0
+ .uleb128 0x2
+ .long .LASF246
+ .byte 0x1
+ .byte 0x3
+ .long 0x4e
+ .quad .LFB0
+ .quad .LFE0-.LFB0
+ .uleb128 0x1
+ .byte 0x9c
+ .uleb128 0x3
+ .byte 0x4
+ .byte 0x5
+ .string "int"
+ .byte 0
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1
+ .uleb128 0x11
+ .byte 0x1
+ .uleb128 0x25
+ .uleb128 0xe
+ .uleb128 0x13
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x1b
+ .uleb128 0xe
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x7
+ .uleb128 0x10
+ .uleb128 0x17
+ .uleb128 0x2119
+ .uleb128 0x17
+ .byte 0
+ .byte 0
+ .uleb128 0x2
+ .uleb128 0x2e
+ .byte 0
+ .uleb128 0x3f
+ .uleb128 0x19
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x7
+ .uleb128 0x40
+ .uleb128 0x18
+ .uleb128 0x2117
+ .uleb128 0x19
+ .byte 0
+ .byte 0
+ .uleb128 0x3
+ .uleb128 0x24
+ .byte 0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0x8
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_aranges,"",@progbits
+ .long 0x2c
+ .value 0x2
+ .long .Ldebug_info0
+ .byte 0x8
+ .byte 0
+ .value 0
+ .value 0
+ .quad .Ltext0
+ .quad .Letext0-.Ltext0
+ .quad 0
+ .quad 0
+ .section .debug_macro,"",@progbits
+.Ldebug_macro0:
+ .value 0x4
+ .byte 0x6
+ .long .Ldebug_line0
+ .byte 0x1
+ .byte 0xff
+ .uleb128 0
+ .byte 0xff
+ .byte 0x3
+ .uleb128 0
+ .uleb128 0x1
+ .byte 0x5
+ .uleb128 0x1
+ .long .LASF243
+ .byte 0x4
+ .byte 0
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF245:
+ .string "/home/petr/proj/elfutils/master/elfutils"
+.LASF244:
+ .string "GNU C++ 4.9.0 20140422 (Red Hat 4.9.0-1) -mtune=generic -march=x86-64 -g3"
+.LASF243:
+ .string "FOO 0"
+.LASF246:
+ .string "main"
+ .ident "GCC: (GNU) 4.9.0 20140422 (Red Hat 4.9.0-1)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/tests/testfile-macros.bz2 b/tests/testfile-macros.bz2
new file mode 100755
index 0000000..d74df94
--- /dev/null
+++ b/tests/testfile-macros.bz2
Binary files differ
diff --git a/tests/testfile-nobitsalign.bz2 b/tests/testfile-nobitsalign.bz2
new file mode 100755
index 0000000..7f0d424
--- /dev/null
+++ b/tests/testfile-nobitsalign.bz2
Binary files differ
diff --git a/tests/testfile-nobitsalign.strip.bz2 b/tests/testfile-nobitsalign.strip.bz2
new file mode 100755
index 0000000..f72000c
--- /dev/null
+++ b/tests/testfile-nobitsalign.strip.bz2
Binary files differ
diff --git a/tests/testfile-nolfs.bz2 b/tests/testfile-nolfs.bz2
new file mode 100644
index 0000000..ab8351e
--- /dev/null
+++ b/tests/testfile-nolfs.bz2
Binary files differ
diff --git a/tests/testfile-s390x-hash-both.bz2 b/tests/testfile-s390x-hash-both.bz2
new file mode 100755
index 0000000..86e0bcc
--- /dev/null
+++ b/tests/testfile-s390x-hash-both.bz2
Binary files differ
diff --git a/tests/testfile-sizes1.o.bz2 b/tests/testfile-sizes1.o.bz2
new file mode 100644
index 0000000..479ecb2
--- /dev/null
+++ b/tests/testfile-sizes1.o.bz2
Binary files differ
diff --git a/tests/testfile-sizes2.o.bz2 b/tests/testfile-sizes2.o.bz2
new file mode 100644
index 0000000..7bd7b47
--- /dev/null
+++ b/tests/testfile-sizes2.o.bz2
Binary files differ
diff --git a/tests/testfile-sizes3.o.bz2 b/tests/testfile-sizes3.o.bz2
new file mode 100644
index 0000000..8633382
--- /dev/null
+++ b/tests/testfile-sizes3.o.bz2
Binary files differ
diff --git a/tests/testfile-sizes4.o.bz2 b/tests/testfile-sizes4.o.bz2
new file mode 100644
index 0000000..046e0a2
--- /dev/null
+++ b/tests/testfile-sizes4.o.bz2
Binary files differ
diff --git a/tests/testfile-sizes4.s b/tests/testfile-sizes4.s
new file mode 100644
index 0000000..a243021
--- /dev/null
+++ b/tests/testfile-sizes4.s
@@ -0,0 +1,77 @@
+ .section .debug_info
+.Lcu1_begin:
+ .4byte .Lcu1_end - .Lcu1_start
+.Lcu1_start:
+ .2byte 4 /* Version */
+ .4byte .Labbrev1_begin /* Abbrevs */
+ .byte 8 /* Pointer size */
+ .uleb128 2 /* Abbrev (DW_TAG_compile_unit) */
+ .uleb128 3 /* Abbrev (DW_TAG_variable) */
+ .ascii "v\0"
+ .4byte .Llabel1 - .Lcu1_begin
+.Llabel1:
+ .uleb128 4 /* Abbrev (DW_TAG_array_type) */
+ .4byte .Llabel2 - .Lcu1_begin
+ .uleb128 5 /* Abbrev (DW_TAG_subrange_type) */
+ .byte -1
+ .2byte 255
+ .byte 0x0 /* Terminate children */
+.Llabel2:
+ .uleb128 6 /* Abbrev (DW_TAG_base_type) */
+ .byte 1
+ .byte 0x0 /* Terminate children */
+.Lcu1_end:
+ .section .note.gnu.build-id, "a", %note
+ .4byte 4
+ .4byte 8
+ .4byte 3
+ .ascii "GNU\0"
+ .byte 0x01
+ .byte 0x02
+ .byte 0x03
+ .byte 0x04
+ .byte 0x05
+ .byte 0x06
+ .byte 0x07
+ .byte 0x08
+ .section .debug_abbrev
+.Labbrev1_begin:
+ .uleb128 2 /* Abbrev start */
+ .uleb128 0x11 /* DW_TAG_compile_unit */
+ .byte 1 /* has_children */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+ .uleb128 3 /* Abbrev start */
+ .uleb128 0x34 /* DW_TAG_variable */
+ .byte 0 /* has_children */
+ .uleb128 0x03 /* DW_AT_name */
+ .uleb128 0x08 /* DW_FORM_string */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+ .uleb128 4 /* Abbrev start */
+ .uleb128 0x01 /* DW_TAG_array_type */
+ .byte 1 /* has_children */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+ .uleb128 5 /* Abbrev start */
+ .uleb128 0x21 /* DW_TAG_subrange_type */
+ .byte 0 /* has_children */
+ .uleb128 0x22 /* DW_AT_lower_bound */
+ .uleb128 0x0b /* DW_FORM_data1 */
+ .uleb128 0x2f /* DW_AT_upper_bound */
+ .uleb128 0x05 /* DW_FORM_data2 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+ .uleb128 6 /* Abbrev start */
+ .uleb128 0x24 /* DW_TAG_base_type */
+ .byte 0 /* has_children */
+ .uleb128 0x0b /* DW_AT_byte_size */
+ .uleb128 0x0b /* DW_FORM_data1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
diff --git a/tests/testfile-stridex.bz2 b/tests/testfile-stridex.bz2
new file mode 100755
index 0000000..ff909f4
--- /dev/null
+++ b/tests/testfile-stridex.bz2
Binary files differ
diff --git a/tests/testfile-strtab.bz2 b/tests/testfile-strtab.bz2
new file mode 100644
index 0000000..4eda14d
--- /dev/null
+++ b/tests/testfile-strtab.bz2
Binary files differ
diff --git a/tests/testfile-strtab.debuginfo.bz2 b/tests/testfile-strtab.debuginfo.bz2
new file mode 100644
index 0000000..6fb8164
--- /dev/null
+++ b/tests/testfile-strtab.debuginfo.bz2
Binary files differ
diff --git a/tests/testfile-strtab.stripped.bz2 b/tests/testfile-strtab.stripped.bz2
new file mode 100644
index 0000000..779bfdb
--- /dev/null
+++ b/tests/testfile-strtab.stripped.bz2
Binary files differ
diff --git a/tests/testfile-x32-core.bz2 b/tests/testfile-x32-core.bz2
new file mode 100644
index 0000000..d519851
--- /dev/null
+++ b/tests/testfile-x32-core.bz2
Binary files differ
diff --git a/tests/testfile-x32-d.bz2 b/tests/testfile-x32-d.bz2
new file mode 100755
index 0000000..ad5836e
--- /dev/null
+++ b/tests/testfile-x32-d.bz2
Binary files differ
diff --git a/tests/testfile-x32-debug.bz2 b/tests/testfile-x32-debug.bz2
new file mode 100755
index 0000000..d55a004
--- /dev/null
+++ b/tests/testfile-x32-debug.bz2
Binary files differ
diff --git a/tests/testfile-x32-s.bz2 b/tests/testfile-x32-s.bz2
new file mode 100755
index 0000000..a909d33
--- /dev/null
+++ b/tests/testfile-x32-s.bz2
Binary files differ
diff --git a/tests/testfile-x32.bz2 b/tests/testfile-x32.bz2
new file mode 100755
index 0000000..f6df180
--- /dev/null
+++ b/tests/testfile-x32.bz2
Binary files differ
diff --git a/tests/testfile-zdebug.bz2 b/tests/testfile-zdebug.bz2
new file mode 100755
index 0000000..784041c
--- /dev/null
+++ b/tests/testfile-zdebug.bz2
Binary files differ
diff --git a/tests/testfile-zgabi32.bz2 b/tests/testfile-zgabi32.bz2
new file mode 100755
index 0000000..6159dbc
--- /dev/null
+++ b/tests/testfile-zgabi32.bz2
Binary files differ
diff --git a/tests/testfile-zgabi32be.bz2 b/tests/testfile-zgabi32be.bz2
new file mode 100755
index 0000000..f1f5eb5
--- /dev/null
+++ b/tests/testfile-zgabi32be.bz2
Binary files differ
diff --git a/tests/testfile-zgabi64.bz2 b/tests/testfile-zgabi64.bz2
new file mode 100755
index 0000000..3b44f08
--- /dev/null
+++ b/tests/testfile-zgabi64.bz2
Binary files differ
diff --git a/tests/testfile-zgabi64be.bz2 b/tests/testfile-zgabi64be.bz2
new file mode 100755
index 0000000..d819ae3
--- /dev/null
+++ b/tests/testfile-zgabi64be.bz2
Binary files differ
diff --git a/tests/testfile-zgnu32.bz2 b/tests/testfile-zgnu32.bz2
new file mode 100755
index 0000000..9d622ca
--- /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 0000000..c1dd589
--- /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 0000000..1bc2c09
--- /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 0000000..390c9c9
--- /dev/null
+++ b/tests/testfile-zgnu64be.bz2
Binary files differ
diff --git a/tests/testfile.bz2 b/tests/testfile.bz2
new file mode 100644
index 0000000..bde9b12
--- /dev/null
+++ b/tests/testfile.bz2
Binary files differ
diff --git a/tests/testfile10.bz2 b/tests/testfile10.bz2
new file mode 100644
index 0000000..e9dd504
--- /dev/null
+++ b/tests/testfile10.bz2
Binary files differ
diff --git a/tests/testfile11.bz2 b/tests/testfile11.bz2
new file mode 100644
index 0000000..d094b84
--- /dev/null
+++ b/tests/testfile11.bz2
Binary files differ
diff --git a/tests/testfile12.bz2 b/tests/testfile12.bz2
new file mode 100644
index 0000000..8bb5ad3
--- /dev/null
+++ b/tests/testfile12.bz2
Binary files differ
diff --git a/tests/testfile13.bz2 b/tests/testfile13.bz2
new file mode 100644
index 0000000..3b0bcb9
--- /dev/null
+++ b/tests/testfile13.bz2
Binary files differ
diff --git a/tests/testfile14.bz2 b/tests/testfile14.bz2
new file mode 100644
index 0000000..ac7c69e
--- /dev/null
+++ b/tests/testfile14.bz2
Binary files differ
diff --git a/tests/testfile15.bz2 b/tests/testfile15.bz2
new file mode 100644
index 0000000..e75f457
--- /dev/null
+++ b/tests/testfile15.bz2
Binary files differ
diff --git a/tests/testfile15.debug.bz2 b/tests/testfile15.debug.bz2
new file mode 100644
index 0000000..5c86900
--- /dev/null
+++ b/tests/testfile15.debug.bz2
Binary files differ
diff --git a/tests/testfile16.bz2 b/tests/testfile16.bz2
new file mode 100644
index 0000000..4d7160c
--- /dev/null
+++ b/tests/testfile16.bz2
Binary files differ
diff --git a/tests/testfile16.debug.bz2 b/tests/testfile16.debug.bz2
new file mode 100644
index 0000000..f02a972
--- /dev/null
+++ b/tests/testfile16.debug.bz2
Binary files differ
diff --git a/tests/testfile17.bz2 b/tests/testfile17.bz2
new file mode 100644
index 0000000..5a12320
--- /dev/null
+++ b/tests/testfile17.bz2
Binary files differ
diff --git a/tests/testfile17.debug.bz2 b/tests/testfile17.debug.bz2
new file mode 100644
index 0000000..86a76ab
--- /dev/null
+++ b/tests/testfile17.debug.bz2
Binary files differ
diff --git a/tests/testfile18.bz2 b/tests/testfile18.bz2
new file mode 100644
index 0000000..8b5326c
--- /dev/null
+++ b/tests/testfile18.bz2
Binary files differ
diff --git a/tests/testfile19.bz2 b/tests/testfile19.bz2
new file mode 100644
index 0000000..f3e6512
--- /dev/null
+++ b/tests/testfile19.bz2
Binary files differ
diff --git a/tests/testfile19.index.bz2 b/tests/testfile19.index.bz2
new file mode 100644
index 0000000..c0a0a7a
--- /dev/null
+++ b/tests/testfile19.index.bz2
Binary files differ
diff --git a/tests/testfile2.bz2 b/tests/testfile2.bz2
new file mode 100644
index 0000000..0771311
--- /dev/null
+++ b/tests/testfile2.bz2
Binary files differ
diff --git a/tests/testfile20.bz2 b/tests/testfile20.bz2
new file mode 100644
index 0000000..a379f6b
--- /dev/null
+++ b/tests/testfile20.bz2
Binary files differ
diff --git a/tests/testfile20.index.bz2 b/tests/testfile20.index.bz2
new file mode 100644
index 0000000..08dedaf
--- /dev/null
+++ b/tests/testfile20.index.bz2
Binary files differ
diff --git a/tests/testfile21.bz2 b/tests/testfile21.bz2
new file mode 100644
index 0000000..bab7e6d
--- /dev/null
+++ b/tests/testfile21.bz2
Binary files differ
diff --git a/tests/testfile21.index.bz2 b/tests/testfile21.index.bz2
new file mode 100644
index 0000000..5192219
--- /dev/null
+++ b/tests/testfile21.index.bz2
Binary files differ
diff --git a/tests/testfile22.bz2 b/tests/testfile22.bz2
new file mode 100644
index 0000000..8c26270
--- /dev/null
+++ b/tests/testfile22.bz2
Binary files differ
diff --git a/tests/testfile23.bz2 b/tests/testfile23.bz2
new file mode 100644
index 0000000..cf0ce55
--- /dev/null
+++ b/tests/testfile23.bz2
Binary files differ
diff --git a/tests/testfile24.bz2 b/tests/testfile24.bz2
new file mode 100644
index 0000000..2320acb
--- /dev/null
+++ b/tests/testfile24.bz2
Binary files differ
diff --git a/tests/testfile25.bz2 b/tests/testfile25.bz2
new file mode 100644
index 0000000..51e0421
--- /dev/null
+++ b/tests/testfile25.bz2
Binary files differ
diff --git a/tests/testfile26.bz2 b/tests/testfile26.bz2
new file mode 100644
index 0000000..1f86285
--- /dev/null
+++ b/tests/testfile26.bz2
Binary files differ
diff --git a/tests/testfile27.bz2 b/tests/testfile27.bz2
new file mode 100644
index 0000000..9d06cd9
--- /dev/null
+++ b/tests/testfile27.bz2
Binary files differ
diff --git a/tests/testfile28.bz2 b/tests/testfile28.bz2
new file mode 100644
index 0000000..ca0dff3
--- /dev/null
+++ b/tests/testfile28.bz2
Binary files differ
diff --git a/tests/testfile28.rdwr.bz2 b/tests/testfile28.rdwr.bz2
new file mode 100644
index 0000000..4c65848
--- /dev/null
+++ b/tests/testfile28.rdwr.bz2
Binary files differ
diff --git a/tests/testfile29.bz2 b/tests/testfile29.bz2
new file mode 100644
index 0000000..b46451b
--- /dev/null
+++ b/tests/testfile29.bz2
Binary files differ
diff --git a/tests/testfile29.rdwr.bz2 b/tests/testfile29.rdwr.bz2
new file mode 100644
index 0000000..42eadc7
--- /dev/null
+++ b/tests/testfile29.rdwr.bz2
Binary files differ
diff --git a/tests/testfile3.bz2 b/tests/testfile3.bz2
new file mode 100644
index 0000000..30a456c
--- /dev/null
+++ b/tests/testfile3.bz2
Binary files differ
diff --git a/tests/testfile30.bz2 b/tests/testfile30.bz2
new file mode 100644
index 0000000..9ee93c0
--- /dev/null
+++ b/tests/testfile30.bz2
Binary files differ
diff --git a/tests/testfile31.bz2 b/tests/testfile31.bz2
new file mode 100644
index 0000000..73451d2
--- /dev/null
+++ b/tests/testfile31.bz2
Binary files differ
diff --git a/tests/testfile32.bz2 b/tests/testfile32.bz2
new file mode 100644
index 0000000..7e3c73e
--- /dev/null
+++ b/tests/testfile32.bz2
Binary files differ
diff --git a/tests/testfile33.bz2 b/tests/testfile33.bz2
new file mode 100644
index 0000000..f3dbc73
--- /dev/null
+++ b/tests/testfile33.bz2
Binary files differ
diff --git a/tests/testfile34.bz2 b/tests/testfile34.bz2
new file mode 100644
index 0000000..a417fcb
--- /dev/null
+++ b/tests/testfile34.bz2
Binary files differ
diff --git a/tests/testfile35.bz2 b/tests/testfile35.bz2
new file mode 100644
index 0000000..b591301
--- /dev/null
+++ b/tests/testfile35.bz2
Binary files differ
diff --git a/tests/testfile35.debug.bz2 b/tests/testfile35.debug.bz2
new file mode 100644
index 0000000..f191862
--- /dev/null
+++ b/tests/testfile35.debug.bz2
Binary files differ
diff --git a/tests/testfile36.bz2 b/tests/testfile36.bz2
new file mode 100644
index 0000000..e912a19
--- /dev/null
+++ b/tests/testfile36.bz2
Binary files differ
diff --git a/tests/testfile36.debug.bz2 b/tests/testfile36.debug.bz2
new file mode 100644
index 0000000..76aca42
--- /dev/null
+++ b/tests/testfile36.debug.bz2
Binary files differ
diff --git a/tests/testfile37.bz2 b/tests/testfile37.bz2
new file mode 100644
index 0000000..254ce32
--- /dev/null
+++ b/tests/testfile37.bz2
Binary files differ
diff --git a/tests/testfile37.debug.bz2 b/tests/testfile37.debug.bz2
new file mode 100644
index 0000000..74e46a8
--- /dev/null
+++ b/tests/testfile37.debug.bz2
Binary files differ
diff --git a/tests/testfile38.bz2 b/tests/testfile38.bz2
new file mode 100644
index 0000000..42adb77
--- /dev/null
+++ b/tests/testfile38.bz2
Binary files differ
diff --git a/tests/testfile39.bz2 b/tests/testfile39.bz2
new file mode 100644
index 0000000..42d0fbc
--- /dev/null
+++ b/tests/testfile39.bz2
Binary files differ
diff --git a/tests/testfile4.bz2 b/tests/testfile4.bz2
new file mode 100644
index 0000000..25b25df
--- /dev/null
+++ b/tests/testfile4.bz2
Binary files differ
diff --git a/tests/testfile40.bz2 b/tests/testfile40.bz2
new file mode 100644
index 0000000..ad41985
--- /dev/null
+++ b/tests/testfile40.bz2
Binary files differ
diff --git a/tests/testfile40.debug.bz2 b/tests/testfile40.debug.bz2
new file mode 100644
index 0000000..2eec4d7
--- /dev/null
+++ b/tests/testfile40.debug.bz2
Binary files differ
diff --git a/tests/testfile41.bz2 b/tests/testfile41.bz2
new file mode 100644
index 0000000..f9bf5a4
--- /dev/null
+++ b/tests/testfile41.bz2
Binary files differ
diff --git a/tests/testfile42.bz2 b/tests/testfile42.bz2
new file mode 100644
index 0000000..2530aba
--- /dev/null
+++ b/tests/testfile42.bz2
Binary files differ
diff --git a/tests/testfile42_noshdrs.bz2 b/tests/testfile42_noshdrs.bz2
new file mode 100644
index 0000000..e50f750
--- /dev/null
+++ b/tests/testfile42_noshdrs.bz2
Binary files differ
diff --git a/tests/testfile43.bz2 b/tests/testfile43.bz2
new file mode 100644
index 0000000..c99db24
--- /dev/null
+++ b/tests/testfile43.bz2
Binary files differ
diff --git a/tests/testfile44.S.bz2 b/tests/testfile44.S.bz2
new file mode 100644
index 0000000..4e87434
--- /dev/null
+++ b/tests/testfile44.S.bz2
Binary files differ
diff --git a/tests/testfile44.expect.bz2 b/tests/testfile44.expect.bz2
new file mode 100644
index 0000000..b3937b9
--- /dev/null
+++ b/tests/testfile44.expect.bz2
Binary files differ
diff --git a/tests/testfile45.S.bz2 b/tests/testfile45.S.bz2
new file mode 100644
index 0000000..00e819e
--- /dev/null
+++ b/tests/testfile45.S.bz2
Binary files differ
diff --git a/tests/testfile45.expect.bz2 b/tests/testfile45.expect.bz2
new file mode 100644
index 0000000..b8b33e9
--- /dev/null
+++ b/tests/testfile45.expect.bz2
Binary files differ
diff --git a/tests/testfile46.bz2 b/tests/testfile46.bz2
new file mode 100644
index 0000000..db83b27
--- /dev/null
+++ b/tests/testfile46.bz2
Binary files differ
diff --git a/tests/testfile47.bz2 b/tests/testfile47.bz2
new file mode 100644
index 0000000..334bd6c
--- /dev/null
+++ b/tests/testfile47.bz2
Binary files differ
diff --git a/tests/testfile48.bz2 b/tests/testfile48.bz2
new file mode 100644
index 0000000..da0d9da
--- /dev/null
+++ b/tests/testfile48.bz2
Binary files differ
diff --git a/tests/testfile48.debug.bz2 b/tests/testfile48.debug.bz2
new file mode 100644
index 0000000..7b84c4c
--- /dev/null
+++ b/tests/testfile48.debug.bz2
Binary files differ
diff --git a/tests/testfile49.bz2 b/tests/testfile49.bz2
new file mode 100644
index 0000000..8741a6b
--- /dev/null
+++ b/tests/testfile49.bz2
Binary files differ
diff --git a/tests/testfile5.bz2 b/tests/testfile5.bz2
new file mode 100644
index 0000000..247313e
--- /dev/null
+++ b/tests/testfile5.bz2
Binary files differ
diff --git a/tests/testfile50.bz2 b/tests/testfile50.bz2
new file mode 100644
index 0000000..fce4332
--- /dev/null
+++ b/tests/testfile50.bz2
Binary files differ
diff --git a/tests/testfile51.bz2 b/tests/testfile51.bz2
new file mode 100755
index 0000000..5ff45c6
--- /dev/null
+++ b/tests/testfile51.bz2
Binary files differ
diff --git a/tests/testfile52-32.noshdrs.so.bz2 b/tests/testfile52-32.noshdrs.so.bz2
new file mode 100755
index 0000000..01d2742
--- /dev/null
+++ b/tests/testfile52-32.noshdrs.so.bz2
Binary files differ
diff --git a/tests/testfile52-32.prelink.so.bz2 b/tests/testfile52-32.prelink.so.bz2
new file mode 100755
index 0000000..ccb9ae3
--- /dev/null
+++ b/tests/testfile52-32.prelink.so.bz2
Binary files differ
diff --git a/tests/testfile52-32.so.bz2 b/tests/testfile52-32.so.bz2
new file mode 100755
index 0000000..2a5b56e
--- /dev/null
+++ b/tests/testfile52-32.so.bz2
Binary files differ
diff --git a/tests/testfile52-32.so.debug.bz2 b/tests/testfile52-32.so.debug.bz2
new file mode 100755
index 0000000..818b36d
--- /dev/null
+++ b/tests/testfile52-32.so.debug.bz2
Binary files differ
diff --git a/tests/testfile52-64.noshdrs.so.bz2 b/tests/testfile52-64.noshdrs.so.bz2
new file mode 100755
index 0000000..5ca310f
--- /dev/null
+++ b/tests/testfile52-64.noshdrs.so.bz2
Binary files differ
diff --git a/tests/testfile52-64.prelink.so.bz2 b/tests/testfile52-64.prelink.so.bz2
new file mode 100755
index 0000000..8cb8f48
--- /dev/null
+++ b/tests/testfile52-64.prelink.so.bz2
Binary files differ
diff --git a/tests/testfile52-64.so.bz2 b/tests/testfile52-64.so.bz2
new file mode 100755
index 0000000..8009f07
--- /dev/null
+++ b/tests/testfile52-64.so.bz2
Binary files differ
diff --git a/tests/testfile52-64.so.debug.bz2 b/tests/testfile52-64.so.debug.bz2
new file mode 100755
index 0000000..4397788
--- /dev/null
+++ b/tests/testfile52-64.so.debug.bz2
Binary files differ
diff --git a/tests/testfile53-32.bz2 b/tests/testfile53-32.bz2
new file mode 100755
index 0000000..7bf48d9
--- /dev/null
+++ b/tests/testfile53-32.bz2
Binary files differ
diff --git a/tests/testfile53-32.debug.bz2 b/tests/testfile53-32.debug.bz2
new file mode 100755
index 0000000..79ea566
--- /dev/null
+++ b/tests/testfile53-32.debug.bz2
Binary files differ
diff --git a/tests/testfile53-32.prelink.bz2 b/tests/testfile53-32.prelink.bz2
new file mode 100755
index 0000000..8e05abf
--- /dev/null
+++ b/tests/testfile53-32.prelink.bz2
Binary files differ
diff --git a/tests/testfile53-64.bz2 b/tests/testfile53-64.bz2
new file mode 100755
index 0000000..235a763
--- /dev/null
+++ b/tests/testfile53-64.bz2
Binary files differ
diff --git a/tests/testfile53-64.debug.bz2 b/tests/testfile53-64.debug.bz2
new file mode 100755
index 0000000..675c6ea
--- /dev/null
+++ b/tests/testfile53-64.debug.bz2
Binary files differ
diff --git a/tests/testfile53-64.prelink.bz2 b/tests/testfile53-64.prelink.bz2
new file mode 100755
index 0000000..853aba7
--- /dev/null
+++ b/tests/testfile53-64.prelink.bz2
Binary files differ
diff --git a/tests/testfile54-32.noshdrs.so.bz2 b/tests/testfile54-32.noshdrs.so.bz2
new file mode 100755
index 0000000..846bc91
--- /dev/null
+++ b/tests/testfile54-32.noshdrs.so.bz2
Binary files differ
diff --git a/tests/testfile54-32.prelink.so.bz2 b/tests/testfile54-32.prelink.so.bz2
new file mode 100755
index 0000000..85c8526
--- /dev/null
+++ b/tests/testfile54-32.prelink.so.bz2
Binary files differ
diff --git a/tests/testfile54-32.so.bz2 b/tests/testfile54-32.so.bz2
new file mode 100755
index 0000000..4bc4fa3
--- /dev/null
+++ b/tests/testfile54-32.so.bz2
Binary files differ
diff --git a/tests/testfile54-32.so.debug.bz2 b/tests/testfile54-32.so.debug.bz2
new file mode 100755
index 0000000..79dd614
--- /dev/null
+++ b/tests/testfile54-32.so.debug.bz2
Binary files differ
diff --git a/tests/testfile54-64.noshdrs.so.bz2 b/tests/testfile54-64.noshdrs.so.bz2
new file mode 100755
index 0000000..3da726a
--- /dev/null
+++ b/tests/testfile54-64.noshdrs.so.bz2
Binary files differ
diff --git a/tests/testfile54-64.prelink.so.bz2 b/tests/testfile54-64.prelink.so.bz2
new file mode 100755
index 0000000..e296a1d
--- /dev/null
+++ b/tests/testfile54-64.prelink.so.bz2
Binary files differ
diff --git a/tests/testfile54-64.so.bz2 b/tests/testfile54-64.so.bz2
new file mode 100755
index 0000000..6072bf1
--- /dev/null
+++ b/tests/testfile54-64.so.bz2
Binary files differ
diff --git a/tests/testfile54-64.so.debug.bz2 b/tests/testfile54-64.so.debug.bz2
new file mode 100755
index 0000000..6b45390
--- /dev/null
+++ b/tests/testfile54-64.so.debug.bz2
Binary files differ
diff --git a/tests/testfile55-32.bz2 b/tests/testfile55-32.bz2
new file mode 100755
index 0000000..d4cc986
--- /dev/null
+++ b/tests/testfile55-32.bz2
Binary files differ
diff --git a/tests/testfile55-32.debug.bz2 b/tests/testfile55-32.debug.bz2
new file mode 100755
index 0000000..c5aa3f6
--- /dev/null
+++ b/tests/testfile55-32.debug.bz2
Binary files differ
diff --git a/tests/testfile55-32.prelink.bz2 b/tests/testfile55-32.prelink.bz2
new file mode 100755
index 0000000..4fc171a
--- /dev/null
+++ b/tests/testfile55-32.prelink.bz2
Binary files differ
diff --git a/tests/testfile55-64.bz2 b/tests/testfile55-64.bz2
new file mode 100755
index 0000000..27341fa
--- /dev/null
+++ b/tests/testfile55-64.bz2
Binary files differ
diff --git a/tests/testfile55-64.debug.bz2 b/tests/testfile55-64.debug.bz2
new file mode 100755
index 0000000..d975c70
--- /dev/null
+++ b/tests/testfile55-64.debug.bz2
Binary files differ
diff --git a/tests/testfile55-64.prelink.bz2 b/tests/testfile55-64.prelink.bz2
new file mode 100755
index 0000000..a4338fe
--- /dev/null
+++ b/tests/testfile55-64.prelink.bz2
Binary files differ
diff --git a/tests/testfile56.bz2 b/tests/testfile56.bz2
new file mode 100644
index 0000000..0e2257c
--- /dev/null
+++ b/tests/testfile56.bz2
Binary files differ
diff --git a/tests/testfile57.bz2 b/tests/testfile57.bz2
new file mode 100644
index 0000000..59dbde1
--- /dev/null
+++ b/tests/testfile57.bz2
Binary files differ
diff --git a/tests/testfile58.bz2 b/tests/testfile58.bz2
new file mode 100644
index 0000000..839efd9
--- /dev/null
+++ b/tests/testfile58.bz2
Binary files differ
diff --git a/tests/testfile59.bz2 b/tests/testfile59.bz2
new file mode 100755
index 0000000..bcee648
--- /dev/null
+++ b/tests/testfile59.bz2
Binary files differ
diff --git a/tests/testfile6.bz2 b/tests/testfile6.bz2
new file mode 100644
index 0000000..fd376b2
--- /dev/null
+++ b/tests/testfile6.bz2
Binary files differ
diff --git a/tests/testfile60.bz2 b/tests/testfile60.bz2
new file mode 100755
index 0000000..6a0cd7b
--- /dev/null
+++ b/tests/testfile60.bz2
Binary files differ
diff --git a/tests/testfile61.bz2 b/tests/testfile61.bz2
new file mode 100644
index 0000000..d139389
--- /dev/null
+++ b/tests/testfile61.bz2
Binary files differ
diff --git a/tests/testfile62.bz2 b/tests/testfile62.bz2
new file mode 100644
index 0000000..8a42cf6
--- /dev/null
+++ b/tests/testfile62.bz2
Binary files differ
diff --git a/tests/testfile63.bz2 b/tests/testfile63.bz2
new file mode 100644
index 0000000..4be87cd
--- /dev/null
+++ b/tests/testfile63.bz2
Binary files differ
diff --git a/tests/testfile64.bz2 b/tests/testfile64.bz2
new file mode 100644
index 0000000..674bd53
--- /dev/null
+++ b/tests/testfile64.bz2
Binary files differ
diff --git a/tests/testfile65.bz2 b/tests/testfile65.bz2
new file mode 100644
index 0000000..5e925f8
--- /dev/null
+++ b/tests/testfile65.bz2
Binary files differ
diff --git a/tests/testfile66.bz2 b/tests/testfile66.bz2
new file mode 100755
index 0000000..4797590
--- /dev/null
+++ b/tests/testfile66.bz2
Binary files differ
diff --git a/tests/testfile66.core.bz2 b/tests/testfile66.core.bz2
new file mode 100644
index 0000000..12e2d44
--- /dev/null
+++ b/tests/testfile66.core.bz2
Binary files differ
diff --git a/tests/testfile67.bz2 b/tests/testfile67.bz2
new file mode 100644
index 0000000..bb64745
--- /dev/null
+++ b/tests/testfile67.bz2
Binary files differ
diff --git a/tests/testfile68.bz2 b/tests/testfile68.bz2
new file mode 100644
index 0000000..3fe6792
--- /dev/null
+++ b/tests/testfile68.bz2
Binary files differ
diff --git a/tests/testfile69.core.bz2 b/tests/testfile69.core.bz2
new file mode 100644
index 0000000..9955318
--- /dev/null
+++ b/tests/testfile69.core.bz2
Binary files differ
diff --git a/tests/testfile69.so.bz2 b/tests/testfile69.so.bz2
new file mode 100755
index 0000000..fdddab9
--- /dev/null
+++ b/tests/testfile69.so.bz2
Binary files differ
diff --git a/tests/testfile7.bz2 b/tests/testfile7.bz2
new file mode 100644
index 0000000..73452bb
--- /dev/null
+++ b/tests/testfile7.bz2
Binary files differ
diff --git a/tests/testfile70.core.bz2 b/tests/testfile70.core.bz2
new file mode 100644
index 0000000..6c47c6d
--- /dev/null
+++ b/tests/testfile70.core.bz2
Binary files differ
diff --git a/tests/testfile70.exec.bz2 b/tests/testfile70.exec.bz2
new file mode 100644
index 0000000..f1b969a
--- /dev/null
+++ b/tests/testfile70.exec.bz2
Binary files differ
diff --git a/tests/testfile71.bz2 b/tests/testfile71.bz2
new file mode 100644
index 0000000..ce5b08f
--- /dev/null
+++ b/tests/testfile71.bz2
Binary files differ
diff --git a/tests/testfile8.bz2 b/tests/testfile8.bz2
new file mode 100644
index 0000000..1ff4994
--- /dev/null
+++ b/tests/testfile8.bz2
Binary files differ
diff --git a/tests/testfile9.bz2 b/tests/testfile9.bz2
new file mode 100644
index 0000000..40454bc
--- /dev/null
+++ b/tests/testfile9.bz2
Binary files differ
diff --git a/tests/testfile_aarch64_core.bz2 b/tests/testfile_aarch64_core.bz2
new file mode 100644
index 0000000..9d56268
--- /dev/null
+++ b/tests/testfile_aarch64_core.bz2
Binary files differ
diff --git a/tests/testfile_class_func.bz2 b/tests/testfile_class_func.bz2
new file mode 100755
index 0000000..e40dcf2
--- /dev/null
+++ b/tests/testfile_class_func.bz2
Binary files differ
diff --git a/tests/testfile_const_type.bz2 b/tests/testfile_const_type.bz2
new file mode 100755
index 0000000..fea4a9c
--- /dev/null
+++ b/tests/testfile_const_type.bz2
Binary files differ
diff --git a/tests/testfile_const_type.c b/tests/testfile_const_type.c
new file mode 100644
index 0000000..259007d
--- /dev/null
+++ b/tests/testfile_const_type.c
@@ -0,0 +1,14 @@
+// gcc -m32 -g -O2 -o const_type const_type.c
+
+__attribute__((noinline, noclone)) int
+f1 (long long d)
+{
+ long long w = d / 0x1234567800000LL;
+ return w;
+}
+
+int
+main ()
+{
+ return f1 (4LL) - f1 (4LL);
+}
diff --git a/tests/testfile_entry_value.bz2 b/tests/testfile_entry_value.bz2
new file mode 100755
index 0000000..fde86c6
--- /dev/null
+++ b/tests/testfile_entry_value.bz2
Binary files differ
diff --git a/tests/testfile_entry_value.c b/tests/testfile_entry_value.c
new file mode 100644
index 0000000..d2f232b
--- /dev/null
+++ b/tests/testfile_entry_value.c
@@ -0,0 +1,19 @@
+// gcc -g -O2 -o entry_value entry_value.c
+int __attribute__((noinline, noclone)) foo (int x, int y)
+{
+ return x + y;
+}
+
+int __attribute__((noinline, noclone)) bar (int x, int y)
+{
+ int z;
+ z = foo (x, y);
+ z += foo (y, x);
+ return z;
+}
+
+int
+main (int argc, char **argv)
+{
+ return bar (argc + 1, argc - 1);
+}
diff --git a/tests/testfile_i686_core.bz2 b/tests/testfile_i686_core.bz2
new file mode 100644
index 0000000..8412776
--- /dev/null
+++ b/tests/testfile_i686_core.bz2
Binary files differ
diff --git a/tests/testfile_implicit_pointer.bz2 b/tests/testfile_implicit_pointer.bz2
new file mode 100755
index 0000000..72f6a69
--- /dev/null
+++ b/tests/testfile_implicit_pointer.bz2
Binary files differ
diff --git a/tests/testfile_implicit_pointer.c b/tests/testfile_implicit_pointer.c
new file mode 100644
index 0000000..d7e28a0
--- /dev/null
+++ b/tests/testfile_implicit_pointer.c
@@ -0,0 +1,12 @@
+// gcc -g -O2 -o implicit_pointer implicit_pointer.c
+
+static __attribute__((noinline, noclone)) int foo (int i)
+{
+ int *p = &i;
+ return *p;
+}
+
+int main (void)
+{
+ return foo (23) - 23;
+}
diff --git a/tests/testfile_implicit_value.bz2 b/tests/testfile_implicit_value.bz2
new file mode 100755
index 0000000..c365a99
--- /dev/null
+++ b/tests/testfile_implicit_value.bz2
Binary files differ
diff --git a/tests/testfile_implicit_value.c b/tests/testfile_implicit_value.c
new file mode 100644
index 0000000..8885bbf
--- /dev/null
+++ b/tests/testfile_implicit_value.c
@@ -0,0 +1,12 @@
+// gcc -m32 -g -O2 -o implicit_value implicit_value.c
+
+static __attribute__((noinline, noclone)) int foo ()
+{
+ unsigned long long a[] = { 2, 21 };
+ return a[0] * a[1];
+}
+
+int main (void)
+{
+ return foo () - 42;
+}
diff --git a/tests/testfile_low_high_pc.bz2 b/tests/testfile_low_high_pc.bz2
new file mode 100755
index 0000000..f20814a
--- /dev/null
+++ b/tests/testfile_low_high_pc.bz2
Binary files differ
diff --git a/tests/testfile_multi.dwz.bz2 b/tests/testfile_multi.dwz.bz2
new file mode 100644
index 0000000..1f52fb6
--- /dev/null
+++ b/tests/testfile_multi.dwz.bz2
Binary files differ
diff --git a/tests/testfile_multi_main.bz2 b/tests/testfile_multi_main.bz2
new file mode 100755
index 0000000..bc6ca5f
--- /dev/null
+++ b/tests/testfile_multi_main.bz2
Binary files differ
diff --git a/tests/testfile_nested_funcs.bz2 b/tests/testfile_nested_funcs.bz2
new file mode 100755
index 0000000..d36b603
--- /dev/null
+++ b/tests/testfile_nested_funcs.bz2
Binary files differ
diff --git a/tests/testfile_parameter_ref.bz2 b/tests/testfile_parameter_ref.bz2
new file mode 100755
index 0000000..8ff900d
--- /dev/null
+++ b/tests/testfile_parameter_ref.bz2
Binary files differ
diff --git a/tests/testfile_parameter_ref.c b/tests/testfile_parameter_ref.c
new file mode 100644
index 0000000..7fe985f
--- /dev/null
+++ b/tests/testfile_parameter_ref.c
@@ -0,0 +1,20 @@
+// gcc -g -O2 -o parameter_ref parameter_ref.c
+
+volatile int vv;
+
+/* Don't inline, but do allow clone to create specialized versions. */
+static __attribute__((noinline)) int
+foo (int x, int y, int z)
+{
+ int a = x * 2;
+ int b = y * 2;
+ int c = z * 2;
+ vv++;
+ return x + z;
+}
+
+int
+main (int x, char **argv)
+{
+ return foo (x, 2, 3) + foo (x, 4, 3) + foo (x + 6, x, 3) + x;
+}
diff --git a/tests/testfileaarch64.bz2 b/tests/testfileaarch64.bz2
new file mode 100755
index 0000000..72e5ef0
--- /dev/null
+++ b/tests/testfileaarch64.bz2
Binary files differ
diff --git a/tests/testfilearm.bz2 b/tests/testfilearm.bz2
new file mode 100755
index 0000000..d6cd090
--- /dev/null
+++ b/tests/testfilearm.bz2
Binary files differ
diff --git a/tests/testfilebasmin.bz2 b/tests/testfilebasmin.bz2
new file mode 100755
index 0000000..3843972
--- /dev/null
+++ b/tests/testfilebasmin.bz2
Binary files differ
diff --git a/tests/testfilebaxmin.bz2 b/tests/testfilebaxmin.bz2
new file mode 100755
index 0000000..c450cc8
--- /dev/null
+++ b/tests/testfilebaxmin.bz2
Binary files differ
diff --git a/tests/testfilebazdbg.bz2 b/tests/testfilebazdbg.bz2
new file mode 100755
index 0000000..8e58636
--- /dev/null
+++ b/tests/testfilebazdbg.bz2
Binary files differ
diff --git a/tests/testfilebazdbg.debug.bz2 b/tests/testfilebazdbg.debug.bz2
new file mode 100755
index 0000000..3b01176
--- /dev/null
+++ b/tests/testfilebazdbg.debug.bz2
Binary files differ
diff --git a/tests/testfilebazdbg_pl.bz2 b/tests/testfilebazdbg_pl.bz2
new file mode 100755
index 0000000..9e06a80
--- /dev/null
+++ b/tests/testfilebazdbg_pl.bz2
Binary files differ
diff --git a/tests/testfilebazdbg_plr.bz2 b/tests/testfilebazdbg_plr.bz2
new file mode 100755
index 0000000..1bc43dd
--- /dev/null
+++ b/tests/testfilebazdbg_plr.bz2
Binary files differ
diff --git a/tests/testfilebazdbgppc64.bz2 b/tests/testfilebazdbgppc64.bz2
new file mode 100755
index 0000000..17e77d6
--- /dev/null
+++ b/tests/testfilebazdbgppc64.bz2
Binary files differ
diff --git a/tests/testfilebazdbgppc64.debug.bz2 b/tests/testfilebazdbgppc64.debug.bz2
new file mode 100755
index 0000000..8faa17a
--- /dev/null
+++ b/tests/testfilebazdbgppc64.debug.bz2
Binary files differ
diff --git a/tests/testfilebazdbgppc64_pl.bz2 b/tests/testfilebazdbgppc64_pl.bz2
new file mode 100755
index 0000000..9f372fb
--- /dev/null
+++ b/tests/testfilebazdbgppc64_pl.bz2
Binary files differ
diff --git a/tests/testfilebazdbgppc64_plr.bz2 b/tests/testfilebazdbgppc64_plr.bz2
new file mode 100755
index 0000000..70f8e00
--- /dev/null
+++ b/tests/testfilebazdbgppc64_plr.bz2
Binary files differ
diff --git a/tests/testfilebazdyn.bz2 b/tests/testfilebazdyn.bz2
new file mode 100755
index 0000000..bb623bb
--- /dev/null
+++ b/tests/testfilebazdyn.bz2
Binary files differ
diff --git a/tests/testfilebazdynppc64.bz2 b/tests/testfilebazdynppc64.bz2
new file mode 100755
index 0000000..2e01699
--- /dev/null
+++ b/tests/testfilebazdynppc64.bz2
Binary files differ
diff --git a/tests/testfilebazmdb.bz2 b/tests/testfilebazmdb.bz2
new file mode 100755
index 0000000..561eca1
--- /dev/null
+++ b/tests/testfilebazmdb.bz2
Binary files differ
diff --git a/tests/testfilebazmdbppc64.bz2 b/tests/testfilebazmdbppc64.bz2
new file mode 100755
index 0000000..16c2dd0
--- /dev/null
+++ b/tests/testfilebazmdbppc64.bz2
Binary files differ
diff --git a/tests/testfilebazmin.bz2 b/tests/testfilebazmin.bz2
new file mode 100755
index 0000000..12bcc6b
--- /dev/null
+++ b/tests/testfilebazmin.bz2
Binary files differ
diff --git a/tests/testfilebazmin_pl.bz2 b/tests/testfilebazmin_pl.bz2
new file mode 100755
index 0000000..73cef4a
--- /dev/null
+++ b/tests/testfilebazmin_pl.bz2
Binary files differ
diff --git a/tests/testfilebazmin_plr.bz2 b/tests/testfilebazmin_plr.bz2
new file mode 100755
index 0000000..e4fcf85
--- /dev/null
+++ b/tests/testfilebazmin_plr.bz2
Binary files differ
diff --git a/tests/testfilebazminppc64.bz2 b/tests/testfilebazminppc64.bz2
new file mode 100755
index 0000000..364d84c
--- /dev/null
+++ b/tests/testfilebazminppc64.bz2
Binary files differ
diff --git a/tests/testfilebazminppc64_pl.bz2 b/tests/testfilebazminppc64_pl.bz2
new file mode 100755
index 0000000..6686340
--- /dev/null
+++ b/tests/testfilebazminppc64_pl.bz2
Binary files differ
diff --git a/tests/testfilebazminppc64_plr.bz2 b/tests/testfilebazminppc64_plr.bz2
new file mode 100755
index 0000000..4610285
--- /dev/null
+++ b/tests/testfilebazminppc64_plr.bz2
Binary files differ
diff --git a/tests/testfilebaztab.bz2 b/tests/testfilebaztab.bz2
new file mode 100755
index 0000000..a99b739
--- /dev/null
+++ b/tests/testfilebaztab.bz2
Binary files differ
diff --git a/tests/testfilebaztabppc64.bz2 b/tests/testfilebaztabppc64.bz2
new file mode 100755
index 0000000..03afb8c
--- /dev/null
+++ b/tests/testfilebaztabppc64.bz2
Binary files differ
diff --git a/tests/testfiledwarfinlines.bz2 b/tests/testfiledwarfinlines.bz2
new file mode 100755
index 0000000..db14f81
--- /dev/null
+++ b/tests/testfiledwarfinlines.bz2
Binary files differ
diff --git a/tests/testfiledwarfinlines.core.bz2 b/tests/testfiledwarfinlines.core.bz2
new file mode 100644
index 0000000..2299e1e
--- /dev/null
+++ b/tests/testfiledwarfinlines.core.bz2
Binary files differ
diff --git a/tests/testfilefoobarbaz.bz2 b/tests/testfilefoobarbaz.bz2
new file mode 100755
index 0000000..0e721ff
--- /dev/null
+++ b/tests/testfilefoobarbaz.bz2
Binary files differ
diff --git a/tests/testfilegdbindex5.bz2 b/tests/testfilegdbindex5.bz2
new file mode 100755
index 0000000..45ee945
--- /dev/null
+++ b/tests/testfilegdbindex5.bz2
Binary files differ
diff --git a/tests/testfilegdbindex7.bz2 b/tests/testfilegdbindex7.bz2
new file mode 100755
index 0000000..2a7c6c2
--- /dev/null
+++ b/tests/testfilegdbindex7.bz2
Binary files differ
diff --git a/tests/testfileloc.bz2 b/tests/testfileloc.bz2
new file mode 100755
index 0000000..a436965
--- /dev/null
+++ b/tests/testfileloc.bz2
Binary files differ
diff --git a/tests/testfilemacro.bz2 b/tests/testfilemacro.bz2
new file mode 100755
index 0000000..7db51ff
--- /dev/null
+++ b/tests/testfilemacro.bz2
Binary files differ
diff --git a/tests/testfilenolines.bz2 b/tests/testfilenolines.bz2
new file mode 100755
index 0000000..23cd722
--- /dev/null
+++ b/tests/testfilenolines.bz2
Binary files differ
diff --git a/tests/testfileppc32.bz2 b/tests/testfileppc32.bz2
new file mode 100755
index 0000000..f57763a
--- /dev/null
+++ b/tests/testfileppc32.bz2
Binary files differ
diff --git a/tests/testfileppc32attrs.o.bz2 b/tests/testfileppc32attrs.o.bz2
new file mode 100644
index 0000000..c8d80a9
--- /dev/null
+++ b/tests/testfileppc32attrs.o.bz2
Binary files differ
diff --git a/tests/testfileppc64.bz2 b/tests/testfileppc64.bz2
new file mode 100755
index 0000000..870046b
--- /dev/null
+++ b/tests/testfileppc64.bz2
Binary files differ
diff --git a/tests/testfileppc64attrs.o.bz2 b/tests/testfileppc64attrs.o.bz2
new file mode 100644
index 0000000..5af2ab6
--- /dev/null
+++ b/tests/testfileppc64attrs.o.bz2
Binary files differ
diff --git a/tests/testfiles390.bz2 b/tests/testfiles390.bz2
new file mode 100755
index 0000000..14ebf6c
--- /dev/null
+++ b/tests/testfiles390.bz2
Binary files differ
diff --git a/tests/testfiles390x.bz2 b/tests/testfiles390x.bz2
new file mode 100755
index 0000000..eb63ed8
--- /dev/null
+++ b/tests/testfiles390x.bz2
Binary files differ
diff --git a/tests/testfilesparc64attrs.o.bz2 b/tests/testfilesparc64attrs.o.bz2
new file mode 100644
index 0000000..7be7f88
--- /dev/null
+++ b/tests/testfilesparc64attrs.o.bz2
Binary files differ
diff --git a/tests/testlib_dynseg.so.bz2 b/tests/testlib_dynseg.so.bz2
new file mode 100755
index 0000000..94296a4
--- /dev/null
+++ b/tests/testlib_dynseg.so.bz2
Binary files differ
diff --git a/tests/typeiter.c b/tests/typeiter.c
new file mode 100644
index 0000000..dff4526
--- /dev/null
+++ b/tests/typeiter.c
@@ -0,0 +1,90 @@
+/* Copyright (C) 2012 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 <fcntl.h>
+#include ELFUTILS_HEADER(dw)
+#include <stdio.h>
+#include <unistd.h>
+#include <dwarf.h>
+
+int
+main (int argc, char *argv[])
+{
+ for (int i = 1; i < argc; ++i)
+ {
+ int fd = open (argv[i], O_RDONLY);
+
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg != NULL)
+ {
+ Dwarf_Off off = 0;
+ size_t cuhl;
+ Dwarf_Off noff;
+
+ while (dwarf_nextcu (dbg, off, &noff, &cuhl, NULL, NULL, NULL) == 0)
+ {
+ Dwarf_Die die_mem;
+ Dwarf_Die *die = dwarf_offdie (dbg, off + cuhl, &die_mem);
+
+ Dwarf_Die iter_mem;
+ Dwarf_Die *iter = &iter_mem;
+ dwarf_child (die, &iter_mem);
+
+ while (1)
+ {
+ if (dwarf_tag (iter) == DW_TAG_variable)
+ {
+ Dwarf_Attribute attr_mem;
+ Dwarf_Die form_mem;
+ dwarf_formref_die (dwarf_attr (iter, DW_AT_type,
+ &attr_mem),
+ &form_mem);
+ }
+
+ if (dwarf_siblingof (iter, &iter_mem) != 0)
+ break;
+ }
+
+ off = noff;
+ }
+
+ off = 0;
+ uint64_t type_sig;
+
+ while (dwarf_next_unit (dbg, off, &noff, &cuhl, NULL, NULL, NULL,
+ NULL, &type_sig, NULL) == 0)
+ {
+ Dwarf_Die die_mem;
+ Dwarf_Die *die = dwarf_offdie_types (dbg, off + cuhl, &die_mem);
+
+ if (die == NULL)
+ printf ("fail\n");
+ else
+ printf ("ok\n");
+
+ off = noff;
+ }
+
+ dwarf_end (dbg);
+ }
+
+ close (fd);
+ }
+}
diff --git a/tests/typeiter2.c b/tests/typeiter2.c
new file mode 100644
index 0000000..35b6a12
--- /dev/null
+++ b/tests/typeiter2.c
@@ -0,0 +1,91 @@
+/* Copyright (C) 2012, 2013, 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 <fcntl.h>
+#include ELFUTILS_HEADER(dw)
+#include <stdio.h>
+#include <unistd.h>
+#include <dwarf.h>
+#include <inttypes.h>
+
+int
+main (int argc, char *argv[])
+{
+ for (int i = 1; i < argc; ++i)
+ {
+ int fd = open (argv[i], O_RDONLY);
+
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg != NULL)
+ {
+ Dwarf_Off off = 0;
+ size_t cuhl;
+ Dwarf_Off noff;
+ uint64_t type_sig;
+
+ while (dwarf_next_unit (dbg, off, &noff, &cuhl, NULL, NULL, NULL,
+ NULL, &type_sig, NULL) == 0)
+ {
+ Dwarf_Die die_mem;
+ dwarf_offdie_types (dbg, off + cuhl, &die_mem);
+ off = noff;
+ }
+
+ off = 0;
+
+ while (dwarf_nextcu (dbg, off, &noff, &cuhl, NULL, NULL, NULL) == 0)
+ {
+ Dwarf_Die die_mem;
+ Dwarf_Die *die = dwarf_offdie (dbg, off + cuhl, &die_mem);
+
+ Dwarf_Die iter_mem;
+ Dwarf_Die *iter = &iter_mem;
+ dwarf_child (die, &iter_mem);
+
+ while (1)
+ {
+ if (dwarf_tag (iter) == DW_TAG_variable)
+ {
+ Dwarf_Attribute attr_mem;
+ Dwarf_Die form_mem, *form;
+ form = dwarf_formref_die (dwarf_attr (iter, DW_AT_type,
+ &attr_mem),
+ &form_mem);
+
+ if (form == NULL)
+ printf ("fail\n");
+ else
+ printf ("ok %s [%" PRIx64 "]\n",
+ dwarf_diename (form), dwarf_dieoffset (form));
+ }
+
+ if (dwarf_siblingof (iter, &iter_mem) != 0)
+ break;
+ }
+
+ off = noff;
+ }
+
+ dwarf_end (dbg);
+ }
+
+ close (fd);
+ }
+}
diff --git a/tests/update1.c b/tests/update1.c
new file mode 100644
index 0000000..f4c1475
--- /dev/null
+++ b/tests/update1.c
@@ -0,0 +1,127 @@
+/* Test program for elf_update function.
+ Copyright (C) 2000, 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ 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 <errno.h>
+#include <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[] __attribute__ ((unused)))
+{
+ const char *fname = "xxx_update1";
+ int fd;
+ Elf *elf;
+ Elf32_Ehdr *ehdr;
+ int i;
+
+ fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf_version (EV_CURRENT);
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Create an ELF header. */
+ ehdr = elf32_newehdr (elf);
+ if (ehdr == NULL)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Print the ELF header values. */
+ if (argc > 1)
+ {
+ for (i = 0; i < EI_NIDENT; ++i)
+ printf (" %02x", ehdr->e_ident[i]);
+ printf ("\
+\ntype = %hu\nmachine = %hu\nversion = %u\nentry = %u\nphoff = %u\n"
+ "shoff = %u\nflags = %u\nehsize = %hu\nphentsize = %hu\n"
+ "phnum = %hu\nshentsize = %hu\nshnum = %hu\nshstrndx = %hu\n",
+ ehdr->e_type, ehdr->e_machine, ehdr->e_version, ehdr->e_entry,
+ ehdr->e_phoff, ehdr->e_shoff, ehdr->e_flags, ehdr->e_ehsize,
+ ehdr->e_phentsize, ehdr->e_phnum, ehdr->e_shentsize,
+ ehdr->e_shnum, ehdr->e_shstrndx);
+ }
+
+ ehdr->e_ident[0] = 42;
+ ehdr->e_ident[4] = 1;
+ ehdr->e_ident[5] = 1;
+ ehdr->e_ident[6] = 2;
+ ehdr->e_ident[9] = 2;
+ ehdr->e_version = 1;
+ ehdr->e_ehsize = 1;
+
+ /* Write out the file. */
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Create an ELF header. */
+ ehdr = elf32_newehdr (elf);
+ if (ehdr == NULL)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Print the ELF header values. */
+ if (argc > 1)
+ {
+ for (i = 0; i < EI_NIDENT; ++i)
+ printf (" %02x", ehdr->e_ident[i]);
+ printf ("\
+\ntype = %hu\nmachine = %hu\nversion = %u\nentry = %u\nphoff = %u\n"
+ "shoff = %u\nflags = %u\nehsize = %hu\nphentsize = %hu\n"
+ "phnum = %hu\nshentsize = %hu\nshnum = %hu\nshstrndx = %hu\n",
+ ehdr->e_type, ehdr->e_machine, ehdr->e_version, ehdr->e_entry,
+ ehdr->e_phoff, ehdr->e_shoff, ehdr->e_flags, ehdr->e_ehsize,
+ ehdr->e_phentsize, ehdr->e_phnum, ehdr->e_shentsize,
+ ehdr->e_shnum, ehdr->e_shstrndx);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ unlink (fname);
+
+ return 0;
+}
diff --git a/tests/update2.c b/tests/update2.c
new file mode 100644
index 0000000..5805163
--- /dev/null
+++ b/tests/update2.c
@@ -0,0 +1,150 @@
+/* Test program for elf_update function.
+ Copyright (C) 2000, 2002, 2005 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ 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 <errno.h>
+#include <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[] __attribute__ ((unused)))
+{
+ const char *fname = "xxx_update2";
+ int fd;
+ Elf *elf;
+ Elf32_Ehdr *ehdr;
+ Elf32_Phdr *phdr;
+ int i;
+
+ fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf_version (EV_CURRENT);
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Create an ELF header. */
+ ehdr = elf32_newehdr (elf);
+ if (ehdr == NULL)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Print the ELF header values. */
+ if (argc > 1)
+ {
+ for (i = 0; i < EI_NIDENT; ++i)
+ printf (" %02x", ehdr->e_ident[i]);
+ printf ("\
+\ntype = %hu\nmachine = %hu\nversion = %u\nentry = %u\nphoff = %u\n"
+ "shoff = %u\nflags = %u\nehsize = %hu\nphentsize = %hu\n"
+ "phnum = %hu\nshentsize = %hu\nshnum = %hu\nshstrndx = %hu\n",
+ ehdr->e_type, ehdr->e_machine, ehdr->e_version, ehdr->e_entry,
+ ehdr->e_phoff, ehdr->e_shoff, ehdr->e_flags, ehdr->e_ehsize,
+ ehdr->e_phentsize, ehdr->e_phnum, ehdr->e_shentsize,
+ ehdr->e_shnum, ehdr->e_shstrndx);
+ }
+
+ ehdr->e_ident[0] = 42;
+ ehdr->e_ident[4] = 1;
+ ehdr->e_ident[5] = 1;
+ ehdr->e_ident[6] = 2;
+ ehdr->e_type = ET_EXEC;
+ ehdr->e_version = 1;
+ ehdr->e_ehsize = 1;
+ elf_flagehdr (elf, ELF_C_SET, ELF_F_DIRTY);
+
+ /* Create the program header. */
+ phdr = elf32_newphdr (elf, 1);
+ if (phdr == NULL)
+ {
+ printf ("cannot create program header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ phdr[0].p_type = PT_PHDR;
+ elf_flagphdr (elf, ELF_C_SET, ELF_F_DIRTY);
+
+ /* Let the library compute the internal structure information. */
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in elf_update(NULL): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ ehdr = elf32_getehdr (elf);
+
+ phdr[0].p_offset = ehdr->e_phoff;
+ phdr[0].p_offset = ehdr->e_phoff;
+ phdr[0].p_vaddr = ehdr->e_phoff;
+ phdr[0].p_paddr = ehdr->e_phoff;
+ phdr[0].p_flags = PF_R | PF_X;
+ phdr[0].p_filesz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_memsz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_align = sizeof (Elf32_Word);
+
+ /* Write out the file. */
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Print the ELF header values. */
+ if (argc > 1)
+ {
+ for (i = 0; i < EI_NIDENT; ++i)
+ printf (" %02x", ehdr->e_ident[i]);
+ printf ("\
+\ntype = %hu\nmachine = %hu\nversion = %u\nentry = %u\nphoff = %u\n"
+ "shoff = %u\nflags = %u\nehsize = %hu\nphentsize = %hu\n"
+ "phnum = %hu\nshentsize = %hu\nshnum = %hu\nshstrndx = %hu\n",
+ ehdr->e_type, ehdr->e_machine, ehdr->e_version, ehdr->e_entry,
+ ehdr->e_phoff, ehdr->e_shoff, ehdr->e_flags, ehdr->e_ehsize,
+ ehdr->e_phentsize, ehdr->e_phnum, ehdr->e_shentsize,
+ ehdr->e_shnum, ehdr->e_shstrndx);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ unlink (fname);
+
+ return 0;
+}
diff --git a/tests/update3.c b/tests/update3.c
new file mode 100644
index 0000000..7a4224d
--- /dev/null
+++ b/tests/update3.c
@@ -0,0 +1,205 @@
+/* Test program for elf_update function.
+ Copyright (C) 2000, 2002, 2005, 2016 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ 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 <errno.h>
+#include <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(dwelf)
+
+
+int
+main (int argc, char *argv[] __attribute__ ((unused)))
+{
+ const char *fname = "xxx_update3";
+ int fd;
+ Elf *elf;
+ Elf32_Ehdr *ehdr;
+ Elf32_Phdr *phdr;
+ Elf_Scn *scn;
+ Elf32_Shdr *shdr;
+ Elf_Data *data;
+ Dwelf_Strtab *shst;
+ Dwelf_Strent *shstrtabse;
+ int i;
+
+ fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf_version (EV_CURRENT);
+
+ elf_fill (0x42);
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Create an ELF header. */
+ ehdr = elf32_newehdr (elf);
+ if (ehdr == NULL)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Print the ELF header values. */
+ if (argc > 1)
+ {
+ for (i = 0; i < EI_NIDENT; ++i)
+ printf (" %02x", ehdr->e_ident[i]);
+ printf ("\
+\ntype = %hu\nmachine = %hu\nversion = %u\nentry = %u\nphoff = %u\n"
+ "shoff = %u\nflags = %u\nehsize = %hu\nphentsize = %hu\n"
+ "phnum = %hu\nshentsize = %hu\nshnum = %hu\nshstrndx = %hu\n",
+ ehdr->e_type, ehdr->e_machine, ehdr->e_version, ehdr->e_entry,
+ ehdr->e_phoff, ehdr->e_shoff, ehdr->e_flags, ehdr->e_ehsize,
+ ehdr->e_phentsize, ehdr->e_phnum, ehdr->e_shentsize,
+ ehdr->e_shnum, ehdr->e_shstrndx);
+ }
+
+ ehdr->e_ident[0] = 42;
+ ehdr->e_ident[4] = 1;
+ ehdr->e_ident[5] = 1;
+ ehdr->e_ident[6] = 2;
+ ehdr->e_type = ET_EXEC;
+ ehdr->e_version = 1;
+ ehdr->e_ehsize = 1;
+ elf_flagehdr (elf, ELF_C_SET, ELF_F_DIRTY);
+
+ /* Create the program header. */
+ phdr = elf32_newphdr (elf, 1);
+ if (phdr == NULL)
+ {
+ printf ("cannot create program header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ phdr[0].p_type = PT_PHDR;
+ elf_flagphdr (elf, ELF_C_SET, ELF_F_DIRTY);
+
+ shst = dwelf_strtab_init (true);
+
+ scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ shstrtabse = dwelf_strtab_add (shst, ".shstrtab");
+
+ shdr->sh_type = SHT_STRTAB;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_addralign = 1;
+ shdr->sh_entsize = 0;
+
+ /* We have to store the section index in the ELF header. */
+ ehdr->e_shstrndx = elf_ndxscn (scn);
+
+ data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* No more sections, finalize the section header string table. */
+ dwelf_strtab_finalize (shst, data);
+
+ shdr->sh_name = dwelf_strent_off (shstrtabse);
+
+ /* Let the library compute the internal structure information. */
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in elf_update(NULL): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ ehdr = elf32_getehdr (elf);
+
+ phdr[0].p_offset = ehdr->e_phoff;
+ phdr[0].p_offset = ehdr->e_phoff;
+ phdr[0].p_vaddr = ehdr->e_phoff;
+ phdr[0].p_paddr = ehdr->e_phoff;
+ phdr[0].p_flags = PF_R | PF_X;
+ phdr[0].p_filesz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_memsz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_align = sizeof (Elf32_Word);
+
+ /* Write out the file. */
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* We don't need the string table anymore. */
+ dwelf_strtab_free (shst);
+
+ /* And the data allocated in the .shstrtab section. */
+ free (data->d_buf);
+
+ /* Print the ELF header values. */
+ if (argc > 1)
+ {
+ for (i = 0; i < EI_NIDENT; ++i)
+ printf (" %02x", ehdr->e_ident[i]);
+ printf ("\
+\ntype = %hu\nmachine = %hu\nversion = %u\nentry = %u\nphoff = %u\n"
+ "shoff = %u\nflags = %u\nehsize = %hu\nphentsize = %hu\n"
+ "phnum = %hu\nshentsize = %hu\nshnum = %hu\nshstrndx = %hu\n",
+ ehdr->e_type, ehdr->e_machine, ehdr->e_version, ehdr->e_entry,
+ ehdr->e_phoff, ehdr->e_shoff, ehdr->e_flags, ehdr->e_ehsize,
+ ehdr->e_phentsize, ehdr->e_phnum, ehdr->e_shentsize,
+ ehdr->e_shnum, ehdr->e_shstrndx);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ unlink (fname);
+
+ return 0;
+}
diff --git a/tests/update4.c b/tests/update4.c
new file mode 100644
index 0000000..a9bd4bf
--- /dev/null
+++ b/tests/update4.c
@@ -0,0 +1,357 @@
+/* Test program for elf_update function.
+ Copyright (C) 2000, 2001, 2002, 2005, 2016 Red Hat, Inc.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ 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 <errno.h>
+#include <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(dwelf)
+
+
+int
+main (int argc, char *argv[] __attribute__ ((unused)))
+{
+ const char fname[] = "xxx_update4";
+ int fd;
+ Elf *elf;
+ Elf32_Ehdr *ehdr;
+ Elf32_Phdr *phdr;
+ Elf_Scn *scn;
+ Elf32_Shdr *shdr;
+ Elf_Data *data;
+ Dwelf_Strtab *shst;
+ Dwelf_Strent *firstse;
+ Dwelf_Strent *secondse;
+ Dwelf_Strent *thirdse;
+ Dwelf_Strent *fourthse;
+ Dwelf_Strent *shstrtabse;
+ int i;
+
+ fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf_version (EV_CURRENT);
+
+ elf_fill (0x42);
+
+ elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Create an ELF header. */
+ ehdr = elf32_newehdr (elf);
+ if (ehdr == NULL)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Print the ELF header values. */
+ if (argc > 1)
+ {
+ for (i = 0; i < EI_NIDENT; ++i)
+ printf (" %02x", ehdr->e_ident[i]);
+ printf ("\
+\ntype = %hu\nmachine = %hu\nversion = %u\nentry = %u\nphoff = %u\n"
+ "shoff = %u\nflags = %u\nehsize = %hu\nphentsize = %hu\n"
+ "phnum = %hu\nshentsize = %hu\nshnum = %hu\nshstrndx = %hu\n",
+ ehdr->e_type, ehdr->e_machine, ehdr->e_version, ehdr->e_entry,
+ ehdr->e_phoff, ehdr->e_shoff, ehdr->e_flags, ehdr->e_ehsize,
+ ehdr->e_phentsize, ehdr->e_phnum, ehdr->e_shentsize,
+ ehdr->e_shnum, ehdr->e_shstrndx);
+ }
+
+ ehdr->e_ident[0] = 42;
+ ehdr->e_ident[4] = 1;
+ ehdr->e_ident[5] = 1;
+ ehdr->e_ident[6] = 2;
+ ehdr->e_type = ET_EXEC;
+ ehdr->e_version = 1;
+ ehdr->e_ehsize = 1;
+ elf_flagehdr (elf, ELF_C_SET, ELF_F_DIRTY);
+
+ /* Create the program header. */
+ phdr = elf32_newphdr (elf, 1);
+ if (phdr == NULL)
+ {
+ printf ("cannot create program header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ phdr[0].p_type = PT_PHDR;
+ elf_flagphdr (elf, ELF_C_SET, ELF_F_DIRTY);
+
+ shst = dwelf_strtab_init (true);
+
+ scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create first section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for first section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ firstse = dwelf_strtab_add (shst, ".first");
+
+ shdr->sh_type = SHT_PROGBITS;
+ shdr->sh_flags = SHF_ALLOC | SHF_EXECINSTR;
+ shdr->sh_addr = 0;
+ shdr->sh_link = 0;
+ shdr->sh_info = 0;
+ shdr->sh_entsize = 1;
+
+ data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data first section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = "hello";
+ data->d_type = ELF_T_BYTE;
+ data->d_version = EV_CURRENT;
+ data->d_size = 5;
+ data->d_align = 16;
+
+
+ scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create second section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for second section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ secondse = dwelf_strtab_add (shst, ".second");
+
+ shdr->sh_type = SHT_PROGBITS;
+ shdr->sh_flags = SHF_ALLOC | SHF_WRITE;
+ shdr->sh_addr = 0;
+ shdr->sh_link = 0;
+ shdr->sh_info = 0;
+ shdr->sh_entsize = 1;
+
+ data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data second section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = "world";
+ data->d_type = ELF_T_BYTE;
+ data->d_version = EV_CURRENT;
+ data->d_size = 5;
+ data->d_align = 16;
+
+
+ scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create third section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for third section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ thirdse = dwelf_strtab_add (shst, ".third");
+
+ shdr->sh_type = SHT_PROGBITS;
+ shdr->sh_flags = SHF_ALLOC | SHF_EXECINSTR;
+ shdr->sh_addr = 0;
+ shdr->sh_link = 0;
+ shdr->sh_info = 0;
+ shdr->sh_entsize = 1;
+
+ data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data third section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = "!!!!!";
+ data->d_type = ELF_T_BYTE;
+ data->d_version = EV_CURRENT;
+ data->d_size = 5;
+ data->d_align = 16;
+
+
+ scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create fourth section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for fourth section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ fourthse = dwelf_strtab_add (shst, ".fourth");
+
+ shdr->sh_type = SHT_NOBITS;
+ shdr->sh_flags = SHF_ALLOC | SHF_EXECINSTR;
+ shdr->sh_addr = 0;
+ shdr->sh_link = 0;
+ shdr->sh_info = 0;
+ shdr->sh_entsize = 1;
+ shdr->sh_size = 100;
+
+ data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data fourth section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = NULL;
+ data->d_type = ELF_T_BYTE;
+ data->d_version = EV_CURRENT;
+ data->d_size = 100;
+ data->d_align = 16;
+
+
+ scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ shstrtabse = dwelf_strtab_add (shst, ".shstrtab");
+
+ shdr->sh_type = SHT_STRTAB;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_entsize = 1;
+
+ /* We have to store the section index in the ELF header. */
+ ehdr->e_shstrndx = elf_ndxscn (scn);
+
+ data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* No more sections, finalize the section header string table. */
+ dwelf_strtab_finalize (shst, data);
+
+ elf32_getshdr (elf_getscn (elf, 1))->sh_name = dwelf_strent_off (firstse);
+ elf32_getshdr (elf_getscn (elf, 2))->sh_name = dwelf_strent_off (secondse);
+ elf32_getshdr (elf_getscn (elf, 3))->sh_name = dwelf_strent_off (thirdse);
+ elf32_getshdr (elf_getscn (elf, 4))->sh_name = dwelf_strent_off (fourthse);
+ shdr->sh_name = dwelf_strent_off (shstrtabse);
+
+ /* Let the library compute the internal structure information. */
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in elf_update(NULL): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ ehdr = elf32_getehdr (elf);
+
+ phdr[0].p_offset = ehdr->e_phoff;
+ phdr[0].p_offset = ehdr->e_phoff;
+ phdr[0].p_vaddr = ehdr->e_phoff;
+ phdr[0].p_paddr = ehdr->e_phoff;
+ phdr[0].p_flags = PF_R | PF_X;
+ phdr[0].p_filesz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_memsz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_align = sizeof (Elf32_Word);
+
+ /* Write out the file. */
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* We don't need the string table anymore. */
+ dwelf_strtab_free (shst);
+
+ /* And the data allocated in the .shstrtab section. */
+ free (data->d_buf);
+
+ /* Print the ELF header values. */
+ if (argc > 1)
+ {
+ for (i = 0; i < EI_NIDENT; ++i)
+ printf (" %02x", ehdr->e_ident[i]);
+ printf ("\
+\ntype = %hu\nmachine = %hu\nversion = %u\nentry = %u\nphoff = %u\n"
+ "shoff = %u\nflags = %u\nehsize = %hu\nphentsize = %hu\n"
+ "phnum = %hu\nshentsize = %hu\nshnum = %hu\nshstrndx = %hu\n",
+ ehdr->e_type, ehdr->e_machine, ehdr->e_version, ehdr->e_entry,
+ ehdr->e_phoff, ehdr->e_shoff, ehdr->e_flags, ehdr->e_ehsize,
+ ehdr->e_phentsize, ehdr->e_phnum, ehdr->e_shentsize,
+ ehdr->e_shnum, ehdr->e_shstrndx);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ unlink (fname);
+
+ return 0;
+}
diff --git a/tests/varlocs.c b/tests/varlocs.c
new file mode 100644
index 0000000..0e43229
--- /dev/null
+++ b/tests/varlocs.c
@@ -0,0 +1,1074 @@
+/* Test program for dwarf location functions.
+ Copyright (C) 2013, 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <argp.h>
+#include <inttypes.h>
+#include <errno.h>
+#include ELFUTILS_HEADER(dw)
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <error.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "../libdw/known-dwarf.h"
+
+// The Dwarf, Dwarf_CFIs and address bias of
+// cfi table to adjust DWARF addresses against.
+// Needed for DW_OP_call_frame_cfa.
+static Dwarf *dw;
+Dwarf_CFI *cfi_debug;
+Dwarf_Addr cfi_debug_bias;
+Dwarf_CFI *cfi_eh;
+Dwarf_Addr cfi_eh_bias;
+
+bool is_ET_REL;
+
+// Whether the current function has a DW_AT_frame_base defined.
+// Needed for DW_OP_fbreg.
+bool has_frame_base;
+
+static void
+print_die (Dwarf_Die *die, const char *what, int indent)
+{
+ Dwarf_Addr entrypc;
+ const char *name = dwarf_diename (die) ?: "<unknown>";
+ if (dwarf_entrypc (die, &entrypc) == 0)
+ printf ("%*s[%" PRIx64 "] %s '%s'@%" PRIx64 "\n", indent * 2, "",
+ dwarf_dieoffset (die), what, name, entrypc);
+ else
+ printf ("%*s[%" PRIx64 "] %s '%s'\n", indent * 2, "",
+ dwarf_dieoffset (die), what, name);
+}
+
+static const char *
+dwarf_encoding_string (unsigned int code)
+{
+ static const char *const known[] =
+ {
+#define DWARF_ONE_KNOWN_DW_ATE(NAME, CODE) [CODE] = #NAME,
+ DWARF_ALL_KNOWN_DW_ATE
+#undef DWARF_ONE_KNOWN_DW_ATE
+ };
+
+ if (likely (code < sizeof (known) / sizeof (known[0])))
+ return known[code];
+
+ return NULL;
+}
+
+static const char *
+dwarf_tag_string (unsigned int tag)
+{
+ switch (tag)
+ {
+#define DWARF_ONE_KNOWN_DW_TAG(NAME, CODE) case CODE: return #NAME;
+ DWARF_ALL_KNOWN_DW_TAG
+#undef DWARF_ONE_KNOWN_DW_TAG
+ default:
+ return NULL;
+ }
+}
+
+static const char *
+dwarf_attr_string (unsigned int attrnum)
+{
+ switch (attrnum)
+ {
+#define DWARF_ONE_KNOWN_DW_AT(NAME, CODE) case CODE: return #NAME;
+ DWARF_ALL_KNOWN_DW_AT
+#undef DWARF_ONE_KNOWN_DW_AT
+ default:
+ return NULL;
+ }
+}
+
+static const char *
+dwarf_form_string (unsigned int form)
+{
+ switch (form)
+ {
+#define DWARF_ONE_KNOWN_DW_FORM(NAME, CODE) case CODE: return #NAME;
+ DWARF_ALL_KNOWN_DW_FORM
+#undef DWARF_ONE_KNOWN_DW_FORM
+ default:
+ return NULL;
+ }
+}
+
+/* BASE must be a base type DIE referenced by a typed DWARF expression op. */
+static void
+print_base_type (Dwarf_Die *base)
+{
+ assert (dwarf_tag (base) == DW_TAG_base_type);
+
+ Dwarf_Attribute encoding;
+ Dwarf_Word enctype = 0;
+ if (dwarf_attr (base, DW_AT_encoding, &encoding) == NULL
+ || dwarf_formudata (&encoding, &enctype) != 0)
+ error (EXIT_FAILURE, 0, "base type without encoding");
+
+ Dwarf_Attribute bsize;
+ Dwarf_Word bits;
+ if (dwarf_attr (base, DW_AT_byte_size, &bsize) != NULL
+ && dwarf_formudata (&bsize, &bits) == 0)
+ bits *= 8;
+ else if (dwarf_attr (base, DW_AT_bit_size, &bsize) == NULL
+ || dwarf_formudata (&bsize, &bits) != 0)
+ error (EXIT_FAILURE, 0, "base type without byte or bit size");
+
+ printf ("{%s,%s,%" PRIu64 "@[%" PRIx64 "]}",
+ dwarf_diename (base),
+ dwarf_encoding_string (enctype),
+ bits,
+ dwarf_dieoffset (base));
+}
+
+static const char *
+dwarf_opcode_string (unsigned int code)
+{
+ static const char *const known[] =
+ {
+#define DWARF_ONE_KNOWN_DW_OP(NAME, CODE) [CODE] = #NAME,
+ DWARF_ALL_KNOWN_DW_OP
+#undef DWARF_ONE_KNOWN_DW_OP
+ };
+
+ if (likely (code < sizeof (known) / sizeof (known[0])))
+ return known[code];
+
+ return NULL;
+}
+
+// Forward reference for print_expr_block.
+static void print_expr (Dwarf_Attribute *, Dwarf_Op *, Dwarf_Addr);
+
+static void
+print_expr_block (Dwarf_Attribute *attr, Dwarf_Op *exprs, int len,
+ Dwarf_Addr addr)
+{
+ printf ("{");
+ for (int i = 0; i < len; i++)
+ {
+ print_expr (attr, &exprs[i], addr);
+ printf ("%s", (i + 1 < len ? ", " : ""));
+ }
+ printf ("}");
+}
+
+static void
+print_expr_block_addrs (Dwarf_Attribute *attr,
+ Dwarf_Addr begin, Dwarf_Addr end,
+ Dwarf_Op *exprs, int len)
+{
+ printf (" [%" PRIx64 ",%" PRIx64 ") ", begin, end);
+ print_expr_block (attr, exprs, len, begin);
+ printf ("\n");
+}
+
+static void
+print_expr (Dwarf_Attribute *attr, Dwarf_Op *expr, Dwarf_Addr addr)
+{
+ uint8_t atom = expr->atom;
+ const char *opname = dwarf_opcode_string (atom);
+ assert (opname != NULL);
+
+ switch (atom)
+ {
+ case DW_OP_deref:
+ case DW_OP_dup:
+ case DW_OP_drop:
+ case DW_OP_over:
+ case DW_OP_swap:
+ case DW_OP_rot:
+ case DW_OP_xderef:
+ case DW_OP_abs:
+ case DW_OP_and:
+ case DW_OP_div:
+ case DW_OP_minus:
+ case DW_OP_mod:
+ case DW_OP_mul:
+ case DW_OP_neg:
+ case DW_OP_not:
+ case DW_OP_or:
+ case DW_OP_plus:
+ case DW_OP_shl:
+ case DW_OP_shr:
+ case DW_OP_shra:
+ case DW_OP_xor:
+ case DW_OP_eq:
+ case DW_OP_ge:
+ case DW_OP_gt:
+ case DW_OP_le:
+ case DW_OP_lt:
+ case DW_OP_ne:
+ case DW_OP_lit0 ... DW_OP_lit31:
+ case DW_OP_reg0 ... DW_OP_reg31:
+ case DW_OP_nop:
+ case DW_OP_stack_value:
+ /* No arguments. */
+ printf ("%s", opname);
+ break;
+
+ case DW_OP_form_tls_address:
+ /* No arguments. Special. Pops an address and pushes the
+ corresponding address in the current thread local
+ storage. Uses the thread local storage block of the defining
+ module (executable, shared library). */
+ printf ("%s", opname);
+ break;
+
+ case DW_OP_GNU_push_tls_address:
+ /* No arguments. Special. Not the same as DW_OP_form_tls_address.
+ Pops an offset into the current thread local strorage and
+ pushes back the actual address. */
+ printf ("%s", opname);
+ break;
+
+ case DW_OP_call_frame_cfa:
+ /* No arguments. Special. Pushes Call Frame Address as computed
+ by CFI data (dwarf_cfi_addrframe will fetch that info (either from
+ the .eh_frame or .debug_frame CFI) and dwarf_frame_cfa translatesr
+ the CFI instructions into a plain DWARF expression.
+ Never used in CFI itself. */
+
+ if (attr == NULL)
+ error (EXIT_FAILURE, 0, "%s used in CFI", opname);
+
+ printf ("%s ", opname);
+ if (cfi_eh == NULL && cfi_debug == NULL)
+ error (EXIT_FAILURE, 0, "DW_OP_call_frame_cfa used but no cfi found.");
+
+ Dwarf_Frame *frame;
+ if (dwarf_cfi_addrframe (cfi_eh, addr + cfi_eh_bias, &frame) == 0
+ || dwarf_cfi_addrframe (cfi_debug, addr + cfi_debug_bias,
+ &frame) == 0)
+ {
+ Dwarf_Op *cfa_ops;
+ size_t cfa_nops;
+ if (dwarf_frame_cfa (frame, &cfa_ops, &cfa_nops) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_frame_cfa 0x%" PRIx64 ": %s",
+ addr, dwarf_errmsg (-1));
+ if (cfa_nops < 1)
+ error (EXIT_FAILURE, 0, "dwarf_frame_cfa no ops");
+ print_expr_block (NULL, cfa_ops, cfa_nops, 0);
+ free (frame);
+ }
+ else if (is_ET_REL)
+ {
+ /* XXX In ET_REL files there might be an .eh_frame with relocations
+ we don't handle (e.g. X86_64_PC32). Maybe we should? */
+ printf ("{...}\n");
+ }
+ else
+ error (EXIT_FAILURE, 0, "dwarf_cfi_addrframe 0x%" PRIx64 ": %s",
+ addr, dwarf_errmsg (-1));
+ break;
+
+ case DW_OP_push_object_address:
+ /* No arguments. Special. Pushes object address explicitly.
+ Normally only done implicitly by DW_AT_data_member_location.
+ Never used in CFI. */
+ if (attr == NULL)
+ error (EXIT_FAILURE, 0, "%s used in CFI", opname);
+ printf ("%s", opname);
+ break;
+
+ case DW_OP_addr:
+ /* 1 address argument. */
+ printf ("%s(0x%" PRIx64 ")", opname, (Dwarf_Addr) expr->number);
+ break;
+
+ case DW_OP_const1u:
+ case DW_OP_const2u:
+ case DW_OP_const4u:
+ case DW_OP_const8u:
+ case DW_OP_constu:
+ case DW_OP_pick:
+ case DW_OP_plus_uconst:
+ case DW_OP_regx:
+ case DW_OP_piece:
+ case DW_OP_deref_size:
+ case DW_OP_xderef_size:
+ /* 1 numeric unsigned argument. */
+ printf ("%s(%" PRIu64 ")", opname, expr->number);
+ break;
+
+ case DW_OP_call2:
+ case DW_OP_call4:
+ case DW_OP_call_ref:
+ /* 1 DIE offset argument for more ops in location attribute of DIE.
+ Never used in CFI. */
+ {
+ if (attr == NULL)
+ error (EXIT_FAILURE, 0, "%s used in CFI", opname);
+
+ Dwarf_Attribute call_attr;
+ if (dwarf_getlocation_attr (attr, expr, &call_attr) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_attr for %s error %s",
+ opname, dwarf_errmsg (-1));
+
+ Dwarf_Die call_die;
+ if (dwarf_getlocation_die (attr, expr, &call_die) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_die for %s error %s",
+ opname, dwarf_errmsg (-1));
+
+ Dwarf_Op *call_ops;
+ size_t call_len;
+ if (dwarf_getlocation (&call_attr, &call_ops, &call_len) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation for entry: %s",
+ dwarf_errmsg (-1));
+
+ printf ("%s([%" PRIx64 "]) ", opname, dwarf_dieoffset (&call_die));
+ print_expr_block (&call_attr, call_ops, call_len, addr);
+ }
+ break;
+
+ case DW_OP_const1s:
+ case DW_OP_const2s:
+ case DW_OP_const4s:
+ case DW_OP_const8s:
+ case DW_OP_consts:
+ case DW_OP_skip:
+ case DW_OP_bra:
+ case DW_OP_breg0 ... DW_OP_breg31:
+ /* 1 numeric signed argument. */
+ printf ("%s(%" PRId64 ")", opname, (Dwarf_Sword) expr->number);
+ break;
+
+ case DW_OP_fbreg:
+ /* 1 numeric signed argument. Offset from frame base. */
+ if (attr == NULL)
+ error (EXIT_FAILURE, 0, "%s used in CFI", opname);
+
+ if (! has_frame_base)
+ error (EXIT_FAILURE, 0, "DW_OP_fbreg used without a frame base");
+
+ printf ("%s(%" PRId64 ")", opname, (Dwarf_Sword) expr->number);
+ break;
+
+ case DW_OP_bregx:
+ /* 2 arguments, unsigned register number, signed offset. */
+ printf ("%s(%" PRIu64 ",%" PRId64 ")", opname,
+ expr->number, (Dwarf_Sword) expr->number2);
+ break;
+
+ case DW_OP_bit_piece:
+ /* 2 arguments, unsigned size, unsigned offset. */
+ printf ("%s(%" PRIu64 ",%" PRIu64 ")", opname,
+ expr->number, expr->number2);
+ break;
+
+ case DW_OP_implicit_value:
+ /* Special, unsigned size plus block. */
+ {
+ Dwarf_Attribute const_attr;
+ Dwarf_Block block;
+ if (dwarf_getlocation_attr (attr, expr, &const_attr) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_attr: %s",
+ dwarf_errmsg (-1));
+
+ if (dwarf_formblock (&const_attr, &block) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_formblock: %s",
+ dwarf_errmsg (-1));
+
+ /* This is the "old" way. Check they result in the same. */
+ Dwarf_Block block_impl;
+ if (dwarf_getlocation_implicit_value (attr, expr, &block_impl) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_implicit_value: %s",
+ dwarf_errmsg (-1));
+
+ assert (expr->number == block.length);
+ assert (block.length == block_impl.length);
+ printf ("%s(%" PRIu64 "){", opname, block.length);
+ for (size_t i = 0; i < block.length; i++)
+ {
+ printf ("%02x", block.data[i]);
+ assert (block.data[i] == block_impl.data[i]);
+ }
+ printf("}");
+ }
+ break;
+
+ case DW_OP_GNU_implicit_pointer:
+ /* Special, DIE offset, signed offset. Referenced DIE has a
+ location or const_value attribute. */
+ {
+ if (attr == NULL)
+ error (EXIT_FAILURE, 0, "%s used in CFI", opname);
+
+ Dwarf_Attribute attrval;
+ if (dwarf_getlocation_implicit_pointer (attr, expr, &attrval) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_implicit_pointer: %s",
+ dwarf_errmsg (-1));
+
+ // Sanity check, results should be the same.
+ Dwarf_Attribute attrval2;
+ if (dwarf_getlocation_attr (attr, expr, &attrval2) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_attr: %s",
+ dwarf_errmsg (-1));
+
+ assert (dwarf_whatattr (&attrval) == dwarf_whatattr (&attrval2));
+ assert (dwarf_whatform (&attrval) == dwarf_whatform (&attrval2));
+ // In theory two different valp pointers could point to the same
+ // value. But here we really expect them to be the equal.
+ assert (attrval.valp == attrval2.valp);
+
+ Dwarf_Die impl_die;
+ if (dwarf_getlocation_die (attr, expr, &impl_die) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_die: %s",
+ dwarf_errmsg (-1));
+
+ printf ("%s([%" PRIx64 "],%" PRId64 ") ", opname,
+ dwarf_dieoffset (&impl_die), expr->number2);
+
+ if (dwarf_whatattr (&attrval) == DW_AT_const_value)
+ printf ("<constant value>"); // Lookup type...
+ else
+ {
+ // Lookup the location description at the current address.
+ Dwarf_Op *exprval;
+ size_t exprval_len;
+ int locs = dwarf_getlocation_addr (&attrval, addr,
+ &exprval, &exprval_len, 1);
+ if (locs == 0)
+ printf ("<no location>"); // This means "optimized out".
+ else if (locs == 1)
+ print_expr_block (&attrval, exprval, exprval_len, addr);
+ else
+ error (EXIT_FAILURE, 0,
+ "dwarf_getlocation_addr attrval at addr 0x%" PRIx64
+ ", locs (%d): %s", addr, locs, dwarf_errmsg (-1));
+ }
+ }
+ break;
+
+ case DW_OP_GNU_variable_value:
+ /* Special, DIE offset. Referenced DIE has a location or const_value
+ attribute. */
+ {
+ if (attr == NULL)
+ error (EXIT_FAILURE, 0, "%s used in CFI", opname);
+
+ Dwarf_Attribute attrval;
+ if (dwarf_getlocation_attr (attr, expr, &attrval) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_attr: %s",
+ dwarf_errmsg (-1));
+
+ Dwarf_Die impl_die;
+ if (dwarf_getlocation_die (attr, expr, &impl_die) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_die: %s",
+ dwarf_errmsg (-1));
+
+ printf ("%s([%" PRIx64 "]) ", opname, dwarf_dieoffset (&impl_die));
+
+ if (dwarf_whatattr (&attrval) == DW_AT_const_value)
+ printf ("<constant value>"); // Lookup type...
+ else
+ {
+ // Lookup the location description at the current address.
+ Dwarf_Op *exprval;
+ size_t exprval_len;
+ int locs = dwarf_getlocation_addr (&attrval, addr,
+ &exprval, &exprval_len, 1);
+ if (locs == 0)
+ printf ("<no location>"); // This means "optimized out".
+ else if (locs == 1)
+ print_expr_block (&attrval, exprval, exprval_len, addr);
+ else
+ error (EXIT_FAILURE, 0,
+ "dwarf_getlocation_addr attrval at addr 0x%" PRIx64
+ ", locs (%d): %s", addr, locs, dwarf_errmsg (-1));
+ }
+ }
+ break;
+
+ case DW_OP_GNU_entry_value:
+ /* Special, unsigned size plus expression block. All registers
+ inside the block should be interpreted as they had on
+ entering the function. dwarf_getlocation_attr will return an
+ attribute containing the block as locexpr which can be
+ retrieved with dwarf_getlocation. */
+ {
+ Dwarf_Attribute entry_attr;
+ if (dwarf_getlocation_attr (attr, expr, &entry_attr) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_attr: %s",
+ dwarf_errmsg (-1));
+
+ Dwarf_Op *entry_ops;
+ size_t entry_len;
+ if (dwarf_getlocation (&entry_attr, &entry_ops, &entry_len) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation for entry: %s",
+ dwarf_errmsg (-1));
+
+ printf ("%s(%zd) ", opname, entry_len);
+ print_expr_block (attr, entry_ops, entry_len, addr);
+ }
+ break;
+
+ case DW_OP_GNU_parameter_ref:
+ /* Special, unsigned CU relative DIE offset pointing to a
+ DW_TAG_formal_parameter. The value that parameter had at the
+ call site of the current function will be put on the DWARF
+ stack. The value can be retrieved by finding the
+ DW_TAG_GNU_call_site_parameter which has as
+ DW_AT_abstract_origin the same formal parameter DIE. */
+ {
+ Dwarf_Die param;
+ if (dwarf_getlocation_die (attr, expr, ¶m) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_die: %s",
+ dwarf_errmsg (-1));
+ // XXX actually lookup DW_TAG_GNU_call_site_parameter
+ printf ("%s[%" PRIx64 "]", opname, dwarf_dieoffset (¶m));
+ assert (expr->number == dwarf_cuoffset (¶m));
+ assert (dwarf_tag (¶m) == DW_TAG_formal_parameter);
+ }
+ break;
+
+ case DW_OP_GNU_convert:
+ case DW_OP_GNU_reinterpret:
+ /* Special, unsigned CU relative DIE offset pointing to a
+ DW_TAG_base_type. Pops a value, converts or reinterprets the
+ value to the given type. When the argument is zero the value
+ becomes untyped again. */
+ {
+ Dwarf_Die type;
+ Dwarf_Off off = expr->number;
+ if (off != 0)
+ {
+ if (dwarf_getlocation_die (attr, expr, &type) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_die: %s",
+ dwarf_errmsg (-1));
+ off = dwarf_dieoffset (&type);
+ assert (expr->number == dwarf_cuoffset (&type));
+ printf ("%s", opname);
+ print_base_type (&type);
+ }
+ else
+ printf ("%s[%" PRIu64 "]", opname, off);
+
+ }
+ break;
+
+ case DW_OP_GNU_regval_type:
+ /* Special, unsigned register number plus unsigned CU relative
+ DIE offset pointing to a DW_TAG_base_type. */
+ {
+ Dwarf_Die type;
+ if (dwarf_getlocation_die (attr, expr, &type) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_die: %s",
+ dwarf_errmsg (-1));
+ assert (expr->number2 == dwarf_cuoffset (&type));
+ // XXX check size against base_type size?
+ printf ("%s(reg%" PRIu64 ")", opname, expr->number);
+ print_base_type (&type);
+ }
+ break;
+
+ case DW_OP_GNU_deref_type:
+ /* Special, unsigned size plus unsigned CU relative DIE offset
+ pointing to a DW_TAG_base_type. */
+ {
+ Dwarf_Die type;
+ if (dwarf_getlocation_die (attr, expr, &type) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_die: %s",
+ dwarf_errmsg (-1));
+ assert (expr->number2 == dwarf_cuoffset (&type));
+ // XXX check size against base_type size?
+ printf ("%s(%" PRIu64 ")", opname, expr->number);
+ print_base_type (&type);
+ }
+ break;
+
+ case DW_OP_GNU_const_type:
+ /* Special, unsigned CU relative DIE offset pointing to a
+ DW_TAG_base_type, an unsigned size length plus a block with
+ the constant value. */
+ {
+ Dwarf_Die type;
+ if (dwarf_getlocation_die (attr, expr, &type) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_die: %s",
+ dwarf_errmsg (-1));
+ assert (expr->number == dwarf_cuoffset (&type));
+
+ Dwarf_Attribute const_attr;
+ if (dwarf_getlocation_attr (attr, expr, &const_attr) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocation_attr for type: %s",
+ dwarf_errmsg (-1));
+
+ Dwarf_Block block;
+ if (dwarf_formblock (&const_attr, &block) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_formblock for type: %s",
+ dwarf_errmsg (-1));
+
+ printf ("%s", opname);
+ print_base_type (&type);
+ printf ("(%" PRIu64 ")[", block.length);
+ for (size_t i = 0; i < block.length; i++)
+ printf ("%02x", block.data[i]);
+ printf("]");
+ }
+ break;
+
+ default:
+ error (EXIT_FAILURE, 0, "unhandled opcode: DW_OP_%s (0x%x)",
+ opname, atom);
+ }
+}
+
+/* Get all variables and print their value expressions. */
+static void
+print_varlocs (Dwarf_Die *funcdie)
+{
+ // Display frame base for function if it exists.
+ // Should be used for DW_OP_fbreg.
+ has_frame_base = dwarf_hasattr (funcdie, DW_AT_frame_base);
+ if (has_frame_base)
+ {
+ Dwarf_Attribute fb_attr;
+ if (dwarf_attr (funcdie, DW_AT_frame_base, &fb_attr) == NULL)
+ error (EXIT_FAILURE, 0, "dwarf_attr fb: %s", dwarf_errmsg (-1));
+
+ Dwarf_Op *fb_expr;
+ size_t fb_exprlen;
+ if (dwarf_getlocation (&fb_attr, &fb_expr, &fb_exprlen) == 0)
+ {
+ // Covers all of function.
+ Dwarf_Addr entrypc;
+ if (dwarf_entrypc (funcdie, &entrypc) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_entrypc: %s", dwarf_errmsg (-1));
+
+ printf (" frame_base: ");
+ if (entrypc == 0)
+ printf ("XXX zero address"); // XXX bad DWARF?
+ else
+ print_expr_block (&fb_attr, fb_expr, fb_exprlen, entrypc);
+ printf ("\n");
+ }
+ else
+ {
+ Dwarf_Addr base, start, end;
+ ptrdiff_t off = 0;
+ printf (" frame_base:\n");
+ while ((off = dwarf_getlocations (&fb_attr, off, &base,
+ &start, &end,
+ &fb_expr, &fb_exprlen)) > 0)
+ {
+ printf (" (%" PRIx64 ",%" PRIx64 ") ", start, end);
+ print_expr_block (&fb_attr, fb_expr, fb_exprlen, start);
+ printf ("\n");
+ }
+
+ if (off < 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocations fb: %s",
+ dwarf_errmsg (-1));
+ }
+ }
+ else if (dwarf_tag (funcdie) == DW_TAG_inlined_subroutine)
+ {
+ // See whether the subprogram we are inlined into has a frame
+ // base we should use.
+ Dwarf_Die *scopes;
+ int n = dwarf_getscopes_die (funcdie, &scopes);
+ if (n <= 0)
+ error (EXIT_FAILURE, 0, "dwarf_getscopes_die: %s", dwarf_errmsg (-1));
+
+ while (n-- > 0)
+ if (dwarf_tag (&scopes[n]) == DW_TAG_subprogram
+ && dwarf_hasattr (&scopes[n], DW_AT_frame_base))
+ {
+ has_frame_base = true;
+ break;
+ }
+ free (scopes);
+ }
+
+ if (! dwarf_haschildren (funcdie))
+ return;
+
+ Dwarf_Die child;
+ int res = dwarf_child (funcdie, &child);
+ if (res < 0)
+ error (EXIT_FAILURE, 0, "dwarf_child: %s", dwarf_errmsg (-1));
+
+ /* We thought there was a child, but the child list was actually
+ empty. This isn't technically an error in the DWARF, but it is
+ certainly non-optimimal. */
+ if (res == 1)
+ return;
+
+ do
+ {
+ int tag = dwarf_tag (&child);
+ if (tag == DW_TAG_variable || tag == DW_TAG_formal_parameter)
+ {
+ const char *what = tag == DW_TAG_variable ? "variable" : "parameter";
+ print_die (&child, what, 2);
+
+ if (dwarf_hasattr (&child, DW_AT_location))
+ {
+ Dwarf_Attribute attr;
+ if (dwarf_attr (&child, DW_AT_location, &attr) == NULL)
+ error (EXIT_FAILURE, 0, "dwarf_attr: %s", dwarf_errmsg (-1));
+
+ Dwarf_Op *expr;
+ size_t exprlen;
+ if (dwarf_getlocation (&attr, &expr, &exprlen) == 0)
+ {
+ // Covers all ranges of the function.
+ // Evaluate the expression block for each range.
+ ptrdiff_t offset = 0;
+ Dwarf_Addr base, begin, end;
+ do
+ {
+ offset = dwarf_ranges (funcdie, offset, &base,
+ &begin, &end);
+ if (offset < 0)
+ error (EXIT_FAILURE, 0, "dwarf_ranges: %s",
+ dwarf_errmsg (-1));
+
+ if (offset > 0)
+ {
+ if (exprlen == 0)
+ printf (" (%"
+ PRIx64 ",%" PRIx64
+ ") <empty expression>\n", begin, end);
+ else
+ print_expr_block_addrs (&attr, begin, end,
+ expr, exprlen);
+ }
+ }
+ while (offset > 0);
+
+ if (offset < 0)
+ error (EXIT_FAILURE, 0, "dwarf_ranges: %s",
+ dwarf_errmsg (-1));
+ }
+ else
+ {
+ Dwarf_Addr base, begin, end;
+ ptrdiff_t offset = 0;
+ while ((offset = dwarf_getlocations (&attr, offset,
+ &base, &begin, &end,
+ &expr, &exprlen)) > 0)
+ if (begin >= end)
+ printf (" (%" PRIx64 ",%" PRIx64
+ ") <empty range>\n", begin, end); // XXX report?
+ else
+ {
+ print_expr_block_addrs (&attr, begin, end,
+ expr, exprlen);
+
+ // Extra sanity check for dwarf_getlocation_addr
+ // Must at least find one range for begin and end-1.
+ Dwarf_Op *expraddr;
+ size_t expraddr_len;
+ int locs = dwarf_getlocation_addr (&attr, begin,
+ &expraddr,
+ &expraddr_len, 1);
+ assert (locs == 1);
+ locs = dwarf_getlocation_addr (&attr, end - 1,
+ &expraddr,
+ &expraddr_len, 1);
+ assert (locs == 1);
+ }
+
+ if (offset < 0)
+ error (EXIT_FAILURE, 0, "dwarf_getlocations: %s",
+ dwarf_errmsg (-1));
+ }
+ }
+ else if (dwarf_hasattr (&child, DW_AT_const_value))
+ {
+ printf (" <constant value>\n"); // Lookup type and print.
+ }
+ else
+ {
+ printf (" <no value>\n");
+ }
+ }
+ }
+ while (dwarf_siblingof (&child, &child) == 0);
+}
+
+static int
+handle_instance (Dwarf_Die *funcdie, void *arg __attribute__ ((unused)))
+{
+ print_die (funcdie, "inlined function", 1);
+ print_varlocs (funcdie);
+
+ return DWARF_CB_OK;
+}
+
+static int
+handle_function (Dwarf_Die *funcdie, void *arg __attribute__((unused)))
+{
+ if (dwarf_func_inline (funcdie) > 0)
+ {
+ // abstract inline definition, find all inlined instances.
+
+ // Note this is convenient for listing all instances together
+ // so you can easily compare the location expressions describing
+ // the variables and parameters, but it isn't very efficient
+ // since it will walk the DIE tree multiple times.
+ if (dwarf_func_inline_instances (funcdie, &handle_instance, NULL) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_func_inline_instances: %s",
+ dwarf_errmsg (-1));
+ }
+ else
+ {
+ // Contains actual code, not just a declaration?
+ Dwarf_Addr entrypc;
+ if (dwarf_entrypc (funcdie, &entrypc) == 0)
+ {
+ print_die (funcdie, "function", 1);
+ print_varlocs (funcdie);
+ }
+ }
+
+ return DWARF_CB_OK;
+}
+
+struct attr_arg
+{
+ int depth;
+ Dwarf_Addr entrypc;
+};
+
+static int
+handle_attr (Dwarf_Attribute *attr, void *arg)
+{
+ int depth = ((struct attr_arg *) arg)->depth;
+ Dwarf_Addr entrypc = ((struct attr_arg *) arg)->entrypc;
+
+ unsigned int code = dwarf_whatattr (attr);
+ unsigned int form = dwarf_whatform (attr);
+
+ printf ("%*s%s (%s)", depth * 2, "",
+ dwarf_attr_string (code), dwarf_form_string (form));
+
+ /* If we can get an DWARF expression (or location lists) from this
+ attribute we'll print it, otherwise we'll ignore it. But if
+ there is an error while the attribute has the "correct" form then
+ we'll report an error (we can only really check DW_FORM_exprloc
+ other forms can be ambiguous). */
+ Dwarf_Op *expr;
+ size_t exprlen;
+ bool printed = false;
+ int res = dwarf_getlocation (attr, &expr, &exprlen);
+ if (res == 0)
+ {
+ printf (" ");
+ print_expr_block (attr, expr, exprlen, entrypc);
+ printf ("\n");
+ printed = true;
+ }
+ else if (form == DW_FORM_exprloc)
+ {
+ error (0, 0, "%s dwarf_getlocation failed: %s",
+ dwarf_attr_string (code), dwarf_errmsg (-1));
+ return DWARF_CB_ABORT;
+ }
+ else
+ {
+ Dwarf_Addr base, begin, end;
+ ptrdiff_t offset = 0;
+ while ((offset = dwarf_getlocations (attr, offset,
+ &base, &begin, &end,
+ &expr, &exprlen)) > 0)
+ {
+ if (! printed)
+ printf ("\n");
+ printf ("%*s", depth * 2, "");
+ print_expr_block_addrs (attr, begin, end, expr, exprlen);
+ printed = true;
+ }
+ }
+
+ if (! printed)
+ printf ("\n");
+
+ return DWARF_CB_OK;
+}
+
+static void
+handle_die (Dwarf_Die *die, int depth, bool outer_has_frame_base,
+ Dwarf_Addr outer_entrypc)
+{
+ /* CU DIE already printed. */
+ if (depth > 0)
+ {
+ const char *name = dwarf_diename (die);
+ if (name != NULL)
+ printf ("%*s[%" PRIx64 "] %s \"%s\"\n", depth * 2, "",
+ dwarf_dieoffset (die), dwarf_tag_string (dwarf_tag (die)),
+ name);
+ else
+ printf ("%*s[%" PRIx64 "] %s\n", depth * 2, "",
+ dwarf_dieoffset (die), dwarf_tag_string (dwarf_tag (die)));
+ }
+
+ struct attr_arg arg;
+ arg.depth = depth + 1;
+
+ /* The (lowest) address to use for (looking up) operands that depend
+ on address. */
+ Dwarf_Addr die_entrypc;
+ if (dwarf_entrypc (die, &die_entrypc) != 0 || die_entrypc == 0)
+ {
+ /* Try to get the lowest address of the first range covered. */
+ Dwarf_Addr base, start, end;
+ if (dwarf_ranges (die, 0, &base, &start, &end) <= 0 || start == 0)
+ die_entrypc = outer_entrypc;
+ else
+ die_entrypc = start;
+ }
+ arg.entrypc = die_entrypc;
+
+ /* Whether this or the any outer DIE has a frame base. Used as
+ sanity check when printing experssions that use DW_OP_fbreg. */
+ bool die_has_frame_base = dwarf_hasattr (die, DW_AT_frame_base);
+ die_has_frame_base |= outer_has_frame_base;
+ has_frame_base = die_has_frame_base;
+
+ /* Look through all attributes to find those that contain DWARF
+ expressions and print those. We expect to handle all attributes,
+ anything else is an error. */
+ if (dwarf_getattrs (die, handle_attr, &arg, 0) != 1)
+ error (EXIT_FAILURE, 0, "Couldn't get all attributes: %s",
+ dwarf_errmsg (-1));
+
+ /* Handle children and siblings recursively depth first. */
+ Dwarf_Die child;
+ if (dwarf_haschildren (die) != 0 && dwarf_child (die, &child) == 0)
+ handle_die (&child, depth + 1, die_has_frame_base, die_entrypc);
+
+ Dwarf_Die sibling;
+ if (dwarf_siblingof (die, &sibling) == 0)
+ handle_die (&sibling, depth, outer_has_frame_base, outer_entrypc);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* With --exprlocs we process all DIEs looking for any attribute
+ which contains an DWARF expression (but not location lists) and
+ print those. Otherwise we process all function DIEs and print
+ all DWARF expressions and location lists associated with
+ parameters and variables). */
+ bool exprlocs = false;
+ if (argc > 1 && strcmp ("--exprlocs", argv[1]) == 0)
+ {
+ exprlocs = true;
+ argv[1] = "";
+ }
+
+ int remaining;
+ Dwfl *dwfl;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining,
+ &dwfl);
+ assert (dwfl != NULL);
+
+ Dwarf_Die *cu = NULL;
+ Dwarf_Addr dwbias;
+ bool found_cu = false;
+ while ((cu = dwfl_nextcu (dwfl, cu, &dwbias)) != NULL)
+ {
+ /* Only walk actual compile units (not partial units) that
+ contain code if we are only interested in the function variable
+ locations. */
+ Dwarf_Addr cubase;
+ if (dwarf_tag (cu) == DW_TAG_compile_unit
+ && (exprlocs || dwarf_lowpc (cu, &cubase) == 0))
+ {
+ found_cu = true;
+
+ Dwfl_Module *mod = dwfl_cumodule (cu);
+ Dwarf_Addr modbias;
+ dw = dwfl_module_getdwarf (mod, &modbias);
+ assert (dwbias == modbias);
+
+ const char *mainfile;
+ const char *modname = dwfl_module_info (mod, NULL,
+ NULL, NULL,
+ NULL, NULL,
+ &mainfile,
+ NULL);
+ if (modname == NULL)
+ error (EXIT_FAILURE, 0, "dwfl_module_info: %s", dwarf_errmsg (-1));
+
+ const char *name = (modname[0] != '\0'
+ ? modname
+ : basename (mainfile));
+ printf ("module '%s'\n", name);
+ print_die (cu, "CU", 0);
+
+ Dwarf_Addr elfbias;
+ Elf *elf = dwfl_module_getelf (mod, &elfbias);
+
+ // CFI. We need both since sometimes neither is complete.
+ cfi_debug = dwfl_module_dwarf_cfi (mod, &cfi_debug_bias);
+ cfi_eh = dwfl_module_eh_cfi (mod, &cfi_eh_bias);
+
+ assert (cfi_debug_bias == 0); // No bias needed, same file.
+
+ // We are a bit forgiving for object files. There might be
+ // relocations we don't handle that are needed in some
+ // places...
+ GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ is_ET_REL = ehdr->e_type == ET_REL;
+
+ // Get the actual CU DIE and walk all all DIEs (or just the
+ // functions) inside it.
+ Dwarf_Die cudie;
+ uint8_t offsize;
+ uint8_t addrsize;
+ if (dwarf_diecu (cu, &cudie, &addrsize, &offsize) == NULL)
+ error (EXIT_FAILURE, 0, "dwarf_diecu %s", dwarf_errmsg (-1));
+
+ if (exprlocs)
+ {
+ Dwarf_Addr entrypc;
+ if (dwarf_entrypc (cu, &entrypc) != 0)
+ entrypc = 0;
+
+ /* XXX - Passing true for has_frame_base is not really true.
+ We do it because we want to resolve all DIEs and all
+ attributes. Technically we should check that the DIE
+ (types) are referenced from variables that are defined in
+ a context (function) that has a frame base. */
+ handle_die (cu, 0, true /* Should be false */, entrypc);
+ }
+ else if (dwarf_getfuncs (cu, handle_function, NULL, 0) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_getfuncs %s",
+ dwarf_errmsg (-1));
+ }
+ }
+
+ if (! found_cu)
+ error (EXIT_FAILURE, 0, "No DWARF CU found?");
+
+ dwfl_end (dwfl);
+ return 0;
+}
diff --git a/tests/vdsosyms.c b/tests/vdsosyms.c
new file mode 100644
index 0000000..b876c10
--- /dev/null
+++ b/tests/vdsosyms.c
@@ -0,0 +1,110 @@
+/* Test program for getting symbol table from vdso module.
+ Copyright (C) 2014 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/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <errno.h>
+#include <error.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include ELFUTILS_HEADER(dwfl)
+
+#ifndef __linux__
+int
+main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
+{
+ printf ("Getting the vdso is unsupported.\n");
+ return 77;
+}
+#else /* __linux__ */
+static int vdso_syms = 0;
+
+static int
+module_callback (Dwfl_Module *mod, void **userdata __attribute__((unused)),
+ const char *name, Dwarf_Addr start __attribute__((unused)),
+ void *arg __attribute__((unused)))
+{
+ /* We can only recognize the vdso by inspecting the "magic name". */
+ printf ("module name: %s\n", name);
+ if (strncmp ("[vdso: ", name, 7) == 0)
+ {
+ vdso_syms = dwfl_module_getsymtab (mod);
+ printf ("vdso syms: %d\n", vdso_syms);
+ if (vdso_syms < 0)
+ error (2, 0, "dwfl_module_getsymtab: %s", dwfl_errmsg (-1));
+
+ for (int i = 0; i < vdso_syms; i++)
+ {
+ GElf_Sym sym;
+ GElf_Addr addr;
+ const char *sname = dwfl_module_getsym_info (mod, i, &sym, &addr,
+ NULL, NULL, NULL);
+ assert (sname != NULL);
+ printf ("%d: '%s' %" PRIx64 " (%" PRIx64 ")\n",
+ i, sname, sym.st_value, addr);
+ }
+ }
+
+ return DWARF_CB_OK;
+}
+
+int
+main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
+{
+ static char *debuginfo_path;
+ static const Dwfl_Callbacks proc_callbacks =
+ {
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ .debuginfo_path = &debuginfo_path,
+
+ .find_elf = dwfl_linux_proc_find_elf,
+ };
+ Dwfl *dwfl = dwfl_begin (&proc_callbacks);
+ if (dwfl == NULL)
+ error (2, 0, "dwfl_begin: %s", dwfl_errmsg (-1));
+
+ /* Take ourself as "arbitrary" process to inspect. This should work
+ even with "restricted ptrace". */
+ pid_t pid = getpid();
+
+ int result = dwfl_linux_proc_report (dwfl, pid);
+ if (result < 0)
+ error (2, 0, "dwfl_linux_proc_report: %s", dwfl_errmsg (-1));
+ else if (result > 0)
+ error (2, result, "dwfl_linux_proc_report");
+
+ /* Also explicitly attach for older kernels (cannot read vdso otherwise). */
+ result = dwfl_linux_proc_attach (dwfl, pid, false);
+ if (result < 0)
+ error (2, 0, "dwfl_linux_proc_attach: %s", dwfl_errmsg (-1));
+ else if (result > 0)
+ error (2, result, "dwfl_linux_proc_attach");
+
+ if (dwfl_report_end (dwfl, NULL, NULL) != 0)
+ error (2, 0, "dwfl_report_end: %s", dwfl_errmsg (-1));
+
+ if (dwfl_getmodules (dwfl, module_callback, NULL, 0) != 0)
+ error (1, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
+
+ /* No symbols is ok, then we haven't seen the vdso at all on this arch. */
+ return vdso_syms >= 0 ? 0 : -1;
+}
+
+#endif /* ! __linux__ */
diff --git a/tests/vendorelf.c b/tests/vendorelf.c
new file mode 100644
index 0000000..bc13cce
--- /dev/null
+++ b/tests/vendorelf.c
@@ -0,0 +1,197 @@
+/* Test program for adding a program header to a vendor specific ELF file.
+ Copyright (C) 2016 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 <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+void
+check_elf (const char *fname, int class, int use_mmap)
+{
+ printf ("\nfname: %s\n", fname);
+
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Create an ELF header.
+ if (gelf_newehdr (elf, class) == 0)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Initialize header.
+ ehdr->e_ident[EI_DATA] = class == ELFCLASS64 ? ELFDATA2LSB : ELFDATA2MSB;
+ ehdr->e_ident[EI_OSABI] = ELFOSABI_GNU;
+ ehdr->e_type = ET_LOOS + 1;
+ ehdr->e_machine = EM_X86_64;
+ ehdr->e_version = EV_CURRENT;
+
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Create a program header.
+ if (gelf_newphdr (elf, 1) == 0)
+ {
+ printf ("cannot create program header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Phdr phdr;
+ if (gelf_getphdr (elf, 0, &phdr) == NULL)
+ {
+ printf ("cannot get program header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Some random values to check later.
+ phdr.p_type = PT_NULL;
+ phdr.p_offset = 0;
+ phdr.p_vaddr = 0;
+ phdr.p_paddr = 1;
+ phdr.p_filesz = 0;
+ phdr.p_memsz = 1024;
+ phdr.p_flags = PF_R;
+ phdr.p_align = 16;
+
+ if (gelf_update_phdr (elf, 0, &phdr) == 0)
+ {
+ printf ("cannot update program header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ /* Reread the ELF from disk now. */
+ fd = open (fname, O_RDONLY, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_READ_MMAP : ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Is our phdr there?
+ size_t phnum;
+ if (elf_getphdrnum (elf, &phnum) != 0)
+ {
+ printf ("cannot get phdr num: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (phnum != 1)
+ {
+ printf ("Expected just 1 phdr, got: %zd\n", phnum);
+ exit (1);
+ }
+
+ if (gelf_getphdr (elf, 0, &phdr) == NULL)
+ {
+ printf ("cannot get program header from file: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (phdr.p_type != PT_NULL
+ || phdr.p_offset != 0
+ || phdr.p_vaddr != 0
+ || phdr.p_paddr != 1
+ || phdr.p_filesz != 0
+ || phdr.p_memsz != 1024
+ || phdr.p_flags != PF_R
+ || phdr.p_align != 16)
+ {
+ printf ("Unexpected phdr values\n");
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ unlink (fname);
+}
+
+int
+main (int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ elf_version (EV_CURRENT);
+
+ check_elf ("vendor.elf.32", ELFCLASS32, 0);
+ check_elf ("vendor.elf.32.mmap", ELFCLASS32, 1);
+ check_elf ("vendor.elf.64", ELFCLASS64, 0);
+ check_elf ("vendor.elf.64.mmap", ELFCLASS64, 1);
+
+ return 0;
+}
diff --git a/tests/zstrptr.c b/tests/zstrptr.c
new file mode 100644
index 0000000..6d8e19f
--- /dev/null
+++ b/tests/zstrptr.c
@@ -0,0 +1,124 @@
+/* Test program for elf_strptr function.
+ 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 <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+int
+main (int argc, char *argv[])
+{
+ if (argc != 2)
+ {
+ printf ("No ELF file given as argument");
+ exit (1);
+ }
+
+ const char *fname = argv[1];
+
+ // Initialize libelf.
+ elf_version (EV_CURRENT);
+
+ /* Read the ELF from disk now. */
+ int fd = open (fname, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ size_t ndx;
+ if (elf_getshdrstrndx (elf, &ndx) != 0)
+ {
+ printf ("cannot get section header table index: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (ndx == SHN_UNDEF)
+ {
+ printf ("ELF file `%s' doesn't have a section header table index", fname);
+ exit (1);
+ }
+
+ Elf_Scn *scn = elf_getscn (elf, ndx);
+ if (scn == NULL)
+ {
+ printf ("Couldn't get section %zd: %s\n", ndx, elf_errmsg (-1));
+ exit (1);
+ }
+
+ void print_strings (void)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+
+ printf ("Strings in section %zd (%s):\n", ndx,
+ ((shdr->sh_flags & SHF_COMPRESSED) != 0
+ ? "compressed" : "uncompressed"));
+
+ size_t off = 0;
+ const char *str = elf_strptr (elf, ndx, off);
+ while (str != NULL)
+ {
+ printf ("[%zx] '%s'\n", off, str);
+ off += strlen (str) + 1;
+ str = elf_strptr (elf, ndx, off);
+ }
+ }
+
+ if (elf_compress (scn, ELFCOMPRESS_ZLIB, 0) < 0)
+ {
+ printf ("Couldn't compress section %zd: %s\n", ndx, elf_errmsg (-1));
+ exit (1);
+ }
+ print_strings ();
+
+ if (elf_compress (scn, 0, 0) < 0)
+ {
+ printf ("Couldn't decompress section %zd: %s\n", ndx, elf_errmsg (-1));
+ exit (1);
+ }
+ print_strings ();
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ return 0;
+}