summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* 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]>
* dwelf: Add string table functions from ebl.Mark Wielaard2016-08-035-46/+69
| | | | | | | | | | | | | | | | 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 <[email protected]>
* Remove eu-ld and unused code.Mark Wielaard2016-08-0319-13157/+29
| | | | | | | | 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 <[email protected]>
* unstrip: Fix off by one array access with unstripped_strent.Mark Wielaard2016-07-112-3/+8
| | | | | | | | | | 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 <[email protected]>
* Add support for BPFRichard Henderson2016-06-282-1/+5
| | | | Signed-off-by: Richard Henderson <[email protected]>
* elfcmp: fix self-comparison error with GCC 6David Abdurachmanov2016-04-112-1/+5
| | | | | | | | | | | | 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 <[email protected]>
* nm: Check for malloc size argument overflow in show_symbols.Mark Wielaard2016-03-212-0/+9
| | | | | Reported-by: Florian Weimer <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* readelf: Warn when uncompressing fails and error when gelf_getshdr fails.Mark Wielaard2016-02-222-5/+46
| | | | | | | | 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 <[email protected]>
* elfcompress: -q should not imply --force.Mark Wielaard2016-02-222-1/+6
| | | | | | We accidentally set force = true after handling -q and setting verbose--. Signed-off-by: Mark Wielaard <[email protected]>
* Fix GCC6 -Wnull-dereference warnings.Mark Wielaard2016-02-222-2/+8
| | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* readelf: Read and print (encoded) DW_CFA_set_loc op and update pc.Mark Wielaard2016-02-182-60/+68
| | | | | | | 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 <[email protected]>