summaryrefslogtreecommitdiffstats
path: root/src/elflint.c
Commit message (Collapse)AuthorAgeFilesLines
* elflint: Recognize and check SHF_COMPRESSED section flag.Mark Wielaard2016-01-051-10/+35
| | | | | | | | 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 <[email protected]>
* elflint: Add _edata and _end to the list of possibly dangling gnuld symbols.Mark Wielaard2016-01-051-1/+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 <[email protected]>
* elflint: Don't check shdr or TLS symbol offsets against debuginfo phdrs.Mark Wielaard2015-10-161-2/+3
| | | | | | | | | | | | 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 <[email protected]>
* elflint: Reject mergable string sections as relocation target.Mark Wielaard2015-10-161-2/+3
| | | | | | | | 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 <[email protected]>
* Do not rely on ebl_check_special_section when checking debuginfo files.Jose E. Marchesi2015-10-131-5/+13
| | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* elflint: Check relro flags are a subset of the load segment.Mark Wielaard2015-10-131-3/+19
| | | | | | | | | 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 <[email protected]>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-091-2/+2
| | | | | | | | | | | | | | | 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 <[email protected]>
* Replace printf %Z length modifier with %z.Chih-Hung Hsieh2015-09-071-5/+5
| | | | | | | | %Z is a GNU extension predating the ISO C99 %z modifier supported by libc5 and no longer recommended. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Add gnuld check when a NOBITS section falls inside a segment.Mark Wielaard2015-08-171-2/+32
| | | | | | | | | | | | 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 <[email protected]>
* elflint: Only check the PT_TLS phdr if it actually exists, warn otherwise.Mark Wielaard2015-06-191-0/+6
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Check gnu_hash has enough data and bitmask_words is not zero.Mark Wielaard2015-05-121-6/+20
| | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c31 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Add sanity checks to check_attributes.Mark Wielaard2015-05-121-2/+4
| | | | | | | | | | This is similar to commit 9644aa for readelf print_attributes. Bail out when the vendor name isn't terminated and add overflow check for subsection_len. Note that readelf does handle non-gnu attributes, while elflint doesn't. Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Use Use Elf64_Word for shdr->sh_info cnt.Mark Wielaard2015-05-121-2/+6
| | | | | | | On 32bit using int might overflow. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c31 Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Stop checking section when 2nd hash function shift too big.Mark Wielaard2015-05-121-2/+5
| | | | | | Nothing good comes from trying to continue with a bogus hash function. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c31
* elflint: Correct gnu_symbias usage in compare_hash_gnu_hash.Mark Wielaard2015-03-131-14/+16
| | | | | | | | | | | commit 0a545e "elflint: Add various low-level checks." introduced a bug in the handling of the gnu_symbias. The symbol in the bucket should first be compared to STN_UNDEF before applying the bias. And the used symbol index should have the bias added when compared against plain hash symbol. Found on Debian wheezy with run-elflint-self.sh. Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Add various low-level checks.Mark Wielaard2015-01-151-52/+211
| | | | | | | | | elflint could crash or hang because it didn't check some low level issues. https://bugzilla.redhat.com/show_bug.cgi?id=1170810 Reported-by: Alexander Cherepanov <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add get_uleb128 and get_sleb128 bounds checking.Mark Wielaard2014-12-171-3/+3
| | | | | | | | | | | Both get_uleb128 and get_sleb128 now take an end pointer to prevent reading too much data. Adjust all callers to provide the end pointer. There are still two exceptions. "Raw" dwarf_getabbrevattr and read_encoded_valued don't have a end pointer associated yet. They will have to be provided in the future. Signed-off-by: Mark Wielaard <[email protected]>
* Use elf_getphdrnum instead of accessing ehdr->e_phnum directly.Mark Wielaard2014-11-261-1/+1
| | | | | | | Using elf_getphdrnum lets us handle ELF files that use more than PN_XNUM phdrs. And guards against some corrupt files. Signed-off-by: Mark Wielaard <[email protected]>
* Add ppc64le ELFv2 abi support to backends and elflint.Mark Wielaard2014-07-041-1/+2
| | | | | | | | | | The big endian vs little endian changes are already handled by detecting the EI_DATA data encoding. And the function descriptors are already not used when we see there is no .opd section. This change adds new checks for st_other bits, new relocations and recognizes DT_PPC64_OPT. Signed-off-by: Menanteau Guy <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libebl: Add ebl_func_addr_mask plus ARM backend implementation.Mark Wielaard2014-06-221-7/+13
| | | | | | | | | | | | | | The ARM EABI says that the zero bit of function symbol st_value indicates whether the symbol points to a THUMB or ARM function. Also the return value address in an unwind will contain the same extra bit to indicate whether to return to a regular ARM or THUMB function. Add a new ebl function to mask off such bits and turn a function value into a function address so that we get the actual value that a function symbol or return address points to. It isn't easily possible to reuse the existing ebl_resolve_sym_value for this purpose, so we end up with another hook that can be used from dwfl_module_getsym, handle_cfi and elflint. Signed-off-by: Mark Wielaard <[email protected]>
* backends: Add ebl_check_reloc_target_type.Mark Wielaard2014-05-191-2/+1
| | | | | | | | | And implement for arm and ia64. Both have special section types that are valid targets for a reloc. Both refer to unwind data. elflint now just calls ebl_check_reloc_target_type instead of hard coding the expected section types. Signed-off-by: Mark Wielaard <[email protected]>
* robustify: elflint.Jakub Jelinek2014-01-231-28/+77
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Support AArch64 architecturePetr Machata2013-11-261-2/+2
| | | | Signed-off-by: Petr Machata <[email protected]>
* elflint.c (check_symtab): Add __bss_start__ to the list of allowed symbols.Mark Wielaard2013-02-241-0/+1
| | | | | | Some architectures (ARM) use __bss_start__ instead of __bss_start. Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Add two more symbols to gnuld list of allowed bad values.Mark Wielaard2013-02-061-3/+10
| | | | | | | | | | | | | Add __bss_start and __TMC_END__ to the list of symbols allowed to have out of section values because of the following GNU ld bug: http://sourceware.org/bugzilla/show_bug.cgi?id=13621. Allow them to appear in either .symtab or .dynsym, but only when they are zero sized. It is impossible to define a general rule for this bug, but this should catch most common issues that are mostly harmless because the symbols signify the removed section was empty to being with. This catches at least all symbols often flagged in the tests. Signed-off-by: Mark Wielaard <[email protected]>
* Add support for Tilera TILE-Gx processor.Jeff Kenton2012-08-241-1/+2
| | | | Signed-off-by: Jeff Kenton <[email protected]>
* Update name, license and contributor policy.Mark Wielaard2012-06-051-19/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change name from "Red Hat elfutils" to "elfutils". * Update license of standalone tools and test from GPLv2 to GPLv3+. * Change license of libraries from GPLv2+exception to GPLv2/LGPLv3+. * Add Developer Certificate of Origin based contributor policy. top-level: - COPYING: Upgraded from GPLv2 to GPLv3. - CONTRIBUTING, COPYING-GPLv2, COPYING-LGPLv3: New files. - NEWS: Added note about new contribution and license policy. - Makefile.am: Updated to GPLv3, added new files to EXTRA_DIST. - configure.ac: Update to GPLv3, changed AC_INIT name to 'elfutils'. backends, lib, libasm, libcpu, libdw, libdwfl, libebl, libelf: - All files updated to GPLv2/LGPLv3+. Except some very small files (<5 lines) which didn't have any headers at all before, the linker .maps files and the libcpu/defs files which only contain data and libelf/elf.h which comes from glibc and is under LGPLv2+. config: - elfutils.spec.in: Add new License: headers and new %doc files. - Update all license headers to GPLv2/LGPLv3+ for files used by libs. src, tests: - All files updated to GPLv3+. Except for the test bz2 data files, the linker maps and script files and some very small files (<5 lines) that don't have any headers. Signed-off-by: Richard Fontana <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* elflint: Allow zero sized sections at (filesz) end of segment.Mark Wielaard2012-05-091-2/+4
|
* elflint: Accept SHF_INFO_LINK for reloc sections.Roland McGrath2012-03-281-2/+2
|
* Update copyright yearUlrich Drepper2012-01-211-2/+2
|
* Add new ebl_check_st_other_bits function.upstream/mpolacek/autotestMark Wielaard2011-03-111-1/+1
|
* elflint: Remove unused variables.Roland McGrath2011-02-081-13/+0
|
* ld: Remove an unused variable.Roland McGrath2011-02-081-3/+4
|
* Fix some message typos and xgettext markers.Roland McGrath2010-04-061-2/+2
|
* Fix sloppy #include use, breaks with latest glibc.Roland McGrath2010-01-151-0/+1
|
* Handle extended phnum in elflint and elfcmp.Roland McGrath2010-01-071-33/+54
|
* Handle new .comment section flags.Mark Wielaard2009-09-211-2/+2
| | | | | Newer gcc+ld combinations use string merging in the .comment section. Allow that in elflint.
* Handle NT_GNU_GOLD_VERSION.Mark Wielaard2009-07-261-0/+1
|
* Add STB_GNU_UNIQUE support to elflint.Ulrich Drepper2009-07-141-3/+11
|
* Add test of st_other field of symbol table entries.Ulrich Drepper2009-04-291-0/+11
|
* Fix error handling in a few programs.Ulrich Drepper2009-02-011-3/+2
|
* Fix handling of debuginfo files when checking exception handling tables.Ulrich Drepper2009-01-211-21/+40
|
* Fix elflint test for .eh_frame_hdr allocation.Ulrich Drepper2009-01-211-1/+5
|
* More improveents to exception handling table printing and checking.Ulrich Drepper2009-01-171-5/+18
|
* Merge branch 'master' of ssh://git.fedorahosted.org/git/elfutilsUlrich Drepper2009-01-171-3/+2
|\
| * Move argp_program_version_hook and argp_program_bug_address variablesUlrich Drepper2009-01-171-3/+2
| | | | | | | | in all programs into the .rodata section.
* | Beginning of exception table testing.Ulrich Drepper2009-01-171-0/+38
|/
* Implement check for PT_GNU_EH_FRAME program header check.Ulrich Drepper2009-01-161-1/+36
|
* Unpdate copyright in messages.Ulrich Drepper2009-01-011-2/+2
|
* src/Roland McGrath2008-04-111-4/+9
| | | | | | | | | | | | | * strip.c (handle_elf): Don't keep sections that kept symbol tables refer to. Instead, just be sure to preserve the original symbol table in the debug file so those symbols go with their sections and can be elided from the stripped version of the symbol table. tests/ * testfile48.bz2, testfile48.bz2.debug: New data files. * Makefile.am (EXTRA_DIST): Add them. * run-strip-test8.sh: Use them.