summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Clean up linux-specific system includesUlf Hermann2017-04-2113-14/+35
| | | | | | | We only include them where we actually need them and only on linux. Change-Id: Ic3065ffab67ba1177f63204fb91a92c5f4336dbb Reviewed-by: Christian Kandeler <[email protected]>
* Include sys/types.h before fts.hUlf Hermann2017-04-212-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. Change-Id: I31ac8d2aadcf7ffb3efb63583b2745991bfd6f90 Reviewed-by: Christian Kandeler <[email protected]>
* Merge branch 'upstream' into HEADUlf Hermann2017-04-1911-7/+249
|\ | | | | | | Change-Id: Ifefd8ffeadb4e7d6df59cdc606323999eedc9adb
| * 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]>
* | Merge branch 'upstream'Ulf Hermann2017-04-0612-28/+582
|\| | | | | | | Change-Id: Ie20a924c8a6bd83cf404f236dd288a489ace62a0
| * 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]>
* | Merge remote-tracking branch 'upstream/master' into HEADUlf Hermann2017-03-289-6/+39
|\| | | | | | | Change-Id: I7874d814ddf7e5887fd720c899cb9e7499d5fbb8
| * 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]>
* libelf: Always set ELF maxsize when reading an ELF file for sanity checks.Mark Wielaard2016-11-102-18/+27
| | | | | | | | | | | | | | There are various sanity checks that depend on knowing the file size of the underlying ELF file which we only used when mmapping the ELF file. Although we probably won't crash if we use pread to try to read from the file, we still might return completely bogus data structures. This could cause us to malloc insane amounts of memory. Always try to get the maxsize when unknown in elf_begin.c (read_file). https://bugzilla.redhat.com/show_bug.cgi?id=1388057 Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Correct spelling of DW_LANG_PLI in dwarf.h.Mark Wielaard2016-11-104-4/+16
| | | | | | | | | 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]>
* Add GCC7 -Wimplicit-fallthrough support/fixes.Mark Wielaard2016-11-1025-18/+89
| | | | | | | | | | | GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one small buglet in elflint option procession. So it seems useful to enable to make sure all swatch case fallthroughs are deliberate. Add configure check to detect whether gcc support -Wimplicit-fallthrough and enable it. Add fixes and explicit fallthrough comments where necessary. Signed-off-by: Mark Wielaard <[email protected]>
* tests: unstrip: Add test for mismatched .strtab sectionsKevin Cernekee2016-10-246-3/+33
| | | | | | | | | | Current unstrip test cases either have no .symtab/.strtab in the stripped binary, or .strtab sections that are identical between the stripped and debuginfo binaries. Add a test case where .symtab/.strtab in the stripped binary contains a small subset of the full unstripped data. Signed-off-by: Kevin Cernekee <[email protected]>
* unstrip: Don't try to use unstripped .symtab with stripped .strtabKevin Cernekee2016-10-242-7/+12
| | | | | | | | | | | | | | | | | | | | | | | Prematurely matching up the stripped and unstripped .strtab sections in the "Match each debuginfo" loop can lead to a case where sec->outscn gets populated for the stripped .strtab, which we normally want to ignore. This causes the .strtab override in the "Make sure each main file section" loop to be skipped, so the code winds up using indices from the unstripped .symtab to look up strings in the stripped .strtab. This returns incorrect strings for a little while, and then fails catastrophically when it tries to read past the end of the (smaller) stripped file's .strtab section: eu-unstrip: invalid string offset in symbol [1589] Fix this by adding logic to the "Match each debuginfo" loop to treat the unstripped .strtab, .shstrtab, and .symtab sections essentially the same way. The new logic will break if the .strtab section shows up earlier than the .symtab section. We will assume this never happens in practice. Signed-off-by: Kevin Cernekee <[email protected]>
* Do not depend on some non-POSIX features.Akihiko Odaki2016-10-138-8/+76
| | | | | | | | Define/open code memrchr, rawmemchr, powerof2 and TEMP_FAILURE_RETRY if not available through system headers. Signed-off-by: Akihiko Odaki <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* lib: Provide MAX and MIN in system.hAkihiko Odaki2016-10-1246-96/+182
| | | | | | | | | | 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]>
* strip: Don't remove real symbols from allocated symbol tables.Mark Wielaard2016-10-062-11/+29
| | | | | | | | | | | | | | | Having a symbol in an allocated symbol table (like .dynsym) that points to an unallocated section is wrong. Traditionally strip has removed such symbols if they are section or group symbols. But removing a real symbol from an allocate symbol table is hard and probably a mistake. Really removing it means rewriting the dynamic segment and hash sections. Since we don't do that, don't remove the symbol (and corrupt the ELF file). Do warn and set the symbol section to SHN_UNDEF. https://bugzilla.redhat.com/show_bug.cgi?id=1380961 Signed-off-by: Mark Wielaard <[email protected]>
* libcpu: Fix build of bpf_disasm.c for kernels < 3.20.Mark Wielaard2016-09-052-0/+8
| | | | | | | Before linux 3.20 the BPF_PSEUDO_MAP_FD constant wasn't defined. Reported-by: Julian Ospald <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* tests: Fix --enable-gcov tests build. Add libdw to LDADD for asm_tsts.Mark Wielaard2016-08-302-9/+13
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Regenerate .po files.elfutils-0.167Mark Wielaard2016-08-265-10/+10
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* tests: Simplify backtrace-native tests. Drop raise jmp patching for x86_64.Mark Wielaard2016-08-253-22/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The backtrace-native[-biarch] testcase was a little too clever in places making it unreliable. On x86_64 we tried to make an interesting backtrace by catching the first signal and then replacing the pc with the address of the first instruction of a function. Then we would raise a new signal, through ptrace, to create a backtrace that went from a signal frame into a frame at the start of a function. That way we could check that we were trying to fetch the correct CFI for the (jmp) function even at the first instruction (normally we would substract one from the return address to get at the call address). This works as long as the CFI for the jmp() function is identical to the CFI for the raise() function that we "patched away". Unfortunately on Fedora rawhide glibc has a rewritten raise() implementation that has different CFI, in particular the CFA is calculated differently. Making the testcase fail because we cannot properly unwind from jmp(). So this special x86_64 case has been disabled (the code is still there in case we find another way to test this in a more reliable way). On Ubuntu there have been spurious testcase failures because see_exec_module found two Dwfl_Modules with the same path. This would trigger an assert. Although this might indicate some issue (maybe we are not parsing the proc/pid/map correctly?) it isn't clear that it really is a bug. Since the assert is not very helpful finding any actual bug and for the testcase it is only necessary that the first Dwfl_Module that represents the executable is found we just pick that Dwfl_Module and don't iterate through any of the others. Signed-off-by: Mark Wielaard <[email protected]>