summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-objcopy] Consistently use createStringError instead of ↵Martin Storsjo2019-01-225-41/+39
| | | | | | | | | | | | make_error<StringError> This was requested in the review of D57006. Also add missing quotes around symbol names in error messages. Differential Revision: https://reviews.llvm.org/D57014 llvm-svn: 351799
* [llvm-objcopy] [COFF] Implement --only-sectionMartin Storsjo2019-01-191-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D56873 llvm-svn: 351663
* [llvm-objcopy] [COFF] Implement --only-keep-debugMartin Storsjo2019-01-193-0/+21
| | | | | | Differential Revision: https://reviews.llvm.org/D56840 llvm-svn: 351662
* [llvm-objcopy] [COFF] Implement --strip-debugMartin Storsjo2019-01-191-0/+11
| | | | | | | | | Also remove sections similarly for --strip-all, --discard-all, --strip-unneeded. Differential Revision: https://reviews.llvm.org/D56839 llvm-svn: 351661
* [llvm-objcopy] [COFF] Add support for removing sectionsMartin Storsjo2019-01-196-19/+181
| | | | | | Differential Revision: https://reviews.llvm.org/D56683 llvm-svn: 351660
* [llvm-objcopy] [COFF] Remove a superfluous namespace qualification. NFC.Martin Storsjo2019-01-191-1/+1
| | | | llvm-svn: 351658
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1919-76/+57
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [llvm-objcopy] Use SHT_NOTE for added note sections.Jordan Rupprecht2019-01-151-9/+13
| | | | | | | | | | | | | | | | | | | Summary: Fix llvm-objcopy to add .note sections as SHT_NOTEs. GNU objcopy overrides section flags for special sections. For `.note` sections (with the exception of `.note.GNU-stack`), SHT_NOTE is used. Many other sections are special cased by libbfd, but `.note` is the only special section I can seem to find being used with objcopy --add-section. See `.note` in context of the full list of special sections here: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf.c;h=eb3e1828e9c651678b95a1dcbc3b124783d1d2be;hb=HEAD#l2675 Reviewers: jhenderson, alexshap, jakehehrlich, espindola Reviewed By: jhenderson Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D56570 llvm-svn: 351204
* [llvm-objcopy] [COFF] Implement --strip-all[-gnu] for symbolsMartin Storsjo2019-01-152-2/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D56481 llvm-svn: 351174
* [llvm-objcopy] [COFF] Remove unreferenced undefined externals with ↵Martin Storsjo2019-01-141-3/+9
| | | | | | | | --strip-unneeded. Differential Revision: https://reviews.llvm.org/D56660 llvm-svn: 351099
* [llvm-objcopy] [COFF] Remove pointless Reader/Writer base classes. NFC.Martin Storsjo2019-01-124-24/+5
| | | | | | | | | These were copied as part of the original design from the ELF backend, but aren't necessary at the moment. Differential Revision: https://reviews.llvm.org/D56431 llvm-svn: 350996
* [llvm-objcopy] [COFF] Implmement --strip-unneeded and -x/--discard-all for ↵Martin Storsjo2019-01-111-1/+12
| | | | | | | | symbols Differential Revision: https://reviews.llvm.org/D56480 llvm-svn: 350927
* [llvm-objcopy] [COFF] Fix writing object files without symbols/string tableMartin Storsjo2019-01-111-5/+4
| | | | | | | | | | Previously, this was broken - by setting PointerToSymbolTable to zero but still actually writing the string table length, the object file header was corrupted. Differential Revision: https://reviews.llvm.org/D56584 llvm-svn: 350926
* [llvm-objcopy] [COFF] Fix warnings abuilt missing field initialization. NFC.Martin Storsjo2019-01-102-1/+4
| | | | llvm-svn: 350898
* [llvm-objcopy] [COFF] Add support for removing symbolsMartin Storsjo2019-01-108-14/+200
| | | | | | Differential Revision: https://reviews.llvm.org/D55881 llvm-svn: 350893
* [llvm-objcopy] Handle -O <format> flag.Jordan Rupprecht2019-01-073-3/+33
| | | | | | | | | | | | | | | | | Summary: The -O flag is currently being mostly ignored; it's only checked whether or not the output format is "binary". This adds support for a few formats (e.g. elf64-x86-64), so that when specified, the output can change between 32/64 bit and sizes/alignments are updated accordingly. This fixes PR39135 Reviewers: jakehehrlich, jhenderson, alexshap, espindola Reviewed By: jhenderson Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53667 llvm-svn: 350541
* [llvm-objcopy] Fix buildbots on older compilersJordan Rupprecht2019-01-032-3/+4
| | | | llvm-svn: 350343
* Fix typos in commentsJordan Rupprecht2019-01-031-2/+2
| | | | llvm-svn: 350337
* [llvm-objcopy][ELF] Implement a mutable section visitor that updates ↵Jordan Rupprecht2019-01-032-34/+151
| | | | | | | | | | | | | | | | | | | | | size-related fields (Size, EntrySize, Align) before layout. Summary: Fix EntrySize, Size, and Align before doing layout calculation. As a side cleanup, this removes a dependence on sizeof(Elf_Sym) within BinaryReader, so we can untemplatize that. This unblocks a cleaner implementation of handling the -O<format> flag. See D53667 for a previous attempt. Actual implementation of the -O<format> flag will come in an upcoming commit, this is largely a NFC (although not _totally_ one, because alignment on binary input was actually wrong before). Reviewers: jakehehrlich, jhenderson, alexshap, espindola Reviewed By: jhenderson Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D56211 llvm-svn: 350336
* [llvm-objcopy] [COFF] Use Error/Expected returns instead of calling ↵Martin Storsjo2018-12-305-56/+63
| | | | | | | | reportError. NFC. Differential Revision: https://reviews.llvm.org/D55922 llvm-svn: 350168
* [llvm-objcopy] [COFF] Avoid memcpy() with null parameters in more places. NFC.Martin Storsjo2018-12-201-4/+4
| | | | | | | | | This fixes all cases of errors in asan+ubsan builds. Also use std::copy instead of if+memcpy in the previously updated spot, for consistency. llvm-svn: 349826
* [llvm-objcopy] [COFF] Don't call memcpy() with a null argument. NFC.Martin Storsjo2018-12-201-1/+2
| | | | | | | | | It is invalid to call memcpy with a null pointer, even if the size is zero. This should fix the sanitizer buildbot. llvm-svn: 349808
* [llvm-objcopy] Use ELFOSABI_NONE instead of 0. NFC.George Rimar2018-12-201-1/+1
| | | | | | | This was requested during the review of D55886. (sorry, forgot to address this) llvm-svn: 349741
* [llvm-objcopy] - Do not drop the OS/ABI and ABIVersion fields of ELF headerGeorge Rimar2018-12-202-2/+8
| | | | | | | | | | | This is https://bugs.llvm.org/show_bug.cgi?id=40005, Patch teaches llvm-objcopy to preserve OS/ABI and ABIVersion fields of ELF header. (Currently, it drops them to zero). Differential revision: https://reviews.llvm.org/D55886 llvm-svn: 349738
* [binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0Jordan Rupprecht2018-12-201-1/+1
| | | | llvm-svn: 349710
* [llvm-objcopy] [COFF] Fix the Object forward declarationMartin Storsjo2018-12-192-2/+2
| | | | | | This fixes build warnings with clang, and linker errors with MSVC. llvm-svn: 349606
* [llvm-objcopy] Initial COFF supportMartin Storsjo2018-12-199-0/+762
| | | | | | | | | This is an initial implementation of no-op passthrough copying of COFF with objcopy. Differential Revision: https://reviews.llvm.org/D54939 llvm-svn: 349605
* [llvm-objcopy] Change Segment::Type from uint64_t to uint32_tFangrui Song2018-12-121-6/+6
| | | | | | | | | | | | | | | | | | Summary: In both Elf{32,64}_Phdr, the field Elf{32,64}_World p_type is uint32_t. Also reorder the fields to be similar to Elf64_Phdr (which is different from Elf32_Phdr but quite similar). Reviewers: rupprecht, jhenderson, jakehehrlich, alexshap, espindola Reviewed By: rupprecht Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D55618 llvm-svn: 348985
* llvm-objcopy: Improve/simplify llvm::Error handling during notes iterationDavid Blaikie2018-12-111-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using an Error as an out parameter from an indirect operation like iteration as described in the documentation ( http://llvm.org/docs/ProgrammersManual.html#building-fallible-iterators-and-iterator-ranges ) seems to be a little fussy - so here's /one/ possible solution, though I'm not sure it's the right one. Alternatively such APIs may be better off being switched to a standard algorithm style, where they take a lambda to do the iteration work that is then called back into (eg: "Error e = obj.for_each_note([](const Note& N) { ... });"). This would be safer than having an unwritten assumption that the user of such an iteration cannot return early from the inside of the function - and must always exit through the gift shop... I mean error checking. (even though it's guaranteed that if you're mid-way through processing an iteration, it's not in an error state). Alternatively we'd need some other (the super untrustworthy/thing we've generally tried to avoid) error handling primitive that actually clears the error state entirely so it's safe to ignore. Fleshed this solution out a bit further during review - it now relies on op==/op!= comparison as the equivalent to "if (Err)" testing the Error. So just like an Error must be checked (even if it's in a success state), the Error hiding in the iterator must be checked after each increment (including by comparison with another iterator - perhaps this could be constrained to only checking if the iterator is compared to the end iterator? Not sure it's too important). So now even just creating the iterator and not incrementing it at all should still assert because the Error has not been checked. Reviewers: lhames, jakehehrlich Differential Revision: https://reviews.llvm.org/D55235 llvm-svn: 348811
* [llvm-objcopy] Change --only-keep to --only-sectionJake Ehrlich2018-12-064-8/+8
| | | | | | | | | | | | I just hard core goofed when I wrote this and created a different name for no good reason. I'm failry aware of most "fresh" users of llvm-objcopy (that is, users which are not using it as a drop in replacement for GNU objcopy) and can say that only "-j" is being used by such people so this patch should strictly increase compatibility and not remove it. Differential Revision: https://reviews.llvm.org/D52180 llvm-svn: 348446
* [llvm-objcopy] Add --build-id-link-dir flagJake Ehrlich2018-12-035-3/+100
| | | | | | | | | | | | | | | This flag does not exist in GNU objcopy but has a major use case. Debugging tools support the .build-id directory structure to find debug binaries. There is no easy way to build this structure up however. One way to do it is by using llvm-readelf and some crazy shell magic. This implements the feature directly. It is most often the case that you'll want to strip a file and send the original to the .build-id directory but if you just want to send a file to the .build-id directory you can copy to /dev/null instead. Differential Revision: https://reviews.llvm.org/D54384 llvm-svn: 348174
* [llvm-objcopy] Delete redundant !Config.xx.empty() when followed by positive ↵Fangrui Song2018-11-291-11/+5
| | | | | | | | | | | | | | | | is_contained() check Summary: The original intention of !Config.xx.empty() was probably to emphasize the thing that is currently considered, but I feel the simplified form is actually easier to understand and it is also consistent with the call sites in other llvm components. Reviewers: alexshap, rupprecht, jakehehrlich, jhenderson, espindola Reviewed By: alexshap, rupprecht Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D55040 llvm-svn: 347891
* [llvm-objcopy] Hook up the -V alias to --version, output "GNU strip"Martin Storsjo2018-11-283-0/+4
| | | | | | | | | | | This allows libtool to detect the presence of llvm-strip and use it with the options --strip-debug and --strip-unneeded. Also hook up the -V alias for objcopy. Differential Revision: https://reviews.llvm.org/D54936 llvm-svn: 347731
* Use llvm::copy. NFCFangrui Song2018-11-171-5/+5
| | | | llvm-svn: 347126
* [llvm-objcopy] Use llvm::all_of and rename the variables "Segment" to avoid ↵Fangrui Song2018-11-171-6/+6
| | | | | | confusion with the type of the same name llvm-svn: 347123
* [llvm-objcopy] Rename --keep to --keep-section.Jordan Rupprecht2018-11-135-9/+11
| | | | | | | | | | | | | | | | 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-objcopy] Don't copy Config when processing --keepFangrui Song2018-11-121-1/+1
| | | | llvm-svn: 346717
* [Support] Make error banner optional in logAllUnhandledErrorsJonas Devlieghere2018-11-112-2/+2
| | | | | | | | In a lot of places an empty string was passed as the ErrorBanner to logAllUnhandledErrors. This patch makes that argument optional to simplify the call sites. llvm-svn: 346604
* [llvm-strip] Check "strip" with StringRef::contains instead of ends_withFangrui Song2018-11-071-1/+1
| | | | | | | | | | | | | | Summary: If argv[0] is version suffixed, e.g. llvm-strip-7, this will still work. Reviewers: rupprecht, jhenderson, alexshap, jakehehrlich Reviewed By: rupprecht Subscribers: alexshap, jakehehrlich, llvm-commits Differential Revision: https://reviews.llvm.org/D54193 llvm-svn: 346292
* [llvm-objcopy/strip] [NFC] Clean up tablegen opts (clang-format + ↵Jordan Rupprecht2018-11-012-110/+108
| | | | | | reorganizing things). llvm-svn: 345896
* [llvm-strip] Support --keep and --strip-all-gnu from llvm-objcopyJordan Rupprecht2018-11-013-3/+13
| | | | | | | | | | | | | | 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-015-4/+45
| | | | | | | | | | | | | | 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-013-4/+8
| | | | | | | | | | | | | | | | | 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] For multiclass Eq, associate help text with --name= , not ↵Fangrui Song2018-11-012-81/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | with --name Summary: Before: % llvm-objcopy -help ... --weaken-symbol=symbol Mark <symbol> as weak --weaken-symbol symbol Mark <symbol> as weak After: % llvm-objcopy -help ... --weaken-symbol=symbol Mark <symbol> as weak Reviewers: jhenderson, rupprecht, alexshap, jakehehrlich Reviewed By: jhenderson Subscribers: llvm-commits, kristina Differential Revision: https://reviews.llvm.org/D53983 llvm-svn: 345855
* [llvm-objcopy] Use proper casesFangrui Song2018-11-011-17/+17
| | | | | | | | | | | | Reviewers: jhenderson, alexshap, jakehehrlich, espindola, rupprecht Reviewed By: jhenderson, rupprecht Subscribers: emaste, arichardson, rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D53971 llvm-svn: 345845
* [llvm-objcopy] Delete a redundant override whose base is emptyFangrui Song2018-10-311-1/+0
| | | | llvm-svn: 345684
* [llvm-objcopy] Fix --keep-global-symbol/--globalize-symbol for undefined ↵Jordan Rupprecht2018-10-301-2/+4
| | | | | | | | | | | | | | | | 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-objcopy] Move elf-specific code into subfolderAlexander Shaposhnikov2018-10-296-472/+540
| | | | | | | | | | | In this diff the elf-specific code is moved into the subfolder ELF (and factored out from llvm-objcopy.cpp). Test plan: make check-all Differential revision: https://reviews.llvm.org/D53790 llvm-svn: 345544
* [llvm-objcopy] Introduce dispatch mechanism based on the inputAlexander Shaposhnikov2018-10-243-29/+77
| | | | | | | | | | | | | In this diff we introduce dispatch mechanism based on the type of the input (archive, object file, raw binary) and the format (coff, elf, macho). We also move the ELF-specific code into the namespace llvm::objcopy::elf. Test plan: make check-all Differential revision: https://reviews.llvm.org/D53311 llvm-svn: 345217
* [llvm-objcopy] Fix use-after-move clang-tidy warningJordan Rupprecht2018-10-231-2/+2
| | | | llvm-svn: 345079
OpenPOWER on IntegriCloud