summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Optionally allow unknown symbols in the backtrace tests"Mark Wielaard2017-05-023-31/+17
| | | | | | | | | | | | | | This reverts commit f9971cb422df39adea7e8c7e22689b879e39c626. Allowing no symbol resolving at all makes it too hard to see whether the test actually tests anything. But do keep "address out of range" as allowed error in check_err. This can be interpreted as DWARF not available (if end of callstack marker is missing, which it unfortunately often is missing even if CFI is available.). Signed-off-by: Mark Wielaard <[email protected]>
* Avoid double-including config.hUlf Hermann2017-05-0262-11/+291
| | | | | | | | | | | | | | | | config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through our own private headers. In order to set a clear rule about inclusion of config.h, it is now included in every .c file as first header, but not in any header. This will definitely avoid double-inclusion and satisfy the condition that it has to be included before gnulib headers. It comes at the price of adding some redundancy, but there is no clean way to avoid this. Signed-off-by: Ulf Hermann <[email protected]>
* Use F_GETFD rather than F_GETFL to check validity of file descriptorUlf Hermann2017-05-022-1/+5
| | | | | | | F_GETFD is both cheaper and easier to port, and otherwise has the same effect here. Signed-off-by: Ulf Hermann <[email protected]>
* Make __attribute__ conditional in all installed headersUlf Hermann2017-05-028-33/+54
| | | | | | | | | | __attribute__ is a GNU extension. If we want to link against the libraries using a different compiler, it needs to be disabled. It was already disabled in libdw.h, and this patch extends this to the other headers. We move the defines to libelf.h as that is included in all the others. Signed-off-by: Ulf Hermann <[email protected]>
* Fix nesting of bracesUlf Hermann2017-04-282-1/+5
| | | | | | | | The way it was before it didn't actually test if elf_update failed, but rather did something random. !!(<some number>) is a boolean and boolean true can be represented as anything non-0, including negative numbers. Signed-off-by: Ulf Hermann <[email protected]>
* On elf_update, remember when we mmap()Ulf Hermann2017-04-282-0/+6
| | | | | | Otherwise we skip the munmap() later. This leaks resources. Signed-off-by: Ulf Hermann <[email protected]>
* Avoid signed/unsigned comparisonUlf Hermann2017-04-272-1/+5
| | | | | | | | | | | Some compilers implicitly cast the result of uint_fast16_t * uint_fast16_t to something signed and then complain about the comparison to (unsigned) size_t. Casting phnum to size_t is a good idea anyway as 16bit multiplication can easily overflow and we are not checking for this. Signed-off-by: Ulf Hermann <[email protected]>
* Include strings.h to make ffs availableUlf Hermann2017-04-272-0/+5
| | | | | | We cannot rely on it to be available from any of the other headers. Signed-off-by: Ulf Hermann <[email protected]>
* Protect against integer overflow on shnumUlf Hermann2017-04-274-19/+33
| | | | | | | If shnum is 0, the many "shnum - 1" would result in an overflow. Check it for 0, and only subtract once, rather than on every usage. Signed-off-by: Ulf Hermann <[email protected]>
* Add EXEEXT to gendisUlf Hermann2017-04-262-3/+7
| | | | | | | Otherwise the build will fail on systems that actually need file extension for executables. Signed-off-by: Ulf Hermann <[email protected]>
* Include endian.h when handling BYTE_ORDERUlf Hermann2017-04-262-0/+5
| | | | | | BYTE_ORDER and friends are customarily defined in endian.h. Signed-off-by: Ulf Hermann <[email protected]>
* Add missing entries to .gitignoreUlf Hermann2017-04-262-0/+6
| | | | Signed-off-by: Ulf Hermann <[email protected]>
* Avoid YESSTR and NOSTRUlf Hermann2017-04-265-21/+32
| | | | | | | | | Those are deprecated and apparently some implementations of nl_langinfo return empty strings for them. The tests even tested for those empty strings even though the intention of the code was clearly to output "yes" or "no" there. Signed-off-by: Ulf Hermann <[email protected]>
* Don't use comparison_fn_tUlf Hermann2017-04-262-2/+6
| | | | | | Not all search.h declare it, and it is not very helpful anyway. Signed-off-by: Ulf Hermann <[email protected]>
* Clean up linux-specific system includesUlf Hermann2017-04-2613-14/+35
| | | | | | We only include them where we actually need them and only on linux. Signed-off-by: Ulf Hermann <[email protected]>
* Include sys/types.h before fts.hUlf Hermann2017-04-252-1/+9
| | | | | | | The bad fts not only needs to be included before config.h, but also requires various special types without including sys/types.h. Signed-off-by: Ulf Hermann <[email protected]>
* libelf: Initialize n to zero in elf_getarsym.Mark Wielaard2017-04-192-1/+5
| | | | | | | | | | | | When building with gcc -Os it seems we can inline read_number_entries but if that function fails then n will not be initialized. GCC seems not to realize that in that case n won't be used at all. Explicitly initialize n to zero to prevent a spurious error: 'n' may be used uninitialized in this function [-Werror=maybe-uninitialized] in that case. https://sourceware.org/bugzilla/show_bug.cgi?id=21011 Signed-off-by: Mark Wielaard <[email protected]>
* Add missing peel_type.c test for commit f339da.Mark Wielaard2017-04-071-0/+119
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Support checking ELF files with compressed sections.Mark Wielaard2017-04-056-3/+47
| | | | | | | | | Simply unconditionally uncompress any section to make sure indexes between sections check out. Add some testcases with various compressed sections. https://sourceware.org/bugzilla/show_bug.cgi?id=21332 Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Fix dwarf_peel_type infinite loop.Mark Wielaard2017-04-055-4/+83
| | | | | | | | | | We were calling dwarf_attr_integrate () in the die in the loop instead of on the result. Which would cause an infinite loop when die != result. Add a testcase that explicitly checks this case. https://sourceware.org/bugzilla/show_bug.cgi?id=21330 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Don't check section group without flags word.Mark Wielaard2017-04-042-1/+8
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=21320 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Sanity check the number of phdrs and shdrs available.Mark Wielaard2017-04-042-0/+30
| | | | | | | | | Make sure we can at least read the shnum sections or phnum segments. Limit the number we do check to those we can actually read. https://sourceware.org/bugzilla/show_bug.cgi?id=21312 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Don't trust sh_entsize when checking hash sections.Mark Wielaard2017-04-042-12/+27
| | | | | | | | | | Calculate and use the expected entsize instead of relying on the one given by the ELF file section header. Return early if there isn't enough data in the section to check the full hash table. https://sourceware.org/bugzilla/show_bug.cgi?id=21311 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Check symbol table data is big enough before checking.Mark Wielaard2017-04-042-1/+6
| | | | | | | | | Before checking symbol index zero we should make sure the data size is big enough. https://sourceware.org/bugzilla/show_bug.cgi?id=21310 Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Always update last_offset in updatefile and updatemmap.Mark Wielaard2017-04-045-7/+468
| | | | | | | | | | | | | | | | When ELF section data was used, but not updated or marked as dirty and there also existed non-dirty sections and some padding was needed between the sections (possibly because of alignment) then elf_update might write "fill" over some of the existing data. This happened because in that case the last_position was not updated correctly. Includes a new testcase fillfile that fails before this patch by showing fill instead of the expected data in some section data. It succeeds with this patch. https://sourceware.org/bugzilla/show_bug.cgi?id=21199 Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Check compression ratio before trying to allocate output buffer.Mark Wielaard2017-04-032-0/+14
| | | | | | | | | | The maximum compression factor (http://www.zlib.net/zlib_tech.html) is 1032:1. Add a sanity check for that before trying to allocate lots of memory and trying to decompress lots of bogus data. https://sourceware.org/bugzilla/show_bug.cgi?id=21301 Signed-off-by: Mark Wielaard <[email protected]>
* Use the empty string for note names with zero size (without any data).Mark Wielaard2017-04-035-6/+23
| | | | | | | | | | ELF notes can have a zero sized name. In which case there is no data at all (so also no zero terminator). Make sure to use the empty string for such notes if the code does not otherwise explicitly check n_namesz. https://sourceware.org/bugzilla/show_bug.cgi?id=21300 Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Fix off by one sanity check in handle_gnu_hash.Mark Wielaard2017-04-032-1/+6
| | | | | | | | | | We sanity check to make sure we don't index outside the chain array by testing inner > max_nsyms. But inner is a zero-based index, while max_nsyms is the maximum number. Change the check to inner >= max_nsyms. https://sourceware.org/bugzilla/show_bug.cgi?id=21299 Signed-off-by: Mark Wielaard <[email protected]>
* libasm: Fix one GCC7 -Wformat-truncation=2 warning.Mark Wielaard2017-03-242-3/+9
| | | | | | | | | | | Make sure that if we have really lots of labels the tempsym doesn't get truncated because it is too small to hold the whole name. This doesn't enable -Wformat-truncation=2 or fix other "issues" pointed out by enabling this warning because there are currently some issues with it. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79448 Signed-off-by: Mark Wielaard <[email protected]>
* backends: Add support for EM_PPC64 GNU_ATTRIBUTES.Mark Wielaard2017-03-247-3/+30
| | | | | | | | ppc64 and ppc64le ELF files can also contain a power specific .gnu.attributes section. Add support for those and recognize the new GNU_Power_ABI_FP Single-precision hard float value. Signed-off-by: Mark Wielaard <[email protected]>
* Move print_version into printversion.{h|c}Ulf Hermann2017-02-1723-27/+103
| | | | | | | | Rename version.c so that the implementation is called after the header and the header doesn't clash with the toplevel version.h. print_version depends on argp and is only used in the tools. Signed-off-by: Ulf Hermann <[email protected]>
* Check for existence of mempcpyUlf Hermann2017-02-1714-2/+40
| | | | | | If it doesn't exist, provide a definition based on memcpy. Signed-off-by: Ulf Hermann <[email protected]>
* Always use the same method to query the system page sizeUlf Hermann2017-02-155-3/+12
| | | | | | | This makes it easier to write a replacement for it on systems where sysconf(3) doesn't exist. Signed-off-by: Ulf Hermann <[email protected]>
* Move color handling into a separate headerUlf Hermann2017-02-158-34/+79
| | | | | | | | We only need it in nm.c and objdump.c, but it pulls in argp as dependency. By dropping it from libeu.h, the libraries can be compiled without argp. Signed-off-by: Ulf Hermann <[email protected]>
* Add -D_FORTIFY_SOURCE=2 to CFLAGS if possible.Mark Wielaard2017-02-142-0/+25
| | | | | | | | | Some distros now add -D_FORTIFY_SOURCE=2 by default and we have missed some issues in the past caught by it. Add it to CFLAGS if possible. The configure check will make sure that it doesn't conflict with any other CFLAGS already defined. Signed-off-by: Mark Wielaard <[email protected]>
* Optionally allow unknown symbols in the backtrace testsUlf Hermann2017-02-143-12/+38
| | | | | | | | This is useful to test unwinding without debug information. The binaries being examined might still have frame pointers that allow us to bridge the unknown symbols. Signed-off-by: Ulf Hermann <[email protected]>
* Make the backtrace-data test helper more robustUlf Hermann2017-02-142-3/+19
| | | | | | | | | When unwinding by frame pointer the unwinder might ask for invalid addresses. We don't have to fail the test in this case. In fact any broken dwarf information can lead to requests for invalid addresses, also without frame pointer unwinding. Signed-off-by: Ulf Hermann <[email protected]>
* Add missing tests to .gitignoreUlf Hermann2017-02-141-0/+12
| | | | | | Some test binaries were missing and showed up in "git status". Signed-off-by: Ulf Hermann <[email protected]>
* Define PACKAGE_URL for older autoconf.Mark Wielaard2017-01-122-0/+10
| | | | | | | autoconf < 2.64 doesn't define PACKAGE_URL through AC_INIT. Define it ourselves if needed. Signed-off-by: Mark Wielaard <[email protected]>
* Fix TEMP_FAILURE_RETRY definition when not defined.Luiz Angelo Daros de Luca2016-12-307-2/+15
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=21001 Signed-off-by: Luiz Angelo Daros de Luca <[email protected]>
* Update Polish translationPiotr Drąg2016-12-291-2/+15
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=20999 Signed-off-by: Piotr Drąg <[email protected]>
* Update POTFILES.inPiotr Drąg2016-12-291-0/+1
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=20999 Signed-off-by: Piotr Drąg <[email protected]>
* Update Polish translationPiotr Drąg2016-12-291-126/+95
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=20999 Signed-off-by: Piotr Drąg <[email protected]>
* Prepare for elfutils 0.168 release.elfutils-0.168Mark Wielaard2016-12-2711-5199/+5191
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* http://elfutils.org/ is now hosted at http://sourceware.org/elfutils/Mark Wielaard2016-12-2431-250/+169
| | | | | | | | | | | | | | | | | fedorahosted used to be our home, but we are now hosted at sourceware. Change the elfutils project home to http://elfutils.org/ Point hosted services (email, release, git, bug tracker and web pages) to https://sourceware.org/elfutils/ Move design notes from README to NOTES. Add URLs for home, releases, bugs, git and mailinglist to README. Make the --version output of all tools the same by using a common print_version function and update the publicly shown copyright holder to the elfutils developers. Signed-off-by: Mark Wielaard <[email protected]>
* libelf: gelf_newehdr and gelf_newehdr should return void *.Akihiko Odaki2016-12-074-10/+22
| | | | | | | | | | | | unsigned long int is not always capable to have pointer in some cases (LLP64, for example). Return a void pointer instead. Other libelf implementations will also make this change (or already have). Also update the documentation to state what is created and that NULL is returned on error (don't document that the returned value is a pointer to the actual header created). Signed-off-by: Akihiko Odaki <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Only workaround fts.h if we have a bad version that doesn't handle LFS.Mark Wielaard2016-11-234-8/+33
| | | | | | | | | | Older versions of glibc included an fts implementation that didn't have Large File System support. We worked around that in linux-kernel-modules.c by including it early before config.h and then redefining some symbols to get the 64-bit versions. This is somewhat fragile and not necessary with newer glibc. If possible we want the 64bit fts version always. Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Add optional --symbols[=SECTION] argument to select section name.Mark Wielaard2016-11-174-1/+41
| | | | | | | | | Make it possible to display just the symbols from a named symbol section instead of always displaying all symbol sections. https://bugzilla.redhat.com/show_bug.cgi?id=1396092 Signed-off-by: Mark Wielaard <[email protected]>
* ar: Fix GCC7 -Wformat-length issues.Mark Wielaard2016-11-113-10/+28
| | | | | | | | | | | | GCC7 adds warnings for snprintf formatting into too small buffers. Fix the two issues pointed out by the new warning. The ar header fields are fixed length containing left-justified strings without zero terminator. snprintf always adds a '\0' char at the end (which we then don't copy into the ar header field) and numbers are decimal strings of fixed 10 chars (-Wformat-length thinks formatting them as size_t might overflow the buffer on 64bit arches). Signed-off-by: Mark Wielaard <[email protected]>
* libelf: Sanity check offset and size before trying to malloc and read data.Mark Wielaard2016-11-102-0/+16
| | | | | | | | | | Bad sh_off or sh_size could trigger a bad malloc or read. Sanity check the header values first before trying to malloc a huge buffer or reading any data that will certainly fail. https://bugzilla.redhat.com/show_bug.cgi?id=1387584 Signed-off-by: Mark Wielaard <[email protected]>