Jan Kratochvil [Tue, 9 Sep 2014 20:58:26 +0000 (22:58 +0200)]
Add is_executable to Dwfl_Module.
Next patch will find module names from NT_FILE note so that main executable
will no longer necessarily have the name "[exe]" or "[pie]".
-e|--executable still should be able to override such module.
libdwfl/
2014-09-18 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwfl_build_id_find_elf.c (dwfl_build_id_find_elf): Use IS_EXECUTABLE.
* dwfl_segment_report_module.c (dwfl_segment_report_module): Set
IS_EXECUTABLE.
* libdwflP.h (struct Dwfl_Module): New field is_executable.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Petr Machata [Fri, 12 Sep 2014 17:03:33 +0000 (19:03 +0200)]
Rename read_ubyte_unaligned_inc to read_addr_unaligned_inc
- The behavior of this function has been changed to read only
address-sized quantities, i.e. the size of 2 is no longer allowed.
(Size of 1 never was.) The two outstanding uses, both in readelf.c,
which actually do use this call to read address-sized units, were
updated, rejecting fields that indicate weird address sizes.
- The three related calls, read_sbyte_unaligned_inc,
read_ubyte_unaligned and read_sbyte_unaligned were dropped. There
are currently no uses for these calls.
Signed-off-by: Petr Machata <pmachata@redhat.com>
Petr Machata [Wed, 10 Sep 2014 20:26:28 +0000 (22:26 +0200)]
Accept DW_AT_GNU_call_site_* as attributes that hold location expressions
- These are extension attributes that correspond in behavior to
attributes described in this proposal:
http://www.dwarfstd.org/ShowIssue.php?issue=100909.2
- N.B.: DW_AT_call_site_data_location doesn't have a DW_AT_GNU_*
counterpart.
Signed-off-by: Petr Machata <pmachata@redhat.com>
Petr Machata [Wed, 10 Sep 2014 20:25:35 +0000 (22:25 +0200)]
elf_begin sets elf_errno for cases that the file is completely unreadable
- The problem this is trying to solve can be seen for example thus:
$ eu-readelf -a /
eu-readelf: failed reading '/': (null)
With the fix we see a proper error number and get a reasonable error
message:
$ eu-readelf -a /
eu-readelf: failed reading '/': invalid file descriptor
Signed-off-by: Petr Machata <pmachata@redhat.com>
Jan Kratochvil [Sun, 17 Aug 2014 16:49:36 +0000 (18:49 +0200)]
Fix resolving ELF symbols for live PIDs with deleted files
For deleted shared library files the offsets to the symbol table were
calculated wrongly from the phdrs because the main_bias wasn't taken into
account.
Formerly shared libraries did not get resolved properly:
#2 0x00007fc4d86c56d6
#3 0x0000000000400938 main
Fixed elfutils produce:
#2 0x00007f61094876d6 libfunc
#3 0x0000000000400938 main
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Josh Stone [Mon, 25 Aug 2014 21:40:35 +0000 (14:40 -0700)]
Prevent premature @AR@ replacement in a sed expression.
The Makefile rule for make-debug-archive has a sed expression to replace
@AR@ will the installed name, but this was itself getting replaced when
the Makefile was configured, for a pattern like "s,ar,/path/prefix-,g".
Havoc ensued in the resulting make-debug-archive.
The fix matches it using a regex bracket expression, "[@]AR[@]", so sed
will still match it, but it's immune to configure's replacement.
Signed-off-by: Josh Stone <jistone@redhat.com>
Mark Wielaard [Mon, 25 Aug 2014 20:13:57 +0000 (22:13 +0200)]
Prepare 0.160 release.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 15 Aug 2014 14:03:21 +0000 (16:03 +0200)]
libdw: Add new function dwarf_cu_die.
Given a Dwarf_Die or Dwarf_Attribute it is often convenient to get at the
CU DIE and the CU header information. There is dwarf_diecu but that doesn't
provide all information from the header and it doesn't work for attributes.
Add a new dwarf_cu_die function that provides all information given a
Dwarf_CU, which both Dwarf_Die and Dwarf_Attribute reference.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 15 Aug 2014 11:08:24 +0000 (13:08 +0200)]
libdw: Add new function dwarf_cu_getdwarf.
In both systemtap and libabigail there is a need to get the actual Dwarf
underlying an Dwarf_Die or Dwarf_Attribute. Following a DIE reference
might end up in an alternate Dwarf since the addition of DWZ multifile
forms. Both Dwarf_Die and Dwarf_Attribute already contain a Dwarf_CU
handle. Add a function dwarf_cu_getdwarf to retrieve the underlying
Dwarf using the Dwarf_CU.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 14 Aug 2014 20:07:44 +0000 (22:07 +0200)]
libdwfl: Handle LZMA .ko.xz compressed kernel modules.
Linux kernel modules can not just be compressed with gz and bz2, but also
with xz.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Kyle McMartin [Mon, 9 Jun 2014 19:06:26 +0000 (21:06 +0200)]
aarch64: use <sys/user.h> defined register structures
glibc now supplies these (compatible) structs instead of including the
kernel's <asm/ptrace.h> header, so let's use them. Annoyingly this will
cause new elfutils to FTBFS on old glibc, and vice versa. So include a
new configure check for the new struct names and use the old ones if
they are not avilable.
Signed-off-by: Kyle McMartin <kyle@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jan Kratochvil [Thu, 24 Jul 2014 18:47:17 +0000 (20:47 +0200)]
Fix report_r_debug for prelinked libraries
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Mark Wielaard [Mon, 14 Jul 2014 12:34:15 +0000 (14:34 +0200)]
m4: Handle cross-compile situations in biarch.m4 tests.
Reported-by: Leonard Crestez <lcrestez@ixiacom.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 4 Jul 2014 12:30:48 +0000 (14:30 +0200)]
Add ppc64le ELFv2 abi support to backends and elflint.
The big endian vs little endian changes are already handled by detecting
the EI_DATA data encoding. And the function descriptors are already not
used when we see there is no .opd section. This change adds new checks
for st_other bits, new relocations and recognizes DT_PPC64_OPT.
Signed-off-by: Menanteau Guy <menantea@linux.vnet.ibm.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 4 Jul 2014 11:39:18 +0000 (13:39 +0200)]
Update elf.h from glibc.
Includes new bits needed for ppc64le ELFv2 abi.
https://bugzilla.redhat.com/show_bug.cgi?id=1110249
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 4 Jul 2014 11:26:12 +0000 (13:26 +0200)]
backends: aarch64_return_value_location should handle DW_ATE_boolean.
Found with run-native-test.sh om debian arm64.
http://bugs.debian.org/753552
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Kurt Roeckx [Tue, 24 Jun 2014 20:08:36 +0000 (22:08 +0200)]
Make the attach code build again on non-Linux hosts.
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Mark Wielaard [Wed, 18 Jun 2014 08:57:58 +0000 (10:57 +0200)]
dwarf.h: Remove non-existing DW_TAG_mutable_type.
The DW_TAG_mutable_type was only mentioned in an early draft of DWARFv3.
But was removed because there are no C++ mutable qualified types. It was
replaced by a new attribute DW_AT_mutable on DW_TAG_member DIEs. The new
attribute is available in dwarf.h.
http://dwarfstd.org/ShowIssue.php?issue=050223.1
DW_TAG_mutable_type was only used internally in some backends (which
just ignored it anyway). dwarves did use it to turn it into a string
value, libabigail used it and ignored it (patches to remove sent).
GCC, GDB and binutils don't use nor define it.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 14 Jun 2014 15:15:37 +0000 (17:15 +0200)]
libebl: Add ebl_func_addr_mask plus ARM backend implementation.
The ARM EABI says that the zero bit of function symbol st_value indicates
whether the symbol points to a THUMB or ARM function. Also the return
value address in an unwind will contain the same extra bit to indicate
whether to return to a regular ARM or THUMB function. Add a new ebl
function to mask off such bits and turn a function value into a function
address so that we get the actual value that a function symbol or return
address points to. It isn't easily possible to reuse the existing
ebl_resolve_sym_value for this purpose, so we end up with another hook
that can be used from dwfl_module_getsym, handle_cfi and elflint.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Petr Machata [Fri, 20 Jun 2014 20:59:43 +0000 (22:59 +0200)]
backends (*_return_value_location): call dwarf_peeled_die_type
... instead of inlining equivalent code.
Signed-off-by: Petr Machata <pmachata@redhat.com>
Mark Wielaard [Sun, 15 Jun 2014 09:35:50 +0000 (11:35 +0200)]
tests/backtrace.c (frame_callback): Error on seeing more than 16 frames.
Don't fill up the test logs with obviously bogus frames.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 13 Jun 2014 23:09:17 +0000 (01:09 +0200)]
tests: backtrace.c accept __libc_do_syscall as first frame symname.
On some architectures (Debian armhl) system calls go through
__libc_do_syscall instead of __kernel_vsyscall. Accept either of
these symbol names for the first backtrace frame.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 13 Jun 2014 23:01:58 +0000 (01:01 +0200)]
tests: backtrace-subr.sh add check_native_unsupported.
The special arm check in check_unsupported should only trigger for native
tests, otherwise on arm various backtrace tests would be skipped that
should work just fine.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sun, 15 Jun 2014 20:14:04 +0000 (22:14 +0200)]
libdwfl: linux-core-attach.c handle possible unaligned data access.
Use libdw/memory-access.h macros read_4ubyte_unaligned_noncvt and
read_8ubyte_unaligned_noncvt to access possibly unaligned data in
core files.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 11 Jun 2014 13:14:23 +0000 (15:14 +0200)]
libdwfl: Record dwfl_attach_state error and return it on failure.
When dwfl_attach_state fails functions that need the process state should
return the error that caused the attach to fail. Use this in the backtrace
test to signal any attach failure. This makes sure that architectures that
don't provide unwinder support get properly detected (and the tests SKIPs)
Also don't assert when trying to attach a non-core ELF file, but return an
error to indicate failure.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 10 Jun 2014 13:09:23 +0000 (15:09 +0200)]
libdwfl: dwfl_standard_argp should not fail when not able to attach Dwfl.
As pointed out in https://bugzilla.redhat.com/show_bug.cgi?id=1107654
commit 191080 introduced a thinko that caused dwfl_standard_argp
to fail if the Dwfl couldn't be attached. Instead of generating a warning
as the comment intended, the failure would be fatal. But even warning
about dwfl_core_file_attach () or dwfl_linux_proc_attach () failing
would be a mistake. The caller/user might not be interested in such
a non-fatal issue. So just ignore if the call failed for whatever reason.
If the caller is interested in warning up front about this issue, then
dwfl_pid () should be called to check the Dwfl is attached. Things should
work just fine for anything that doesn't call any of the dwfl_state related
functions.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 27 May 2014 08:25:27 +0000 (10:25 +0200)]
readelf: Skip section if name is NULL in print_debug.
Don't crash and burn when a section doesn't have a name (possibly invalid
ELF file string table). Just try the next section instead of calling strcmp
on NULL.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 26 May 2014 20:54:38 +0000 (22:54 +0200)]
readelf: Don't print 'for section' when rela section sh_info is zero.
This matches how handle_relocs_rel already printed the header.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 26 May 2014 20:35:30 +0000 (22:35 +0200)]
unstrip: Allow prelinked, but non-split .bss section.
If the section sh_size of the original and undo section are equal then
match them and don't set split_bss. This is also what prelink's
undo_sections allows.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 26 May 2014 19:28:05 +0000 (21:28 +0200)]
unstrip: Add --force to force combining files when ELF headers don't match.
Older versions of GNU binutils strip would drop some ELF header flags.
Causing the main ELF file and the separate .debug file to have mismatched
ELF header fields. Unfortunately some distros are still shipping such files.
eu-unstrip doesn't want to recombine such files. Add a more explicit
explanation which fields don't match and provide a --force, -F flag to
force combining such files anyway (producing a warning).
https://bugzilla.redhat.com/show_bug.cgi?id=698005
https://bugzilla.redhat.com/show_bug.cgi?id=806474
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 20 May 2014 08:44:28 +0000 (10:44 +0200)]
Regenerate *.po files.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 19 May 2014 14:52:56 +0000 (16:52 +0200)]
backends: Add ebl_check_reloc_target_type.
And implement for arm and ia64. Both have special section types that
are valid targets for a reloc. Both refer to unwind data. elflint now
just calls ebl_check_reloc_target_type instead of hard coding the
expected section types.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sun, 18 May 2014 20:41:19 +0000 (22:41 +0200)]
tests: Don't use static functions in testfile-backtrace-demangle.
Compilers and demanglers might treat local/static functions different
between versions. In particular g++ 4.1.2 and libstdc++ mangle and
demangle the static void cxxfunc (int i) function as _Z7cxxfunci.
While g++ 4.8.2 and libstdc++ mangle and demangle it as _ZL7cxxfunci.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 17 May 2014 22:28:26 +0000 (00:28 +0200)]
Prepare 0.159 release.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 15 May 2014 14:03:59 +0000 (16:03 +0200)]
libdwfl: Don't leak fd on error in linux-proc-maps.c (grovel_auxv).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 2 May 2014 22:23:06 +0000 (00:23 +0200)]
Remove --enable-dwz. dwz alt debug is no longer experimental.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 1 May 2014 12:48:27 +0000 (14:48 +0200)]
libdwfl: Move dwz alt multi file searching to find_debuginfo callback.
Don't hard code the Dwarf dwz alt multi file search but allow the user
to override it through the standard Dwfl_Callbacks. Also move ownership
completely to the user of dwarf_setalt by removing free_alt from Dwarf
and adding alt, fd and elf fields to Dwfl_Module. Add a relative .dwz
file test case.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 30 Apr 2014 21:00:40 +0000 (23:00 +0200)]
libdwelf: Add dwelf_elf_gnu_build_id.
Move internal function __libdwfl_find_build_id to libdwelf and use it to
add a public dwelf_elf_gnu_build_id function to extract the NT_GNU_BUILD_ID
from an ELF file using either the shdrs or phdrs. Adjust internal callers
and add a testcase.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Florian Weimer [Tue, 15 Apr 2014 15:11:17 +0000 (17:11 +0200)]
Move .gnu_debugaltlink handling from libdw to libdwfl
Also use dwelf_dwarf_gnu_debugaltlink to locate the alternate debugging
information.
Signed-off-by: Florian Weimer <fweimer@redhat.com>
Florian Weimer [Tue, 15 Apr 2014 14:58:39 +0000 (16:58 +0200)]
tests/allfcts.c: Install alternate debug information
This change also adds more error checking and reporting.
Signed-off-by: Florian Weimer <fweimer@redhat.com>
Florian Weimer [Thu, 24 Apr 2014 12:06:43 +0000 (14:06 +0200)]
libdwelf: Add dwelf_dwarf_gnu_debugaltlink
Signed-off-by: Florian Weimer <fweimer@redhat.com>
Florian Weimer [Tue, 15 Apr 2014 12:31:55 +0000 (14:31 +0200)]
libdw: Add dwarf_getalt, dwarf_setalt
Signed-off-by: Florian Weimer <fweimer@redhat.com>
Florian Weimer [Tue, 15 Apr 2014 12:04:19 +0000 (14:04 +0200)]
dwarf_elf_begin: Add .gnu_debugaltlink to the sectiondata array
And use it if DWZ mode is enabled.
Signed-off-by: Florian Weimer <fweimer@redhat.com>
Mark Wielaard [Fri, 11 Apr 2014 21:52:47 +0000 (23:52 +0200)]
libdwelf: New DWARF ELF Low-level Functions. Add dwelf_elf_gnu_debuglink.
New public header elfutils/libdwelf.h for low-level DWARF/ELF helper
functions. The new function dwelf_elf_gnu_debuglink returns the name and
crc as found in the .gnu_debuglink section of an ELF file.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 22 Apr 2014 21:26:34 +0000 (23:26 +0200)]
readelf: handle_core_item make sure variable length array isn't zero size.
The printed array should have at least space for the terminating zero char.
Found by gcc -fsanitize=undefined while running run-readelf-vmcoreinfo.sh.
runtime error: variable length array bound evaluates to non-positive value 0
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 22 Apr 2014 20:52:06 +0000 (22:52 +0200)]
libdwfl: __libdwfl_frame_reg_[gs]et use uint64_t when checking bits.
Found by gcc -fsanitize=undefined while running the backtrace-core-ppc test.
runtime error: shift exponent 45 is too large for 32-bit type 'unsigned int'
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 22 Apr 2014 20:23:18 +0000 (22:23 +0200)]
readelf.c (print_gdb_index_section): Use unsigned int for 31 bits left shift.
Found by gcc -fsanitize=undefined.
left shift of 1 by 31 places cannot be represented in type 'int'
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 22 Apr 2014 14:43:11 +0000 (16:43 +0200)]
libdw (get_sleb128_step): Remove undefined behavior.
As pointed out by gcc -fsanitize=undefined left shifting a negative value
is undefined. Replace it with a multiplication of the signed value as
suggested by Richard Henderson and Josh Stone.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 23 Apr 2014 07:54:30 +0000 (09:54 +0200)]
tests: run-nm-self.sh use test = not == for string comparisons.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Kurt Roeckx [Tue, 22 Apr 2014 19:46:22 +0000 (21:46 +0200)]
Unwinding is only supported on Linux
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Mark Wielaard [Sun, 13 Apr 2014 15:39:57 +0000 (17:39 +0200)]
Remove mudflap build option.
The --enable-mudflap configure build has been broken for 2 years without
anybody apparently noticing. GCC 4.9 removed mudflap support. Before
release we now run make distcheck with valgrind support. Removal of the
mudflap configure option simplifies the build a little.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 9 Apr 2014 20:38:07 +0000 (22:38 +0200)]
readelf: Read the decompressed data when processing .zdebug DWARF sections.
readelf uses libdw to open the Dwarf and read some of the DWARF data.
But it also uses its own parsers to display some of the low-level
unprocessed data. If the DWARF debug section was zlib compressed it
should actually use the decompressed section data from libdw instead
of the raw section data.
Includes a testcase for those sections that couldn't be properly
displayed when compressed before.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 10 Apr 2014 13:02:53 +0000 (15:02 +0200)]
readelf: convert up to a target long in buf_read_ulong.
Add a i686 corefile test.
Reported-by: Markus Engel <m_engel@cs.uni-kl.de>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 9 Apr 2014 09:48:23 +0000 (11:48 +0200)]
backends: Add aarch64 native and core unwind support.
Add aarch64 backend functions frame_nregs and set_initial_registers_tid.
Mark pc_register in aarch64 prstatus_regs as pc_register.
Add backtrace-core-aarch64 testcase.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 9 Apr 2014 09:33:23 +0000 (11:33 +0200)]
CVE-2014-0172 Check for overflow before calling malloc to uncompress data.
https://bugzilla.redhat.com/show_bug.cgi?id=1085663
Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jean Pihet [Fri, 28 Mar 2014 14:13:10 +0000 (15:13 +0100)]
backends: add ARM compatible mode to AARCH64
Add the initial register setup for AARCH64 running ARM code (so
called compat mode). This makes 'eu-stack -p' happy on ARM binaries
while running on a AARCH64 kernel.
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 19 Mar 2014 13:41:00 +0000 (14:41 +0100)]
backends: AARCH64_ABS32 and AARCH64_ABS64 are also valid in ET_REL.
This is tested now in a native aarch64 build by tests/run-elflint-self.sh
since we added some .o files to the self tests.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 3 Mar 2014 14:07:31 +0000 (15:07 +0100)]
libdwfl: elf_from_remote_memory only trust shdrs of last file-only segment.
If the last PT_LOAD segment that contains the whole shdrs also extends
the segment in memory beyond the end of file the program might be reusing
the memory space that we expect the shdrs to be in. Don't trust the shdrs
are valid in that case.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Josh Stone [Wed, 12 Mar 2014 01:13:55 +0000 (18:13 -0700)]
libdwfl: test dwflsyms on ET_EXEC with minisymtab
This adds testfilebaxmin, an ET_EXEC binary with .gnu_debugdata that
doesn't match the load address of the main file. A previous bug made
this trigger a kernel heuristic that forces the module to act like
ET_DYN, which makes things like dwfl_module_relocate_address report
relative addresses rather than proper absolute addresses.
For example, before the fix dwflsyms would print:
deregister_tm_clones (0) 0x400430, rel: 0x430 (.text)
Now it properly prints:
deregister_tm_clones (0) 0x400430, rel: 0x400430 (.text)
These new test additions confirm that it's fixed.
Signed-off-by: Josh Stone <jistone@redhat.com>
Josh Stone [Tue, 11 Mar 2014 17:19:28 +0000 (10:19 -0700)]
libdwfl: dwfl_module_getdwarf.c (open_elf) only (re)set mod->e_type once.
As noted in https://sourceware.org/bugzilla/show_bug.cgi?id=16676#c2 for
systemtap, the heuristic used by open_elf to set the kernel Dwfl_Module
type to ET_DYN, even if the underlying ELF file e_type was set to
ET_EXEC, could trigger erroneously for non-kernel/non-main (debug or
aux) files. Make sure we only set the e_type of the module once when
processing the main file (when the phdrs can be trusted).
Mark Wielaard [Tue, 4 Mar 2014 10:27:15 +0000 (11:27 +0100)]
libdwfl: dwfl_linux_proc_find_elf use elf_from_remote_memory for (deleted).
If a module has a "(deleted)" main ELF file, then try to read it from
remote memory if the Dwfl has process state attached by reusing the ptrace
mechanism from linux-pid-attach.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 3 Mar 2014 10:43:43 +0000 (11:43 +0100)]
libdwfl: elf_from_remote_memory should use pagesize, not p_align.
elf_from_remote_memory would use the actual p_align of the PT_LOAD segments
to calculate the loadbase, end and start of a segment. But the dynamic
loader aligns the segments using the pagesize and only sanity checks the
p_align values. So we should do the same to get accurate segment addresses.
Also fixes a small memory leak in case the ELF image appears to be bad.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 5 Mar 2014 15:17:54 +0000 (16:17 +0100)]
readelf: Print DW_FORM_sdata values as signed numbers.
Printing DW_FORM_sdata numbers as unsigned values is misleading.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jan Kratochvil [Mon, 3 Mar 2014 23:04:27 +0000 (00:04 +0100)]
Fix abort() on missing section headers.
libdw/
2014-03-03 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix abort() on missing section headers.
* dwarf_begin_elf.c (check_section): Replace abort call by goto err.
New label err to return NULL.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Mark Wielaard [Wed, 26 Feb 2014 16:00:39 +0000 (17:00 +0100)]
libdwfl: linux-proc-maps.c (proc_maps_report): Don't assert on bad input.
If ino == last_ino && dmajor == last_dmajor && dminor == last_dminor then
we expect the file names to be the same as well. Which is reasonable if
the input came from the /proc file system. But there could be bad user
input if the file was supplied through dwfl_linux_proc_maps_report.
Instead of asserting on the bad input, just signal a bad_report.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 26 Feb 2014 16:17:07 +0000 (17:17 +0100)]
libdwfl: elf-from-memory.c (elf_from_remote_memory): Check against p64 p_type.
There was a type in the case of parsing ELFCLASS64 phdrs. Check against
p64 p_type, not the p32 p_type which at a different location in the union.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 24 Feb 2014 16:44:42 +0000 (17:44 +0100)]
readelf: More sanity checks before trying to display interpreter string.
Check there is a SHT_PROGBITS section at the offset given by p_offsets for
a PT_INTERP segment before trying to display the interpreter string.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 7 Feb 2014 13:23:24 +0000 (14:23 +0100)]
readelf: Robustify print_phdr program interpreter printing.
Check phdr->p_filesz and make sure interpreter string is zero terminated
before calling printf.
Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Josh Stone [Wed, 5 Feb 2014 19:26:27 +0000 (11:26 -0800)]
libdw: Read DW_AT_decl_file/line/column as unsigned
Section 2.14 of the DWARF v3 & v4 standards specifies that all three
declaration coordinates are unsigned integer constants. DWARF v2 did
not specify signedness. Now dwarf_decl_* use dwarf_formudata to read
these values.
Also, an assertion on the range of line/column is now a handled error,
setting DWARF_E_INVALID_DWARF for values greater than INT_MAX.
Signed-off-by: Josh Stone <jistone@redhat.com>
Petr Machata [Thu, 30 Jan 2014 14:34:33 +0000 (15:34 +0100)]
backends: Make aarch64_regs.c checkable by -Wprintf
Mark Wielaard [Sun, 26 Jan 2014 19:16:48 +0000 (20:16 +0100)]
backends: Add arm frame_nregs and set_initial_registers_tid.
This allows CFI unwinding for ARM. It relies on having .debug_frame around
which is always the case in our testsuite. All native backtrace tests PASS
on arm if debuginfo (for glibc) is installed on the system. Otherwise the
tests SKIP.
For non-debug unwinding ARM uses EXIDX tables, not .eh_frames, which
would have to be translated to CFI to do unwinding without .debug_frame
available.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 25 Jan 2014 13:32:42 +0000 (14:32 +0100)]
backends: arm_cfi SP (r13) is restored from CFA by default.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 24 Jan 2014 14:50:52 +0000 (15:50 +0100)]
backends: Update arm_reloc.def.
The elflint self test now also checks ET_REL files. Update the list of
relocation types to include all known relocations from elf.h.
R_ARM_SWI24 was obsolete and is now named R_ARM_TLS_DESC. The only other
relocation used in the dynamic linker is R_ARM_IRELATIVE.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 22 Jan 2014 23:56:41 +0000 (00:56 +0100)]
Use -Wformat=2 by default for all files.
This just makes sure that all format strings are given as literals to
printf like functions so the compiler can see and check them. Remove
all no_Wformat, add -Wformat=2 unconditionally to AM_CFLAGS.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 21 Jan 2014 15:13:49 +0000 (16:13 +0100)]
stack: Add -i, --inlines. Show inlined call frames using DWARF debuginfo.
Using dwarf_getscopes_die we can get all scopes that make up the current
subprogram representing an address. Using the call_file/line/column
attributes we can also show the source locations of these "inlined" calls.
Includes a test that shows that when DWARF debuginfo is available all
inlined function call frames and their source location can be shown.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 27 Jan 2014 15:05:54 +0000 (16:05 +0100)]
stack: Initialize -n maxframes to 256 by default.
Make -n default just 256 frames, 2048 was too big. Also Document magic
number used in frames.allocated initialization.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 20 Jan 2014 22:09:26 +0000 (23:09 +0100)]
stack: Add -d, --debugname. Lookup DWARF debuginfo name for frame address.
Includes test that shows -d matches the function name that corresponds to
the actual source line we report with -s for a frame address.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 20 Jan 2014 12:49:48 +0000 (13:49 +0100)]
addr2line: handle_address initialize scopes to NULL.
dwarf_getscopes returns the number of scope DIEs containing a PC address.
It returns -1 for errors or 0 if no scopes match PC. If dwarf_getscopes
returned 0, then scopes will not be allocated and handle_address might free
the uninitialized scopes pointer. Make sure it always has a defined value.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jakub Jelinek [Fri, 17 Jan 2014 19:38:01 +0000 (20:38 +0100)]
robustify: libelf gelf define INVALID_NDX macro.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jakub Jelinek [Fri, 17 Jan 2014 18:36:16 +0000 (19:36 +0100)]
robustify: libelf.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Roland McGrath [Fri, 17 Jan 2014 16:12:46 +0000 (17:12 +0100)]
robustify: strip.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Roland McGrath [Fri, 17 Jan 2014 16:11:39 +0000 (17:11 +0100)]
robustify: readelf.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jakub Jelinek [Fri, 17 Jan 2014 16:07:27 +0000 (17:07 +0100)]
robustify: elflint.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Petr Machata [Fri, 17 Jan 2014 16:00:12 +0000 (17:00 +0100)]
robustify: Use gelf_fsize instead of relying on shdr->sh_entsize.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 16 Jan 2014 12:48:24 +0000 (13:48 +0100)]
tests: Reduce the total number of self-test files and add ET_REL files.
Some self tests would run for a really long time (especially under valgrind)
because we included all libebl backends in the list (there are 12 backends).
Now only test two explicitly. Also there were no ET_REL files in the
self test file list. So add two ET_REL files. The total number of self test
files is now 12.
run-nm-self.sh would run 4 * 3 * 3 * 22 = 792 tests (on all self test files).
Reduce the number of different files to test to 3 (one ET_EXEC, one ET_DYN
and one ET_REL file). Reducing the number of test runs to 99.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 16 Jan 2014 08:45:51 +0000 (09:45 +0100)]
tests: run-backtrace-demangle.sh check exitcode and max number of frames.
There can be more than 3 frames, but depending on the system/installed
glibc we might not be able to unwind fully till the end.
cxxfunc -> f -> main
Expect to see the top two and a warning that there are more frames
(exit code 1)
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jan Kratochvil [Sat, 18 Jan 2014 20:56:13 +0000 (21:56 +0100)]
Fix false FAILs on testsuite with ulimit -c unlimited.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Mark Wielaard [Tue, 14 Jan 2014 21:14:23 +0000 (22:14 +0100)]
backends: aarch64_check_special_symbol check shdr is not NULL before usage.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 14 Jan 2014 21:13:43 +0000 (22:13 +0100)]
readelf: print_debug_macro_section clear vendor array before use.
Not setting a vendor code before use would be invalid which we tried to
catch. But to detect that we do need to initialize the vendor array to
zero first.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Lei Zhang [Fri, 17 Jan 2014 11:20:45 +0000 (03:20 -0800)]
lib: Add missing config.h #include to crc32_file.c.
Without config.h, there is no possibility of large file support.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jan Kratochvil [Wed, 15 Jan 2014 20:16:57 +0000 (21:16 +0100)]
Fix corruption of non-C++ symbols by the demangler.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Matthias Klose [Tue, 7 Jan 2014 09:25:29 +0000 (10:25 +0100)]
tests: backtrace-subr.sh (check_native_core) should check core file name.
Needed when /proc/sys/kernel/core_uses_pid is set to 0. Try to rename
the core file, and if it does still fail, skip the test.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sun, 5 Jan 2014 19:37:30 +0000 (20:37 +0100)]
libdwfl: Only skip reset of return register for non-CIE-return regno (ppc64).
For PPC64 we skip resetting the return register if it is already set.
This is because on PPC64 there are two DWARF registers numbers that can
represent the same register. Setting the return address again confuses
the unwinder. But we do want to reset it if the register number
(non-translated by the ppc64 ebl) is equal to the actual register number
as set in the CIE as return address. This happens on older toolchains in
.debug_frame where the return address is set to 108, but the ebl abi_cfi
also sets register number 65.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 4 Jan 2014 22:28:33 +0000 (23:28 +0100)]
tests: Don't use ptrace detach stopped trick. Raise can return.
On older kernels the ptrace detach stop trick doesn't work reliably.
Just keep the child processes attached and stopped during the tests,
dwfl_linux_proc_attach will handle that fine now. Also on older kernels
raise would sometimes return anyway and cause a spurious assert. Just
ignore it.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 4 Jan 2014 18:19:16 +0000 (19:19 +0100)]
backends: Add PPC64 machine_flag_check.
To distinguish between the current PPC64 ELF ABI and the revised
ELFv2 ABI that will not use function descriptors binutils started
to emit the version (currently 1) in the ehdr e_flags. Recognize
all valid versions (0, 1 or 2) in elflint by adding the hook
ppc64_machine_flag_check.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 4 Jan 2014 14:41:04 +0000 (15:41 +0100)]
tests: backtrace-subr.sh skip check_native_core test if core ulimit fails.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 4 Jan 2014 13:24:58 +0000 (14:24 +0100)]
tests: Simplify backtrace-dwarf (gcc cleanup-13.c) testcase.
The testcase originally came from GCC which was testing the runtime
unwinder using _Unwind_ForcedUnwind. Since we are using our own external
unwinder we can just abort at the right place and unwind from there.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 3 Jan 2014 21:16:34 +0000 (22:16 +0100)]
Prepare 0.158 release.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 3 Jan 2014 17:15:02 +0000 (18:15 +0100)]
backends: Add aarch64 abi_cfi.
Setup initial CIE values for aarch64 for use with dwarf_frame functions.
Register info prefix should be the empty string (not NULL) when not used.
Add an EM_AARCH64 testcase to tests/run-addrcfi.sh to check both issues.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 2 Jan 2014 23:06:31 +0000 (00:06 +0100)]
stack: Show and handle -r,--raw even without USE_DEMANGLE.
Signed-off-by: Mark Wielaard <mjw@redhat.com>