summaryrefslogtreecommitdiffstats
path: root/libdw
Commit message (Collapse)AuthorAgeFilesLines
* libdw: Add DW_MACRO constants and DW_MACRO_GNU compatibility defines.upstream/mjw/DWARF5Mark Wielaard2016-10-283-22/+50
| | | | | | | | | | 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 immutable, packed and shared types in dwarf_peel_type.Mark Wielaard2016-10-282-12/+23
| | | | | | | | | 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 peel. Explicitly mention pointer and reference types, which aren't peeled. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add new DWARF5 tag constants.Mark Wielaard2016-10-282-2/+13
| | | | | | | | | | 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 dwarf_default_lower_bound.Mark Wielaard2016-10-288-52/+122
| | | | | | | | | | 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 Wielaard2016-10-283-1/+31
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdw: DWARF5 Add DW_CC_pass_by_reference and DW_CC_pass_by_reference.Mark Wielaard2016-10-282-1/+10
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Correct spelling of DW_LANG_PLI in dwarf.h.Mark Wielaard2016-10-273-5/+13
| | | | | | | | | The name used in the standard and other DWARF implementations for Programming Language One, PL/I, is DW_LANG_PLI (not DW_LANG_PL1). Fix usage in dwarf_aggregate_size. Signed-off-by: Mark Wielaard <[email protected]>
* lib: Provide MAX and MIN in system.hAkihiko Odaki2016-10-123-2/+7
| | | | | | | | | | This change also creates a new header file libeu.h to provide the prototypes for the function of libeu. That hides the definition of function crc32, which can conflict with zlib, from libelf. It also prevents mistakes to refer those functions from a component which doesn't link with libeu, such as libelf. Signed-off-by: Akihiko Odaki <[email protected]>
* dwelf: Add string table functions from ebl.Mark Wielaard2016-08-032-0/+17
| | | | | | | | | | | | | | | | Move the strtab functions from libebl to libdw. Programs often want to create ELF/DWARF string tables. We don't want (static) linking against ebl since those are internal functions that might change. This introduces dwelf_strtab_init, dwelf_strtab_add, dwelf_strtab_add_len, dwelf_strtab_finalize, dwelf_strent_off, dwelf_strent_str and dwelf_strtab_free. Documentation for each has been added to libdwelf.h. The add fucntion got a variant that takes the length explicitly and finalize was changed to return NULL on out of memory instead of aborting. All code and tests now uses the new functions. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Fix bad free on invalid data in dwarf_getsrclines.c.Mark Wielaard2016-02-222-2/+9
| | | | | | | | If the last dir name wasn't zero terminated we goto invalid_data and might free the wrong data because we believe ndirlist is valid. Don't update ndirlist until we are sure we will use all dirs. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Use elf_compress[_gnu] to uncompress debug section data.Mark Wielaard2016-01-064-137/+63
| | | | | | | | libdw used its own code for decompressing GNU style .zdebug sections. Using elf_compress and elf_compress_gnu instead makes it possible to transparently use either GNU style or ELF style compressed data. Signed-off-by: Mark Wielaard <[email protected]>
* libdwelf: Add dwelf_scn_gnu_compressed_size.Mark Wielaard2016-01-062-0/+9
| | | | | | Helper function to get the size of a GNU compressed zdebug section. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Don't leak duplicate FDEs.Mark Wielaard2016-01-022-1/+14
| | | | | | | | Although it isn't supposed to happen there could be FDEs that cover the same address range. Don't leak such FDEs and use an existing FDE for consistency. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Don't use a FDE if it doesn't actually cover a real code range.Mark Wielaard2016-01-022-0/+12
| | | | | | | | | | If the FDE end <= start then it doesn't actually cover a valid code range. Don't use and cache such FDEs (it will cause memory leaks if there is another FDE that has the same start address and a valid code range). Such FDEs have been seen in the backtrace.ppc.exec testfile. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Don't leak fake_loc_cu.Mark Wielaard2016-01-022-1/+9
| | | | | | | | The fake_loc_cu is used when synthesizing attributes for Dwarf_Ops that came from a location list entry in dwarf_getlocation_attr. Make sure we remove the loc cache stored in it when disposing of the fake_loc_cu. Signed-off-by: Mark Wielaard <[email protected]>
* Move nested functions in dwarf_entry_breakpoints.c to file scope.Chih-Hung Hsieh2016-01-022-51/+64
| | | | | | No nested functions to compile with clang/llvm. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Move nested functions in libdw_visit_scopes.c to file scope.Chih-Hung Hsieh2016-01-022-71/+95
| | | | | | | * No nested functions to compile with clang/llvm. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Make sure Ebl is always freed from cfi frame cache.Mark Wielaard2015-11-272-1/+10
| | | | | | | | | | | | | | libdwfl sets the Dwfl_Module Ebl for the eh_cfi and dwarf_cfi cache to save a bit of memory. It also calls ebl_closebackend on the ebl to free it. The Dwarf_CFI never frees the Ebl in the cache, even when it opened one itself. This means that if only libdw calls are used to access the Dwarf_CFI the Ebl might be leaked. Always destroy the Dwarf_CFI cache Ebl in __libdw_destroy_frame_cache. And in __libdwfl_module_free clear the Dwarf_CFI Ebl if it is the Dwfl_Module Ebl before calling dwarf_cfi_end and dwarf_end. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: initialize state early in read_srclinesDmitry V. Levin2015-11-162-19/+24
| | | | | | | | Starting with commit f8443bd09f8a8d3d84a63e5ce206a218e57dff7a, we might jump to "out" on error before initialization of "state". Initialize "state" early to fix this issue. Signed-off-by: Dmitry V. Levin <[email protected]>
* No nested functions in dwarf_getsrclines.Chih-Hung Hsieh2015-11-132-105/+144
| | | | | | | Move nested functions in libdw/dwarf_getsrclines.c to file scope. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* No nested function in dwarf_getscopevar to file scope.Chih-Hung Hsieh2015-11-132-17/+27
| | | | | Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Make zlib mandatory.Mark Wielaard2015-10-262-1/+5
| | | | | | Explicitly link libelf and libdw with -lz. Signed-off-by: Mark Wielaard <[email protected]>
* Move nested functions in libdw/cfi.c to file scope.Chih-Hung Hsieh2015-10-222-42/+50
| | | | | | * No nested functions to compile with clang/llvm. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-092-2/+7
| | | | | | | | | | | | | | | AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS in config.h if needed for LFS, and this automatically maps things like open to open64. But quite a few places used explicit 64-bit names, which won't work on platforms like FreeBSD where off_t is always 64-bit and there are no foo64 names. It's better to just trust that AC_SYS_LARGEFILE is doing it correctly. But we can verify this too, as some file could easily forget to include config.h. The new tests/run-lfs-symbols.sh checks all build targets against lfs-symbols (taken from lintian) to make sure everything was implicitly mapped to 64-bit variants when _FILE_OFFSET_BITS is set. Signed-off-by: Josh Stone <[email protected]>
* Improve AM_SILENT_RULES coverageJosh Stone2015-10-062-2/+6
| | | | | | | | | | | Note, elfutils does not explicitly enable AM_SILENT_RULES. It's only available starting from automake 1.11, but starting from automake 1.13 silent rules are always generated, defaulting to verbose. $(AM_V_foo) additions should be no-ops on systems that don't support silent rules. To be silent, use "./configure --enable-silent-rules" or "make V=0". Signed-off-by: Josh Stone <[email protected]>
* Use -fPIC instead of -fpic when generating PIC code.Jose E. Marchesi2015-10-062-1/+6
| | | | | | | This avoids relocation overflows in sparc/sparc64 targets while linking, where the reachable data using -fpic is only 4kb. Signed-off-by: Jose E. Marchesi <[email protected]>
* Properly mark all internal function definitions.Mark Wielaard2015-09-235-0/+11
| | | | | | | | | | | | | | | | | Since we banned old style function definitions GCC is able to diagnose function definitions that don't match the function declaration: elf32_getehdr.c:78: error: conflicting types for ‘__elf64_getehdr_wrlock’ libelfP.h:498: note: previous declaration of ‘__elf64_getehdr_wrlock’ This happens on i386 because there internal functions are marked with: # define internal_function __attribute__ ((regparm (3), stdcall)) Make sure all internal function declarations and definitions are marked with internal_function. Signed-off-by: Mark Wielaard <[email protected]>
* Remove old-style function definitions.Mark Wielaard2015-09-2367-274/+114
| | | | | | | We already require -std=gnu99 and old-style function definitions might hide some compiler warnings. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Don't reassign result pointer in dwarf_peel_type.Mark Wielaard2015-09-152-3/+6
| | | | | | | | | | | | | | GCC6 will warn about the reassignement of the nonnull result pointer. The reassignment is indeed a little questionable. The compiler cannot see that the pointer will not actually be reassigned since the function will just return the same pointer value except when the dwarf_formref_die function fails. In which case we don't use the result anymore. So the compiler has to pessimistically assume the pointer will need to be reloaded in the loop every time. Help the compiler generate slightly better code by just checking whether the function fails directly instead of reusing the pointer value for this. Signed-off-by: Mark Wielaard <[email protected]>
* Remove redundant NULL tests.Chih-Hung Hsieh2015-09-144-13/+15
| | | | | | | | GCC6 and Clang give warnings on redundant NULL tests of parameters that are declared with __nonnull_attribute__. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add const declaration to getlocations_addr locs.Chih-Hung Hsieh2015-09-072-11/+11
| | | | | | | | And change K&R C function definition to ansi, which prevented GCC from seeing that callers passed in const arguments. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Replace some K&R function definitions with ansi-C definitions.Chih-Hung Hsieh2015-09-073-14/+14
| | | | | Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add DW_LANG_Haskell.Mark Wielaard2015-08-252-0/+5
| | | | | | | | | See http://www.dwarfstd.org/ShowIssue.php?issue=120218.1 GHC emits this language code (0x18). Also updated https://fedorahosted.org/elfutils/wiki/DwarfExtensions Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Make sure the default page size is big enough to hold a Dwarf.Mark Wielaard2015-06-192-0/+6
| | | | | | | Just assert early that the page size isn't unreasonable small instead of corrupting memory later. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Not leak memory on error in dwarf_getpubnames.Mark Wielaard2015-06-192-0/+5
| | | | | | | | When there is an error with the first entry we might already have allocated the memory but not yet set cnt to 1. Just always free the memory on error. free (NULL) is a nop anyway and doesn't matter on a failure path. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Detect dwarf_formudata errors in dwarf_getmacros.Mark Wielaard2015-06-192-2/+10
| | | | | | dwarf_formudata can return an error for bad DWARF. Don't ignore it. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Initialize dirarray early in read_srclines.Mark Wielaard2015-06-102-10/+14
| | | | | | | We might jump to "out" early on error. Help gcc see that isn't an issue by initializing dirarray to dirstack early. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Initialize filelist early in read_srclines.Mark Wielaard2015-06-082-11/+16
| | | | | | | We might jump to "out" early on error. Then filelist might not be set yet and we might try to free garbage. Set it to the null_file early. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Fix overflow in read_encoded_value for the DW_EH_PE_indirect case.Mark Wielaard2015-06-012-3/+9
| | | | | | | If we are going to dereference a pointer there should be at least enough data to hold a pointer. Found by afl-fuzz. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Limit stack usage of temporary dir, file and line lists.Mark Wielaard2015-05-272-60/+98
| | | | | | | | | | | | | | | | Limit stack usage of lines with MAX_STACK_LINES, files with MAX_STACK_LINES and dirs with MAX_STACK_DIRS. Calculate number of dirs needed first, then create dirarray directly, without needing the next field. Free not stack allocated lines and files at the end. Use preallocated stack arrays for all instead of calling alloca to help compiler see actual stack usage. The current stack allocation limits are 4096 lines, 1024 files in 256 dirs per CU. For GCC 4.8 libstdc++.so has on average 512 lines per CU. With these settings read_srclines uses max 228K of stack on x86_64. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Fix possibly unbounded stack usage in __libdw_intern_expression.Mark Wielaard2015-05-272-15/+36
| | | | | | | Create a stack allocated array to hold locs. Allocate locs bigger than the array with malloc and free them when done. Signed-off-by: Mark Wielaard <[email protected]>
* dwarf_begin_elf: new error for compression failureJonathan Lebon2015-05-134-61/+97
| | | | | | | | | | | In order to provide better feedback to users, a distinction is made between finding no dwarf info (E_NO_DWARF) and finding dwarf info but which is compressed and failed to decompress (E_COMPRESSED_ERROR). This can occur for example if elfutils was built without zlib support, or if the compressed section is invalid. Signed-off-by: Jonathan Lebon <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* dwarf_begin_elf: decouple section searching from readingJonathan Lebon2015-05-132-31/+36
| | | | | | | | | | | To help legibility, we separate the section name matching from the actual section reading. This also allows us to remove duplicate code in cases of sections appearing twice or empty section data. There are no changes in functionality. The indentation will be fixed in the next commit, in the interest of keeping this commit easier to read. Signed-off-by: Jonathan Lebon <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Detect line number overflow in dwarf_getsrclines on 32bit.Mark Wielaard2015-05-122-1/+7
| | | | | | | | | | We do check whether the values we store for the line fit our data representation in add_new_line, but on 32bit systems we would fail to notice line overflowing. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c32 Signed-off-by: Mark Wielaard <[email protected]>
* libdw: dwarf_getaranges check there is enough data before reading.Mark Wielaard2015-05-122-2/+19
| | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c30 Signed-off-by: Mark Wielaard <[email protected]>
* Link against standalone argp libraryAnthony G. Basile2015-05-042-1/+6
| | | | | | | | | | | | | | argp is not part of POSIX standards and not provided by uClibc or some other standard C libraries. However, it is possible to link against a breakout argp library. One is provided at http://www.lysator.liu.se/~nisse/misc/ This patch tests if libc provides argp otherwise it adds the linker flag -largp where needed in the build system. Signed-off-by: Anthony G. Basile <[email protected]> Signed-off-by: Max Filippov <[email protected]>
* libdw: Undefined behavior in get_sleb128_step.Mark Wielaard2015-04-282-4/+27
| | | | | | | | | | gcc -fsanitize=undefined pointed out that for too big sleb128 values we could shift into the sign bit. So for sleb128 values that have to fit in a (signed) int64_t variable reduce the max number of steps by one. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c29 Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Don't overflow stack with user defined macro attributes array.Mark Wielaard2015-04-222-4/+31
| | | | | | | | | | | | In theory user defined debug macros can have an arbitrary number of arguments. Don't allocate them all on stack. If there are more than 8 (arbitrary number, but no sane macro should have more arguments), then dynamically allocate and free the attributes. Found by gcc -fsanitize=undefined. Which pointed out the nforms could be zero, creating an empty vla (which could cause undefined behavior). Signed-off-by: Mark Wielaard <[email protected]>
* Do not reject type units in dwarf_getsrcfiles and dwarf_getsrclinesPetr Machata2015-04-035-9/+32
| | | | Signed-off-by: Petr Machata <[email protected]>
* Publish known-dwarf.hPetr Machata2015-03-312-2/+7
| | | | | | | | | | | | | - Make the macro names properly scoped (DWARF_ALL_KNOWN_* and DWARF_ONE_KNOWN_*). - Simplify the calling convention: don't keep track of the comment associated with the enumerator, always use the non-_DESC DWARF_ONE_KNOWN_* callback. - Install known-dwarf.h alongside libdw.h and others. Signed-off-by: Petr Machata <[email protected]>