summaryrefslogtreecommitdiff
path: root/libdwfl/link_map.c
Commit message (Collapse)AuthorAgeFilesLines
* libdwfl: Don't dereference possibly unaligned auxv entry pointer from core.Mark Wielaard2017-11-241-19/+19
| | | | | | | | | | | | | The notes in a core file that contain the auxv entries might not be naturally aligned. The code already tried to account for that, but the GCC 8 undefined behaviour sanitizer found we were till dereferencing the actual auxv entry pointer directly. Fix this by calculating all pointers by hand and not use an array of auxv entries trick. This makes make distcheck (which enables sanitize-undefined by default) pass again using GCC8. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdwfl: Fix assert and set in.d_size in dwfl_link_map_report.Mark Wielaard2016-08-151-2/+5
| | | | | | | | | | | | When reading the phdrs from a core file segment fails we would try to read them from the exec. This fallback path contained a faulty assert that the requested size of the phdrs was still setup. But the core file reading callback might have reset the d_size value to zero on error. So explicitly set the number of bytes we want to read again instead of asserting the size. https://bugzilla.redhat.com/show_bug.cgi?id=1365812 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Move nested functions check64 and check32 in link_map.c to file scope.Chih-Hung Hsieh2016-01-031-47/+53
| | | | | | | | * In libdwfl/link_map.c, nested functions check64, check32, are moved to file scope to compile with clang. Signed-off-by: Chih-Hung Hsieh <chh@google.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Fix memory leak in link_map.c dwfl_link_map_report.Mark Wielaard2016-01-021-2/+7
| | | | | | | | 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 <mjw@redhat.com>
* libdwfl: Don't leak core Elf and core file descriptor from argp-std.Mark Wielaard2016-01-021-4/+8
| | | | | | | | 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 <mjw@redhat.com>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-091-1/+1
| | | | | | | | | | | | | | | 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>
* Do without union of variable length arrays.Chih-Hung Hsieh2015-10-071-53/+34
| | | | | | | | | | | | | | 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 <chh@google.com>
* libdwfl: Don't assume auxv or r_debug data is properly aligned in link_map.Mark Wielaard2015-06-051-10/+15
| | | | | | | 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 <mjw@redhat.com>
* libdwfl: Don't allocate phdrs and dyn on stack in link_map.Mark Wielaard2015-05-271-10/+24
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Use elf_getphdrnum instead of accessing ehdr->e_phnum directly.Mark Wielaard2014-11-261-3/+15
| | | | | | | Using elf_getphdrnum lets us handle ELF files that use more than PN_XNUM phdrs. And guards against some corrupt files. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Fix report_r_debug for prelinked librariesJan Kratochvil2014-07-281-3/+10
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Fix non-build-id core files on build-id systemJan Kratochvil2013-11-211-3/+5
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* link_map: Use proper bias, not l_addrJan Kratochvil2013-11-211-6/+6
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* dwfl_core_file_report: Fix core files for re-prelink-ed filesJan Kratochvil2013-11-071-1/+0
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Fix false match of non-build-id disk library to build-id memory library.Jan Kratochvil2013-07-231-28/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this patch: Use DT_DEBUG library search first. 8ff862960efb648cdff647d7fad1be5acffe9b11 [patch 2/2] Fix loading core files without build-ids https://lists.fedorahosted.org/pipermail/elfutils-devel/2013-April/003031.html [patch 2/2 v2] Fix loading core files without build-ids https://lists.fedorahosted.org/pipermail/elfutils-devel/2013-May/003065.html has PASS->FAIL regression on CentOS-5 for run-unstrip-n.sh: -actual on CentOS-5 +expected by testcase -0xf77b3000+0x822c - /lib/librt.so.1 - librt.so.1 -0xf7603000+0x15c5c4 - /lib/libc.so.6 - libc.so.6 -0xf75e9000+0x191e4 - /lib/libpthread.so.0 - libpthread.so.0 -0xf77d7000+0x1c670 - /lib/ld-linux.so.2 - ld-linux.so.2 0x8048000+0x2000 f1c600bc36cb91bf01f9a63a634ecb79aa4c3199@0x8048178 . - [exe] +0xf75e9000+0x1a000 29a103420abe341e92072fb14274e250e4072148@0xf75e9164 - - libpthread.so.0 +0xf7603000+0x1b0000 0b9bf374699e141e5dfc14757ff42b8c2373b4de@0xf7603184 - - libc.so.6 +0xf77b3000+0x9000 c6c5b5e35ab9589d4762ac85b4bd56b1b2720e37@0xf77b3164 - - librt.so.1 0xf77d6000+0x1000 676560b1b765cde9c2e53f134f4ee354ea894747@0xf77d6210 . - linux-gate.so.1 +0xf77d7000+0x21000 6d2cb32650054f1c176d01d48713a4a5e5e84c1a@0xf77d7124 - - ld-linux.so.2 Therefore elfutils now incorrectly matches on-disk file without build-id to an in-core (in-memory) file with build-id. In fact due to its known FIXME: This verification gives false positive if in-core ELF had build-id but on-disk ELF does not have any. But we cannot reliably find ELF header and/or the ELF build id just from the link map (and checking core segments is also not reliable). */ So it probably should not be so ignorable as I did, one may want to analyze build-id core files on CentOS-5, not sure. In fact it can be fixed, when we find in dwfl_segment_report_module a module with build-id with conflicts in its address range with existing non-build-id dwfl_link_map_report module we should prefer the build-id module instead. The problem is that once Dwfl_Module is added to Dwfl it cannot be easily removed. Originally elfutils called dwfl_segment_report_module first and then dwfl_link_map_report. Currently the order is dwfl_link_map_report and then dwfl_segment_report_module only for modules missing from dwfl_link_map_report. Patch below unfortunately needs bidirectional negotiation between the two functions, therefore dwfl_link_map_report now no longer adds Dwfl_Modules to Dwfl but it only stores information about them to r_debug_info_module. This information is filtered then by dwfl_segment_report_module and only filtered r_debug_info_module entries get finally added to Dwfl (in dwfl_core_file_report). NT_FILE would make all this magic easy but it is true that on CentOS-5 it definitely does not exist. libdwfl/ 2013-07-23 Jan Kratochvil <jan.kratochvil@redhat.com> * core-file.c (clear_r_debug_info): Close also ELF and FD. (dwfl_core_file_report): Call __libdwfl_report_elf for R_DEBUG_INFO.MODULE. * dwfl_report_elf.c (__libdwfl_elf_address_range): New function from code of ... (__libdwfl_report_elf): ... this function. Call it. * dwfl_segment_report_module.c: Include unistd.h. (dwfl_segment_report_module): Use basename for MODULE->NAME. Clear MODULE if it has no build-id and we have segment with build-id. Ignore this segment only if MODULE still contains valid ELF. * libdwflP.h (__libdwfl_elf_address_range): New declaration. (struct r_debug_info_module): New fields fd, elf, l_addr, start, end and disk_file_has_build_id. (dwfl_link_map_report): Extend the comment. * link_map.c (report_r_debug): Extend the comment. Always fill in new r_debug_info_module. Initialize also the new r_debug_info_module fields. Remove one FIXME comment. Call __libdwfl_elf_address_range instead of __libdwfl_report_elf when R_DEBUG_INFO is not NULL. tests/ 2013-07-23 Jan Kratochvil <jan.kratochvil@redhat.com> * run-unstrip-n.sh (test-core.*): Ignore libc.so.6 entry and order of the entries. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* libdwfl: link_map.c (report_r_debug) always release memory_callback buffer.Mark Wielaard2013-06-051-5/+10
| | | | | | | | | If the buffer isn't released after getting a valid build-id from the memory_callback the first run-unstrip-n.sh testcase will fail on systems where there is a matching librt.so file for which dwfl_addrsegment returns a valid segment index in the Dwfl (but where the build-id doesn't match). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Use DT_DEBUG library search first.Jan Kratochvil2013-05-301-35/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libdwfl/ 2013-05-30 Jan Kratochvil <jan.kratochvil@redhat.com> * argp-std.c (parse_opt) <ARGP_KEY_SUCCESS> <opt->core> <opt->e>: Set executable_for_core before calling dwfl_core_file_report. * core-file.c (clear_r_debug_info): New function. (dwfl_core_file_report): Move raw segments reporting lower. New variable r_debug_info, pass it to dwfl_segment_report_module. Call clear_r_debug_info in the end. Return sum of LISTED and SNIFFED. * dwfl_module_build_id.c (check_notes): Move into __libdwfl_find_elf_build_id. (__libdwfl_find_build_id): Rename to ... (__libdwfl_find_elf_build_id): ... here. Add parameters build_id_bits, build_id_elfaddr and build_id_len. Verify MOD vs. ELF. (__libdwfl_find_elf_build_id) (check_notes): Remove parameters mod and set, rename data_vaddr to data_elfaddr. Do not call found_build_id. (__libdwfl_find_elf_build_id): Update the check_notes caller, do not adjust its data_elfaddr parameter. (__libdwfl_find_build_id): New wrapper of __libdwfl_find_elf_build_id. * dwfl_segment_report_module.c (dwfl_segment_report_module): New parameter r_debug_info. New variable name_is_final. Adjust addresses according to R_DEBUG_INFO->MODULE. Check conflicts against DWFL. Do not overwrite NAME by SONAME if NAME_IS_FINAL. * libdwflP.h (__libdwfl_find_elf_build_id): New declaration. (struct r_debug_info_module, struct r_debug_info): New definitions. (dwfl_segment_report_module, dwfl_link_map_report): Add parameter r_debug_info. * link_map.c: Include fcntl.h. (report_r_debug): Add parameter r_debug_info, describe it in the function comment. Delete dwfl_addrmodule call and its dependent code. Verify build-id before calling dwfl_report_elf, also supply executable_for_core to it. Store r_debug_info->module info when appropriate. (dwfl_link_map_report): Add parameter r_debug_info. New variable in_ok. Try to read IN from EXECUTABLE_FOR_CORE. Update report_r_debug caller parameters. tests/ 2013-05-30 Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.am (EXTRA_DIST): Add test-core-lib.so.bz2, test-core.core.bz2 and test-core.exec.bz2. * run-addrname-test.sh: New test for these files. * run-unstrip-n.sh: Update expected output. New test for these files. * test-core-lib.so.bz2: New file. * test-core.core.bz2: New file. * test-core.exec.bz2: New file. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Add parameter add_p_vaddr to dwfl_report_elf.Jan Kratochvil2013-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | libdwfl/ * dwfl_report_elf.c (__libdwfl_report_elf): Add parameter add_p_vaddr. Set it to true for ET_EXEC and ET_CORE. Provide alternative setup of START and BIAS if !ADD_P_VADDR. Set END from BIAS, not BASE. (dwfl_report_elf): Add parameter add_p_vaddr. Pass it down. Add NEW_VERSION. (_compat_without_add_p_vaddr_dwfl_report_elf) <SHARED>: New, with COMPAT_VERSION. * libdwfl.h (dwfl_report_elf): Add parameter add_p_vaddr. Describe it. * libdwflP.h (__libdwfl_report_elf): Add parameter add_p_vaddr. * link_map.c (report_r_debug): Use true add_p_vaddr for dwfl_report_elf. * linux-kernel-modules.c (report_kernel): Use false add_p_vaddr for dwfl_report_elf. * offline.c (process_elf): Use true add_p_vaddr for dwfl_report_elf. tests/ * dwfl-report-elf-align.c: Use false add_p_vaddr for dwfl_report_elf. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* libdwfl/link_map.c: #include system.h.Mark Wielaard2013-04-271-0/+1
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Unify {BE,LE}{32,64} in lib/system.h.Jan Kratochvil2013-04-261-12/+0
| | | | | | | | | | | | lib/ * system.h (LE64, BE64): Move here the definitions from libdwfl/link_map.c. libdwfl/ * link_map.c (BE32, BE64, LE32, LE64): Delete the definitions, move them to lib/system.h. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* dwfl_link_map_report: Handle unaligned auxv data.Roland McGrath2013-01-071-28/+39
| | | | Signed-off-by: Roland McGrath <roland@hack.frob.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>
* libdwfl: Revamp bias bookkeeping, account correctly for prelink REL->RELA ↵Roland McGrath2010-11-121-5/+5
| | | | segment inflation.
* Don't suppress full file names found in core-file link_map.Roland McGrath2010-08-181-3/+1
|
* dwfl_link_map_report: Handle PIE-generated core.Roland McGrath2010-05-041-12/+38
|
* Prevent infinite iteration on link_map list clobbered into circularity.Roland McGrath2010-04-141-2/+8
|
* Fix auxv scanning in core-file grokking.Roland McGrath2010-04-061-10/+3
|
* Use dwfl_addrmodule for l_ld lookup, don't bail on lookup failure.Roland McGrath2009-11-051-5/+1
|
* Ignore link_map entries with l_ld==0.Roland McGrath2009-11-051-0/+5
|
* Fix RHBZ#494858: fix bad address checks in core file support.Roland McGrath2009-04-141-1/+0
|
* Remove assert depending on confluence of guesses without anomaly.Roland McGrath2009-02-101-4/+2
|
* Fix up bogon and missing log entries from .pmachata.threads branch.Roland McGrath2008-08-251-0/+867