summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'elfutils-0.170'Ulf Hermann2017-08-173-51/+306
|\ | | | | | | | | | | elfutils 0.170 release Change-Id: I37d03645902b9f0a9fb708af1551db8843537799
| * libdw: Add DW_MACRO constants and DW_MACRO_GNU compatibility defines.Mark Wielaard2017-08-022-16/+86
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * Handle DWARF5 defaulted member function encodings.Mark Wielaard2017-08-022-0/+35
| | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * strip: Deal with ARM data marker symbols pointing to debug sections.Mark Wielaard2017-07-242-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * strip: Add --keep-section=SECTION and --remove-section=SECTION.Mark Wielaard2017-07-172-17/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * strip: Don't generate empty output file when nothing to do.Mark Wielaard2017-06-142-12/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * strip: Make sure old .shstrab is removed when eu-strip recreates it.Mark Wielaard2017-06-142-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * Include strings.h to make ffs availableUlf Hermann2017-04-272-0/+5
| | | | | | | | | | | | We cannot rely on it to be available from any of the other headers. Signed-off-by: Ulf Hermann <[email protected]>
| * Protect against integer overflow on shnumUlf Hermann2017-04-272-11/+18
| | | | | | | | | | | | | | 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 <[email protected]>
| * Avoid YESSTR and NOSTRUlf Hermann2017-04-262-3/+8
| | | | | | | | | | | | | | | | | | 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 <[email protected]>
* | Make ranlib work on windowsUlf Hermann2017-05-081-3/+26
| | | | | | | | | | Change-Id: I51b9bb88dc86c3378451e07ade19b21526b9eb0c Reviewed-by: Christian Kandeler <[email protected]>
* | Drop file name truncation and date preservation from ar.cUlf Hermann2017-05-081-28/+1
| | | | | | | | | | Change-Id: I6b5eb620bbd3d20e0dfff173917f1615cddd5718 Reviewed-by: Christian Kandeler <[email protected]>
* | Use trees rather than hashes in ar.cUlf Hermann2017-05-082-33/+48
| | | | | | | | | | | | | | The tree functions are more widely available. Change-Id: Ic11a6485ae45f83e7ec8c18dcd7fa1a1902f7ff4 Reviewed-by: Christian Kandeler <[email protected]>
* | Make strip compile on windowsUlf Hermann2017-05-081-39/+9
| | | | | | | | | | | | | | We drop the preserve_dates mode. Change-Id: I79ec3737a41f30bd942e7bc7ea6b1abe33ee9616 Reviewed-by: Christian Kandeler <[email protected]>
* | Make elfcompress compile on windowsUlf Hermann2017-05-081-1/+4
| | | | | | | | | | | | | | | | The fnmatch implementation in gnulib is buggy and cannot understand ".?(z)debug*". We split it into two patterns. Change-Id: Ia70b56a9852b442344ebdd7f2a64ae52321411cf Reviewed-by: Christian Kandeler <[email protected]>
* | Use octal numbers rather than permission macrosUlf Hermann2017-05-085-8/+15
| | | | | | | | | | | | | | | | The permission macros are not guaranteed to be defined and the octal numbers are rather well known. Change-Id: I90ea2f98013f963857946a2f150a4a7114ca2b9a Reviewed-by: Christian Kandeler <[email protected]>
* | Make unstrip compile on windowsUlf Hermann2017-05-082-1/+6
| | | | | | | | | | | | | | strndupa doesn't exist, so we use strndup and free. Change-Id: Ibb3fed05bcfcf9d74b31e5695e43e08766512cbf Reviewed-by: Christian Kandeler <[email protected]>
* | Cast pid_t to long long when printingUlf Hermann2017-05-082-11/+15
| | | | | | | | | | | | | | | | On windows x86_64 pid_t is 64bit wide. We need to adapt our printf format respectively. Change-Id: I0e78ed597b780ea9ede6044d9d10ef08736b9009 Reviewed-by: Christian Kandeler <[email protected]>
* | Make readelf compile on windowsUlf Hermann2017-05-081-1/+4
| | | | | | | | | | | | | | | | The printf format attribute is not supported there. Also, SIGBUS and SI_USER don't exist, so we don't have to check for them. Change-Id: I1472150c83946337954cbbc475318dbb05549fc2 Reviewed-by: Christian Kandeler <[email protected]>
* | Close files before renaming or unlinking themUlf Hermann2017-05-082-1/+8
| | | | | | | | | | | | | | On windows we cannot rename or unlink open files. Change-Id: Ieae8712266a3e65217580d4936219767c5f26f21 Reviewed-by: Christian Kandeler <[email protected]>
* | Use OS-specific pathsUlf Hermann2017-05-084-6/+12
| | | | | | | | | | | | | | | | | | | | In general we need to use ';' as path separator and '\' and directory separator on windows. The shell will automatically translate paths to some extent, but we have to call "pwd -W" rather than plain "pwd" to get something useful. Change-Id: I1a117d219a2aa00c1f77ae7d3a1d92b9bae526db Reviewed-by: Christian Kandeler <[email protected]>
* | Open files in O_BINARYUlf Hermann2017-05-0815-25/+42
| | | | | | | | | | | | | | | | | | If O_BINARY is not defined, define it to 0, so that the change has no effect then. Some systems have separate binary and text modes for files, and we don't want the text mode to be used. Change-Id: If7efb5bd448c2a1c7d1eb5dab276849b1b15a3ce Reviewed-by: Christian Kandeler <[email protected]>
* | Skip fchown, fchmod, fadvise, fallocate if functions are unavailableUlf Hermann2017-05-046-29/+71
| | | | | | | | | | | | | | | | | | | | | | If fchmod or fchown are unavailable, then the file permission model is likely to be different from what we expect there. posix_fallocate is a rather fragile affair already on linux, and not guaranteed to do anything useful. If it's not available, the result will be the same as when it's available and unreliable. fadvise is an optimization. Change-Id: I28a77e976a0198cf80397b45eb1bc8cfb30664f5 Reviewed-by: Christian Kandeler <[email protected]>
* | Define roundup() for strings.c if it doesn't existUlf Hermann2017-05-042-0/+7
| | | | | | | | | | Change-Id: I6ea7c1f894e89bbaaecb724473c4c00e67296f05 Reviewed-by: Christian Kandeler <[email protected]>
* | Generalize library namesUlf Hermann2017-04-282-3/+8
| | | | | | | | | | | | | | | | | | On windows library names end with ".dll" and the prefix "lib" us usually omitted. Take this into account and also drop the $(EXEEXT) workaround. We don't need to use noinst_PROGRAMS as there is also noinst_DATA. Change-Id: I7e4ba2432811d5ad85051ea0c9d5674eabf79b3c Reviewed-by: Christian Kandeler <[email protected]>
* | Work around bogus compile errorUlf Hermann2017-04-281-0/+1
| | | | | | | | | | | | | | | | | | The gnulib error.h doesn't tell the compiler that error() cannot return. Therefore we get some null pointer dereference warnings. Switch those off. Change-Id: Ib7db818155fac3a458223c9e64dfa051212edac3 Reviewed-by: Christian Kandeler <[email protected]>
* | Check if we need -lintl for linking gettextUlf Hermann2017-04-281-15/+15
| | | | | | | | | | | | | | | | We might not have gettext available from libc and we cannot get it from gnulib either. Change-Id: I1cc657b13b97bcc7c0f158f11b6702c24e69695c Reviewed-by: Christian Kandeler <[email protected]>
* | Drop handrolled or #ifdef'ed libc replacementsUlf Hermann2017-04-282-15/+19
| | | | | | | | | | | | | | | | | | mempcpy, memrchr, rawmemchr, and argp are provided by gnulib now. We don't need to define them locally and we don't need to search for an external libargp. Change-Id: I131ca4bc2d77c597b99c296c28259a3600e5d1b5 Reviewed-by: Christian Kandeler <[email protected]>
* | Add gnulib modules to replace missing libc functionalityUlf Hermann2017-04-272-15/+24
| | | | | | | | | | | | | | | | | | | | This enables us to build a fully featured elfutils package on systems with reduced C libraries, such as windows. All the modules are built into libgnu.a, which is then linked into all binaries if --enable-gnulib is given on the configure line. Change-Id: I743fd22172bc85d9f10dcc3dad8eb921f462b554 Reviewed-by: Christian Kandeler <[email protected]>
* | Include strings.h to make ffs availableUlf Hermann2017-04-262-0/+5
| | | | | | | | | | | | | | We cannot rely on it to be available from any of the other headers. Change-Id: I33a93fa8d41183908242542b8efafd2355bc968c Reviewed-by: Christian Kandeler <[email protected]>
* | Protect against integer overflow on shnumUlf Hermann2017-04-262-11/+18
| | | | | | | | | | | | | | | | 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. Change-Id: I37a9e5d4e012a501d5ec98762ec0a435c743e25f Reviewed-by: Christian Kandeler <[email protected]>
* | Avoid YESSTR and NOSTRUlf Hermann2017-04-212-3/+8
|/ | | | | | | | | | 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. Change-Id: I4a0a24df2e9b5ac14a7eb6028f89c408b8a8aac7 Reviewed-by: Christian Kandeler <[email protected]>
* elflint: Support checking ELF files with compressed sections.Mark Wielaard2017-04-052-1/+10
| | | | | | | | | 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 <[email protected]>
* elflint: Don't check section group without flags word.Mark Wielaard2017-04-042-1/+8
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=21320 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Sanity check the number of phdrs and shdrs available.Mark Wielaard2017-04-042-0/+30
| | | | | | | | | 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 <[email protected]>
* elflint: Don't trust sh_entsize when checking hash sections.Mark Wielaard2017-04-042-12/+27
| | | | | | | | | | 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 <[email protected]>
* elflint: Check symbol table data is big enough before checking.Mark Wielaard2017-04-042-1/+6
| | | | | | | | | 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 <[email protected]>
* Use the empty string for note names with zero size (without any data).Mark Wielaard2017-04-033-3/+11
| | | | | | | | | | 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 <[email protected]>
* readelf: Fix off by one sanity check in handle_gnu_hash.Mark Wielaard2017-04-032-1/+6
| | | | | | | | | | 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 <[email protected]>
* Move print_version into printversion.{h|c}Ulf Hermann2017-02-1716-5/+33
| | | | | | | | 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 <[email protected]>
* Move color handling into a separate headerUlf Hermann2017-02-153-0/+7
| | | | | | | | 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 <[email protected]>
* http://elfutils.org/ is now hosted at http://sourceware.org/elfutils/Mark Wielaard2016-12-2417-211/+24
| | | | | | | | | | | | | | | | | 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 <[email protected]>
* readelf: Add optional --symbols[=SECTION] argument to select section name.Mark Wielaard2016-11-172-1/+26
| | | | | | | | | 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 <[email protected]>
* ar: Fix GCC7 -Wformat-length issues.Mark Wielaard2016-11-113-10/+28
| | | | | | | | | | | | 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 <[email protected]>
* Add GCC7 -Wimplicit-fallthrough support/fixes.Mark Wielaard2016-11-105-3/+17
| | | | | | | | | | | 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 <[email protected]>
* unstrip: Don't try to use unstripped .symtab with stripped .strtabKevin Cernekee2016-10-242-7/+12
| | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* lib: Provide MAX and MIN in system.hAkihiko Odaki2016-10-1213-10/+24
| | | | | | | | | | 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 <[email protected]>
* strip: Don't remove real symbols from allocated symbol tables.Mark Wielaard2016-10-062-11/+29
| | | | | | | | | | | | | | | 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 <[email protected]>
* strip: Use ELF_CHF_FORCE to recompress any sections that were uncompressed.Mark Wielaard2016-08-252-1/+5
| | | | | | | | 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 <[email protected]>
* strip: Handle compressed relocation target sections.Mark Wielaard2016-08-152-5/+22
| | | | | | | | | | | | | | | 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 <[email protected]>