summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* readelf: Don't print 'for section' when rela section sh_info is zero.Mark Wielaard2014-05-272-1/+20
| | | | | | This matches how handle_relocs_rel already printed the header. Signed-off-by: Mark Wielaard <[email protected]>
* unstrip: Allow prelinked, but non-split .bss section.Mark Wielaard2014-05-272-2/+8
| | | | | | | | If the section sh_size of the original and undo section are equal then match them and don't set split_bss. This is also what prelink's undo_sections allows. Signed-off-by: Mark Wielaard <[email protected]>
* unstrip: Add --force to force combining files when ELF headers don't match.Mark Wielaard2014-05-272-16/+56
| | | | | | | | | | | | | | Older versions of GNU binutils strip would drop some ELF header flags. Causing the main ELF file and the separate .debug file to have mismatched ELF header fields. Unfortunately some distros are still shipping such files. eu-unstrip doesn't want to recombine such files. Add a more explicit explanation which fields don't match and provide a --force, -F flag to force combining such files anyway (producing a warning). https://bugzilla.redhat.com/show_bug.cgi?id=698005 https://bugzilla.redhat.com/show_bug.cgi?id=806474 Signed-off-by: Mark Wielaard <[email protected]>
* backends: Add ebl_check_reloc_target_type.Mark Wielaard2014-05-192-2/+5
| | | | | | | | | And implement for arm and ia64. Both have special section types that are valid targets for a reloc. Both refer to unwind data. elflint now just calls ebl_check_reloc_target_type instead of hard coding the expected section types. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Move dwz alt multi file searching to find_debuginfo callback.Mark Wielaard2014-05-022-10/+29
| | | | | | | | | | Don't hard code the Dwarf dwz alt multi file search but allow the user to override it through the standard Dwfl_Callbacks. Also move ownership completely to the user of dwarf_setalt by removing free_alt from Dwarf and adding alt, fd and elf fields to Dwfl_Module. Add a relative .dwz file test case. Signed-off-by: Mark Wielaard <[email protected]>
* libdwelf: New DWARF ELF Low-level Functions. Add dwelf_elf_gnu_debuglink.Mark Wielaard2014-04-242-2/+6
| | | | | | | | New public header elfutils/libdwelf.h for low-level DWARF/ELF helper functions. The new function dwelf_elf_gnu_debuglink returns the name and crc as found in the .gnu_debuglink section of an ELF file. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: handle_core_item make sure variable length array isn't zero size.Mark Wielaard2014-04-242-1/+6
| | | | | | | | The printed array should have at least space for the terminating zero char. Found by gcc -fsanitize=undefined while running run-readelf-vmcoreinfo.sh. runtime error: variable length array bound evaluates to non-positive value 0 Signed-off-by: Mark Wielaard <[email protected]>
* readelf.c (print_gdb_index_section): Use unsigned int for 31 bits left shift.Mark Wielaard2014-04-242-1/+6
| | | | | | | Found by gcc -fsanitize=undefined. left shift of 1 by 31 places cannot be represented in type 'int' Signed-off-by: Mark Wielaard <[email protected]>
* Remove mudflap build option.Mark Wielaard2014-04-183-26/+21
| | | | | | | | | The --enable-mudflap configure build has been broken for 2 years without anybody apparently noticing. GCC 4.9 removed mudflap support. Before release we now run make distcheck with valgrind support. Removal of the mudflap configure option simplifies the build a little. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Read the decompressed data when processing .zdebug DWARF sections.Mark Wielaard2014-04-152-8/+21
| | | | | | | | | | | | | readelf uses libdw to open the Dwarf and read some of the DWARF data. But it also uses its own parsers to display some of the low-level unprocessed data. If the DWARF debug section was zlib compressed it should actually use the decompressed section data from libdw instead of the raw section data. Includes a testcase for those sections that couldn't be properly displayed when compressed before. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: convert up to a target long in buf_read_ulong.Mark Wielaard2014-04-142-1/+5
| | | | | | | Add a i686 corefile test. Reported-by: Markus Engel <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Print DW_FORM_sdata values as signed numbers.Mark Wielaard2014-03-102-7/+32
| | | | | | Printing DW_FORM_sdata numbers as unsigned values is misleading. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: More sanity checks before trying to display interpreter string.Mark Wielaard2014-02-242-2/+22
| | | | | | | Check there is a SHT_PROGBITS section at the offset given by p_offsets for a PT_INTERP segment before trying to display the interpreter string. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Robustify print_phdr program interpreter printing.Mark Wielaard2014-02-072-1/+9
| | | | | | | | Check phdr->p_filesz and make sure interpreter string is zero terminated before calling printf. Reported-by: Florian Weimer <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Use -Wformat=2 by default for all files.Mark Wielaard2014-01-305-79/+101
| | | | | | | | This just makes sure that all format strings are given as literals to printf like functions so the compiler can see and check them. Remove all no_Wformat, add -Wformat=2 unconditionally to AM_CFLAGS. Signed-off-by: Mark Wielaard <[email protected]>
* stack: Add -i, --inlines. Show inlined call frames using DWARF debuginfo.Mark Wielaard2014-01-272-77/+188
| | | | | | | | | | Using dwarf_getscopes_die we can get all scopes that make up the current subprogram representing an address. Using the call_file/line/column attributes we can also show the source locations of these "inlined" calls. Includes a test that shows that when DWARF debuginfo is available all inlined function call frames and their source location can be shown. Signed-off-by: Mark Wielaard <[email protected]>
* stack: Initialize -n maxframes to 256 by default.Mark Wielaard2014-01-272-2/+10
| | | | | | | Make -n default just 256 frames, 2048 was too big. Also Document magic number used in frames.allocated initialization. Signed-off-by: Mark Wielaard <[email protected]>
* stack: Add -d, --debugname. Lookup DWARF debuginfo name for frame address.Mark Wielaard2014-01-272-3/+63
| | | | | | | Includes test that shows -d matches the function name that corresponds to the actual source line we report with -s for a frame address. Signed-off-by: Mark Wielaard <[email protected]>
* addr2line: handle_address initialize scopes to NULL.Mark Wielaard2014-01-242-1/+5
| | | | | | | | | dwarf_getscopes returns the number of scope DIEs containing a PC address. It returns -1 for errors or 0 if no scopes match PC. If dwarf_getscopes returned 0, then scopes will not be allocated and handle_address might free the uninitialized scopes pointer. Make sure it always has a defined value. Signed-off-by: Mark Wielaard <[email protected]>
* robustify: strip.Roland McGrath2014-01-232-31/+63
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* robustify: readelf.Roland McGrath2014-01-232-26/+60
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* robustify: elflint.Jakub Jelinek2014-01-232-28/+86
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* robustify: Use gelf_fsize instead of relying on shdr->sh_entsize.Petr Machata2014-01-232-10/+35
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* readelf: print_debug_macro_section clear vendor array before use.Mark Wielaard2014-01-172-0/+6
| | | | | | | | Not setting a vendor code before use would be invalid which we tried to catch. But to detect that we do need to initialize the vendor array to zero first. Signed-off-by: Mark Wielaard <[email protected]>
* Fix corruption of non-C++ symbols by the demangler.Jan Kratochvil2014-01-153-10/+18
| | | | Signed-off-by: Jan Kratochvil <[email protected]>
* stack: Show and handle -r,--raw even without USE_DEMANGLE.Mark Wielaard2014-01-032-6/+6
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* stack.c (print_frames): Print 0x before build-id hex-offset.Mark Wielaard2014-01-022-1/+6
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* stack: Allow -n 0 for unlimited frames. Make default 2048 frames.Mark Wielaard2014-01-022-15/+41
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Add dwfl_core_file_attach and dwfl_linux_proc_attach.Mark Wielaard2013-12-312-0/+21
| | | | | | | | | | | | | | Rewrite __libdwfl_attach_state_for_pid and __libdwfl_attach_state_for_core as public functions and don't call them from dwfl_linux_proc_report and dwfl_core_file_report anymore. This lets the user attach state explicitly independ from how the dwfl modules have been reported. Since attaching state is an explicit action now the error can be returned directly and we don't need to keep track of process_attach_error. dwfl_linux_proc_attach lets the user can tell libdwfl whether caller takes care of ptrace attaching and stopping the threads under inspection, or whether the callback needs to take care of that and detaching again. Signed-off-by: Mark Wielaard <[email protected]>
* stack: Add -l, --list-modules. Show module memory map, build-id and files.Mark Wielaard2013-12-312-17/+92
| | | | | | | | Use to list modules detected for process or core file by stack program and to see build-ids and which main elf and debug files were recognized by libdwfl callbacks. Signed-off-by: Mark Wielaard <[email protected]>
* stack: Improve error checking and exit code handling.Mark Wielaard2013-12-312-22/+97
| | | | | | | | | | | | | Check up front whether we attached correctly, if not error out. Make sure callbacks report -1 only on real errors and DWARF_CB_ABORT if exiting early (but not in error). Handle all errors from frame callback in print_frames after printing of good frames. Print as much information as possible like tid, address and module name if known with error messages. Only exit with exit code zero if everything went fine. Exit with error code one if there were any non-fatal errors. Exit with error code two if no frames could be printed or a fatal error occurred. Signed-off-by: Mark Wielaard <[email protected]>
* stack: Add --quiet to not resolve addresses, add --raw to not demangle.Mark Wielaard2013-12-313-3/+57
| | | | | | | | | Resolving addresses to function symbol names can be expensive. Use -q to only print addresses (use together with --build-id to process later). Demangle names by default, but add the -r option to not demangle and show the raw names. Signed-off-by: Mark Wielaard <[email protected]>
* stack: Simplify argument parsing. Don't use dwfl_standard_argp.Mark Wielaard2013-12-312-28/+120
| | | | | | | | | | | | We were using dwfl_standard_argp but trying to add our own and substract some options from it. dwfl_standard_argp also handles kernel, modules, executables without state and process maps that stack doesn't support. That made argp parsing somewhat ugly and meant our --help and --usage didn't really match. Just handle the dwfl_standard_argp options we do want directly ('-p', '--core', '-e' and '--debuginfo-path'). That way we can also do sanity checking on the options given. Signed-off-by: Mark Wielaard <[email protected]>
* stack: -b, --build-id shows module build-id, load address and pc offset.Mark Wielaard2013-12-312-4/+35
| | | | | | A convenient format for offline processing of the backtrace. Signed-off-by: Mark Wielaard <[email protected]>
* stack: Add new '-n MAXFRAMES' option. Resolve addresses after unwind.Mark Wielaard2013-12-312-63/+127
| | | | | | | | | Limit the number of frames printed per thread (defaults to 64) and resolve addresses to names, modules and source after unwinding so the thread is only stopped for the minimum time needed to do the actual unwinding. The thread doesn't need to wait for the lookups and printing of information. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Add dwfl_getthread_frames.Mark Wielaard2013-12-232-10/+43
| | | | | | | | | | | | | | | | dwfl_getthread_frames is a convenience function for when the user is only interested in one specific thread id of a process. It can be implemented by a simple wrapper function that removes an extra callback layer just to filter on thread id. But it also provides an optimized path to getting access to just one particular Dwfl_Thread of the Dwfl process by providing and (optional) new callback for the state provider. The pid_thread_callbacks now provide an (optional) pid_getthread that doesn't need to travers all threads anymore. Which is implemented for the linux-pid-attach provider. stack now uses this to implement a new '-1' option that shows just one specific thread of a process. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Introduce dwfl_module_getsym_info and dwfl_module_addrinfo.Mark Wielaard2013-12-203-16/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some arches like ppc64 use function descriptor values instead of function addresses causing matching of names and addresses to fail when using dwfl_module_getsym or dwfl_module_addrsym. Add ebl hook to resolve any function descriptor values found in non-ET_REL modules. The new function dwfl_module_getsym_info doesn't adjust the symbol value in any way, but returns the adjusted and/or resolved address associated with the symbol separately. The new function dwfl_module_addrinfo resolves against both the address associated with the symbol (which could be the function entry address) value and the adjusted st_value. So that it is easy to resolve and match either function descriptors and/or function entry addresses. Since these new functions also return more information they replace the dwfl_module_getsym_elf and dwfl_module_addrsym_elf functions that never made it into a released elfutils version. addr2line and readelf now use the new functions when looking up functions names. addr2line will now also display the section the address was found in when given -x. Extra testcases were added for both addr2line and the dwflsyms testscase. Signed-off-by: Mark Wielaard <[email protected]>
* stack: show binary and source file names where a function is definedMasatake YAMATO2013-12-182-6/+72
| | | | | | | | | | | | | | | | | | This patch adds the module and source file information to the each stack trace line. `-m' is for module file information and `-s' is for source file information. `-v' is for both and more. This is based on private discussion with Jan Kratochvil <[email protected]>. In v2 patch, `-s' and `-m' options are introduced instead of using `-v' repeatedly as suggested by Mark Wielaard <[email protected]>. In v3 patch `-a' is added as extra option and source lines are printed on their own line. Signed-off-by: Masatake YAMATO <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Support AArch64 architecturePetr Machata2013-11-262-2/+6
| | | | Signed-off-by: Petr Machata <[email protected]>
* Support new 'h' core note item format for hidden fieldsPetr Machata2013-11-222-0/+8
| | | | Signed-off-by: Petr Machata <[email protected]>
* stack: Add basic argp version and bug definitions.Mark Wielaard2013-11-112-0/+21
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Fix some (harmless) cppcheck warnings.Mark Wielaard2013-11-093-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | [dwarf_getaranges.c:149]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'? There was already an XXX statement that we weren't using the result. Explicitly read the segment_size and check it is zero. And report an error if it isn't, since we aren't prepared to handle such a case. [arlib.c:62]: (error) Uninitialized variable: tmpbuf [arlib.c:124]: (error) Uninitialized variable: tmpbuf cppcheck is wrong. tmpbuf is initialized in the snprintf call whose result is use in the same memcpy call. It does make the code less readable and harder to understand. So explicitly split the snprintf and memcpy calls. [nm.c:766]: (warning) Assert statement modifies 'cnt'. The cnt variable was only used for this assert sanity check. But it is bad style to do have side effects inside an assert statement. Increase cnt after the assert. Reported-by: David Binderman <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Unwinder for x86*.Jan Kratochvil2013-11-073-2/+183
| | | | | Signed-off-by: Jan Kratochvil <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Solve comparison between signed and unsigned compiler warning.Mark Wielaard2013-11-052-2/+8
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* ar: Correct operation check when instance_specifed is set.Mark Wielaard2013-10-182-1/+5
| | | | | Reported-by: David Binderman <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Show contents NT_FILE core note in readelfPetr Machata2013-09-302-4/+68
| | | | Signed-off-by: Petr Machata <[email protected]>
* Show contents NT_SIGINFO core note in readelfPetr Machata2013-09-302-0/+109
| | | | Signed-off-by: Petr Machata <[email protected]>
* addr2line: Support -i, --inlines output option.Mark Wielaard2013-08-132-20/+129
| | | | | | | | | | | | Show all source locations that caused inline expansion of subroutines at the given address. This can easily be supported by using libdw dwarf_getscopes_die which will give all nested inlined subroutines. When -f, --functions is given also show the function names where the subroutines were inlined. The output matches that of binutils addr2line --inlines. Signed-off-by: Mark Wielaard <[email protected]>
* addr2line: Remove newline from strings returned by getline.Mark Wielaard2013-08-122-1/+10
| | | | | | | | | | | getline can return strings with a newline as last character when reading from stdin. This could cause confusing symbol lookup failures like: addr2line: cannot find symbol 'foo ' So if the last character of the buf returned by getline is a newline just null-terminate it right there. Also add a new testcase run-addr2line-test.sh. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: print actual DIE offsets of DW_OP_GNU_<type> ops.Mark Wielaard2013-07-131-2/+17
| | | | | | | | | | | | | Like DW_OP_GNU_parameter_ref the DW_OP_GNU type conversion ops DW_OP_GNU_const_type, DW_OP_GNU_regval_type, DW_OP_GNU_deref_type, DW_OP_GNU_convert and DW_OP_GNU_reinterpret take a CU relative offset to a DIE (in these cases a DW_TAG_base_type). So handle the DIE offsets just like in the DW_OP_GNU_parameter_ref case by adding the cu->start if known (and -U hasn't been given). For DW_OP_GNU_convert and DW_OP_GNU_reinterpret handle zero specially since it means to "untype" the result and so isn't an actual DIE reference. Signed-off-by: Mark Wielaard <[email protected]>