platform/upstream/elfutils.git
10 years agodwfl_core_file_report: Fix a regression of dwfl_core_file_report retval
Jan Kratochvil [Thu, 7 Nov 2013 20:27:54 +0000 (21:27 +0100)]
dwfl_core_file_report: Fix a regression of dwfl_core_file_report retval

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agodwfl_core_file_report: Fix core files for re-prelink-ed files
Jan Kratochvil [Thu, 7 Nov 2013 15:47:19 +0000 (16:47 +0100)]
dwfl_core_file_report: Fix core files for re-prelink-ed files

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agodwfl_core_file_report: Code cleanup: Reindentation.
Jan Kratochvil [Thu, 7 Nov 2013 15:34:58 +0000 (16:34 +0100)]
dwfl_core_file_report: Code cleanup: Reindentation.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoconfigure.ac: Warn when --enable-dwz=no, but /usr/lib/debug/.dwz exists.
Mark Wielaard [Wed, 6 Nov 2013 13:57:33 +0000 (14:57 +0100)]
configure.ac: Warn when --enable-dwz=no, but /usr/lib/debug/.dwz exists.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoconfigure.ac: Add warning that --enable-thread-safety is experimental.
Mark Wielaard [Wed, 6 Nov 2013 11:21:32 +0000 (12:21 +0100)]
configure.ac: Add warning that --enable-thread-safety is experimental.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibelf: Write all section headers if elf flags contains ELF_F_DIRTY.
Mark Wielaard [Tue, 5 Nov 2013 15:27:32 +0000 (16:27 +0100)]
libelf: Write all section headers if elf flags contains ELF_F_DIRTY.

When ehdr e_shoff changes, elf flags is set dirty. This indicates that
the section header moved because sections were added/removed or changed
in size.

Reported-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix expansion of libdw_a_LIBADD
Michael Forney [Fri, 1 Nov 2013 07:51:05 +0000 (00:51 -0700)]
Fix expansion of libdw_a_LIBADD

At least with automake-1.14, libdw_a_LIBADD currently expands to:

    <snip>
    am__DEPENDENCIES_1 =
    libdw_a_DEPENDENCIES = $(addprefix ../libdwfl/,$(shell \
            $(am__DEPENDENCIES_1) t ../libdwfl/libdwfl.a))
    <snip>
    libdw_a_LIBADD = $(addprefix ../libdwfl/,$(shell $(AR) t ../libdwfl/libdwfl.a))

This leads to the spurious error message:

    make[2]: t: Command not found

Signed-off-by: Michael Forney <mforney@mforney.org>
10 years agoCheck for prefixed ar, readelf, and nm
Michael Forney [Fri, 1 Nov 2013 07:51:04 +0000 (00:51 -0700)]
Check for prefixed ar, readelf, and nm

Sometimes with cross-compile toolchains, the tools are prefixed with the
target arch. Using AC_CHECK_TOOL looks for tools named like this.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoreadelf: Solve comparison between signed and unsigned compiler warning.
Mark Wielaard [Tue, 5 Nov 2013 12:37:33 +0000 (13:37 +0100)]
readelf: Solve comparison between signed and unsigned compiler warning.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: allfcts.c (main): Correct dwarf_getfuncs return value check.
Mark Wielaard [Tue, 5 Nov 2013 10:27:19 +0000 (11:27 +0100)]
tests: allfcts.c (main): Correct dwarf_getfuncs return value check.

The return value of dwarf_getfuncs is a ptrdiff_t that is zero on success,
or non-zero (an offset to continue the search) when the callback returned
DWARF_CB_ABORT or on error. When an error occurs dwarf_errno is set.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoREADME: Fix compatbile -> compatible typo.
Mark Wielaard [Mon, 4 Nov 2013 14:43:33 +0000 (15:43 +0100)]
README: Fix compatbile -> compatible typo.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoREADME: Document that tools and libraries should be upgraded together.
Mark Wielaard [Mon, 4 Nov 2013 14:19:32 +0000 (15:19 +0100)]
README: Document that tools and libraries should be upgraded together.

On some distributions it was possible to upgrade separate parts of elfutils
individually. That causes hard to debug issues since some tools (e.g. readelf)
and some libraries (e.g. libdw) depend on libelf internal data structures,
which could be different between versions (or when configured with different
flags). So explicitly document that they should always be upgraded together.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix executable_for_core for non-dwfl_standard_argp
Jan Kratochvil [Wed, 30 Oct 2013 09:48:20 +0000 (10:48 +0100)]
Fix executable_for_core for non-dwfl_standard_argp

./
2013-10-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

* NEWS (Version 0.158): New.

libdw/
2013-10-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

* libdw.map (ELFUTILS_0.158): New.

libdwfl/
2013-10-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

* argp-std.c (parse_opt): Use executable parameter of
dwfl_core_file_report.
* core-file.c (dwfl_core_file_report): Add parameter executable.  Set
it to DWFL.  Add NEW_VERSION for it.
(_compat_without_executable_dwfl_core_file_report): New.  Twice.
* libdwfl.h (dwfl_core_file_report): Add parameter executable, update
the function comment.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolibdw: Handle dwz multi files correctly in dwarf_getfuncs.
Mark Wielaard [Thu, 10 Oct 2013 09:40:12 +0000 (11:40 +0200)]
libdw: Handle dwz multi files correctly in dwarf_getfuncs.

Don't use DIE offsets, but use their addresses to make sure they are unique.
Include test cases where main and alt file have subprograms at same offsets.

Reported-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Don't report and abort on non-file mappings in maps.
Mark Wielaard [Tue, 15 Oct 2013 21:53:32 +0000 (23:53 +0200)]
libdwfl: Don't report and abort on non-file mappings in maps.

proc_maps_report, used for -p or -M, could report modules with names
that were not absolute file names (and not the special vdso marker).
dwfl_linux_proc_find_elf would abort on such names. This isn't a very
nice thing to do in a library. Make sure only real (absolute) file
mappings are reported and don't abort when unexpected file names are
found, just report failure.

Test case with some examples as found in Linux /proc/PID/maps added.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoar: Correct operation check when instance_specifed is set.
Mark Wielaard [Fri, 18 Oct 2013 08:37:53 +0000 (10:37 +0200)]
ar: Correct operation check when instance_specifed is set.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUpdate Ukrainian translation
Yuri Chornoivan [Wed, 9 Oct 2013 15:04:59 +0000 (18:04 +0300)]
Update Ukrainian translation

Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
10 years agobackends: ppc_abi_cfi reg1 use DW_CFA_val_offset not DW_CFA_val_expression.
Mark Wielaard [Sun, 6 Oct 2013 15:04:07 +0000 (17:04 +0200)]
backends: ppc_abi_cfi reg1 use DW_CFA_val_offset not DW_CFA_val_expression.

Register rules using expressions are stored using an offset from the
start of the .eh_frame or .debug_frame ELF section data. Since abi_cfi
rules aren't stored in those ELF sections they should use neither
DW_CFA_expression nor DW_CFA_val_expression. The only backend that used
DW_CFA_val_expression was ppc_cfi.c. It was easier to express the same
rule using DW_CFA_val_offset than to change the code to handle register
rules using expressions. On most architectures this did work by accident.
See the definition of struct dwarf_frame_register value in libdw/cfi.h to
see why. But on ia64 the abi_cfi data and actual frame data were placed
too far apart and caused a crash in tests/run-addrcfi.sh for ppc32.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdw: Make sure that every debug_types sig8 is hashed
Josh Stone [Thu, 3 Oct 2013 19:38:25 +0000 (12:38 -0700)]
libdw: Make sure that every debug_types sig8 is hashed

When dwarf_formref_die can't find a sig8 in the hash, it walks
__libdw_intern_next_unit, and was then adding those to the hash.
However, if dwarf_offdie_types is called earlier, which also uses that
next_unit, then they are missed from the hash (and never revisited).

This patch makes __libdw_intern_next_unit do the sig8 hash insert, so no
type unit is ever missed.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agoUpdate elf.h from glibc
Petr Machata [Tue, 1 Oct 2013 14:29:41 +0000 (16:29 +0200)]
Update elf.h from glibc

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years ago0.157 release updates for NEWS, elfutils.spec.in and .po files. elfutils-0.157
Mark Wielaard [Mon, 30 Sep 2013 11:50:26 +0000 (13:50 +0200)]
0.157 release updates for NEWS, elfutils.spec.in and .po files.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoShow contents NT_FILE core note in readelf
Petr Machata [Thu, 26 Sep 2013 19:02:22 +0000 (21:02 +0200)]
Show contents NT_FILE core note in readelf

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agoShow contents NT_SIGINFO core note in readelf
Petr Machata [Wed, 25 Sep 2013 22:39:34 +0000 (00:39 +0200)]
Show contents NT_SIGINFO core note in readelf

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agolibdw: Fix compiler warnings on 32-bit.
Mark Wielaard [Sun, 29 Sep 2013 22:39:07 +0000 (00:39 +0200)]
libdw: Fix compiler warnings on 32-bit.

Don't cast directly to/from Dwarf_Word (uint64_t) to/from pointers,
but use uintptr_t as intermediary to prevent cast to pointer from
integer of different size warnings.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoRecognize names of some new core note types in ebl_core_note_type_name
Petr Machata [Wed, 25 Sep 2013 22:38:37 +0000 (00:38 +0200)]
Recognize names of some new core note types in ebl_core_note_type_name

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agoPrepare 0.157 release.
Mark Wielaard [Fri, 27 Sep 2013 12:02:26 +0000 (14:02 +0200)]
Prepare 0.157 release.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUpdate elf.h from glibc
Petr Machata [Mon, 17 Jun 2013 21:52:27 +0000 (23:52 +0200)]
Update elf.h from glibc

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agolibdw: Simplify __libdw_visit_scopes' tag checks
Josh Stone [Tue, 24 Sep 2013 22:52:05 +0000 (15:52 -0700)]
libdw: Simplify __libdw_visit_scopes' tag checks

The former classify_die() was splitting tags into more classes than
actually needed.

The one place that used the "imported" die_class now just compares to
DW_TAG_imported_unit directly.

The recursion check was squashing "match", "match_inline", and "walk"
into the same action.  Now that uses the new may_have_scopes(), which
just returns true for all tags that had those classifications.

The net result has no functional change, but performs better.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agoeblsectionstripp.c (ebl_section_strip_p): Check shdr_l is not NULL.
Mark Wielaard [Wed, 25 Sep 2013 11:02:53 +0000 (13:02 +0200)]
eblsectionstripp.c (ebl_section_strip_p): Check shdr_l is not NULL.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdw: Make dwarf_getfuncs find all (defining) DW_TAG_subprogram DIEs.
Mark Wielaard [Fri, 20 Sep 2013 13:50:42 +0000 (09:50 -0400)]
libdw: Make dwarf_getfuncs find all (defining) DW_TAG_subprogram DIEs.

dwarf_getfuncs used to return only the DW_TAG_subprogram DIEs that were
direct children of the given CU. This is normally how GCC outputs the
subprogram DIEs. But not always. For nested functions the subprogram DIE
is placed under the code construct DIE where it is nested. Other compilers
might output the defining subprogram DIE of a C++ class function under
the DW_TAG_namespace DIE where it was defined. Both such constructs seem
allowed by the DWARF specification. So just searching the CU DIE children
was wrong.

To find all (defining) subprogram DIEs in a CU dwarf_getfuncs should
use __libdw_visit_scopes to walk the tree for all DIEs that can contain
subprograms as children. The only tricky part is making sure the offset
returned and used when the callback returns DWARF_CB_ABORT is correct
and the search continues at the right spot in the CU DIE tree. This
operation now needs to rewalk the whole tree.

Two new testcases were added that fail without this patch. And the
allfcts test was tweaked so that it always returns DWARF_CB_ABORT
from its callback to make sure the offset handling is correct.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoMake sure --enable-dwz code is also tested during make distcheck.
Mark Wielaard [Fri, 20 Sep 2013 12:48:00 +0000 (14:48 +0200)]
Make sure --enable-dwz code is also tested during make distcheck.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Fix memory leak in cu.c on bad DWARF.
Mark Wielaard [Thu, 12 Sep 2013 14:49:25 +0000 (16:49 +0200)]
libdwfl: Fix memory leak in cu.c on bad DWARF.

If libdw dwarf_offdie fails free cu structure.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix memory leak and set libdw errno when intern_fde cannot parse start/end.
Mark Wielaard [Thu, 12 Sep 2013 13:49:47 +0000 (15:49 +0200)]
Fix memory leak and set libdw errno when intern_fde cannot parse start/end.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: proc_maps_report should not fclose the given file.
Mark Wielaard [Thu, 12 Sep 2013 13:16:13 +0000 (15:16 +0200)]
libdwfl: proc_maps_report should not fclose the given file.

Calling fclose only on bad_report, but not on other errors or success
is confusing. The caller is always responsible for calling fclose on
the given file. Otherwise flcose might be called twice (e.g. in
dwfl_linux_proc_report).

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix typo in dwfl_module_getdwarf.c (find_symtab).
Mark Wielaard [Thu, 12 Sep 2013 09:27:56 +0000 (11:27 +0200)]
Fix typo in dwfl_module_getdwarf.c (find_symtab).

Call elf_getdata with aux_xndxscn, not xndxscn, for aux_symxndxdata.
This was a copy/paste error from the code just above for symxndxdata.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: Add new varlocs test for dwarf_getlocation* functions.
Mark Wielaard [Fri, 30 Aug 2013 22:52:12 +0000 (00:52 +0200)]
tests: Add new varlocs test for dwarf_getlocation* functions.

This tests the new dwarf_getlocations, dwarf_getlocation_attr and
dwarf_getlocation_die functions. But it is also an example of how
to handle location expressions and which libdw functions can be
used to access all information required to interpret each DW_OP.

It might make sense to extend this test/example into a program
that verifies various properties of DWARF expressions.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdw: Add new functions dwarf_getlocation_attr and dwarf_getlocation_die.
Mark Wielaard [Fri, 30 Aug 2013 21:55:12 +0000 (23:55 +0200)]
libdw: Add new functions dwarf_getlocation_attr and dwarf_getlocation_die.

Some location expression operations have a DIE associated with them.
Examples are some of the new GNU typed DWARF extensions, DW_OP_GNU_convert,
DW_OP_GNU_reinterpret, DW_OP_GNU_const_type, DW_OP_GNU_regval_type and
DW_OP_GNU_deref_type. Others have (block) values associated with them,
like DW_OP_GNU_entry_value and DW_OP_GNU_const_type.

It is not always easy to access these values. The DIE offset is given in
various formats either as global offset or CU relative offset. The (block)
value might be constant or a location description. And the block might be
encoded with a uleb128 or ubyte length. The new functions help to easily
get at the DIE or attribute value.

In theory dwarf_getlocation_attr could be used for all cases, since
besides returning DW_AT_const_value or DW_AT_location, it could also
return an attribute referencing a DIE. But at least one operation,
DW_OP_GNU_const_type, has both a (type) DIE and a constant (block)
value associated with it. And directly getting the DIE when needed
is easier than first having to retrieve a (synthesized) attribute
and then getting the actual (type) DIE.

Expression operations that reference an actual DIE for the
DW_AT_location or DW_AT_const_value, like DW_OP_call2, DW_OP_call4,
DW_OP_callref and DW_OP_GNU_implicit_pointer can be used with both
dwarf_getlocation_attr and dwarf_getlocation_die.

DW_OP_implicit_value and DW_OP_GNU_implicit_pointer already had
their own special accessors (dwarf_getlocation_implicit_value
and dwarf_getlocation_implicit_pointer), but it seemed consistent
to include them in the new more generic accessors too.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdw: Add new function dwarf_getlocations.
Mark Wielaard [Fri, 23 Aug 2013 14:12:37 +0000 (16:12 +0200)]
libdw: Add new function dwarf_getlocations.

Using dwarf_getlocation it is possible to get single location
descriptions and with dwarf_getlocation_addr it is possible to
get a location list covering a specific address.  But sometimes
it is more convenient to get all ranges covered by a location
list.  For example when a specific address isn't covered and
you want to find alternative addresses where a location
description is defined.

dwarf_getlocations is modelled after dwarf_ranges. It enumerates
the location ranges and descriptions covered by the given
attribute.  In the first call OFFSET should be zero and *BASEP
need not be initialized.  Returns -1 for errors, zero when
there are no more locations to report, or a nonzero OFFSET
value to pass to the next call.  Each subsequent call must
preserve *BASEP from the prior call.  Successful calls fill in
*STARTP and *ENDP with a contiguous address range and *EXPR with
a pointer to an array of operations with length *EXPRLEN.  If
the attribute describes a single location description and not a
location list the first call (with OFFSET zero) will return the
location description in *EXPR with *STARTP set to zero and *ENDP
set to minus one.

ptrdiff_t dwarf_getlocations (Dwarf_Attribute *attr, ptrdiff_t offset,
                              Dwarf_Addr *basep, Dwarf_Addr *startp,
                              Dwarf_Addr *endp, Dwarf_Op **expr,
                              size_t *exprlen);

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agobackends: Hook abi_cfi for arm.
Mark Wielaard [Mon, 2 Sep 2013 14:46:50 +0000 (16:46 +0200)]
backends: Hook abi_cfi for arm.

New arm_abi_cfi that defines initial CFA, rules for callee-saved regs,
including VFP ones and return register.

Note the DWARF abi extension for ARM says that "registers intentionally
unused" should also be initialized as if by DW_CFA_same_value.  The
example given is "an integer-only function might be included in one
executable file for targets with VFP and another for targets without".
We don't currently do this yet. See the DWARF and calling convention
documents:

DWARF for the ARM Architecture ABI r2.09
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040b/IHI0040B_aadwarf.pdf

Procedure Call Standard for the ARM Architecture ABI r2.09
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf

Also adds addrcfi arm testcase.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: Add s390 and s390x addrcfi testcases.
Mark Wielaard [Wed, 28 Aug 2013 19:54:58 +0000 (21:54 +0200)]
tests: Add s390 and s390x addrcfi testcases.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: Add ppc32 and ppc64 addrcfi testcases.
Mark Wielaard [Wed, 28 Aug 2013 16:10:44 +0000 (18:10 +0200)]
tests: Add ppc32 and ppc64 addrcfi testcases.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agobackends: Hook abi_cfi for ppc and s390.
Jan Kratochvil [Tue, 27 Aug 2013 20:49:36 +0000 (22:49 +0200)]
backends: Hook abi_cfi for ppc and s390.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: Add run-addrcfi.sh test for libdw cfi dwarf_frame_* functions.
Mark Wielaard [Tue, 27 Aug 2013 13:40:56 +0000 (15:40 +0200)]
tests: Add run-addrcfi.sh test for libdw cfi dwarf_frame_* functions.

We require architecture backends to implement the ebl abi_cfi hook
to provide the ABI's default CFI program as used by the libdw dwarf cfi
functions. There is the addrcfi test program that prints the return
address, cfa location expression and register states as returned by
various dwarf_cfi_* and dwarf_frame functions. But that has to be run
by hand. The new run-addrcfi.sh tests hooks addrcfi up to some existing
architecture specific test files and known addresses to more easily
(and automaticly) check that the default CFI program is implemented
correctly and to test the libdw cfi frame info functionality.

Only i386 and x86_64 are tested for now since other backends don't have
the abi_cfi hook yet.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agobackends: Always set *prefix to "" when not used in register_info hook.
Mark Wielaard [Wed, 28 Aug 2013 13:57:27 +0000 (15:57 +0200)]
backends: Always set *prefix to "" when not used in register_info hook.

For ia64 and tilegx *prefix was already set to the empty string, but
arm, ppc and sh used NULL to indicate no prefix preceded the register
name in the canonical assembler syntax. Consistently use the empty string
in all backends since dwfl_module_register_names says: 'a prefix used in
assembler syntax (such as "%" or "$", may be "")'. So users had to handle
the empty string already, and might forget to handle the NULL case
(like our own addrcfi testcase).

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agogelf.h: Fix typo in comment.
Namhyung Kim [Wed, 28 Aug 2013 14:39:00 +0000 (23:39 +0900)]
gelf.h: Fix typo in comment.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agogelf_getauxv: Add missing whitespace.
Mark Wielaard [Tue, 27 Aug 2013 22:03:29 +0000 (00:03 +0200)]
gelf_getauxv: Add missing whitespace.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agogelf_getauxv: Remove unnecessary casts to char *.
Mark Wielaard [Tue, 27 Aug 2013 09:39:52 +0000 (11:39 +0200)]
gelf_getauxv: Remove unnecessary casts to char *.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agogelf_getauxv: Use memcpy, not pointer deref, to avoid alignment problems.
Kurt Roeckx [Sun, 25 Aug 2013 21:15:13 +0000 (23:15 +0200)]
gelf_getauxv: Use memcpy, not pointer deref, to avoid alignment problems.

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl/linux-kernel-modules.c (report_kernel): Pass add_p_vaddr as true.
Mark Wielaard [Thu, 22 Aug 2013 11:45:16 +0000 (13:45 +0200)]
libdwfl/linux-kernel-modules.c (report_kernel): Pass add_p_vaddr as true.

On some architectures (e.g. x86_64) the vmlinux is ET_EXEC, while on
others (e.g. ppc64) it is ET_DYN.  In both cases the phdr p_vaddr will
be non-zero.  We want the image to be placed as if it was ET_DYN, so
pass true for add_p_vaddr which will do the right thing (in combination
with a zero base) in either case.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoCONTRIBUTING: Fix typo.
Mark Wielaard [Wed, 21 Aug 2013 08:41:12 +0000 (10:41 +0200)]
CONTRIBUTING: Fix typo.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoaddr2line: Support -i, --inlines output option.
Mark Wielaard [Tue, 13 Aug 2013 09:40:21 +0000 (11:40 +0200)]
addr2line: Support -i, --inlines output option.

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 <mjw@redhat.com>
10 years agoaddr2line: Remove newline from strings returned by getline.
Mark Wielaard [Mon, 12 Aug 2013 12:21:31 +0000 (14:21 +0200)]
addr2line: Remove newline from strings returned by getline.

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 <mjw@redhat.com>
10 years agoPrepare 0.156 release. elfutils-0.156
Jan Kratochvil [Thu, 25 Jul 2013 09:17:49 +0000 (11:17 +0200)]
Prepare 0.156 release.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoFix run-unstrip-n.sh regression on CentOS-5 ppc.
Jan Kratochvil [Thu, 25 Jul 2013 09:05:35 +0000 (11:05 +0200)]
Fix run-unstrip-n.sh regression on CentOS-5 ppc.

last patch was a bit more heuristic than needed which was found on RHEL-5 ppc
(32-bit):

FAIL: run-unstrip-n.sh (exit: 1)
================================
--- unstrip.out 2013-07-23 23:23:49.000000000 +0200
+++ -   2013-07-23 23:23:49.434052534 +0200
@@ -4,4 +4,3 @@
 0xfdf0000+0x1c0000 edf3dd232e09d01b90683889bd16b9406c52d4de@0xfdf0184 - - libc.so.6
 0xffb0000+0x50000 edec437a85026a1cf8cda94003706202733130c1@0xffb0124 - - ld.so.1
 0x10000000+0x20000 979b7a26747cc09bd84a42b311b5288c704baea5@0x10000174 . - [exe]
-0xf880000+0x201d4 - /lib/librt.so.1 /usr/lib/debug/lib/librt-2.5.so.debug librt.so.1

Therefore the new code generated this excessive line:
0xf880000+0x201d4 - /lib/librt.so.1 /usr/lib/debug/lib/librt-2.5.so.debug librt.so.1

The first part of debug dump is from DT_DEBUG, second part is from segments:

start=0xf880000 end=0xf8a01d4 l_ld=0xfd6fe20 name=/lib/librt.so.1
start=0xfc60000 end=0xfe031e4 l_ld=0xff9e270 name=/lib/libc.so.6
start=0xfe10000 end=0xfe421dc l_ld=0xfddfd98 name=/lib/libpthread.so.0
start=0xffb0000 end=0xfff0668 l_ld=0xffef9ac name=/lib/ld.so.1
module_start=0x100000 module_end=0x110000 dyn_vaddr=0x100ee4
module_start=0xfd50000 module_end=0xfd80000 dyn_vaddr=0xfd6fe20 /lib/librt.so.1
module_start=0xfdb0000 module_end=0xfdf0000 dyn_vaddr=0xfddfd98 /lib/libpthread.so.0
module_start=0xfdf0000 module_end=0xffb0000 dyn_vaddr=0xff9e270 /lib/libc.so.6
module_start=0xffb0000 module_end=0x10000000 dyn_vaddr=0xffef9ac /lib/ld.so.1
module_start=0x10000000 module_end=0x10020000 dyn_vaddr=0x10010850

When comparing conflicts for (found in segments)
module_start=0xfd50000 module_end=0xfd80000 dyn_vaddr=0xfd6fe20 /lib/librt.so.1

the code found this line conflicts (and discarded it):
start=0xfc60000 end=0xfe031e4 l_ld=0xff9e270 name=/lib/libc.so.6

but it did not discard also conflicting:
start=0xf880000 end=0xf8a01d4 l_ld=0xfd6fe20 name=/lib/librt.so.1

So I have changed/improved the algorithm - L_LD can be IMO compared exactly
but otherwise the ranges should be compared for every module, not just the
first one.

Again I am not much happy from this code, it should be using NT_FILE instead,
but when we keep compatibility with old OSes elfutils should not regress
there.

libdwfl/
2013-07-25  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwfl_segment_report_module.c (dwfl_segment_report_module): Check for
conflicts all the modules, not just the first one.  Compare L_LD if it
is equal, not if it is in a module address range.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years ago__libdwfl_elf_address_range: Add missing internal_function keyword.
Jan Kratochvil [Tue, 23 Jul 2013 15:52:01 +0000 (17:52 +0200)]
__libdwfl_elf_address_range: Add missing internal_function keyword.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoFix false match of non-build-id disk library to build-id memory library.
Jan Kratochvil [Tue, 23 Jul 2013 14:30:01 +0000 (16:30 +0200)]
Fix false match of non-build-id disk library to build-id memory library.

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>
10 years agoNEWS: Remove bugfix only entries from Version 0.156.
Jan Kratochvil [Fri, 19 Jul 2013 21:26:28 +0000 (23:26 +0200)]
NEWS: Remove bugfix only entries from Version 0.156.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years ago__libdwfl_find_elf_build_id: Add missing internal_function keyword.
Jan Kratochvil [Fri, 19 Jul 2013 19:41:31 +0000 (21:41 +0200)]
__libdwfl_find_elf_build_id: Add missing internal_function keyword.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoNEWS: Add entries for Version 0.156.
Jan Kratochvil [Thu, 18 Jul 2013 22:24:06 +0000 (00:24 +0200)]
NEWS: Add entries for Version 0.156.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
11 years agoreadelf: print actual DIE offsets of DW_OP_GNU_<type> ops.
Mark Wielaard [Tue, 9 Jul 2013 21:09:38 +0000 (23:09 +0200)]
readelf: print actual DIE offsets of DW_OP_GNU_<type> ops.

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 <mjw@redhat.com>
11 years agoreadelf: print actual DW_OP_GNU_parameter_ref DIE offset.
Mark Wielaard [Fri, 5 Jul 2013 14:44:47 +0000 (16:44 +0200)]
readelf: print actual DW_OP_GNU_parameter_ref DIE offset.

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 <mjw@redhat.com>
11 years agolibdw. Don't blow up stack in dwarf_getsrclines with lots of lines.
Mark Wielaard [Tue, 2 Jul 2013 14:36:16 +0000 (16:36 +0200)]
libdw. Don't blow up stack in dwarf_getsrclines with lots of lines.

When a CU has a really large number of lines dwarf_getsrclines could blow
up the stack because it uses alloca for temporary storage. Use malloc and
free if the number of lines gets too big.

11 years agoDon't assert on mod->e_type in __libdwfl_relocate_value.
Mark Wielaard [Tue, 2 Jul 2013 11:35:29 +0000 (13:35 +0200)]
Don't assert on mod->e_type in __libdwfl_relocate_value.

When setting up the module and searching for an ELF file with a correct
build_id __libdwfl_relocate_value will be called for an ET_REL file in
__libdwfl_find_elf_build_id but mod->e_type is not yet setup in that case
because the Dwfl_Module isn't yet complete (the build-id could mismatch).
This can happen when using the dwfl_linux_kernel_find_elf callback when
it searches for the ELF file matching a kernel module.

11 years agogetcfi_scn_eh_frame: Don't crash and burn when .eh_frame bits aren't there.
Mark Wielaard [Tue, 2 Jul 2013 09:22:35 +0000 (11:22 +0200)]
getcfi_scn_eh_frame: Don't crash and burn when .eh_frame bits aren't there.

Trying to read non-existing bits sometimes works and normally a sanity
check will fail. But it could also lead to an unexpected crash much later
when trying to use the non-existing data.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years ago libdw_visit_scopes: Don't recurse into imported unit children.
Mark Wielaard [Wed, 26 Jun 2013 15:42:52 +0000 (11:42 -0400)]
libdw_visit_scopes: Don't recurse into imported unit children.

    There were two issues with __libdw_visit_scopes. First it returned an
    error whenever called with a root DIE that didn't have any children.
    However a DIE abbrev can have DW_CHILDREN_yes set and still have an
    empty child list. It is inefficient and should be fixed in the DWARF
    producer, but it is legal DWARF. Also the function shouldn't hide real
    DWARF errors found by dwarf_child () or dwarf_siblingof (). Secondly
    __libdw_visit_scopes would recurse into an imported unit and then
    forget about the rest of the children of the root DIE. For an imported
    unit the children of that unit DIE should be treated as if they were
    logical children of the root DIE and not increase the recursion depth.
    Both issues were shown by a systemtap bug using dwarf_getscopes () on
    a CU that had various partial units imported through dwz.

    See http://sourceware.org/bugzilla/show_bug.cgi?id=15671

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agotests EXTRA_DIST typo, forgot extension in testfilenolines.bz2.
Mark Wielaard [Tue, 2 Jul 2013 14:16:58 +0000 (16:16 +0200)]
tests EXTRA_DIST typo, forgot extension in testfilenolines.bz2.

11 years agolibdwfl: link_map.c (report_r_debug) always release memory_callback buffer.
Mark Wielaard [Wed, 5 Jun 2013 15:03:25 +0000 (17:03 +0200)]
libdwfl: link_map.c (report_r_debug) always release memory_callback buffer.

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>
11 years agoUse DT_DEBUG library search first.
Jan Kratochvil [Thu, 30 May 2013 11:21:20 +0000 (13:21 +0200)]
Use DT_DEBUG library search first.

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>
11 years agoreadelf: Format first DW_OP_GNU_implicit_pointer argument as DIE offset.
Mark Wielaard [Mon, 6 May 2013 13:48:56 +0000 (15:48 +0200)]
readelf: Format first DW_OP_GNU_implicit_pointer argument as DIE offset.

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 <mjw@redhat.com>
11 years agolibdw: dwarf_getsrclines don't set end_sequence when there are no lines.
Mark Wielaard [Fri, 3 May 2013 09:28:49 +0000 (11:28 +0200)]
libdw: dwarf_getsrclines don't set end_sequence when there are no lines.

Some CUs might only have a file list, but no actual source lines in their
statement list. Only set end_sequence at the end of the source lines list
if there are actually lines.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoAdd parameter add_p_vaddr to dwfl_report_elf.
Jan Kratochvil [Tue, 30 Apr 2013 12:27:16 +0000 (14:27 +0200)]
Add parameter add_p_vaddr to dwfl_report_elf.

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>
11 years agoNew macro COMPAT_VERSION_NEWPROTO.
Jan Kratochvil [Sun, 28 Apr 2013 18:10:33 +0000 (20:10 +0200)]
New macro COMPAT_VERSION_NEWPROTO.

lib/
* eu-config.h (COMPAT_VERSION_NEWPROTO): New.  Twice.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
11 years agotests: Don't use pushd or popd, just use cd to change working directory.
Mark Wielaard [Mon, 29 Apr 2013 18:48:36 +0000 (20:48 +0200)]
tests: Don't use pushd or popd, just use cd to change working directory.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agotests: Tests that override EXIT (0) trap need to cleanup themselves.
Mark Wielaard [Sat, 27 Apr 2013 21:15:44 +0000 (23:15 +0200)]
tests: Tests that override EXIT (0) trap need to cleanup themselves.

Since trap handlers don't nest tests that install their own EXIT (0) trap
handler need to cleanup themselves. Add an exit_cleanup helper function
to test-subr.sh that can be used by run-native-test.sh to exit cleanly.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agotests: All update tests should use unique temporary file names and cleanup.
Mark Wielaard [Sat, 27 Apr 2013 22:54:17 +0000 (00:54 +0200)]
tests: All update tests should use unique temporary file names and cleanup.

All update tests used the same temporary file name xxx. And only update4
would clean up this file. Now that tests can run in parallel make sure
all temporary names are unique and every test cleans up their own files.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agotests: Add various files to tempfiles so they are always cleaned up.
Mark Wielaard [Fri, 26 Apr 2013 19:21:56 +0000 (21:21 +0200)]
tests: Add various files to tempfiles so they are always cleaned up.

Various tests tried to rm their own temporary files. That could mean those
files weren't properly cleaned up if the testcase unexpectedly failed. Add
them to tempfiles to make sure they are always cleaned up by test-subr.sh.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agolibdwfl/link_map.c: #include system.h.
Mark Wielaard [Sat, 27 Apr 2013 18:50:32 +0000 (20:50 +0200)]
libdwfl/link_map.c: #include system.h.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoEnable automake parallel-tests for make check.
Mark Wielaard [Fri, 26 Apr 2013 21:44:25 +0000 (23:44 +0200)]
Enable automake parallel-tests for make check.

The parallel-tests option was introduced in automake 1.11 and is the
default since automake 1.13. All tests can now be ran in parallel with
make check -j. To enable this all tests are ran in their own temporary
directory so they don't stomp on each others input or output files.
On my machine (4 cores) make check takes ~20 seconds, but now with
make check -j8 takes only ~4 seconds.

ChangeLog:

       * configure.ac (AM_INIT_AUTOMAKE): Request parallel-tests.

tests/ChangeLog:

       * Makefile.am (installed_TESTS_ENVIRONMENT): Export environment,
       remove wrapper.
       (TESTS_ENVIRONMENT): Likewise.
       (installed_LOG_COMPILER): New variable defining wrapper.
       (LOG_COMPILER): Likewise.
       * run-*.sh: Fixup location of input and output files.
       * test-subr.sh: Create test_dir, pushd to execute test in.
       (trap): Remove test_dir.
       (testfiles): Use abs_srcdir.
       (installed_testrun): Match on abs_builddir or abs_top_builddir.
       (self_test_files): Adjust path.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoUnify {BE,LE}{32,64} in lib/system.h.
Jan Kratochvil [Fri, 26 Apr 2013 15:00:50 +0000 (17:00 +0200)]
Unify {BE,LE}{32,64} in lib/system.h.

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>
11 years agoUpdates for Automake 1.13.
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.

11 years agolibdw: DW_FORM_GNU_ref_alt is always offset_size.
Mark Wielaard [Wed, 10 Apr 2013 13:52:57 +0000 (15:52 +0200)]
libdw: DW_FORM_GNU_ref_alt is always offset_size.

Unlike DW_FORM_ref_addr, a DW_FORM_GNU_ref_alt is always of offset size,
even in DWARF version 2.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoreadelf: Add --debug-dump=decodedline support.
Mark Wielaard [Mon, 25 Mar 2013 13:48:06 +0000 (14:48 +0100)]
readelf: Add --debug-dump=decodedline support.

Use libdw to decode the .debug_line section and print address table view
when --debug-dump=decodedline is given.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoreadelf: Display raw .debug_aranges. Use libdw only for decodedaranges.
Mark Wielaard [Mon, 25 Mar 2013 10:45:22 +0000 (11:45 +0100)]
readelf: Display raw .debug_aranges. Use libdw only for decodedaranges.

Display "raw" .debug_aranges by default.  Only use libdw parsing when
--debug-dump=decodedaranges is given.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agolibdw: dwarf_getsrclines mark highest address as end_sequence.
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.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoreadelf: When highpc is in constant form also print as address.
Mark Wielaard [Mon, 25 Mar 2013 20:11:53 +0000 (21:11 +0100)]
readelf: When highpc is in constant form also print as address.

When highpc is in constant form it is relative to lowpc.  In that case
also show as address.

Suggested-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoFix dwfl_report_elf BASE alignment
Jan Kratochvil [Tue, 19 Mar 2013 12:40:13 +0000 (13:40 +0100)]
Fix dwfl_report_elf BASE alignment

libdwfl/
* dwfl_report_elf.c (__libdwfl_report_elf): Remove BASE aligning.

tests/
* Makefile.am (check_PROGRAMS): Add dwfl-report-elf-align.
(TESTS): Add run-dwfl-report-elf-align.sh.
(EXTRA_DIST): Add run-dwfl-report-elf-align.sh and
testfile-dwfl-report-elf-align-shlib.so.bz2 .
(dwfl_report_elf_align_LDADD): New.
* dwfl-report-elf-align.c: New file.
* run-dwfl-report-elf-align.sh: New file.
* testfile-dwfl-report-elf-align-shlib.so.bz2: New file.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
11 years agoreadelf: print_gdb_index_section fix memory leak.
Mark Wielaard [Tue, 19 Mar 2013 10:43:49 +0000 (11:43 +0100)]
readelf: print_gdb_index_section fix memory leak.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoreadelf: Accept version 8 .gdb_index section format.
Mark Wielaard [Mon, 18 Mar 2013 12:54:50 +0000 (13:54 +0100)]
readelf: Accept version 8 .gdb_index section format.

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 <mjw@redhat.com>
11 years agolibdw and libdwfl srcfiles and srclines fixes for partial_units.
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

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoFix two memory leaks in findtextrel and strip.
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".

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoelflint.c (check_symtab): Add __bss_start__ to the list of allowed symbols.
Mark Wielaard [Sun, 24 Feb 2013 21:58:49 +0000 (22:58 +0100)]
elflint.c (check_symtab): Add __bss_start__ to the list of allowed symbols.

Some architectures (ARM) use __bss_start__ instead of __bss_start.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agolibdwfl: Try opening files all installed compression libraries.
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.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agolibdw: Handle FORM_GNU_strp_alt for files with string data only in dwz file.
Mark Wielaard [Fri, 15 Feb 2013 21:45:22 +0000 (22:45 +0100)]
libdw: Handle FORM_GNU_strp_alt for files with string data only in dwz file.

dwarf_formstring should check that the dbg file from which we want the
strp data actually has a IDX_debug_str section.

Reported-By: Tom Tromey <tromey@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agolibdwfl: Use actual file names in parse_opt failure cases.
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.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoelflint: Add two more symbols to gnuld list of allowed bad values.
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.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agobackends: Check type DIE exists before calling dwarf_tag ().
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.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoAdd readelf test for --debug-dump=loc --debug-dump=ranges, -N and -U.
Mark Wielaard [Wed, 30 Jan 2013 10:04:38 +0000 (11:04 +0100)]
Add readelf test for --debug-dump=loc --debug-dump=ranges, -N and -U.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agoreadelf: Add -U, --unresolved-address-offsets output control.
Mark Wielaard [Thu, 24 Jan 2013 10:29:21 +0000 (11:29 +0100)]
readelf: Add -U, --unresolved-address-offsets output control.

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 <mjw@redhat.com>
11 years agoreadelf: Add base to offsets in format_dwarf_addr for debug_loc/ranges.
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 ().

Signed-off-by: Mark Wielaard <mjw@redhat.com>
11 years agolibdwfl/
Jan Kratochvil [Wed, 10 Oct 2012 18:42:30 +0000 (20:42 +0200)]
libdwfl/
linux-proc-maps.c: Include system.h.
(PROCEXEFMT, get_pid_class): New.
(grovel_auxv): Detect 32-bit vs. 64-bit auxv, possibly call get_pid_class.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>