summaryrefslogtreecommitdiffstats
path: root/libdwfl
Commit message (Collapse)AuthorAgeFilesLines
* Don't include sys/uio.h if we don't need itUlf Hermann2018-07-191-1/+1
| | | | | | | The PID attaching only works on linux. Change-Id: I00428a711b64cb490429363ef28a867b1347956e Reviewed-by: Christian Kandeler <[email protected]>
* Merge tag 'elfutils-0.173'Ulf Hermann2018-07-1315-73/+260
|\ | | | | | | | | | | elfutils 0.173 release Change-Id: I83dc56dd15c26fe7acf4ce73c29df65b8b65e757
| * libdwfl: Make __libdwfl_addrsym a static function in dwfl_module_addrsym.cMark Wielaard2018-06-083-12/+11
| | | | | | | | | | | | | | __libdwfl_addrsym is only used in the dwfl_module_addrsym.c source. There is no need to mark this as a (shared) internal function. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Allow partial relocations also for debug files.Mark Wielaard2018-05-292-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | __libdwfl_relocate is called for get_dwarf and get_elf. We allow not all relocations to be resolved for Elf files, but required all relocations (in the debug sections) to be fully resoled in Dwarf files. This used to mostly work out with .o ET_REL files when the main Elf was gotten before the Dwarf. But with .dwo files, we (readelf) might open the .o file just for the (skeleton) Dwarf. In this case it could happen not all relocations in the debug sections could be resolved (.debug_info and .debug_addr might contain referenes to undefined symbols). So allow partial relocations also for debug files. Signed-off-by: Mark Wielaard <[email protected]>
| * libdw: Cache ELF directory early. Explicitly set it in dwfl.Mark Wielaard2018-05-205-6/+33
| | | | | | | | | | | | | | | | | | | | | | The logic that finds alt files and dwo files relies on having an open file descriptor. But after all needed ELF data has been read the underlying Elf file descriptor can be closed. libdwfl in particular closes file descriptor fairly aggressively. So capture the directory early on. And make dwfl set it if it has recorded it. Which it will do now before closing a file descriptor for the main Dwfl_Module file. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Handle unwind frame when the return address register isn't set.Mark Wielaard2018-04-132-16/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we have unwound the frame and then cannot set the return address we wouldn't set any error. That meant that a dwfl_thread_getframes () call could end in an error, but without any dwfl_errno set, producing the "no error" error message. If we cannot set the return address at the end of unwinding the frame that means that either the return address register is bogus (error), or that the return address is undefined (end of the call stack). This fixes the run-backtrace-native-biarch.sh testcase for me on an i386 on x86_64 setup with gcc 7.2.1 and glibc 2.17. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Use process_vm_readv when available.Mark Wielaard2018-03-283-2/+107
| | | | | | | | | | | | | | | | | | | | If possible use process_vm_readv to read 4K blocks instead of fetching each word individually with ptrace. For unwinding this often means we only have to do one process_vm_readv of the stack instead of dozens of ptrace calls. There is one 4K cache per process, cleared whenever a thread is detached. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Use realpath (name, NULL) instead of canonicalize_file_name (name).Mark Wielaard2018-03-103-2/+8
| | | | | | | | | | | | | | | | | | | | Some systems apparently don't provide canonicalize_file_name. Since canonicalize_file_name (path) is defined as realpath(path, NULL) just use realpath everywhere. https://sourceware.org/bugzilla/show_bug.cgi?id=21009 Signed-off-by: Mark Wielaard <[email protected]>
| * libdw: Parse new DWARF5 units and CU DIEs.Mark Wielaard2018-02-212-11/+10
| | | | | | | | | | | | | | | | Parse DWARF5 units, add the unit_type to the Dwarf_CU and generalize some code calculating the header length and getting at the first DIE of a unit. Unit headers can have different sizes depending on the unit type. Signed-off-by: Mark Wielaard <[email protected]>
| * Include sys/ptrace.h as early as possible.Mark Wielaard2018-02-152-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some systems, at least on Fedora 27 ppc64le with glibc 2.26-24 and kernel 4.14.18-300, including sys/ptrace.h late (after signal.h or sys/wait.h for example) will cause issues and produce errors like: In file included from /usr/include/asm/sigcontext.h:12:0, from /usr/include/bits/sigcontext.h:30, from /usr/include/signal.h:287, from /usr/include/sys/wait.h:36, from linux-pid-attach.c:38: /usr/include/sys/ptrace.h:73:3: error: expected identifier before numeric constant PTRACE_GETREGS = 12, ^ Swapping the include order fixes these issues. Signed-off-by: Mark Wielaard <[email protected]>
| * Use fallthrough attribute.Joshua Watt2018-02-103-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use __attribute__ ((fallthrough)) to indicate switch case fall through instead of a comment. This ensures that the fallthrough warning is not triggered even if the file is pre-processed (hence stripping the comments) before it is compiled. The actual fallback implementation is hidden behind a FALLBACK macro in case the compiler doesn't support it. Finally, the -Wimplict-fallthrough warning was upgraded to only allow the attribute to satisfy it; a comment alone is no longer sufficient. Signed-off-by: Joshua Watt <[email protected]>
| * libdwfl: Don't dereference possibly unaligned auxv entry pointer from core.Mark Wielaard2017-11-242-19/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * libdwfl: When the kernel is found, but not the modules warn, don't fail.Mark Wielaard2017-10-202-1/+6
| | | | | | | | | | | | | | | | | | For -k the argp parser could fail to find the modules after the kernel itself was already found. Calling failure at this point closes the Dwfl, which isn't necessary. Just warn about the missing modules and continue with the kernel only Dwfl. Signed-off-by: Mark Wielaard <[email protected]>
* | Merge tag 'elfutils-0.170'Ulf Hermann2017-08-172-26/+34
|\| | | | | | | | | | | elfutils 0.170 release Change-Id: I37d03645902b9f0a9fb708af1551db8843537799
| * libdwfl: Move nested functions in parse_opt to file scope.Yunlian Jiang2017-07-272-26/+34
| | | | | | | | | | | | | | * Move nested function 'failure' to file scope to compile with clang. * Move nested function 'fail' to file scope to compile with clang. Signed-off-by: Yunlian Jiang <[email protected]>
* | Merge tag 'elfutils-0.169'QtCreator4.5.1QtCreator4.5.0-rc1QtCreator4.5.0QtCreator4.4.1QtCreator4.4.0-rc1QtCreator4.4.0-beta1QtCreator4.4.04.54.4Ulf Hermann2017-05-083-21/+27
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: ChangeLog backends/ChangeLog config/ChangeLog lib/ChangeLog libasm/ChangeLog libcpu/ChangeLog libdw/ChangeLog libdwfl/ChangeLog libdwfl/derelocate.c libdwfl/linux-kernel-modules.c libebl/ChangeLog libelf/ChangeLog src/ChangeLog tests/ChangeLog Change-Id: I3b7ced947c6498290aaae27443985b84531f0bcd
| * Make elf section sorting more deterministicUlf Hermann2017-05-032-1/+13
| | | | | | | | | | | | | | | | | | At least one test (dwfl-addr-sect) depends on the order of elf sections with equal addresses. This is not guaranteed by the code. Compare also by end address and section index to tell entries apart. Signed-off-by: Ulf Hermann <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
| * Don't look for kernel version if not running on linuxUlf Hermann2017-05-022-0/+13
| | | | | | | | | | | | | | We don't want to use it, even if it exists. Signed-off-by: Ulf Hermann <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
| * Avoid double-including config.hUlf Hermann2017-05-0257-3/+278
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * Make __attribute__ conditional in all installed headersUlf Hermann2017-05-022-1/+5
| | | | | | | | | | | | | | | | | | | | __attribute__ is a GNU extension. If we want to link against the libraries using a different compiler, it needs to be disabled. It was already disabled in libdw.h, and this patch extends this to the other headers. We move the defines to libelf.h as that is included in all the others. Signed-off-by: Ulf Hermann <[email protected]>
| * Avoid signed/unsigned comparisonUlf Hermann2017-04-272-1/+5
| | | | | | | | | | | | | | | | | | | | | | Some compilers implicitly cast the result of uint_fast16_t * uint_fast16_t to something signed and then complain about the comparison to (unsigned) size_t. Casting phnum to size_t is a good idea anyway as 16bit multiplication can easily overflow and we are not checking for this. Signed-off-by: Ulf Hermann <[email protected]>
| * Protect against integer overflow on shnumUlf Hermann2017-04-272-8/+15
| | | | | | | | | | | | | | If shnum is 0, the many "shnum - 1" would result in an overflow. Check it for 0, and only subtract once, rather than on every usage. Signed-off-by: Ulf Hermann <[email protected]>
| * Clean up linux-specific system includesUlf Hermann2017-04-264-4/+10
| | | | | | | | | | | | We only include them where we actually need them and only on linux. Signed-off-by: Ulf Hermann <[email protected]>
| * Include sys/types.h before fts.hUlf Hermann2017-04-252-1/+9
| | | | | | | | | | | | | | The bad fts not only needs to be included before config.h, but also requires various special types without including sys/types.h. Signed-off-by: Ulf Hermann <[email protected]>
* | Adapt debug info fstat check for windowsUlf Hermann2017-05-082-0/+14
| | | | | | | | | | | | | | | | | | | | | | On windows the resulting ino and dev entries are always 0, so the file would always be discarded. We apply a heuristic instead: If the ctime, mtime, mode and size of the two files are all equal then we consider them to be the same. It's exceedingly unlikely to produce two different files for which that holds by chance. Change-Id: I491c95ab8b90fc3c1b786cceae242e142b5a491f Reviewed-by: Christian Kandeler <[email protected]>
* | Use OS-specific pathsUlf Hermann2017-05-086-55/+75
| | | | | | | | | | | | | | | | | | | | In general we need to use ';' as path separator and '\' and directory separator on windows. The shell will automatically translate paths to some extent, but we have to call "pwd -W" rather than plain "pwd" to get something useful. Change-Id: I1a117d219a2aa00c1f77ae7d3a1d92b9bae526db Reviewed-by: Christian Kandeler <[email protected]>
* | Open files in O_BINARYUlf Hermann2017-05-0812-28/+43
| | | | | | | | | | | | | | | | | | If O_BINARY is not defined, define it to 0, so that the change has no effect then. Some systems have separate binary and text modes for files, and we don't want the text mode to be used. Change-Id: If7efb5bd448c2a1c7d1eb5dab276849b1b15a3ce Reviewed-by: Christian Kandeler <[email protected]>
* | Check for existence of GNU-style strerror_rUlf Hermann2017-05-052-0/+9
| | | | | | | | | | | | | | | | If we don't have it, we don't translate system error codes to strings in dwfl_error.c. Change-Id: I829616cfba787d778c3273f2042512739df91d81 Reviewed-by: Christian Kandeler <[email protected]>
* | Drop handrolled or #ifdef'ed libc replacementsUlf Hermann2017-04-282-1/+4
| | | | | | | | | | | | | | | | | | mempcpy, memrchr, rawmemchr, and argp are provided by gnulib now. We don't need to define them locally and we don't need to search for an external libargp. Change-Id: I131ca4bc2d77c597b99c296c28259a3600e5d1b5 Reviewed-by: Christian Kandeler <[email protected]>
* | Make elf section sorting more deterministicUlf Hermann2017-04-262-6/+16
| | | | | | | | | | | | | | | | | | At least one test (dwfl-addr-sect) depends on the order of elf sections with equal addresses. This is not guaranteed by the code. Compare also by end address and name to tell entries apart. Change-Id: I0e85e7b86a0489b6bc85f45f9a359c68a04f635a Reviewed-by: Christian Kandeler <[email protected]>
* | Avoid signed/unsigned comparisonUlf Hermann2017-04-262-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Some compilers implicitly cast the result of uint_fast16_t * uint_fast16_t to something signed and then complain about the comparison to (unsigned) size_t. Casting phnum to size_t is a good idea anyway as 16bit multiplication can easily overflow and we are not checking for this. Change-Id: I073202d433d75b540ca042d15c364187a08fec6c Reviewed-by: Christian Kandeler <[email protected]>
* | Avoid double-including config.hUlf Hermann2017-04-2657-3/+278
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Change-Id: Ib78dd7e058ef8ac93cd379dcd14a2ffbc86c1988 Reviewed-by: Christian Kandeler <[email protected]>
* | Don't look for kernel version if not running on linuxUlf Hermann2017-04-262-0/+9
| | | | | | | | | | Change-Id: Ia74c04e2590d2d918fb7d5227a106de789551843 Reviewed-by: Christian Kandeler <[email protected]>
* | Protect against integer overflow on shnumUlf Hermann2017-04-262-8/+15
| | | | | | | | | | | | | | | | If shnum is 0, the many "shnum - 1" would result in an overflow. Check it for 0, and only subtract once, rather than on every usage. Change-Id: I37a9e5d4e012a501d5ec98762ec0a435c743e25f Reviewed-by: Christian Kandeler <[email protected]>
* | Make __attribute__ conditional in all installed headersUlf Hermann2017-04-212-1/+5
| | | | | | | | | | | | | | | | | | | | | | __attribute__ is a GNU extension. If we want to link against the libraries using a different compiler, it needs to be disabled. It was already disabled in libdw.h, and this patch extends this to the other headers. We move the defines to libelf.h as that is included in all the others. Change-Id: I6e22674641f19f5a8820e2c7c7ec46f2fd70a8af Reviewed-by: Christian Kandeler <[email protected]>
* | Clean up linux-specific system includesUlf Hermann2017-04-214-4/+10
| | | | | | | | | | | | | | We only include them where we actually need them and only on linux. Change-Id: Ic3065ffab67ba1177f63204fb91a92c5f4336dbb Reviewed-by: Christian Kandeler <[email protected]>
* | Include sys/types.h before fts.hUlf Hermann2017-04-212-1/+9
|/ | | | | | | | The bad fts not only needs to be included before config.h, but also requires various special types without including sys/types.h. Change-Id: I31ac8d2aadcf7ffb3efb63583b2745991bfd6f90 Reviewed-by: Christian Kandeler <[email protected]>
* Use the empty string for note names with zero size (without any data).Mark Wielaard2017-04-032-3/+12
| | | | | | | | | | ELF notes can have a zero sized name. In which case there is no data at all (so also no zero terminator). Make sure to use the empty string for such notes if the code does not otherwise explicitly check n_namesz. https://sourceware.org/bugzilla/show_bug.cgi?id=21300 Signed-off-by: Mark Wielaard <[email protected]>
* Check for existence of mempcpyUlf Hermann2017-02-172-0/+5
| | | | | | If it doesn't exist, provide a definition based on memcpy. Signed-off-by: Ulf Hermann <[email protected]>
* Always use the same method to query the system page sizeUlf Hermann2017-02-153-2/+7
| | | | | | | This makes it easier to write a replacement for it on systems where sysconf(3) doesn't exist. Signed-off-by: Ulf Hermann <[email protected]>
* Fix TEMP_FAILURE_RETRY definition when not defined.Luiz Angelo Daros de Luca2016-12-304-1/+8
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=21001 Signed-off-by: Luiz Angelo Daros de Luca <[email protected]>
* Only workaround fts.h if we have a bad version that doesn't handle LFS.Mark Wielaard2016-11-232-8/+19
| | | | | | | | | | Older versions of glibc included an fts implementation that didn't have Large File System support. We worked around that in linux-kernel-modules.c by including it early before config.h and then redefining some symbols to get the 64-bit versions. This is somewhat fragile and not necessary with newer glibc. If possible we want the 64bit fts version always. Signed-off-by: Mark Wielaard <[email protected]>
* Add GCC7 -Wimplicit-fallthrough support/fixes.Mark Wielaard2016-11-101-1/+1
| | | | | | | | | | | GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one small buglet in elflint option procession. So it seems useful to enable to make sure all swatch case fallthroughs are deliberate. Add configure check to detect whether gcc support -Wimplicit-fallthrough and enable it. Add fixes and explicit fallthrough comments where necessary. Signed-off-by: Mark Wielaard <[email protected]>
* lib: Provide MAX and MIN in system.hAkihiko Odaki2016-10-126-18/+13
| | | | | | | | | | This change also creates a new header file libeu.h to provide the prototypes for the function of libeu. That hides the definition of function crc32, which can conflict with zlib, from libelf. It also prevents mistakes to refer those functions from a component which doesn't link with libeu, such as libelf. Signed-off-by: Akihiko Odaki <[email protected]>
* libdwfl: Fix assert and set in.d_size in dwfl_link_map_report.Mark Wielaard2016-08-152-2/+9
| | | | | | | | | | | | 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 <[email protected]>
* libdwfl: Fix memory leak in dwfl_module_getsrc_file on invalid DWARF.Mark Wielaard2016-04-142-0/+7
| | | | | | | If we allocated the match results array ourselves, then free it when we detect invalid DWARF and return an error. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Fix memory leak in proc_maps_report on bad file mapping.Mark Wielaard2016-04-142-1/+9
| | | | | | | Normally last_file is freed inside report(), but in the case of a bad file mapping we don't call report. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: clean up non-Linux GNU platforms codeSteven Chamberlain2016-03-022-63/+7
| | | | | | | | | | | | | | | | | | | For non-Linux GNU platforms (like kFreeBSD, Hurd), linux-pid-attach.c had some stub functions that are not used or exported. Since gcc-6, having these caused compiler errors due to -Wall -Werror: linux-pid-attach.c:479:36: error: 'pid_thread_callbacks' defined but not used [-Werror=unused-const-variable=] linux-pid-attach.c:474:1: error: 'pid_thread_detach' defined but not used [-Werror=unused-function] linux-pid-attach.c:461:1: error: 'pid_detach' defined but not used [-Werror=unused-function] linux-pid-attach.c:452:1: error: 'pid_set_initial_registers' defined but not used [-Werror=unused-function] linux-pid-attach.c:441:1: error: 'pid_memory_read' defined but not used [-Werror=unused-function] linux-pid-attach.c:420:1: error: 'pid_getthread' defined but not used [-Werror=unused-function] linux-pid-attach.c:410:1: error: 'pid_next_thread' defined but not used [-Werror=unused-function] This part of the source file is guarded by #ifndef __linux__ Signed-off-by: Steven Chamberlain <[email protected]>
* libdwfl: Check for kernel debuginfo file without .debug extension as wellRavi Bangoria2016-02-223-9/+36
| | | | | | | | | | | | | | | | | | | | | Elfutils, looking for kernel debuginfo file, tries to find it at various places. If elfutils finds /boot/vmlinu*x* file, it checks for debufginfo section. If debuginfo is not present, it saves it as 'main elf' and continue looking for debuginfo file having .debug extension i.e. vmlinux-RELEASE.debug. 'Ubuntu on powerpc' installs kernel as /boot/vmlinux and installs debuginfo without any extension as /usr/lib/debug/boot/vmlinux-RELEASE and hence, elfutils is not able to find the debuginfo file. Here is the launchpad bug for the same: https://bugs.launchpad.net/ubuntu/+source/systemtap/+bug/1537125 This patch adds functionality to search for a kernel or debuginfo file both with and without .debug extension. Signed-off-by: Ravi Bangoria <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't leak memory in proc_maps_report when ENOEXEC.Mark Wielaard2016-02-222-1/+6
| | | | | | We forgot to free last_file on error. Signed-off-by: Mark Wielaard <[email protected]>