summaryrefslogtreecommitdiffstats
path: root/src/unstrip.c
Commit message (Collapse)AuthorAgeFilesLines
* Internationalized messages should not contain the '\v' escape sequence.Mark Wielaard2017-09-151-1/+2
| | | | | | | Replace horizontal tab '\v' with double line feed '\n\n' in doc strings. Regenerate .po files. Signed-off-by: Mark Wielaard <[email protected]>
* Protect against integer overflow on shnumUlf Hermann2017-04-271-11/+14
| | | | | | | 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]>
* Move print_version into printversion.{h|c}Ulf Hermann2017-02-171-1/+1
| | | | | | | | 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]>
* http://elfutils.org/ is now hosted at http://sourceware.org/elfutils/Mark Wielaard2016-12-241-14/+0
| | | | | | | | | | | | | | | | | 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]>
* unstrip: Don't try to use unstripped .symtab with stripped .strtabKevin Cernekee2016-10-241-6/+6
| | | | | | | | | | | | | | | | | | | | | | | 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-121-0/+1
| | | | | | | | | | 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]>
* dwelf: Add string table functions from ebl.Mark Wielaard2016-08-031-23/+27
| | | | | | | | | | | | | | | | 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]>
* unstrip: Fix off by one array access with unstripped_strent.Mark Wielaard2016-07-111-3/+3
| | | | | | | | | | 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]>
* unstrip: Don't leak new section data.Mark Wielaard2016-01-021-2/+37
| | | | | | | When we copy elided sections some section data is newly allocated. Track those allocations so we can free them when done. Signed-off-by: Mark Wielaard <[email protected]>
* Trust AC_SYS_LARGEFILE to provide large file supportJosh Stone2015-10-091-4/+4
| | | | | | | | | | | | | | | 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]>
* Allocate exact amount of bytes for phdrs and shdrs.Mark Wielaard2015-10-081-11/+7
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* Do without union of variable length arrays.Chih-Hung Hsieh2015-10-071-9/+18
| | | | | | | | | | | | | | Prepare to compile with clang. A union like { T32 a32[n]; T64 a64[n]; } u; is expanded to size_t nbytes = n * MAX(sizeof(T32), sizeof(T64)); void *data = malloc(nbytes); T32 (*a32)[n] = data; T64 (*a64)[n] = data; Signed-off-by: Chih-Hung Hsieh <[email protected]>
* unstrip: Update sh_info when SH_INFO_LINK_P not just when SHF_INFO_LINK setMark Wielaard2015-10-051-1/+1
| | | | | | | | | | | SHF_INFO_LINK is not consistently set when sh_info is actually a section index reference. Use SH_INFO_LINK_P to check whether to update the sh_info value. SH_INFO_LINK_P also checks the section type to know whether or not sh_info is meant as section index. Found by run-strip-strmerge.sh test with older binutils. Signed-off-by: Mark Wielaard <[email protected]>
* Handle merged strtab/shstrtab string tables in strip and unstrip.Mark Wielaard2015-10-051-1/+44
| | | | | | | | | | | | | | | | | | | | | 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]>
* Replace printf %Z length modifier with %z.Chih-Hung Hsieh2015-09-071-7/+7
| | | | | | | | %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]>
* unstrip: Handle debuginfo files with missing SHF_INFO_LINK section flags.Mark Wielaard2015-08-031-5/+29
| | | | | | | | | | | | | | | | With GCC 5 there might be a .rela.plt section with SHF_INFO_LINK set. Buggy binutils objdump might strip it from the section in the debug file. Ignore such differences for relocation sections and put the flag back if necessary. Also improve the error message a little by only discarding the already matched sections if there is an prelink undo section. Otherwise we will report all sections as not matching if the file wasn't prelinked instead of just the non-matching sections. New testfiles generated by gcc5 and binutils objdump added. Signed-off-by: Mark Wielaard <[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]>
* Use elf_getphdrnum instead of accessing ehdr->e_phnum directly.Mark Wielaard2014-11-261-8/+20
| | | | | | | 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]>
* unstrip: Allow prelinked, but non-split .bss section.Mark Wielaard2014-05-271-2/+3
| | | | | | | | If the section sh_size of the original and undo section are equal then match them and don't set split_bss. This is also what prelink's undo_sections allows. Signed-off-by: Mark Wielaard <[email protected]>
* unstrip: Add --force to force combining files when ELF headers don't match.Mark Wielaard2014-05-271-16/+41
| | | | | | | | | | | | | | Older versions of GNU binutils strip would drop some ELF header flags. Causing the main ELF file and the separate .debug file to have mismatched ELF header fields. Unfortunately some distros are still shipping such files. eu-unstrip doesn't want to recombine such files. Add a more explicit explanation which fields don't match and provide a --force, -F flag to force combining such files anyway (producing a warning). https://bugzilla.redhat.com/show_bug.cgi?id=698005 https://bugzilla.redhat.com/show_bug.cgi?id=806474 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-2/+2
|
* unstrip.c: Mark function as static.Marek Polacek2011-05-071-1/+1
|
* unstrip: Remove unused variable.Roland McGrath2011-02-081-3/+1
|
* Fix unstrip for modifying file in place.Roland McGrath2010-06-141-1/+11
|
* unstrip: Factor common code for shdr changes.Roland McGrath2010-06-141-15/+14
|
* unstrip: Bail early on bogus invocation with reversed arguments.Roland McGrath2010-06-141-0/+4
|
* 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-5/+5
| | | | | | | | | | 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).
* Move argp_program_version_hook and argp_program_bug_address variablesUlrich Drepper2009-01-171-3/+2
| | | | in all programs into the .rodata section.
* Unpdate copyright in messages.Ulrich Drepper2009-01-011-2/+2
|
* propagate from branch 'com.redhat.elfutils.disasm' (head ↵Ulrich Drepper2008-01-021-0/+3
| | | | | | d15b4eb794e81e477f9896fe82a74cb5ecf4514c) to branch 'com.redhat.elfutils' (head eaacbf01f8cc89d043ec6eca9b5e35cb5c4cde06)
* Update copyright year.Ulrich Drepper2008-01-021-1/+1
|
* 2007-10-23 Roland McGrath <[email protected]>Roland McGrath2007-10-231-18/+62
| | | | | | * linux-kernel-modules.c (report_kernel_archive): Reorder the kernel module to appear first.
* merge of '92c36bfdbc6468d1711c043b530e0dfe5abb6dec'Ulrich Drepper2007-10-161-85/+168
| | | | and 'c22c8c43f8f68b0bffd4d5ccdb2282c958268742'
* src/Roland McGrath2007-10-041-4/+78
| | | | | | | | | | | | | | | | | | | | 2007-10-04 Roland McGrath <[email protected]> * readelf.c (print_archive_index): New variable. (options, parse_opt): Accept -c/--archive-index to set it. (dump_archive_index): New function. (process_file): Take new arg WILL_PRINT_ARCHIVE_INDEX. Call dump_archive_index on archives if set. (main): Update caller. (any_control_option): Give it file scope, moved out of ... (parse_opt): ... here. tests/ 2007-10-04 Roland McGrath <[email protected]> * run-readelf-test4.sh: New file. * Makefile.am (TESTS, EXTRA_DIST): Add it.
* readelf register printing sort order tweakRoland McGrath2007-08-231-57/+72
|
* Prepare for 0.128 release.Ulrich Drepper2007-06-061-3/+3
| | | | | | Minor fixes. Update gettext files to 0.16.1.
* src/Roland McGrath2007-05-181-120/+450
| | | | | | | | | | | | | | | | | | | 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-0/+1768
* run-strip-test.sh: When we saved the debug info, test unstrip too.