summaryrefslogtreecommitdiff
path: root/libdwfl/open.c
Commit message (Collapse)AuthorAgeFilesLines
* libdwfl: add check for elf_memory return valueAleksei Vetrov2023-01-261-0/+4
| | | | | | | elf_memory call in __libdw_open_elf_memory can return NULL. It was not checked and led to the null pointer dereference. Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
* Fix typos from codespellSam James2023-01-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | debuginfod/ChangeLog: * debuginfod-client.c: Typo simultaniously. doc/ChangeLog: * debuginfod.8: Typo succesfully. lib/ChangeLog: * dynamicsizehash_concurrent.c: Typo modul. * system.h: Typo dependend. libdwfl/ChangeLog: * open.c: Typo non-existant. src/ChangeLog: * nm.c: Typo Covert. * strings.c: Likewise. tests/ChangeLog: * elfstrmerge.c: Typo outselves. * run-debuginfod-extraction.sh: Typo accidentially. * run-debuginfod-fd-prefetch-caches.sh: Likewise. Signed-off-by: Sam James <sam@gentoo.org>
* libdwfl: Don't undef _Mark Wielaard2022-12-221-1/+0
| | | | | | | 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>
* Do not use relative include paths in library files.Mark Wielaard2022-12-201-1/+1
| | | | | | | | | 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>
* lib{asm,cpu,dw,dwfl,dwelf}: Move platform depended include into system.hYonggang Luo2022-10-281-2/+0
| | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* libdwfl: add dwfl_report_offline_memoryAleksei Vetrov2022-10-161-4/+26
| | | | | | | | | | | | | 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>
* libdwfl: Add ZSTD support.Mark Wielaard2020-09-211-0/+6
| | | | | | | | | | | | | | | Newer kernels might be compressed using ZSTD add support to libdwfl open so we can can automatically read ZSTD compressed files and kernel images. The support is very similar to the bzip2 and lzma support, but slightly different. With a bit more macros it could maybe have used the gzip.c USE_INFLATE code path. But I felt that the many macros didn't really help understand the code. So the unzip routine has a slightly different code path for ZSTD. https://sourceware.org/bugzilla/show_bug.cgi?id=26632 Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdwelf: Make dwelf_elf_begin return NULL only when there is an error.Mark Wielaard2019-08-131-3/+7
| | | | | | | | | | | | | | | | | | | | | | | dwelf_elf_begin was slightly different from elf_begin in case the file turned out to not be an ELF file. elf_begin would return an Elf handle with ELF_K_NONE. But dwelf_elf_begin would return NULL. This made it impossible to tell the difference between a file or decompression error and a (decompressed) file not being an ELF file. Since dwelf_elf_begin could still return different kinds of ELF files (ELF_K_ELF or ELF_K_AR - and theoretically ELF_K_COFF) this was not really useful anyway. So make it so that dwelf_elf_begin always returns an Elf handle unless there was a real error reading or decompressing the file. Otherwise return NULL to make clear there was a real error. Make sure that the decompression function returns DWFL_E_BADELF only when the file isn't compressed. In which case the Elf handle won't be replaced and can be returned (as ELF_K_NONE). Add a new version to dwelf_elf_begin so programs can rely on it returning NULL only for real errors. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdwelf: New function dwelf_elf_begin.Mark Wielaard2018-11-091-8/+22
| | | | | | | | | | | | | | | | | | This introduces a new function dwelf_elf_begin which creates a (read-only) ELF handle from a possibly compressed file handle or a file that start with a linux kernel header. This can be used in eu-readelf to (re)open a (pure) ELF. eu-readelf uses libdwfl to relocate addresses in the original file in case it is ET_REL. But to show the "raw" data it might need to (re)open the file. Which could fail if the file was compressed. And produced an obscure error message: "cannot create EBL handle". This rewrites __libdw_open_file a little so that the given file handle will never be closed (whether on success or failure) and introduces a new internal function __libdw_open_elf that dwelf_elf_begin wraps. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Avoid double-including config.hUlf Hermann2017-05-021-0/+4
| | | | | | | | | | | | | | | | config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through our own private headers. In order to set a clear rule about inclusion of config.h, it is now included in every .c file as first header, but not in any header. This will definitely avoid double-inclusion and satisfy the condition that it has to be included before gnulib headers. It comes at the price of adding some redundancy, but there is no clean way to avoid this. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Simplify code and build now that zlib support is no longer optional.Mark Wielaard2016-01-081-8/+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>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-091-2/+2
| | | | | | | | | | | | | | | 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>
* libdwfl: Try opening files all installed compression libraries.Mark Wielaard2013-02-221-3/+3
| | | | | | | | | | rhbz #909481. When a compression library wasn't installed libdwfl would not try the next compression library for opening a file. Retry with the next available compression library if a previous one isn't installed. Also disable tests that depend on a particular compression library (run-readelf-s.sh and run-dwflsyms.sh) if that library isn't installed. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Update name, license and contributor policy.Mark Wielaard2012-06-051-40/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change name from "Red Hat elfutils" to "elfutils". * Update license of standalone tools and test from GPLv2 to GPLv3+. * Change license of libraries from GPLv2+exception to GPLv2/LGPLv3+. * Add Developer Certificate of Origin based contributor policy. top-level: - COPYING: Upgraded from GPLv2 to GPLv3. - CONTRIBUTING, COPYING-GPLv2, COPYING-LGPLv3: New files. - NEWS: Added note about new contribution and license policy. - Makefile.am: Updated to GPLv3, added new files to EXTRA_DIST. - configure.ac: Update to GPLv3, changed AC_INIT name to 'elfutils'. backends, lib, libasm, libcpu, libdw, libdwfl, libebl, libelf: - All files updated to GPLv2/LGPLv3+. Except some very small files (<5 lines) which didn't have any headers at all before, the linker .maps files and the libcpu/defs files which only contain data and libelf/elf.h which comes from glibc and is under LGPLv2+. config: - elfutils.spec.in: Add new License: headers and new %doc files. - Update all license headers to GPLv2/LGPLv3+ for files used by libs. src, tests: - All files updated to GPLv3+. Except for the test bz2 data files, the linker maps and script files and some very small files (<5 lines) that don't have any headers. Signed-off-by: Richard Fontana <rfontana@redhat.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Rewrite kernel image support: use calculation instead of brute force, ↵Roland McGrath2009-08-271-20/+65
| | | | support uncompressed payloads.
* libdwfl: Support automatic decompression of files in XZ format.Roland McGrath2009-08-261-1/+7
|
* Fix crash in libdw with empty input files.Ulrich Drepper2009-02-101-0/+2
|
* Fix build when missing -lz and -lbz2.Roland McGrath2009-01-221-8/+15
|
* libdwfl automagic decompression supportRoland McGrath2009-01-051-0/+143