summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Handle DWARF5 defaulted member function encodings.Mark Wielaard2017-08-026-3/+52
| | | | | | | | | Add DW_DEFAULTED_no, DW_DEFAULTED_in_class and DW_DEFAULTED_out_of_class to dwarf.h. Print value (no, in_class or out_of_class) of DW_AT_defaulted in readelf. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: DWARF5 Add DW_CC_pass_by_reference and DW_CC_pass_by_reference.Mark Wielaard2017-08-024-3/+16
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add dwarf_default_lower_bound.Mark Wielaard2017-08-0213-55/+217
| | | | | | | | | | Add dwarf_default_lower_bound to get the default lower bound for a language when not given as attribute for an subrange type. Implementation extracted from dwarf_aggregate_size. Add a test to check all known language codes are handled. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: DWARF5 Add new DW_LANG codes and default lower array bound.Mark Wielaard2017-08-025-5/+37
| | | | | | | | | | Add DW_LANG_OpenCL, DW_LANG_Modula3, DW_LANG_C_plus_plus_03, DW_LANG_OCaml, DW_LANG_Rust, DW_LANG_Swift, DW_LANG_Julia, DW_LANG_Dylan, DW_LANG_RenderScript and DW_LANG_BLISS to dwarf.h. Update default language array lower bounds in dwarf_aggregate_size.c. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add new DWARF5 character encodings.Mark Wielaard2017-08-024-2/+10
| | | | | | | Add DW_ATE_UCS and DW_ATE_ASCII for Fortran 2003 string kinds ASCII (ISO/IEC 646:1991) and ISO_10646 (UCS-4 in ISO/IEC 10646:2000). Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add new DWARF5 tag constants.Mark Wielaard2017-08-024-5/+23
| | | | | | | | | | Add DW_TAG_coarray_type, DW_TAG_generic_subrange, DW_TAG_dynamic_type, DW_TAG_call_site, DW_TAG_call_site_parameter, DW_TAG_skeleton_unit, DW_TAG_immutable_type. Just the constants, no further interpretion yet. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add DWARF5 attributes.Mark Wielaard2017-08-024-8/+71
| | | | | | | | | | | | Add new DWARF5 attribute constant names to the attributes enum. Also add reserved comments between non-consecutive (reserved) numbers. Remove DW_AT_subscr_data, DW_AT_element_list and DW_AT_member from the enum list and turn them into compatibility defines because they are not part of DWARF2+. That way code that directly references them still compiles but they won't show up in known-dwarf.h. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Move nested functions in parse_opt to file scope.Yunlian Jiang2017-07-272-26/+34
| | | | | | | * Move nested function 'failure' to file scope to compile with clang. * Move nested function 'fail' to file scope to compile with clang. Signed-off-by: Yunlian Jiang <[email protected]>
* libdw: Add dwarf_line_file.Mark Wielaard2017-07-267-1/+97
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* ppc64: Add HTM SPRs support to readelfGustavo Romero2017-07-2510-18/+58
| | | | | | | | | | Since POWER8, PowerPC 64 supports Hardware Transactional Memory, which has three special purpose registers associated to it: tfhar, tfiar, and texasr. This commit add HTM SPRs set as known note type so it's possible to use 'readelf --notes' to inspect the HTM SPRs in a coredump file generated in such a machines. Signed-off-by: Gustavo Romero <[email protected]>
* strip: Deal with ARM data marker symbols pointing to debug sections.Mark Wielaard2017-07-2416-17/+252
| | | | | | | | | | | | | | | | | | | ARM data marker symbols "$d" indicate the start of a sequence of data items in a section. For data only sections no data marker symbol is necessary, but may be put pointing to the start of the section. binutils however has a bug which places a data marker symbol somewhere inside the section (at least for .debug_frame). https://sourceware.org/bugzilla/show_bug.cgi?id=21809 When strip finds a symbol pointing to a debug section that would be put into the .debug file then it will copy over the whole symbol table. This isn't necessary because the symbol is redundant. Add an ebl hook to recognize data marker symbols with implementations for arm and aarch64. Use it in strip to strip such symbols from the symbol table if they point to a debug section. Signed-off-by: Mark Wielaard <[email protected]>
* backends: Don't depend on linux/bpf.h to compile bpf disassembler.Mark Wielaard2017-07-2415-29/+115
| | | | | | | | | We only need a few constants and one structure definition from linux/bpf. Just define those in a local lib/bpf.h file. This makes sure the bpf disassembler is always build and included even when elfutils is build on older GNU/Linux systems (and even on other platforms). Signed-off-by: Mark Wielaard <[email protected]>
* Write to /dev/null rather than /dev/zeroUlf Hermann2017-07-242-1/+5
| | | | | | | /dev/zero is meant for reading zeroes. /dev/null is for writing into nirvana. Signed-off-by: Ulf Hermann <[email protected]>
* Unify linking of libasm, libelf, libdw, backendsUlf Hermann2017-07-248-20/+64
| | | | | | | | | | Link them all with -z,defs,-z,relro,--no-undefined, provide complete dependencies for the link steps, and add libeu.a to each one. libeu.a contains useful library functionality that each of them might use. The linker will strip unneeded symbols, so linking it in won't hurt even if none of the functions are used. Signed-off-by: Ulf Hermann <[email protected]>
* backends: Swap sys/ptrace.h and asm/ptrace.h include order on s390.Mark Wielaard2017-07-172-1/+5
| | | | | | | | | glibc 2.26 changed the sys/ptrace.h header so that it cannot be included after asm/ptrace.h. We still need to include the kernel asm/ptrace.h for the ptrace_area definition. Including it after sys/ptrace.h works against both old and new glibc. Signed-off-by: Mark Wielaard <[email protected]>
* strip: Add --keep-section=SECTION and --remove-section=SECTION.Mark Wielaard2017-07-177-19/+827
| | | | | | | | | | | | | | | | | | | | | Adds two new output options: --keep-section=SECTION Keep the named section. SECTION is an extended wildcard pattern. May be given more than once. --remove-section=SECTION Remove the named section. SECTION is an extended wildcard pattern. May be given more than once. Only non-allocated sections can be removed. The --remove-section was already partially implemented, but only for the .comment section. The short option -R is to be compatible with binutils. The new testcase makes sure that various combinations of kept/removed sections pull the correct dependencies into the output and/or debug files. https://bugzilla.redhat.com/show_bug.cgi?id=1465997 Signed-off-by: Mark Wielaard <[email protected]>
* Support EM_PPC machine flagsAndreas Schwab2017-06-153-0/+16
| | | | | | | This fixes the elflint self test when the compiler is configured for PIE default. Signed-off-by: Andreas Schwab <[email protected]>
* strip: Don't generate empty output file when nothing to do.Mark Wielaard2017-06-145-12/+95
| | | | | | | | | | | | | | | | | If there was nothing to do strip would skip generating a separate debug file if one was requested, but it would also not finish the creation of a new output file (with the non-stripped sections). Also if there was an error any partially created output would be kept. Make sure that when the -o output file option is given we always generate a complete output file (except on error). Also make sure that when the -f debug file option is given it is only generated when it is not empty. Add testcase run-strip-nothing.sh that tests the various combinations. https://sourceware.org/bugzilla/show_bug.cgi?id=21522 Signed-off-by: Mark Wielaard <[email protected]>
* strip: Make sure old .shstrab is removed when eu-strip recreates it.Mark Wielaard2017-06-144-6/+26
| | | | | | | | | | | | | | | | Although we always recreate the .shstrtab section for the new output file we never explicitly assumed it could be removed. It might not be possible to remove it when the section string table is shared with a symbol table. But if it is removable we should (and recreate it for the new section list). Regression introduced in commit elfutils-0.163-33-gdf7dfab. "Handle merged strtab/shstrtab string tables in strip and unstrip." Add extra testcase to explicitly check for this case. https://sourceware.org/bugzilla/show_bug.cgi?id=21525 Signed-off-by: Mark Wielaard <[email protected]>
* ppc64: Add minimal fallback unwinder.Mark Wielaard2017-06-1210-2/+127
| | | | | | | | | | | | | This adds a minimal fallback unwinder for ppc64[le] in case we cannot find CFI for a particular address. It simply always sets the program counter to the link register, picks the previous stack pointer from the backchain, and the previous link register from the LR save area. This is enough for some simple situations when we don't have CFI and seems to work nicely in the case of perf with libdw powerpc support: https://lkml.org/lkml/2017/5/18/998 Signed-off-by: Mark Wielaard <[email protected]>
* Prepare for 0.169.elfutils-0.169Mark Wielaard2017-05-0513-5079/+5189
| | | | | | | Set version to 0.169. Update copyright year. Update po/*.po files. And add user visible changes to new 0.169 NEWS section. Signed-off-by: Mark Wielaard <[email protected]>
* Make elf section sorting more deterministicUlf Hermann2017-05-032-1/+13
| | | | | | | | | At least one test (dwfl-addr-sect) depends on the order of elf sections with equal addresses. This is not guaranteed by the code. Compare also by end address and section index to tell entries apart. Signed-off-by: Ulf Hermann <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Don't look for kernel version if not running on linuxUlf Hermann2017-05-022-0/+13
| | | | | | | We don't want to use it, even if it exists. Signed-off-by: Ulf Hermann <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Add frame pointer unwinding for aarch64 and relax backtrace testcases.Ulf Hermann2017-05-0211-2/+145
| | | | | | | | | | | | | | | If we don't find any debug information for a given frame, we usually cannot unwind any further. However, the binary in question might have been compiled with frame pointers, in which case we can look up the well known frame pointer locations in the stack snapshot and use them to bridge the frames without debug information. Relax the backtrace core testcases a little by allowing a duplicate sigusr2 frame or a backtrace ending with an invalid register. Both of which can happen if the frame pointer unwinder guesses slightly wrong. Signed-off-by: Ulf Hermann <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Add i386 frame pointer unwinder.Mark Wielaard2017-05-029-3/+135
| | | | | | | Add a simple i386_unwind.c frame pointer unwinder as fallback if DWARF/CFI unwinding fails. Signed-off-by: Mark Wielaard <[email protected]>
* Add frame pointer unwinding as fallback on x86_64Ulf Hermann2017-05-029-1/+133
| | | | | | | | | | | | | | If we don't find any debug information for a given frame, we usually cannot unwind any further. However, the binary in question might have been compiled with frame pointers, in which case we can look up the well known frame pointer locations in the stack snapshot and use them to bridge the frames without debug information. The "unwind" hook is the right place for this as it is so far only used on s390 and called only after trying to unwind with debug information. Signed-off-by: Ulf Hermann <[email protected]>
* tests: Add core backtracegen check and regen ppc32 backtrace testfiles.Mark Wielaard2017-05-025-0/+30
| | | | | | | | | | | | | Add a check to check_core to make sure the backtracegen function is found in the backtrace. This function is in the middle of the backtrace in the main executable and if not found it means the backtrace was incomplete or the frame was skipped (which could happen on a bad frame pointer only unwind). This showed that the ppc32 backtrace test files were missing DWARF CFI for the main executable. Regenerated them to include full CFI. Signed-off-by: Mark Wielaard <[email protected]>
* Revert "Optionally allow unknown symbols in the backtrace tests"Mark Wielaard2017-05-023-31/+17
| | | | | | | | | | | | | | This reverts commit f9971cb422df39adea7e8c7e22689b879e39c626. Allowing no symbol resolving at all makes it too hard to see whether the test actually tests anything. But do keep "address out of range" as allowed error in check_err. This can be interpreted as DWARF not available (if end of callstack marker is missing, which it unfortunately often is missing even if CFI is available.). Signed-off-by: Mark Wielaard <[email protected]>
* Avoid double-including config.hUlf Hermann2017-05-0262-11/+291
| | | | | | | | | | | | | | | | config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through our own private headers. In order to set a clear rule about inclusion of config.h, it is now included in every .c file as first header, but not in any header. This will definitely avoid double-inclusion and satisfy the condition that it has to be included before gnulib headers. It comes at the price of adding some redundancy, but there is no clean way to avoid this. Signed-off-by: Ulf Hermann <[email protected]>
* Use F_GETFD rather than F_GETFL to check validity of file descriptorUlf Hermann2017-05-022-1/+5
| | | | | | | F_GETFD is both cheaper and easier to port, and otherwise has the same effect here. Signed-off-by: Ulf Hermann <[email protected]>
* Make __attribute__ conditional in all installed headersUlf Hermann2017-05-028-33/+54
| | | | | | | | | | __attribute__ is a GNU extension. If we want to link against the libraries using a different compiler, it needs to be disabled. It was already disabled in libdw.h, and this patch extends this to the other headers. We move the defines to libelf.h as that is included in all the others. Signed-off-by: Ulf Hermann <[email protected]>
* Fix nesting of bracesUlf Hermann2017-04-282-1/+5
| | | | | | | | The way it was before it didn't actually test if elf_update failed, but rather did something random. !!(<some number>) is a boolean and boolean true can be represented as anything non-0, including negative numbers. Signed-off-by: Ulf Hermann <[email protected]>
* On elf_update, remember when we mmap()Ulf Hermann2017-04-282-0/+6
| | | | | | Otherwise we skip the munmap() later. This leaks resources. Signed-off-by: Ulf Hermann <[email protected]>
* Avoid signed/unsigned comparisonUlf Hermann2017-04-272-1/+5
| | | | | | | | | | | Some compilers implicitly cast the result of uint_fast16_t * uint_fast16_t to something signed and then complain about the comparison to (unsigned) size_t. Casting phnum to size_t is a good idea anyway as 16bit multiplication can easily overflow and we are not checking for this. Signed-off-by: Ulf Hermann <[email protected]>
* Include strings.h to make ffs availableUlf Hermann2017-04-272-0/+5
| | | | | | We cannot rely on it to be available from any of the other headers. Signed-off-by: Ulf Hermann <[email protected]>
* Protect against integer overflow on shnumUlf Hermann2017-04-274-19/+33
| | | | | | | If shnum is 0, the many "shnum - 1" would result in an overflow. Check it for 0, and only subtract once, rather than on every usage. Signed-off-by: Ulf Hermann <[email protected]>
* Add EXEEXT to gendisUlf Hermann2017-04-262-3/+7
| | | | | | | Otherwise the build will fail on systems that actually need file extension for executables. Signed-off-by: Ulf Hermann <[email protected]>
* Include endian.h when handling BYTE_ORDERUlf Hermann2017-04-262-0/+5
| | | | | | BYTE_ORDER and friends are customarily defined in endian.h. Signed-off-by: Ulf Hermann <[email protected]>
* Add missing entries to .gitignoreUlf Hermann2017-04-262-0/+6
| | | | Signed-off-by: Ulf Hermann <[email protected]>
* Avoid YESSTR and NOSTRUlf Hermann2017-04-265-21/+32
| | | | | | | | | Those are deprecated and apparently some implementations of nl_langinfo return empty strings for them. The tests even tested for those empty strings even though the intention of the code was clearly to output "yes" or "no" there. Signed-off-by: Ulf Hermann <[email protected]>
* Don't use comparison_fn_tUlf Hermann2017-04-262-2/+6
| | | | | | Not all search.h declare it, and it is not very helpful anyway. Signed-off-by: Ulf Hermann <[email protected]>
* Clean up linux-specific system includesUlf Hermann2017-04-2613-14/+35
| | | | | | We only include them where we actually need them and only on linux. Signed-off-by: Ulf Hermann <[email protected]>
* Include sys/types.h before fts.hUlf Hermann2017-04-252-1/+9
| | | | | | | The bad fts not only needs to be included before config.h, but also requires various special types without including sys/types.h. Signed-off-by: Ulf Hermann <[email protected]>
* libelf: Initialize n to zero in elf_getarsym.Mark Wielaard2017-04-192-1/+5
| | | | | | | | | | | | When building with gcc -Os it seems we can inline read_number_entries but if that function fails then n will not be initialized. GCC seems not to realize that in that case n won't be used at all. Explicitly initialize n to zero to prevent a spurious error: 'n' may be used uninitialized in this function [-Werror=maybe-uninitialized] in that case. https://sourceware.org/bugzilla/show_bug.cgi?id=21011 Signed-off-by: Mark Wielaard <[email protected]>
* Add missing peel_type.c test for commit f339da.Mark Wielaard2017-04-071-0/+119
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Support checking ELF files with compressed sections.Mark Wielaard2017-04-056-3/+47
| | | | | | | | | Simply unconditionally uncompress any section to make sure indexes between sections check out. Add some testcases with various compressed sections. https://sourceware.org/bugzilla/show_bug.cgi?id=21332 Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Fix dwarf_peel_type infinite loop.Mark Wielaard2017-04-055-4/+83
| | | | | | | | | | We were calling dwarf_attr_integrate () in the die in the loop instead of on the result. Which would cause an infinite loop when die != result. Add a testcase that explicitly checks this case. https://sourceware.org/bugzilla/show_bug.cgi?id=21330 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Don't check section group without flags word.Mark Wielaard2017-04-042-1/+8
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=21320 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Sanity check the number of phdrs and shdrs available.Mark Wielaard2017-04-042-0/+30
| | | | | | | | | Make sure we can at least read the shnum sections or phnum segments. Limit the number we do check to those we can actually read. https://sourceware.org/bugzilla/show_bug.cgi?id=21312 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Don't trust sh_entsize when checking hash sections.Mark Wielaard2017-04-042-12/+27
| | | | | | | | | | Calculate and use the expected entsize instead of relying on the one given by the ELF file section header. Return early if there isn't enough data in the section to check the full hash table. https://sourceware.org/bugzilla/show_bug.cgi?id=21311 Signed-off-by: Mark Wielaard <[email protected]>