summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tests/run-ar.sh: disable PIC/PIE/PLT for ar-extract-ar binariesAaron Merey2025-10-241-1/+1
| | | | | | | | | | | | | | Architecutres such as Debian i386 may enable PIE by default, resulting in test binaries that include extra symbols such as '__x86.get_pc_thunk.ax'. These extra symbols are added to test archive symbol indices. This changes ar-extract-ar output which causes test failures. Include '-fno-pic -fno-pie -fno-plt' when compiling test binaries to ensure that no extra symbols are added and no symbols are reordered. Signed-off-by: Aaron Merey <[email protected]>
* elf_getarhdr.c: Return correct header for archive within an archiveAaron Merey2025-10-244-0/+232
| | | | | | | | | | | | | | | | | | | | If elf_getarhdr is called on a descriptor that refers to an archive which is itself a member of another archive, it may return the Elf_Arhdr of the current member (i.e., the member selected by elf_next or elf_rand) of the inner archive instead of Elf_Arhdr of the inner archive itself. This also causes a memory leak: elf_end only attempts to free Elf_Arhdr fields ar_name and ar_rawname for descriptors that are not ELF_K_AR. To fix this, replace the state.elf[32|64] field elf_ar_hdr with new struct Elf field elf_ar_hdr. This field stores the Elf_Arhdr for all descriptors of archive members, including those with kind ELF_K_AR. Also rename the state.ar field elf_ar_hdr to cur_ar_hdr to clarify that this is the header of an archive's current member. Signed-off-by: Aaron Merey <[email protected]>
* elfclassify: Add --has-debug-sections classification optionMark Wielaard2025-08-281-0/+25
| | | | | | | | | | | | | | | | | | | There is --unstripped but that is whether the ELF file can be stripped (further) by removing any .[z]debug_* sections or symbol table (.symtab section). The --has-debug-sections option only checks whether there are .[z]debug sections present. * src/elfclassify.c (is_has_debug_sections): New function. (enum classify_check): Add classify_has_debug_sections. (check_checks): Add and print (if verbose) classify_has_debug_sections value. (main): Add ar-member to options. Update argp.doc to explain different debug options (--unstripped, --has-debug-section and --debug-only). * tests/run-elfclassify.sh: Add various --has-debug-sections tests. Signed-off-by: Mark Wielaard <[email protected]>
* elfclassify: Add --any-ar-member option to classify archive memberMark Wielaard2025-08-281-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | To determine whether an ELF archive contains a member of a particular type add a new input option to eu-elfclassify --any-ar-member. eu-elfclassify will match if a given file is an ELF archive and the classification options apply to at least one of the members. This can be used for example to check whether an ELF archive file contains ELF members that can be stripped by using: eu-elfclassify --ar-member --unstripped <ar-file> * src/elfclassify.c (current_path): Drop const. (flag_ar_member): New static bool. (classify_flag_ar_member): new enum member. (parse_opt): Handle classify_flag_ar_member. (check_checks): New function taken from... (process_current_path): ...here. (check_ar_members): New function. (main): Add ar-member to options. Update argp.doc. * tests/run-elfclassify.sh: Add various --any-ar-member tests. Signed-off-by: Mark Wielaard <[email protected]>
* elf_getarhdr: Replace per-archive Elf_Arhdr storage with per-member storageupstream/users/amerey/try-arhdrAaron Merey2025-08-201-8/+62
| | | | | | | | | | | | | | | | | | | | | | | Currently each archive descriptor maintains a single Elf_Arhdr for the current archive member (as determined by elf_next or elf_rand) which is returned by elf_getarhdr. A single per-archive Elf_Arhdr is not ideal since elf_next and elf_rand can invalidate an archive member's reference to its own Elf_Arhdr. Avoid this possible invalidation by storing each Elf_Arhdr in its archive member descriptor. The existing Elf_Arhdr parsing and storage in the archive descriptor internal state is left mostly untouched. When an archive member is created with elf_begin it is given its own copy of its Elf_Arhdr from the archive descriptor. Also update tests/arextract.c with verification that each Elf_Arhdr is distinct and remains valid after calls to elf_next that would have previously invalidated the Elf_Arhdr. Signed-off-by: Aaron Merey <[email protected]>
* drop executable bits from **/*.bz2Matthias Maennich2025-08-11160-0/+0
| | | | | | | | | | | | Archives are usually not meant to be executable and hence should not need the executable bit set. Drop it consistently to avoid unintential (and potentially harmful) execution. Note, no binary in this repository has been identified as harmful in any way; this is just a drive-by change. Suggested-by: Philipp Reichart <[email protected]> Signed-off-by: Matthias Maennich <[email protected]>
* debuginfod-find.c: Avoid leaving temp files in the cacheAaron Merey2025-08-111-2/+2
| | | | | | | | | | | | | | | | | Add a SIGINT handler to debuginfod-find so that ctrl-c during a download causes clean up to occur instead of immediately killing the process and possibly leaving temp files in the client cache. This change requires setting the client progressfn unconditionally instead of only when --verbose is given. This in turn requires a small change to a debuginfod-find testcase in run-debuginfod-artifact-running.sh to account for output differences between the debuginfod-find progressfn and the debuginfod_client default_progressfn which was previously used when debuginfod-find lacked -v but had DEBUGINFOD_PROGRESS=1 set. https://sourceware.org/bugzilla/show_bug.cgi?id=33163 Signed-off-by: Aaron Merey <[email protected]>
* libdwfl: resolve all paths relative to sysrootMichal Sekletar2025-06-021-0/+34
| | | | | | | | Whenever possible, resolve all symlinks as if the sysroot path were a chroot environment. This prevents potential interactions with files from the host filesystem. Signed-off-by: Michal Sekletar <[email protected]>
* tests: Create random test_dir nameMark Wielaard2025-05-131-1/+3
| | | | | | | | | | | | | | | | The testsuite relies on there being no files in the test directory after the test finishes. A test will fail if the test dir cannot be removed. But the test dir isn't really random, it uses the pid of the shell script that executes the test. On some of the buildbots that execute a lot of tests it can happen that the pid number wraps around and a pid of a previous pid is reused. To prevent that happening generate a real random number (8 bytes) using od /dev/urandom and xargs (to trim away spaces left by od). * tests/test-subr.sh: Define test_name and random_number and use those to define test_dir. Signed-off-by: Mark Wielaard <[email protected]>
* Revert "tests/run-stack-live-test.sh: prototype 'live' eu-stack testing"Serhei Makarov2025-05-082-66/+1
| | | | This reverts commit deca125665a76cf024bd063ff4f477cb675ad41e.
* tests/run-stack-live-test.sh: prototype 'live' eu-stack testingSerhei Makarov2025-05-082-1/+66
| | | | | | | | | | | | | | | | | | | | | | | | | Missing a few pieces, but worth sharing as an RFC. My idea is to ensure better test coverage for eu-stack and then eu-stacktrace+libdwfl_stacktrace by running against a live process with known content, stopped at a known location, and aggressively scrubbing output that's known to vary from testrun to testrun. This is a very basic preview of how that might look. If the approach is sound, I hope to make it more sophisticated/reliable. Unanswered questions: - Scrub more data (e.g. libc symvers) from a more known program. Scrub stack frame numbers to account for a case where extra frames appear / are missing at the bottom of the stack? - Something better than sed for the scrubbing? - An equivalent eu-stacktrace test will require privileged perf_events access for profiling data and therefore likely to be skipped by default. How feasible is it to be enabled on the buildbots, though? * tests/run-stack-live-test.sh: New test with wild and fuzzy testrun_compare variant that scrubs inherently unpredictable parts of the data. Needs to scrub even more. * tests/Makefile.am (TESTS): Add run-stack-live-test.sh.
* readelf: Add 'Key to Flags' to eu-readelf --section-headers outputSamuel Zeter2025-04-046-4/+104
| | | | | | | | | | | | | | | | | | When printing section headers, also include a key to what each flag is at the end of the section header output. * src/readelf.c (print_flag_info): New function. (print_shdr): Call print_flag_info. * tests/run-copyadd-sections.sh: Fix .extra grep by escaping \. * tests/run-large-elf-file.sh: Likewise. * tests/test-copymany-subr.sh: Likewise. * tests/run-readelf-z.sh: Add Key to Flags to expected output. * tests/run-retain.sh: Likewise. * tests/run-strip-remove-keep.sh: Likewise. https://sourceware.org/bugzilla/show_bug.cgi?id=29571 Signed-off-by: Samuel Zeter <[email protected]>
* tests/.gitignore: Add dwarf_language_lower_bound, test-manyfuncsAaron Merey2025-03-261-0/+2
| | | | Signed-off-by: Aaron Merey <[email protected]>
* tests/thread-safety-subr.sh: Change if [[ ]] to if [ ]Mark Wielaard2025-03-261-1/+1
| | | | | | | | | Using [[ is a bashism. We can just use [ since this is a simple comparision. * tests/thread-safety-subr.sh: Use if [ instead of if [[. Signed-off-by: Mark Wielaard <[email protected]>
* Add tests/run-eu-search-die.shHeather S. McIntyre2025-03-264-3/+266
| | | | | | | | | | | * tests/.gitignore: Add eu_search_die. * tests/Makefile.am: Add eu_search_die, run-eu-search-die.sh. * tests/eu_search_die.c: New file. * tests/run-eu-search-die.sh: New file. Signed-off-by: Heather S. McIntyre <[email protected]> Signed-off-by: Aaron Merey <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Add tests/run-eu-search-lines.shHeather S. McIntyre2025-03-264-2/+250
| | | | | | | | | | | | * tests/.gitignore: Add eu_search-lines. * tests/Makefile.am: Add eu_search_lines, run-eu-search-lines.sh. * tests/eu_search_lines.c: New file. tests/run-eu-search-lines.sh: New file. Signed-off-by: Heather S. McIntyre <[email protected]> Signed-off-by: Aaron Merey <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Add tests/run-eu-search-macros.shHeather S. McIntyre2025-03-264-3/+210
| | | | | | | | | | | | * tests/.gitignore: Add eu_search_macros.sh * tests/Makefile.am: Add eu_search_macros, run-eu-search-macros.sh. * tests/eu_search_macros.c: New file. * tests/run-eu-search-macros.sh: New file. Signed-off-by: Heather S. McIntyre <[email protected]> Signed-off-by: Aaron Merey <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Add tests/run-eu-search-cfi.shHeather S. McIntyre2025-03-264-2/+240
| | | | | | | | | | | * tests/.gitignore: Add eu_search_cfi. * tests/Makefile.am: Add eu_search_cfi, run-eu-search-cfi.sh. * tests/eu_search_cfi.c: New file. * tests/run-eu-search-cfi.sh: New file. Signed-off-by: Heather S. McIntyre <[email protected]> Signed-off-by: Aaron Merey <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Add tests/thread-safety-subr.shAaron Merey2025-03-262-1/+34
| | | | | | | | | | thread-safety-subr.sh contains subroutine check_thread_safety_enabled which skips further testing when USE_LOCKS is false. * tests/Makefile.am (EXTRA_DIST): Add thread-safety-subr.sh. * tests/thread-safety-subr.sh: New file. Signed-off-by: Aaron Merey <[email protected]>
* Add configure option --enable-helgrindAaron Merey2025-03-261-0/+4
| | | | | | | | | | | | | | | | Like --enable-valgrind but uses helgrind instead of memcheck. If both --enable-valgrind and --enable-helgrind are given then helgrind takes priority. --enable-helgrind requires --enable-valgrind-annotations. * configure.ac: Add --enable-helgrind option. * tests/Makefile.am: If USE_HELGRIND is true, then include --tool=helgrind in the valgrind command that tests are run under. Signed-off-by: Aaron Merey <[email protected]>
* readelf: Add support for printing DW_AT_language_name DW_LNAMEsMark Wielaard2025-03-113-0/+94
| | | | | | | | | | | | | | | | | | Add a testfile using GCC 15 (experimental). * libdw/dwarf.h: Add DW_LNAME_lo_user and DW_LNAME_hi_user. * src/readelf.c (dwarf_lname_string): New function. (dwarf_lname_name): Likewise. (attr_callback): Handle DW_AT_language_name by calling dwarf_lname_name. * run-readelf-lnames.sh: New test. * testfile-lnames.bz2: New testfile. * tests/Makefile.am (TESTS): Add run-readelf-lnames.sh. (EXTRA_DIST): Add run-readelf-lnames.sh and testfile-lnames.bz2. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add dwarf_language and dwarf_language_lower_bound functions.Mark Wielaard2025-03-092-1/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dwarf_language returns a DW_LNAME constant for a CU Die. If the CU Die has a DW_AT_language_name attribute dwarf_language will return it and the DW_AT_language_version attribute value. Otherwise dwarf_language will lookup the (old style) DW_AT_language attribute and translate the DW_LANG constant into a DW_LNAME constant and version using a new static function srclang_to_language. The dwarf_language_lower_bound function works just like the dwarf_default_lower_bound function, but takes a DW_LNAME constant instead of a DW_LANG constant. Adds a new test to make sure dwarf_language_lower_bound handles all known DW_LNAME constants. * NEWS: Add new functions. * libdw/libdw.map (ELFUTILS_0.193): New section with new functions. * libdw/libdw.h (dwarf_srclang): Add comment explaining this returns DW_LANG constants. (dwarf_language): New function. (dwarf_default_lower_bound): Add comment explaining this works on DW_LANG constants. (dwarf_language_lower_bound): New function. * libdw/libdwP.h: INTDECL dwarf_language and dwarf_language_lower_bound. * libdw/dwarf_srclang.c (srclang_to_language): New function. (dwarf_language): Likewise. * libdw/dwarf_default_lower_bound.c (dwarf_language_lower_bound): New function. * libdw/dwarf_getfuncs.c (dwarf_getfuncs): Use dwarf_language and dwarf_language_lower_bound. * libdw/dwarf_aggregate_size.c (array_size): Likewise. * tests/dwarf_language_lower_bound.c: New test. * tests/Makefile.am (check_PROGRAMS): Add dwarf_language_lower_bound. (TESTS): Likewise. (dwarf_language_lower_bound_LDADD): New variable. Signed-off-by: Mark Wielaard <[email protected]>
* PR31862: debuginfod: client to cache x-debuginfod-* headersFrank Ch. Eigler2025-03-051-0/+7
| | | | | | | | | | | | | | | | This feature allows the extra http headers from debuginfod to be saved into the client cache, and also thus replayed to clients. This way they can perform IMA verification again, if they like, or a federating caching intermediate debuginfod server can replay the headers it received previously from upstream to future downstream. The headers are placed adjacent to the payload files .cache/debuginfod/BUILDID/PAYLOAD as .cache/debuginfod/BUILDID/hdr-PAYLOAD. They are aged the same atime-based way. Testing via an extension of a previous small test, and hand-running both client & server code under valgrind. No memcheck errors reported. Signed-off-by: Frank Ch. Eigler <[email protected]>
* libelf: Rewrite elf_scnshndx, extended index table handlingMark Wielaard2025-03-016-6/+483
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | elf_scnshndx is a elfutils extension to libelf that given a SHT_SYMTAB section returns the index to the corresponding SHT_SYMTAB_SHNDX section, if it exists. This is needed when there are more than 64K sections and there are symbols that have to refer to a section with an index larger than 64K, because the Elf Sym st_shndx field is only 16 bits. This was implemented by adding an shndx_index field to the Elf_Scn struct which is updated when reading the section headers. This takes up space in every section and is hard to proof correct. In the case of using ELF_C_READ_MMAP the shndx_index field was only updated when the shdrs needed to be converted from file to memory order. And the two places were this function was used in readelf.c and elf-print-reloc-syms.c the wrong section was used to lookup the extended index table. There were also no tests for this functionality. Replace the elf_scnshndx implementation with a simpler lookup over all sections. This sounds inefficient, but in practice the SHT_SYMTAB_SHNDX section is the next section after the SHT_SYMTAB section. elf_scnshndx only needs to be called when there are more than SHN_LORESERVE (0xff00) sections. And normally a user would just lookup the SHT_SYMTAB and SHT_SYMTAB_SHNDX sections at the same time (which is what readelf does when showing the symbol table, as does nm, objcopy and libdwfl). Add a testfile manyfuncs.c that when compiled contains 64K symbols and sections. Make sure to use -fasynchronous-unwind-tables so there is at least one relocatable section that uses all function symbols (e.g. on arm32 where there is no .eh_frame by default). This can then be used to verify the readelf --relocs support. Add another test, test-manyfuncs that explicitly goes through the symbol table and associated extended index table and verify each function symbol matches the section name. There are For riscv there are local, notype, symbols at the start of each executable section which relocations refer to instead of the section symbol. Since all these local symbols are called ".L0" this isn't very useful, so print the section name instead. For powerpc ELFv1 all function symbols go through the .opd section. Allow this in the new test-manyfuncs test. * libelf/elf32_getshdr.c (load_shdr_wrlock): Remove handling of shndx_index. * libelf/elf_begin.c (file_read_elf): Likewise. * libelf/elf_scnshndx.c (elf_scnshndx): Rewritten. * libelf/libelf.h (elf_scnshndx): Added full documentation. * libelf/libelfP.h (struct Elf_Scn): Remove shndx_index field. (__elf_scnshndx_internal): Removed. * src/readelf.c (handle_relocs_rel): Use symscn in call to elf_scnshndx. Print section name for local start section label. (handle_relocs_rela): Likewise. * tests/Makefile.am (check_PROGRAMS): Add test-manyfuncs. (manyfuncs.o): New target. (check-local): New target, depends on manyfuncs.o. (TESTS): Add run-readelf-r-manyfuncs.sh and run-test-manyfuncs.sh. (EXTRA_DIST): Add run-readelf-r-manyfuncs.sh, run-test-manyfuncs.sh and manyfuncs.c. (test_manyfuncs_LDADD): New variable. (EXTRA_test_manyfuncs_DEPENDENCIES): New variable. (CLEANFILES): Add manyfuncs.o. * tests/elf-print-reloc-syms.c (print_reloc_symnames): Use symscn in call to elf_scnshndx. * tests/manyfuncs.c: New test file to generate 64K symbols and sections. * tests/run-readelf-r-manyfuncs.sh: New test wrapper. * tests/run-test-manyfuncs.sh: Likewise. * tests/test-manyfuncs.c: New test. Signed-off-by: Mark Wielaard <[email protected]>
* tests/Makefile.am: Add --track-fds=yes to valgrind_cmdAaron Merey2025-02-071-1/+1
| | | | | | | `valgrind --track-fds=yes` will report errors for file descriptor leaks and attempts at closing invalid file descriptors. Signed-off-by: Aaron Merey <[email protected]>
* tests: Avoid leaking file descriptorsAaron Merey2025-02-0716-2/+25
| | | | | | | | Add calls to close for all test programs that leak file descriptors in order to prevent test failures when run under valgrind --track-fds=yes. Signed-off-by: Aaron Merey <[email protected]>
* tests/backtrace-subr.sh: Avoid valgrind track-fds in check_native_coreAaron Merey2025-02-071-1/+9
| | | | | | | | | | valgrind --track-fds=yes might incorrectly report an error due to the use of inherited file descriptors in check_native_core. Prevent this false positive by temporarily removing "--track-fds=yes" from $VALGRIND_CMD for the duration of the testrun in check_native_core. Signed-off-by: Aaron Merey <[email protected]>
* Consolidate list of custom phony targetsMichael Pratt2025-01-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Having a target defined as phony within a condition while another target is always defined as phony causes an automake warning: Makefile.am:67: warning: .PHONY was already defined in condition TRUE, which includes condition GCOV ... config/eu.am:141: ... '.PHONY' previously defined here Makefile.am:21: 'config/eu.am' included from here tests/Makefile.am:895: warning: .PHONY was already defined in condition TRUE, which includes condition GCOV ... config/eu.am:141: ... '.PHONY' previously defined here tests/Makefile.am:19: 'config/eu.am' included from here Instead, list all the custom targets that are phony in the common definitions in the eu.am file. Since it is all related to coverage at this moment, the list can be grouped as it is instead of moved or split. * Makefile.am: remove .PHONY list in conditional * config/eu.am: add coverage target to .PHONY list * tests/Makefile.am: remove .PHONY list in conditional Signed-off-by: Michael Pratt <[email protected]>
* debuginfod: in --cors mode, add CORS response headers and OPTIONS methodHenning Meyer2024-12-082-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CORS is the Cross-Origin-Resource-Sharing mechanism explained at https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS 1. by default JavaScript code from Website A cannot request arbitrary resources from website B, these are called cross-origin-requests 2. The browser performs what is called a preflight check, this the OPTIONS method 3. the response allows website B fine-grained control over what the web browser should allow 4. Setting "Access-Control-Allow-Origin: *" tells the web browser to allow all access, e.g. the same behavior you get with curl or debuginfod-find The website mentions that the corresponding spec has been changed, such that preflight requests are no longer necessary, but in the browsers I use today (Firefox 132 and Chromium 131) they are still necessary. I have confirmed that I can use debuginfod with this patch from my web application at https://core-explorer.github.io/cdx-type/ FChE simplified the code and added a few quick "curl -i | grep" tests to confirm the new headers are there. * debuginfod/debuginfod.cxx (handle_options): New function. (handler_cb): Call it for OPTIONS. Add ACAO header for all successful requests. (parse_opt): Parse --cors. * tests/run-debuginfod-federation-metrics.sh, tests/run-debuginfod-find-metadata.sh: Lightly test. * doc/debuginfod.8: Document --cors option, default off. Signed-off-by: Henning Meyer <[email protected]> Signed-off-by: Frank Ch. Eigler <[email protected]>
* libdw: Update DW_LANG codesMark Wielaard2024-12-021-12/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Pick up the language codes published after DWARF5 was published. The are listed at https://dwarfstd.org/languages.html Also adjust C language dectection in dwarf_getfuncs and update the dwarf_default_lower_bound function to return the default lower bounds for the new langauge codes. There is one small change in dwarf_default_lower_bound. We now return zero instead of an error when called for DW_LANG_Mips_Assembler. Since there is now an "official" DW_LANG_Assembly which is explicitly defined as having a default lower bound of zero. It seems better to do the same for the vendor code too. * libdw/dwarf.h: Add new DW_LANG codes. * libdw/dwarf_default_lower_bound.c (dwarf_default_lower_bound): Handle new language codes and remove a special case for DW_LANG_Mips_Assembler. * libdw/dwarf_getfuncs.c (dwarf_getfuncs): Check against DW_LANG_C17 and DW_LANG_C23. * tests/dwarf_default_lower_bound.c: Also check for DW_LANG_Mips_Assembler. Signed-off-by: Mark Wielaard <[email protected]>
* Consolidate and add files to clean target variablesupstream/users/amerey/try-cleanMichael Pratt2024-11-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | To increase the consistency of how automatic clean targets run, define the variables together without +=, default to MOSTLYCLEANFILES when there is no need for different levels or add more clean levels to match other subdirectories, add more files that are built, remove duplication, and cleanup. Do the same for EXTRA_DIST where it is equally messy. * backends/Makefile.am: add more objects to clean, improve spacing. * debuginfod/Makefile.am: Likewise, and remove duplicates. * lib/Makefile.am: improve spacing. * libasm/Makefile.am: add more objects to clean, split similar to debuginfod. * libcpu/Makefile.am: use normal =, add more objects to clean. * libdw/Makefile.am: add more objects to clean, split similar to debuginfod. * libdwelf/Makefile.am: add more objects to clean, use lowest clean level. * libdwfl/Makefile.am: Likewise. * libebl/Makefile.am: add more objects to clean. * libelf/Makefile.am: add more objects to clean, split similar to debuginfod. * src/Makefile.am: consolidate including EXTRA_DIST, split clean levels, define with normal =, define with variables. * tests/Makefile.am: Likewise, but not including EXTRA_DIST. Signed-off-by: Michael Pratt <[email protected]>
* tests/.gitignore: Add newzdataAaron Merey2024-10-291-0/+1
| | | | Signed-off-by: Aaron Merey <[email protected]>
* tests: run-debuginfod-seekable.sh depends on LZMA and DEBUGINFODMark Wielaard2024-10-241-1/+4
| | | | | | | | | | | The run-debuginfod-seekable.sh test would run (and fail) if lzma support was enabled, but debuginfod wasn't build. Only run it when both are available. * tests/Makefile.am (TESTS): Add run-debuginfod-seekable.sh if DEBUGINFOD and LZMA. Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Treat elf_memory image as writableMark Wielaard2024-10-181-2/+4
| | | | | | | | | | | | | | | | | | | | | There are use cases where the Elf image created by elf_memory is manipulated, through the libelf interfaces, in place. This doesn't work anymore since we changed elf_memory to assume the memory is read-only in elfutils 0.191. commit cc44ac674 ('libelf: Treat elf_memory as if using ELF_C_READ_MMAP'). The reason for that change was that if elf_memory was given a read-only memory image then decompressing a section with elf_compress would crash. Since it directly writes the updated Shdr size. If you do want to use elf_compress on an Elf created by elf_memory you have make sure the memory is writable. You can do this for example by using mmap PROTE_WRITE and MAP_PRIVATE. * libelf/elf_memory.c (elf_memory): Call __libelf_read_mmaped_file with ELF_C_READ_MMAP_PRIVATE. * tests/elfgetzdata.c (main): Use mmap PROT_WRITE and MAP_PRIVATE. Signed-off-by: Mark Wielaard <[email protected]>
* libelf: elf_compress doesn't handle multiple elf_newdata chunks correctlyMark Wielaard2024-10-182-2/+505
| | | | | | | | | | | | | | | | | | | elf_compress would compress all (new) data chunks, but didn't reset the section data_list. This would cause extra data to be returned after decompression or create bad compressed data. Add a new testcase for this and explicitly zap the scn->data_list before resetting the elf section raw data after (de)compression. * libelf/elf_compress.c (__libelf_reset_rawdata): Cleanup scn->data_list. * tests/newzdata.c: New testcase. * tests/Makefile.am (check_PROGRAMS): Add newzdata. (TESTS): Likewise. (newzdata_LDADD): New variable. https://sourceware.org/bugzilla/show_bug.cgi?id=32102 Signed-off-by: Mark Wielaard <[email protected]>
* eu-stacktrace [4/5]: src: add unwind origin diagnostics to eu-stackSerhei Makarov2024-10-171-1/+14
| | | | | | | | | | | | | | | | | | | Since we obtain diagnostics about unwind method, another logical place to show them is in eu-stack. * src/stack.c (show_unwound_source): New global variable. (struct frame): Add unwound_source field. (frame_callback): Copy over unwound_source from Dwfl_Frame. (print_frame): Take unwound_source string and print it. (print_inline_frames): Take unwound_source argument and pass it on, except for subsequent frames where we pass the string "inline". (print_frames): Take unwound_source field from struct frame and pass it on. (parse_opt): Add --cfi-type,-c option to set show_unwound_source. (main): Ditto. * tests/run-stack-i-test.sh: Add testcase for --cfi-type. Signed-off-by: Serhei Makarov <[email protected]>
* Remove usage of "unlocked" variant of stdio print functionsMichael Pratt2024-10-171-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These "unlocked" Linux Standard Base variants of standard functions are not available on some systems that are still capable of building Linux and ELFs. The difference is negligible for simple printing to stdout. POSIX also states for the similar putc_unlocked(): These functions can safely be used in a multi-threaded program if and only if they are called while the invoking thread owns the (FILE *) object, as is the case after a successful call to the flockfile() or ftrylockfile() functions. ... These unlocked versions can be safely used only within explicitly locked program regions, using exported locking primitives. and these precautions were never done. Use the standard forms of these print functions. There is inconsistent use of fputc_unlocked() with putc_unlocked(), so consistently use the safer fputc() instead. Signed-off-by: Michael Pratt <[email protected]>
* PR32218: debuginfod-client: support very long source file namesFrank Ch. Eigler2024-10-167-9/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | debuginfod clients & servers may sometimes encounter very long source file names. Previously, the client would synthesize a path name like $CACHEDIR/$BUILDID/source-$PATHNAME where $PATHNAME was a funky ##-encoded version of the entire source path name. See https://sourceware.org/PR32218 for a horror case. This can get too long to store as a single component of a file system pathname (e.g. linux/limits.h NAME_MAX), resulting on client-side errors even after a successful download. New code switches encoding of the $PATHNAME part to use less escaping, and a merciless truncation to the tail part of the filename. (We keep the tail rather than the head, so that the extension is preserved, which makes some consumers happier.) To limit collision damage from truncation, we add also insert a goofy hash (4-byte DJBX33A) of the name into the path name. The result is a relatively short name: $CACHEDIR/$BUILDID/source-$HASH-$NAMETAIL This is a transparent change to clients, who are not to make any assumptions about cache file naming structure. However, one existing test did make such assumptions, so is fixed with some globness. A new test is also added, using a pre-baked tarball with a very long srcfile name. Signed-off-by: Frank Ch. Eigler <[email protected]>
* tests/test-subr.sh: Put test_dir under /var/tmp.Frank Ch. Eigler2024-10-101-2/+3
| | | | | | | | | | | | | | | | | Every individual test in elfutils involves a temporary directory. Previous version of this script put that directory under the build tree. That's OK if it's a local disk, but if it's on NFS, then some tests - run-large-elf-file.sh, several run-debuginfod-*.sh - take long enough to run to fail tests intermittently. This patch moves the temp_dir under ${TMPDIR-/var/tmp/}, so it operates at local disk speed rather than whatever-build-filesystem speed. Individual test scripts are all unaffected. (One could consider /tmp instead, which is a RAM disk on modern systems, except that some of the elfutils tests produce GB-sized temporary files. That's probably too big for RAM.) Signed-off-by: Frank Ch. Eigler <[email protected]>
* tests: Fix specifying constant of double typeKhem Raj2024-10-031-1/+1
| | | | | | | | | | | | | | | 'd' suffix seems to be not acceptable by clang compiler Using 'e0' fixes this by keeping value to be same Fixes funcretval_test_struct.c:83:27: error: invalid suffix 'd' on floating constant 83 | dpoint_t dp = dmkpt (3.0d, 1.0d); | ^ funcretval_test_struct.c:83:33: error: invalid suffix 'd' on floating constant 83 | dpoint_t dp = dmkpt (3.0d, 1.0d); | Signed-off-by: Khem Raj <[email protected]>
* srcfiles: Fix compile with --disable-libdebuginfodMark Wielaard2024-09-102-2/+3
| | | | | | | | | | | | | | | | | The eu-srcfiles --no-backup option is only valid when build with libdebuginfod support. Adjust the ENABLE_LIBDEBUGINFOD conditional to not use no_backup anywhere. Also only run the run-srcfiles-self.sh test when debuginfod is enabled. * src/srcfiles.cxx (zip_files): Move endif ENABLE_LIBDEBUGINFOD after no_backup check. * tests/Makefile.am (TESTS): Only add run-srcfiles-self.sh if DEBUGINFOD and !DUMMY_LIBDEBUGINFOD. * tests/run-srcfiles.self.sh: Use local DEBUGINFOD_CACHE_PATH. https://sourceware.org/bugzilla/show_bug.cgi?id=32155 Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Fix printing of .gdb_index symbol table offset.Mark Wielaard2024-09-071-4/+4
| | | | | | | | | | | | | We were printing the addr_off instead of the sym_off. And the testcases all expected the address offset instead of the symbol table offset. * src/readelf.c (print_gdb_index_section): Print sym_off as Symbol table offset. * tests/run-readelf-gdb_index.sh: Fix up all symbol table offsets that were the same as the address offset. Signed-off-by: Mark Wielaard <[email protected]>
* aarch64: Create definitions for AARCH64_RA_SIGN_STATE registerGerman Gomez2024-08-302-0/+2
| | | | | | | | | | | This register will be used to indicate whether a return address is mangled with a PAC or not, in accordance with the DWARF AARCH64 ABI [1]. [1] https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#41dwarf-register-names Signed-off-by: German Gomez <[email protected]> [SteveC: move DW_AARCH64_RA_SIGN_STATE to cfi.h, fix comments] Signed-off-by: Steve Capper <[email protected]>
* tests: When BUILD_STATIC always link against libeuMark Wielaard2024-08-211-1/+1
| | | | | | | | | | libeu is a static library with internal helper functions normally included in all shared libraries. But when linking static (with --enable-gcov) we need to explicitly link it into the test binaries. * tests/Makefile.am (libelf): Add $(libeu) when BUILD_STATIC. Signed-off-by: Mark Wielaard <[email protected]>
* debuginfod: populate _r_seekable on requestOmar Sandoval2024-07-241-0/+48
| | | | | | | | | | | | | | Since the schema change adding _r_seekable was done in a backward compatible way, seekable archives that were previously scanned will not be in _r_seekable. Whenever an archive is going to be extracted to satisfy a request, check if it is seekable. If so, populate _r_seekable while extracting it so that future requests use the optimized path. The next time that BUILDIDS is bumped, all archives will be checked at scan time. At that point, checking again will be unnecessary and this commit (including the test case modification) can be reverted. Signed-off-by: Omar Sandoval <[email protected]>
* debuginfod: populate _r_seekable on scanOmar Sandoval2024-07-2411-2/+174
| | | | | | | | | Whenever a new archive is scanned, check if it is seekable with a little liblzma magic, and populate _r_seekable if so. With this, newly scanned seekable archives will used the optimized extraction path added in the previous commit. Also add a test case using some artificial packages. Signed-off-by: Omar Sandoval <[email protected]>
* tests/run-debuginfod-fd-prefetch-caches.sh: disable fdcache limit checkOmar Sandoval2024-07-241-0/+4
| | | | | | | | | | | | | | | Since commit acd9525e93d7 ("PR31265 - rework debuginfod archive-extract fdcache"), the fdcache limit is only applied when a new file is interned and it has been at least 10 seconds since the limit was last applied. This means that the fdcache can go over the limit temporarily. run-debuginfod-fd-prefetch-caches.sh happens to avoid tripping over this because of lucky sizes of the files used in the test. However, adding new files for an upcoming test exposed this failure. Disable this part of the test for now. Signed-off-by: Omar Sandoval <[email protected]>
* debuginfod: fix skipping <built-in> source fileOmar Sandoval2024-07-242-2/+2
| | | | | | | | | | | | | dwarf_extract_source_paths explicitly skips source files that equal "<built-in>", but dwarf_filesrc may return a path like "dir/<built-in>". Check for and skip that case, too. In particular, the test debuginfod RPMs have paths like this. However, the test cases didn't catch this because they have a bug, too: they follow symlinks, which results in double-counting every file. Fix that, too. Signed-off-by: Omar Sandoval <[email protected]>
* libdwfl: Make dwfl_report_offline_memory work with ELF_C_READ_MMAPAleksei Vetrov2024-07-123-7/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | elf_memory open mode recently changed from ELF_C_READ to ELF_C_READ_MMAP. This broken dwfl_report_offline_memory that changes mode to ELF_C_READ_MMAP_PRIVATE to be compatible with subsequent elf_begin on embedded ELF files. The proper implementation of dwfl_report_offline_memory doesn't change open mode and subsequent elf_begin invocations simply use cmd from the reference Elf*. Add tests to exercise Elf* to trigger the bug caused by incorrect cmd set to Elf*. * libdwfl/offline.c (process_archive): Use archive->cmd instead of hardcoded ELF_C_READ_MMAP_PRIVATE. * libdwfl/open.c (libdw_open_elf): Use elf->cmd instead of hardcoded ELF_C_READ_MMAP_PRIVATE. (__libdw_open_elf_memory): Don't override (*elfp)->cmd. * tests/Makefile.am (dwfl_report_offline_memory): Add libelf as dependency. * tests/dwfl-report-offline-memory.c: Add count_sections to exercise Elf* from dwfl_report_offline_memory. * tests/run-dwfl-report-offline-memory.sh: Add expected number of sections to test invocations. Signed-off-by: Aleksei Vetrov <[email protected]>
* tests/run-sysroot.sh: Call exit_cleanup directlyAaron Merey2024-07-111-0/+2
| | | | | | exit_cleanup needs to be called directly since this test traps EXIT. Signed-off-by: Aaron Merey <[email protected]>