summaryrefslogtreecommitdiffstats
path: root/tests/Makefile.am
Commit message (Collapse)AuthorAgeFilesLines
* libelf: Add ELF compression types and defines to libelf.h for older glibc.Mark Wielaard2016-01-141-2/+7
| | | | | | | | | | | | | Older glibc elf.h might not define the new ELF compression defines and types. If not just define them in libelf.h directly to make the libelf headers work on older glibc systems. Also include a testcase to check the libelf headers build against the system elf.h. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810885 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Simplify code and build now that zlib support is no longer optional.Mark Wielaard2016-01-081-5/+2
| | | | | | | Now that we always require zlib support we don't need to conditionally build or compile code that depends on it. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elfcompress: New utility.Mark Wielaard2016-01-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Usage: elfcompress [OPTION...] FILE... Compress or decompress sections in an ELF file. -f, --force Force compression of section even if it would become larger -n, --name=SECTION SECTION name to (de)compress, SECTION is an extended wildcard pattern (defaults to '.?(z)debug*') -o, --output=FILE Place (de)compressed output into FILE -p, --permissive Relax a few rules to handle slightly broken ELF files -q, --quiet Be silent when a section cannot be compressed -t, --type=TYPE What type of compression to apply. TYPE can be 'none' (decompress), 'zlib' (ELF ZLIB compression, the default, 'zlib-gabi' is an alias) or 'zlib-gnu' (.zdebug GNU style compression, 'gnu' is an alias) -v, --verbose Print a message for each section being (de)compressed -?, --help Give this help list --usage Give a short usage message -V, --version Print program version Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Make elf_strptr index correctly into compressed section data.Mark Wielaard2016-01-061-3/+5
| | | | | | | | | elf_strptr indexes into the section data. This is defined as index into the uncompressed data of the section. If the section is compressed make sure the uncompressed data is available, but don't really decompress the section header (elf_getdata will still return compressed data). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* readelf: Handle compressed sections and extend -z to cover -x and -p.Mark Wielaard2016-01-061-2/+5
| | | | | | | | | | | | | | | When printing a (non-string, non-data) section use uncompressed data when possible. For dumping hex and string sections (-x and -p) -z will dump the uncompressed data (otherwise the compressed data is dumped). -z, --decompress Show compression information for compressed sections (when used with -S); decompress section before dumping data (when used with -p or -x) Includes test cases for ET_REL files using compressed relocation (target) debug sections to test libdwfl transparent uncompression of sections. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Add elf_compress and elf_compress_gnu.Mark Wielaard2016-01-061-3/+7
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* readelf: Add -z,--decompress option.Mark Wielaard2016-01-061-1/+2
| | | | | | | -z, --decompress Show compression information for compressed sections (when used with -S). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Add elf32_getchdr, elf64_getchdr and gelf_getchdr.Mark Wielaard2016-01-061-3/+8
| | | | | | | | | Elf_Data of a compressed section has type ELF_T_CHDR. This type can be xlated to the file or memory representation. This will make sure the Chdr is in the correct endianess. The compressed data following the Chdr isn't translated. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwelf: Add dwelf_scn_gnu_compressed_size.Mark Wielaard2016-01-061-3/+7
| | | | | | Helper function to get the size of a GNU compressed zdebug section. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: elfstrmerge warn about STT_SECTION symbol for shstrhndx.Mark Wielaard2016-01-051-2/+2
| | | | | | | | | | | | | | Old linkers might have created an STT_SECTION symbol for the section header string table section, which isn't actually used. For now just warn about such symbols. If such a symbol would actually really be used (but why?) then we would have to handle it by removing it and rewriting the symbol table. This is a testsuite only change, but includes an extra test with files that have such STT_SECTION symbols to make sure it will be handled in case we "upgrade" the elfstrmerge test to a real utility. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* backends: sparc: support for core backtracesJose E. Marchesi2016-01-031-1/+3
| | | | | | | | This patch adds sparc support to the unwinder, providing a default CFI program that works in both sparcv9-*-* and sparc64-*-* targets. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Use valgrind --leak-check=full.Mark Wielaard2016-01-021-1/+1
| | | | | | | | | When --enable-valgrind is given run the testsuite with --leak-check=full treating any memory leak as a failure. Also disable valgrind for those tests that trigger a valgrind bug. https://bugs.kde.org/show_bug.cgi?id=327427 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Make zlib mandatory.Mark Wielaard2015-10-261-2/+2
| | | | | | Explicitly link libelf and libdw with -lz. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Add AM_LDFLAGS to dwfl_proc_attach_LDFLAGS.Mark Wielaard2015-10-161-1/+1
| | | | | | We want to be sure the libelf.so under test is picked up. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-091-2/+3
| | | | | | | | | | | | | | | AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS in config.h if needed for LFS, and this automatically maps things like open to open64. But quite a few places used explicit 64-bit names, which won't work on platforms like FreeBSD where off_t is always 64-bit and there are no foo64 names. It's better to just trust that AC_SYS_LARGEFILE is doing it correctly. But we can verify this too, as some file could easily forget to include config.h. The new tests/run-lfs-symbols.sh checks all build targets against lfs-symbols (taken from lintian) to make sure everything was implicitly mapped to 64-bit variants when _FILE_OFFSET_BITS is set. Signed-off-by: Josh Stone <jistone@redhat.com>
* Improve AM_SILENT_RULES coverageJosh Stone2015-10-061-1/+1
| | | | | | | | | | | Note, elfutils does not explicitly enable AM_SILENT_RULES. It's only available starting from automake 1.11, but starting from automake 1.13 silent rules are always generated, defaulting to verbose. $(AM_V_foo) additions should be no-ops on systems that don't support silent rules. To be silent, use "./configure --enable-silent-rules" or "make V=0". Signed-off-by: Josh Stone <jistone@redhat.com>
* Handle merged strtab/shstrtab string tables in strip and unstrip.Mark Wielaard2015-10-051-3/+4
| | | | | | | | | | | | | | | | | | | | | ELF files can share the section header string table (e_shstrndx) with the symtab .strtab section. That might in some cases save a bit of space since symbols and sections might share some (sub)strings. To handle that eu-strip just needs to not unconditionally remove the .shstrtab section (it will be properly marked as used/unused as needed). eu-unstrip needs to make sure the section names are added to the strtab if it decides to rewrite that section. Also makes sure that eu-strip won't move around a SHT_NOBITS section that has SHF_ALLOC set. Although it is allowed to move such sections around, there is no benefit. And some tools might expect no allocated section to move around, not even a nobits section. It also makes it harder to do "roundtripping" sanity checks that make sure splitting a file with eu-strip and then reconstructed with eu-unstrip produce the same ELF file (as is done in the new run-strip-strmerge.sh). Introduces a somewhat large test generator elfstrmerge.c that will hopefully turn into a more generic string table merger program. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Always update e_version and e_shentsize in elf_update.Mark Wielaard2015-10-051-2/+5
| | | | | | | | | | | When e_version is EV_NONE we should set it to EV_CURRENT like we do for the EI_VERSION and like we set EI_DATA to the correct byte order when set to ELFDATANONE. Likewise we should always set e_shentsize like we do for e_phentsize, not just when ELF_F_LAYOUT isn't set. Add a new elfshphehdr testcase to check the above. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Make dwfl_linux_proc_attach work even without any Dwfl_Modules.Mark Wielaard2015-09-141-2/+4
| | | | | | | | | dwfl_linux_proc_attach depended on a Dwfl_Module with the correct ELF header already being available. That isn't really necessary since when we attach we have the main exe ELF file available. Just use that to make dwfl_linux_proc_attach always work. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Add a testcase for dwfl debuginfo-path with separate bin/debug dirs.Mark Wielaard2015-08-141-2/+2
| | | | | | | | | Reuse the run-addr2line-i-test.sh testfile-inlines testfile, but first strip the debuginfo and put the binary and separate debuginfo file in different roots. Check that --debuginfo-path still finds the debug file. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* unstrip: Handle debuginfo files with missing SHF_INFO_LINK section flags.Mark Wielaard2015-08-031-2/+6
| | | | | | | | | | | | | | | | With GCC 5 there might be a .rela.plt section with SHF_INFO_LINK set. Buggy binutils objdump might strip it from the section in the debug file. Ignore such differences for relocation sections and put the flag back if necessary. Also improve the error message a little by only discarding the already matched sections if there is an prelink undo section. Otherwise we will report all sections as not matching if the file wasn't prelinked instead of just the non-matching sections. New testfiles generated by gcc5 and binutils objdump added. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: Add demangler support.Mark Wielaard2015-05-271-0/+2
| | | | | | | Makes the -C, --demangle option visible and implements it (ignoring the demangle style argument). Adds a new test with sample output. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Link against standalone argp libraryAnthony G. Basile2015-05-041-15/+15
| | | | | | | | | | | | | | argp is not part of POSIX standards and not provided by uClibc or some other standard C libraries. However, it is possible to link against a breakout argp library. One is provided at http://www.lysator.liu.se/~nisse/misc/ This patch tests if libc provides argp otherwise it adds the linker flag -largp where needed in the build system. Signed-off-by: Anthony G. Basile <blueness@gentoo.org> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
* tests: Split run-stack tests to support missing demangler.Mark Wielaard2015-05-011-0/+2
| | | | | | SKIP tests that need a demangler if it is not there. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Add run-strip-test10.shH.J. Lu2015-04-011-3/+3
| | | | Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
* tests: Add run-strip-test9.shH.J. Lu2015-04-011-1/+4
| | | | Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
* tests: Add run-backtrace-core-x32.shH.J. Lu2015-04-011-1/+4
| | | | Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
* tests: Add testfile-x32 to run-addrcfi.shH.J. Lu2015-04-011-1/+1
| | | | Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
* tests: Add testfile-x32-core.bz2 to run-readelf-mixed-corenote.shH.J. Lu2015-04-011-1/+2
| | | | Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
* Add forgotten files to EXTRA_DISTPetr Machata2015-03-251-1/+3
| | | | Signed-off-by: Petr Machata <pmachata@redhat.com>
* dwarf_ranges: do not request base address attributes if not necessaryPetr Machata2015-02-111-2/+3
| | | | | | | | - Instead of bailing out at iteration start, we remember the base-address-selecting attributes were not seen, and then bail out later if no base address selection entry has been seen. Signed-off-by: Petr Machata <pmachata@redhat.com>
* libelf: elf_strptr should use datalist when data has been added to section.Mark Wielaard2015-02-061-2/+3
| | | | | | | | | | elf_strptr always used the rawdata when available. But when data has been added to the section it should find the correct buffer in the datalist. Adds a large testcase that checks various ways of adding and extracting strings from a section. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Fix elf_newdata when raw ELF file/image data is available.Mark Wielaard2015-02-061-2/+3
| | | | | | | | | | | | | | | When ELF data for a section has been read by elf_rawdata, data_read and rawdata_base are set, but data_list_rear will not be set until the data will be converted (by elf_getdata). elf_newdata would overwrite the existing data in that case. Both elf_getdata and elf_update rely on the fact that when data_list_rear is set they don't have to look at the raw data anymore. So make sure we update the data list properly before adding any new data and raw data is available in elf_newdata. Add newdata test that calls elf_newdata before and after elf_rawdata and elf_getdata and checks the new size and contents of the section. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: elf_strptr should fetch the shdr for the section if not yet known.Mark Wielaard2015-02-061-3/+4
| | | | | | | | | elf_strptr might be called before the shdrs are read in. In that case it needs to explicitly call __elf[32|64]_getshdr_rdlock to check the section type and size. The new strptr testcase triggers this corner case and crashes before the fix. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdw: Search for the last matching address with dwarf_getsrc_die.Mark Wielaard2015-01-161-3/+7
| | | | | | | | | | In commit 7d9b5a dwfl_module_getsrc was changed so that it returns the last line record <= addr, rather than returning immediately on a match. This changes dwarf_getsrc_die to do the same. And it adds a new test that checks this by comparing against the same results from eu-addr2line (which uses dwfl_module_getsrc) using dwarf_addrdie and dwarf_getsrc_die instead. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Add testfile-debug-types test case.Mark Wielaard2015-01-141-2/+3
| | | | | | | Test for regression fixed in commit 7c713822: "libdw: fix offset for sig8 lookup in dwarf_formref_die" Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Add testfile-macros-0xff.bz2 to EXTRA_DIST.Mark Wielaard2014-12-181-0/+1
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Add an explicit -fasynchronous-unwind-tables for deleted-lib.so.Mark Wielaard2014-12-141-1/+1
| | | | | | | | | Some systems don't add a PT_GNU_EH_FRAME segment by default, but the deleted test depends on it so that it can get at the .eh_frame_hdr table through the phdrs from the remote memory ELF image. Request one explicitly with -fasynchronous-unwind-tables. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Test addr2line -i with lexical blocks presentJosh Stone2014-12-131-1/+3
| | | | | | | | This test is for the fix in commit aecdf2670c02, but it was hampered by unlucky sorting of line records. With the new stable sort, the test now gets the desired line numbers. Signed-off-by: Josh Stone <jistone@redhat.com>
* readelf: print_attributes (-A) robustify and handle non-gnu attributes.Mark Wielaard2014-11-261-2/+3
| | | | | | | | | | | print_attributes wasn't robust against empty or broken attribute sections. It also only handled GNU attributes. But the arm backend contains some none-GNU attributes. The difference is in how to handle the tag arguments. Adds a new test run-readelf-A.sh for both gnu (ppc32) and non-gnu (arm) attributes. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: find_dynsym don't assume dynamic linker has adjusted DYNAMIC entries.Mark Wielaard2014-11-131-2/+3
| | | | | | | | | | | | | | | | | | commit 037505 "Fix resolving ELF symbols for live PIDs with deleted files" changed find_dynsym to assume the PT_DYNAMIC entries had been adjusted by the dynamic linker. That is often a correct assumption when the ELF image comes from remote memory. But we cannot rely on that. In the case of the vdso image the DYNAMIC segment has not been adjusted for example. There is no good way to determine whether the DYNAMIC segment has or hasn't been adjusted already to the load address by the dynamic linker. So we just try twice. Once without and if the fails again with assuming adjustments being applied. Includes a new vdsosyms testcase that fails on i686 before and succeeds after the fix. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdw: Add dwarf_peel_type. Use it in dwarf_aggregate_size.Mark Wielaard2014-11-051-1/+2
| | | | | | | | | | | | | | | Add new function dwarf_peel_type. Some type annotations in DWARF are specified by modifier tag type wrappers instead of attributes. For type aliases (typedef) and qualifiers (const, volatile, restrict) tags dwarf_peel_type follows the DW_AT_type attributes till it finds a base, user-defined, reference or pointer type DIE. Use this new function in the backends for return type DIEs (replacing the existing dwarf_peel_type there) and in dwarf_aggregate_size so it can provide the sizes for qualified types too. Add a new version and testcase for the new dwarf_aggregate_size functionality. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdw: dwarf_aggregate_size return CU address_size for sizeless pointer/refs.Mark Wielaard2014-10-021-3/+5
| | | | | Tested-by: Conrad Meyer <cse.cem@gmail.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Support note NT_FILE for locating files.Jan Kratochvil2014-09-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Martin Milata: ------------------------------------------------------------------------------ RFE: dwfl_core_file_report: use NT_FILE core note if the link_map chain is broken https://bugzilla.redhat.com/show_bug.cgi?id=1129777 The dwfl_core_file_report function follows dynamic linker's link_map chain in order to determine the shared libraries used by the executable. As this data structure is located in writable memory it can be overwritten by garbage, which is sometimes the case. https://github.com/abrt/satyr/issues/127#issuecomment-46957546 Since version 3.7 (commit 2aa362c49), Linux kernel adds NT_FILE note to core files which contains the files mapped by the process, including shared libraries. ------------------------------------------------------------------------------ dwfl_core_file_report now tries to fall back on NT_FILE if the link_map chain is broken. elfutils would already find the appropriate binary file from /usr/lib/debug/.build-id/ symbolic links. But those symbolic links do not have to be present on the system while NT_FILE still points to the correct binaries. Filenames from the note NT_FILE are used only if link_map filenames failed to locate matching binaries. tests/test-core.core.bz2 had to have its NT_FILE disabled as run-unstrip-n.sh otherwise FAILs: FAIL: 0x7f67f2aaf000+0x202000 - . - /home/jkratoch/redhat/elfutils-libregr/test-core-lib.so PASS: 0x7f67f2aaf000+0x202000 - . - test-core-lib.so As test-core-lib.so is found in link_map but it is not present on the disk elfutils now chooses the more reliable filename from NT_FILE (although that filename is also not found on the disk). Updating the expected text would be also sufficient. libdwfl/ 2014-09-26 Jan Kratochvil <jan.kratochvil@redhat.com> Support NT_FILE for locating files. * core-file.c (dwfl_core_file_report): New variables note_file and note_file_size, set them and pass them to dwfl_segment_report_module. * dwfl_segment_report_module.c: Include common.h and fcntl.h. (buf_has_data, buf_read_ulong, handle_file_note): New functions. (invalid_elf): New function from code of dwfl_segment_report_module. (dwfl_segment_report_module): Add parameters note_file and note_file_size. New variables elf and fd, clean them up in finish. Move some code to invalid_elf. Call handle_file_note, if it found a name verify the file by invalid_elf. Protect elf and fd against cleanup by finish if we found the file for new Dwfl_Module. * libdwflP.h (dwfl_segment_report_module): Add parameters note_file and note_file_size. tests/ 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. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Fix resolving ELF symbols for live PIDs with deleted filesJan Kratochvil2014-08-291-3/+7
| | | | | | | | | | | | | | | | For deleted shared library files the offsets to the symbol table were calculated wrongly from the phdrs because the main_bias wasn't taken into account. Formerly shared libraries did not get resolved properly: #2 0x00007fc4d86c56d6 #3 0x0000000000400938 main Fixed elfutils produce: #2 0x00007f61094876d6 libfunc #3 0x0000000000400938 main Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Remove --enable-dwz. dwz alt debug is no longer experimental.Mark Wielaard2014-05-031-6/+2
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwelf: Add dwelf_elf_gnu_build_id.Mark Wielaard2014-05-011-4/+8
| | | | | | | | | Move internal function __libdwfl_find_build_id to libdwelf and use it to add a public dwelf_elf_gnu_build_id function to extract the NT_GNU_BUILD_ID from an ELF file using either the shdrs or phdrs. Adjust internal callers and add a testcase. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwelf: Add dwelf_dwarf_gnu_debugaltlinkFlorian Weimer2014-04-241-3/+4
| | | | Signed-off-by: Florian Weimer <fweimer@redhat.com>
* libdwelf: New DWARF ELF Low-level Functions. Add dwelf_elf_gnu_debuglink.Mark Wielaard2014-04-241-2/+5
| | | | | | | | New public header elfutils/libdwelf.h for low-level DWARF/ELF helper functions. The new function dwelf_elf_gnu_debuglink returns the name and crc as found in the .gnu_debuglink section of an ELF file. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Remove mudflap build option.Mark Wielaard2014-04-181-73/+65
| | | | | | | | | The --enable-mudflap configure build has been broken for 2 years without anybody apparently noticing. GCC 4.9 removed mudflap support. Before release we now run make distcheck with valgrind support. Removal of the mudflap configure option simplifies the build a little. Signed-off-by: Mark Wielaard <mjw@redhat.com>