summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
| * libelf: Fix shnum and section zero handling.Mark Wielaard2018-09-136-3/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For ELF files with more than SHN_LOWRESERVE sections we always need section zero to store the section number (it doesn't just fit in the Ehdr e_shnum field). Make sure to create it if it doesn't exist yet in elf_getscn. Also fix handling on shnum in updatefile for the mmap case (we already got this correct for the non-mmap case). This adds a new test run-copymany-sections.sh which is like run-copyadd-sections.sh but tries to add two times 65535 sections. It makes sure libelf can copy the whole file and elfcmp checks they are the same. It doesn't use mmap for addsections since that doesn't work yet. ELF_C_RDWR_MMAP needs mremap which will fail since it needs too much space and the original mmap cannot move. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * elfcmp: Get, check and shdrstrndx for section names.Mark Wielaard2018-09-132-2/+22
| | | | | | | | | | | | | | | | elfcmp would use the Ehdr e_shstrndx field to find the shdr string index table. Use elf_getshdrstrndx instead to be able to handle ELF files with more than SHN_LORESERVE sections. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * libebl: Use elf_getshdrstrndx in ebl_section_strip_p.Mark Wielaard2018-09-136-7/+21
| | | | | | | | | | | | | | | | | | | | The ebl_section_strip_p function used the Ehdr e_shstrndx field to get at the name of the (debug) sections. This is not correct if there are more than SHN_LORESERVE sections. Use elf_getshdrstrndx to get at the shstrtab section. And drop the Ehdr argument that isn't necessary anymore. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * backends: Use elf_getshdrstrndx to find .odp section in ppc64_initMark Wielaard2018-09-132-2/+8
| | | | | | | | | | | | | | | | | | The .odp section is found by name. But ppc64_init used the e_shstrndx Ehdr field for that. This is wrong if the file contains more than SHN_LORESERVE sections. Use elf_getshdrstrndx instead to find the shstrtab section. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * backends: Always use elf_getshdrstrndx in check_special_symbol.Mark Wielaard2018-09-1313-18/+50
| | | | | | | | | | | | | | | | | | | | The check_special_symbol backend functions used the Ehdr e_shstrndx field to get at the name of sections. This is not correct if there are more than SHN_LORESERVE sections. Always use elf_getshdrstrndx to get the shstrtab section. And drop the Ehdr argument that isn't necessary anymore. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * libelf: Fix some issues with ELF_C_RDWR_MMAP.Mark Wielaard2018-09-138-14/+713
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When ELF_C_RDWR_MMAP is used libelf might have to write overlapping memory when moving the section data or headers. Make sure to use memmove, not memcpy. Also the size of the underlying file might have to change. That means we will have to also extend the mmap region with mremap. Since we are using direct pointers into the mmapped area we cannot move the mmap, only extend it. This might still fail if there is not enough free memory available to extend the mmap region. Two new test programs have been added. elfcopy which copies a whole elf file (using either ELF_C_WRITE or ELF_C_WRITE_MMAP). And addsections which adds new sections to an existing ELF file (using either ELF_C_RDWR or ELF_C_RDWR_MMAP). The newly added test will fail under valgrind without the fixes. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * tests: Add section attribute to defeat -freorder-blocks-and-partition.Mark Wielaard2018-09-112-0/+5
| | | | | | | | | | | | | | | | GCC could partition main into an cold and hot block causing our symbol lookup to fail in the backtrace-dwarf testcase. Add a section attribute on "main" so that it will be kept together. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * strip: Handle mixed allocated/non-allocated sections.Mark Wielaard2018-08-302-15/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Normally in non-ET_REL files all allocated sections come before all non-allocated sections. eu-strip relies on this when stripping a file and calculating the file offsets. But recently on Fedora there are non-allocated .gnu.build.attributes NOTE sections in the middle of the allocated sections, with a sh_offset field that is larger then the next section. This confuses eu-strip so much that it might corrupt the stripped file. Work around this by calculating the sh_offset fields in two phases when detecting mixed allocated/non-allocated sections. First handle the allocated ones, then use the offset after the last allocated section to calculate the offsets of the non-allocated sections left in the stripped file. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * libdw: Check end of attributes list consistently.Mark Wielaard2018-08-183-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dwarf_child (__libdw_find_attr), dwarf_getabbrevattr[_data] and dwarf_getattrs all assume the end of the attribute list is when both the name (code) and form of the attribute are zero. dwarf_getabbrev (__libdw_getabbrev) and dwarf_hasattr assume the end of the attribute list is when either the name (code) or the form of the attribute is zero. The DWARF spec says: "The series of attribute specifications ends with an entry containing 0 for the name and 0 for the form." So the first check is correct. Make sure dwarf_getabbrev and dwarf_hasattr use the same check. This is important since all other functions expect dwarf_getabbrev (__libdw_getabbrev) to have done a data sanity check of the attribute. So if the ending condition is different it could cause a crash. https://sourceware.org/bugzilla/show_bug.cgi?id=23529 Signed-off-by: Mark Wielaard <mark@klomp.org>
| * libdw, readelf: Make sure there is enough data to read full aranges header.Mark Wielaard2018-08-184-0/+16
| | | | | | | | | | | | | | | | | | | | dwarf_getaranges didn't check if there was enough data left to read both the address and segment size. readelf didn't check there was enough data left to read the segment size. https://sourceware.org/bugzilla/show_bug.cgi?id=23541 Signed-off-by: Mark Wielaard <mark@klomp.org>
| * elflint: Fix check_sysv_hash[64] sanity checks to not overflow.Mark Wielaard2018-08-182-2/+12
| | | | | | | | | | | | | | | | | | The sanity checks for how many words were needed in the section could overflow causing errors. Fix the checks. https://sourceware.org/bugzilla/show_bug.cgi?id=23542 Signed-off-by: Mark Wielaard <mark@klomp.org>
| * libelf: Return error if elf_compress_gnu is used on SHF_COMPRESSED section.Mark Wielaard2018-08-183-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | Compressing a section that is already compressed is fine, but useless. But it isn't possible to gnu compress (or decompress) a SHF_COMPRESSED section since there is no state kept that would tell if the section was first GNU compressed or first gabi compressed. Calling elf_compress_gnu on a section and then calling elf_compress on it to decompress it twice could cause a crash (the other way around is fine). Just disallow it. https://sourceware.org/bugzilla/show_bug.cgi?id=23528 Signed-off-by: Mark Wielaard <mark@klomp.org>
| * libelf: Fix documentation of elf_getshdrstrndx and elf_getshstrndx.Mark Wielaard2018-07-272-4/+9
| | | | | | | | | | | | | | | | | | Because of copy/paste error part of the documentation for elf_getshdrstrndx and elf_getshstrndx was actually for elf_getshdrnum and elf_getshnum. Fix it to refer to the proper ehdr field and deprecated function name. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * unstrip: Also check sh_size in compare_unalloc_sections.Mark Wielaard2018-07-276-0/+72
| | | | | | | | | | | | | | | | | | | | | | | | compare_unalloc_sections only checked sh_flags and the section names. This would cause stripped/debug section mismatches when there were multiple sections with the same name and flags. Fix this by also checking the size of the section matches. Add a testcase that has two ".group" sections created on i386 with the gcc annobin plugin. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * unstrip: Handle SHT_GROUP sections in ET_REL files.Mark Wielaard2018-07-276-2/+87
| | | | | | | | | | | | | | | | | | SHT_GROUP sections are put in both the stripped and debug file. Handle correcting the symbol table/name entry of the group only once. The testfile was generated with the gcc annobin plugin. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * elfcompress: Don't rewrite file if no section data needs to be updated.Mark Wielaard2018-07-242-3/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the input and output file are the same and no section needs to be updated we really don't need to rewrite the file. Check whether any matching section is already compressed or decompressed. Skip the section if it doesn't need to be changed. If no section data needs updating end with success without rewriting/updating file. With --force the file will still always be updated/rewritten even if no section data needs to be (de)compressed. Acked-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org> Signed-off-by: Mark Wielaard <mark@klomp.org>
| * backends: add abi_cfi and set_initial_registers_tid callbacks for M68KAndreas Schwab2018-07-225-1/+153
| | | | | | | | | | | | This fixes all testsuite failures. Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
| * elfcompress: Swap fchmod and fchown calls on new file.Mark Wielaard2018-07-222-4/+11
| | | | | | | | | | | | | | | | | | | | | | Calling fchmod with a suid bit on a file might silently fail or the suid bit might be slilently cleared by a call to fchown if already set. Swap the calls so that the owner is set first and then set the suid bit. https://bugzilla.redhat.com/show_bug.cgi?id=1607044 Reported-and-tested-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org> Signed-off-by: Mark Wielaard <mark@klomp.org>
| * tests: Add core and strip tests for RISC-VAndreas Schwab2018-07-198-1/+162
| | | | | | | | Signed-off-by: Andreas Schwab <schwab@suse.de>
| * Fix typo in riscv_register_infoAndreas Schwab2018-07-192-1/+5
| | | | | | | | Signed-off-by: Andreas Schwab <schwab@suse.de>
| * Don't include sys/uio.h if we don't need itUlf Hermann2018-07-172-1/+5
| | | | | | | | The PID attaching only works on linux.
| * backends: add core_note callback for RISC-VAndreas Schwab2018-07-174-1/+68
| | | | | | | | Signed-off-by: Andreas Schwab <schwab@suse.de>
| * Remove previous test files before running the next roundUlf Hermann2018-07-172-0/+7
| | | | | | | | | | | | | | | | | | | | | | strip explicitly creates the new files. This will not work on windows if the files already exist. Also, if strip fails to create the files for any reason, we would check the previous run's files and succeed. However, the test should fail then. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
| * tests: Update hello_riscv64.ko test file with debuginfo.Mark Wielaard2018-07-173-1/+8
| | | | | | | | | | | | | | | | Also document CONFIG_DEBUG_INFO=y. Updated test file provided by Andreas Schwab <schwab@suse.de>. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * backends: add set_initial_registers_tid callback for RISC-VAndreas Schwab2018-07-134-1/+86
| | | | | | | | | | | | | | This fixes the backtrace-dwarf and deleted tests, and lets backtrace-native run a bit further. Signed-off-by: Andreas Schwab <schwab@suse.de>
| * tests: Handle compressed sections in next_cfi testcase.Mark Wielaard2018-07-102-4/+30
| | | | | | | | | | | | | | | | | | | | Some toolchains use compressed ELF sections by default. This would make run-next-cfi-self.sh fail because it would try to decode the compressed data. Fix by decompressing the section first. https://sourceware.org/bugzilla/show_bug.cgi?id=23370 Signed-off-by: Mark Wielaard <mark@klomp.org>
| * readelf: Don't shadow index function from string.hMark Wielaard2018-07-052-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | On some ancient GCC versions (4.4.7 at least) -Wshadow warns about local variables "shadowing" global function definitions. readelf.c: In function ‘print_debug_addr_section’: readelf.c:5265: error: declaration of ‘index’ shadows a global declaration /usr/include/string.h:489: error: shadowed declaration is here This is silly of course, but easy to work around. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Consolidate error.h inclusion in system.hRoss Burton2018-07-0567-63/+116
| | | | | | | | | | | | | | | | | | error.h isn't standard and so isn't part of the musl C library. To easy future porting, consolidate the inclusion of error.h into system.h. https://sourceware.org/bugzilla/show_bug.cgi?id=21008 Signed-off-by: Ross Burton <ross.burton@intel.com>
| * Require gawk in maintainer modeRoss Burton2018-07-052-0/+8
| | | | | | | | | | | | gawk is required to build known_dwarf.h, so check for it in configure.ac. Signed-off-by: Ross Burton <ross.burton@intel.com>
| * config: Add upload-release.sh script.Mark Wielaard2018-07-042-0/+35
| | | | | | | | | | | | | | | | Should be run after making a release to upload the new tar.bz2, signature file and update the latest symlinks. Make sure to run make distcheck first. Requires a shell account on sourceware. Signed-off-by: Mark Wielaard <mark@klomp.org>
* | Add a header for eu_compat.dll, and export more functionsQtCreator4.8.1QtCreator4.8.0-rc1QtCreator4.8.0-beta2QtCreator4.8.0-beta1QtCreator4.8.04.8Ulf Hermann2018-07-253-0/+82
| | | | | | | | | | | | | | | | We obviously need strdup, and it doesn't hurt to also export realloc and calloc. Change-Id: Ia4af48faaec2bcf24c3e07002711cd6153f684bf Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Remove bogus white space in test-subr.shUlf Hermann2018-07-241-2/+2
| | | | | | | | | | | | | | mingw should have complained about this, too ... Change-Id: I03940ba6e93ef04c51418cc507cccf47453d10fa Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Don't install versioned DLLs on windowsUlf Hermann2018-07-245-46/+65
| | | | | | | | | | | | | | | | Nobody can use those, and as windows doesn't have proper symlinks, they take up lots of space. Change-Id: If62db984c7ac62e798a88e3a4ecd15962683d001 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Untangle +/-1 code in __libdw_debugdirUlf Hermann2018-07-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In some situations GetFinalPathNameByHandleA actually wants to write one character more than the number it gives as return value. We just always make enough space for this, to be on the safe side. Following the example given in the documentation, we offer it the whole buffer (not -1), and figure out if we can fit the zero in afterwards. It can respond with exactly the number given as input and mean "this is not enough". Change-Id: I3a7c2bdbe505ae7382607482e647313684c3ff74 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Deal with newer libdl on windows requiring psapi.dllUlf Hermann2018-07-233-27/+42
| | | | | | | | | | | | | | We want to link libdl statically, so we need to link psapi ourselves. Change-Id: I001bda009c58cfb39bba0733436f883bbf501b80 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | On PE platforms, set PATH rather than LD_LIBRARY_PATH for installcheckUlf Hermann2018-07-231-1/+7
| | | | | | | | | | | | | | Windows loads DLLs from PATH. Change-Id: I96ef61236a615d06f1d667e1ae25f11a10e545da Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | readlink: unlink temporary files after closing them, and avoid TMPDIRUlf Hermann2018-07-231-11/+16
| | | | | | | | | | | | | | | | Windows cannot unlink open files, and there is no predefined temporary directory. Use the section name as base for the file name. Change-Id: I7e050e1ca5e5e890256b2573ca0d0c64745932fa Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Ignore trailing CR in readelf-variant testUlf Hermann2018-07-231-1/+1
| | | | | | | | | | Change-Id: Ie9cf00b2e00b84ab736aaefc805a1cacfc9ae408 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | ranlib: unlink only after closeUlf Hermann2018-07-231-1/+1
| | | | | | | | | | | | | | Windows won't unlink open files. Change-Id: I23f785a8463aa29a972598e1e5a25b4f92448cb8 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Make __libdw_debugdir and __libdw_filepath portableUlf Hermann2018-07-232-2/+55
| | | | | | | | | | | | | | | | Use generic IS_ABSOLUTE_FILE macro, and implement fd-to-filename for windows. Reading from /proc/self obviously is not porable. Change-Id: I805c5295871c13f4fa4b89eb89871fc100559318 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | On PE platforms, use PATH instead of LD_LIBRARY_PATHUlf Hermann2018-07-233-8/+40
| | | | | | | | | | | | | | | | | | The windows linker looks for .dll files in PATH. LD_LIBRARY_PATH doesn't work. This reduces the amount of headache to be suffered when running the test suite. Change-Id: I94e73af46bf4a7b185158067db86a9c16f3690dd Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Don't match line endings with grep in linkmap-cut testUlf Hermann2018-07-231-2/+2
| | | | | | | | | | | | | | | | I don't think we can accidentally match these strings in any other place and the line ending matches are brittle. Change-Id: I880e23a89c56851b17e50d804ed949761c9c1955 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Disable symbol versioning for distcheckUlf Hermann2018-07-231-0/+1
| | | | | | | | | | Change-Id: Idae0879a3514a9968395de399ee0094fb27e1a08 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Don't match line ending when using grep to search for error messageUlf Hermann2018-07-231-1/+1
| | | | | | | | | | | | | | | | | | | | We are relying on the version of grep being used to recognize the platform specific line endings. In principle it should, but the reality turns out to be ... complicated. This message is unique enough to not require the additional qualification of "at end of line". Change-Id: I8241b023e759c9b57e050b07995cad0683c4bf35 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Remove files before regenerating them in run-strip-g testUlf Hermann2018-07-201-0/+2
| | | | | | | | | | | | | | On windows, strip cannot overwrite files. Change-Id: I2cf1384b18daec71f079238cf274bce08bdc209b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Refine self-test detectionUlf Hermann2018-07-206-48/+56
| | | | | | | | | | | | | | | | There are some convenient new methods for selftests that we can hook into to avoid repeating the same check in every test. Change-Id: Ie12e1f90f86f3bd3f0590fef4fe0157f4bc0f59c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Add O_BINARY to new open() callsUlf Hermann2018-07-2013-15/+15
| | | | | | | | | | | | | | Windows needs that if you're not reading text. Change-Id: I923782f2c47ef16765f52d6a435f69cb33f50dfd Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Update gnulib modules, replacing canonicalize with canonicalize-lgplUlf Hermann2018-07-20385-6559/+5688
| | | | | | | | | | | | | | | | We need realpath() now, as upstream has changed to use that. Updating single gnulib modules is not really possible, so we update everything. Change-Id: I32943a1c8af7c1ecce625dca173a942cc58d9c38 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | ar.c: Make sure we always close any fd before unlink or renameUlf Hermann2018-07-201-15/+22
| | | | | | | | | | | | | | | | Windows doesn't unlink or rename if there are still open file handles around. Change-Id: Idddda2cf841d42fa3a5a3fee9e3fe79f2a49136b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Don't include sys/uio.h if we don't need itUlf Hermann2018-07-191-1/+1
| | | | | | | | | | | | | | The PID attaching only works on linux. Change-Id: I00428a711b64cb490429363ef28a867b1347956e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>