Mark Wielaard [Thu, 4 Aug 2016 11:36:34 +0000 (13:36 +0200)]
Prepare 0.167 release.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 8 Jul 2016 12:08:22 +0000 (14:08 +0200)]
dwelf: Add string table functions from ebl.
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>
Mark Wielaard [Wed, 6 Jul 2016 16:27:54 +0000 (18:27 +0200)]
Remove eu-ld and unused code.
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>
Andreas Schwab [Sun, 10 Jul 2016 15:36:38 +0000 (17:36 +0200)]
Add m68k tests
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Mark Wielaard [Wed, 6 Jul 2016 19:31:54 +0000 (21:31 +0200)]
unstrip: Fix off by one array access with unstripped_strent.
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>
Mark Wielaard [Wed, 6 Jul 2016 13:27:56 +0000 (15:27 +0200)]
libelf: Allow updating phdrs for any e_type.
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>
John Ogness [Thu, 23 Jun 2016 14:03:58 +0000 (16:03 +0200)]
libelf: find 1st section instead of assuming
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>
Richard Henderson [Tue, 21 Jun 2016 22:10:10 +0000 (15:10 -0700)]
Add support for BPF
Signed-off-by: Richard Henderson <rth@redhat.com>
Richard Henderson [Tue, 21 Jun 2016 22:10:09 +0000 (15:10 -0700)]
Sync elf.h from glibc
Add lots of new EM_* definitions.
Add R_BPF_* definitions.
Signed-off-by: Richard Henderson <rth@redhat.com>
Mark Wielaard [Fri, 10 Jun 2016 12:03:15 +0000 (14:03 +0200)]
CONTRIBUTING: Extend patch, committer and maintainer guidelines.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Andreas Schwab [Fri, 20 May 2016 17:37:29 +0000 (19:37 +0200)]
Add support for m68k
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Filipe Brandenburger [Mon, 2 May 2016 20:26:13 +0000 (13:26 -0700)]
config: Pass the compiler -Werror during warning detection
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>
Filipe Brandenburger [Mon, 2 May 2016 19:18:47 +0000 (12:18 -0700)]
config: Fix check for argp_parse to pass &argv
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>
Mark Wielaard [Thu, 14 Apr 2016 19:53:33 +0000 (21:53 +0200)]
libdwfl: Fix memory leak in dwfl_module_getsrc_file on invalid DWARF.
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>
Mark Wielaard [Thu, 14 Apr 2016 19:32:55 +0000 (21:32 +0200)]
libdwfl: Fix memory leak in proc_maps_report on bad file mapping.
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>
Mark Wielaard [Thu, 14 Apr 2016 19:02:39 +0000 (21:02 +0200)]
libelf: Fix memory leak when zlib deflateInit fails in elf_compress.
On error we return NULL, not out_buf. So make sure to not leak it.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
David Abdurachmanov [Mon, 11 Apr 2016 14:00:57 +0000 (16:00 +0200)]
elfcmp: fix self-comparison error with GCC 6
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>
Mark Wielaard [Thu, 31 Mar 2016 09:04:25 +0000 (11:04 +0200)]
Prepare 0.166 release.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 21 Mar 2016 15:01:02 +0000 (16:01 +0100)]
nm: Check for malloc size argument overflow in show_symbols.
Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 2 Mar 2016 14:04:43 +0000 (15:04 +0100)]
config: Use --program-prefix=eu- by default.
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>
Steven Chamberlain [Tue, 1 Mar 2016 13:32:37 +0000 (13:32 +0000)]
libdwfl: clean up non-Linux GNU platforms code
For non-Linux GNU platforms (like kFreeBSD, Hurd), linux-pid-attach.c
had some stub functions that are not used or exported. Since gcc-6,
having these caused compiler errors due to -Wall -Werror:
linux-pid-attach.c:479:36: error: 'pid_thread_callbacks' defined but not used [-Werror=unused-const-variable=]
linux-pid-attach.c:474:1: error: 'pid_thread_detach' defined but not used [-Werror=unused-function]
linux-pid-attach.c:461:1: error: 'pid_detach' defined but not used [-Werror=unused-function]
linux-pid-attach.c:452:1: error: 'pid_set_initial_registers' defined but not used [-Werror=unused-function]
linux-pid-attach.c:441:1: error: 'pid_memory_read' defined but not used [-Werror=unused-function]
linux-pid-attach.c:420:1: error: 'pid_getthread' defined but not used [-Werror=unused-function]
linux-pid-attach.c:410:1: error: 'pid_next_thread' defined but not used [-Werror=unused-function]
This part of the source file is guarded by #ifndef __linux__
Signed-off-by: Steven Chamberlain <steven@pyro.eu.org>
Jose E. Marchesi [Fri, 26 Feb 2016 18:30:30 +0000 (10:30 -0800)]
sparc: restore 32-bit build.
This patch provides a dummy sparc_set_initial_registers-tid for
sparc32. This fixes the build in sparcv9-*-* targets.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Andreas Schwab [Fri, 26 Feb 2016 14:47:21 +0000 (15:47 +0100)]
Add support for DT_PPC_OPT
https://sourceware.org/ml/binutils/2013-10/msg00378.html
Signed-off-by: Andreas Schwab <schwab@suse.de>
Ravi Bangoria [Tue, 16 Feb 2016 16:21:35 +0000 (21:51 +0530)]
libdwfl: Check for kernel debuginfo file without .debug extension as well
Elfutils, looking for kernel debuginfo file, tries to find it at
various places. If elfutils finds /boot/vmlinu*x* file, it checks
for debufginfo section. If debuginfo is not present, it saves it as
'main elf' and continue looking for debuginfo file having .debug
extension i.e. vmlinux-RELEASE.debug.
'Ubuntu on powerpc' installs kernel as /boot/vmlinux and installs
debuginfo without any extension as /usr/lib/debug/boot/vmlinux-RELEASE
and hence, elfutils is not able to find the debuginfo file.
Here is the launchpad bug for the same:
https://bugs.launchpad.net/ubuntu/+source/systemtap/+bug/1537125
This patch adds functionality to search for a kernel or debuginfo file
both with and without .debug extension.
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 13 Feb 2016 19:00:37 +0000 (20:00 +0100)]
readelf: Warn when uncompressing fails and error when gelf_getshdr fails.
After decompressing we want to get the new shdr. This can theoretically
fail so we have to check. Also warn the user if a section couldn't be
uncompressed.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 13 Feb 2016 18:56:13 +0000 (19:56 +0100)]
elfcompress: -q should not imply --force.
We accidentally set force = true after handling -q and setting verbose--.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 13 Feb 2016 18:51:48 +0000 (19:51 +0100)]
libelf: Don't leak memory when out of memory in updatemmap.
We forgot to free scns when returning ELF_E_NOMEM.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 13 Feb 2016 18:48:57 +0000 (19:48 +0100)]
libdwfl: Don't leak memory in proc_maps_report when ENOEXEC.
We forgot to free last_file on error.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 13 Feb 2016 18:44:59 +0000 (19:44 +0100)]
libdwfl: Don't crash on out of memory when frame unwinding.
new_unwound didn't check whether malloc was successful. Check that we
could allocate memory before use and return DWFL_E_NOMEM otherwise.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 13 Feb 2016 18:36:50 +0000 (19:36 +0100)]
libdw: Fix bad free on invalid data in dwarf_getsrclines.c.
If the last dir name wasn't zero terminated we goto invalid_data
and might free the wrong data because we believe ndirlist is valid.
Don't update ndirlist until we are sure we will use all dirs.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 13 Feb 2016 18:10:00 +0000 (19:10 +0100)]
config: Check for and use gcc -Wnull-dereference.
-Wnull-dereference is new in GCC6
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 12 Feb 2016 22:59:32 +0000 (23:59 +0100)]
Fix GCC6 -Wnull-dereference warnings.
asm_begin.c: In function ‘asm_begin’:
asm_begin.c:62:7: error: potential null pointer dereference [-Werror=null-dereference]
__fsetlocking (result->out.file, FSETLOCKING_BYCALLER);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We set result to NULL just before this call in case of error.
Fixed by only calling __fsetlocking when result is not NULL.
strip.c: In function ‘handle_elf.constprop’:
strip.c:1270:31: error: null pointer dereference [-Werror=null-dereference]
elf_assert ((versiondata->d_size / sizeof (Elf32_Word))
~~~~~~~~~~~^~~
src/strip.c:597:37: note: in definition of macro ‘elf_assert’
#define elf_assert(test) do { if (!(test)) goto illformed; } while (0)
^~~~
That is the wrong check, we want to check shndxdata, not versiondata here.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 28 Jan 2016 12:59:20 +0000 (13:59 +0100)]
Add new i386 and x86_64 relocation types.
Update elf.h from glibc and recognize R_386_GOT32X, R_X86_64_GOTPCRELX
and R_x86_64_REX_GOTPCRELX as non-dynamic relocations.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 11 Feb 2016 12:20:59 +0000 (13:20 +0100)]
libdwfl: Check result of gelf_get* calls in relocate.c
For corrupted ELF files gelf_get calls might fail in which case it
is better to immediately return an error instead of using the NULL
result and crashing.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 11 Feb 2016 11:46:03 +0000 (12:46 +0100)]
libdwfl: Check result of gelf_update_* calls in relocate_section.
For corrupted ELF files the gelf_update calls might fail in which case it
is better to immediately return an error message instead of (silently)
continuing.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 9 Feb 2016 22:25:54 +0000 (23:25 +0100)]
readelf: Read and print (encoded) DW_CFA_set_loc op and update pc.
DW_CFA_set_loc takes an address as op, not an uleb128. Read and decode it.
Print the actual address and (updated) pc (address plus vma_base).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 12 Feb 2016 17:04:30 +0000 (18:04 +0100)]
Add NT_ARM_SYSTEM_CALL aarch64 syscall regset.
Linux kernel 3.18 added the NT_ARM_SYSTEM_CALL regset for aarch64.
Recognize and print this new core item.
https://bugzilla.redhat.com/show_bug.cgi?id=1285613
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 12 Feb 2016 14:04:00 +0000 (15:04 +0100)]
libebl: Don't assume ELF notes are "GNU" when unknown, recognize "Go" notes.
We used to assume any unknown ELF note provider name was "GNU" and didn't
recognize any of the "Go" provider types. We now check the provider name
explictly in ebl_object_note_type_name and recognize the following Go
note names: PKGLIST, ABIHASH, DEPS and BUILDID. But there is no attempt
yet in ebl_object_note to decode the description of these notes.
https://bugzilla.redhat.com/show_bug.cgi?id=1295951
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 9 Feb 2016 15:10:22 +0000 (16:10 +0100)]
config: Check for and use gcc -Wlogical-op and -Wduplicated-cond.
Both -Wlogical-op and -Wduplicated-cond may produce useful warnings.
But we have to check them first. Older versions of gcc had a -Wlogical-op
that warned on some constructs using macros that are not erronious.
Only GCC6 has -Wduplicated-cond.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 9 Feb 2016 13:18:49 +0000 (14:18 +0100)]
elflint: Fix sh_entsize check when comparing SHT_HASH and SHT_GNU_HASH.
GCC6 -Wduplicated-cond found the following issue:
elflint.c: In function ‘compare_hash_gnu_hash’:
elflint.c:2483:34: error: duplicated ‘if’ condition [-Werror=duplicated-cond]
else if (hash_shdr->sh_entsize == sizeof (Elf64_Word))
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
elflint.c:2448:29: note: previously used here
if (hash_shdr->sh_entsize == sizeof (Elf32_Word))
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Which is correct, a Word in both Elf32 and Elf64 files is 4 bytes.
We meant to check for sizeof (Elf64_Xword) which is 8 bytes.
Also fix the section index and name in the error message.
The reason we probably didn't see this issue before is that SHT_HASH
sections really always should have sh_entsize of 4 even on 64bit arches.
There are however a couple of arches with mistakes in their sysv ABI.
See libelf/common.h. This also would only be triggered if on such an
architectures when the ELF file would have both a SHT_HASH and SHT_GNU_HASH
section and elflint would try to compare those sections.
Add an example testfile-s390x-hash-both to run-elflint-test.sh.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 4 Feb 2016 08:53:41 +0000 (09:53 +0100)]
libelf: elf_getdata should not adjust alignment for SHT_NOBITS sections.
In commit c0748e "libelf: More checking of valid sh_addralign values." we
adjusted bogus alignment of data buffers if they were greater than the
offset of the data in the file. This works OK, except when there is no
data in the file. So make sure to not adjust any NOBITS sections.
Also adds a test that shows the issue and makes sure elflint is called
with --gnu in run-strip-test.sh.
https://bugzilla.redhat.com/show_bug.cgi?id=1303845
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Chih-Hung Hsieh [Fri, 22 Jan 2016 18:04:33 +0000 (10:04 -0800)]
Move nested functions in elf_compress.c and elf_strptr.c.
* elf_compress.c (__libelf_compress): do_deflate_cleanup
* elf_strptr.c (elf_strptr): get_zdata
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Mark Wielaard [Wed, 13 Jan 2016 22:06:33 +0000 (23:06 +0100)]
tests: Skip dwfl-bug-fd-leak test if dwfl_linux_proc_report is unsupported.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 13 Jan 2016 21:57:03 +0000 (22:57 +0100)]
elflint: Recognize ELFOSABI_FREEBSD which Debian kFreeBSD uses.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 13 Jan 2016 21:49:02 +0000 (22:49 +0100)]
tests: Guard linux specific header includes with ifdef __linux__.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mike Frysinger [Thu, 14 Jan 2016 18:46:18 +0000 (13:46 -0500)]
configure: clarify zlib error message
Also drop the spurious quotes.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Mike Frysinger [Thu, 14 Jan 2016 18:46:12 +0000 (13:46 -0500)]
gitignore: update
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Mark Wielaard [Wed, 13 Jan 2016 16:16:48 +0000 (17:16 +0100)]
libelf: Add ELF compression types and defines to libelf.h for older glibc.
Older glibc elf.h might not define the new ELF compression defines and
types. If not just define them in libelf.h directly to make the libelf
headers work on older glibc systems.
Also include a testcase to check the libelf headers build against the
system elf.h.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810885
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 11 Jan 2016 10:11:44 +0000 (11:11 +0100)]
Regenerate .po files.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 9 Jan 2016 21:09:48 +0000 (22:09 +0100)]
libebl: Fix missing brackets around if statement body.
GCC6 [will have] a nice new warning that showed a real bug:
elfutils/libebl/eblobjnote.c: In function ‘ebl_object_note’:
elfutils/libebl/eblobjnote.c:135:5: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
switch (type)
^~~~~~
elfutils/libebl/eblobjnote.c:45:3: note: ...this ‘if’ clause, but it is not
if (! ebl->object_note (name, type, descsz, desc))
^~
And indeed, it should have been under the if, but wasn't because of missing
brackets. Added brackets (and reindent).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 8 Jan 2016 20:55:58 +0000 (21:55 +0100)]
tests: Fix parentheses in elfputzdata strncmp test.
We were checking strlen () == 0 instead of strncmp () == 0. Oops.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 8 Jan 2016 15:45:12 +0000 (16:45 +0100)]
Fix build on 32bit systems.
size_t has a different size on 32 and 64 bit systems.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 8 Jan 2016 13:44:49 +0000 (14:44 +0100)]
Prepare 0.165 release.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 8 Jan 2016 12:35:33 +0000 (13:35 +0100)]
Simplify code and build now that zlib support is no longer optional.
Now that we always require zlib support we don't need to conditionally
build or compile code that depends on it.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Piotr Drąg [Thu, 7 Jan 2016 14:46:50 +0000 (15:46 +0100)]
Updated Polish translation
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
Piotr Drąg [Thu, 24 Dec 2015 13:16:15 +0000 (14:16 +0100)]
Updated Polish translation
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
Mark Wielaard [Tue, 1 Dec 2015 13:55:07 +0000 (14:55 +0100)]
elfcompress: New utility.
Usage: elfcompress [OPTION...] FILE...
Compress or decompress sections in an ELF file.
-f, --force Force compression of section even if it would
become larger
-n, --name=SECTION SECTION name to (de)compress, SECTION is an
extended wildcard pattern (defaults to
'.?(z)debug*')
-o, --output=FILE Place (de)compressed output into FILE
-p, --permissive Relax a few rules to handle slightly broken ELF
files
-q, --quiet Be silent when a section cannot be compressed
-t, --type=TYPE What type of compression to apply. TYPE can be
'none' (decompress), 'zlib' (ELF ZLIB compression,
the default, 'zlib-gabi' is an alias) or
'zlib-gnu' (.zdebug GNU style compression, 'gnu'
is an alias)
-v, --verbose Print a message for each section being
(de)compressed
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 18 Dec 2015 14:51:37 +0000 (15:51 +0100)]
elflint: Recognize and check SHF_COMPRESSED section flag.
SHF_COMPRESSED is a valid section flag, it can optionally be on any special
section, but it cannot be used on NOBITS sections or together with SHF_ALLOC.
A section that has SHF_COMPRESSED set must have a valid Chdr.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 30 Dec 2015 00:39:29 +0000 (01:39 +0100)]
libelf: Make elf_strptr index correctly into compressed section data.
elf_strptr indexes into the section data. This is defined as index into
the uncompressed data of the section. If the section is compressed make
sure the uncompressed data is available, but don't really decompress the
section header (elf_getdata will still return compressed data).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 20 Oct 2015 23:30:44 +0000 (01:30 +0200)]
readelf: Handle compressed sections and extend -z to cover -x and -p.
When printing a (non-string, non-data) section use uncompressed data when
possible. For dumping hex and string sections (-x and -p) -z will dump the
uncompressed data (otherwise the compressed data is dumped).
-z, --decompress Show compression information for compressed
sections (when used with -S); decompress section
before dumping data (when used with -p or -x)
Includes test cases for ET_REL files using compressed relocation (target)
debug sections to test libdwfl transparent uncompression of sections.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 30 Dec 2015 13:39:18 +0000 (14:39 +0100)]
libdwfl: Use elf_compress[_gnu] to decompress string, symbol and reloc data.
This makes usage of the libdwfl symbol functions work out of the box even
when some sections (string, symbol or xndx) are compressed. For ET_REL
files this makes relocations just work by making sure the target section
is decompressed first before relocations are applied.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 30 Dec 2015 13:18:40 +0000 (14:18 +0100)]
libdw: Use elf_compress[_gnu] to uncompress debug section data.
libdw used its own code for decompressing GNU style .zdebug sections.
Using elf_compress and elf_compress_gnu instead makes it possible to
transparently use either GNU style or ELF style compressed data.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Sat, 19 Dec 2015 00:29:54 +0000 (01:29 +0100)]
libelf: Add elf_compress and elf_compress_gnu.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Fri, 16 Oct 2015 20:21:23 +0000 (22:21 +0200)]
readelf: Add -z,--decompress option.
-z, --decompress Show compression information for compressed
sections (when used with -S).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 19 Nov 2015 23:12:37 +0000 (00:12 +0100)]
libelf: Add elf32_getchdr, elf64_getchdr and gelf_getchdr.
Elf_Data of a compressed section has type ELF_T_CHDR. This type can be
xlated to the file or memory representation. This will make sure the Chdr
is in the correct endianess. The compressed data following the Chdr isn't
translated.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 17 Nov 2015 22:52:39 +0000 (23:52 +0100)]
libdwelf: Add dwelf_scn_gnu_compressed_size.
Helper function to get the size of a GNU compressed zdebug section.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Mon, 4 Jan 2016 20:41:52 +0000 (21:41 +0100)]
config: Add libelf and libdw pkg-config files.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 31 Dec 2015 22:16:28 +0000 (23:16 +0100)]
elflint: Add _edata and _end to the list of possibly dangling gnuld symbols.
gnuld might keep dangling/unused symbols around (see sourceware PR13621).
Add _edata (end of initialized data address) and _end (end of uninitialized
data address) to that list. They might have been added by gnuld even if
there is no such [un]initialized data. Also add the double underscore
variants which are used on some architectures.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 31 Dec 2015 22:03:20 +0000 (23:03 +0100)]
tests: elfstrmerge warn about STT_SECTION symbol for shstrhndx.
Old linkers might have created an STT_SECTION symbol for the section
header string table section, which isn't actually used. For now just
warn about such symbols. If such a symbol would actually really be used
(but why?) then we would have to handle it by removing it and rewriting
the symbol table.
This is a testsuite only change, but includes an extra test with files
that have such STT_SECTION symbols to make sure it will be handled in
case we "upgrade" the elfstrmerge test to a real utility.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 31 Dec 2015 21:08:23 +0000 (22:08 +0100)]
Make make more silent.
Silent rules already are the default, but automake and make both still
tell which directory is being entered/build. Disable printing from make.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Chih-Hung Hsieh [Wed, 18 Nov 2015 19:04:52 +0000 (11:04 -0800)]
Move nested functions in linux-proc-maps.c to file scope.
* Move nested function 'report' to file scope to compile with clang.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Chih-Hung Hsieh [Wed, 18 Nov 2015 18:38:19 +0000 (10:38 -0800)]
Move nested functions in core-file.c to file scope.
* Move nested functions 'fail', 'update_end', and 'more' to file scope.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Chih-Hung Hsieh [Tue, 17 Nov 2015 22:45:15 +0000 (14:45 -0800)]
Move nested functions check64 and check32 in link_map.c to file scope.
* In libdwfl/link_map.c, nested functions check64, check32, are moved
to file scope to compile with clang.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jose E. Marchesi [Tue, 8 Dec 2015 18:10:43 +0000 (19:10 +0100)]
backends: sparc: support for live backtraces
This patch implements the set_initial_registers_tid hook for sparc.
It works in both sparcv9-*-* and sparc64-*-* targets.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Jose E. Marchesi [Tue, 8 Dec 2015 18:10:42 +0000 (19:10 +0100)]
backends: sparc: support for core backtraces
This patch adds sparc support to the unwinder, providing a default CFI
program that works in both sparcv9-*-* and sparc64-*-* targets.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Jose E. Marchesi [Tue, 8 Dec 2015 18:10:41 +0000 (19:10 +0100)]
libdwfl: make the unwinder aware of the backend defined ra_offset.
Ebl backends can define an offset that must be applied to the value of
the "return address register" defined in the CFI ABI information.
This patch makes the unwinder to use that offset when reading the RA
CFI register.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Jose E. Marchesi [Tue, 8 Dec 2015 18:10:40 +0000 (19:10 +0100)]
libebl: new backend attribute ra_offset.
Some backends need to fine-tune the return address as fetched from the
corresponding CFI register. This patch adds a new backend attribute
ra_offset and the corresponding ebl_ra_offset getter function.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Mark Wielaard [Wed, 2 Dec 2015 16:27:18 +0000 (17:27 +0100)]
tests: Use valgrind --leak-check=full.
When --enable-valgrind is given run the testsuite with --leak-check=full
treating any memory leak as a failure. Also disable valgrind for those
tests that trigger a valgrind bug.
https://bugs.kde.org/show_bug.cgi?id=327427
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 2 Dec 2015 16:07:40 +0000 (17:07 +0100)]
libdw: Don't leak duplicate FDEs.
Although it isn't supposed to happen there could be FDEs that cover the
same address range. Don't leak such FDEs and use an existing FDE for
consistency.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 2 Dec 2015 15:57:44 +0000 (16:57 +0100)]
nm: If the file is ET_REL and we need Dwarf use libdwfl to get it relocated.
If we need Dwarf and the file is ET_REL use the same trick as in readelf
to get a relocated Dwarf. Otherwise lots of references in the debug_info
will come out as zero.
This also explains the "bogus" Dwarf seen that caused the memory leak in
the local_root that was fixed previously.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 2 Dec 2015 15:44:42 +0000 (16:44 +0100)]
nm: Don't leak duplicate Dwarf local names.
Badly formed DWARF can have duplicate local names. In which case we do
want to detect those so we don't leak the memory.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Wed, 2 Dec 2015 14:44:10 +0000 (15:44 +0100)]
unstrip: Don't leak new section data.
When we copy elided sections some section data is newly allocated.
Track those allocations so we can free them when done.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 1 Dec 2015 23:21:07 +0000 (00:21 +0100)]
libdw: Don't use a FDE if it doesn't actually cover a real code range.
If the FDE end <= start then it doesn't actually cover a valid code range.
Don't use and cache such FDEs (it will cause memory leaks if there is
another FDE that has the same start address and a valid code range).
Such FDEs have been seen in the backtrace.ppc.exec testfile.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 1 Dec 2015 22:11:55 +0000 (23:11 +0100)]
libdwfl: Fix memory leak in link_map.c dwfl_link_map_report.
The phdrs buffer could come from the core file or through the executable.
dwfl_link_map_report would leak the buffer if it came from the executable.
Track where the buffer came from and free appropriately.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 1 Dec 2015 21:16:00 +0000 (22:16 +0100)]
libdwfl: Don't leak core Elf and core file descriptor from argp-std.
Our argp helper would leak the core Elf and core file descriptor when
given by the user. Store both in the Dwfl as a new Dwfl_User_Core so
they get cleaned up by dwfl_end.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 1 Dec 2015 14:55:08 +0000 (15:55 +0100)]
tests: Fix some memory leaks in testcases.
Make sure all structures allocated in the testcases are disposed so
running them under valgrind will show no memory leaks.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 1 Dec 2015 14:21:55 +0000 (15:21 +0100)]
libdw: Don't leak fake_loc_cu.
The fake_loc_cu is used when synthesizing attributes for Dwarf_Ops that
came from a location list entry in dwarf_getlocation_attr. Make sure
we remove the loc cache stored in it when disposing of the fake_loc_cu.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Tue, 1 Dec 2015 14:02:23 +0000 (15:02 +0100)]
elfcmp: Fix leaking Ebl handles.
open_file () explicitly gets Ebl handles for both Elf files to compare.
Make sure to close those when done.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Chih-Hung Hsieh [Tue, 17 Nov 2015 01:16:50 +0000 (17:16 -0800)]
Move nested functions in dwfl_module_getdwarf.c to file scope.
* In dwfl_module_getdwarf.c, nested functions 'consider_shdr'
and 'translate_offs' are moved to file scope to compile with clang.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Chih-Hung Hsieh [Tue, 17 Nov 2015 00:05:01 +0000 (16:05 -0800)]
Move nested functions in dwfl_module_addrsym.c to file scope.
* Move nested functions 'same_section', 'binding_value',
'try_sym_value', and 'search_table'.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Chih-Hung Hsieh [Wed, 14 Oct 2015 19:30:11 +0000 (12:30 -0700)]
Move nested functions in dwarf_entry_breakpoints.c to file scope.
No nested functions to compile with clang/llvm.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Chih-Hung Hsieh [Wed, 14 Oct 2015 19:23:34 +0000 (12:23 -0700)]
Move nested functions in libdw_visit_scopes.c to file scope.
* No nested functions to compile with clang/llvm.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard [Thu, 19 Nov 2015 11:37:08 +0000 (12:37 +0100)]
libdw: Make sure Ebl is always freed from cfi frame cache.
libdwfl sets the Dwfl_Module Ebl for the eh_cfi and dwarf_cfi cache to
save a bit of memory. It also calls ebl_closebackend on the ebl to free
it. The Dwarf_CFI never frees the Ebl in the cache, even when it opened
one itself. This means that if only libdw calls are used to access the
Dwarf_CFI the Ebl might be leaked.
Always destroy the Dwarf_CFI cache Ebl in __libdw_destroy_frame_cache.
And in __libdwfl_module_free clear the Dwarf_CFI Ebl if it is the
Dwfl_Module Ebl before calling dwarf_cfi_end and dwarf_end.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Dmitry V. Levin [Mon, 16 Nov 2015 15:11:23 +0000 (18:11 +0300)]
libdw: initialize state early in read_srclines
Starting with commit
f8443bd09f8a8d3d84a63e5ce206a218e57dff7a,
we might jump to "out" on error before initialization of "state".
Initialize "state" early to fix this issue.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Chih-Hung Hsieh [Tue, 13 Oct 2015 22:26:14 +0000 (15:26 -0700)]
No nested functions in dwarf_getsrclines.
Move nested functions in libdw/dwarf_getsrclines.c to file scope.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Chih-Hung Hsieh [Fri, 13 Nov 2015 19:48:07 +0000 (11:48 -0800)]
Move nested functions in gzip.c to file scope.
* libdwfl/gzip.c should now compile with clang.
All local variables used by nested functions are
passed in an unzip_state structure.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Chih-Hung Hsieh [Tue, 13 Oct 2015 22:26:14 +0000 (15:26 -0700)]
No nested function in dwarf_getscopevar to file scope.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Chih-Hung Hsieh [Wed, 21 Oct 2015 22:44:56 +0000 (15:44 -0700)]
Move nested functions in dwfl_module_getsrc_file.c.
* Nested functions in this file are moved to file scope
to compile with clang. Extra parameters are added to pass
local variables.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Chih-Hung Hsieh [Thu, 22 Oct 2015 00:12:44 +0000 (17:12 -0700)]
Move nested functions in frame_unwind.c.
* Nested functions 'pop' and 'push' in libdwfl/frame_unwind.c
are moved to file scope. Used local variables are passed in
struct eval_stack.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Chih-Hung Hsieh [Wed, 21 Oct 2015 22:44:56 +0000 (15:44 -0700)]
Move nested functions in dwfl_module.c
* Nested functions in this file are moved to file scope
to compile with clang. Extra parameters are added to pass
local variables.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>