summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* unstrip: Update sh_info when SH_INFO_LINK_P, not just when SHF_INFO_LINK set.upstream/mjw/elfstrmergeMark Wielaard2015-10-022-1/+6
| | | | | | | | | | | SHF_INFO_LINK is not consistently set when sh_info is actually a section index reference. Use SH_INFO_LINK_P to check whether to update the sh_info value. SH_INFO_LINK_P also checks the section type to know whether or not sh_info is meant to as section index. Found by run-strip-strmerge.sh test with older binutils. Signed-off-by: Mark Wielaard <[email protected]>
* Handle merged strtab/shstrtab string tables in strip and unstrip.Mark Wielaard2015-10-027-10/+813
| | | | | | | | | | | | | | | | | | | | | ELF files can share the section header string table (e_shstrndx) with the symtab .strtab section. That might in some cases save a bit of space since symbols and sections might share some (sub)strings. To handle that eu-strip just needs to not unconditionally remove the .shstrtab section (it will be properly marked as used/unused as needed). eu-unstrip needs to make sure the section names are added to the strtab if it decides to rewrite that section. Also makes sure that eu-strip won't move around a SHT_NOBITS section that has SHF_ALLOC set. Although it is allowed to move such sections around, there is no benefit. And some tools might expect no allocated section to move around, not even a nobits section. It also makes it harder to do "roundtripping" sanity checks that make sure splitting a file with eu-strip and then reconstructed with eu-unstrip produce the same ELF file (as is done in the new run-strip-strmerge.sh). Introduces a somewhat large test generator elfstrmerge.c that will hopefully turn into a more generic string table merger program. Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Always update e_version and e_shentsize in elf_update.Mark Wielaard2015-09-295-7/+207
| | | | | | | | | | | When e_version is EV_NONE we should set it to EV_CURRENT like we do for the EI_VERSION and like we set EI_DATA to the correct byte order when set to ELFDATANONE. Likewise we should always set e_shentsize like we do for e_phentsize, not just when ELF_F_LAYOUT isn't set. Add a new elfshphehdr testcase to check the above. Signed-off-by: Mark Wielaard <[email protected]>
* Properly mark all internal function definitions.Mark Wielaard2015-09-2317-0/+44
| | | | | | | | | | | | | | | | | 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-23236-1050/+481
| | | | | | | We already require -std=gnu99 and old-style function definitions might hide some compiler warnings. Signed-off-by: Mark Wielaard <[email protected]>
* Update dl-hash.h from glibc.Mark Wielaard2015-09-232-41/+38
| | | | | | | | | | Our dl-hash.h implementation originally came from, or was written at the same time as, the glibc implementation. At some point (around 9 years ago) they diverged and the elfutils version got an updated copyright header. The glibc version saw various updates/optimizations. Just treat the file like we do for elf.h and copy it whenever the glibc version is updated. 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-1412-20/+41
| | | | | | | | 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]>
* libdwfl: Make dwfl_linux_proc_attach work even without any Dwfl_Modules.Mark Wielaard2015-09-146-8/+161
| | | | | | | | | dwfl_linux_proc_attach depended on a Dwfl_Module with the correct ELF header already being available. That isn't really necessary since when we attach we have the main exe ELF file available. Just use that to make dwfl_linux_proc_attach always work. Signed-off-by: Mark Wielaard <[email protected]>
* Initialize variable before use.Chih-Hung Hsieh2015-09-102-1/+8
| | | | | | Some compiler does not know that error function never returns. Signed-off-by: Chih-Hung Hsieh <[email protected]>
* libdwfl: Replace abs with llabs for int64_t values.Chih-Hung Hsieh2015-09-092-1/+5
| | | | | Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* tests: Init local variable enctype before use in print_base_type varlocs.c.Chih-Hung Hsieh2015-09-072-1/+5
| | | | | | | clang compiler static analysis failed. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* tests: Remove unused static const variables in md5-sha1-test.c.Chih-Hung Hsieh2015-09-072-8/+5
| | | | | 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-0723-89/+96
| | | | | Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Replace printf %Z length modifier with %z.Chih-Hung Hsieh2015-09-0717-95/+133
| | | | | | | | %Z is a GNU extension predating the ISO C99 %z modifier supported by libc5 and no longer recommended. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* backends: Use ebl->class consistently in sparc backend.Mark Wielaard2015-09-032-6/+10
| | | | | | | | | | | sparc_init would check the ELF class to register to correct core_note handler. But sparc_register_info would check the ELF machine to determine whether the register set was 32 or 64 bits. This caused some confusion and assertion failures in readelf when printing core notes where the sparc machine and class didn't seem to match up. Check the ELF class in both sparc_unit and sparc_register_info to give consistent results. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: handle_core_item large right shift triggers undefined behaviour.Mark Wielaard2015-09-032-2/+14
| | | | | | | | | | | | | | | | | | | | | | The problem is this: int n = ffs (w); w >>= n; The intent is to shift away up to (and including) the first least significant bit in w. But w is an unsigned int, so 32 bits. And the least significant bit could be bit 32 (ffs counts from 1). Unfortunately a right shift equal to (or larger than) the length in bits of the left hand operand is undefined behaviour. We expect w to be zero afterwards. Which would terminate the while loop in the function. But since it is undefined behaviour anything can happen. In this case, what will actually happen is that w is unchanged, causing an infinite loop... gcc -fsanitize=undefined will catch and warn about this when w = 0x80000000 https://bugzilla.redhat.com/show_bug.cgi?id=1259259 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]>
* elflint: Add gnuld check when a NOBITS section falls inside a segment.Mark Wielaard2015-08-172-2/+37
| | | | | | | | | | | | gnuld has a really bad bug where it can place a NOBITS section inside a PT_LOAD segment. Normally that would not work. But it also makes sure that the contents of the file is all zeros. So in practice it is actually a PROGBITS section with all zero data. Except that other tools will think there is an unused gap in the ELF file after the NOBITS section. Recognize and check this pattern in elflint when --gnu is given. Signed-off-by: Mark Wielaard <[email protected]>
* tests: Add a testcase for dwfl debuginfo-path with separate bin/debug dirs.Mark Wielaard2015-08-143-2/+75
| | | | | | | | | Reuse the run-addr2line-i-test.sh testfile-inlines testfile, but first strip the debuginfo and put the binary and separate debuginfo file in different roots. Check that --debuginfo-path still finds the debug file. Signed-off-by: Mark Wielaard <[email protected]>
* Fix finding split debug info files not located by the build-id mechanismDodji Seketeli2015-08-143-7/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [This bug has been found by using elfutils in the context of libabigail. The initial bug report is https://sourceware.org/bugzilla/show_bug.cgi?id=18792. The interesting comments start at is https://sourceware.org/bugzilla/show_bug.cgi?id=18792#c4] suppose we have a debug info file that is located at a /prefix1/usr/lib/debug/prefix2/libfoo.so. Suppose also that the debug info describes a binary that is located at /prefix1/prefix2/libfoo.so Suppose the debug_link property inside the binary /prefix1/prefix2/libfoo.so correctly contains the string "libfoo.so" that designates the name of the debug info file. The problem is, when find_debuginfo_in_path() is called with its file_name parameter set to "/prefix1/prefix2/libfoo.so" and mod->dwfl->callbacks->debuginfo_path set to "/prefix1/lib/debug/", it fails to locate the debug info file libfoo.so under "/prefix1/usr/lib/debug/prefix2/". This patch fixes the issue by making find_debuginfo_in_path() try all the sub-strings of "/prefix1/prefix2/libfoo.so "under" "/prefix1/usr/lib/debug/", to find libfoo.so. That is, it tries, in order: - /prefix1/usr/lib/debug/prefix1/prefix2/libfoo.so - /prefix1/usr/lib/debug/prefix2/libfoo.so <-- and boom, it finds it! Note that the patch tries the variations between the two candidates above too. The patch uses a goto. I dislike gotos like anyone else, but then here, not using this would imply a bigger change of the logic of that function. So I am proposing the scheme based on the goto instead. * libdwfl/find-debuginfo.c (find_debuginfo_in_path): Try to locate the debug info file named debuglink_file under mod->dwfl->callbacks->debuginfo_path, by looking at the set of sub-trees under mod->dwfl->callbacks->debuginfo_path which is common to the set of non-absolute parent trees of file_name. https://bugzilla.redhat.com/show_bug.cgi?id=1253367 Signed-off-by: Dodji Seketeli <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* spec: Provide default-yama-scope.Mark Wielaard2015-08-044-2/+69
| | | | | | | | | | | | | | | | | | | | When yama is enabled in the kernel it might be used to filter any user space access which requires PTRACE_MODE_ATTACH like ptrace attach, access to /proc/PID/{mem,personality,stack,syscall}, and the syscalls process_vm_readv and process_vm_writev which are used for interprocess services, communication and introspection (like synchronisation, signaling, debugging, tracing and profiling) of processes. These are precisely the things that libdw dwfl and ebl backends rely on. So make sure they don't mysteriously fail in such cases by providing the default yama scope sysctl value. This is implemented as a separate subpackage that just provides this functionality so other packages that don't directly rely on elfutils-libs can also just Requires: default-yama-scope to function properly. https://bugzilla.redhat.com/show_bug.cgi?id=1209492#c69 Signed-off-by: Mark Wielaard <[email protected]>
* unstrip: Handle debuginfo files with missing SHF_INFO_LINK section flags.Mark Wielaard2015-08-038-7/+71
| | | | | | | | | | | | | | | | With GCC 5 there might be a .rela.plt section with SHF_INFO_LINK set. Buggy binutils objdump might strip it from the section in the debug file. Ignore such differences for relocation sections and put the flag back if necessary. Also improve the error message a little by only discarding the already matched sections if there is an prelink undo section. Otherwise we will report all sections as not matching if the file wasn't prelinked instead of just the non-matching sections. New testfiles generated by gcc5 and binutils objdump added. Signed-off-by: Mark Wielaard <[email protected]>
* ignore more generated filesMike Frysinger2015-07-291-4/+26
| | | | Signed-off-by: Mike Frysinger <[email protected]>
* Fix/improve .gitignorePino Toscano2015-07-112-26/+120
| | | | | | | | | | | | | | | Fill the .gitignore with more generated files, such as: - test executables - results of the automake testing framework (*.log and *.trs) - sources generated by flex and bison - generated *.mnemonics files in libcpu - the helper libcpu/i386_gendis tool - *.so.1 symlinks Also, anchor existing filenames to their location when builddir==srcdir. Signed-off-by: Pino Toscano <[email protected]>
* tests: skip run-deleted.sh when dwfl_linux_proc_attach is not implementedPino Toscano2015-06-272-0/+9
| | | | | | | | If the current OS does not implement dwfl_linux_proc_attach (which currently only Linux does) then skip this test, as "stack" uses that API for attaching to a running process. Signed-off-by: Pino Toscano <[email protected]>
* tests: dwfl-bug-fd-leak: Guard against null module addressesPino Toscano2015-06-272-1/+10
| | | | | | Do not crash if there is no module for the given address. Signed-off-by: Pino Toscano <[email protected]>
* strings: Define MAP_POPULATE if not defined alreadyPino Toscano2015-06-272-0/+8
| | | | | | Currently it is available on Linux only, and it is more an hint. Signed-off-by: Pino Toscano <[email protected]>
* nm: First call elf_getdata, then allocate memory.Mark Wielaard2015-06-272-6/+10
| | | | | | | | This catches bogus data early before we might try to allocate giant amounts of memory. Reported-by: Hanno Böck <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* tests: Mark an unused argument as suchPino Toscano2015-06-272-1/+5
| | | | Signed-off-by: Pino Toscano <[email protected]>
* Reduce scope of some includesPino Toscano2015-06-276-1/+18
| | | | | | | | Use some includes only according to the #ifdef block of the respective code, or matching the fact they are Linux-only. This way, includes potentially unportable are not unconditionally used. Signed-off-by: Pino Toscano <[email protected]>
* Prepare 0.163 release.elfutils-0.163Mark Wielaard2015-06-1911-2256/+2318
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* findtextrel: Don't leak memory in process_file.Mark Wielaard2015-06-192-0/+5
| | | | | | | | | | | | When a files do contain textrels we fail to release the segments searched and valgrind will show: 2,560 bytes in 16 blocks are definitely lost in loss record 1 of 1 at 0x40281B5: malloc (in vgpreload_memcheck-x86-linux.so) by 0x804AE63: process_file (findtextrel.c:322) by 0x804909B: main (findtextrel.c:149) Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Make sure phdr2_mem lifetime/scope equals phdr2 pointer.Mark Wielaard2015-06-192-1/+6
| | | | | | | We dont' want GCC to dispose or reuse phdr2_mem stack memory while phdr2 is pointing to it. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Don't leak fname if file is main file by another name in try_open.Mark Wielaard2015-06-192-1/+6
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Don't leak memory on failure path in handle_gnu_hash.Mark Wielaard2015-06-192-1/+7
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Don't leak memory on failure paths in elf_updatefile.Mark Wielaard2015-06-192-12/+22
| | | | | | | When something goes wrong during the update make sure to always free any temporary allocated memory (shdr_data and/or scns). Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Only check the PT_TLS phdr if it actually exists, warn otherwise.Mark Wielaard2015-06-192-0/+11
| | | | 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]>
* nm: Fix typo in size check to determine whether we stack allocated memory.Mark Wielaard2015-06-192-1/+6
| | | | | | | | | We allocate GElf_SymX entries, which are larger than plain GElf_Sym structs. The check to see whether we could use stack allocation used the correct sizeof (GElf_SymX), but the check to see if we needed to free was using the incorrect sizeof (GElf_Sym). Which could cause us to leak memory. Signed-off-by: Mark Wielaard <[email protected]>
* strings: Handle failure of getting section name on bogus section data.Mark Wielaard2015-06-192-2/+11
| | | | | | | | If there is something wrong with getting the section data it is likely we won't be able to get the actual section name because the file is somehow corrupted. Try to get the name, but handle failure gracefully. Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Check symbol section header exists before use in nlist.Mark Wielaard2015-06-192-2/+10
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Check symbol section exists and has a sane entsize in find_symtab.Mark Wielaard2015-06-192-1/+7
| | | | 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]>
* libelf: Always call ftruncate before posix_fallocate to set the right size.Mark Wielaard2015-06-194-2/+28
| | | | | | | | | | | | | | | When elf_update.c (write_file) doesn't know the current maximum file length it might have to reduce the file size. posix_fallocate can only extend the file. So always call ftruncate before that to set the file size and making sure the backing store is fully there. Add test cases for checking strip in place (eu-strip without -o) actually reduces the file size. But only for non-ET_REL files. We might not be able to strip ET_REL files (except when they are kernel modules) because they might contain "dangling" symbol table entries. https://bugzilla.redhat.com/show_bug.cgi?id=1232206 Signed-off-by: Mark Wielaard <[email protected]>
* po/*.po: Regenerate.Mark Wielaard2015-06-156-1471/+1992
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Updated Polish translationPiotr Drąg2015-06-141-1484/+1746
| | | | Signed-off-by: Piotr Drąg <[email protected]>
* Updated POTFILES.inPiotr Drąg2015-06-141-2/+7
| | | | Signed-off-by: Piotr Drąg <[email protected]>