summaryrefslogtreecommitdiffstats
path: root/src/strip.c
Commit message (Collapse)AuthorAgeFilesLines
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-091-6/+6
| | | | | | | | | | | | | | | 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]>
* strip: Only sanity check symbols to not discarded sections for debug file.Mark Wielaard2015-10-091-3/+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 <[email protected]>
* Handle merged strtab/shstrtab string tables in strip and unstrip.Mark Wielaard2015-10-051-6/+9
| | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* Remove old-style function definitions.Mark Wielaard2015-09-231-2/+2
| | | | | | | We already require -std=gnu99 and old-style function definitions might hide some compiler warnings. Signed-off-by: Mark Wielaard <[email protected]>
* strip: Just admit we don't support stripping ar archives for now.Mark Wielaard2015-06-101-2/+12
| | | | | | | | | | | | | 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 <[email protected]>
* strip: Harden against bogus input files. Don't leak tmp debug file on error.Mark Wielaard2015-05-181-77/+191
| | | | | | | | | | 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 <[email protected]>
* Always call gelf_fsize with EV_CURRENT as argument.Mark Wielaard2015-05-131-12/+7
| | | | | | | | | | Don't trust the elf version given by the file. It could be completely bogus. In which case gelf_fsize just returns zero. Which could cause divide by zero errors. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c34 Signed-off-by: Mark Wielaard <[email protected]>
* Replace futimes with futimens.Max Filippov2015-05-051-9/+9
| | | | | | | | futimes is not standard function, and it's not available in uClibc. Use futimens which is POSIX. Suggested-by: Mike Frysinger <[email protected]> Signed-off-by: Max Filippov <[email protected]>
* Drop mtrace calls.Max Filippov2015-05-041-4/+0
| | | | | | | mtrace is a GNU extension not supported by uClibc and it's believed to not be really used. Drop mtrace() calls and #include <mcheck.h>. Signed-off-by: Max Filippov <[email protected]>
* src: Remove __DATE__ from internal error messages.Mark Wielaard2015-04-141-3/+3
| | | | | | | The date didn't really add much information (it is the day on which the code happened to be compiled) and it prevents creating reproducible builds. Signed-off-by: Mark Wielaard <[email protected]>
* Use elf_getphdrnum instead of accessing ehdr->e_phnum directly.Mark Wielaard2014-11-261-4/+9
| | | | | | | 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]>
* robustify: strip.Roland McGrath2014-01-231-31/+57
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Fix two memory leaks in findtextrel and strip.Mark Wielaard2013-03-011-1/+6
| | | | | | | | | | | The findtextrel leak is real, when processing lots of files without text relocations the files and memory wouldn't be released. The strip leak is minor since it can only happen when using -f which only allows one file as argument. But it is nice to see valgrind say: "All heap blocks were freed -- no leaks are possible". Signed-off-by: Mark Wielaard <[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]>
* Update copyright yearUlrich Drepper2012-01-211-3/+3
|
* strip.c (relocate): Make offset check overflow-proof.Mark Wielaard2011-05-301-1/+2
|
* strip: --reloc-debug-sections, relocate against any debug section symbol.Mark Wielaard2011-05-241-65/+83
|
* strip: Add --reloc-debug-sections option.Mark Wielaard2011-05-231-2/+213
|
* strip: Handle SHT_GROUP sections better.Mark Wielaard2011-05-191-4/+28
|
* strip: Remove all excess for --strip-sections.Roland McGrath2011-01-061-27/+31
|
* strip: Add --strip-sections option.Roland McGrath2011-01-051-0/+58
|
* Fix sloppy #include use, breaks with latest glibc.Roland McGrath2010-01-151-1/+2
|
* Add aliases for elf_getshnum and elf_getshstrndx.Ulrich Drepper2009-06-131-2/+2
| | | | | | | | | | Sun in their implementation messed up the semantics of these functions. To get back to source code compatibility they asked for a solution. We simply add aliases for the two affected functions, named elf_getshdrnum and elf_getshdrstrndx. The semantics remains the same. Users of the old interfaces receive a warning for now. In future we might make it impossible to link programs which request the old interfaces (binary compatibility will of course be maintained).
* Fix strip -f infinite loop when coping with some extra kooky object sections.Roland McGrath2009-04-141-1/+2
|
* Fix typo in comment.Ulrich Drepper2009-01-241-1/+1
|
* Move argp_program_version_hook and argp_program_bug_address variablesUlrich Drepper2009-01-171-2/+2
| | | | in all programs into the .rodata section.
* Unpdate copyright in messages.Ulrich Drepper2009-01-011-2/+2
|
* src/Roland McGrath2008-04-111-263/+305
| | | | | | | | | | | | | * 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.
* propagate from branch 'com.redhat.elfutils.roland.pending' (head ↵Ulrich Drepper2008-01-091-1/+2
| | | | | | 26cc2ce45739af072e7ff4fdab5e8eb7cd756d50) to branch 'com.redhat.elfutils' (head bb519012dee7013b2cab5c2f5ed465cb3821b063)
* propagate from branch 'com.redhat.elfutils.disasm' (head ↵Ulrich Drepper2008-01-021-3/+6
| | | | | | d15b4eb794e81e477f9896fe82a74cb5ecf4514c) to branch 'com.redhat.elfutils' (head eaacbf01f8cc89d043ec6eca9b5e35cb5c4cde06)
* Update copyright year.Ulrich Drepper2008-01-021-1/+1
|
* Prepare for 0.128 release.Ulrich Drepper2007-06-061-4/+4
| | | | | | Minor fixes. Update gettext files to 0.16.1.
* src/Roland McGrath2007-05-181-20/+31
| | | | | | | | | | | | | | | | | | | 2007-05-18 Roland McGrath <[email protected]> * unstrip.c (copy_elided_sections): Match up non-NOBITS sections with stripped file, so as not to duplicate a section copied in both. * strip.c (handle_elf): Keep SHT_NOTE section copies in the debug file. tests/ 2007-05-18 Roland McGrath <[email protected]> * run-strip-test4.sh (stripped, debugfile): Use new reference files. * testfile37.bz2: New data file. * testfile37.debug.bz2: New data file. * run-unstrip-test2.sh: New file. * Makefile.am (TESTS, EXTRA_DIST): Add them.
* 2007-04-24 Roland McGrath <[email protected]>Roland McGrath2007-04-251-1/+1
| | | | | * run-strip-test.sh: When we saved the debug info, test unstrip too.
* Update copyright year.elfutils-0.125Ulrich Drepper2007-01-101-2/+2
|
* propagate from branch 'com.redhat.elfutils' (head ↵Roland McGrath2006-12-171-2/+2
| | | | | | b4944cf70801d9dac056f4f80ef1334e5acb8bdc) to branch 'com.redhat.elfutils.roland.pending' (head e7e402c668fb0670fc5f6b6a522853ae88f32f11)
* Fix FSF address. No exception for libdwarf.Ulrich Drepper2006-04-041-1/+1
|
* Prepare for 0.120 release.Ulrich Drepper2006-04-041-2/+2
|
* propagate from branch 'com.redhat.elfutils.roland.pending' (head ↵Ulrich Drepper2006-04-041-9/+21
| | | | | | 4f8fc821345feef58624f0aa5b470d4827577d8c) to branch 'com.redhat.elfutils' (head 76e26cb54695fd3b21ee8fb5be3036bd68200633)
* Cleanup of messages.Ulrich Drepper2005-09-031-3/+3
|
* merge of 0bdc7517571447282c23ea28a69147eabf574048Roland McGrath2005-08-111-49/+29
| | | | and b0183df71043735ade5c882809fed6c7ca571b2a
* Update DW_LNS_set_epilogue_begin uses to correct misspelling.Roland McGrath2005-08-101-29/+49
|
* Change addr2line to use dwfl_* functions.Ulrich Drepper2005-08-111-47/+28
| | | | Minor strip cleanups.
* Minimal cleanup in strip.Ulrich Drepper2005-08-111-2/+1
|
* 2005-08-08 Roland McGrath <[email protected]>Roland McGrath2005-08-091-0/+20
| | | | | | | * strip.c (options, parse_opt): Grok -R .comment for compatibility with binutils strip. Likewise -d, -S, as aliases for -g. Likewise ignore -s/--strip-all.
* 2005-08-07 Roland McGrath <[email protected]>Roland McGrath2005-08-081-2/+3
| | | | | | * strip.c (process_file): Open read-only when using a different output file.
* Adjust for monotone.Ulrich Drepper2005-07-261-0/+1750