Mark Wielaard [Thu, 25 Apr 2013 20:50:11 +0000 (16:50 -0400)]
Updates for Automake 1.13.
autoreconf will install config/test-driver, ignore it.
Update gettext m4 and po files to version 0.18.2.
Use AM_CPPFLAGS instead of INCLUDES.
All changes are backward compatible with Automake 1.11.
Mark Wielaard [Mon, 25 Mar 2013 16:07:21 +0000 (17:07 +0100)]
libdw: dwarf_getsrclines mark highest address as end_sequence.
Make sure the highest address for the CU is marked as end_sequence.
This is required by the DWARF spec, but some compilers forget and
dwfl_module_getsrc depends on it. We could reject it as bad DWARF
but the DWARF .debug_lines spec is much stricter than what compilers
seem to output in practice.
Mark Wielaard [Tue, 12 Mar 2013 11:02:51 +0000 (12:02 +0100)]
libdw and libdwfl srcfiles and srclines fixes for partial_units.
dwfl_getsrclines would always fail, even when lines were found.
dwarf_decl_file, and other functions relying on srcfiles or srclines would
fail for DIEs in partial_units because stmt_lists on partial_units
were ignored.
Note that dwz contained a bug which makes things fail in __libdw_formptr
for DW_AT_stmt_list with a bogus DW_FORM even with these fixes.
https://bugzilla.redhat.com/show_bug.cgi?id=919755
Mark Wielaard [Fri, 1 Mar 2013 10:51:58 +0000 (11:51 +0100)]
Fix two memory leaks in findtextrel and strip.
The findtextrel leak is real, when processing lots of files without text
relocations the files and memory wouldn't be released. The strip leak is
minor since it can only happen when using -f which only allows one file
as argument. But it is nice to see valgrind say:
"All heap blocks were freed -- no leaks are possible".
Mark Wielaard [Fri, 22 Feb 2013 22:42:59 +0000 (23:42 +0100)]
libdwfl: Try opening files all installed compression libraries.
rhbz #909481. When a compression library wasn't installed libdwfl would
not try the next compression library for opening a file. Retry with the
next available compression library if a previous one isn't installed. Also
disable tests that depend on a particular compression library
(run-readelf-s.sh and run-dwflsyms.sh) if that library isn't installed.
Mark Wielaard [Sun, 10 Feb 2013 14:07:33 +0000 (15:07 +0100)]
libdwfl: Use actual file names in parse_opt failure cases.
When handling ARGP_KEY_SUCCESS the failure handling code would use 'arg'
as failure string. But 'arg' would be NULL in such cases leading to failure
messages like: "cannot open '(null)': No such file or directory".
Use opt->e and opt->core explicitly to show file names that caused failure.
Mark Wielaard [Wed, 6 Feb 2013 15:20:17 +0000 (16:20 +0100)]
elflint: Add two more symbols to gnuld list of allowed bad values.
Add __bss_start and __TMC_END__ to the list of symbols allowed to have
out of section values because of the following GNU ld bug:
http://sourceware.org/bugzilla/show_bug.cgi?id=13621.
Allow them to appear in either .symtab or .dynsym, but only when they
are zero sized. It is impossible to define a general rule for this bug,
but this should catch most common issues that are mostly harmless
because the symbols signify the removed section was empty to being with.
This catches at least all symbols often flagged in the tests.
Mark Wielaard [Wed, 6 Feb 2013 12:15:10 +0000 (13:15 +0100)]
backends: Check type DIE exists before calling dwarf_tag ().
dwarf_attr () or dwarf_form () functions leave typedie NULL when they fail
because of missing attribute or unexpected form. In such cases first check
the DIE exists and return error instead of calling dwarf_tag () and crashing.
This also happens in the testsuite with native tests when elfutils is build
without DWZ support on a distro that uses DWZ DWARF compression on system
libraries. Only the backends used dwarf_tag () directly without checking,
all other uses in elfutils already checked whether the given DIE was NULL.
Mark Wielaard [Fri, 18 Jan 2013 21:19:08 +0000 (22:19 +0100)]
readelf: Add base to offsets in format_dwarf_addr for debug_loc/ranges.
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 ().
Jan Kratochvil [Wed, 10 Oct 2012 17:32:05 +0000 (19:32 +0200)]
backends/
* Makefile.am (s390_SRCS): Add s390_corenote.c and s390x_corenote.c.
* linux-core-note.c (ALIGN_PR_REG): New definitions.
(struct EBLHOOK(prstatus)): Change field pr_reg to anonymous struct with
ALIGN_PR_REG.
(EXTRA_ITEMS): New macro.
* s390_corenote.c: New file.
* s390_init.c (s390x_core_note): New declaration.
(s390_init): Install s390x_core_note and s390_core_note.
* s390x_corenote.c: New file.
tests/
* run-readelf-mixed-corenote.sh: New testcase for readelf -n of s390
and s390x core notes.
* testfile67.bz2: New file.
* testfile68.bz2: New file.
* Makefile.am (EXTRA_DIST): Add testfile67.bz2 and testfile68.bz2 .
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Mark Wielaard [Wed, 16 Jan 2013 14:19:32 +0000 (15:19 +0100)]
libdwfl: Add minisymtab support.
Add an auxiliary symbol table dwfl_file aux_sym to Dwfl_Module if all we
have is the dynsym table. The main file might contain a .gnu_debugdata
section. The .gnu_debugdata section is a compressed embedded ELF file
that contains the text (code) section symbols from the symtab table
that are not in the main file dynsym table. dwfl_module_getsymtab (),
dwfl_module_addrsym () and dwfl_module_getsym () will use the auxiliary
symbol table when available (and no full symtab is available from the
debug file).
* libdwflP.h (struct Dwfl_Module): Add aux_sym, aux_symdata,
aux_syments, aux_symstrdata, aux_symxndxdata and aux_first_global.
(dwfl_adjusted_aux_sym_addr): New function.
(dwfl_deadjust_aux_sym_addr): Likewise.
(dwfl_adjusted_st_value): Take and check symfile argument.
(dwfl_deadjust_st_value): Likewise.
* dwfl_module_getdwarf.c (find_prelink_address_sync): Take and
use dwfl_file as argument to set address_sync.
(find_debuginfo): Call find_prelink_address_sync with debug file.
(find_aux_sym): New function.
(find_symtab): Use find_aux_sym if all we have is the dynsym table
and fill in aux DwflModule fields.
(dwfl_module_getsymtab): Return syments plus aux_syments.
(load_symtab): Always set first_global.
* dwfl_module_addrsym.c (dwfl_module_addrsym): Check symfile
when using same_section. Calculate first_global based on both
mod->first_global and mod->aux_first_global.
* dwfl_module.c (__libdwfl_module_free): Free aux_sym.
* dwfl_module_getsym.c (dwfl_module_getsym): Use auxsym table
to retrieve symbol and name if necessary, making sure all locals
from any table come before any globals.
* dwfl_module_info.c (dwfl_module_info): Call dwfl_adjusted_st_value
with symfile.
* relocate.c (resolve_symbol): Likewise.
Mark Wielaard [Wed, 16 Jan 2013 14:19:20 +0000 (15:19 +0100)]
readelf: Add --elf-section input option to inspect an embedded ELF file.
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.
Mark Wielaard [Fri, 21 Dec 2012 21:11:44 +0000 (22:11 +0100)]
readelf: Adjust initial FDE address if pcrel before printing.
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.
Mark Wielaard [Mon, 3 Dec 2012 16:01:09 +0000 (17:01 +0100)]
Run valgrind tests with --run-libc-freeres=no.
By default valgrind tries to free up glibc memory at exit by running
__libc_freeres (). Unfortunately some older glibc versions have bugs
that either crash the test or make valgrind report errors. Since we
aren't interested in tracking memory leaks in glibc anyway, just
disable it.
Jan Kratochvil [Wed, 17 Oct 2012 22:11:30 +0000 (00:11 +0200)]
libdwfl/
* argp-std.c: Update Copyright year.
(offline_find_elf): New function.
(offline_callbacks): Use it for find_elf.
(struct parse_opt): New.
(parse_opt): New key ARGP_KEY_INIT. In other make hook struct
parse_opt pointer from former Dwfl pointer. Delay 'e and OPT_COREFILE
processing till ARGP_KEY_SUCCESS. Initialize state->input already from
ARGP_KEY_SUCCESS. Modify the cleanup in ARGP_KEY_ERROR. Make the
final state->input initialization optional.
* dwfl_end.c: Update Copyright year.
(dwfl_end): Free executable_for_core.
* libdwflP.h: Update Copyright year.
(struct Dwfl): New field executable_for_core.
tests/
* run-addrname-test.sh: New test for PIE relocation.
* testfile70.core.bz2: New file.
* testfile70.exec.bz2: New file.
* Makefile.am (EXTRA_DIST): Add testfile70.core.bz2 and
testfile70.exec.bz2 .
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Mark Wielaard [Fri, 16 Nov 2012 11:25:04 +0000 (12:25 +0100)]
readelf.c (print_ops): Ajust DW_OP_skip and DW_OP_bra targets calculation.
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.
Jan Kratochvil [Wed, 10 Oct 2012 20:27:58 +0000 (22:27 +0200)]
src/
2012-10-12 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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 <jan.kratochvil@redhat.com>
* linux-core-note.c (prstatus_items): Rename groups of sigpend and
sighold to signal2 and signal3.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Adam Markey [Tue, 9 Oct 2012 09:05:53 +0000 (11:05 +0200)]
Handle partial read or write.
Ran into a situation where pread was returning less data than requested for
remote files on a networked filesystem. This patch modifies the IO wrappers
to request the remaining data as long as no real errors occured.
Signed-off-by: Adam Markey <adam@etinternational.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jan Kratochvil [Mon, 8 Oct 2012 21:34:35 +0000 (23:34 +0200)]
libdw/
fde.c (__libdw_find_fde): Change <fde != NULL> to likely. Return
DWARF_E_NO_MATCH if .eh_frame_hdr points to FDE which is too short for searched
PC.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Jan Kratochvil [Mon, 8 Oct 2012 21:08:01 +0000 (23:08 +0200)]
dwarf_getlocation.c (__libdw_intern_expression) <cfap>: Make new loclist
element DW_OP_call_frame_cfa before decoding the opcodes. Remove the later
DW_OP_call_frame_cfa push to RESULT.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Petr Machata [Mon, 24 Sep 2012 14:46:52 +0000 (16:46 +0200)]
Test elfutils output of a mixed core note.
This is a test for previous commit. The core file was snipped so that only
headers and note contents are left. NT_ARM_VFP is the note that exercises
the code.
Petr Machata [Wed, 19 Sep 2012 14:52:07 +0000 (16:52 +0200)]
In mixed core notes, don't let handle_core_item repeat.
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.
Mark Wielaard [Fri, 24 Aug 2012 11:54:52 +0000 (13:54 +0200)]
Don't include dwz support by default.
By default the dwz multi file support is not included. This means any
DW_FORM_GNU_ref_alt or DW_FORM_GNU_strp_alt encountered in libdw will
just produce an error message. A new configure option --enable-dwz is
needed to include it for those we wish to test it. The dwz test is also
disabled by default.
Mark Wielaard [Thu, 16 Aug 2012 22:35:03 +0000 (00:35 +0200)]
Rewrite DWARF string functions using known-dwarf macros.
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.
Mark Wielaard [Fri, 22 Jun 2012 10:02:45 +0000 (12:02 +0200)]
libdw: Add support for DWZ multifile forms DW_FORM_GNU_ref_alt/strp_alt.
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.