| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fedorahosted used to be our home, but we are now hosted at sourceware.
Change the elfutils project home to http://elfutils.org/
Point hosted services (email, release, git, bug tracker and web pages)
to https://sourceware.org/elfutils/
Move design notes from README to NOTES.
Add URLs for home, releases, bugs, git and mailinglist to README.
Make the --version output of all tools the same by using a common
print_version function and update the publicly shown copyright holder
to the elfutils developers.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
|
|
| |
unsigned long int is not always capable to have pointer in some cases
(LLP64, for example). Return a void pointer instead. Other libelf
implementations will also make this change (or already have).
Also update the documentation to state what is created and that NULL
is returned on error (don't document that the returned value is a
pointer to the actual header created).
Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
Older versions of glibc included an fts implementation that didn't have
Large File System support. We worked around that in linux-kernel-modules.c
by including it early before config.h and then redefining some symbols
to get the 64-bit versions. This is somewhat fragile and not necessary
with newer glibc. If possible we want the 64bit fts version always.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
| |
Make it possible to display just the symbols from a named symbol section
instead of always displaying all symbol sections.
https://bugzilla.redhat.com/show_bug.cgi?id=1396092
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
GCC7 adds warnings for snprintf formatting into too small buffers.
Fix the two issues pointed out by the new warning. The ar header
fields are fixed length containing left-justified strings without
zero terminator. snprintf always adds a '\0' char at the end (which
we then don't copy into the ar header field) and numbers are decimal
strings of fixed 10 chars (-Wformat-length thinks formatting
them as size_t might overflow the buffer on 64bit arches).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
Bad sh_off or sh_size could trigger a bad malloc or read. Sanity check
the header values first before trying to malloc a huge buffer or reading
any data that will certainly fail.
https://bugzilla.redhat.com/show_bug.cgi?id=1387584
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are various sanity checks that depend on knowing the file size
of the underlying ELF file which we only used when mmapping the ELF file.
Although we probably won't crash if we use pread to try to read from
the file, we still might return completely bogus data structures. This
could cause us to malloc insane amounts of memory.
Always try to get the maxsize when unknown in elf_begin.c (read_file).
https://bugzilla.redhat.com/show_bug.cgi?id=1388057
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
| |
The name used in the standard and other DWARF implementations for
Programming Language One, PL/I, is DW_LANG_PLI (not DW_LANG_PL1).
Fix usage in dwarf_aggregate_size.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
| |
GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one
small buglet in elflint option procession. So it seems useful to enable
to make sure all swatch case fallthroughs are deliberate.
Add configure check to detect whether gcc support -Wimplicit-fallthrough
and enable it. Add fixes and explicit fallthrough comments where necessary.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
Current unstrip test cases either have no .symtab/.strtab in the
stripped binary, or .strtab sections that are identical between the
stripped and debuginfo binaries. Add a test case where .symtab/.strtab
in the stripped binary contains a small subset of the full unstripped
data.
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prematurely matching up the stripped and unstripped .strtab sections
in the "Match each debuginfo" loop can lead to a case where sec->outscn
gets populated for the stripped .strtab, which we normally want to
ignore. This causes the .strtab override in the "Make sure each main
file section" loop to be skipped, so the code winds up using indices
from the unstripped .symtab to look up strings in the stripped .strtab.
This returns incorrect strings for a little while, and then fails
catastrophically when it tries to read past the end of the (smaller)
stripped file's .strtab section:
eu-unstrip: invalid string offset in symbol [1589]
Fix this by adding logic to the "Match each debuginfo" loop to
treat the unstripped .strtab, .shstrtab, and .symtab sections
essentially the same way.
The new logic will break if the .strtab section shows up earlier than
the .symtab section. We will assume this never happens in practice.
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
|
|
|
|
|
|
|
|
| |
Define/open code memrchr, rawmemchr, powerof2 and TEMP_FAILURE_RETRY if
not available through system headers.
Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
This change also creates a new header file libeu.h to provide the
prototypes for the function of libeu. That hides the definition of function
crc32, which can conflict with zlib, from libelf. It also prevents mistakes
to refer those functions from a component which doesn't link with libeu,
such as libelf.
Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Having a symbol in an allocated symbol table (like .dynsym) that
points to an unallocated section is wrong. Traditionally strip
has removed such symbols if they are section or group symbols.
But removing a real symbol from an allocate symbol table is hard
and probably a mistake. Really removing it means rewriting the
dynamic segment and hash sections. Since we don't do that, don't
remove the symbol (and corrupt the ELF file). Do warn and set
the symbol section to SHN_UNDEF.
https://bugzilla.redhat.com/show_bug.cgi?id=1380961
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
| |
Before linux 3.20 the BPF_PSEUDO_MAP_FD constant wasn't defined.
Reported-by: Julian Ospald <hasufell@posteo.de>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
| |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
| |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The backtrace-native[-biarch] testcase was a little too clever in places
making it unreliable.
On x86_64 we tried to make an interesting backtrace by catching the
first signal and then replacing the pc with the address of the first
instruction of a function. Then we would raise a new signal, through
ptrace, to create a backtrace that went from a signal frame into a
frame at the start of a function. That way we could check that we were
trying to fetch the correct CFI for the (jmp) function even at the
first instruction (normally we would substract one from the return
address to get at the call address).
This works as long as the CFI for the jmp() function is identical to
the CFI for the raise() function that we "patched away". Unfortunately
on Fedora rawhide glibc has a rewritten raise() implementation that has
different CFI, in particular the CFA is calculated differently. Making
the testcase fail because we cannot properly unwind from jmp().
So this special x86_64 case has been disabled (the code is still there
in case we find another way to test this in a more reliable way).
On Ubuntu there have been spurious testcase failures because
see_exec_module found two Dwfl_Modules with the same path. This would
trigger an assert. Although this might indicate some issue (maybe we
are not parsing the proc/pid/map correctly?) it isn't clear that it
really is a bug. Since the assert is not very helpful finding any
actual bug and for the testcase it is only necessary that the first
Dwfl_Module that represents the executable is found we just pick that
Dwfl_Module and don't iterate through any of the others.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
| |
Older gcc might create small .debug_pubtype. If such a section is compressed
then strip should use ELF_CHF_FORCE to return it to compressed state after it
is done with the section. Found by the run-strip-reloc.sh testcase on rhel6.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
| |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
| |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
The GNU_Sparc_HWCAPS and GNU_Sparc_HWCAPS2 object attributes comprise
a set of hardware capabilities that may (or not) be present in the
target machine for which the object was compiled. This patch adds the
support for printing a nicely formatted comma-separated list with the
selected hw capabilities.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
|
|
|
|
|
|
| |
https://bugzilla.redhat.com/show_bug.cgi?id=1368130
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
|
|
|
|
|
|
|
|
| |
So that translator comments show up in .po files.
https://bugzilla.redhat.com/show_bug.cgi?id=1368130
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
|
|
|
|
|
|
| |
https://bugzilla.redhat.com/show_bug.cgi?id=1368130
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
When reading the phdrs from a core file segment fails we would try to read
them from the exec. This fallback path contained a faulty assert that the
requested size of the phdrs was still setup. But the core file reading
callback might have reset the d_size value to zero on error. So explicitly
set the number of bytes we want to read again instead of asserting the size.
https://bugzilla.redhat.com/show_bug.cgi?id=1365812
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The testcase added to run-strip-reloc.sh for strip-compressed.o showed
a memory leak when ran under valgrind (configure --enable-valgrind).
For a mmapped ELF file when existing section data was compressed
elf_end would fail to release the new compressed data buffer assigned
to rawdata_base. For non-mapped files rawdata_base is always freed.
For decompressed data rawdata_base is released together with zdata_base.
Use the Elf_Scn flag ELF_T_MALLOCED to track whether rawdata_base
points to malloced memory and free it in elf_end even for mmapped
ELF files.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
binutils 2.27 assembler will create compressed sections for x86 ELF
targets. The linker will decompress them again and it doesn't do this
for any other target. This broke one of the run-strip-reloc.sh self tests.
Fix by checking if the target of a relocation section is compressed and
first decompressing it before applying relocations and then compressing
again if necessary.
Add explicit testcases for compressed and uncompressed ET_REL files
to run-strip-reloc.sh.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
| |
It's illegal to skip positional operands for printf. Rearrange the
printing of the instructions to use exactly the operands required.
Also, fix printing of mod operations: s/%/%%/ in the print format.
Also, fix printing of endian operations: remove extra spaces.
|
|
|
|
| |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Richard Henderson <rth@redhat.com>
|
|
|
|
|
|
|
| |
Add lots of new EM_* definitions.
Add R_BPF_* definitions.
Signed-off-by: Richard Henderson <rth@redhat.com>
|
|
|
|
| |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
| |
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
On error we return NULL, not out_buf. So make sure to not leak it.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
| |
Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|