summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* support ZSTD compression algorithmMartin Liska2022-12-2310-125/+407
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | config/ChangeLog: * libelf.pc.in: Add LIBLZSTD to Requires.private. ChangeLog: * configure.ac: Detect ZSTD streaming API. libelf/ChangeLog: * Makefile.am: Use zstd_LIBS. * elf_compress.c: (__libelf_compress): Split into ... (__libelf_compress_zlib): ... this. (do_zstd_cleanup): New. (zstd_cleanup): New. (__libelf_compress_zstd): New. (__libelf_decompress): Switch in between zlib and zstd. (__libelf_decompress_zlib): Renamed from __libelf_decompress. (__libelf_decompress_zstd): New. (__libelf_decompress_elf): Dispatch in between compression algorithms. (elf_compress): Likewise. * elf_compress_gnu.c (elf_compress_gnu): Call with ELFCOMPRESS_ZLIB. * libelfP.h (__libelf_compress): Add new argument. (__libelf_decompress): Add chtype argument. src/ChangeLog: * elfcompress.c (enum ch_type): Add ZSTD. (parse_opt): Parse "zstd". (get_section_chtype): New. (process_file): Support zstd compression. (main): Add zstd to help. * readelf.c (elf_ch_type_name): Rewrite with switch. tests/ChangeLog: * Makefile.am: Add ELFUTILS_ZSTD if zstd is enabled. * run-compress-test.sh: Test zstd compression algorithm for debug sections.
* libdwfl: Don't undef _Mark Wielaard2022-12-225-4/+7
| | | | | | | A couple of files undefined _, which is defined in lib/eu-config.h as gettext helper macro. This seems unnecessary and arbitrary. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Add support for Synopsys ARCv2 processorsShahab Vahedi2022-12-2213-3/+262
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no regression in tests for an x86_64 build, while the new hello_arc_hs4.ko is added as well. This is the only meaningful test that I could add at the moment, given the features supported by this port. $ cat tests/test-suite.log ========================================== elfutils 0.188: tests/test-suite.log ========================================== # TOTAL: 236 # PASS: 235 # SKIP: 1 # XFAIL: 0 # FAIL: 0 # XPASS: 0 # ERROR: 0 .. contents:: :depth: 2 SKIP: run-lfs-symbols.sh ======================== LFS testing is irrelevant on this system SKIP run-lfs-symbols.sh (exit status: 77) $ cat tests/run-strip-reloc.sh.log runtest hello_i386.ko runtest hello_x86_64.ko runtest hello_ppc64.ko runtest hello_s390.ko runtest hello_aarch64.ko runtest hello_m68k.ko runtest hello_riscv64.ko runtest hello_csky.ko runtest hello_arc_hs4.ko <-- [ new ARC HS4 test ] runtest /home/shahab/pahole_pkg/elfutils-git/bld_arc/src/strip runtest /home/shahab/pahole_pkg/elfutils-git/bld_arc/src/strip.o runtest strip-uncompressed.o runtest strip-compressed.o runtest testfile-debug-rel-ppc64.o runtest testfile-debug-rel-ppc64-z.o runtest testfile-debug-rel-ppc64-g.o PASS run-strip-reloc.sh (exit status: 0) Signed-off-by: Shahab Vahedi <shahab@synopsys.email>
* lib: Remove -ffunction-sections for xmallocMark Wielaard2022-12-212-4/+4
| | | | | | The build used -ffunction-sections just for one file. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libcpu: Use __asm instead of asm to mark variables as usedYonggang Luo2022-12-212-2/+6
| | | | | | | This block of code can not be removed. As it's contains a goto label enomem that been used elsewhere. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* debuginfod: Define CURL_AT_LEAST_VERSION if necessaryMark Wielaard2022-12-212-0/+11
| | | | | | | | Older curl.h don't define CURL_AT_LEAST_VERSION, so define it ourselves because it is nicer than doing hex encoded version comparisons. Signed-off-by: Mark Wielaard <mark@klomp.org>
* PR29926: debuginfod: Fix usage of deprecated CURLINFO_*Andrew Paprocki2022-12-212-2/+6
| | | | | | | | | | | | | | | | | The `CURLINFO_SIZE_DOWNLOAD_T` and `CURLINFO_CONTENT_LENGTH_DOWNLOAD_T` identifiers are `enum`s, not pre-processor definitions, so the current `#ifdef` logic is not selecting the newer API. This results in the older identifiers being used and they now generate errors when compiled against Curl 7.87, which has silently deprecated them, causing GCC to emit `-Werror=deprecated-declarations`. Instead, the newer identifiers were added in Curl 7.55, so explicitly check for `CURL_AT_LEAST_VERSION(7, 55, 0)` instead of the current logic. This eliminates the error when compiling against Curl 7.87. Ref: https://github.com/curl/curl/pull/1511 Signed-off-by: Andrew Paprocki <andrew@ishiboo.com>
* Do not use relative include paths in library files.Mark Wielaard2022-12-2035-37/+82
| | | | | | | | | Rely on include dirs being set up correctly. Setup libdw AM_CPPFLAGS to include libebl directory. In libdwfl note that debuginfod.h is a generated file in the builddir. Only include it in the one file debuginfod-client.c that really needs it. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Add support for LoongArchHengqi Chen2022-12-199-3/+228
| | | | | | This implements initial support for the LoongArch architecture. Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
* libdwfl: Read no more than required in dwfl_segment_report_moduleGavin Li2022-12-132-25/+8
| | | | | | | | | | | | | | | Since read_portion and the standard dwfl_elf_phdr_memory_callback functions make sure to read at least minread bytes there is no need for dwfl_segment_report_module to check and adjust the data to the actual buffer size read. Reading beyond the end of the expected data size (if the buffer read is much larger) actually causes issues when passing the data to elfXX_xlatetom() because it is possible that src->d_size is not a multiple of recsize (for ELF_T_DYN, recsize is 16 while the minimum required alignment is 8), causing elfXX_xlatetom() to return ELF_E_INVALID_DATA. Signed-off-by: Gavin Li <gavin@matician.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Change typeof -> __typeof in memory-access.hYonggang Luo2022-12-122-5/+12
| | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* libcpu: Use "#define FCT_mod$64r_m FCT_mod$r_m" in i386_data.hYonggang Luo2022-12-122-1/+5
| | | | | | This is enough and can be recognized by clang-cl on windows Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* libelf: Sync elf.h from glibcMark Wielaard2022-12-012-7/+33
| | | | | | Adds various new ARC related declarations. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Refactor elf_compareMartin Liska2022-11-291-63/+110
| | | | | | | | | | | | | | | src/ChangeLog: * elfcompress.c (T_UNSET): Remove and use ch_type. (T_DECOMPRESS): Likewise. (T_COMPRESS_ZLIB): Likewise. (T_COMPRESS_GNU): Likewise. (enum ch_type): New. (parse_opt): Parse to new ch_type. (compress_section): Change gnu and compress arguments to schtype (source compression) and dchtype (destination compression). (process_file): Use new enum type and adjusted compress_section.
* Missing newline for: elfcompress -t zlib-gnu a.out -forceMartin Liska2022-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | Fixes: ./src/elfcompress -t zlib-gnu a.out -force [28] .zdebug_aranges unchanged, already GNU compressed[29] .zdebug_info unchanged, already GNU compressed[30] .zdebug_abbrev unchanged, already GNU compressed[31] .zdebug_line unchanged, already GNU compressed[32] .zdebug_str unchanged, already GNU compressed[33] .zdebug_line_str unchanged, already GNU compressed[34] .zdebug_rnglists unchanged, already GNU compressed to: ./src/elfcompress -t zlib-gnu a.out -force [28] .zdebug_aranges unchanged, already GNU compressed [29] .zdebug_info unchanged, already GNU compressed [30] .zdebug_abbrev unchanged, already GNU compressed [31] .zdebug_line unchanged, already GNU compressed [32] .zdebug_str unchanged, already GNU compressed [33] .zdebug_line_str unchanged, already GNU compressed [34] .zdebug_rnglists unchanged, already GNU compressed src/ChangeLog: * elfcompress.c (process_file): Add missing newline.
* readelf: print warning for -sWMartin Liska2022-11-282-5/+21
| | | | | | | | | | | | | | | | | | | | | The option -s accepts in elfutils (compared to binutils) a positional argument that is name of a symbol table section which should be printed. Thus, print a reasonable warning if -sW is used: ./src/readelf -sW a.out WARNING: cannot find section: 'W' PR29719 src/ChangeLog: * readelf.c (print_symtab): Change signature and return true if something is printed. (process_elf_file): Use it and print warning. tests/ChangeLog: * run-readelf-s.sh: Test -sW.
* debuginfod: Initialize response_data early in debuginfod-client queryMark Wielaard2022-11-212-2/+7
| | | | | | | | On error going to out2, the response_data is freed. So initialize the response_data to NULL immediately after allocation or when going back to query_in_parallel. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod-client.c: Don't treat 0 as an error code.Aaron Merey2022-11-072-2/+7
| | | | | | | Replace 'fd > 0' with 'fd >= 0' to avoid treating a possible file descriptor as an error code. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod_find_section: Always update rc with most recent error codeAaron Merey2022-11-042-1/+10
| | | | | | | | | debuginfod_find_section may attempt to download both the debuginfo and executable matching the given build-id. If neither of these files can be found, update rc to ensure that we always return an accurate error code in this case. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod.cxx: fix coverity-found use-after-release errorFrank Ch. Eigler2022-11-032-73/+75
| | | | | | | The debuginfod_client object lifetime needs more careful handling, made easier with the defer_dtor<> gadget. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* readelf: Check gelf_getdyn doesn't return NULLMark Wielaard2022-11-032-1/+6
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Don't dereference and assign values we are skippingMark Wielaard2022-11-032-1/+6
| | | | | | | We don't use the FDE address encoding byte, so no reason to read and store it. Just skip past it. Signed-off-by: Mark Wielaard <mark@klomp.org>
* readelf: Check phdr != NULL or shdr != NULL in handle_dynamic.Mark Wielaard2022-11-032-5/+10
| | | | | | | | | The compiler doesn't know that when use_dynamic_segment is true, then phdr should/will be non-NULL and otherwise shdr is non-NULL. Add explicit checks to help the compiler out and in case an error is made calling the handle_dynamic function. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Mark extract_section function staticMark Wielaard2022-11-022-1/+5
| | | | | | | The extract_section function in debuginfod-client.c is an internal function and should not be exported. Mark it as static. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Prepare for 0.188elfutils-0.188Mark Wielaard2022-11-0211-5937/+6189
| | | | | | | | Set version to 0.188 Update elfutils.spec.in Regenerate po/*.po files Signed-off-by: Mark Wielaard <mark@klomp.org>
* Changelog: Update entries from previous commits.Aaron Merey2022-11-012-0/+9
| | | | | | Update Changelogs with details from commits 04b1a3aa and 054b3bde9. Signed-off-by: Aaron Merey <amerey@redhat.com>
* run-debuginfod-section.sh: Avoid zstd-compressed rpmsAaron Merey2022-11-011-1/+1
| | | | | | | Only test using rpms without zstd compression. Older versions of libarchive may fail to handle these. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod-client: Fix out-of-bounds writeAaron Merey2022-11-011-2/+1
| | | | | | | Return early from path_escape when '\0' is seen in order to prevent an out-of-bounds write to the dest buffer. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod: Support queries for ELF/DWARF sectionsAaron Merey2022-11-0117-103/+882
| | | | | | | | | | | | | | | | | | | | | | Add new function debuginfod_find_section which queries debuginfod servers for the raw binary contents of the specified ELF/DWARF section in a file matching the given build-id. Extend the server webapi to support section queries. Section query URLS have the following format: /buildid/BUILDID/section/SECTION The server will attempt to extract the section from a debuginfo file matching the given build-id. If the debuginfo file cannot be found or the section has type SHT_NOBITS, the server will attempt to extract the section from the executable file matching the build-id. If the server is built without section query support, the client will attempt to download the debuginfo matching the build-id and extract the section. If the debuginfo file cannot be found or the section has type SHT_NOBITS, the server will attempt to download the executable file matching the build-id and extract the section. Signed-off-by: Aaron Merey <amerey@redhat.com>
* Rename 'hello{2,3}.spec.' -> 'hello{2,3}.specfile'Yonggang Luo2022-10-318-5/+23
| | | | | | | | | | | These filenames are invalid on win32. We don't want to include multiple .spec files for make rpm. rpmbuild --sign is not supported anymore. Also include hello3.specfile in EXTRA_DIST. Escape some macros in the elfutils.spec.in file comments. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* readelf: add binutils-style --syms optionArsen Arsenović2022-10-306-1/+23
| | | | | | This helps people with a lot of built up muscle memory :) Signed-off-by: Arsen Arsenović <arsen@aarsen.me>
* libelf: Sync elf.h from glibcMark Wielaard2022-10-292-5/+17
| | | | | | Adds ELFCOMPRESS_ZSTD, NT_S390_PV_CPU_DATA and NT_LOONGARCH_*. Signed-off-by: Mark Wielaard <mark@klomp.org>
* lib{asm,cpu,dw,dwfl,dwelf}: Move platform depended include into system.hYonggang Luo2022-10-2837-51/+55
| | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* debuginfod-client: Add DEBUGINFOD_HEADERS_FILE.Daniel Thornburgh2022-10-287-3/+74
| | | | | | | | This DEBUGINFOD_HEADERS_FILE environment variable names a file to supply HTTP headers to outgoing requests. Notably, this allows for Authorization headers to be added from a file under OS access control. Signed-off-by: Daniel Thornburgh <dthorn@google.com>
* configure.ac: Update AC_PROG_CC and AC_PROG_LEX for autoconf 2.70Mark Wielaard2022-10-272-2/+7
| | | | | | | | | With autoconf 2.70 we must use AC_PROG_CC (which will check for c11 and c99), for earlier versions we'll use AC_PROG_CC_C99. Also use AC_PROG_LEX([noyywrap]), the extra argument is ignored with earlier versions, but required for 2.70. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Use grep -E instead of egrep, use grep -F instead of fgrep.Mark Wielaard2022-10-2710-11/+26
| | | | | | | GNU grep 3.8 gives a deprecation warning when using egrep or fgrep. Just use grep -E and grep -F. Signed-off-by: Mark Wielaard <mark@klomp.org>
* config: Add BuildRequires socat for run-debuginfod-response-headers.shMark Wielaard2022-10-272-0/+6
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* readelf: Handle DW_LLE_GNU_view_pairMark Wielaard2022-10-274-1/+27
| | | | | | | | DW_LLE_GNU_view_pair is used by gcc -gvariable-location-views=incompat5. As described in http://www.fsfla.org/~lxoliva/papers/sfn/dwarf6-sfn-lvu.txt and proposed for DWARF6 https://dwarfstd.org/ShowIssue.php?issue=170427.1 Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Use #include <system.h> instead of <endian.h> in memory-access.hYonggang Luo2022-10-272-2/+6
| | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* libelf/libdwfl: Remove LIB_SYSTEM_H define in lib{elf,dwfl}_crc32.cYonggang Luo2022-10-274-2/+8
| | | | | | | | | | | | | rationale: https://sourceware.org/bugzilla/show_bug.cgi?id=21001 If we don't remove this macro, when try #include <system.h> in libdw/memory-access.h wont' take effect because "#define LIB_SYSTEM_H 1" The compile error: ./../libdw/memory-access.h:390:12: error: implicit declaration of function ‘bswap_32’ [-Werror=implicit-function-declaration] Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* libebl: Don't #include <dlfcn.h> in eblclosebackend.c and eblopenbackend.cYonggang Luo2022-10-273-2/+5
| | | | | | | It's not accessed symbols in dlfcn.h in eblclosebackend.c and eblopenbackend.c Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* debuginfod: report libmicrohttpd version on startupFrank Ch. Eigler2022-10-172-0/+6
| | | | | | To assist troubleshooting with intermittent bugs. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIANYonggang Luo2022-10-1717-31/+59
| | | | | | | | __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined by the gcc/clang preprocessor. BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN are defined in <endian.h>. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* Move the #include <libintl.h> into eu-config.hYonggang Luo2022-10-1632-31/+1
| | | | | | | | | | So we do not need include in each file. And indeed the macro #define _(Str) dgettext ("elfutils", Str) access libintl function dgettext, so it's make more sense #include <libintl.h> in file eu-config.h Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* move platform depended include into system.h of libelfYonggang Luo2022-10-1624-43/+43
| | | | | | | | All of these files either #include <system.h> directly or #include "libelfP.h" And now "libelfP.h also #include <system.h>, so the platform depended include can be moved to system.h safely Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* tests: include config.h first.Mark Wielaard2022-10-162-1/+6
| | | | | | | Otherwise some symbols (lseek, open) might not get the 64bit offset variants because they don't pick up _FILE_OFFSET_BITS. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Check lseek, read and malloc results with correct types in test.Mark Wielaard2022-10-162-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | When compiling dwfl-report-offline-memory.c on some systems (latest gcc/glibc and --enable-sanitize-undefined) we might get: In file included from /usr/include/features.h:490, from /usr/include/assert.h:35, from dwfl-report-offline-memory.c:18: In function ‘read’, inlined from ‘main’ at dwfl-report-offline-memory.c:68:23: /usr/include/bits/unistd.h:38:10: error: ‘__read_alias’ specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] 38 | return __glibc_fortify (read, __nbytes, sizeof (char), | ^~~~~~~~~~~~~~~ /usr/include/bits/unistd.h: In function ‘main’: /usr/include/bits/unistd.h:26:16: note: in a call to function ‘__read_alias’ declared with attribute ‘access (write_only, 2, 3)’ 26 | extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, | ^~~~~~~~~~ cc1: all warnings being treated as errors make[2]: *** [Makefile:2461: dwfl-report-offline-memory.o] Error 1 Fix by using the correct types and checking all return values. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdwfl: add dwfl_report_offline_memoryAleksei Vetrov2022-10-1613-4/+221
| | | | | | | | | | | | | This method allows to read and report ELF from memory instead of opening a file. That way arbitrary memory can be worked with, e.g. when coming from a stream without the need to persist. Another useful application is for fuzzing, because fuzzers might be able to track accesses to the memory and change the fuzzer input to cover more edge cases through more targeted input. Hence, add a new function along with a test case. Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
* tests: Add libeu to tests needing error() APIKhem Raj2022-10-132-30/+34
| | | | | | | | A local error() implementation is used when libc does not provide it, therefore link in libeu.a which contains this function in tests needing error() API Signed-off-by: Khem Raj <raj.khem@gmail.com>
* debuginfod-client: Ensure only negative error codes returned.Aaron Merey2022-09-282-2/+7
| | | | | Switch a couple error codes from positive to negative so they aren't interpreted as file descriptors by the caller.