summaryrefslogtreecommitdiffstats
path: root/src/readelf.c
Commit message (Collapse)AuthorAgeFilesLines
* readelf: Don't print 'for section' when rela section sh_info is zero.Mark Wielaard2014-05-271-1/+15
| | | | | | This matches how handle_relocs_rel already printed the header. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Move dwz alt multi file searching to find_debuginfo callback.Mark Wielaard2014-05-021-10/+24
| | | | | | | | | | 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]>
* readelf: handle_core_item make sure variable length array isn't zero size.Mark Wielaard2014-04-241-1/+1
| | | | | | | | 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-241-1/+1
| | | | | | | 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]>
* readelf: Read the decompressed data when processing .zdebug DWARF sections.Mark Wielaard2014-04-151-8/+10
| | | | | | | | | | | | | 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-141-1/+1
| | | | | | | 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-101-7/+27
| | | | | | 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-241-2/+16
| | | | | | | 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-071-1/+4
| | | | | | | | 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]>
* robustify: readelf.Roland McGrath2014-01-231-26/+54
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* robustify: Use gelf_fsize instead of relying on shdr->sh_entsize.Petr Machata2014-01-231-10/+29
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* readelf: print_debug_macro_section clear vendor array before use.Mark Wielaard2014-01-171-0/+1
| | | | | | | | 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]>
* libdwfl: Introduce dwfl_module_getsym_info and dwfl_module_addrinfo.Mark Wielaard2013-12-201-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]>
* Support new 'h' core note item format for hidden fieldsPetr Machata2013-11-221-0/+3
| | | | Signed-off-by: Petr Machata <[email protected]>
* readelf: Solve comparison between signed and unsigned compiler warning.Mark Wielaard2013-11-051-2/+2
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Show contents NT_FILE core note in readelfPetr Machata2013-09-301-4/+63
| | | | Signed-off-by: Petr Machata <[email protected]>
* Show contents NT_SIGINFO core note in readelfPetr Machata2013-09-301-0/+103
| | | | Signed-off-by: Petr Machata <[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]>
* readelf: print actual DW_OP_GNU_parameter_ref DIE offset.Mark Wielaard2013-07-131-32/+49
| | | | | | | | | | | DW_OP_GNU_parameter_ref takes as argument a CU relative offset to a DW_TAG_formal_parameter DIE. Printing just that relative offset makes it hard to find the actual DIE in the output. Now print the actual DIE offset instead (unless -U is given). We already passed around the base address of the CU. Now we pass around the actual CU so we can use it to find both the base address and the CU offset. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Format first DW_OP_GNU_implicit_pointer argument as DIE offset.Mark Wielaard2013-05-061-1/+1
| | | | | | | | | | | | | | | | | | | Make the printing of DW_OP_GNU_implicit_pointer consistent with other operations that have a DIE offset as argument. Before: [ 6e4a] formal_parameter abstract_origin (ref4) [ 616a] location (exprloc) [ 0] GNU_implicit_pointer 0x6dbe, +0 After: [ 6e4a] formal_parameter abstract_origin (ref4) [ 616a] location (exprloc) [ 0] GNU_implicit_pointer [ 6dbe] +0 Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Add --debug-dump=decodedline support.Mark Wielaard2013-04-041-2/+96
| | | | | | | Use libdw to decode the .debug_line section and print address table view when --debug-dump=decodedline is given. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Display raw .debug_aranges. Use libdw only for decodedaranges.Mark Wielaard2013-04-041-5/+172
| | | | | | | Display "raw" .debug_aranges by default. Only use libdw parsing when --debug-dump=decodedaranges is given. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: When highpc is in constant form also print as address.Mark Wielaard2013-03-261-1/+15
| | | | | | | | When highpc is in constant form it is relative to lowpc. In that case also show as address. Suggested-by: Jan Kratochvil <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* readelf: print_gdb_index_section fix memory leak.Mark Wielaard2013-03-191-0/+2
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Accept version 8 .gdb_index section format.Mark Wielaard2013-03-191-3/+5
| | | | | | | Version 8 just indicates that if the .gdb_index was generated by the gold linker it correctly includes TUs for symbols. http://sourceware.org/PR15021 Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Add -U, --unresolved-address-offsets output control.Mark Wielaard2013-02-061-24/+46
| | | | | | | format_dwarf_addr () takes an extra argument 'raw' that is displayed when the user requests printing raw offsets values output for DWARF data. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Add base to offsets in format_dwarf_addr for debug_loc/ranges.Mark Wielaard2013-02-061-14/+44
| | | | | | | | Collect the base address of the CU while creating the listptr_tables and use them when printing debug ranges and location entries with format_dwarf_addr (). Signed-off-by: Mark Wielaard <[email protected]>
* src/Jan Kratochvil2013-01-301-16/+18
| | | | | | | * readelf.c (handle_core_items): Limit special repeated items handling to single-item formats '\n', 'b' and 'B', assert OFFSET 0 there. Signed-off-by: Jan Kratochvil <[email protected]>
* readelf: Add --elf-section input option to inspect an embedded ELF file.Mark Wielaard2013-01-161-0/+150
| | | | | | | | | | | | | | | | | | Some binaries might have (compressed) embedded ELF files inside a section. The default section name for this is .gnu_debugdata. This normally consists of just those sections needed to provide an auxiluary symbol table. But can theoretically contain other (debug) sections. The new --elf-section arguments makes it possible to easily inspect it as if it is a normal ELF file. libdwfl takes care of automatically decompressing any data in the section if necessary. https://fedoraproject.org/wiki/Features/MiniDebugInfo ELF input selection: --elf-section[=SECTION] Use the named SECTION (default .gnu_debugdata) as (compressed) ELF input data Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Adjust initial FDE address if pcrel before printing.Mark Wielaard2012-12-221-1/+22
| | | | | | | | | The FDE initial_location is printed as start address with format_dwarf_addr. Which does the right thing for .debug_frame addresses, but in .eh_frame this is encoded as DW_EH_PE_pcrel and so needs to be adjusted before formatting. Signed-off-by: Mark Wielaard <[email protected]>
* readelf.c (print_ops): Ajust DW_OP_skip and DW_OP_bra targets calculation.Mark Wielaard2012-11-161-1/+1
| | | | | | | | The 2-byte constant is the number of bytes of the DWARF expression to skip forward or backward from the current operation, beginning after the 2-byte constant. Signed-off-by: Mark Wielaard <[email protected]>
* src/Jan Kratochvil2012-10-121-58/+62
| | | | | | | | | | | | | | | | | | | | | | 2012-10-12 Jan Kratochvil <[email protected]> * readelf.c (ITEM_WRAP_COLUMN, REGISTER_WRAP_COLUMN): Merge to ... (WRAP_COLUMN): ... here. (print_core_item): Remove parameter format_max. Update function comment. Replace FORMAT_MAX by the real output width. (handle_core_item): Remove the FORMAT_MAX values in TYPES, DO_TYPE, calls of print_core_item, remove variable maxfmt, change ITEM_WRAP_COLUMN to WRAP_COLUMN. (handle_core_register): Remove the FORMAT_MAX values in TYPES, BITS, calls of print_core_item, change REGISTER_WRAP_COLUMN to WRAP_COLUMN. backends/ 2012-10-12 Jan Kratochvil <[email protected]> * linux-core-note.c (prstatus_items): Rename groups of sigpend and sighold to signal2 and signal3. Signed-off-by: Jan Kratochvil <[email protected]>
* src/Jan Kratochvil2012-10-111-4/+4
| | | | | | | | | 2012-10-11 Jan Kratochvil <[email protected]> * readelf.c (handle_core_item) <b>: Make run an outer block variable. Increase run only if LASTBIT != 0. Print last element only if RUN > 0. Signed-off-by: Jan Kratochvil <[email protected]>
* In mixed core notes, don't let handle_core_item repeat.Petr Machata2012-09-251-1/+5
| | | | | | | | | | | | If a core note contains both registers and items, descsz is 0 to express that we don't wish to repeat the items. If there is only one item in such note, a special block of code hits that passes &size to handle_core_item, which will decrease that size by the amount consumed by the item. But because size is 0, it underflows and wraps, and the loop following this block, which handles the common case, overruns the core note buffer. Signed-off-by: Petr Machata <[email protected]>
* readelf.c (print_debug_macro_section): Print offset as PRIx64.Mark Wielaard2012-08-271-2/+2
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* readelf.c (register_info): Handle loc == NULL.Mark Wielaard2012-08-271-3/+6
| | | | | | register_info is called by print_cfa_program with loc being NULL. Signed-off-by: Mark Wielaard <[email protected]>
* Rewrite DWARF string functions using known-dwarf macros.Mark Wielaard2012-08-171-811/+297
| | | | | | | | readelf and tests were using hard coded string tables to produce DWARF string constants. Use the known-dwarf macros to redefine these and reduce code. Technique comes from dwarf branch dwarfstrings.c. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add support for DWZ multifile forms DW_FORM_GNU_ref_alt/strp_alt.Mark Wielaard2012-08-091-1/+17
| | | | | | | | | | | | | | | DWZ multifile forms http://www.dwarfstd.org/ShowIssue.php?issue=120604.1 DW_FORM_GNU_ref_alt and DW_FORM_GNU_strp_alt reference an alternative debuginfo file. dwarf_begin and dwarf_begin_elf will try to use this automatically. There are no user visible changes to the libdw interface. dwarf_formref_die, dwarf_formstring and dwarf_formudata can now return a Dwarf_Die which comes from a CU in the alternative Dwarf descriptor. __libdw_read_offset was adjusted to take an alternative Dwarf descriptor into account. Signed-off-by: Mark Wielaard <[email protected]>
* Fix formatting string in readelfPetr Machata2012-08-071-1/+1
| | | | | | This caused failures of 32-bit builds. Signed-off-by: Petr Machata <[email protected]>
* readelf: Use DW_LANG_ObjC and known[op].Mark Wielaard2012-07-291-2/+2
| | | | | Not all patches from the dwarfstrings branch were applied, causing compile failures.
* Add DW_OP_GNU_parameter_ref to dwarf.h and handle it in readelf.Mark Wielaard2012-07-261-0/+12
| | | | | | | DW_OP_GNU_parameter_ref takes as operand a 4 byte CU relative reference to the abstract optimized away DW_TAG_formal_parameter. Signed-off-by: Mark Wielaard <[email protected]>
* Merge branch 'debug_macro'Mark Wielaard2012-07-191-2/+413
|\
| * readelf: Add .debug_macro parsing support.Mark Wielaard2012-07-111-2/+413
| | | | | | | | Signed-off-by: Mark Wielaard <[email protected]>
* | readelf: Add .gdb_index version 7 support.Mark Wielaard2012-07-101-16/+48
|/ | | | | | | | Add version 7 support. Keep track of cu_nr. Print kind and static/global flag for each symbol. When a symbol is in the TU list add 'T'. Add testfilegdbindex test files. Signed-off-by: Mark Wielaard <[email protected]>
* Add low-level support for .debug_macro.Mark Wielaard2012-06-271-0/+4
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* readelf.c: Cast printf PRIu/x64 arguments to uint64_t for gcc 4.7 -Wformat.Mark Wielaard2012-06-221-2/+2
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Update name, license and contributor policy.Mark Wielaard2012-06-051-19/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* readelf.c (print_ops): Add missing DW_OP_GNU operands.Mark Wielaard2012-04-241-0/+3
| | | | DW_OP_GNU_push_tls_address, DW_OP_GNU_uinit and DW_OP_GNU_encoded_addr.
* readelf.c: Check debug section data before trying to print abbrev or str.Mark Wielaard2012-03-281-2/+6
| | | | | | * readelf.c (print_debug_abbrev_section): Check there is Dwarf section data. (print_debug_str_section): Likewise.
* readelf.c (print_gdb_index_section): Accept version 6.Mark Wielaard2012-03-211-2/+3
| | | | | No changes in the format. Version 6 contains symbols for inlined functions, older versions didn't.