summaryrefslogtreecommitdiffstats
path: root/libdwfl
Commit message (Collapse)AuthorAgeFilesLines
* libdwfl: Use elf_compress[_gnu] to decompress string, symbol and reloc data.Mark Wielaard2016-01-053-31/+194
| | | | | | | | | This makes usage of the libdwfl symbol functions work out of the box even when some sections (string, symbol or xndx) are compressed. For ET_REL files this makes relocations just work by making sure the target section is decompressed first before relocations are applied. Signed-off-by: Mark Wielaard <[email protected]>
* Move nested functions in linux-proc-maps.c to file scope.Chih-Hung Hsieh2016-01-032-14/+22
| | | | | | * Move nested function 'report' to file scope to compile with clang. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Move nested functions in core-file.c to file scope.Chih-Hung Hsieh2016-01-032-42/+59
| | | | | | * Move nested functions 'fail', 'update_end', and 'more' to file scope. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Move nested functions check64 and check32 in link_map.c to file scope.Chih-Hung Hsieh2016-01-032-47/+58
| | | | | | | | * In libdwfl/link_map.c, nested functions check64, check32, are moved to file scope to compile with clang. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: make the unwinder aware of the backend defined ra_offset.Jose E. Marchesi2016-01-033-2/+16
| | | | | | | | | Ebl backends can define an offset that must be applied to the value of the "return address register" defined in the CFI ABI information. This patch makes the unwinder to use that offset when reading the RA CFI register. Signed-off-by: Jose E. Marchesi <[email protected]>
* libdwfl: Fix memory leak in link_map.c dwfl_link_map_report.Mark Wielaard2016-01-022-2/+12
| | | | | | | | The phdrs buffer could come from the core file or through the executable. dwfl_link_map_report would leak the buffer if it came from the executable. Track where the buffer came from and free appropriately. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't leak core Elf and core file descriptor from argp-std.Mark Wielaard2016-01-027-17/+82
| | | | | | | | Our argp helper would leak the core Elf and core file descriptor when given by the user. Store both in the Dwfl as a new Dwfl_User_Core so they get cleaned up by dwfl_end. Signed-off-by: Mark Wielaard <[email protected]>
* Move nested functions in dwfl_module_getdwarf.c to file scope.Chih-Hung Hsieh2016-01-022-148/+165
| | | | | | | | * In dwfl_module_getdwarf.c, nested functions 'consider_shdr' and 'translate_offs' are moved to file scope to compile with clang. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Move nested functions in dwfl_module_addrsym.c to file scope.Chih-Hung Hsieh2016-01-022-148/+193
| | | | | | | * Move nested functions 'same_section', 'binding_value', 'try_sym_value', and 'search_table'. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* libdw: Make sure Ebl is always freed from cfi frame cache.Mark Wielaard2015-11-272-4/+25
| | | | | | | | | | | | | | libdwfl sets the Dwfl_Module Ebl for the eh_cfi and dwarf_cfi cache to save a bit of memory. It also calls ebl_closebackend on the ebl to free it. The Dwarf_CFI never frees the Ebl in the cache, even when it opened one itself. This means that if only libdw calls are used to access the Dwarf_CFI the Ebl might be leaked. Always destroy the Dwarf_CFI cache Ebl in __libdw_destroy_frame_cache. And in __libdwfl_module_free clear the Dwarf_CFI Ebl if it is the Dwfl_Module Ebl before calling dwarf_cfi_end and dwarf_end. Signed-off-by: Mark Wielaard <[email protected]>
* Move nested functions in gzip.c to file scope.Chih-Hung Hsieh2015-11-132-120/+153
| | | | | | | | * libdwfl/gzip.c should now compile with clang. All local variables used by nested functions are passed in an unzip_state structure. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Move nested functions in dwfl_module_getsrc_file.c.Chih-Hung Hsieh2015-11-032-15/+28
| | | | | | | | | * Nested functions in this file are moved to file scope to compile with clang. Extra parameters are added to pass local variables. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Move nested functions in frame_unwind.c.Chih-Hung Hsieh2015-11-032-73/+95
| | | | | | | | * Nested functions 'pop' and 'push' in libdwfl/frame_unwind.c are moved to file scope. Used local variables are passed in struct eval_stack. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Move nested functions in dwfl_module.cChih-Hung Hsieh2015-11-032-16/+22
| | | | | | | | * Nested functions in this file are moved to file scope to compile with clang. Extra parameters are added to pass local variables. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-0916-42/+75
| | | | | | | | | | | | | | | 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]>
* Use seek+read instead of pread to read from /dev/$$/mem files.Jose E. Marchesi2015-10-092-4/+16
| | | | | | | | pread[64] always returns EINVAL when negative offsets are used. read+seek allows us to read in-memory vdso objects mapped high in the address space. Signed-off-by: Jose E. Marchesi <[email protected]>
* Allocate exact amount of bytes for phdrs and shdrs.Mark Wielaard2015-10-084-42/+48
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Do without union of variable length arrays.Chih-Hung Hsieh2015-10-075-135/+140
| | | | | | | | | | | | | | Prepare to compile with clang. A union like { T32 a32[n]; T64 a64[n]; } u; is expanded to size_t nbytes = n * MAX(sizeof(T32), sizeof(T64)); void *data = malloc(nbytes); T32 (*a32)[n] = data; T64 (*a64)[n] = data; Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Move 4 libdwfl nested functions.Chih-Hung Hsieh2015-10-053-138/+182
| | | | | | | | | | | | | | Now they should compile with clang. Used local variables are passed to new file scope functions as constant parameters, or pointers, or embedded in a 'state' structure. One simple function "report" is changed to a macro. It triggers a gcc false positive -Werror=maybe-uninitialized, so the local variables are explicitly initialized. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Remove old-style function definitions.Mark Wielaard2015-09-238-22/+23
| | | | | | | We already require -std=gnu99 and old-style function definitions might hide some compiler warnings. Signed-off-by: Mark Wielaard <[email protected]>
* Remove redundant NULL tests.Chih-Hung Hsieh2015-09-143-2/+11
| | | | | | | | GCC6 and Clang give warnings on redundant NULL tests of parameters that are declared with __nonnull_attribute__. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Make dwfl_linux_proc_attach work even without any Dwfl_Modules.Mark Wielaard2015-09-143-6/+48
| | | | | | | | | 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 <[email protected]>
* libdwfl: Replace abs with llabs for int64_t values.Chih-Hung Hsieh2015-09-092-1/+5
| | | | | Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Fix finding split debug info files not located by the build-id mechanismDodji Seketeli2015-08-143-7/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [This bug has been found by using elfutils in the context of libabigail. The initial bug report is https://sourceware.org/bugzilla/show_bug.cgi?id=18792. The interesting comments start at is https://sourceware.org/bugzilla/show_bug.cgi?id=18792#c4] suppose we have a debug info file that is located at a /prefix1/usr/lib/debug/prefix2/libfoo.so. Suppose also that the debug info describes a binary that is located at /prefix1/prefix2/libfoo.so Suppose the debug_link property inside the binary /prefix1/prefix2/libfoo.so correctly contains the string "libfoo.so" that designates the name of the debug info file. The problem is, when find_debuginfo_in_path() is called with its file_name parameter set to "/prefix1/prefix2/libfoo.so" and mod->dwfl->callbacks->debuginfo_path set to "/prefix1/lib/debug/", it fails to locate the debug info file libfoo.so under "/prefix1/usr/lib/debug/prefix2/". This patch fixes the issue by making find_debuginfo_in_path() try all the sub-strings of "/prefix1/prefix2/libfoo.so "under" "/prefix1/usr/lib/debug/", to find libfoo.so. That is, it tries, in order: - /prefix1/usr/lib/debug/prefix1/prefix2/libfoo.so - /prefix1/usr/lib/debug/prefix2/libfoo.so <-- and boom, it finds it! Note that the patch tries the variations between the two candidates above too. The patch uses a goto. I dislike gotos like anyone else, but then here, not using this would imply a bigger change of the logic of that function. So I am proposing the scheme based on the goto instead. * libdwfl/find-debuginfo.c (find_debuginfo_in_path): Try to locate the debug info file named debuglink_file under mod->dwfl->callbacks->debuginfo_path, by looking at the set of sub-trees under mod->dwfl->callbacks->debuginfo_path which is common to the set of non-absolute parent trees of file_name. https://bugzilla.redhat.com/show_bug.cgi?id=1253367 Signed-off-by: Dodji Seketeli <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't leak fname if file is main file by another name in try_open.Mark Wielaard2015-06-192-1/+6
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Check symbol section exists and has a sane entsize in find_symtab.Mark Wielaard2015-06-192-1/+7
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Fix memory leak in find_debuginfo_in_path.Mark Wielaard2015-06-092-10/+13
| | | | | | | | | commit c4f133 libdwfl: find_debuginfo_in_patch don't alloca/strdupa strings of unknown size. Introduced a memory leak in the case nothing was found. Make sure before returning all temporary strings are all freed. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Fix memory leak in cache_sections.Mark Wielaard2015-06-092-0/+5
| | | | | | | | commit be1778 libdwfl: Fix possible unbounded stack usage in cache_sections. introduced a memory leak. The refs pointers were copied to the sortrefs array but never freed. Only the array was freed. Also free the elements. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Report core module segment even when NT_FILE build-id doesn't match.Mark Wielaard2015-06-082-2/+13
| | | | | | | | | | | | | | | dwfl_segment_report_module can take the NT_FILE note contents to find the matching file for the module on the file system from the core file. If the file exists but the build-id didn't match we would not report the module. But we should just report the module anyway, ignore the file, and try to match the ELF image another way. This issue can be replicated by building and running make check in /tmp/elfutils with run-backtrace-core-aarch64.sh since that core file includes a NT_FILE note pointing to /tmp/elfutils/tests/backtrace-child. Which won't match if it was just recompiled. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Fix memory leak in __libdwfl_open_by_build_id.Mark Wielaard2015-06-052-1/+7
| | | | | | | | | commit c57829 introduced a memory leak by passing the path string to strsep. strsep will change the given pointer and set it to NULL eventually. Causing the original pointer to leak. Fix by passing a copy of the pointer to strsep. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't assume auxv or r_debug data is properly aligned in link_map.Mark Wielaard2015-06-052-10/+22
| | | | | | | core file data isn't guaranteed to be alligned properly. Use read_(4|8)ubyte_unaligned_noncvt to read values, types and addresses. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Check file_name is not NULL before calling canonicalize_file_name.Mark Wielaard2015-06-052-1/+6
| | | | | | canonicalize_file_name is marked as taking a nonnull argument. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Check mod is not NULL in check_module.Mark Wielaard2015-05-272-0/+7
| | | | | | | | | check_module is called from dwfl_module_relocate_address and from dwfl_module_address_section. Both could take a NULL Dwfl_Module if an earlier error had occured. Make check_module return immediately indicating an issue in that case. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't allocate phdrs and dyn on stack in link_map.Mark Wielaard2015-05-272-10/+29
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't allocate phdrs and dyn on stack in dwfl_segment_report_module.Mark Wielaard2015-05-272-26/+47
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: find_debuginfo_in_patch don't alloca/strdupa strings of unknown size.Mark Wielaard2015-05-272-7/+37
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Reject very short or really large build-ids.Mark Wielaard2015-05-272-4/+25
| | | | | | | | We cannot handle build-ids less than at least 3 or more than 64 bytes. Very big build-ids, or very large debug search paths might have blown up the stack. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't allocate all phdrs on the stack in elf_from_remote_memory.Mark Wielaard2015-05-272-19/+45
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't stack allocate alternate_name in dwfl_linux_kernel_find_elf.Mark Wielaard2015-05-272-1/+13
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Minimize stack usage in dwfl_linux_kernel_report_offline.Mark Wielaard2015-05-272-8/+22
| | | | | | | | Don't stack allocate module name. Also fixes a latent bug (if the module file didn't have a suffix - which is very unlikely) and an inefficiency. We only need to substitue chars up to the suffix. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Fix unbounded stack usage in find_prelink_address_sync.Mark Wielaard2015-05-272-19/+47
| | | | | | Allocate phdr and shdr unions with malloc, not alloca. Free after use. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Fix possible unbounded stack usage in cache_sections.Mark Wielaard2015-05-272-9/+33
| | | | | | | For modules with lots of sections cache_sections could blow up the stack theoretically. Don't use alloca, but use malloc with explicit free. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Only intern CU when not EOF marker and cuoff points to a DIE.Mark Wielaard2015-05-122-40/+49
| | | | | | | | | | | | | We need to check the cuoff points to a real Dwarf_Die before trying to intern the cu with tsearch. Otherwise bogus keys might end up in the search tree with NULL cus. That will cause crashes in compare_cukey during next insertion or deletion of cus. We also don't want to insert the EOF marker and unconditionally tdestroy the lazy_cu_root. The EOF could be caused by bad DWARF from a bogus agranges entry. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c30 Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Bounds check Dwarf_Fileinfo file number in dwfl_lineinfo.Mark Wielaard2015-05-122-1/+11
| | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c30 Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Make dwfl_error.c C99-kosher.Roland McGrath2015-05-062-4/+24
| | | | Signed-off-by: Roland McGrath <[email protected]>
* Allow disabling symbol versioning at configure timeMax Filippov2015-04-234-3/+12
| | | | | | | | | | | | | Due to missing symbol versioning support in uClibc calls to versioned functions that internally call different version of themselves results in infinite recursion. Introduce macro SYMBOL_VERSIONING and use it instead of plain SHARED to decide whether symbol versioning is needed. Control this macro definition with new configure option --disable-symbol-versioning. Signed-off-by: Max Filippov <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Correct off-by-one check in segment.c insert.Mark Wielaard2015-04-142-3/+8
| | | | | | Caught by running run-backtrace-core-x32.sh under valgrind. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Special case core_file_read_eagerly for small ELF images.Mark Wielaard2015-04-032-7/+23
| | | | | | | | | | | | Small ELF images, like linux-gate or linux-vdso, might be available in the core file, but not on disk, even if we have a build-id. If the whole image is small enough try to read them in from the core file to make sure symbols and unwind information are always available for them. We would already map them in if the core file was opened with ELF_C_READ_MMAP. https://bugzilla.redhat.com/show_bug.cgi?id=1129756 Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Clear symtab result on error before using find_dynsym fallback.Mark Wielaard2015-02-062-0/+8
| | | | | | | | | | | find_dynsym could succeed after find_symtab failed but had already set up symdata, syments and first_global. find_dynsym would not set or clear first_global since all syms in dynsym are global. Causing lots of failing lookups when calling __libdwfl_addrsym if first_global was some huge bogus value. Reported-by: Hanno Böck <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: dwfl_module_getsrc should never match end_sequence line.Mark Wielaard2015-01-162-4/+9
| | | | | | | | | | | | | | The line with end_sequence set has an address outside the current line sequence. An end_sequence line has no other useful information except marking the address as out of range. Two tests, addrscopes and funcscopes, depended on matching the end_sequence line. But that was because they included the high_pc address in the scope. However the high_pc attributes has as address the first location past the range associated with a given DIE. Adjust the tests to use high_pc - 1 as end of the scope. Signed-off-by: Mark Wielaard <[email protected]>