summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Clean up linux-specific system includesUlf Hermann2017-04-213-2/+7
| | | | | | | We only include them where we actually need them and only on linux. Change-Id: Ic3065ffab67ba1177f63204fb91a92c5f4336dbb Reviewed-by: Christian Kandeler <[email protected]>
* Add missing peel_type.c test for commit f339da.Mark Wielaard2017-04-071-0/+119
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Support checking ELF files with compressed sections.Mark Wielaard2017-04-054-2/+37
| | | | | | | | | Simply unconditionally uncompress any section to make sure indexes between sections check out. Add some testcases with various compressed sections. https://sourceware.org/bugzilla/show_bug.cgi?id=21332 Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Fix dwarf_peel_type infinite loop.Mark Wielaard2017-04-053-3/+77
| | | | | | | | | | We were calling dwarf_attr_integrate () in the die in the loop instead of on the result. Which would cause an infinite loop when die != result. Add a testcase that explicitly checks this case. https://sourceware.org/bugzilla/show_bug.cgi?id=21330 Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Always update last_offset in updatefile and updatemmap.Mark Wielaard2017-04-043-2/+459
| | | | | | | | | | | | | | | | When ELF section data was used, but not updated or marked as dirty and there also existed non-dirty sections and some padding was needed between the sections (possibly because of alignment) then elf_update might write "fill" over some of the existing data. This happened because in that case the last_position was not updated correctly. Includes a new testcase fillfile that fails before this patch by showing fill instead of the expected data in some section data. It succeeds with this patch. https://sourceware.org/bugzilla/show_bug.cgi?id=21199 Signed-off-by: Mark Wielaard <[email protected]>
* backends: Add support for EM_PPC64 GNU_ATTRIBUTES.Mark Wielaard2017-03-244-3/+22
| | | | | | | | ppc64 and ppc64le ELF files can also contain a power specific .gnu.attributes section. Add support for those and recognize the new GNU_Power_ABI_FP Single-precision hard float value. Signed-off-by: Mark Wielaard <[email protected]>
* Check for existence of mempcpyUlf Hermann2017-02-172-0/+5
| | | | | | If it doesn't exist, provide a definition based on memcpy. Signed-off-by: Ulf Hermann <[email protected]>
* Optionally allow unknown symbols in the backtrace testsUlf Hermann2017-02-143-12/+38
| | | | | | | | This is useful to test unwinding without debug information. The binaries being examined might still have frame pointers that allow us to bridge the unknown symbols. Signed-off-by: Ulf Hermann <[email protected]>
* Make the backtrace-data test helper more robustUlf Hermann2017-02-142-3/+19
| | | | | | | | | When unwinding by frame pointer the unwinder might ask for invalid addresses. We don't have to fail the test in this case. In fact any broken dwarf information can lead to requests for invalid addresses, also without frame pointer unwinding. Signed-off-by: Ulf Hermann <[email protected]>
* readelf: Add optional --symbols[=SECTION] argument to select section name.Mark Wielaard2016-11-172-0/+15
| | | | | | | | | Make it possible to display just the symbols from a named symbol section instead of always displaying all symbol sections. https://bugzilla.redhat.com/show_bug.cgi?id=1396092 Signed-off-by: Mark Wielaard <[email protected]>
* Add GCC7 -Wimplicit-fallthrough support/fixes.Mark Wielaard2016-11-103-1/+7
| | | | | | | | | | | GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one small buglet in elflint option procession. So it seems useful to enable to make sure all swatch case fallthroughs are deliberate. Add configure check to detect whether gcc support -Wimplicit-fallthrough and enable it. Add fixes and explicit fallthrough comments where necessary. Signed-off-by: Mark Wielaard <[email protected]>
* tests: unstrip: Add test for mismatched .strtab sectionsKevin Cernekee2016-10-246-3/+33
| | | | | | | | | | Current unstrip test cases either have no .symtab/.strtab in the stripped binary, or .strtab sections that are identical between the stripped and debuginfo binaries. Add a test case where .symtab/.strtab in the stripped binary contains a small subset of the full unstripped data. Signed-off-by: Kevin Cernekee <[email protected]>
* lib: Provide MAX and MIN in system.hAkihiko Odaki2016-10-122-1/+5
| | | | | | | | | | This change also creates a new header file libeu.h to provide the prototypes for the function of libeu. That hides the definition of function crc32, which can conflict with zlib, from libelf. It also prevents mistakes to refer those functions from a component which doesn't link with libeu, such as libelf. Signed-off-by: Akihiko Odaki <[email protected]>
* tests: Fix --enable-gcov tests build. Add libdw to LDADD for asm_tsts.Mark Wielaard2016-08-302-9/+13
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* tests: Simplify backtrace-native tests. Drop raise jmp patching for x86_64.Mark Wielaard2016-08-253-22/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The backtrace-native[-biarch] testcase was a little too clever in places making it unreliable. On x86_64 we tried to make an interesting backtrace by catching the first signal and then replacing the pc with the address of the first instruction of a function. Then we would raise a new signal, through ptrace, to create a backtrace that went from a signal frame into a frame at the start of a function. That way we could check that we were trying to fetch the correct CFI for the (jmp) function even at the first instruction (normally we would substract one from the return address to get at the call address). This works as long as the CFI for the jmp() function is identical to the CFI for the raise() function that we "patched away". Unfortunately on Fedora rawhide glibc has a rewritten raise() implementation that has different CFI, in particular the CFA is calculated differently. Making the testcase fail because we cannot properly unwind from jmp(). So this special x86_64 case has been disabled (the code is still there in case we find another way to test this in a more reliable way). On Ubuntu there have been spurious testcase failures because see_exec_module found two Dwfl_Modules with the same path. This would trigger an assert. Although this might indicate some issue (maybe we are not parsing the proc/pid/map correctly?) it isn't clear that it really is a bug. Since the assert is not very helpful finding any actual bug and for the testcase it is only necessary that the first Dwfl_Module that represents the executable is found we just pick that Dwfl_Module and don't iterate through any of the others. Signed-off-by: Mark Wielaard <[email protected]>
* tests: Add testfilesparc64attrs.o.bz2 to EXTRA_DIST.Mark Wielaard2016-08-242-0/+5
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* sparc: fix the printing of hw capabilities object attributes.Jose E. Marchesi2016-08-243-1/+23
| | | | | | | | | | The GNU_Sparc_HWCAPS and GNU_Sparc_HWCAPS2 object attributes comprise a set of hardware capabilities that may (or not) be present in the target machine for which the object was compiled. This patch adds the support for printing a nicely formatted comma-separated list with the selected hw capabilities. Signed-off-by: Jose E. Marchesi <[email protected]>
* strip: Handle compressed relocation target sections.Mark Wielaard2016-08-152-0/+16
| | | | | | | | | | | | | | | binutils 2.27 assembler will create compressed sections for x86 ELF targets. The linker will decompress them again and it doesn't do this for any other target. This broke one of the run-strip-reloc.sh self tests. Fix by checking if the target of a relocation section is compressed and first decompressing it before applying relocations and then compressing again if necessary. Add explicit testcases for compressed and uncompressed ET_REL files to run-strip-reloc.sh. Signed-off-by: Mark Wielaard <[email protected]>
* Fix bpf disassembler for _FORTIFY_SOURCERichard Henderson2016-08-112-1/+6
| | | | | | | | It's illegal to skip positional operands for printf. Rearrange the printing of the instructions to use exactly the operands required. Also, fix printing of mod operations: s/%/%%/ in the print format. Also, fix printing of endian operations: remove extra spaces.
* dwelf: Add string table functions from ebl.Mark Wielaard2016-08-036-61/+74
| | | | | | | | | | | | | | | | Move the strtab functions from libebl to libdw. Programs often want to create ELF/DWARF string tables. We don't want (static) linking against ebl since those are internal functions that might change. This introduces dwelf_strtab_init, dwelf_strtab_add, dwelf_strtab_add_len, dwelf_strtab_finalize, dwelf_strent_off, dwelf_strent_str and dwelf_strtab_free. Documentation for each has been added to libdwelf.h. The add fucntion got a variant that takes the length explicitly and finalize was changed to return NULL on out of memory instead of aborting. All code and tests now uses the new functions. Signed-off-by: Mark Wielaard <[email protected]>
* Add m68k testsAndreas Schwab2016-07-1110-5/+122
| | | | Signed-off-by: Andreas Schwab <[email protected]>
* libelf: Allow updating phdrs for any e_type.Mark Wielaard2016-07-114-3/+209
| | | | | | | | | | | | | | | | | | | | | | | | elf[32|64]_updatenull would sanity check the e_type before allowing to update the phdrs. This prevents creating an ET_REL file with phdrs. It also prevents creating any vendor specific ELF file having phdrs. We only check this when updating/writing out the file. But we would just read such files. Don't prevent people from creating unexpected ELF files. elflint will warn for such files. While writing a new testcase for this another bug was found that prevented updating a just created phdr because elf_getphdrnum would sanity check the phdr offset in the file (which doesn't exist yet). Fix that by only doing such a sanity check if the phdrs haven't been read in or created yet. This second bug should have been found by the existing elfshphehdr test, but that test contained a typo checking elf_getphdrnum. It tested that the called failed when there were no phdrs, but then elf_getphdrnum should simply succeed and return zero. https://bugzilla.redhat.com/show_bug.cgi?id=1352232 Signed-off-by: Mark Wielaard <[email protected]>
* libelf: find 1st section instead of assumingJohn Ogness2016-06-283-2/+288
| | | | | | | | | | | | | | | | | | When getting section headers it is assumed that the first section is on the first section list. However, it is possible that the first section list only contains the zeroth section, in which case either illegal memory access occurs or elf_nextscn() erroneously returns NULL. With this patch, checks are added to avoid the illegal memory access and (if available) the second section list is looked at to find the first section. A new test emptyfile is added that tests adding a section to and "empty" ELF file 32/64 class with ELF_C_RDWR[_MMAP]. Signed-off-by: John Ogness <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Add support for BPFRichard Henderson2016-06-285-1/+78
| | | | Signed-off-by: Richard Henderson <[email protected]>
* elflint: Fix sh_entsize check when comparing SHT_HASH and SHT_GNU_HASH.Mark Wielaard2016-02-154-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC6 -Wduplicated-cond found the following issue: elflint.c: In function ‘compare_hash_gnu_hash’: elflint.c:2483:34: error: duplicated ‘if’ condition [-Werror=duplicated-cond] else if (hash_shdr->sh_entsize == sizeof (Elf64_Word)) ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ elflint.c:2448:29: note: previously used here if (hash_shdr->sh_entsize == sizeof (Elf32_Word)) ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ Which is correct, a Word in both Elf32 and Elf64 files is 4 bytes. We meant to check for sizeof (Elf64_Xword) which is 8 bytes. Also fix the section index and name in the error message. The reason we probably didn't see this issue before is that SHT_HASH sections really always should have sh_entsize of 4 even on 64bit arches. There are however a couple of arches with mistakes in their sysv ABI. See libelf/common.h. This also would only be triggered if on such an architectures when the ELF file would have both a SHT_HASH and SHT_GNU_HASH section and elflint would try to compare those sections. Add an example testfile-s390x-hash-both to run-elflint-test.sh. Signed-off-by: Mark Wielaard <[email protected]>
* libelf: elf_getdata should not adjust alignment for SHT_NOBITS sections.Mark Wielaard2016-02-106-3/+51
| | | | | | | | | | | | | | In commit c0748e "libelf: More checking of valid sh_addralign values." we adjusted bogus alignment of data buffers if they were greater than the offset of the data in the file. This works OK, except when there is no data in the file. So make sure to not adjust any NOBITS sections. Also adds a test that shows the issue and makes sure elflint is called with --gnu in run-strip-test.sh. https://bugzilla.redhat.com/show_bug.cgi?id=1303845 Signed-off-by: Mark Wielaard <[email protected]>
* tests: Skip dwfl-bug-fd-leak test if dwfl_linux_proc_report is unsupported.Mark Wielaard2016-01-182-0/+14
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* tests: Guard linux specific header includes with ifdef __linux__.Mark Wielaard2016-01-182-0/+6
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Add ELF compression types and defines to libelf.h for older glibc.Mark Wielaard2016-01-143-2/+50
| | | | | | | | | | | | | 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 <[email protected]>
* tests: Fix parentheses in elfputzdata strncmp test.Mark Wielaard2016-01-082-1/+5
| | | | | | We were checking strlen () == 0 instead of strncmp () == 0. Oops. Signed-off-by: Mark Wielaard <[email protected]>
* Fix build on 32bit systems.Mark Wielaard2016-01-082-1/+5
| | | | | | size_t has a different size on 32 and 64 bit systems. Signed-off-by: Mark Wielaard <[email protected]>
* Simplify code and build now that zlib support is no longer optional.Mark Wielaard2016-01-082-5/+7
| | | | | | | 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 <[email protected]>
* elfcompress: New utility.Mark Wielaard2016-01-063-2/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* libelf: Make elf_strptr index correctly into compressed section data.Mark Wielaard2016-01-066-16/+325
| | | | | | | | | 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 <[email protected]>
* readelf: Handle compressed sections and extend -z to cover -x and -p.Mark Wielaard2016-01-068-2/+493
| | | | | | | | | | | | | | | 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 <[email protected]>
* libelf: Add elf_compress and elf_compress_gnu.Mark Wielaard2016-01-067-4/+926
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Add -z,--decompress option.Mark Wielaard2016-01-063-1/+210
| | | | | | | -z, --decompress Show compression information for compressed sections (when used with -S). Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Add elf32_getchdr, elf64_getchdr and gelf_getchdr.Mark Wielaard2016-01-069-4/+341
| | | | | | | | | 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 <[email protected]>
* libdwelf: Add dwelf_scn_gnu_compressed_size.Mark Wielaard2016-01-068-3/+231
| | | | | | Helper function to get the size of a GNU compressed zdebug section. Signed-off-by: Mark Wielaard <[email protected]>
* tests: elfstrmerge warn about STT_SECTION symbol for shstrhndx.Mark Wielaard2016-01-054-4/+56
| | | | | | | | | | | | | | 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 <[email protected]>
* backends: sparc: support for core backtracesJose E. Marchesi2016-01-035-1/+31
| | | | | | | | 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 <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* tests: Use valgrind --leak-check=full.Mark Wielaard2016-01-026-1/+50
| | | | | | | | | 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 <[email protected]>
* tests: Fix some memory leaks in testcases.Mark Wielaard2016-01-029-4/+36
| | | | | | | Make sure all structures allocated in the testcases are disposed so running them under valgrind will show no memory leaks. Signed-off-by: Mark Wielaard <[email protected]>
* Make zlib mandatory.Mark Wielaard2015-10-262-2/+7
| | | | | | Explicitly link libelf and libdw with -lz. Signed-off-by: Mark Wielaard <[email protected]>
* tests: Add AM_LDFLAGS to dwfl_proc_attach_LDFLAGS.Mark Wielaard2015-10-162-1/+5
| | | | | | We want to be sure the libelf.so under test is picked up. Signed-off-by: Mark Wielaard <[email protected]>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-0912-5/+202
| | | | | | | | | | | | | | | 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 <[email protected]>
* tests: Rename argument from check to statement in elfshphehdr.c.Mark Wielaard2015-10-092-4/+9
| | | | | | Some older compilers warn about a function and argument name being equal. Signed-off-by: Mark Wielaard <[email protected]>
* strip: Only sanity check symbols to not discarded sections for debug file.Mark Wielaard2015-10-091-11/+5
| | | | | | | | | | | | | | We can only sanity check the symbols to discarded sections when creating a debug file. Otherwise we won't keep track of debug_data. This can trigger erroneously when there are relocation symbols in the symtab for a .debug section but we are not putting those symbols in a separate .debug file. Adjust run-strip-test.sh to always run in-place strip size check even for ET_REL files. Before this fix the sanity check would trigger for some ET_REL files because they contained such relocation symbols to .debug sections (but debug_data would be NULL because -f wasn't used). Signed-off-by: Mark Wielaard <[email protected]>
* Improve AM_SILENT_RULES coverageJosh Stone2015-10-062-1/+5
| | | | | | | | | | | 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 <[email protected]>
* Handle merged strtab/shstrtab string tables in strip and unstrip.Mark Wielaard2015-10-054-3/+758
| | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>