summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* tests: Use valgrind --leak-check=full.mjw/leaksMark Wielaard2015-12-026-1/+50
| | | | | | | | | When --enable-valgrind is given run the testsuite with --leak-check=full treating any memory leak as a failure. Also disable valgrind for those tests that trigger a valgrind bug. https://bugs.kde.org/show_bug.cgi?id=327427 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdw: Don't leak duplicate FDEs.Mark Wielaard2015-12-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 <mjw@redhat.com>
* nm: If the file is ET_REL and we need Dwarf use libdwfl to get it relocated.Mark Wielaard2015-12-022-8/+116
| | | | | | | | | | | If we need Dwarf and the file is ET_REL use the same trick as in readelf to get a relocated Dwarf. Otherwise lots of references in the debug_info will come out as zero. This also explains the "bogus" Dwarf seen that caused the memory leak in the local_root that was fixed previously. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* nm: Don't leak duplicate Dwarf local names.Mark Wielaard2015-12-022-5/+14
| | | | | | | Badly formed DWARF can have duplicate local names. In which case we do want to detect those so we don't leak the memory. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* unstrip: Don't leak new section data.Mark Wielaard2015-12-022-2/+47
| | | | | | | When we copy elided sections some section data is newly allocated. Track those allocations so we can free them when done. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdw: Don't use a FDE if it doesn't actually cover a real code range.Mark Wielaard2015-12-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 <mjw@redhat.com>
* libdwfl: Fix memory leak in link_map.c dwfl_link_map_report.Mark Wielaard2015-12-012-2/+12
| | | | | | | | The phdrs buffer could come from the core file or through the executable. dwfl_link_map_report would leak the buffer if it came from the executable. Track where the buffer came from and free appropriately. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Don't leak core Elf and core file descriptor from argp-std.Mark Wielaard2015-12-017-17/+82
| | | | | | | | Our argp helper would leak the core Elf and core file descriptor when given by the user. Store both in the Dwfl as a new Dwfl_User_Core so they get cleaned up by dwfl_end. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Fix some memory leaks in testcases.Mark Wielaard2015-12-019-4/+36
| | | | | | | Make sure all structures allocated in the testcases are disposed so running them under valgrind will show no memory leaks. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdw: Don't leak fake_loc_cu.Mark Wielaard2015-12-012-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 <mjw@redhat.com>
* elfcmp: Fix leaking Ebl handles.Mark Wielaard2015-12-012-0/+6
| | | | | | | open_file () explicitly gets Ebl handles for both Elf files to compare. Make sure to close those when done. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdw: Make sure Ebl is always freed from cfi frame cache.Mark Wielaard2015-11-274-5/+35
| | | | | | | | | | | | | | 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 <mjw@redhat.com>
* 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 <ldv@altlinux.org>
* 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 <chh@google.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Move nested functions in gzip.c to file scope.Chih-Hung Hsieh2015-11-132-120/+153
| | | | | | | | * libdwfl/gzip.c should now compile with clang. All local variables used by nested functions are passed in an unzip_state structure. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* No nested function in dwarf_getscopevar to file scope.Chih-Hung Hsieh2015-11-132-17/+27
| | | | | Signed-off-by: Chih-Hung Hsieh <chh@google.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Move nested functions in dwfl_module_getsrc_file.c.Chih-Hung Hsieh2015-11-032-15/+28
| | | | | | | | | * Nested functions in this file are moved to file scope to compile with clang. Extra parameters are added to pass local variables. Signed-off-by: Chih-Hung Hsieh <chh@google.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Move nested functions in frame_unwind.c.Chih-Hung Hsieh2015-11-032-73/+95
| | | | | | | | * Nested functions 'pop' and 'push' in libdwfl/frame_unwind.c are moved to file scope. Used local variables are passed in struct eval_stack. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* Move nested functions in dwfl_module.cChih-Hung Hsieh2015-11-032-16/+22
| | | | | | | | * Nested functions in this file are moved to file scope to compile with clang. Extra parameters are added to pass local variables. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* Move nested functions in backends to file scope.Chih-Hung Hsieh2015-11-033-25/+40
| | | | | | | * backends/aarch64_regs.c and backends/ia64_retval.c should now compile with clang. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* Make zlib mandatory.Mark Wielaard2015-10-2610-8/+36
| | | | | | Explicitly link libelf and libdw with -lz. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elf.h: Update from glibc. Add section compression constants and structures.Mark Wielaard2015-10-222-0/+30
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: use the right size when preading in[0].sh_sizeJose E. Marchesi2015-10-222-1/+6
| | | | Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* 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 <chh@google.com>
* Move nested functions in libdwelf.Chih-Hung Hsieh2015-10-222-20/+34
| | | | | | | | * Move nested functions to file scope in libdwelf/dwelf_elf_gnu_build_id.c to compile with clang. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* Move nested functions in libelf.Chih-Hung Hsieh2015-10-223-38/+49
| | | | | | | | * Move nested functions to file scope in libelf/elf_begin.c and elf32_updatefile.c to compile with clang. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* elflint: Don't check shdr or TLS symbol offsets against debuginfo phdrs.Mark Wielaard2015-10-162-2/+10
| | | | | | | | | | | | In debuginfo files the phdrs file offsets match those of the original ELF file. So the section header file offsets and the TLS symbol value offset in debuginfo files cannot be sanity checked against the phdrs file offset. The issue can be triggered with run-strip-strmerge.sh test when configured with --enable-gcov. Which will insert a .tbss section and TLS symbols that trigger the above checks. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Regenerate .po files.elfutils-0.164Mark Wielaard2015-10-166-1186/+1195
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elflint: Reject mergable string sections as relocation target.Mark Wielaard2015-10-162-2/+8
| | | | | | | | Mergable sections can be the target of a relocation, but only if they contain items of the same size. So only reject mergable string sections as target of a relocation section. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* ppc: ppc_check_special_symbol): Also allow _SDA_BASE_ in .data section.Mark Wielaard2015-10-162-3/+13
| | | | | | | | | The Small Data Area Base normally points to .sdata, in which case we check it is at an offset of 0x8000. It might however fall in the .data section, in which case we cannot check the offset. The size always should be zero. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Add AM_LDFLAGS to dwfl_proc_attach_LDFLAGS.Mark Wielaard2015-10-162-1/+5
| | | | | | We want to be sure the libelf.so under test is picked up. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Prepare 0.164 release.Mark Wielaard2015-10-1511-1142/+1290
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Use int64_t for offsets in libelf.hJosh Stone2015-10-142-6/+11
| | | | | | | | Some systems don't have loff_t, like FreeBSD where off_t always supports large files. We need a standardized 64-bit signed type for the public header, without depending on configuration... OK, just use int64_t. Signed-off-by: Josh Stone <jistone@redhat.com>
* Do not rely on ebl_check_special_section when checking debuginfo files.Jose E. Marchesi2015-10-132-5/+19
| | | | | | | | | | | | | | | | | | | | | | | The test run-strip-strmerge.sh is failing in sparc targets. This is because it does an `elflint -d' in a debuginfo file, and this fails with: section [21] '.plt' is both executable and writable elflint uses the ebl_check_special_section hook (implemented only by the alpha and sparc backends) in order to determine whether an executable+writable section must be flagged or not. In both cases the hook will fail analyzing eu-strip debuginfo files (as they should, because debuginfo files are broken ;). This patch just modifies elflint to not use the hook when -d is specified in the command-line. This fixes the test in sparc-* and sparc64-* targets (and presumably in alpha* targets too). Additionaly, the patch checks that the type of WE sections in debuginfo files is NOBITS. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* elflint: Check relro flags are a subset of the load segment.Mark Wielaard2015-10-132-3/+24
| | | | | | | | | If the RELRO segment doesn't fully overlap with the load segment then the load segment might have more flags sets. This happens for example on sparc when the .plt, which is executable, is also part of the load segment that RELRO covers. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Only use posix_fallocate when using mmap. Ignore unsupported errors.Mark Wielaard2015-10-122-13/+28
| | | | | | | | | | | | | | | | Don't use posix_fallocate when not using mmap. It is enough to ftruncate the file to the right size. pwrite will report an error if there is no disk space left. And on file systems that don't support fallocate it might duplicate writes in that case. When using posix_fallocate do ignore most errors. Other libc implementations don't guarantee the call actually works always and even with glibc there might be an unexpected error from the fallback code when the file system doesn't support fallocate. That is pretty nasty since we might get a SIGBUS in that case when writing to the mmapped memory. But the chance of that happening is very small. And will normally never happen with glibc. So only report an error when posix_fallocate reports ENOSPC. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* ldlex: Fix sign-compare warning, suppress -Wstack-usage.Mark Wielaard2015-10-123-1/+7
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* config: Use ARFLAGS 'cr'.Mark Wielaard2015-10-122-0/+8
| | | | | | | | | | | | | | | By default automake uses ARFLAGS cru. 'u' is an optimization that makes sure files are only added to the archive when they are newer than the version already in the .a file. This optimization doesn't work when ar is deterministic by default because then it doesn't record timestamps in the archive. Deterministic ar is the default now on various distributions causing multiple warnings like: ar: `u' modifier ignored since `D' is the default (see `U') To suppress these warnings drop the 'u' flag. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* configure.ac: Add AM_SILENT_RULES([yes])Mark Wielaard2015-10-122-0/+6
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-0943-105/+369
| | | | | | | | | | | | | | | 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 <jistone@redhat.com>
* Use seek+read instead of pread to read from /dev/$$/mem files.Jose E. Marchesi2015-10-092-4/+16
| | | | | | | | pread[64] always returns EINVAL when negative offsets are used. read+seek allows us to read in-memory vdso objects mapped high in the address space. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* Move recursive nested function to file scope.Chih-Hung Hsieh2015-10-092-46/+53
| | | | | | Prepare src/ld.c to compile with clang. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* tests: Rename argument from check to statement in elfshphehdr.c.Mark Wielaard2015-10-092-4/+9
| | | | | | Some older compilers warn about a function and argument name being equal. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* strip: Only sanity check symbols to not discarded sections for debug file.Mark Wielaard2015-10-093-14/+15
| | | | | | | | | | | | | | We can only sanity check the symbols to discarded sections when creating a debug file. Otherwise we won't keep track of debug_data. This can trigger erroneously when there are relocation symbols in the symtab for a .debug section but we are not putting those symbols in a separate .debug file. Adjust run-strip-test.sh to always run in-place strip size check even for ET_REL files. Before this fix the sanity check would trigger for some ET_REL files because they contained such relocation symbols to .debug sections (but debug_data would be NULL because -f wasn't used). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Allocate exact amount of bytes for phdrs and shdrs.Mark Wielaard2015-10-086-53/+61
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Do without union of variable length arrays.Chih-Hung Hsieh2015-10-0710-161/+194
| | | | | | | | | | | | | | Prepare to compile with clang. A union like { T32 a32[n]; T64 a64[n]; } u; is expanded to size_t nbytes = n * MAX(sizeof(T32), sizeof(T64)); void *data = malloc(nbytes); T32 (*a32)[n] = data; T64 (*a64)[n] = data; Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* Improve AM_SILENT_RULES coverageJosh Stone2015-10-0616-21/+57
| | | | | | | | | | | 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 <jistone@redhat.com>
* sparc: support for the check_object_attribute ebl hook.Jose E. Marchesi2015-10-064-1/+83
| | | | | | | This makes elfutils based utilities to be aware of the ELF attribute tags defined in sparc targets. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* 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 <jose.marchesi@oracle.com>
* Use -fPIC instead of -fpic when generating PIC code.Jose E. Marchesi2015-10-0612-7/+37
| | | | | | | 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 <jose.marchesi@oracle.com>