summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Prepare for elfutils 0.168 release.elfutils-0.168Mark Wielaard2016-12-2711-5199/+5191
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* 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 <mark@klomp.org>
* 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 <akihiko.odaki.4i@stu.hosei.ac.jp> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* 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 <mjw@redhat.com>
* 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 <mjw@redhat.com>
* 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 <mjw@redhat.com>
* 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 <mjw@redhat.com>
* 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 <mjw@redhat.com>
* 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 <mjw@redhat.com>
* 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 <mjw@redhat.com>
* 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 <cernekee@chromium.org>
* 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 <cernekee@chromium.org>
* 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 <akihiko.odaki.4i@stu.hosei.ac.jp> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* 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 <akihiko.odaki.4i@stu.hosei.ac.jp>
* 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 <mjw@redhat.com>
* 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 <hasufell@posteo.de> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Fix --enable-gcov tests build. Add libdw to LDADD for asm_tsts.Mark Wielaard2016-08-302-9/+13
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Regenerate .po files.elfutils-0.167Mark Wielaard2016-08-265-10/+10
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* 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 <mjw@redhat.com>
* strip: Use ELF_CHF_FORCE to recompress any sections that were uncompressed.Mark Wielaard2016-08-252-1/+5
| | | | | | | | Older gcc might create small .debug_pubtype. If such a section is compressed then strip should use ELF_CHF_FORCE to return it to compressed state after it is done with the section. Found by the run-strip-reloc.sh testcase on rhel6. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Regenerate .po files.Mark Wielaard2016-08-246-101/+568
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Add testfilesparc64attrs.o.bz2 to EXTRA_DIST.Mark Wielaard2016-08-242-0/+5
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* sparc: fix the printing of hw capabilities object attributes.Jose E. Marchesi2016-08-245-24/+81
| | | | | | | | | | The GNU_Sparc_HWCAPS and GNU_Sparc_HWCAPS2 object attributes comprise a set of hardware capabilities that may (or not) be present in the target machine for which the object was compiled. This patch adds the support for printing a nicely formatted comma-separated list with the selected hw capabilities. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* Updated Polish translationPiotr Drąg2016-08-191-757/+405
| | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1368130 Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
* Add --add-comments to XGETTEXT_OPTIONS in MakevarsPiotr Drąg2016-08-191-1/+2
| | | | | | | | So that translator comments show up in .po files. https://bugzilla.redhat.com/show_bug.cgi?id=1368130 Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
* Update POTFILES.inPiotr Drąg2016-08-191-0/+1
| | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1368130 Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
* libdwfl: Fix assert and set in.d_size in dwfl_link_map_report.Mark Wielaard2016-08-152-2/+9
| | | | | | | | | | | | When reading the phdrs from a core file segment fails we would try to read them from the exec. This fallback path contained a faulty assert that the requested size of the phdrs was still setup. But the core file reading callback might have reset the d_size value to zero on error. So explicitly set the number of bytes we want to read again instead of asserting the size. https://bugzilla.redhat.com/show_bug.cgi?id=1365812 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Fix memory leak in elf_compress for mmapped ELF files.Mark Wielaard2016-08-154-6/+24
| | | | | | | | | | | | | | | | The testcase added to run-strip-reloc.sh for strip-compressed.o showed a memory leak when ran under valgrind (configure --enable-valgrind). For a mmapped ELF file when existing section data was compressed elf_end would fail to release the new compressed data buffer assigned to rawdata_base. For non-mapped files rawdata_base is always freed. For decompressed data rawdata_base is released together with zdata_base. Use the Elf_Scn flag ELF_T_MALLOCED to track whether rawdata_base points to malloced memory and free it in elf_end even for mmapped ELF files. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* strip: Handle compressed relocation target sections.Mark Wielaard2016-08-154-5/+38
| | | | | | | | | | | | | | | binutils 2.27 assembler will create compressed sections for x86 ELF targets. The linker will decompress them again and it doesn't do this for any other target. This broke one of the run-strip-reloc.sh self tests. Fix by checking if the target of a relocation section is compressed and first decompressing it before applying relocations and then compressing again if necessary. Add explicit testcases for compressed and uncompressed ET_REL files to run-strip-reloc.sh. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Fix bpf disassembler for _FORTIFY_SOURCERichard Henderson2016-08-114-175/+378
| | | | | | | | It's illegal to skip positional operands for printf. Rearrange the printing of the instructions to use exactly the operands required. Also, fix printing of mod operations: s/%/%%/ in the print format. Also, fix printing of endian operations: remove extra spaces.
* Prepare 0.167 release.Mark Wielaard2016-08-0411-4315/+2795
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* dwelf: Add string table functions from ebl.Mark Wielaard2016-08-0332-231/+369
| | | | | | | | | | | | | | | | Move the strtab functions from libebl to libdw. Programs often want to create ELF/DWARF string tables. We don't want (static) linking against ebl since those are internal functions that might change. This introduces dwelf_strtab_init, dwelf_strtab_add, dwelf_strtab_add_len, dwelf_strtab_finalize, dwelf_strent_off, dwelf_strent_str and dwelf_strtab_free. Documentation for each has been added to libdwelf.h. The add fucntion got a variant that takes the length explicitly and finalize was changed to return NULL on out of memory instead of aborting. All code and tests now uses the new functions. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Remove eu-ld and unused code.Mark Wielaard2016-08-0337-14131/+72
| | | | | | | | Nobody has hacked on eu-ld in a very long time. It didn't really work. And we didn't install it by default in the spec file. Remove sources, the build rules and any (now) unused code. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Add m68k testsAndreas Schwab2016-07-1113-6/+134
| | | | Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
* unstrip: Fix off by one array access with unstripped_strent.Mark Wielaard2016-07-112-3/+8
| | | | | | | | | | When configuring with --enable-sanitize-undefined the latest GCC found an array out of bounds access when running the un-strip-strmerge.sh test. We keep an array of section names. But skipped section zero, since it didn't have a name. We should however not actually skip the first array index (zero) when storing and reading the names. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Allow updating phdrs for any e_type.Mark Wielaard2016-07-117-43/+249
| | | | | | | | | | | | | | | | | | | | | | | | elf[32|64]_updatenull would sanity check the e_type before allowing to update the phdrs. This prevents creating an ET_REL file with phdrs. It also prevents creating any vendor specific ELF file having phdrs. We only check this when updating/writing out the file. But we would just read such files. Don't prevent people from creating unexpected ELF files. elflint will warn for such files. While writing a new testcase for this another bug was found that prevented updating a just created phdr because elf_getphdrnum would sanity check the phdr offset in the file (which doesn't exist yet). Fix that by only doing such a sanity check if the phdrs haven't been read in or created yet. This second bug should have been found by the existing elfshphehdr test, but that test contained a typo checking elf_getphdrnum. It tested that the called failed when there were no phdrs, but then elf_getphdrnum should simply succeed and return zero. https://bugzilla.redhat.com/show_bug.cgi?id=1352232 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: find 1st section instead of assumingJohn Ogness2016-06-286-25/+320
| | | | | | | | | | | | | | | | | | When getting section headers it is assumed that the first section is on the first section list. However, it is possible that the first section list only contains the zeroth section, in which case either illegal memory access occurs or elf_nextscn() erroneously returns NULL. With this patch, checks are added to avoid the illegal memory access and (if available) the second section list is looked at to find the first section. A new test emptyfile is added that tests adding a section to and "empty" ELF file 32/64 class with ELF_C_RDWR[_MMAP]. Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Add support for BPFRichard Henderson2016-06-2824-10/+590
| | | | Signed-off-by: Richard Henderson <rth@redhat.com>
* Sync elf.h from glibcRichard Henderson2016-06-282-83/+202
| | | | | | | Add lots of new EM_* definitions. Add R_BPF_* definitions. Signed-off-by: Richard Henderson <rth@redhat.com>
* CONTRIBUTING: Extend patch, committer and maintainer guidelines.Mark Wielaard2016-06-212-0/+57
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Add support for m68kAndreas Schwab2016-05-2311-4/+550
| | | | Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
* config: Pass the compiler -Werror during warning detectionFilipe Brandenburger2016-05-032-3/+6
| | | | | | | | | | | | | | Otherwise the compilation prints a warning but exits with 0 return code. However, later during the compilation, when -Werror is enforced to about every file, the unsupported options start breaking the builds. Tested: Ran configure with clang-3.5 and built libelf/ tree with it. $ autoreconf -i $ ./configure CC=clang-3.5 ... $ make -C libelf Signed-off-by: Filipe Brandenburger <filbranden@google.com>
* config: Fix check for argp_parse to pass &argvFilipe Brandenburger2016-05-022-1/+5
| | | | | | | | | | | | | | | | | | | Right now it's passing a char* when it expects a char** instead. This usually produces a warning that may go unnoticed, but if CFLAGS contains -Werror, that breaks the ./configure run with the following error: $ ./configure CFLAGS=-Werror ... configure: WARNING: "libc does not have argp" checking for argp_parse in -largp... no configure: error: "no libargp found" Tested: Checked that after this fix, running ./configure CFLAGS=-Werror works as expected and argp_parse is correctly detected. Signed-off-by: Filipe Brandenburger <filbranden@google.com>
* libdwfl: Fix memory leak in dwfl_module_getsrc_file on invalid DWARF.Mark Wielaard2016-04-142-0/+7
| | | | | | | If we allocated the match results array ourselves, then free it when we detect invalid DWARF and return an error. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Fix memory leak in proc_maps_report on bad file mapping.Mark Wielaard2016-04-142-1/+9
| | | | | | | Normally last_file is freed inside report(), but in the case of a bad file mapping we don't call report. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Fix memory leak when zlib deflateInit fails in elf_compress.Mark Wielaard2016-04-142-0/+6
| | | | | | On error we return NULL, not out_buf. So make sure to not leak it. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elfcmp: fix self-comparison error with GCC 6David Abdurachmanov2016-04-112-1/+5
| | | | | | | | | | | | Noticed with Fedora 24 Alpha, gcc (GCC) 6.0.0 20160406 (Red Hat 6.0.0-0.20). elfcmp.c: In function ‘main’: elfcmp.c:364:199: error: self-comparison always evaluates to false [-Werror=tautological-compare] if (unlikely (name1 == NULL || name2 == NULL Signed-off-by: David Abdurachmanov <davidlt@cern.ch>
* Prepare 0.166 release.elfutils-0.166Mark Wielaard2016-03-3110-2786/+2863
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* nm: Check for malloc size argument overflow in show_symbols.Mark Wielaard2016-03-212-0/+9
| | | | | Reported-by: Florian Weimer <fweimer@redhat.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* config: Use --program-prefix=eu- by default.Mark Wielaard2016-03-023-0/+23
| | | | | | | | | | | | We want eu- as default program prefix if none was given by the user. But if the user explicitly provided --program-prefix="" then pretend it wasn't set at all (NONE). This makes sure all tools will be installed as eu-<program>. We want this default since most tools would normally conflict with the GNU binutils variants that have similar names. Signed-off-by: Mark Wielaard <mjw@redhat.com>