summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-objcopy
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-objcopy] Rename --keep to --keep-section.Jordan Rupprecht2018-11-135-7/+7
| | | | | | | | | | | | | | | | Summary: llvm-objcopy/strip support `--keep` (for sections) and `--keep-symbols` (for symbols). For consistency and clarity, rename `--keep` to `--keep-section`. In fact, for GNU compatability, -K is --keep-symbol, so it's weird that the alias `-K` is not the same as the short-ish `--keep`. Reviewers: jakehehrlich, jhenderson, alexshap, MaskRay, espindola Reviewed By: jakehehrlich, MaskRay Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D54477 llvm-svn: 346782
* [llvm-strip] Support --keep and --strip-all-gnu from llvm-objcopyJordan Rupprecht2018-11-012-0/+4
| | | | | | | | | | | | | | Summary: Add --keep and --strip-all-gnu from llvm-objcopy into llvm-strip. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53954 llvm-svn: 345861
* [llvm-objcopy] Support --{enable,disable}-deterministic-archivesJordan Rupprecht2018-11-011-0/+65
| | | | | | | | | | | | | | Summary: ar and objcopy/strip all support configuring whether archives are written deterministically (timestamps/UIDs/GIDs/etc zero'd). This has been ported to llvm-ar (the U/D modifiers) but not yet to llvm-objcopy/strip. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Subscribers: ruiu, mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D53913 llvm-svn: 345859
* [llvm-objcopy] Don't apply --localize flags to common symbolsJordan Rupprecht2018-11-012-1/+37
| | | | | | | | | | | | | | | | | Summary: --localize-symbol and --localize-hidden will currently localize common symbols. GNU objcopy will not localize these symbols even when explicitly requested, which seems reasonable; common symbols should always be global so they can be merged during linking. See PR39461 Reviewers: jakehehrlich, jhenderson, alexshap, MaskRay, espindola Reviewed By: jakehehrlich, jhenderson, alexshap, MaskRay Subscribers: emaste, arichardson, alexshap, MaskRay, llvm-commits Differential Revision: https://reviews.llvm.org/D53782 llvm-svn: 345856
* [llvm-objcopy] Fix --keep-global-symbol/--globalize-symbol for undefined ↵Jordan Rupprecht2018-10-302-4/+21
| | | | | | | | | | | | | | | | symbols. Summary: --keep-global-symbol and --globalize-symbol don't make sense for undefined symbols, so it should be ignored for those symbols. This matches GNU objcopy behavior. Reviewers: jhenderson, alexshap, jakehehrlich, espindola Reviewed By: jhenderson, jakehehrlich Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53733 llvm-svn: 345614
* [llvm-strip] Support -s alias for --strip-all. Make both strip and objcopy ↵Jordan Rupprecht2018-10-231-4/+8
| | | | | | | | | | | | | | | | | | | | | case sensitive to support both -s (--strip-all) and -S (--strip-debug). Summary: GNU strip supports both `-s` and `-S` as aliases for `--strip-all` and `--strip-debug`, respectfully. As part of this, it turns out that strip/objcopy were accepting case insensitive command line args. I'm not sure if there was an explicit reason for this. The only others uses of this are llvm-cvtres/llvm-mt/llvm-lib, which are all tools specific for windows support. Forcing case sensitivity allows both aliases to exist, but seems like a good idea anyway. And as a surprise test case adjustment, the llvm-strip unit test was running with `-keep=unavailable_symbol`, despite `keep` not be a valid flag for strip. This is because there is a flag `-K` which, when case insensitivity is permitted, allows it to be interpreted as `-K` = `eep=unavailable_symbol` (e.g. to allow `-Kfoo` == `--keep-symbol=foo`). Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jakehehrlich Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53163 llvm-svn: 345068
* [llvm-objcopy] NFC: update TODO test commentJordan Rupprecht2018-10-151-1/+1
| | | | llvm-svn: 344550
* [llvm-objcopy] Add -F|--target compatibilityJordan Rupprecht2018-10-121-0/+22
| | | | | | | | | | | | | | | | | Summary: This change adds support for the GNU --target flag, which sets both --input-target and --output-target. GNU objcopy doesn't do any checking for whether both --target and --{input,output}-target are used, and so it allows both, e.g. "--target A --output-target B" is equivalent to "--input-target A --output-target B" since the later command line flag would override earlier ones. This may be error prone, so I chose to implement it as an error if both are used. I'm not sure if anyone is actually using both. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jakehehrlich, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53029 llvm-svn: 344321
* [llvm-objcopy] Make -S an alias for --strip-allJake Ehrlich2018-10-092-2/+4
| | | | | | -S should be an alias for --strip-all not --strip-all-gnu llvm-svn: 344080
* [NFC] Adding "REQUIRES: zlib" to a llvm-objcopy test for bots without zlib.Puyan Lotfi2018-10-011-0/+2
| | | | | | M test/tools/llvm-objcopy/compress-and-decompress-debug-sections-error.test llvm-svn: 343454
* [llvm-objcopy] Adding support for decompressing zlib compressed dwarf sections.Puyan Lotfi2018-10-014-0/+57
| | | | | | | | | | | | | | | Summary: I had added support for compressing dwarf sections in a prior commit, this one adds support for decompressing. Usage is: llvm-objcopy --decompress-debug-sections input.o output.o Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D51841 llvm-svn: 343451
* [llvm-objcopy/llvm-strip]: handle --versionJordan Rupprecht2018-09-212-0/+8
| | | | | | | | | | | | | | | | | Summary: Implement --version for objcopy and strip. I think there are LLVM utilities that automatically handle this, but that doesn't seem to work with custom parsing since this binary handles both objcopy and strip, so it uses custom parsing. This fixes PR38298 Reviewers: jhenderson, alexshap, jakehehrlich Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52328 llvm-svn: 342702
* [llvm-objcopy] Add missing alias for --strip-all-gnuAlexander Shaposhnikov2018-09-171-0/+3
| | | | | | | | | | | | | This diff adds -S as an alias for --strip-all-gnu (for compatibility with binutils' objcopy). Patch by Dmitry Golovin! Test plan: make check-all Differential revision: https://reviews.llvm.org/D52163 llvm-svn: 342364
* [objcopy] make objcopy follow program header standardsJulie Hockett2018-09-124-5/+21
| | | | | | | | | | | | | | | | | | Submitted on behalf of Armando Montanez (amontanez@google.com). Objects with unused program headers copied by objcopy would always have nonzero values for program header offset and program header entry size. While technically valid, this atypical behavior triggers warnings in some tools. This change sets the two fields to zero when the program header is unused, better fitting the general expectations for unused program header data. Section headers behaved somewhat similarly (though only with the entry size), and are fixed in this revision as well. Differential Revision: https://reviews.llvm.org/D51961 llvm-svn: 342065
* [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).Puyan Lotfi2018-09-076-0/+146
| | | | | | | | | | | | | | | | | | | | | | | Third Attempt: - Alignment issues resolved. - zlib::isAvailable() detected. - ArrayRef misuse fixed. Usage: llvm-objcopy --compress-debug-sections=zlib foo.o llvm-objcopy --compress-debug-sections=zlib-gnu foo.o In both cases the debug section contents is compressed with zlib. In the GNU style case the header is the "ZLIB" magic string followed by the uint64 big- endian decompressed size. In the non-GNU mode the header is the Elf(32|64)_Chdr. Decompression support is coming soon. Differential Revision: https://reviews.llvm.org/D49678 llvm-svn: 341635
* [llvm-strip] -p test fix for windows buildbotsJordan Rupprecht2018-09-071-4/+4
| | | | | | Windows ls prints dates as "1997-05-05" instead of "May 05 1997", so only check for a leading space. llvm-svn: 341614
* Revert: [llvm-objcopy] Dwarf .debug section compression (Second Attempt).Puyan Lotfi2018-09-076-146/+0
| | | | | | Various bots still fail for unknown reason. llvm-svn: 341613
* [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).Puyan Lotfi2018-09-066-0/+146
| | | | | | | | | | | | | | | | | | | | Second Attempt. Alignment issues resolved. zlib::isAvailable() detected. Usage: llvm-objcopy --compress-debug-sections=zlib foo.o llvm-objcopy --compress-debug-sections=zlib-gnu foo.o In both cases the debug section contents is compressed with zlib. In the GNU style case the header is the "ZLIB" magic string followed by the uint64 big- endian decompressed size. In the non-GNU mode the header is the Elf(32|64)_Chdr. Decompression support is coming soon. Differential Revision: https://reviews.llvm.org/D49678 llvm-svn: 341607
* [llvm-strip] Fix -p test to check for explicit spaces around dates, to avoid ↵Jordan Rupprecht2018-09-061-4/+4
| | | | | | when the filename happens to contain 1995/1997. llvm-svn: 341595
* [llvm-strip] Support stripping multiple input filesJordan Rupprecht2018-09-051-0/+75
| | | | | | | | | | | | | | | | | Summary: Allow strip to be called on multiple input files, which is interpreted as stripping N files in place. Using multiple input files is incompatible with -o. To allow this, create a `DriverConfig` struct which just wraps a list of `CopyConfigs`. objcopy will only ever have a single `CopyConfig`, but strip will have N (where N >= 1) CopyConfigs. Reviewers: alexshap, jakehehrlich Reviewed By: alexshap, jakehehrlich Subscribers: MaskRay, jakehehrlich, llvm-commits Differential Revision: https://reviews.llvm.org/D51660 llvm-svn: 341464
* [llvm-strip] Allow copying relocation sections without symbol tables.Jordan Rupprecht2018-09-041-0/+45
| | | | | | | | | | | | | | | | | | | | | Summary: Fixes the error "Link field value 0 in section .rela.plt is invalid" when copying/stripping certain binaries. Minimal repro: ``` $ cat /tmp/a.c int main() { return 0; } $ clang -static /tmp/a.c -o /tmp/a $ llvm-strip /tmp/a -o /tmp/b llvm-strip: error: Link field value 0 in section .rela.plt is invalid. ``` Reviewers: jakehehrlich, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51493 llvm-svn: 341419
* Revert r341342: Dwarf .debug section compression support (zlib, zlib-gnu).Chandler Carruth2018-09-046-146/+0
| | | | | | | | | | | | Also reverts follow-up commits r341343 and r341344. The primary commit continues to break some build bots even after the fixes in r341343 for UBSan issues: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/5823 It is also failing for me locally (linux, x86-64). llvm-svn: 341360
* [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).Puyan Lotfi2018-09-036-0/+146
| | | | | | | | | | | | | | | | | | | Usage: llvm-objcopy --compress-debug-sections=zlib foo.o llvm-objcopy --compress-debug-sections=zlib-gnu foo.o In both cases the debug section contents is compressed with zlib. In the GNU style case the header is the "ZLIB" magic string followed by the uint64 big- endian decompressed size. In the non-GNU mode the header is the Elf(32|64)_Chdr. Decompression support is coming soon. Differential Revision: https://reviews.llvm.org/D49678 llvm-svn: 341342
* [llvm-strip] Fix -p|--preserve-dates to not truncate output when used in-place.Jordan Rupprecht2018-08-291-0/+8
| | | | | | | | The restoreDateOnFile() method used to preserve dates uses sys::fs::openFileForWrite(). That method defaults to opening files with CD_CreateAlways, which truncates the output file if it exists. Use CD_OpenExisting instead to open it and *not* truncate it, which also has the side benefit of erroring if the file does not exist (it should always exist, because we just wrote it out). Also, fix the test case to make sure the output is a valid output file, and not empty. The extra test assertions are enough to catch this regression. llvm-svn: 340996
* [llvm-objcopy] Implement -G/--keep-global-symbol(s).Jordan Rupprecht2018-08-172-0/+146
| | | | | | | | | | | | | | | | | Summary: Port GNU Objcopy -G/--keep-global-symbol(s). This is slightly different than the already-implemented --globalize-symbol, which marks a symbol as global when copying. When --keep-global-symbol (alias -G) is used, *only* those symbols marked will stay global, and all other globals are demoted to local. (Also note that it doesn't *promote* a symbol to global). Additionally, there is a pluralized version of the flag --keep-global-symbols, which effectively applies --keep-global-symbol for every non-comment in a file. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50589 llvm-svn: 340105
* Fix windows buildbots by removing : from filenamesJordan Rupprecht2018-08-171-4/+4
| | | | llvm-svn: 340071
* [llvm-objcopy] Add support for -I binary -B <arch>.Jordan Rupprecht2018-08-174-0/+212
| | | | | | | | | | | | | | | | | Summary: The -I (--input-target) and -B (--binary-architecture) flags exist but are currently silently ignored. This adds support for -I binary for architectures i386, x86-64 (and alias i386:x86-64), arm, aarch64, sparc, and ppc (powerpc:common64). This is largely based on D41687. This is done by implementing an additional subclass of Reader, BinaryReader, which works by interpreting the input file as contents for .data field, sets up a synthetic header, and adds additional sections/symbols (e.g. _binary__tmp_data_txt_start). Reviewers: jakehehrlich, alexshap, jhenderson, javed.absar Reviewed By: jhenderson Subscribers: jyknight, nemanjai, kbarton, fedor.sergeev, jrtc27, kristof.beyls, paulsemel, llvm-commits Differential Revision: https://reviews.llvm.org/D50343 llvm-svn: 340070
* [llvm-strip] Add support for -p/--preserve-datesJordan Rupprecht2018-08-161-0/+70
| | | | | | | | | | | | | | Summary: [llvm-strip] Preserve access/modification timestamps when -p is used. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50744 llvm-svn: 339921
* [llvm-objcopy] NFC: Add some color to error()Jordan Rupprecht2018-08-092-2/+2
| | | | llvm-svn: 339404
* [llvm-objcopy] Add --prefix-symbols optionPaul Semel2018-08-091-0/+71
| | | | | | Differential Revision: https://reviews.llvm.org/D50381 llvm-svn: 339362
* [llvm-objcopy] Add --dump-sectionPaul Semel2018-08-091-0/+16
| | | | | | Differential Revision: https://reviews.llvm.org/D49979 llvm-svn: 339358
* [lit, python] Always add quotes around the python path in litStella Stamenova2018-08-064-4/+4
| | | | | | | | | | | | | | | | | Summary: The issue with the python path is that the path to python on Windows can contain spaces. To make the tests always work, the path to python needs to be surrounded by quotes. This change updates several configuration files which specify the path to python as a substitution and also remove quotes from existing tests. Reviewers: asmith, zturner, alexshap, jakehehrlich Reviewed By: zturner, alexshap, jakehehrlich Subscribers: mehdi_amini, nemanjai, eraman, kbarton, jakehehrlich, steven_wu, dexonsmith, stella.stamenova, delcypher, llvm-commits Differential Revision: https://reviews.llvm.org/D50206 llvm-svn: 339073
* [llvm-objcopy] Add support for --rename-section flags from gnu objcopyJordan Rupprecht2018-08-014-2/+251
| | | | | | | | | | | | | | | | | Summary: Add support for --rename-section flags from gnu objcopy. Not all flags appear to have an effect for ELF objects, but allowing them would allow easier drop-in replacement. Other unrecognized flags are rejected. This was only tested by comparing flags printed by "readelf -e <.o>" against the output of gnu vs llvm objcopy, it hasn't been tested to be valid beyond that. Reviewers: jakehehrlich, alexshap Subscribers: llvm-commits, paulsemel, alexshap Differential Revision: https://reviews.llvm.org/D49870 llvm-svn: 338582
* [llvm-objcopy] Make --strip-debug strip .gdb_indexFangrui Song2018-07-311-1/+7
| | | | | | | | | | | | | | | | | Summary: See binutils-gdb/bfd/elf.c, GNU objcopy also strips .stab* (STABS) .line* (DWARF 1) .gnu.linkonce.wi.* (linkonce section for .debug_info) but I'm not sure we need to be compatible with it. Reviewers: dblaikie, alexshap, jakehehrlich, jhenderson Reviewed By: alexshap, jakehehrlich Subscribers: aprantl, JDevlieghere, jakehehrlich, llvm-commits Differential Revision: https://reviews.llvm.org/D50100 llvm-svn: 338443
* Handle the lack of a symbol table correctly.Stephen Hines2018-07-261-0/+7
| | | | | | | | | | | | | | | | | Summary: These two cases will trigger a dereference on a nullptr, since the SymbolTable can be nonexistent for a given library, in addition to just being empty. Reviewers: alexshap Reviewed By: alexshap Subscribers: meikeb, kongyi, chh, jakehehrlich, llvm-commits, pirama Differential Revision: https://reviews.llvm.org/D49534 llvm-svn: 338062
* [llvm-objcopy] Add basic support for --rename-sectionJordan Rupprecht2018-07-202-0/+71
| | | | | | | | | | | | | | | Summary: Add basic support for --rename-section=old=new to llvm-objcopy. A full replacement for GNU objcopy requires also modifying flags (i.e. --rename-section=old=new,flag1,flag2); I'd like to keep that in a separate change to keep this simple. Reviewers: jakehehrlich, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49576 llvm-svn: 337604
* [llvm-objcopy, tests] Fix several llvm-objcopy testsStella Stamenova2018-07-201-1/+9
| | | | | | | | | | | | | | Summary: In Python 3, sys.stdout.write expects a string rather than bytes. In order to be able to write the bytes to stdout, we need to use the buffer directly instead. This change is borrowing the implementation for writing to stdout that cat.py uses. Note that we cannot use cat.py directly because the file we are trying to open is a gzip file. Reviewers: asmith, bkramer, alexshap, jakehehrlich Reviewed By: alexshap, jakehehrlich Subscribers: jakehehrlich, llvm-commits Differential Revision: https://reviews.llvm.org/D49515 llvm-svn: 337567
* [llvm-objcopy] %python wants to be in quotes, because it might contain spacesBenjamin Kramer2018-07-184-4/+4
| | | | llvm-svn: 337399
* [llvm-objcopy] Run not with any python, but the python configured in lit.Benjamin Kramer2018-07-174-4/+4
| | | | llvm-svn: 337262
* [llvm-objcopy] Add support for large indexesJake Ehrlich2018-07-166-0/+80
| | | | | | | | | | | | | | | | | | | This patch is an update of an older patch that never landed (see here: https://reviews.llvm.org/D42516) Recently various users have run into this issue and it just 100% has to be solved at this point. The main difference in this patch is that I use gunzip instead of unzip which should hopefully allow tests to pass. Please review this as if it is a new patch however. I found some issues along the way and made some minor modifications. The binary used in this patch for testing (a zip file to make it small) can be found here: https://drive.google.com/file/d/1UjsnTO9edLttZibbr-2T1bJl92KEQFAO/view?usp=sharing Differential Revision: https://reviews.llvm.org/D49206 llvm-svn: 337204
* Add --strip-all option back to llvm-strip.Stephen Hines2018-07-121-0/+8
| | | | | | | | | | | | | | | | | Summary: This option appears to have been dropped as part of the refactoring in r331663. Unfortunately, if we want to use llvm-strip as a drop-in replacement for strip, this option should still be available. Reviewers: alexshap Reviewed By: alexshap Subscribers: meikeb, kongyi, chh, jakehehrlich, llvm-commits, pirama Differential Revision: https://reviews.llvm.org/D49226 llvm-svn: 336921
* [llvm-objcopy] Add support for static librariesAlexander Shaposhnikov2018-07-064-1/+169
| | | | | | | | | | | This diff adds support for handling static libraries to llvm-objcopy and llvm-strip. Test plan: make check-all Differential revision: https://reviews.llvm.org/D48413 llvm-svn: 336455
* [llvm-strip] Expose --strip-unneeded optionPaul Semel2018-06-071-0/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D47818 llvm-svn: 334182
* [llvm-strip] Expose --discard-all optionAlexander Shaposhnikov2018-06-061-2/+17
| | | | | | | | | | Expose objcopy's --discard-all option in llvm-strip. Test plan: make check-all Differential revision: https://reviews.llvm.org/D47750 llvm-svn: 334131
* [llvm-strip] Add missing aliases for --strip-debugAlexander Shaposhnikov2018-06-041-4/+15
| | | | | | | | | | Add missing aliases for --strip-debug: -g, -S, -d. Test plan: make check-all Differential revision: https://reviews.llvm.org/D47674 llvm-svn: 333940
* [llvm-objcopy] Fix null symbol handlingPaul Semel2018-06-013-0/+46
| | | | | | | | | This fixes the bug where strip-all option was leading to a malformed outputted ELF file. Differential Revision: https://reviews.llvm.org/D47414 llvm-svn: 333772
* [llvm-strip] Add -o option to llvm-stripAlexander Shaposhnikov2018-05-311-4/+15
| | | | | | | | | | | This diff implements the option -o for specifying a file to write the output to. Test plan: make check-all Differential revision: https://reviews.llvm.org/D47505 llvm-svn: 333693
* llvm-objcopy: Set sh_link to 0 on unrecognized symtab-linked sections.Peter Collingbourne2018-05-301-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | Per discussion on the generic-abi mailing list: https://groups.google.com/forum/#!topic/generic-abi/MPr8TVtnVn4 An object file manipulation tool must either write out a symbol table with the same number of entries as the original symbol table and in the same order, or if this is impossible, refuse to operate on the object file if it has unrecognized sections that are linked to the symtab section. However, existing tools (namely GNU strip, GNU objcopy and ld.{bfd,gold,lld} -r) do not comply with this at present: they change symbol table indexes and set sh_link to 0 on the unrecognized symtab-linked sections. We intend to use the latter as a (temporary) signal that a tool has operated on a proposed new symtab-linked section and invalidated the symbol table indexes. However, llvm-objcopy currently keeps sh_link pointing to the new symtab section. This patch changes llvm-objcopy to set sh_link to 0 to match the behaviour of the other tools. Differential Revision: https://reviews.llvm.org/D47404 llvm-svn: 333581
* [llvm-objcopy] Add --keep-file-symbols optionPaul Semel2018-05-261-0/+70
| | | | | | | | This option prevent from removing file symbols while removing symbols. Differential Revision: https://reviews.llvm.org/D46830 llvm-svn: 333339
* [llvm-objcopy] Add --strip-unneeded optionPaul Semel2018-05-251-0/+136
| | | | | | Differential Revision: https://reviews.llvm.org/D46896 llvm-svn: 333267
OpenPOWER on IntegriCloud