platform/upstream/elfutils.git
10 years agounwinder: s390 and s390x
Jan Kratochvil [Tue, 17 Dec 2013 17:49:54 +0000 (18:49 +0100)]
unwinder: s390 and s390x

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agostack: show binary and source file names where a function is defined
Masatake YAMATO [Tue, 17 Dec 2013 03:03:29 +0000 (12:03 +0900)]
stack: show binary and source file names where a function is defined

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
<jan.kratochvil@redhat.com>.

In v2 patch, `-s' and `-m' options are introduced instead
of using `-v' repeatedly as suggested by Mark Wielaard <mjw@redhat.com>.

In v3 patch `-a' is added as extra option and source lines are
printed on their own line.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoRemove tests/backtrace-dwarf.c unused code.
Jan Kratochvil [Tue, 17 Dec 2013 20:11:48 +0000 (21:11 +0100)]
Remove tests/backtrace-dwarf.c unused code.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoFix forgotten call of ebl_dwarf_to_regno.
Jan Kratochvil [Tue, 17 Dec 2013 17:17:32 +0000 (18:17 +0100)]
Fix forgotten call of ebl_dwarf_to_regno.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolibdwfl: linux-pid-attach.c (pid_next_thread): Use rewinddir on first call.
Mark Wielaard [Tue, 17 Dec 2013 09:37:29 +0000 (10:37 +0100)]
libdwfl: linux-pid-attach.c (pid_next_thread): Use rewinddir on first call.

dwfl_getthreads would otherwise fail to report any threads after it was
called once.

Reported-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Add dwfl_module_getsymtab_first_global.
Mark Wielaard [Mon, 16 Dec 2013 12:28:59 +0000 (13:28 +0100)]
libdwfl: Add dwfl_module_getsymtab_first_global.

New function that provides the index after the last non-local symbol as
returned by dwfl_module_getsym and dwfl_module_getsym_info. Allows users to
first search through all global symbols before searching the local symbols
in the table like dwfl_module_addrsym and dwfl_module_addrsym_info do as
optimization.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Fix various frame related memory leaks.
Mark Wielaard [Sat, 14 Dec 2013 14:02:56 +0000 (15:02 +0100)]
libdwfl: Fix various frame related memory leaks.

The result of dwarf_cfi_addrframe should have been freed when done.
Dwfl_Module cached the reloc_info and the eh_cfi it which also should
have been released when disposing of the module.

Reported-by: Masatake YAMATO <yamato@redhat.com>
Tested-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agounwinder: ppc and ppc64
Jan Kratochvil [Sun, 15 Dec 2013 17:56:17 +0000 (18:56 +0100)]
unwinder: ppc and ppc64

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agotests: Add backtrace_child_biarch_SOURCES to make distcheck happy.
Mark Wielaard [Fri, 13 Dec 2013 22:12:18 +0000 (23:12 +0100)]
tests: Add backtrace_child_biarch_SOURCES to make distcheck happy.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: Disable valgrind for core dumping and for self-introspecting tests.
Mark Wielaard [Fri, 13 Dec 2013 21:42:46 +0000 (22:42 +0100)]
tests: Disable valgrind for core dumping and for self-introspecting tests.

The only tests that fork and exec are those that will then try to ptrace
attach the child for unwind testing. That won't work when the child is
also running under valgrind. So remove --trace-children=yes. Also disable
valgrind while dumping a core or for tests that try to inspect their own
state. They will get confused otherwise finding pieces of valgrind in
their maps.

Note we still seem to hit the following valgrind bug because the way we
map and unmap some shared libraries gets valgrind confused:
https://bugs.kde.org/show_bug.cgi?id=327427

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolib: Avoid the hash-lookup division if possible
Josh Stone [Fri, 13 Dec 2013 00:34:15 +0000 (16:34 -0800)]
lib: Avoid the hash-lookup division if possible

For Dwarf_Abbrev codes, the most common case is that they're packed at
the low end, saving uleb128 encoding size.  Since the hash table is
always resized to be no more than 90% full, those codes are always less
than the table size, and dividing for the remainder is unnecessary.

Dwarf_Dies are frequently created anew, and need to find abbrev each
time, so even that one division becomes a noticeable hotspot.  This
patch adds a branch to avoid it, which is very predictable for the CPU.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agolibdw: Simplify and inline get_uleb128 and get_sleb128
Josh Stone [Tue, 10 Dec 2013 22:19:09 +0000 (14:19 -0800)]
libdw: Simplify and inline get_uleb128 and get_sleb128

This removes the IS_LIBDW distinction so LEB128 operations are now
always inlined, and the implementations are simplified, more direct.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agolibdw: Add an inlined fast path for __libdw_form_val_len
Josh Stone [Mon, 9 Dec 2013 21:52:10 +0000 (13:52 -0800)]
libdw: Add an inlined fast path for __libdw_form_val_len

Quite a few DW_FORMs have a fixed length for their data, and we can
easily represent these in a small lookup table.  The rest of the forms
are left in the old function to compute as needed.  Combined with
inlining, this takes care of many forms with fewer branches and without
any call.  (It's conceivable that a smart compiler could make a similar
lookup transformation from the large switch itself, but GCC doesn't.)

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agolibdw: Handle empty location expression for (indirect) DIE locations.
Mark Wielaard [Mon, 9 Dec 2013 15:33:26 +0000 (16:33 +0100)]
libdw: Handle empty location expression for (indirect) DIE locations.

When dwarf_getlocation_implicit_pointer and dwarf_getlocation_attr
refer to a DIE that doesn't contain a DW_AT_location then don't generate
an error, but return an empty location expression to signal the actual
value pointed to is not available. This isn't invalid DWARF. Also make
sure that __libdw_intern_expression handles empty location expressions.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoAdd config/ar-lib to .gitignore
Josh Stone [Mon, 9 Dec 2013 21:15:56 +0000 (13:15 -0800)]
Add config/ar-lib to .gitignore

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agoFix test FAIL with -O2
Jan Kratochvil [Thu, 5 Dec 2013 15:16:14 +0000 (16:16 +0100)]
Fix test FAIL with -O2

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agotests: SKIP backtrace-data and backtrace-dwarf on unsupported arches.
Mark Wielaard [Thu, 5 Dec 2013 14:26:51 +0000 (15:26 +0100)]
tests: SKIP backtrace-data and backtrace-dwarf on unsupported arches.

run-backtrace-data.sh did check stderr whether the arch was unsupported
but the test didn't print that message yet. backtrace-dwarf did print
the message but was missing a check_unsupported test. Also add an explicit
check_main test for backtrace-dwarf.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: automake 1.13 compatibility fix.
Mark Wielaard [Wed, 4 Dec 2013 19:55:23 +0000 (20:55 +0100)]
tests: automake 1.13 compatibility fix.

tests/Makefile.am:65: warning: deprecated feature: target
'backtrace-child-biarch' overrides 'backtrace-child-biarch$(EXEEXT)'
tests/Makefile.am:65: change your target to read
'backtrace-child-biarch$(EXEEXT)'

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoTests for unwinder of x86*.
Jan Kratochvil [Mon, 2 Dec 2013 19:54:28 +0000 (20:54 +0100)]
Tests for unwinder of x86*.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoIntroduce process_attach_error.
Jan Kratochvil [Sat, 30 Nov 2013 20:40:29 +0000 (21:40 +0100)]
Introduce process_attach_error.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolibdwfl: Add dwfl_module_addrsym_elf and dwfl_module_getsym_elf.
Mark Wielaard [Wed, 27 Nov 2013 15:45:44 +0000 (16:45 +0100)]
libdwfl: Add dwfl_module_addrsym_elf and dwfl_module_getsym_elf.

Introduce two new functions that also return the elf associated with a
symbol to make symbol section indexing work for non-special sections.
Simplify code by removing dwfl_file where appropriate and just track Elf
directly. Document limitations of shndx with existing dwfl_module_addrsym
and dwfl_module_getsym. Extend dwflsyms testcase to check some more symbol
and section (index) properties.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoMark new dwfl functions with version ELFUTILS_0.158.
Mark Wielaard [Tue, 26 Nov 2013 14:13:22 +0000 (15:13 +0100)]
Mark new dwfl functions with version ELFUTILS_0.158.

It took two versions to get the new thread state and unwind dwfl functions
in. Make sure they carry the latest elfutils symbol version in which they
were actually added.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: Makefile.am (EXTRA_DIST): Add run-funcretval.sh.
Mark Wielaard [Tue, 26 Nov 2013 09:44:18 +0000 (10:44 +0100)]
tests: Makefile.am (EXTRA_DIST): Add run-funcretval.sh.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoSupport AArch64 architecture
Petr Machata [Tue, 26 Nov 2013 02:10:31 +0000 (03:10 +0100)]
Support AArch64 architecture

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agoSupport new 'h' core note item format for hidden fields
Petr Machata [Thu, 14 Nov 2013 00:07:22 +0000 (01:07 +0100)]
Support new 'h' core note item format for hidden fields

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agoFix non-build-id core files on build-id system
Jan Kratochvil [Thu, 21 Nov 2013 14:33:22 +0000 (15:33 +0100)]
Fix non-build-id core files on build-id system

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoVerify file vs. core build-id, when both available
Jan Kratochvil [Thu, 21 Nov 2013 14:31:04 +0000 (15:31 +0100)]
Verify file vs. core build-id, when both available

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolink_map: Use proper bias, not l_addr
Jan Kratochvil [Thu, 21 Nov 2013 14:28:02 +0000 (15:28 +0100)]
link_map: Use proper bias, not l_addr

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoCompatibility with older kernels such as RHEL-6.
Jan Kratochvil [Tue, 19 Nov 2013 14:00:15 +0000 (15:00 +0100)]
Compatibility with older kernels such as RHEL-6.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolibdwfl: Fix and test aux_sym address_sync with relocated ELF
Josh Stone [Mon, 18 Nov 2013 22:29:35 +0000 (14:29 -0800)]
libdwfl: Fix and test aux_sym address_sync with relocated ELF

The aux_sym address_sync already worked with a full prelink, which has
.gnu.prelink_undo, but it failed on plain relocations with prelink -r.

Now it uses the difference in ehdr.e_entry as a first offset guess, and
the tests confirm this seems to work fine.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agotests: Fix broken dwflsyms tests, extend test and add prelink tests.
Mark Wielaard [Fri, 15 Nov 2013 23:11:38 +0000 (00:11 +0100)]
tests: Fix broken dwflsyms tests, extend test and add prelink tests.

The two test files that contains minisymtab tables and the expected test
output were wrongly generated. Also prelink tests were missing to check
that a prelinked main ELF file with separate debug or minisyms generated
correctly adjusted symbol values. The dwflsyms test was also extended to
check print and check the result of dwfl_module_relocate_address.

Reported-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUpdate m4/ChangeLog for m4/biarch.m4 authorship.
Jan Kratochvil [Fri, 15 Nov 2013 16:10:45 +0000 (17:10 +0100)]
Update m4/ChangeLog for m4/biarch.m4 authorship.

10 years agoCode cleanup: Remove const in prototype
Jan Kratochvil [Thu, 14 Nov 2013 19:55:41 +0000 (20:55 +0100)]
Code cleanup: Remove const in prototype

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoFix dwfl_attach_state machine->elf
Jan Kratochvil [Thu, 14 Nov 2013 19:53:20 +0000 (20:53 +0100)]
Fix dwfl_attach_state machine->elf

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoProvide __libdwfl_module_getsym to get dwfl_file *
Jan Kratochvil [Wed, 13 Nov 2013 19:00:56 +0000 (20:00 +0100)]
Provide __libdwfl_module_getsym to get dwfl_file *

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoFix dwfl_module_addrsym for minidebuginfo
Jan Kratochvil [Wed, 13 Nov 2013 18:58:06 +0000 (19:58 +0100)]
Fix dwfl_module_addrsym for minidebuginfo

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agostack: Add basic argp version and bug definitions.
Mark Wielaard [Sun, 10 Nov 2013 21:17:05 +0000 (22:17 +0100)]
stack: Add basic argp version and bug definitions.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibelf: Only memcpy ehdr back when not already directly mmapped.
Mark Wielaard [Fri, 8 Nov 2013 18:28:16 +0000 (19:28 +0100)]
libelf: Only memcpy ehdr back when not already directly mmapped.

When the elf file is mmapped ehdr can still point to ehdr_mem if the
address is unaligned.  In such cases we do need to memcpy the ehdr back
to the file. We shouldn't when ehdr already comes directly from the mmapped
file, because that would cause an memcpy call with overlapping addresses
(ehdr being copied directly over itself).

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix some (harmless) cppcheck warnings.
Mark Wielaard [Sat, 9 Nov 2013 15:45:22 +0000 (16:45 +0100)]
Fix some (harmless) cppcheck warnings.

[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 <dcb314@hotmail.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUnwinder for x86*.
Jan Kratochvil [Thu, 30 May 2013 12:37:38 +0000 (14:37 +0200)]
Unwinder for x86*.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agodwfl_core_file_report: Remove the use of MAX.
Jan Kratochvil [Thu, 7 Nov 2013 20:30:17 +0000 (21:30 +0100)]
dwfl_core_file_report: Remove the use of MAX.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>