summaryrefslogtreecommitdiffstats
path: root/src/ChangeLog
Commit message (Collapse)AuthorAgeFilesLines
* elflint: Recognize ELFOSABI_FREEBSD which Debian kFreeBSD uses.Mark Wielaard2016-01-181-0/+4
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Fix build on 32bit systems.Mark Wielaard2016-01-081-0/+5
| | | | | | size_t has a different size on 32 and 64 bit systems. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elfcompress: New utility.Mark Wielaard2016-01-061-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* elflint: Recognize and check SHF_COMPRESSED section flag.Mark Wielaard2016-01-061-0/+8
| | | | | | | | 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>
* readelf: Handle compressed sections and extend -z to cover -x and -p.Mark Wielaard2016-01-061-0/+13
| | | | | | | | | | | | | | | 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>
* readelf: Add -z,--decompress option.Mark Wielaard2016-01-061-0/+8
| | | | | | | -z, --decompress Show compression information for compressed sections (when used with -S). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elflint: Add _edata and _end to the list of possibly dangling gnuld symbols.Mark Wielaard2016-01-051-0/+5
| | | | | | | | | | 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>
* nm: If the file is ET_REL and we need Dwarf use libdwfl to get it relocated.Mark Wielaard2016-01-021-0/+10
| | | | | | | | | | | 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>
* nm: Don't leak duplicate Dwarf local names.Mark Wielaard2016-01-021-0/+4
| | | | | | | 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>
* unstrip: Don't leak new section data.Mark Wielaard2016-01-021-0/+10
| | | | | | | 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>
* elfcmp: Fix leaking Ebl handles.Mark Wielaard2016-01-021-0/+4
| | | | | | | 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>
* Make zlib mandatory.Mark Wielaard2015-10-261-0/+5
| | | | | | Explicitly link libelf and libdw with -lz. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elflint: Don't check shdr or TLS symbol offsets against debuginfo phdrs.Mark Wielaard2015-10-161-0/+7
| | | | | | | | | | | | In debuginfo files the phdrs file offsets match those of the original ELF file. So the section header file offsets and the TLS symbol value offset in debuginfo files cannot be sanity checked against the phdrs file offset. The issue can be triggered with run-strip-strmerge.sh test when configured with --enable-gcov. Which will insert a .tbss section and TLS symbols that trigger the above checks. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elflint: Reject mergable string sections as relocation target.Mark Wielaard2015-10-161-0/+5
| | | | | | | | Mergable sections can be the target of a relocation, but only if they contain items of the same size. So only reject mergable string sections as target of a relocation section. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Do not rely on ebl_check_special_section when checking debuginfo files.Jose E. Marchesi2015-10-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | The test run-strip-strmerge.sh is failing in sparc targets. This is because it does an `elflint -d' in a debuginfo file, and this fails with: section [21] '.plt' is both executable and writable elflint uses the ebl_check_special_section hook (implemented only by the alpha and sparc backends) in order to determine whether an executable+writable section must be flagged or not. In both cases the hook will fail analyzing eu-strip debuginfo files (as they should, because debuginfo files are broken ;). This patch just modifies elflint to not use the hook when -d is specified in the command-line. This fixes the test in sparc-* and sparc64-* targets (and presumably in alpha* targets too). Additionaly, the patch checks that the type of WE sections in debuginfo files is NOBITS. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* elflint: Check relro flags are a subset of the load segment.Mark Wielaard2015-10-131-0/+5
| | | | | | | | | If the RELRO segment doesn't fully overlap with the load segment then the load segment might have more flags sets. This happens for example on sparc when the .plt, which is executable, is also part of the load segment that RELRO covers. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* ldlex: Fix sign-compare warning, suppress -Wstack-usage.Mark Wielaard2015-10-121-0/+5
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-091-0/+17
| | | | | | | | | | | | | | | AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS in config.h if needed for LFS, and this automatically maps things like open to open64. But quite a few places used explicit 64-bit names, which won't work on platforms like FreeBSD where off_t is always 64-bit and there are no foo64 names. It's better to just trust that AC_SYS_LARGEFILE is doing it correctly. But we can verify this too, as some file could easily forget to include config.h. The new tests/run-lfs-symbols.sh checks all build targets against lfs-symbols (taken from lintian) to make sure everything was implicitly mapped to 64-bit variants when _FILE_OFFSET_BITS is set. Signed-off-by: Josh Stone <jistone@redhat.com>
* Move recursive nested function to file scope.Chih-Hung Hsieh2015-10-091-0/+5
| | | | | | Prepare src/ld.c to compile with clang. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* strip: Only sanity check symbols to not discarded sections for debug file.Mark Wielaard2015-10-091-0/+5
| | | | | | | | | | | | | | We can only sanity check the symbols to discarded sections when creating a debug file. Otherwise we won't keep track of debug_data. This can trigger erroneously when there are relocation symbols in the symtab for a .debug section but we are not putting those symbols in a separate .debug file. Adjust run-strip-test.sh to always run in-place strip size check even for ET_REL files. Before this fix the sanity check would trigger for some ET_REL files because they contained such relocation symbols to .debug sections (but debug_data would be NULL because -f wasn't used). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Allocate exact amount of bytes for phdrs and shdrs.Mark Wielaard2015-10-081-0/+6
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Do without union of variable length arrays.Chih-Hung Hsieh2015-10-071-0/+8
| | | | | | | | | | | | | | Prepare to compile with clang. A union like { T32 a32[n]; T64 a64[n]; } u; is expanded to size_t nbytes = n * MAX(sizeof(T32), sizeof(T64)); void *data = malloc(nbytes); T32 (*a32)[n] = data; T64 (*a64)[n] = data; Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* Improve AM_SILENT_RULES coverageJosh Stone2015-10-061-0/+6
| | | | | | | | | | | Note, elfutils does not explicitly enable AM_SILENT_RULES. It's only available starting from automake 1.11, but starting from automake 1.13 silent rules are always generated, defaulting to verbose. $(AM_V_foo) additions should be no-ops on systems that don't support silent rules. To be silent, use "./configure --enable-silent-rules" or "make V=0". Signed-off-by: Josh Stone <jistone@redhat.com>
* unstrip: Update sh_info when SH_INFO_LINK_P not just when SHF_INFO_LINK setMark Wielaard2015-10-051-0/+5
| | | | | | | | | | | SHF_INFO_LINK is not consistently set when sh_info is actually a section index reference. Use SH_INFO_LINK_P to check whether to update the sh_info value. SH_INFO_LINK_P also checks the section type to know whether or not sh_info is meant as section index. Found by run-strip-strmerge.sh test with older binutils. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Handle merged strtab/shstrtab string tables in strip and unstrip.Mark Wielaard2015-10-051-0/+7
| | | | | | | | | | | | | | | | | | | | | ELF files can share the section header string table (e_shstrndx) with the symtab .strtab section. That might in some cases save a bit of space since symbols and sections might share some (sub)strings. To handle that eu-strip just needs to not unconditionally remove the .shstrtab section (it will be properly marked as used/unused as needed). eu-unstrip needs to make sure the section names are added to the strtab if it decides to rewrite that section. Also makes sure that eu-strip won't move around a SHT_NOBITS section that has SHF_ALLOC set. Although it is allowed to move such sections around, there is no benefit. And some tools might expect no allocated section to move around, not even a nobits section. It also makes it harder to do "roundtripping" sanity checks that make sure splitting a file with eu-strip and then reconstructed with eu-unstrip produce the same ELF file (as is done in the new run-strip-strmerge.sh). Introduces a somewhat large test generator elfstrmerge.c that will hopefully turn into a more generic string table merger program. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Remove old-style function definitions.Mark Wielaard2015-09-231-0/+4
| | | | | | | We already require -std=gnu99 and old-style function definitions might hide some compiler warnings. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Initialize variable before use.Chih-Hung Hsieh2015-09-101-0/+6
| | | | | | Some compiler does not know that error function never returns. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* Replace printf %Z length modifier with %z.Chih-Hung Hsieh2015-09-071-0/+25
| | | | | | | | %Z is a GNU extension predating the ISO C99 %z modifier supported by libc5 and no longer recommended. Signed-off-by: Chih-Hung Hsieh <chh@google.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* readelf: handle_core_item large right shift triggers undefined behaviour.Mark Wielaard2015-09-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | The problem is this: int n = ffs (w); w >>= n; The intent is to shift away up to (and including) the first least significant bit in w. But w is an unsigned int, so 32 bits. And the least significant bit could be bit 32 (ffs counts from 1). Unfortunately a right shift equal to (or larger than) the length in bits of the left hand operand is undefined behaviour. We expect w to be zero afterwards. Which would terminate the while loop in the function. But since it is undefined behaviour anything can happen. In this case, what will actually happen is that w is unchanged, causing an infinite loop... gcc -fsanitize=undefined will catch and warn about this when w = 0x80000000 https://bugzilla.redhat.com/show_bug.cgi?id=1259259 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elflint: Add gnuld check when a NOBITS section falls inside a segment.Mark Wielaard2015-08-171-0/+5
| | | | | | | | | | | | gnuld has a really bad bug where it can place a NOBITS section inside a PT_LOAD segment. Normally that would not work. But it also makes sure that the contents of the file is all zeros. So in practice it is actually a PROGBITS section with all zero data. Except that other tools will think there is an unused gap in the ELF file after the NOBITS section. Recognize and check this pattern in elflint when --gnu is given. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* unstrip: Handle debuginfo files with missing SHF_INFO_LINK section flags.Mark Wielaard2015-08-031-0/+9
| | | | | | | | | | | | | | | | With GCC 5 there might be a .rela.plt section with SHF_INFO_LINK set. Buggy binutils objdump might strip it from the section in the debug file. Ignore such differences for relocation sections and put the flag back if necessary. Also improve the error message a little by only discarding the already matched sections if there is an prelink undo section. Otherwise we will report all sections as not matching if the file wasn't prelinked instead of just the non-matching sections. New testfiles generated by gcc5 and binutils objdump added. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* strings: Define MAP_POPULATE if not defined alreadyPino Toscano2015-06-271-0/+4
| | | | | | Currently it is available on Linux only, and it is more an hint. Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
* nm: First call elf_getdata, then allocate memory.Mark Wielaard2015-06-271-0/+4
| | | | | | | | This catches bogus data early before we might try to allocate giant amounts of memory. Reported-by: Hanno Böck <hanno@hboeck.de> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* findtextrel: Don't leak memory in process_file.Mark Wielaard2015-06-191-0/+4
| | | | | | | | | | | | When a files do contain textrels we fail to release the segments searched and valgrind will show: 2,560 bytes in 16 blocks are definitely lost in loss record 1 of 1 at 0x40281B5: malloc (in vgpreload_memcheck-x86-linux.so) by 0x804AE63: process_file (findtextrel.c:322) by 0x804909B: main (findtextrel.c:149) Signed-off-by: Mark Wielaard <mjw@redhat.com>
* readelf: Make sure phdr2_mem lifetime/scope equals phdr2 pointer.Mark Wielaard2015-06-191-0/+5
| | | | | | | We dont' want GCC to dispose or reuse phdr2_mem stack memory while phdr2 is pointing to it. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* readelf: Don't leak memory on failure path in handle_gnu_hash.Mark Wielaard2015-06-191-0/+4
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elflint: Only check the PT_TLS phdr if it actually exists, warn otherwise.Mark Wielaard2015-06-191-0/+5
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* nm: Fix typo in size check to determine whether we stack allocated memory.Mark Wielaard2015-06-191-0/+5
| | | | | | | | | We allocate GElf_SymX entries, which are larger than plain GElf_Sym structs. The check to see whether we could use stack allocation used the correct sizeof (GElf_SymX), but the check to see if we needed to free was using the incorrect sizeof (GElf_Sym). Which could cause us to leak memory. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* strings: Handle failure of getting section name on bogus section data.Mark Wielaard2015-06-191-0/+5
| | | | | | | | If there is something wrong with getting the section data it is likely we won't be able to get the actual section name because the file is somehow corrupted. Try to get the name, but handle failure gracefully. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: Fix memory leak in print_dwarf_function.Mark Wielaard2015-06-101-0/+5
| | | | | | Always free the scopes returned by dwarf_getscopes () when done. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* strip: Just admit we don't support stripping ar archives for now.Mark Wielaard2015-06-101-0/+5
| | | | | | | | | | | | | We try to handle (in-place) stripping of ar archives, but since elf_clone doesn't really support cloning ar members and we don't handle reducing the size of the members, moving the offsets of other members. This causes crashes or writing garbage. Better to just admit that for now we don't support stripping archives. Call error when we see an ELF_K_AR file. https://bugzilla.redhat.com/show_bug.cgi?id=766156 https://lists.fedorahosted.org/pipermail/elfutils-devel/2009-August/000567.html Signed-off-by: Mark Wielaard <mjw@redhat.com>
* elfcmp: Don't call memcmp with possible NULL d_buf.Mark Wielaard2015-06-051-0/+4
| | | | | | When d_size is zero d_buf might be NULL. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* config: Add -Wstack-usage=262144 (256K) warning check.Mark Wielaard2015-05-271-0/+5
| | | | | | | | All library code now builds with this warning and -Werror enabled. Add exceptions for most of the src tools (ldgeneric, readelf, nm, size, strip, elflint, findtextrel, elfcmp objdump, ranlib, ar and unstrip). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: Set scopes to NULL after free in handle_address.Mark Wielaard2015-05-271-0/+4
| | | | | | | If dwarf_getscopes_die () fails then scopes might not be reset and we could cause a double free. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: Add --pretty-print option to show all information on one line.Mark Wielaard2015-05-271-0/+10
| | | | | | | | | | | | | | | | | | This adds an option --pretty-print to eu-addr2line to show all information on one line and all inlines on a line of their own. This mimics the same option from binutils addr2line, but without the short option variant -p. Since we already use -p to select the process. Example output: eu-addr2line --pretty-print -s -i -f -C -p$(pidof firefox) 0x00007f368c6f8915 mozilla::ReentrantMonitor::Wait(unsigned int) at ReentrantMonitor.h:92 (inlined by) mozilla::ReentrantMonitorAutoEnter::Wait(unsigned int) at ReentrantMonitor.h:190 A couple of tests were added to check the output matches that of binutils addr2line. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: Add demangler support.Mark Wielaard2015-05-271-0/+15
| | | | | | | Makes the -C, --demangle option visible and implements it (ignoring the demangle style argument). Adds a new test with sample output. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: Add -a, --address. Print address before for each entry.Mark Wielaard2015-05-271-0/+8
| | | | | | Adds test cases with sample output. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: Always parse addresses as hex numbers.Mark Wielaard2015-05-271-0/+5
| | | | | | | | We would sometimes interpret input addresses as decimal or octal. That could be confusing and isn't what binutils addr2line does. Be consistent and always treat input addresses as hex. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: Split options in input and output format groups.Mark Wielaard2015-05-271-0/+5
| | | | | | | This makes it clear that -j, --section=NAME is about how input is treated, not how the output is formatted. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* strip: Harden against bogus input files. Don't leak tmp debug file on error.Mark Wielaard2015-05-181-0/+13
| | | | | | | | | | There were various places where a bogus/unexpected input file would cause eu-strip to crash. Also on an unexpected error eu-strip would leak the temp debug file it was writing. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c34 Signed-off-by: Mark Wielaard <mjw@redhat.com>