Mark Wielaard [Thu, 29 Aug 2019 14:21:35 +0000 (16:21 +0200)]
tests: Use smaller self test files.
Don't use the largest executables/libraries to reduce the make check time.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Omar Sandoval [Mon, 26 Aug 2019 17:51:46 +0000 (10:51 -0700)]
Don't use dlopen() for libebl modules
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>
Mark Wielaard [Wed, 28 Aug 2019 21:55:24 +0000 (23:55 +0200)]
libasm: Link against libebl_pic.a.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Omar Sandoval [Mon, 26 Aug 2019 17:51:45 +0000 (10:51 -0700)]
Add PIC and non-PIC variants of libcpu and libebl
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>
Omar Sandoval [Mon, 26 Aug 2019 17:51:44 +0000 (10:51 -0700)]
libcpu: merge libcpu_{i386,x86_64,bpf} into one library
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>
Omar Sandoval [Mon, 26 Aug 2019 17:51:43 +0000 (10:51 -0700)]
libebl: remove unnecessary variable in Makefile.am
gen_SOURCES is assigned to libebl_a_SOURCES and never used again. Get
rid of it.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Omar Sandoval [Mon, 26 Aug 2019 17:58:31 +0000 (10:58 -0700)]
Add elfclassify to .gitignore
The tool was just added, but it's missing the ignore entry.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Ben Woodard [Fri, 23 Aug 2019 20:42:06 +0000 (13:42 -0700)]
Begin adding some docs to elfutils
- 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>
Jonathon Anderson [Sun, 25 Aug 2019 15:07:00 +0000 (10:07 -0500)]
libdw: fix latent bug in dwarf_getcfi.c not setting default_same_value.
Signed-off-by: Jonathon Anderson <jma14@rice.edu>
Mark Wielaard [Wed, 21 Aug 2019 10:28:56 +0000 (12:28 +0200)]
readelf: Add optional "SECTION" argument for --notes.
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>
Dmitry V. Levin [Wed, 14 Aug 2019 20:45:56 +0000 (23:45 +0300)]
config/elfutils.spec.in: package eu-elfclassify
Package the new tool introduced by commit elfutils-0.177~1.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Mark Wielaard [Tue, 13 Aug 2019 21:53:56 +0000 (23:53 +0200)]
Prepare for 0.177
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>
Florian Weimer [Tue, 13 Aug 2019 11:27:15 +0000 (13:27 +0200)]
elfclassify: New tool to analyze ELF objects.
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>
Mark Wielaard [Sun, 11 Aug 2019 22:43:22 +0000 (00:43 +0200)]
libdwelf: Make dwelf_elf_begin return NULL only when there is an error.
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>
Omar Sandoval [Mon, 5 Aug 2019 10:40:05 +0000 (03:40 -0700)]
libdwfl: Fix fd leak/closing wrong fd after dwfl_core_file_report()
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>
Mao Han [Tue, 16 Jul 2019 11:14:24 +0000 (19:14 +0800)]
Add backend support for C-SKY
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>
Mark Wielaard [Fri, 28 Jun 2019 17:21:59 +0000 (19:21 +0200)]
libdwelf: Add dwelf_elf_e_machine_string and use it in readelf.
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>
Mark Wielaard [Mon, 1 Jul 2019 15:08:43 +0000 (17:08 +0200)]
tests: Add 2GB to mem_needed running run-large-elf-file.sh with valgrind
Running under valgrind just requires even more free memory.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 24 Feb 2019 22:51:16 +0000 (23:51 +0100)]
libelf: Fix some 32bit offset/size issues that break updating 4G+ files.
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>
Mark Wielaard [Mon, 24 Jun 2019 22:21:42 +0000 (00:21 +0200)]
stack: Fix error message when dwfl_core_file_attach fails.
Reported-by: Mao Han <han_mao@c-sky.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 4 Mar 2019 19:04:18 +0000 (20:04 +0100)]
strip don't mmap debug output file.
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>
Mark Wielaard [Mon, 3 Jun 2019 16:00:20 +0000 (18:00 +0200)]
tests: elfcopy --reverse-offs should only swap sections next to each other.
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>
Mark Wielaard [Sat, 11 May 2019 14:55:01 +0000 (16:55 +0200)]
libebl: Try harder to find backend library in bin and lib origin paths.
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>
Mark Wielaard [Sat, 11 May 2019 22:37:45 +0000 (00:37 +0200)]
libelf: Mark shdr_flags dirty if offset or size changes during update.
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>
Mark Wielaard [Thu, 16 May 2019 15:20:35 +0000 (17:20 +0200)]
libdw: Add DW_AT_GNU_numerator, DW_AT_GNU_denominator and DW_AT_GNU_bias.
https://sourceware.org/bugzilla/show_bug.cgi?id=24550
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 5 May 2019 21:18:36 +0000 (23:18 +0200)]
readelf: Decode DW_AT_discr_list block attributes.
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>
Mark Wielaard [Thu, 9 May 2019 11:15:14 +0000 (13:15 +0200)]
readelf: Clean up section lists after usage.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Rosen Penev [Fri, 3 May 2019 17:59:55 +0000 (10:59 -0700)]
lib/color: Fix compilation with uClibc
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>
Mark Wielaard [Wed, 1 May 2019 13:52:24 +0000 (15:52 +0200)]
libelf: Add n_namesz offset overflow check to gelf_get_note.
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>
Mark Wielaard [Tue, 30 Apr 2019 11:00:17 +0000 (13:00 +0200)]
libelf: If xlate can only convert the ELF note header, just do that.
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>
Mark Wielaard [Tue, 30 Apr 2019 18:48:13 +0000 (20:48 +0200)]
tests: Don't printf a known NULL symname in backtrace-dwarf.c.
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>
Mark Wielaard [Tue, 30 Apr 2019 18:36:39 +0000 (20:36 +0200)]
tests: Don't printf a known NULL symname.
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>
Mark Wielaard [Sun, 28 Apr 2019 16:07:03 +0000 (18:07 +0200)]
unstrip: Robustify gelf_getshdr and gelf_getsymshndx calls.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Apr 2019 16:02:05 +0000 (18:02 +0200)]
size: Robustify against gelf_getshdr returning NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Apr 2019 15:51:06 +0000 (17:51 +0200)]
nm: Simplify naming of invalid sections, check shdr isn't NULL.
When shdr is NULL or the sh_name index is invalid, don't try to use
it. Just call the section "[invalid section name]". Don't try to be
too smart by creating a dynamic invalid name using alloca to simplify
memory usage in this exceptional case.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Apr 2019 15:06:50 +0000 (17:06 +0200)]
elfcmp: Handle bad sections without crashing.
If we cannot get the Shdr of a section then don't try to use or
compare them.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Apr 2019 11:40:45 +0000 (13:40 +0200)]
libebl: Check ebl is not NULL in ebl_symbol_[binding|type]_name.
For STB_GNU_UNIQUE and STT_GNU_IFUNC we need to check the elf of the
given ebl. Make sure the ebl given isn't NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Apr 2019 11:29:53 +0000 (13:29 +0200)]
libdwfl: Make sure to left shift a unsigned 64bit value in expr_eval.
In frame_unwind.c expr_eval we left shift 1 up to 56 bits. We have to
make sure we don't left shift a 32bit signed value (that would be
undefined behavior). So shift a 1ULL value instead.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Apr 2019 11:21:50 +0000 (13:21 +0200)]
libdwfl: Don't call realloc with zero in cu.c addraranges.
Calling realloc when naranges is zero will result is trying to free
aranges. If realloc does free aranges it returns NULL, which means
aranges is still assigned. This is likely not a problem, because in
most cases aranges will be NULL already. But if it was not and
naranges does turn out to be zero after reduction (which would be
invalid DWARF) we are left with a dangling pointer.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Apr 2019 11:04:28 +0000 (13:04 +0200)]
libdw: Remove unused variable initialization in dwarf_siblingof.
We immediately reassign the value of addr after declaration.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Apr 2019 10:42:04 +0000 (12:42 +0200)]
libdw: Call check_constant_offset with direct pointers.
In dwarf_getlocation_addr pass the pointers to llbufs and listlens
indirectly by passing a pointer to the first array element. Simplify the
code by passing the pointers directly.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sat, 27 Apr 2019 21:58:57 +0000 (23:58 +0200)]
libdw: Reject DW_OP_implicit_value in CFI.
When we encounter a DW_OP_implicit_value we call store_implicit_value ()
which will try to store the value as part of the Dwarf dbg. But if we are
examining CFI there will be no Dwarf dbg. And DW_OP_implicit_value should
not be part of CFI. So explicitly reject it in store_implicit_value if
dbg is NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 15 Apr 2019 14:07:34 +0000 (16:07 +0200)]
config: Add git tag --verify to upload-release.sh.
Add a check to make sure we have to correct (signed) tag.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 14 Apr 2019 20:40:53 +0000 (22:40 +0200)]
backends: riscv_cfi.c had a bad BACKEND define.
BACKEND should have been defined as riscv_ (not aarch64_).
Reported-by: Mao Han <han_mao@c-sky.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mao Han [Wed, 10 Apr 2019 07:51:48 +0000 (15:51 +0800)]
libelf: Sync elf.h from glibc
Signed-off-by: Mao Han <han_mao@c-sky.com>
Mark Wielaard [Wed, 3 Apr 2019 14:54:15 +0000 (16:54 +0200)]
readelf: Print DW_AT_data_member_location as decimal offset, not hex number.
The data_member_location attribute was printed as a hex number, but other
constant attributes like bit_offset, byte_size or alignment were printed
as decimal numbers. This is confusing.
The reason that data_member_location was printed as hex seemed to have
been because it could also have been a location description, in which
case it might have been of DW_FORM_loclist, for which it makes sense
to print as hex offset (between square brackets).
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 29 Mar 2019 09:53:27 +0000 (10:53 +0100)]
readelf: print_debug_macinfo_section, check cus[0] is not the sentinel.
If there are no CUs at all we can not find any CU DIE file.
https://sourceware.org/bugzilla/show_bug.cgi?id=24398
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 27 Mar 2019 21:32:21 +0000 (22:32 +0100)]
libdwfl: Sanity check partial core file phdrs data read.
When reading the phdrs data from the core file check if we got everything,
or just part of the data.
https://sourceware.org/bugzilla/show_bug.cgi?id=24387
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 27 Mar 2019 20:54:06 +0000 (21:54 +0100)]
strip: Files with symbols referring to non-existing sections are illformed
The check added in commit
4540ea98c "strip: Fix check test for SHN_XINDEX
symbol" was not complete. The (extended) section index should also exist.
If it doesn't exist, mark the file as illformed.
https://sourceware.org/bugzilla/show_bug.cgi?id=24385
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 7 Mar 2019 16:31:53 +0000 (17:31 +0100)]
libelf: Use posix_memalign instead of aligned_alloc.
Older glibc might not have aligned_alloc (it is C11).
Use posix_memalign instead. posix_memalign requires the alignment to
be a multiple of sizeof (void *). So use malloc for smaller alignments.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 6 Mar 2019 19:02:52 +0000 (20:02 +0100)]
libasm: Check return value of gelf_update_ehdr in asm_end.
In theory the gelf_update_ehdr call could fail. Immediately report an
error in that case.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 6 Mar 2019 18:56:54 +0000 (19:56 +0100)]
libelf: Fix possible resource leak in elf[32|64]_updatefile.
When we cannot allocate enough memory to convert the data in
updatemmap we should free the scns before returning an error.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 4 Mar 2019 19:10:35 +0000 (20:10 +0100)]
tests: Remove tgkill define from backtrace.c
tgkill is never used in the test and it might conflict with newer
glibc which might define tgkill themselves (just like gettid):
https://sourceware.org/bugzilla/show_bug.cgi?id=6399
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sat, 23 Feb 2019 19:44:24 +0000 (20:44 +0100)]
libelf: Remove unused __elf_xfctstof.
__elf_xfctstof is only used in case the memory size and file size of ELF
data structures are different. This is never the case.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 21 Feb 2019 23:28:01 +0000 (00:28 +0100)]
libelf: Remove unused internal __elf[32|64]_msize functions.
Those functions were intended for ELF versions where the memory and
file sizes of data structures are different. They were never used
because libelf depends on the file and memory sizes being equal
(otherwise using mmap wouldn't work).
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 3 Feb 2019 18:05:13 +0000 (19:05 +0100)]
libelf: There is just one ELF version.
Remove (partially defined out) code and data structures dealing with
multiple ELF versions. There hasn't been a new ELF version in the
last 20 years. Simplify the code a bit by just assuming there will
only be one version (EV_CURRENT == 1).
Simplifies elf_version, gets rid of __libelf_version_initialized.
Removes one (or more) array (version) dimension from various tables
and accessor functions (__elf_xfctstom, shtype_map, __libelf_data_type,
__libelf_type_aligns and __libelf_type_sizes).
Signed-off-by: Mark Wielaard <mark@klomp.org>`
Mark Wielaard [Sun, 3 Feb 2019 18:03:26 +0000 (19:03 +0100)]
libdwfl: Initialize notes early in intuit_kernel_bounds.
We fake initialization of notes with an empty asm statement. But
it is simpler and less confusing to just initialize notes just
before the fopen.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 19 Feb 2019 15:27:40 +0000 (16:27 +0100)]
libelf: Handle zero size decompressed data.
This is a corner case that will most likely never occur in practice,
but we have several testcases that compress and decompress zero sized
data. In that case during decompression we might malloc a buffer of
size zero. It is allowed for malloc to return NULL in that case. But
we do need a non-NULL buffer to return and set as result. So make sure
to always at least allocate one byte. Also make sure that we don't
allocate a zero sized conversion buffer for the data.
https://sourceware.org/bugzilla/show_bug.cgi?id=24000
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 15 Feb 2019 13:39:57 +0000 (14:39 +0100)]
s390: elflint should check if _GLOBAL_OFFSET_TABLE_ points to .got.
The _GLOBAL_OFFSET_TABLE_ symbol might point to the DT_PLTGOT,
which is in the .got section, even if the symbol itself is
associated with the .got.plt section.
See https://sourceware.org/ml/binutils/2018-07/msg00200.html
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 14 Feb 2019 12:29:39 +0000 (13:29 +0100)]
Prepare for 0.176
Set version to 0.176.
Update NEWS and elfutils.spec.in.
Update GPG-KEY.
Regenerate po/*.po files.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 14 Feb 2019 10:47:59 +0000 (11:47 +0100)]
libelf: Make sure ar_size is terminated when reading ar long names.
The ar_size is given as a fixed size decimal string, right padded with
spaces. Make sure we read it properly even if there is no terminating
space. Also sanity check len early if we can.
https://sourceware.org/bugzilla/show_bug.cgi?id=24085
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 1 Feb 2019 13:03:38 +0000 (14:03 +0100)]
libdw: Check there is enough space for CU 64bit length, version and type.
We only checked we could read the initial length and after knowing the
version and type whether the unit header was the right size. Also check
there are at least enough bytes to read the 64bit length, version and
unit type bytes.
https://sourceware.org/bugzilla/show_bug.cgi?id=24140
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 1 Feb 2019 08:08:14 +0000 (09:08 +0100)]
readelf: Check there is enough data to read DWARF line opcodes arguments.
When reading the debug_line opcode arguments we have to make sure there
is enough data to read the arguments (if there are any(.
The similar code in dwarf_getsrclines already had these checks.
https://sourceware.org/bugzilla/show_bug.cgi?id=24116
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 18 Jan 2019 13:18:22 +0000 (14:18 +0100)]
configure: Add new --enable-install-elfh option.
We explicitly test (with system-elf-libelf) that our include headers
work with the system elf.h header. But it might be helpful to install
the elf.h file for a private install. Our elf.h header really is just
a copy of the latest glibc elf.h. But it might be newer and include
more constants than the system installed elf.h.
Add a new configure option --enable-install-elfh to install elf.h.
But warn when it is enabled for the default /usr or /usr/local prefix
because it might clash with the glibc/system elf.h header in that case.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 31 Jan 2019 22:18:25 +0000 (23:18 +0100)]
tests: Remove assert (errno == 0) from tests.
When a function fails it might set errno. But it isn't a guarantee
that if a function succeeds that it sets errno to zero.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Yonghong Song [Tue, 29 Jan 2019 21:33:03 +0000 (13:33 -0800)]
tests: parse inode in /proc/pid/maps/correctly in run-backtrace-data.sh
The backtrace-data.c parsed the inode in /proc/pid/maps with
format "%*x".
This caused failure if inode is big. For example,
7f269223d000-
7f269226b000 r-xp
00000000 00:50
10224326387095067468 /home/...
The error likes below:
-bash-4.4$ cat run-backtrace-data.sh.log
backtrace-data: /home/engshare/elfutils/0.174/src/elfutils-0.174/tests/backtrace-data.c:110:
maps_lookup: Assertion `errno == 0' failed.
/home/engshare/elfutils/0.174/src/elfutils-0.174/tests/test-subr.sh: line 84:
3123578 Aborted (core dumped)
LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" $VALGRIND_CMD "$@"
data: no main
-bash-4.4$
The reason is errno is ERANGE.
Fix the test with inode format string "%*u" as inode here is presented
as decimal numbers.
Suggested-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Yonghong Song <yhs@fb.com>
Mark Wielaard [Tue, 29 Jan 2019 23:04:11 +0000 (00:04 +0100)]
libebl: Check GNU property note data padding fits inside note.
The GNU property note data is padded. Make sure the extra padding
still fits in the note description.
https://sourceware.org/bugzilla/show_bug.cgi?id=24075
Signed-off-by: Mark Wielaard <mark@klomp.org>
Yonghong Song [Fri, 25 Jan 2019 21:20:08 +0000 (13:20 -0800)]
libdwfl: parse inode in /proc/pid/maps correctly
The inode number in /proc/pid/maps is displayed as "unsigned long"
type.
In one of our x64 system, we have inode number exceeding valid "long"
type range, which caused the following test failure:
FAIL: dwfl-bug-fd-leak
FAIL: run-backtrace-dwarf.sh
FAIL: vdsosyms
The offending map entry:
7f269246b000-
7f269246c000 rw-p
0002e000 00:50
10224326387095067468 /home/...
This patch changed sscanf inode number type from PRIi64 to PRIu64
and fixed the problem.
Signed-off-by: Yonghong Song <yhs@fb.com>
Ulf Hermann [Thu, 17 Jan 2019 14:00:46 +0000 (15:00 +0100)]
tests: Use separate files for strip outputs
This way we can verify that strip actually created all of them.
Also, check that strip, unstrip, elflint actually succeed in
run-strip-test-many.sh. This exposed the fact that the generated
testfile in run-strip-test-many.sh is considered as illformed by
strip -g.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
Mark Wielaard [Thu, 24 Jan 2019 15:00:49 +0000 (16:00 +0100)]
strip: Fix check test for SHN_XINDEX symbol.
The check for whether a symbol used the extended section table was
wrong causing the run-strip-test-many.sh testcase to declare the
testfile was an illformed file.
Fixing this exposed a strict elfutils check for the '.shstrtab'
section having this exact name and a SHT_STRTAB type. This might
be a little too strict, but easily worked around by changing the
name of the "old" shstrtab section in the addsections program.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 22 Jan 2019 14:55:18 +0000 (15:55 +0100)]
readelf: Don't go past end of line data reading unknown opcode parameters.
https://sourceware.org/bugzilla/show_bug.cgi?id=24116
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 20 Jan 2019 21:10:18 +0000 (22:10 +0100)]
libdw: Check terminating NUL byte in dwarf_getsrclines for dir/file table.
For DWARF version < 5 the .debug_line directory and file tables consist
of a terminating NUL byte after all strings. The code used to just skip
this without checking it actually existed. This could case a spurious
read past the end of data.
Fix the same issue in readelf.
https://sourceware.org/bugzilla/show_bug.cgi?id=24102
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 20 Jan 2019 22:05:56 +0000 (23:05 +0100)]
libdwfl: Sanity check partial core file dyn data read.
When reading the dyn data from the core file check if we got everything,
or just part of the data.
https://sourceware.org/bugzilla/show_bug.cgi?id=24103
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 16 Jan 2019 14:41:31 +0000 (15:41 +0100)]
libebl: Check NT_PLATFORM core notes contain a zero terminated string.
Most strings in core notes are fixed size. But NT_PLATFORM contains just
a variable length string. Check that it is actually zero terminated
before passing to readelf to print.
https://sourceware.org/bugzilla/show_bug.cgi?id=24089
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 16 Jan 2019 11:25:57 +0000 (12:25 +0100)]
libelf: Correct overflow check in note_xlate.
We want to make sure the note_len doesn't overflow and becomes shorter
than the note header. But the namesz and descsz checks got the note header
size wrong). Replace the wrong constant (8) with a sizeof cvt_Nhdr (12).
https://sourceware.org/bugzilla/show_bug.cgi?id=24084
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 16 Jan 2019 10:57:35 +0000 (11:57 +0100)]
libebl: Check GNU property note pr_datasz fits inside note description.
Before printing the data values, make sure pr_datasz doesn't go beyond
the end of the note description data.
https://sourceware.org/bugzilla/show_bug.cgi?id=24075
Signed-off-by: Mark Wielaard <mark@klomp.org>
Ulf Hermann [Sun, 13 Jan 2019 22:14:35 +0000 (23:14 +0100)]
Skip run-readelf-compressed.sh test if built without bzip2
Obviously, we cannot read the compressed ELF file if no bzip2 support is
present.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
Jim Wilson [Thu, 27 Dec 2018 23:27:02 +0000 (15:27 -0800)]
RISC-V: Add untested 32-bit core file support.
Adds 32-bit support exactly the same way that the sparc backend handles
32- and 64-bit core file support. The 64-bit core file support was tested
and still works same as before.
Signed-off-by: Jim Wilson <jimw@sifive.com>
Jim Wilson [Thu, 27 Dec 2018 23:26:11 +0000 (15:26 -0800)]
RISC-V: Add initial return value location support.
Started with the aarch64 support and modified it for RISC-V. The
flattened structure support hasn't been written yet, but the rest of
it should be correct for the LP64D ABI. We have potentially 6 different
ABIs to support, so this requires checking elf header flags in riscv_init
when setting the hook.
Signed-off-by: Jim Wilson <jimw@sifive.com>
Jim Wilson [Thu, 27 Dec 2018 23:25:49 +0000 (15:25 -0800)]
RISC-V: Improve riscv64 core file support.
This fixes two problems. The offset for x1 is changed from 1 to 8 because
this is a byte offset not a register skip count. Support for reading the
PC value is added. This requires changing the testsuite to match the new
readelf output for coredumps.
Signed-off-by: Jim Wilson <jimw@sifive.com>
Mark Wielaard [Sun, 2 Dec 2018 23:03:39 +0000 (00:03 +0100)]
libebl: Fix reading GNU_PROPERTY_STACK_SIZE reading from 32bit notes.
When reading a GNU_PROPERTY_STACK_SIZE we need to use the proper data
type. GElf_Addr is 64bit always and when reading a 32bit size part of
it would not be initialized. Use either Elf32_Addr or Elf64_Addr to
read and print the data.
Add 32bit and 64bit, little and big endian testcases.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 28 Nov 2018 12:58:31 +0000 (13:58 +0100)]
tests: Improve backtrace-data SKIP message.
The backtrace-data testcase is x86_64 linux only because it uses its
own set_initial_registers and scans its own /proc/pid/maps file.
The SKIP message it gave on other platforms was misleading. It said
"Unwinding not supported for this architecture". Change it to
"x86_64 linux only test" to be less confusing.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 23 Nov 2018 20:10:27 +0000 (21:10 +0100)]
libdwfl: Fix relocation overlap sanity check.
We would not relocate when the relocation section data or the target
section date would overlap with one of the ELF headers. This is only
really necessary if the data comes directly from the mmapped file.
Otherwise there is no real overlap and the relocations can be safely
applied.
One particular thing we got wrong with the original sanity check was
when the relocation data or target data section was compressed. In
that case it could happen we overestimated the size (because the Shdr
would have been updated to show the uncompressed data size). But
uncompressed data is always malloced and so cannot overlap with the
mmapped Elf header structures.
When building with CFLAGS="-g -Og" this showed up as a failure in
run-strip-reloc.sh for strip-compressed.o. Where the .debug_loc
section decompressed would "overlap" with the shdrs at the end of
the file and so wouldn't get relocations applied.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 23 Nov 2018 19:50:51 +0000 (20:50 +0100)]
libdw: Enable building with -Og.
When building with -Og gcc is unable to see that __libdw_dieabbrev ()
will initialize what the second argument points to when no error occurs
as called by dwarf_child and dwarf_getattrs. Causing an possibly
uninitialized error. Just initialize readp/die_addr to NULL, which is
the value we would return if an error occurs anyway.
https://sourceware.org/bugzilla/show_bug.cgi?id=23914
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 21 Nov 2018 19:07:14 +0000 (20:07 +0100)]
tests: Call test_cleanup in backtrace-subr.sh check_unsupported.
We want to make sure all (temporary) test files are cleaned up even when
we exit 77 to skip the testcase.
https://sourceware.org/bugzilla/show_bug.cgi?id=23901
Tested-by: Kurt Roeckx <kurt@roeckx.be>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sat, 17 Nov 2018 23:21:49 +0000 (00:21 +0100)]
libelf: Get alignment correct when calling conversion functions.
When writing out data that needs to be converted we have to make sure
the conversion function is called on correctly aligned buffers. When
using mmap this might mean we have to convert into a temporarily buffer
if the user wants to write out the section at a location that is not
correctly aligned for the section type.
Older gas would generate misaligned ELF notes for the .version
directive. When copying over such notes using mmap from files with
a different endianness using mmap we would get the alignment of the
conversion destination wrong.
The new testcase would fail with configure --enable-sanitize-undefined
on little endian systems. The GCC undefinited sanitizer caught a similar
issue with testfile1 on big endian systems.
gelf_xlate.h:47:1: runtime error: member access within misaligned address
0x7f8145d770d5 for type 'struct Elf32_Nhdr', which requires 4 byte alignment
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 19 Nov 2018 10:46:46 +0000 (11:46 +0100)]
Add -Wtrampolines to CFLAGS.
elfutils uses nested functions a lot. This is fine unless one takes the
address of such a nested function. When taking the address of a nested
function a trampoline is generated that on some systems require the stack
to be executable. That is bad. We never want to generate such trampolines.
Add -Wtrampolines to CLAGS to make sure we don't.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 16 Nov 2018 11:52:00 +0000 (12:52 +0100)]
config/upload-release.sh: Need to make before make dist.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 16 Nov 2018 11:44:53 +0000 (12:44 +0100)]
Update upload-release.sh script and po files.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 16 Nov 2018 08:27:00 +0000 (09:27 +0100)]
libelf: Mark both fsize and msize with const attribute.
GCC9 -Wmissing-attributes pointed out that although we alias the fsize
and msize functions only fsize was marked as const. Fix by also marking
the msize definition as const.
https://sourceware.org/bugzilla/show_bug.cgi?id=23884
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 15 Nov 2018 14:53:41 +0000 (15:53 +0100)]
libebl: Don't update w, t and len unnecessarily in ebl_object_note_type_name.
Harmless, but useless.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 14 Nov 2018 12:12:24 +0000 (13:12 +0100)]
Prepare for 0.175
Set version to 0.175
Update NEWS and elfutils.spec.in.
Regenerate po/*.po files.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sat, 10 Nov 2018 22:33:03 +0000 (23:33 +0100)]
elflint: Allow PT_GNU_EH_FRAME segment to match SHT_X86_64_UNWIND section.
The gold linker might generate an .eh_frame_hdr with a SHT_X86_64_UNWIND
type instead of a SHT_PROGBITS type.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 13 Nov 2018 20:18:09 +0000 (21:18 +0100)]
libelf: Correctly setup alignment of SHF_COMPRESSED section data.
We didn't set the alignment of SHF_COMPRESSED sections correctly.
Those sections start with an Elf(32|64)_Chdr. Make sure sh_addralign
is setup to be able to read such a struct directly. Likewise don't
trust the alignment set on any SHF_COMPRESSED section, but always
make the (raw) compressed data aligned correctly for the reading the
Elf(32|64)_Chdr directly.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 9 Nov 2018 14:19:07 +0000 (15:19 +0100)]
strip: Also handle gnu compressed debug sections with --reloc-debug-sections
Check whether a section was gnu compressed and decompress it first
before trying to resolve relocations. Recompress it afterwards.
This found a bug in elf_compress_gnu which would use the "raw" file
contents even if the user had just created the section (copying over
the section from the original input file).
Add compressed ET_REL tests to run-strip-reloc.sh testcase.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 12 Nov 2018 22:34:24 +0000 (23:34 +0100)]
Handle GNU Build Attribute ELF Notes.
GNU Build Attribute ELF Notes are generated by the GCC annobin plugin
and described at https://fedoraproject.org/wiki/Toolchain/Watermark
Unfortunately the constants aren't yet described in the standard glibc
elf.h so they have been added to the elfutils specific elf-knowledge.h.
The notes abuse the name owner field to encode some data not in the
description. This makes it a bit hard to parse. We have to match the
note owner name prefix (to "GA") to be sure the type is valid. We also
cannot rely on the owner name being a valid C string since the attribute
name and value can contain zero (terminators). So pass around namesz
to the ebl note parsing functions.
eu-elflint will recognize and eu-readelf -n will now show the notes:
Note section [27] '.gnu.build.attributes' of 56080 bytes at offset 0x114564:
Owner Data size Type
GA 16 GNU Build Attribute OPEN
Address Range: 0x2f30f - 0x2f30f
VERSION: "3p8"
GA 0 GNU Build Attribute OPEN
TOOL: "gcc 8.2.1
20180801"
GA 0 GNU Build Attribute OPEN
"GOW": 45
GA 0 GNU Build Attribute OPEN
STACK_PROT: 0
GA 0 GNU Build Attribute OPEN
"stack_clash": TRUE
GA 0 GNU Build Attribute OPEN
"cf_protection": 0
GA 0 GNU Build Attribute OPEN
"GLIBCXX_ASSERTIONS": TRUE
GA 0 GNU Build Attribute OPEN
"FORTIFY": 0
GA 0 GNU Build Attribute OPEN
PIC: 3
GA 0 GNU Build Attribute OPEN
SHORT_ENUM: FALSE
GA 0 GNU Build Attribute OPEN
ABI:
c001100000012
GA 0 GNU Build Attribute OPEN
"stack_realign": FALSE
A new test was added to run-readelf -n for the existing annobin file.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 11 Nov 2018 22:50:41 +0000 (23:50 +0100)]
Recognize NT_VERSION notes.
NT_VERSION notes are emitted by the gas .version directive.
They have an empty description and (ab)use the owner name to store the
version data string.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 4 Nov 2018 20:34:38 +0000 (21:34 +0100)]
libcpu: Recognize bpf jump variants BPF_JLT, BPF_JLE, BPF_JSLT and BPF_JSLE
Linux kernel 4.13 introduced 4 more jump class variants.
commit
92b31a9af73b3a3fc801899335d6c47966351830
Author: Daniel Borkmann <daniel@iogearbox.net>
Date: Thu Aug 10 01:39:55 2017 +0200
bpf: add BPF_J{LT,LE,SLT,SLE} instructions
For conditional jumping on unsigned and signed < and <= between a register
and another register or immediate.
Add these new constants to bpf.h, recognize them in bpf_disasm and update
the testfile-bpf-dis1.expect file.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 21 Oct 2018 21:41:32 +0000 (23:41 +0200)]
libdwelf: New function dwelf_elf_begin.
This introduces a new function dwelf_elf_begin which creates a (read-only)
ELF handle from a possibly compressed file handle or a file that start
with a linux kernel header. This can be used in eu-readelf to (re)open a
(pure) ELF.
eu-readelf uses libdwfl to relocate addresses in the original file in
case it is ET_REL. But to show the "raw" data it might need to (re)open
the file. Which could fail if the file was compressed. And produced an
obscure error message: "cannot create EBL handle".
This rewrites __libdw_open_file a little so that the given file handle
will never be closed (whether on success or failure) and introduces a
new internal function __libdw_open_elf that dwelf_elf_begin wraps.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 6 Nov 2018 11:01:25 +0000 (12:01 +0100)]
backends: Add x86_64 section_type_name for SHT_X86_64_UNWIND.
Makes sure that eu-readelf and eu-elflint recognize and show the
x86_64 specific section type correctly.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Tested-by: Milian Wolff <milian.wolff@kdab.com>