summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Explicitly qualify specializations of elfutils::to_stringdwarflintDavid Malcolm2018-02-265-8/+21
| | | | | | | | | | | | | I attempted to build the "dwarflint" branch with gcc 7.3.1 , but ran into various problems of the form: c++/known.cc:220:1: error: explicit specialization of ‘template<class type> std::__cxx11::string elfutils::to_string(const type&)’ outside its namespace must use a nested-name-specifier [-fpermissive] to_string<dwarf::dwarf_enum> (const dwarf::dwarf_enum &value) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ The fix appears to be trivial. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
* Add support for dwarflint testingDjordje Todorovic2017-10-0619-71/+143
| | | | | | | | | | | | * dwarflint/tests: Update all scripts and makefiles to work with current test environment. * dwarflint/Makefile.am: Add support for dwarflint testing. * tests/test-subr.sh: Update to be used in dwarflint/tests. * tests/test-wrapper.sh: Likewise. * tests/run-dwarflint-self.sh: Return back into tests/. Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* dwarflint: Remember the referring CU when read src linesDjordje Todorovic2017-10-065-10/+21
| | | | Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* libdw: Proper handling of DW_AT_high_pcDjordje Todorovic2017-10-061-1/+3
| | | | | | | Since DWARF4 DW_AT_high_pc may be a constant. Which should be added to the DW_AT_low_pc value to get the address. Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* Add support for DW_OP_GNU_parameter_ref to dwarf-opcodes.hMark Wielaard2017-10-061-0/+1
| | | | | Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* dwarflint: Avoid corrupted accessDjordje Todorovic2017-10-061-1/+2
| | | | Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* dwarflint: Report summary for sub-category of variablesDjordje Todorovic2017-10-061-3/+48
| | | | | | | | | Add new option --sub-category of locstats that reports summary for either for local variables or formal parameters. * dwarflint/locstats.cc: Handle the option. Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* C++ build fixes.Mark Wielaard2017-10-065-4/+1038
| | | | | | | | | | Add AX_CXX_COMPILE_STDCXX_11 and AX_CXX_COMPILE_STDCXX from the autoconf-archive. Use it in configure.ac to make sure we get a C++11 capable compiler. Add various c++ sources to libdw/Makefile.am. Change INCLUDES in dwarflint/Makefile.am to AM_CPPFLAGS to support newer automake. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Update code to work with current version of elfutilsDjordje Todorovic2017-10-064-64/+87
| | | | Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* dwarflint: Update code to work with current version of elfutilsDjordje Todorovic2017-10-067-9/+12
| | | | Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* Add files needed by c++ module from dwarf branch.Djordje Todorovic2017-10-064-1/+1092
| | | | | | | | | * src/dwarf-opcodes.h: Return back the file. * src/dwarfstrings.c: Likewise. * src/dwarfstrings.h: Likewise. Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* Add support for building C++Djordje Todorovic2017-10-062-2/+4
| | | | | | | * configure.ac: Add support for C++ build. * Makefile.am: Add dwarflint into SUBDIRS. Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* Add dwarflint/ from origin/dwarf branchDjordje Todorovic2017-10-06159-0/+18270
| | | | Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* Add libdw/c++/ from origin/dwarf branchDjordje Todorovic2017-10-0616-0/+12092
| | | | Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
* libdw: Add ELFUTILS_PRIVATE_TMP versionDjordje Todorovic2017-10-061-0/+6
| | | | | | | This hack is needed for libdw/c++/values.cc. Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Define LIBDW_CIE_ID and use it in dwarf_cfi_cie_p.Mark Wielaard2017-10-052-1/+7
| | | | | | | | dwarf_cfi_cie_p used DW_CIE_ID_64 from dwarf.h which meant you had to include dwarf.h just to use the dwarf_cfi_cie_p macros. Just define the constant as LIBDW_CIE_ID in libdw.h to keep it independent. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Make sure packed structs follow the gcc memory layoutUlf Hermann2017-09-2012-4/+51
| | | | | | | | | | | | | | gcc defaults to using struct layouts that follow the native conventions, even if __attribute__((packed)) is given. In order to get the layout we expect, we need to tell gcc to always use the gcc struct layout, at least for packed structs. To do this, we can use the gcc_struct attribute. This is important, not only for porting to windows, but also potentially for other platforms, as the bugs resulting from struct layout differences are rather subtle and hard to find. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* ar: Check whether ar header values fit.Mark Wielaard2017-09-205-22/+103
| | | | | | | | | | | | | | | | | When compiling with -O3 gcc finds an interesting error: src/ar.c: In function ‘do_oper_insert’: src/ar.c:1077:56: error: ‘%-*ld’ directive output may be truncated writing between 6 and 10 bytes into a region of size 7 [-Werror=format-truncation=] snprintf (tmpbuf, sizeof (tmpbuf), ofmt ? "%-*lo" : "%-*ld", bufsize, val); ^~~~~ The problem is that the ar header values have to fit in a limited (not zero terminated) string. We should check the snprintf return value to see if the values are representable. Also make ar valgrind and ubsan clean and add a minimal sanity test. Reported-by: Matthias Klose <doko@ubuntu.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* README: Add basic build instructions.Mark Wielaard2017-09-192-0/+13
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* Internationalized messages should not contain the '\v' escape sequence.Mark Wielaard2017-09-1514-1910/+1942
| | | | | | | Replace horizontal tab '\v' with double line feed '\n\n' in doc strings. Regenerate .po files. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Cast pid_t to long long when printingUlf Hermann2017-08-182-14/+22
| | | | | | | | | We don't know sizeof(pid_t) as it's not specified in any standard. In order to still print it, we cast to long long, the largest integer type we can easily print. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io> Signed-off-by: Mark Wielaard <mark@klomp.org>
* On non-linux systems, don't use native signal numbersUlf Hermann2017-08-182-5/+23
| | | | | | | | We assume core files from linux systems, so we should use the linux version of the signals when reading them. Other OS might have different signal numbers. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Detect if symbol versioning is supportedUlf Hermann2017-08-182-0/+19
| | | | | | | If not, throw an error unless symbol versioning was explicitly disabled. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Drop -rdynamic from deleted-lib.so link stepUlf Hermann2017-08-182-1/+5
| | | | | | | | | | | | -rdynamic is meant for ELF objects that need to export internal symbols to libraries they link to, but deleted-lib.so does not link to anything else and doesn't have any internal symbols. Note that the "deleted" test program does link to deleted-lib.so, but deleted-lib.so being a shared object, will automatically export the (non-hidden) "libfunc" symbol anyway. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Check if gcc complains about __attribute__ (visibility(..))Ulf Hermann2017-08-189-3/+42
| | | | | | | | | | | | | | | If so, define attribute_hidden to be empty. Also, use attribute_hidden in all places where we hide symbols. If this attribute is missing, it simply means that we cannot hide private symbols in the binary using attributes. This disables some optimizations and may increase the risk of symbol name clashes with other libraries, but is not fatal. However, we still employ linker version scripts to explicitly define the exported symbols. This serves much of the same purpose. Also, as all our symbols are prefixed with the library name, and "__" for private ones, the chance of clashes is low anyway. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Check for -z,defs, -z,relro, -fPIC, -fPIE before using themUlf Hermann2017-08-1820-19/+112
| | | | | | | | | | | | | | | | | | | | | | | | Those flags are not available on all platforms, and omitting them when not available will not cause any harm. In particular: -z,defs disallows undefined symbols in object files. This option is unsupported if the target binary format enforces the same condition already. Furthermore it is only a compile time sanity check. When it is omitted, the same binary is produced. -z,relro instructs the loader to mark sections read-only after loading the library, where possible. This is a hardening mechanism. If it is unavailable, the functionality of the code is not affected in any way. -fPIC instructs the compiler to produce position independent code. While this is preferable to relocatable code, relocatable code also works and may even be faster. Relocatable code might just be loaded into memory multiple times for different processes. -fPIE is the same thing as -fPIC for executables rather than shared libraries. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* libelf: Sync elf.h from glibc.Mark Wielaard2017-08-152-3/+97
| | | | | | Add new powerpc note descriptors. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: robustify run-strip-nothing.sh against unstripped libc_nonshared.aDmitry V. Levin2017-08-092-1/+5
| | | | | | | | | When glibc's libc_nonshared.a contains objects with debug info, this debug info is leaked into every output file produced by gcc. Change run-strip-nothing.sh to use "gcc -s" instead of plain "gcc" for producing objects without debug info. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Prepare for 0.170.elfutils-0.170Mark Wielaard2017-08-0211-1148/+1306
| | | | | | | Set version to 0.170. Update po/*.po files. Add some more user visible changes to NEWS. Signed-off-by: Mark Wielaard <mark@klomp.org>
* backends: sparc GOTDATA_OP[_HIX22|LOX10] can be used in ET_REL files.Mark Wielaard2017-08-022-3/+8
| | | | | | Tested on new GNU Compile Farm server gcc202. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Add DW_MACRO constants and DW_MACRO_GNU compatibility defines.Mark Wielaard2017-08-029-44/+152
| | | | | | | | | | Accept version 5 .debug_macro format, which is identical to the GNU version 4 format. No real support yet for the new supplementary object file (sup) and indirect string references (strx). GCC doesn't generate them yet. readelf does recognize them, but doesn't try to decode them. dwarf_getmacros currently rejects the new formats. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Handle DWARF5 immutable, packed and shared in dwarf_peel_type.Mark Wielaard2017-08-025-12/+34
| | | | | | | | | | Also update the documentation to explain that any type alias or modifier that doesn't modify, change the structural layout or the way to access the underlying type is peeled. Explicitly mention pointer and reference types as examples of modifiers that don't obey that rule and so aren't peeled. Signed-off-by: Mark Wielaard <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <yunlian@google.com>
* libdw: Add dwarf_line_file.Mark Wielaard2017-07-267-1/+97
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* 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 <gromero@linux.vnet.ibm.com>
* 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 <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <ulf.hermann@qt.io>
* 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 <ulf.hermann@qt.io>
* 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 <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <schwab@linux-m68k.org>
* 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 <mark@klomp.org>