summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* libdbgserver: rename build_id_bytes parameter of dbgserver_find_*()dbgserver.demoAaron Merey2019-09-032-16/+16
| | | | | Renamed to build_id, since these functions can take both raw bytes and hex string representations of the build-id.
* dbgserver: post-0.177 merge tweaksFrank Ch. Eigler2019-09-032-7/+7
|
* dbgserver: add man pages for libdbgserver functionsAaron Merey2019-09-035-1/+79
|
* dbgserver-find: add executable and source lookup testsAaron Merey2019-09-031-1/+27
|
* dbgserver-find: exit early if no args given, add dbgserver-find testsAaron Merey2019-09-033-14/+42
|
* dbgserver: document controlling env vars as macros in -client.hFrank Ch. Eigler2019-09-034-6/+49
|
* dbgserver-find: tweak doc messageFrank Ch. Eigler2019-09-031-1/+1
|
* dbgserver: rpm source file indexing/serviceFrank Ch. Eigler2019-09-031-62/+93
|
* snapFrank Ch. Eigler2019-09-031-55/+253
|
* dbgserver: uniqueify -F and -R pathsFrank Ch. Eigler2019-09-032-6/+8
|
* dbgserver: garbage collect previous-schema-version tablesFrank Ch. Eigler2019-09-031-12/+15
|
* dbgserver: snapFrank Ch. Eigler2019-09-035-26/+116
| | | | | | | - support more specific posix error codes from dbgserver-find lookups - accept presence or absence of traling slash in DBGSERVER_URL - be able to run dbgserver-find.sh tests in check and installcheck mode - run installcheck tests in dbgserver proper, by adding argp to dbgserver-find.c
* elfutils-dbgserver prototype, squashed commitsFrank Ch. Eigler2019-09-0325-8/+3919
|
* config: Fix spec file, add manpages and new GFDL license.Mark Wielaard2019-08-295-6/+23
| | | | | | | | | Now that we have manpages lets also package them. Rename COPYING to COPYING-GFDL to make it not clash with the top-level COPYING file. Also fix up the spec file so it can be used to create a srpm again. Add eu-stack to the file list. Signed-off-by: Mark Wielaard <mark@klomp.org>
* readelf: Actually dump hex or strings when -p or -x get section number.Mark Wielaard2019-08-294-0/+17
| | | | | | | | The readelf code did parse section numbers, but then failed to actually dump the section found. Fixed by actually calling the dump function (either the hex or string variant). Add testcase for readelf -x num. Signed-off-by: Mark Wielaard <mark@klomp.org>
* nm: Fix latent memory leak in show_symbols.Mark Wielaard2019-08-292-1/+7
| | | | | | | | | | | | If there are just a handful of symbols then memory for them is allocated on the stack, otherwise the memory is malloced. So before freeing the memory we need to check the number of entries to know if the memory was heap allocated or not. But since not all entries might be used we might have decreased the number of entries to the number we will actually show. Remember the original symbol entries to not have a memory leak. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Use smaller self test files.Mark Wielaard2019-08-292-4/+10
| | | | | | Don't use the largest executables/libraries to reduce the make check time. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Don't use dlopen() for libebl modulesOmar Sandoval2019-08-2918-308/+200
| | | | | | | | | | | | Currently, architecture-specific code for libebl exists in separate libebl_$ARCH.so libraries which libebl loads with dlopen() at runtime. This makes it impossible to have standalone, statically-linked binaries which use libdwfl if they depend on any architecture-specific functionality. Additionally, when these libraries cannot be found, the failure modes are non-obvious. So, let's get rid of libebl_$arch.so and move it all into libdw.so/libdw.a, which simplifies things considerably. Signed-off-by: Omar Sandoval <osandov@fb.com>
* libasm: Link against libebl_pic.a.Mark Wielaard2019-08-282-1/+5
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* Add PIC and non-PIC variants of libcpu and libeblOmar Sandoval2019-08-288-9/+32
| | | | | | | | | Currently, libcpu and libebl are always compiled as PIC. An upcoming change will add the objects from libcpu.a and libebl.a to libdw.a, which should not be PIC unless configured that way. So, make libcpu.a and libebl.a non-PIC and add libcpu_pic.a and libebl_pic.a. Signed-off-by: Omar Sandoval <osandov@fb.com>
* libcpu: merge libcpu_{i386,x86_64,bpf} into one libraryOmar Sandoval2019-08-284-16/+16
| | | | | | | In preparation for combining the libebl backend modules, combine all of the libcpu backends into libcpu.a. Signed-off-by: Omar Sandoval <osandov@fb.com>
* libebl: remove unnecessary variable in Makefile.amOmar Sandoval2019-08-282-20/+23
| | | | | | | gen_SOURCES is assigned to libebl_a_SOURCES and never used again. Get rid of it. Signed-off-by: Omar Sandoval <osandov@fb.com>
* Add elfclassify to .gitignoreOmar Sandoval2019-08-281-0/+1
| | | | | | The tool was just added, but it's missing the ignore entry. Signed-off-by: Omar Sandoval <osandov@fb.com>
* Begin adding some docs to elfutilsBen Woodard2019-08-2712-18/+1319
| | | | | | | | | | | | | | | | | | | - Added doc/README - Updated doc/ChangeLog - Added a eu-readelf manpage based on the one from binutils. - Added a brand new manpage for eu-elfclassify the new utility. - Add some new files in the doc directory and sync makefile with upstream. - Reenable the compilation of doc directory. - Disable sgml file building - Build man pages the automake way Since V1 - Put man pages in the proper directories. - Added copy of Gnu Free Documentation License - Modified eu-readelf.1 man page to match the supported options. Signed-off-by: Ben Woodard <woodard@redhat.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: fix latent bug in dwarf_getcfi.c not setting default_same_value.Jonathon Anderson2019-08-262-0/+5
| | | | Signed-off-by: Jonathon Anderson <jma14@rice.edu>
* readelf: Add optional "SECTION" argument for --notes.Mark Wielaard2019-08-262-1/+19
| | | | | | | | | There are multiple sections that can contain ELF Notes. It is sometimes nice to just list the notes from a specific section. -n, --notes[=SECTION] Display the ELF notes Signed-off-by: Mark Wielaard <mark@klomp.org>
* config/elfutils.spec.in: package eu-elfclassifyDmitry V. Levin2019-08-152-0/+5
| | | | | | Package the new tool introduced by commit elfutils-0.177~1. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Prepare for 0.177elfutils-0.177Mark Wielaard2019-08-1312-2119/+2218
| | | | | | | | | Set version to 0.177. Update NEWS and elfutils.spec.in. Use git --get user.name and user.email for spec changelog. Regenerate po/*.po files. Signed-off-by: Mark Wielaard <mark@klomp.org>
* elfclassify: New tool to analyze ELF objects.Florian Weimer2019-08-137-5/+1433
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usage: elfclassify [OPTION...] FILE... Determine the type of an ELF file. All of the classification options must apply at the same time to a particular file. Classification options can be negated using a "--not-" prefix. Since modern ELF does not clearly distinguish between programs and dynamic shared objects, you should normally use either --executable or --shared to identify the primary purpose of a file. Only one of the --shared and --executable checks can pass for a file. If you want to know whether an ELF object might a program or a shared library (but could be both), then use --program or --library. Some ELF files will classify as both a program and a library. If you just want to know whether an ELF file is loadable (as program or library) use --loadable. Note that files that only contain (separate) debug information (--debug-only) are never --loadable (even though they might contain program headers). Linux kernel modules are also not --loadable (in the normal sense). Without any of the --print options, the program exits with status 0 if the requested checks pass for all input files, with 1 if a check fails for any file, and 2 if there is an environmental issue (such as a file read error or a memory allocation error). When printing file names, the program exits with status 0 even if no file names are printed, and exits with status 2 if there is an environmental issue. On usage error (e.g. a bad option was given), the program exits with a status code larger than 2. The --quiet or -q oose_filestion suppresses some error warning output, but doesn't change the exit status. Classification options --core File is an ELF core dump file --debug-only File is a debug only ELF file (separate .debug, .dwo or dwz multi-file) --elf File looks like an ELF object or archive/static library (default) --elf-archive File is an ELF archive or static library --elf-file File is an regular ELF object (not an archive/static library) --executable File is (primarily) an ELF program executable (not primarily a DSO) --library File is an ELF shared object (DSO) (might also be an executable) --linux-kernel-module File is a linux kernel module --loadable File is a loadable ELF object (program or shared object) --program File is an ELF program executable (might also be a DSO) --shared File is (primarily) an ELF shared object (DSO) (not primarily an executable) --unstripped File is an ELF file with symbol table or .debug_* sections and can be stripped further Input flags -f, --file Only classify regular (not symlink nor special device) files --no-stdin Do not read files from standard input (default) --stdin Also read file names to process from standard input, separated by newlines --stdin0 Also read file names to process from standard input, separated by ASCII NUL bytes -z, --compressed Try to open compressed files or embedded (kernel) ELF images Output flags --matching If printing file names, print matching files (default) --no-print Do not output file names --not-matching If printing file names, print files that do not match --print Output names of files, separated by newline --print0 Output names of files, separated by ASCII NUL Additional flags -q, --quiet Suppress some error output (counterpart to --verbose) -v, --verbose Output additional information (can be specified multiple times) -?, --help Give this help list --usage Give a short usage message -V, --version Print program version Report bugs to https://sourceware.org/bugzilla. Signed-off-by: Florian Weimer <fweimer@redhat.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdwelf: Make dwelf_elf_begin return NULL only when there is an error.Mark Wielaard2019-08-138-13/+45
| | | | | | | | | | | | | | | | | | | | | | | dwelf_elf_begin was slightly different from elf_begin in case the file turned out to not be an ELF file. elf_begin would return an Elf handle with ELF_K_NONE. But dwelf_elf_begin would return NULL. This made it impossible to tell the difference between a file or decompression error and a (decompressed) file not being an ELF file. Since dwelf_elf_begin could still return different kinds of ELF files (ELF_K_ELF or ELF_K_AR - and theoretically ELF_K_COFF) this was not really useful anyway. So make it so that dwelf_elf_begin always returns an Elf handle unless there was a real error reading or decompressing the file. Otherwise return NULL to make clear there was a real error. Make sure that the decompression function returns DWFL_E_BADELF only when the file isn't compressed. In which case the Elf handle won't be replaced and can be returned (as ELF_K_NONE). Add a new version to dwelf_elf_begin so programs can rely on it returning NULL only for real errors. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdwfl: Fix fd leak/closing wrong fd after dwfl_core_file_report()Omar Sandoval2019-08-092-0/+6
| | | | | | | | | | | | | | dwfl_segment_report_module() (used only by dwfl_core_file_report()) opens a file descriptor and/or an Elf handle, reports a module, and assigns mod->main.elf. However, it doesn't assign mod->main.fd, so it is left as 0. This causes two problems: 1. We leak the file descriptor for the module. 2. When we free the module, we close file descriptor 0 (stdin). Fix it by assigning mod->main.fd. Signed-off-by: Omar Sandoval <osandov@fb.com>
* Add backend support for C-SKYMao Han2019-07-1721-6/+692
| | | | | | | | | C-SKY V2 ABI manual: https://github.com/c-sky/csky-doc/blob/master/C-SKY_V2_CPU_Applications_Binary_Interface_Standards_Manual.pdf C-SKY architecture user guide: https://github.com/c-sky/csky-doc/blob/master/CSKY%20Architecture%20user_guide.pdf Signed-off-by: Mao Han <han_mao@c-sky.com>
* libdwelf: Add dwelf_elf_e_machine_string and use it in readelf.Mark Wielaard2019-07-1031-32/+576
| | | | | | | | | | | | | | | | To print eh human readable description of the ELF e_machine header field we used the ebl name. But this is not set for most EM constants. Introduce a new function dwelf_elf_e_machine_string that does work for all known EM values. Use that in eu-readelf to print a string representation of the e_machine value. Since this was the only usage of ebl->name, remove that from struct ebl. Also add a testcase that makes sure dwelf_elf_e_machine_string works for all EM values in the libelf/elf.h header so we will immediately notice when a new value appears. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Add 2GB to mem_needed running run-large-elf-file.sh with valgrindMark Wielaard2019-07-012-2/+13
| | | | | | Running under valgrind just requires even more free memory. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libelf: Fix some 32bit offset/size issues that break updating 4G+ files.Mark Wielaard2019-06-2815-52/+239
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some years ago, in commit b1d0b0fc "libelf: Use int64_t for offsets in libelf.h", we changed the public interface to use 64bit offsets/sizes. This wasn't really a API change, before we relied on loff_t always being 64bits on all platforms. We didn't change the implementation to use the int64_t type though. That was a little confusing, since the function definitions used a different type, int64_t, from the function implementations, off_t. Since we always build with _FILE_OFFSET_BITS=64 this should be fine. But it was a bit sloppy and confusing. Worse is that we got the translation of offset/sizes wrong in a couple of places when translating to ELF types. In various places we would use Elf32_Word or Elf64_Word. But both are 32bit (unsigned) types! As is GElf_Word. Elf32_Off is 32bits and Elf64_Off is 64bits. But we were not using those consistently. This patch introduces comments for the usage of [G]Elf(32|64)Word in libelf that are correct. And introduces Elf(32|64)_SizeWord in elf32_updatenull.c where we want to make a difference between sizes and offsets (the ELF variants are both unsigned, while int64_t/loff_t is signed). It also includes a new run-large-elf-file.sh test that creates a large ELF files (one 64bit, little endian, rel and another big endian, non-rel) and runs eu-strip, eu-elflint, eu-unstrip and eu-elfcmp. Before this patch, that test case fails and creates corrupt ELF files. The test is guarded by some checks that try to make sure there is enough disk space and memory available on the machine. The test is skipped otherwise. Signed-off-by: Mark Wielaard <mark@klomp.org>
* stack: Fix error message when dwfl_core_file_attach fails.Mark Wielaard2019-06-252-1/+5
| | | | | Reported-by: Mao Han <han_mao@c-sky.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* strip don't mmap debug output file.Mark Wielaard2019-06-242-1/+6
| | | | | | | | | | | | | | | | | Using ELF_C_WRITE_MMAP sometimes causes unexpected errors when disk space is low. When writing out the file, the output file is first extended so that it covers the whole file/mmap size. But it might be that the file system allowed the extension as a sparse file. In that case writing to the file through the mmap might still fail and produce a SIGBUS if the disk is full. This is confusing to the user. Using ELF_C_WRITE will produce "normal" errors when the file cannot be written out. It also seems to use less memory because the debug file is created from scratch. So the memory is first read into the ELF data structure buffers, then written out as a whole. In this case the mmap output buffer is just overhead. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: elfcopy --reverse-offs should only swap sections next to each other.Mark Wielaard2019-06-032-0/+6
| | | | | | | | | The run-reverse-sections-self.sh (which really should have been called "swap-sections") could fail if the ELF file had sections that were not directly next to each other swapped. Add a check to make sure the swapped sections are actually directly next to each other. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libebl: Try harder to find backend library in bin and lib origin paths.Mark Wielaard2019-05-302-47/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | eblopenbackend tries to find libraries based on the $ORIGIN/../$LIB/ path. But depending on whether the system is multilib or multiarch this doesn't always work. On multilib systems $LIB is always just one directory deep (it is either .../lib or .../lib64) but on multiarch systems it can be multiple directories deep (.../lib/x86_64-linux-gnu). This means that on multiarch systems $ORIGIN/../$LIB only works for binaries (where origin is .../bin/), but not for libraries. Most of the time it still works because of RPATH which is tried afterwards. But RPATH processing does not always work reliable. So try multiple paths first. The first time using the $ORIGIN as if it came from an executable (in bin/) and then using the $ORIGIN as if it came from an library (in lib[64]/ or lib/<arch>/). So first time using ../$LIB and second time just with the elfutils EBL_SUBDIR. The first is what we do now and always work on multilib systems. The second try works when loading relative to a library whether on a multilib or multiarch system. Then we use the same fallback (not using any path) we used already (to take advantage of any RPATH or LD_LIBRARY_PATH setting). https://sourceware.org/bugzilla/show_bug.cgi?id=24488 Signed-off-by: Mark Wielaard <mark@klomp.org>
* libelf: Mark shdr_flags dirty if offset or size changes during update.Mark Wielaard2019-05-168-10/+332
| | | | | | | | | | | | | | | We forgot to mark the shdr_flags dirty when only the sh_size or sh_offset changed during elf_update (). This meant that if there were no other shdr changes we only wrote out the section data, but didn't write out the shdr table to the file. Add a testcase that puts some sections in the reverse order and then writes out the resulting file again without doing any other updates. This would show the issue after write out of the (re-reversed) ELF file (the .shstrtab section offset would be wrong causing all section names to be garbage). Also run a self test. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Add DW_AT_GNU_numerator, DW_AT_GNU_denominator and DW_AT_GNU_bias.Mark Wielaard2019-05-162-0/+11
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=24550 Signed-off-by: Mark Wielaard <mark@klomp.org>
* readelf: Decode DW_AT_discr_list block attributes.Mark Wielaard2019-05-147-10/+453
| | | | | | | | | | | | | | | | Decode DW_AT_descr_list blocks using the DW_DSC values. This requires knowing the signedness of the discriminant. Which means the attr_callback function needs access to the parent DIE. Pass the whole DIE path, plus the current level. That way the type of the discriminant can be looked up in the variant_part (parent) DIE of the variant DIE (which has the discr_list attribute). Add a testcase using both signed and unsigned discriminants. https://sourceware.org/bugzilla/show_bug.cgi?id=24509 Signed-off-by: Mark Wielaard <mark@klomp.org>
* readelf: Clean up section lists after usage.Mark Wielaard2019-05-142-0/+19
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* lib/color: Fix compilation with uClibcRosen Penev2019-05-052-1/+5
| | | | | | | elfutils passed -Werror and this call errors on uClibc with a mismatching pointer type. Cast to char * to fix. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* libelf: Add n_namesz offset overflow check to gelf_get_note.Mark Wielaard2019-05-042-2/+8
| | | | | | | | | | During fuzzing of the new xlate_notes testcase I noticed that gelf_get_note didn't check whether the n_namesz of a note was too big. This could lead to offset wrapping around. Causing an infinite loop going over all ELF notes. Fix by adding an overflow check before updating offset. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libelf: If xlate can only convert the ELF note header, just do that.Mark Wielaard2019-05-046-5/+283
| | | | | | | | | | | | | | | | | When we started parsing new style ELF_T_NHDR8 notes we added extra checks on alignment and padding. When those failed we would stop converting and just return the rest of the ELF Note unconverted. In the case were we just had enough data for just the ELF Note header and the destionation and source weren't the same we would then accidentially throw away the Note header conversion we just did. Fix that by indicating we did correctly convert just the header. Adds testcase that compares parsing ELF notes with gelf_getnote and parsing the raw data by hand using elf32_xlatetom using just the Note header and ignoring the (raw) note data. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Don't printf a known NULL symname in backtrace-dwarf.c.Mark Wielaard2019-04-302-1/+6
| | | | | | | | | | GCC9 on 32bit systems might warn about '%s' directive argument is null for symname in backtrace-dwarf.c. Just check whether symname is NULL. This is an identical fix for the same issue as found in backtrace.c, but now in backtrace-dwarf.c Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Don't printf a known NULL symname.Mark Wielaard2019-04-302-1/+5
| | | | | | | GCC9 on 32bit systems might warn about '%s' directive argument is null for symname in backtrace.c. Just check whether symname is NULL. Signed-off-by: Mark Wielaard <mark@klomp.org>
* unstrip: Robustify gelf_getshdr and gelf_getsymshndx calls.Mark Wielaard2019-04-282-0/+10
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* size: Robustify against gelf_getshdr returning NULL.Mark Wielaard2019-04-282-0/+13
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>