Commit Graph

157 Commits

Author SHA1 Message Date
Petr Machata 237188e4d7 elf_begin sets elf_errno for cases that the file is completely unreadable
- The problem this is trying to solve can be seen for example thus:
	$ eu-readelf -a /
	eu-readelf: failed reading '/': (null)

  With the fix we see a proper error number and get a reasonable error
  message:

	$ eu-readelf -a /
	eu-readelf: failed reading '/': invalid file descriptor

Signed-off-by: Petr Machata <pmachata@redhat.com>
2014-09-11 19:45:11 +02:00
Mark Wielaard 16e2d351bf Update elf.h from glibc.
Includes new bits needed for ppc64le ELFv2 abi.
https://bugzilla.redhat.com/show_bug.cgi?id=1110249

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-07-04 13:39:30 +02:00
Mark Wielaard 3232479483 Remove mudflap build option.
The --enable-mudflap configure build has been broken for 2 years without
anybody apparently noticing. GCC 4.9 removed mudflap support. Before
release we now run make distcheck with valgrind support. Removal of the
mudflap configure option simplifies the build a little.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-04-18 11:46:51 +02:00
Jakub Jelinek a9039623c2 robustify: libelf gelf define INVALID_NDX macro.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-01-23 11:31:53 +01:00
Jakub Jelinek 720383c53b robustify: libelf.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-01-23 11:31:53 +01:00
Mark Wielaard 3ba5040317 libelf: Only memcpy ehdr back when not already directly mmapped.
When the elf file is mmapped ehdr can still point to ehdr_mem if the
address is unaligned.  In such cases we do need to memcpy the ehdr back
to the file. We shouldn't when ehdr already comes directly from the mmapped
file, because that would cause an memcpy call with overlapping addresses
(ehdr being copied directly over itself).

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-11-11 15:07:44 +01:00
Mark Wielaard 88ad5ddb71 libelf: Write all section headers if elf flags contains ELF_F_DIRTY.
When ehdr e_shoff changes, elf flags is set dirty. This indicates that
the section header moved because sections were added/removed or changed
in size.

Reported-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-11-05 22:17:51 +01:00
Michael Forney a45c804335 Check for prefixed ar, readelf, and nm
Sometimes with cross-compile toolchains, the tools are prefixed with the
target arch. Using AC_CHECK_TOOL looks for tools named like this.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-11-05 17:07:10 +01:00
Petr Machata acf126799e Update elf.h from glibc
Signed-off-by: Petr Machata <pmachata@redhat.com>
2013-10-01 16:31:16 +02:00
Petr Machata 49a1a381a9 Update elf.h from glibc
Signed-off-by: Petr Machata <pmachata@redhat.com>
2013-09-26 00:24:23 +02:00
Namhyung Kim e0b4385b25 gelf.h: Fix typo in comment.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-08-28 18:58:10 +02:00
Mark Wielaard d0509d49a0 gelf_getauxv: Add missing whitespace.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-08-28 11:44:41 +02:00
Mark Wielaard 4f017daab5 gelf_getauxv: Remove unnecessary casts to char *.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-08-27 11:39:52 +02:00
Kurt Roeckx 617f8ea898 gelf_getauxv: Use memcpy, not pointer deref, to avoid alignment problems.
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-08-26 16:27:35 +02:00
Roland McGrath 6722a667bb elf_getarsym: Handle unaligned data in archive index. 2013-01-07 14:30:54 -08:00
Roland McGrath 99d9db00b8 elf_getarsym: Use memcpy instead of pointer dereference so as not to assume the field is naturally aligned.
Signed-off-by: Roland McGrath <roland@hack.frob.com>
2013-01-07 13:01:10 -08:00
Petr Machata 9312cb5e89 Update elf.h from glibc.
Signed-off-by: Petr Machata <pmachata@redhat.com>
2012-09-17 17:33:22 +02:00
Roland McGrath d83f1324c3 Update elf.h from glibc.
Signed-off-by: Roland McGrath <roland@hack.frob.com>
2012-08-16 10:39:52 -07:00
Mark Wielaard 2105022c82 elf32_checksum.c: Removed unused ebl_debugscn_p define and confusing comment.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2012-08-14 16:48:50 +02:00
Petr Machata e1873141a5 Implement support for archives with 64-bit symbol table
Signed-off-by: Petr Machata <pmachata@redhat.com>
2012-08-07 14:28:57 +02:00
Mark Wielaard 030f626f41 elf_getshdr should work for elf->flags & ELF_F_MALLOCED.
Reported-by: Nick Alcock <nix@esperi.org.uk>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2012-07-24 11:41:01 +02:00
Petr Machata bc0f7450cb elf*_xlatetom: do not check ELF_T_NHDR has integer number of records
See this bug report for more details:
  https://bugzilla.redhat.com/show_bug.cgi?id=835877

Signed-off-by: Petr Machata <pmachata@redhat.com>
2012-07-17 16:29:18 +02:00
Mark Wielaard de2ed97f33 Update name, license and contributor policy.
* 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 <rfontana@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2012-06-05 23:12:05 +02:00
Mark Wielaard 5128fb4487 Remove .mtn-ignore and .cvsignore files.
We use .gitignore these days.
2012-06-05 14:55:29 +02:00
Mark Wielaard 191d1f0b91 elf32_offscn.c: Do not match SHT_NOBITS sections at OFFSET.
readelf -d doesn't work if a SHT_NOBITS section is right before the actual
.dynamic section at the same offset. elflint also fails on such binaries.
So skip SHT_NOBITS sections at the same offset in [g]elf[32|64]_offscn().
2012-04-02 17:11:25 +02:00
Roland McGrath 8e8f0be573 Don't exclude sh_type >= SHT_NUM from stripping. 2012-03-22 10:25:55 -07:00
Mark Wielaard 4955016118 elf_end.c (elf_end): Call rwlock_unlock before rwlock_fini.
Reported-by: Kurt Roeckx <kurt@roeckx.be>
2012-02-26 13:14:32 +01:00
Marek Polacek ed52618203 Fix doubled words. 2011-04-16 14:43:57 +02:00
Jan Kratochvil f1ccc410d6 Fix off64_t overflow when MAXIMUM_SIZE == ~0. 2011-01-05 10:06:21 +01:00
Roland McGrath b088f21641 Add missing size entries for ELF_T_LIB and ELF_T_GNUHASH. 2010-08-18 16:53:43 -07:00
Ulrich Drepper d763578420 Implicitly set dirty bit
The gelf_update_[eps]hdr functions didn't implicitly mark the
data structures as modified.  This has always been the case and
programs should set the bit but it is somewhat inconsistent since
other update functions implicitly set the bit.  Do it in these
three cases, too.
2010-06-14 14:18:23 -07:00
Roland McGrath 9d81c7df78 Fix typo in last change. 2010-04-14 11:37:06 -07:00
Roland McGrath 957072c18a Handle truncated phdrs without crash. 2010-04-14 11:24:15 -07:00
Roland McGrath f35dfa89a0 Update elf.h from glibc. 2010-04-13 12:12:07 -07:00
Matt Fleming d80f0b2cf8 Complete SH port. 2010-04-10 19:13:37 -07:00
Roland McGrath 3b495d8e96 Fix some message typos and xgettext markers. 2010-04-06 12:58:32 -07:00
Petr Machata d7b12c622c Fix for the same
* Initialize data.s for data	that do not need a conversion.
2010-04-06 14:18:18 +02:00
Roland McGrath 331a186dcd elf.h: Update from glibc. 2010-03-11 00:45:28 -08:00
Ulrich Drepper f7a9a9e421 Update elf.h 2010-03-04 21:51:54 -08:00
Roland McGrath 429502fd32 Avoid wild section data pointers from bogus sh_offset in mapped files. 2010-02-17 01:45:32 -08:00
Roland McGrath 22359e2653 Clean up and consolidate automake magic to reduce duplication and to work with --disable-dependency-tracking. 2010-02-15 15:57:03 -08:00
Roland McGrath 6fd3cd104a Add elf_getphdrnum, support >65536 phdrs. 2010-01-07 19:43:42 -08:00
Lubomir Rintel 2cfe33f421 Fix fill_mmap for sections past the section headers
If fill_mmap() was run for a section that's past the shdr_end, but does
not immediately follow the section headers the fill start would be
determined incorrectly as shdr_end, which would wipe off contents of
sections between shdr_end and current one.

Issue was reported and triaged by Hugo Mildenberger, Graham Murray
and Peter Alfredsen. (http://bugs.gentoo.org/show_bug.cgi?id=288977)
2010-01-04 19:32:40 -08:00
Roland McGrath 6b8cd7fcf0 Fix whitespace, copyright years. 2009-11-10 13:34:48 -08:00
Roland McGrath 0c6db7e369 __libelf_readall: Fetch file size if not yet known. 2009-11-10 13:34:09 -08:00
Mark Wielaard c6f5e920be Mark the archive header as unusable when there is no next ar element. 2009-11-06 09:14:09 +01:00
Mark Wielaard e2fedf4ad5 Makefile.am (libelf.so): Use -Wl,-z,defs not -defs. 2009-08-12 12:00:17 +02:00
Ulrich Drepper 3117a85d8c Update elf.h from glibc. 2009-07-26 08:28:15 -07:00
Lubomir Rintel fa1d4447b1 Fix handling of gaps between sections when writing files in libelf. 2009-07-21 21:04:47 -07:00
Roland McGrath 9dedfccc66 Reorder Elf struct members for optimal packing. 2009-07-08 14:42:13 -07:00