| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When compiling with -O3 gcc finds an interesting error:
src/ar.c: In function ‘do_oper_insert’:
src/ar.c:1077:56: error: ‘%-*ld’ directive output may be truncated writing between 6 and 10 bytes into a region of size 7 [-Werror=format-truncation=]
snprintf (tmpbuf, sizeof (tmpbuf), ofmt ? "%-*lo" : "%-*ld", bufsize, val);
^~~~~
The problem is that the ar header values have to fit in a limited
(not zero terminated) string. We should check the snprintf return
value to see if the values are representable.
Also make ar valgrind and ubsan clean and add a minimal sanity test.
Reported-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
| |
Replace horizontal tab '\v' with double line feed '\n\n' in doc strings.
Regenerate .po files.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
| |
We don't know sizeof(pid_t) as it's not specified in any standard. In
order to still print it, we cast to long long, the largest integer type
we can easily print.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
| |
We assume core files from linux systems, so we should use the linux
version of the signals when reading them. Other OS might have different
signal numbers.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
| |
Accept version 5 .debug_macro format, which is identical to the GNU
version 4 format. No real support yet for the new supplementary object
file (sup) and indirect string references (strx). GCC doesn't generate
them yet. readelf does recognize them, but doesn't try to decode them.
dwarf_getmacros currently rejects the new formats.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
| |
Add DW_DEFAULTED_no, DW_DEFAULTED_in_class and DW_DEFAULTED_out_of_class
to dwarf.h.
Print value (no, in_class or out_of_class) of DW_AT_defaulted in readelf.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ARM data marker symbols "$d" indicate the start of a sequence of data
items in a section. For data only sections no data marker symbol is
necessary, but may be put pointing to the start of the section.
binutils however has a bug which places a data marker symbol somewhere
inside the section (at least for .debug_frame).
https://sourceware.org/bugzilla/show_bug.cgi?id=21809
When strip finds a symbol pointing to a debug section that would be
put into the .debug file then it will copy over the whole symbol table.
This isn't necessary because the symbol is redundant.
Add an ebl hook to recognize data marker symbols with implementations
for arm and aarch64. Use it in strip to strip such symbols from the
symbol table if they point to a debug section.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adds two new output options:
--keep-section=SECTION Keep the named section. SECTION is an extended
wildcard pattern. May be given more than once.
--remove-section=SECTION Remove the named section. SECTION is an
extended wildcard pattern. May be given more than
once. Only non-allocated sections can be removed.
The --remove-section was already partially implemented, but only for the
.comment section. The short option -R is to be compatible with binutils.
The new testcase makes sure that various combinations of kept/removed
sections pull the correct dependencies into the output and/or debug files.
https://bugzilla.redhat.com/show_bug.cgi?id=1465997
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If there was nothing to do strip would skip generating a separate
debug file if one was requested, but it would also not finish the
creation of a new output file (with the non-stripped sections).
Also if there was an error any partially created output would be kept.
Make sure that when the -o output file option is given we always generate
a complete output file (except on error). Also make sure that when the -f
debug file option is given it is only generated when it is not empty.
Add testcase run-strip-nothing.sh that tests the various combinations.
https://sourceware.org/bugzilla/show_bug.cgi?id=21522
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Although we always recreate the .shstrtab section for the new output
file we never explicitly assumed it could be removed. It might not be
possible to remove it when the section string table is shared with
a symbol table. But if it is removable we should (and recreate it for
the new section list).
Regression introduced in commit elfutils-0.163-33-gdf7dfab.
"Handle merged strtab/shstrtab string tables in strip and unstrip."
Add extra testcase to explicitly check for this case.
https://sourceware.org/bugzilla/show_bug.cgi?id=21525
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
| |
We cannot rely on it to be available from any of the other headers.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
| |
If shnum is 0, the many "shnum - 1" would result in an overflow. Check it
for 0, and only subtract once, rather than on every usage.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
| |
Those are deprecated and apparently some implementations of nl_langinfo
return empty strings for them. The tests even tested for those empty
strings even though the intention of the code was clearly to output
"yes" or "no" there.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
| |
Simply unconditionally uncompress any section to make sure indexes between
sections check out. Add some testcases with various compressed sections.
https://sourceware.org/bugzilla/show_bug.cgi?id=21332
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
| |
https://sourceware.org/bugzilla/show_bug.cgi?id=21320
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
| |
Make sure we can at least read the shnum sections or phnum segments.
Limit the number we do check to those we can actually read.
https://sourceware.org/bugzilla/show_bug.cgi?id=21312
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
| |
Calculate and use the expected entsize instead of relying on the one
given by the ELF file section header. Return early if there isn't enough
data in the section to check the full hash table.
https://sourceware.org/bugzilla/show_bug.cgi?id=21311
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
| |
Before checking symbol index zero we should make sure the data size
is big enough.
https://sourceware.org/bugzilla/show_bug.cgi?id=21310
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
| |
ELF notes can have a zero sized name. In which case there is no data at
all (so also no zero terminator). Make sure to use the empty string for
such notes if the code does not otherwise explicitly check n_namesz.
https://sourceware.org/bugzilla/show_bug.cgi?id=21300
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
| |
We sanity check to make sure we don't index outside the chain array
by testing inner > max_nsyms. But inner is a zero-based index, while
max_nsyms is the maximum number. Change the check to inner >= max_nsyms.
https://sourceware.org/bugzilla/show_bug.cgi?id=21299
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
| |
Rename version.c so that the implementation is called after the header
and the header doesn't clash with the toplevel version.h. print_version
depends on argp and is only used in the tools.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
| |
We only need it in nm.c and objdump.c, but it pulls in argp as
dependency. By dropping it from libeu.h, the libraries can be
compiled without argp.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Richard Henderson <rth@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>
|
|
|
|
|
| |
Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
We accidentally set force = true after handling -q and setting verbose--.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
| |
size_t has a different size on 32 and 64 bit systems.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
-z, --decompress Show compression information for compressed
sections (when used with -S).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|