summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-objcopy
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-strip] Minor fix of the usage of TableGenAlexander Shaposhnikov2018-05-231-0/+4
| | | | | | | | | | | | This is a small follow-up to the revisions r333117 and r331663. 1. Avoid the name conflicts of the generated variables for prefixes. 2. Apply clang-format -i -style=llvm to llvm-objcopy.cpp once again. 3. Add a test for the flag with double dash. Test plan: make check-all llvm-svn: 333120
* [llvm-strip] Expose --keep-symbol optionAlexander Shaposhnikov2018-05-231-0/+8
| | | | | | | | | | Expose --keep-symbol option in llvm-strip. Test plan: make check-all Differential revision: https://reviews.llvm.org/D47222 llvm-svn: 333117
* [llvm-objcopy] Fix the behavior of --strip-* and --keep-symbolAlexander Shaposhnikov2018-05-221-0/+57
| | | | | | | | | | | | If one runs llvm-objcopy --strip-all --keep-symbol foo and the symbol table indeed contains the symbol "foo" then it should not be removed. Test plan: make check-all Differential revision: https://reviews.llvm.org/D47052 llvm-svn: 333008
* Revert "[llvm-objcopy] Add --strip-unneeded option"Paul Semel2018-05-221-136/+0
| | | | | | | | There is a use after free I didn't see. Need to investigate. This reverts commit f7624abeb1f0d012309baf2e78cf2499fbfe5e5f. llvm-svn: 332925
* [llvm-objcopy] Add --strip-unneeded optionPaul Semel2018-05-211-0/+136
| | | | | | | | This option removes symbols that are not needed by relocations. Differential Revision: https://reviews.llvm.org/D46896 llvm-svn: 332915
* [llvm-objcopy] Add --only-keep-debug as a noopJake Ehrlich2018-05-151-0/+20
| | | | | | | | | | | | | | | | | | | This option just keeps being a problem and really needs to be implemented in some fashion. Implementing it properly requires some kind of "replaceSectionReference" method because all the existing links need to be maintained. The desired behavior is just for allocated sections to become NOBITS but actually implementing that is rather tricky due to the current design of llvm-objcopy. However converting allocated sections to NOBITS is just an optimization and not something debuggers need. Debuggers can debug a stripped executable and take an unstripped executable for that stripped executable as input. Additionally allocated sections account for a very small part of debug binaries so this optimization is quite small. I propose that for the time being we implement this as a NOP so that people can use llvm-objcopy where they need to, just in a sub-optimal way. This option has already blocked a lot of people and its currently blocking me. llvm-svn: 332396
* [llvm-objcopy] Add --keep-symbol (-K) optionPaul Semel2018-05-152-0/+102
| | | | | | | | | This option permits to explicitly keep the specified symbol so that it doesn't get removed. Differential Revision: https://reviews.llvm.org/D46819 llvm-svn: 332356
* [llvm-strip] Add support for -remove-sectionAlexander Shaposhnikov2018-05-112-0/+117
| | | | | | | | | | This diff adds support for -remove-section to llvm-strip. Test plan: make check-all Differential revision: https://reviews.llvm.org/D46567 llvm-svn: 332081
* [llvm-objcopy] Update remove-section.testAlexander Shaposhnikov2018-05-111-0/+9
| | | | | | | | | Verify that the input binary is not getting modified and add an invocation which uses -remove-section instead of -R. Test plan: make check-all llvm-svn: 332078
* [llvm-objcopy] Add tests for help messagesAlexander Shaposhnikov2018-05-102-10/+13
| | | | | | | | | | | This diff slightly reorganizes the tests and improves the test coverage of help messages / error reports. Test plan: make check-all Differential revision: https://reviews.llvm.org/D46589 llvm-svn: 331993
* Fix tests added in r331924 so that they work on Windows.Douglas Yung2018-05-102-2/+2
| | | | | | The test needed to check for the optional executable extension (llvm-objcopy.EXE). llvm-svn: 331952
* [llvm-objcopy] Add --strip-symbol (-N) optionPaul Semel2018-05-093-0/+120
| | | | llvm-svn: 331924
* [llvm-objcopy] Fix exit codeAlexander Shaposhnikov2018-05-081-0/+8
| | | | | | | | | | Set the exit code to 1 if no arguments are specified. Test plan: make check-all Differential revision: https://reviews.llvm.org/D46547 llvm-svn: 331776
* [tools] Introduce llvm-stripAlexander Shaposhnikov2018-05-072-0/+20
| | | | | | | | | | | | llvm-strip is supposed to be a drop-in replacement for binutils strip. To start the ball rolling this diff adds the initial bits for llvm-strip, more features will be added incrementally over time. Test plan: make check-all Differential revision: https://reviews.llvm.org/D46407 llvm-svn: 331663
* [llvm-objcopy] Add --discard-all (-x) optionPaul Semel2018-05-021-0/+91
| | | | llvm-svn: 331400
* [llvm-objcopy] Add --weaken optionPaul Semel2018-05-021-0/+94
| | | | llvm-svn: 331397
* [llvm-objcopy] Add --weaken-symbol (-W) optionPaul Semel2018-04-271-0/+75
| | | | llvm-svn: 331070
* [llvm-objcopy] Add --globalize-symbol optionPaul Semel2018-04-271-0/+75
| | | | llvm-svn: 331068
* [llvm-objcopy] Implement --redefine-sym optionAlexander Shaposhnikov2018-04-261-0/+81
| | | | | | | | | | | This diff implements --redefine-sym option for changing the name of a symbol. Test plan: make check-all Differential revision: https://reviews.llvm.org/D46029 llvm-svn: 330973
* [llvm-objcopy] Add --localize-symbol optionPaul Semel2018-04-261-0/+81
| | | | llvm-svn: 330963
* Recommit "[llvm-objcopy] Switch over to using TableGen for parsing arguments"Alexander Shaposhnikov2018-04-248-8/+8
| | | | | | | | | Add explicit dependency on ObjcopyTableGen and rerun the tests on Windows. I will double-check the build bots and revert this commit if necessary. llvm-svn: 330685
* [llvm-objcopy] Fix sh_linkAlexander Shaposhnikov2018-04-202-1/+49
| | | | | | | | | | | | This diff fixes sh_link for various types of sections (i.e. for SHT_ARM_EXIDX, SHT_HASH). In particular, this change enables us to use llvm-objcopy with clang -gsplit-dwarf for the target android-arm. Test plan: make check-all Differential revision: https://reviews.llvm.org/D45851 llvm-svn: 330478
* Revert "[llvm-objcopy] Switch over to using TableGen for parsing arguments"Jake Ehrlich2018-04-128-8/+8
| | | | | | | | TableGen seems to work differently on windows. I'll need to revert this This reverts commit 7a153ddea067b24da59f6a66c733d79205969501. llvm-svn: 329867
* [llvm-objcopy] Switch over to using TableGen for parsing argumentsJake Ehrlich2018-04-118-8/+8
| | | | | | | | | Swithces from using the command line library to using TableGen. This will allow llvm-strip to exist and allow refinements of the command line syntax. Differential Revision: https://reviews.llvm.org/D44236 llvm-svn: 329863
* [llvm-objcopy] Implement support for section groupsAlexander Shaposhnikov2018-03-215-0/+208
| | | | | | | | | | | | | | | | | | | This diff adds support for SHT_GROUP sections to llvm-objcopy. Some sections are interrelated and comprise a group. For example, a definition of an inline function might require, in addition to the section containing its instructions, a read-only data section containing literals referenced inside the function. A section of the type SHT_GROUP contains the indices of the group members, therefore, it needs to be updated whenever the indices change. Similarly, the fields sh_link, sh_info should be recalculated as well. [Resubmit r328012 with the proper handling of endianness] Test plan: make check-all Differential revision: https://reviews.llvm.org/D43996 llvm-svn: 328143
* [llvm-objcopy] Revert the tests from r328012Alexander Shaposhnikov2018-03-204-152/+0
| | | | | | Temporarily revert the tests from r328012 as well. llvm-svn: 328026
* [llvm-objcopy] Implement support for section groupsAlexander Shaposhnikov2018-03-204-0/+152
| | | | | | | | | | | | | | | | | This diff adds support for SHT_GROUP sections to llvm-objcopy. Some sections are interrelated and comprise a group. For example, a definition of an inline function might require, in addition to the section containing its instructions, a read-only data section containing literals referenced inside the function. A section of the type SHT_GROUP contains the indices of the group members, therefore, it needs to be updated whenever the indices change. Similarly, the fields sh_link, sh_info should be recalculated as well. Test plan: make check-all Differential revision: https://reviews.llvm.org/D43996 llvm-svn: 328012
* Revert "[llvm-objcopy] Add support for large indexes"Jake Ehrlich2018-03-075-74/+0
| | | | | | | | Not all build bots have unzip which I used in a test. This reverts commit 0b1f26d39ea42dd3716b525fbc8c78d8c7bb4479. llvm-svn: 326941
* [llvm-objcopy] Add support for large indexesJake Ehrlich2018-03-075-0/+74
| | | | | | | | | | | | | Because of -ffunction-sections (and maybe other use cases I'm not aware of?) it can occur that we need more than 0xfeff sections but ELF dosn't support that many sections. To solve this problem SHN_XINDEX exists and with it come a whole host of changes for section indexes everywhere. This change adds support for those cases which should allow llvm-objcopy to copy binaries that have an arbitrary number of sections. Differential Revision: https://reviews.llvm.org/D42516 llvm-svn: 326940
* [llvm-objcopy] Use the full filename in --add-gnu-debuglinkAlexander Richardson2018-02-191-2/+3
| | | | | | | | | | | | | | | | | Summary: The current implementation was writing the file name without the extension whereas GNU objcopy writes the full filename. With this change GDB will now load the .debug file instead of silently ignoring it. Reviewers: jakehehrlich, jhenderson Reviewed By: jakehehrlich Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43474 llvm-svn: 325528
* [llvm-objcopy] Fix handling of zero-size segments in llvm-objcopyJake Ehrlich2018-02-141-0/+111
| | | | | | | | | | | | | | | | | Some ELF files produced by lld may have zero-size segment placeholders as shown below. Since GNU_STACK Offset is 0, the current code makes it the lowest used offset, and relocates all the segments over the ELF header. The resulting binary is total garbage. This change fixes how llvm-objcopy handles PT_PHDR properlly by treating ELF headers and the program header table as segments to allow the layout algorithm decide where those should go. Author: vit9696 Differential Revision: https://reviews.llvm.org/D42872 llvm-svn: 325189
* [llvm-objcopy] Make modifications in-place if output is not specifiedAlexander Shaposhnikov2018-02-091-0/+29
| | | | | | | | | | | | | | If the output file is not specified make the modifications in-place (like binutils objcopy does). In particular, this fixes the behavior of Clang -gsplit-dwarf (if Clang is configured to use llvm-objcopy), previously it was creating .dwo files, but still leaving *dwo* sections in the original binary. Test plan: make check-all Differential revision: https://reviews.llvm.org/D42873 llvm-svn: 324783
* [llvm-objcopy] Refactor llvm-objcopy to use reader and writer objectsJake Ehrlich2018-01-253-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While writing code for input and output formats in llvm-objcopy it became apparent that there was a code health problem. This change attempts to solve that problem by refactoring the code to use Reader and Writer objects that can read in different objects in different formats, convert them to a single shared internal representation, and then write them to any other representation. New classes: Reader: the base class used to construct instances of the internal representation Writer: the base class used to write out instances of the internal representation ELFBuilder: a helper class for ELFWriter that takes an ELFFile and converts it to a Object SectionVisitor: it became necessary to remove writeSection from SectionBase because, under the new Reader/Writer scheme, it's possible to convert between ELF Types such as ELF32LE and ELF32BE. This isn't possible with writeSection because it (dynamically) depends on the underlying section type *and* (statically) depends on the ELF type. Bad things would happen if the underlying sections for ELF32LE were used for writing to ELF64BE. To avoid this code smell (which would have compiled, run, and output some nonsesnse) I decoupled writing of sections from a class. SectionWriter: This is just the ELFT templated implementation of SectionVisitor. Many classes now have this class as a friend so that the writing methods in this class can write out private data. ELFWriter: This is the Writer that outputs to ELF BinaryWriter: This is the Writer that outputs to Binary ElfType: Because the ELF Type is not a part of the Object anymore we need a way to construct the correct default Writer based on properties of the Reader. This enum just keeps track of the ELF type of the input so it can be used as the default output type as well. Object has correspondingly undergone some serious changes as well. It now has more generic methods for building and manipulating ELF binaries. This interface makes ELFBuilder easy enough to use and will make the BinaryReader/Builder easy to create as well. Most changes in this diff are cosmetic and deal with the fact that a method has been moved from one class to another or a change from a pointer to a reference. Almost no changes should result in a functional difference (this is after all a refactor). One minor functional change was made and the result can be seen in remove-shstrtab-error.test. The fact that it fails hasn't changed but the error message has changed because that failure is detected at a later point in the code now (because WriteSectionHeaders is a property of the ElfWriter *not* a property of the Object). I'd say roughly 80-90% of this code is cosmetically different, 10-19% is different but functionally the same, and 1-5% is functionally different despite not causing a change in tests. Differential Revision: https://reviews.llvm.org/D42222 llvm-svn: 323480
* [llvm-objcopy] Add --add-gnu-debuglinkJake Ehrlich2018-01-251-0/+27
| | | | | | | | This change adds support for --add-gnu-debuglink to llvm-objcopy Differential Revision: https://reviews.llvm.org/D41731 llvm-svn: 323477
* Revert r322132; it appears to be an accidental commit, based on the commit ↵Aaron Ballman2018-01-251-27/+0
| | | | | | message. The original author of the commit has not commented on whether this was accidental or purposeful, so if this revert is in error, the author can re-commit with an actual commit message. llvm-svn: 323466
* Reverting r323463 as it appears to be an accidental commit. Regardless, it ↵Aaron Ballman2018-01-253-3/+1
| | | | | | | | | | broke a lot of build bots, so reverting back to green. http://lab.llvm.org:8011/builders/lldb-amd64-ninja-netbsd8/builds/9294 http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/24084 http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/9567 llvm-svn: 323465
* tmpJake Ehrlich2018-01-253-1/+3
| | | | llvm-svn: 323463
* [llvm-objcopy] Use physical instead of virtual address when aligning and ↵Jake Ehrlich2018-01-226-12/+100
| | | | | | | | | | | | | | | | | | | | | placing sections in binary For sections with different virtual and physical addresses, alignment and placement in the output binary should be based on the physical address. Ran into this problem with a bare metal ARM project where llvm-objcopy added a lot of zero-padding before the .data section that had differing addresses. GNU objcopy did not add the padding, and after this fix, neither does llvm-objcopy. Update a test case so a section has different physical and virtual addresses. Fixes B35708 Authored By: Owen Shaw (owenpshaw) Differential Revision: https://reviews.llvm.org/D41619 llvm-svn: 323144
* tempJake Ehrlich2018-01-091-0/+27
| | | | llvm-svn: 322132
* [llvm-objcopy] Add --localize-hidden optionJake Ehrlich2018-01-051-0/+164
| | | | | | | This change adds support in llvm-objcopy for GNU objcopy's --localize-hidden option. This option changes every hidden or internal symbol into a local symbol. llvm-svn: 321884
* [llvm-objcopy] Add support for visibilityJake Ehrlich2018-01-021-1/+34
| | | | | | | I have no clue how this was missed when symbol table support was added. This change ensures that the visibility of symbols is preserved by default. llvm-svn: 321681
* [llvm-objcopy] Add option to add a progbits section from a fileJake Ehrlich2017-12-192-0/+73
| | | | | | | | This change adds support for adding progbits sections with contents from a file Differential Revision: https://reviews.llvm.org/D41212 llvm-svn: 321047
* Simplify test.Rafael Espindola2017-12-051-11/+7
| | | | | | It can use attrib instead of icacls. llvm-svn: 319809
* Delete temp file if rename fails.Rafael Espindola2017-12-051-0/+22
| | | | | | | | | | | | | | | | | | | Without this when lld failed to replace the output file it would leave the temporary behind. The problem is that the existing logic is - cancel the delete flag - rename We have to cancel first to avoid renaming and then crashing and deleting the old version. What is missing then is deleting the temporary file if the rename fails. This can be an issue on both unix and windows, but I am not sure how to cause the rename to fail reliably on unix. I think it can be done on ZFS since it has an ACL system similar to what windows uses, but adding support for checking that in llvm-lit is probably not worth it. llvm-svn: 319786
* [llvm-objcopy] Add support for --only-keep/-j and --keepJake Ehrlich2017-11-3012-0/+267
| | | | | | | | | | | | | This change adds support for the --only-keep option and the -j alias as well. A common use case for these being used together is to dump a specific section's data. Additionally the --keep option is added (GNU objcopy doesn't have this) to avoid removing a bunch of things. This allows people to err on the side of stripping aggressively and then to keep the specific bits that they need for their application. Differential Revision: https://reviews.llvm.org/D39021 llvm-svn: 319467
* [llvm-objcopy] Add --strip-all-gnu and change --strip-allJake Ehrlich2017-11-272-34/+63
| | | | | | | | | | | | | | GNU's --strip-all doesn't strip as aggressively as it could in general. Currently llvm-objcopy copies the exact behavoir of GNU's --strip-all. eu-strip is used as a drop in replacement for GNU strip/objcopy in many many places without issue. eu-strip removes non-allocated sections and keeps .gnu.warning* sections. Because --strip-all will likely be the most widely used stripping option we should make --strip-all as aggressive as it can safely be. Since we have evidence from eu-strip that this is a safe option we should allow it. For those that might still have an issue afterwards I've added --strip-all-gnu as an exact drop in replacement for GNU's --strip-all as well. llvm-svn: 319071
* [llvm-objcopy] Change -O binary to respect section removal and behave like ↵Jake Ehrlich2017-11-158-0/+409
| | | | | | | | | | | | | | | | GNU objcopy The original -O binary implementation just copied segment data from the object and dumped it into a file. This doesn't take into account any operations performed on objects such as section removal. GNU objcopy has some specific behavior that we'd also like to respect. For instance using -O binary and -j <some_section> will dump <some_section> to a file. This change implements GNU objcopy style -O binary to as close of an approximation as I can determine. Differential Revision: https://reviews.llvm.org/D39713 llvm-svn: 318324
* [llvm-objcopy] Add -strip-non-alloc option to remove all non-allocated sectionsJake Ehrlich2017-11-141-0/+26
| | | | | | | | | This change adds a new flag not present in GNU objcopy that we call --strip-non-alloc. Differential Revision: https://reviews.llvm.org/D39926 llvm-svn: 318168
* [llvm-objcopy] Support the rest of the ELF formatsJake Ehrlich2017-11-143-0/+84
| | | | | | | | | | | | We haven't been supporting anything but ELF64LE since the start. Luckily this was always accounted for and the change is pretty trivial. B35281 requests this change for ELF32LE. This change adds support for ELF32LE, ELF64BE, and ELF32BE with all supported features that already existed for ELF64LE. Differential Revision: https://reviews.llvm.org/D39977 llvm-svn: 318166
* [llvm-objcopy] Add --strip-debugJake Ehrlich2017-11-131-0/+54
| | | | | | | | | | | | | | | | Many projects use this option. There are two ways to use it. You can either a) Just use --strip-debug and keep the old file with debug content or b) you can use --strip-debug, --only-keep-debug, and --add-gnu-debuglink all in conjunction to create two separate files, the stripped file and the debug file. --only-keep-debug is more complicated than --strip-debug because it keeps the section headers without keeping section contents. That's not really supported by llvm-objcopy at the moment but I plan on adding it. So this change just supports a) and options to support b) will come soon. Differential Revision: https://reviews.llvm.org/D39919 llvm-svn: 318094
OpenPOWER on IntegriCloud