summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* readelf: Print CU, base address and unresolved .debug_loc entries.Mark Wielaard2017-11-296-35/+112
| | | | | | | | | Also adjust the formatting for the resolved addresses to print them on separate lines so they nicely line up even when the addresses are resolved to symbol+offset names. And print the operands starting on a new line. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Print CU, base address and unresolved .debug_range entries.Mark Wielaard2017-11-295-24/+89
| | | | | | | | Also adjust the formatting for the resolved addresses to print them on separate lines so they nicely line up even when the addresses are resolved to symbol+offset names. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Print actual file for decl_file and call_file attributes.Mark Wielaard2017-11-295-21/+53
| | | | | | | | | | | When we see a DW_AT_decl_file or DW_AT_call_file attribute print the actual file name. The current interface gives us a full (absolute) patch, but we only want to show the file name for now to not clutter the output too much. This helps a lot when trying to determine where something was declared if you are just looking at the DIE tree. Otherwise you'll have to cross match the number by hand with the corresponding line table entry. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Print abbrev code for DIE with --debug-dump=info.Mark Wielaard2017-11-295-44/+56
| | | | | | | If there is anything wrong with a DIE it is useful to know what the abbrev code was so you can lookup the abbrev description. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Adjust print_ops formatting.Mark Wielaard2017-11-297-78/+90
| | | | | | | Use only 2 spaces for index (there are never 10000, the most seen in the wild is 64). Adjust re-indenting after GNU_entry_value. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't dereference possibly unaligned auxv entry pointer from core.Mark Wielaard2017-11-242-19/+31
| | | | | | | | | | | | | The notes in a core file that contain the auxv entries might not be naturally aligned. The code already tried to account for that, but the GCC 8 undefined behaviour sanitizer found we were till dereferencing the actual auxv entry pointer directly. Fix this by calculating all pointers by hand and not use an array of auxv entries trick. This makes make distcheck (which enables sanitize-undefined by default) pass again using GCC8. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Print attribute name and form in error message.Mark Wielaard2017-11-242-3/+13
| | | | | | | | | | | | | Now an error getting the attribute value will not only print the DIE offset and the reason, but also the attribute name and form. e.g. DIE [b] cannot get attribute 'ranges' (sec_offset) value: .debug_ranges section missing Also we don't abort, but try to print the other attributes of the DIE anyway. It might just be one attribute whose value cannot be resolved. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Print DIE offset in attribute reading error messages.Mark Wielaard2017-11-162-6/+14
| | | | | | | | | | When processing large files it is useful to know the DIE offset if printing of attributes fails (especially when redirecting the output). With this change the error message looks like: eu-readelf: DIE [2aeb8ef1] cannot get attribute value: invalid DWARF Signed-off-by: Mark Wielaard <[email protected]>
* tests: Fix cfi_debug => cfi_debug_bias typo in varlocs assert.Mark Wielaard2017-11-162-1/+5
| | | | | | | | | | We want to check whether the bias is zero, not whether we have dwarf debug_frame cfi. This triggered on a ppc64/ppc64le self-check since it has both debug_frame and eh_frame cfi (other arches often only have eh_frame). Signed-off-by: Mark Wielaard <[email protected]>
* tests: Add varlocs-self and exprlocs-self tests.Mark Wielaard2017-11-155-16/+110
| | | | | | | | | Make sure the testcases (library functions they use) don't crash, triggers self-check/asserts or leaks memory under valgrind. This also helps making sure newer DWARF constructs are handled (when building with -gdwarf-5). Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Handle DW_OP_GNU_variable_value.Mark Wielaard2017-11-109-7/+431
| | | | | | | | | | | | | Handle DW_OP_GNU_variable_value in dwarf_getlocation[_attr,_die]. DW_OP_GNU_variable_value takes one argument a DIE reference that describes a value given by a location of const_value attribute. To test handling of the new operand the varlocs test is adapted to print out all DIEs and attributes with expressions or location lists (the original varlocs test only prints out variables and arguments of function DIEs). Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Update acceptable forms and attributes for dwarf_getlocation.Mark Wielaard2017-11-102-1/+30
| | | | | | | | | | | | | | | dwarf_getlocation has to know which attributes can contain a DWARF expression or location list because the form alone might be ambiguous. Since DWARF4 there is DW_FORM_exprloc so always accept that. But for older DWARF or location lists we cannot just check for DW_FORM_sec_offset since that could be a reference to diffent kinds of sections (based on attribute). Update the attribute list based on the latest DWARF5 encodings table. Note that DW_AT_call_origin wasn't added because that seems to be a typo in the DWARF5 spec. http://dwarfstd.org/ShowIssue.php?issue=171103.1 Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Handle DW_OP_GNU_variable_value.Mark Wielaard2017-11-104-2/+13
| | | | | | | Also format both DW_OP_call_ref and DW_OP_GNU_variable_value argument as a normal DIE reference. Signed-off-by: Mark Wielaard <[email protected]>
* config: files under /usr/lib/sysctl.d (_sysctldir) aren't %config.Mark Wielaard2017-11-102-2/+7
| | | | | | | Admin can place the real config file under /etc/sysctl.d as override. https://bugzilla.redhat.com/show_bug.cgi?id=1506660 Signed-off-by: Mark Wielaard <[email protected]>
* backends: Ignore GCC8 -Wpacked-not-aligned for m68k_corenote.c.Mark Wielaard2017-10-264-0/+16
| | | | | | | | | The GCC8 -Wpacked-not-aligned warns if a structure field with explicit padding in a packed structure will be misaligned. m68k prstatus core notes are described by a packed structure which has such aligned structure fields. Signed-off-by: Mark Wielaard <[email protected]>
* lib: Remove md5 and sha1 implementations.Mark Wielaard2017-10-2011-1121/+23
| | | | | | Only the testcase md5-sha1-test used them. So also remove that testcase. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: When the kernel is found, but not the modules warn, don't fail.Mark Wielaard2017-10-202-1/+6
| | | | | | | | | For -k the argp parser could fail to find the modules after the kernel itself was already found. Calling failure at this point closes the Dwfl, which isn't necessary. Just warn about the missing modules and continue with the kernel only Dwfl. Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Don't error out when sanity checking e_shoff if scncnt is zero.Mark Wielaard2017-10-132-2/+7
| | | | | | | | We won't use the e_shoff value in that case because we will set elf->state.elf[64|32].scns.cnt to zero to indicate not to read any section header data from the file. Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Add ELF_E_INVALID_ELF error value.Mark Wielaard2017-10-137-23/+83
| | | | | | | | Add ELF_E_INVALID_ELF which is set when the ELF file data is bad. This is different from ELF_E_INVALID_FILE which is set when the file could not be read. Signed-off-by: Mark Wielaard <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* README: Add basic build instructions.Mark Wielaard2017-09-192-0/+13
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* libelf: Sync elf.h from glibc.Mark Wielaard2017-08-152-3/+97
| | | | | | Add new powerpc note descriptors. Signed-off-by: Mark Wielaard <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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]>