Commit Graph

1385 Commits

Author SHA1 Message Date
Mark Wielaard 209f149fdc 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>
2014-08-15 20:29:48 +02:00
Mark Wielaard 9d29ed2989 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>
2014-08-15 20:29:20 +02:00
Kyle McMartin c1e0fcb931 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>
2014-08-01 12:24:21 +02:00
Jan Kratochvil 475849fdb2 Fix report_r_debug for prelinked libraries
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2014-07-28 21:00:13 +02:00
Mark Wielaard e7b2a92bbc m4: Handle cross-compile situations in biarch.m4 tests.
Reported-by: Leonard Crestez <lcrestez@ixiacom.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-07-14 14:34:15 +02:00
Mark Wielaard a95c4ad24c 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>
2014-07-04 14:30:48 +02:00
Mark Wielaard 16e2d351bf 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>
2014-07-04 13:39:30 +02:00
Mark Wielaard 5e9668ccaf 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>
2014-07-04 13:26:12 +02:00
Kurt Roeckx a7a385547b Make the attach code build again on non-Linux hosts.
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
2014-06-25 09:11:08 +02:00
Mark Wielaard af1e6ed9b4 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>
2014-06-22 19:29:13 +02:00
Mark Wielaard c1c1c06e30 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>
2014-06-22 13:47:48 +02:00
Petr Machata ba9e515620 backends (*_return_value_location): call dwarf_peeled_die_type
... instead of inlining equivalent code.

Signed-off-by: Petr Machata <pmachata@redhat.com>
2014-06-20 22:59:43 +02:00
Mark Wielaard 41362da47b 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>
2014-06-17 16:55:28 +02:00
Mark Wielaard 1986c175c1 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>
2014-06-17 16:50:40 +02:00
Mark Wielaard cb5ac6eed9 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>
2014-06-17 16:50:39 +02:00
Mark Wielaard fb86387b18 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>
2014-06-17 16:49:05 +02:00
Mark Wielaard 14beac3b6f 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>
2014-06-11 15:31:41 +02:00
Mark Wielaard 824f393411 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>
2014-06-11 15:14:00 +02:00
Mark Wielaard 903f334ef0 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>
2014-05-27 22:00:46 +02:00
Mark Wielaard eb4811dee1 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>
2014-05-27 22:00:46 +02:00
Mark Wielaard bd1a0d1293 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>
2014-05-27 22:00:46 +02:00
Mark Wielaard 22497096e8 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>
2014-05-27 22:00:38 +02:00
Mark Wielaard 4cd77d68f3 Regenerate *.po files.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-05-20 10:44:28 +02:00
Mark Wielaard 028d0ab0cc 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>
2014-05-19 22:04:24 +02:00
Mark Wielaard 85482fc073 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>
2014-05-18 22:45:45 +02:00
Mark Wielaard f05dff9d39 Prepare 0.159 release.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-05-18 22:37:29 +02:00
Mark Wielaard 0f5b632a72 libdwfl: Don't leak fd on error in linux-proc-maps.c (grovel_auxv).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-05-15 16:03:59 +02:00
Mark Wielaard bb096d0412 Remove --enable-dwz. dwz alt debug is no longer experimental.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-05-03 00:23:06 +02:00
Mark Wielaard df85bf9902 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>
2014-05-02 17:00:48 +02:00
Mark Wielaard d81d32d2a4 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>
2014-05-01 13:51:31 +02:00
Florian Weimer 920f03dcd3 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>
2014-05-01 13:37:43 +02:00
Florian Weimer 2248165d12 tests/allfcts.c: Install alternate debug information
This change also adds more error checking and reporting.

Signed-off-by: Florian Weimer <fweimer@redhat.com>
2014-04-24 14:45:41 +02:00
Florian Weimer 4813dbbcb8 libdwelf: Add dwelf_dwarf_gnu_debugaltlink
Signed-off-by: Florian Weimer <fweimer@redhat.com>
2014-04-24 14:40:59 +02:00
Florian Weimer 35e2a765c0 libdw: Add dwarf_getalt, dwarf_setalt
Signed-off-by: Florian Weimer <fweimer@redhat.com>
2014-04-24 13:18:33 +02:00
Florian Weimer efa72a02de 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>
2014-04-24 13:18:33 +02:00
Mark Wielaard 9380297e13 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>
2014-04-24 13:18:33 +02:00
Mark Wielaard 7c680a24bc 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>
2014-04-24 11:33:54 +02:00
Mark Wielaard 740d1fe497 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>
2014-04-24 11:33:54 +02:00
Mark Wielaard 7c757b33fd 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>
2014-04-24 11:33:54 +02:00
Mark Wielaard eb4da48fa4 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>
2014-04-24 11:33:54 +02:00
Mark Wielaard fe4b5fd34e tests: run-nm-self.sh use test = not == for string comparisons.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-04-23 20:27:23 +02:00
Kurt Roeckx 02cefdaa64 Unwinding is only supported on Linux
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
2014-04-23 10:56:01 +02:00
Mark Wielaard 3232479483 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>
2014-04-18 11:46:51 +02:00
Mark Wielaard f7cdc74ed3 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>
2014-04-15 14:19:55 +02:00
Mark Wielaard 110c273d35 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>
2014-04-14 15:27:04 +02:00
Mark Wielaard 66637fa210 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>
2014-04-14 11:31:28 +02:00
Mark Wielaard 7f1eec317d 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>
2014-04-09 23:09:40 +02:00
Jean Pihet 077082fdef 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>
2014-03-30 13:07:55 +02:00
Mark Wielaard 87955c4cb7 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>
2014-03-19 14:41:04 +01:00
Mark Wielaard dd64d4a926 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>
2014-03-17 11:08:09 +01:00