summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-objcopy] Add option to add a progbits section from a fileJake Ehrlich2017-12-193-1/+48
| | | | | | | | This change adds support for adding progbits sections with contents from a file Differential Revision: https://reviews.llvm.org/D41212 llvm-svn: 321047
* [llvm-objcopy] Reformat everything using clang-format -iJake Ehrlich2017-12-152-26/+22
| | | | | | | | | Overtime some non-clang formatted code has creeped into llvm-objcopy. This patch fixes all of that. Differential Revision: https://reviews.llvm.org/D41262 llvm-svn: 320856
* [llvm-objcopy] Add support for --only-keep/-j and --keepJake Ehrlich2017-11-302-0/+55
| | | | | | | | | | | | | 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-271-3/+19
| | | | | | | | | | | | | | 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-151-63/+129
| | | | | | | | | | | | | | | | 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] Improve command line option help messagesJake Ehrlich2017-11-141-5/+6
| | | | | | | | | | I was being inconsistent with the way I was capitalizing help messages for command line options. Additionally --remove-section wasn't using value_desc even though it benefited from it. Differential Revision: https://reviews.llvm.org/D39978 llvm-svn: 318190
* [llvm-objcopy] Add -strip-non-alloc option to remove all non-allocated sectionsJake Ehrlich2017-11-141-0/+11
| | | | | | | | | 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-141-6/+19
| | | | | | | | | | | | 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/+8
| | | | | | | | | | | | | | | | 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
* [llvm-objcopy] Add --strip-all option to llvm-objcopyJake Ehrlich2017-11-131-0/+20
| | | | | | | | | | | | | | This change adds a slightly less extreme form of stripping. It should remove any section that starts with ".debug" and should remove any symbol table or relocations. In general this strips out most of the stuff you don't need to execute but leaves a number of things around. This behavior has been designed to be compatible with GNU strip/objcopy --strip-all so that anywhere you currently use --strip-all you should be able to use llvm-objcopy as a drop in replacement. Differential Revision: https://reviews.llvm.org/D39769 llvm-svn: 318092
* Make sure an error is always handled.Rafael Espindola2017-11-081-3/+4
| | | | llvm-svn: 317724
* Convert FileOutputBuffer::commit to Error.Rafael Espindola2017-11-081-2/+2
| | | | llvm-svn: 317656
* Convert FileOutputBuffer to Expected. NFC.Rafael Espindola2017-11-081-2/+2
| | | | llvm-svn: 317649
* llvm-objdump: Fix unused-lambda-capture warning by removing unused lambda ↵David Blaikie2017-11-031-1/+1
| | | | | | capture llvm-svn: 317365
* [llvm-objcopy] Add support for dwarf fissionJake Ehrlich2017-11-032-15/+67
| | | | | | | | This change adds support for dwarf fission. Differential Revision: https://reviews.llvm.org/D39207 llvm-svn: 317350
* [llvm-objcopy] Fix bug in how segment alignment was being handledJake Ehrlich2017-11-021-3/+17
| | | | | | | | | | | | | | | Just aligning segment offsets to segment alignment is incorrect and also wastes more space than is needed. The requirement is that p_offset == p_addr modulo p_align *not* that p_offset == 0 modulo p_align. Generally speaking we've been using p_addr == 0 modulo p_align. In fact yaml2obj can't even produce a valid situation which causes llvm-objcopy to produce incorrect results because alignment and offset were both inherited from the sections the program header covers. This change fixes this bad behavior in llvm-objcopy. Differential Revision: https://reviews.llvm.org/D39132 llvm-svn: 317284
* [tools] Add option to install binutils symlinksShoaib Meenai2017-11-021-0/+4
| | | | | | | | | | | | The LLVM tools can be used as a replacement for binutils, in which case it's convenient to create symlinks with the binutils names. Add support for these symlinks in the build system. As with any other llvm tool symlinks, the user can limit the installed symlinks by only adding the desired ones to `LLVM_TOOLCHAIN_TOOLS`. Differential Revision: https://reviews.llvm.org/D39530 llvm-svn: 317272
* [dsymutil, llvm-objcopy] Fix some Clang-tidy modernize and Include What You ↵Eugene Zelenko2017-11-014-141/+206
| | | | | | Use warnings; other minor fixes (NFC). llvm-svn: 317123
* Revert "[ADT] Make Twine's copy constructor private."Zachary Turner2017-10-114-8/+8
| | | | | | | | | | This reverts commit 4e4ee1c507e2707bb3c208e1e1b6551c3015cbf5. This is failing due to some code that isn't built on MSVC so I didn't catch. Not immediately obvious how to fix this at first glance, so I'm reverting for now. llvm-svn: 315536
* [ADT] Make Twine's copy constructor private.Zachary Turner2017-10-114-8/+8
| | | | | | | | | | | | | | | | | There's a lot of misuse of Twine scattered around LLVM. This ranges in severity from benign (returning a Twine from a function by value that is just a string literal) to pretty sketchy (storing a Twine by value in a class). While there are some uses for copying Twines, most of the very compelling ones are confined to the Twine class implementation itself, and other uses are either dubious or easily worked around. This patch makes Twine's copy constructor private, and fixes up all callsites. Differential Revision: https://reviews.llvm.org/D38767 llvm-svn: 315530
* Reland "[llvm-objcopy] Add support for --strip-sections to remove all ↵Jake Ehrlich2017-10-113-22/+52
| | | | | | | | | | | | | | | | | | | | | section headers leaving only program headers and loadable segment data" ubsan caught an issue I made where I was converting a null pointer to a reference. elf utils implements a particularly extreme form of stripping that I'd like to support. eu-strip has an option called "strip-sections" that removes all section headers and leaves only program headers and the segment data. I have implemented this option partly as a test but mainly because in Fuchsia we would like to use this option to minimize the size of our executables. The other strip options that are on my list include --strip-all and --strip-debug. This is a preliminary implementation that I'd like to start using in Fuchsia builds if possible. This change implements such a stripping option for llvm-objcopy Differential Revision: https://reviews.llvm.org/D38335 llvm-svn: 315484
* Revert "[llvm-objcopy] Add support for --strip-sections to remove all ↵Jake Ehrlich2017-10-113-48/+20
| | | | | | | | section headers leaving only program headers and loadable segment data" This reverts commit rL315412 llvm-svn: 315417
* [llvm-objcopy] Add support for --strip-sections to remove all section ↵Jake Ehrlich2017-10-113-20/+48
| | | | | | | | | | | | | | | | | | headers leaving only program headers and loadable segment data elf utils implements a particularly extreme form of stripping that I'd like to support. eu-strip has an option called "strip-sections" that removes all section headers and leaves only program headers and the segment data. I have implemented this option partly as a test but mainly because in Fuchsia we would like to use this option to minimize the size of our executables. The other strip options that are on my list include --strip-all and --strip-debug. This is a preliminary implementation that I'd like to start using in Fuchsia builds if possible. This change implements such a stripping option for llvm-objcopy Differential Revision: https://reviews.llvm.org/D38335 llvm-svn: 315412
* [llvm-objcopy] Add ability to remove multiple sections by nameJake Ehrlich2017-10-101-6/+9
| | | | | | | | | This change adds the ability to use the "-R"/"-remove-section" option multiple times. Differential Revision: https://reviews.llvm.org/D38332 llvm-svn: 315385
* [llvm-objcopy] Fix latent bug that allowed some Sections to be improperly ↵Jake Ehrlich2017-10-102-18/+21
| | | | | | | | | | | | | | | | cast to StringTableSections If a Section had Type SHT_STRTAB (which could happen if you had a .dynstr section) it was possible to cast Section to StringTableSection and get away with any operation that was supported by SectionBase without it being noticed. This change makes this bug easier to notice and fixes it where it occurred. It also made me realize that there was some duplication of efforts in the loop that calls ::initialize. These issues are all fixed by this change. Differential Revision: https://reviews.llvm.org/D38329 llvm-svn: 315372
* [llvm-objcopy] Add support for removing sectionsJake Ehrlich2017-10-103-10/+124
| | | | | | | | | | | This change adds support for removing sections using the -R field (as GNU objcopy does as well). This change should let us add many helpful tests and is a proper stepping stone for adding more general kinds of stripping. Differential Revision: https://reviews.llvm.org/D38260 llvm-svn: 315346
* Revert "temporary"Jake Ehrlich2017-10-103-124/+10
| | | | | | | | | I forgot to add a proper commit message. I'm reverting this to fix that. This reverts commit r315344. llvm-svn: 315345
* temporaryJake Ehrlich2017-10-103-10/+124
| | | | llvm-svn: 315344
* [llvm-objcopy] Fix major layout bugs in llvm-objcopyJake Ehrlich2017-10-042-20/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Somehow a few massive errors slipped though the cracks of testing. 1. The code in Segment::finalize was left over from the old layout algorithm. In certain situations this would cause very strange issues with segment layout. For instance in the shift-segments.test case it would cause the second segment to have the same offset as the first. 2. In debugging this I discovered another issue. Namely section alignment was not being computed based on Section->Align but instead Section->Offset which is bizarre and makes no sense. I have no clue how it worked in the first place. This issue is also fixed 3. Fixing #2 exposed a bug where things were not being written past the end of the file that technically should have been. This was because in certain cases (like overlapping-segments) the end of the file wouldn't always be bumped if the offset could be chosen relative to an existing segment that already had it's offset chosen. For fully nested segments this is fine but for overlapping segments this leaves the end of the file short. So I changed how the offset is bumped when looping though segments. Differential Revision: https://reviews.llvm.org/D38436 llvm-svn: 314918
* Reland: [llvm-objcopy] Add support for dynamic relocationsJake Ehrlich2017-09-271-8/+8
| | | | | | | | | This change adds support for dynamic relocations (allocated SHT_REL/SHT_RELA sections with a dynamic symbol table as their link). I had to reland this because of a I wasn't initilizing some pointers. llvm-svn: 314263
* Initialize the RelocationSectionBase::Section member.James Y Knight2017-09-261-0/+2
| | | | | | In r314227, it wasn't always, and would thus contain random garbage. llvm-svn: 314256
* [llvm-objcopy] Add support for dynamic relocationsJake Ehrlich2017-09-262-40/+53
| | | | | | | | | | | | | | | This change adds support for dynamic relocations (allocated SHT_REL/SHT_RELA sections with a dynamic symbol table as their link). The binary I added for the test is here: https://drive.google.com/file/d/0B3gtIAmiMwZXSjJUZE9pUjd4M0k/view?usp=sharing Unless support for dynamic symbol tables in yaml2obj is added this is needed. Differential Revision: https://reviews.llvm.org/D37915 llvm-svn: 314227
* [llvm-objcopy] Refactor code to include initialize methodJake Ehrlich2017-09-252-34/+92
| | | | | | | | | | | | | | | This change refactors some of the code to allow for some code deduplication in later diffs as well as just to make adding a new section type more self contained to the class itself. The idea for this was first mentioned by James in D 37915 and will be used in that change as recommended. This change follows changes for dynamic sections but precedes support for dynamic relocations. Differential Revision: https://reviews.llvm.org/D38008 llvm-svn: 314148
* Reland "[llvm-objcopy] Add support for .dynamic, .dynsym, and .dynstr"Jake Ehrlich2017-09-202-31/+114
| | | | | | | | | | | | | | I overzealously landed this before I was sure that another change wouldn't break the build that this change depends on. This change adds support for sections involved in dynamic loading such as SHT_DYNAMIC, SHT_DYNSYM, and allocated string tables. The two added binaries used for tests can be downloaded here and here Differential Revision: https://reviews.llvm.org/D36560 llvm-svn: 313767
* Reland "[llvm-objcopy] Add support for nested and overlapping segments"Jake Ehrlich2017-09-192-6/+67
| | | | | | | | | | | I didn't initialize a pointer to be nullptr that I needed to. This change adds support for nested and even overlapping segments. This means that PT_PHDR, PT_GNU_RELRO, PT_TLS, and PT_DYNAMIC can be supported properly. Differential Revision: https://reviews.llvm.org/D36558 llvm-svn: 313682
* Revert "[llvm-objcopy] Add support for .dynamic, .dynsym, and .dynstr"Jake Ehrlich2017-09-192-114/+31
| | | | | | | This reverts commit r313663. Broken because overlapping-sections was reverted. llvm-svn: 313665
* Revert "[llvm-objcopy] Add support for nested and overlapping segments"Jake Ehrlich2017-09-192-67/+6
| | | | | | This reverts commit r313656. Appears to be broken on Windows. llvm-svn: 313664
* [llvm-objcopy] Add support for .dynamic, .dynsym, and .dynstrJake Ehrlich2017-09-192-31/+114
| | | | | | | | | | | | | | | This change adds support for sections involved in dynamic loading such as SHT_DYNAMIC, SHT_DYNSYM, and allocated string tables. The two added binaries used for tests can be downloaded [[ https://drive.google.com/file/d/0B3gtIAmiMwZXOXE3T0RobFg4ZTg/view?usp=sharing | here ]] and [[ https://drive.google.com/file/d/0B3gtIAmiMwZXTFJSQUJZMGxNSXc/view?usp=sharing | here ]] Differential Revision: https://reviews.llvm.org/D36560 llvm-svn: 313663
* [llvm-objcopy] Add support for nested and overlapping segmentsJake Ehrlich2017-09-192-6/+67
| | | | | | | | | This change adds support for nested and even overlapping segments. This means that PT_PHDR, PT_GNU_RELRO, PT_TLS, and PT_DYNAMIC can be supported properly. Differential Revision: https://reviews.llvm.org/D36558 llvm-svn: 313656
* Test patch to check my commit accessJake Ehrlich2017-09-151-1/+1
| | | | llvm-svn: 313404
* [llvm-objcopy] Add e_machine validity check for reserved section indexesPetr Hosek2017-09-131-9/+13
| | | | | | | | | | | | | As discussed on llvm-commits it was decided it would be best to check e_machine before declaring that a reserved section index is valid. The only special e_machine value that matters here is EM_HEXAGON. This change adds a special check for EM_HEXAGON. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D37767 llvm-svn: 313114
* [llvm-objcopy] Add support for special section indexes in symbol table ↵Petr Hosek2017-09-072-8/+70
| | | | | | | | | | | | | | | greater than SHN_LORESERVE As is indexes above SHN_LORESERVE will not be handled correctly because they'll be treated as indexes of sections rather than special values that should just be copied. This change adds support to copy them though. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D37393 llvm-svn: 312756
* Reland "[llvm-objcopy] Add support for relocations"Petr Hosek2017-09-062-0/+115
| | | | | | | | | | | This change adds support for SHT_REL and SHT_RELA sections in llvm-objcopy. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D36554 llvm-svn: 312680
* Revert "[llvm-objcopy] Add support for relocations"Petr Hosek2017-09-062-115/+0
| | | | | | This reverts r312643 because it's failing on llvm-i686-linux-RA. llvm-svn: 312645
* [llvm-objcopy] Add support for relocationsPetr Hosek2017-09-062-0/+115
| | | | | | | | | | | This change adds support for SHT_REL and SHT_RELA sections in llvm-objcopy. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D36554 llvm-svn: 312643
* Reland "[llvm] Add symbol table support to llvm-objcopy"Petr Hosek2017-08-292-0/+147
| | | | | | | | | | This change adds support for SHT_SYMTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D34167 llvm-svn: 311974
* Revert "[llvm] Add symbol table support to llvm-objcopy"Petr Hosek2017-08-262-147/+0
| | | | | | This reverts commit r311826 because it's failing on llvm-i686-linux-RA. llvm-svn: 311827
* [llvm] Add symbol table support to llvm-objcopyPetr Hosek2017-08-262-0/+147
| | | | | | | | | | This change adds support for SHT_SYMTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D34167 llvm-svn: 311826
* [llvm-objcopy] New layout algorithm that lays out segments firstPetr Hosek2017-08-262-48/+41
| | | | | | | | | | | | | | | | The current file layout algorithm in llvm-objcopy is simple but difficult to reason about. It also makes it very complicated to support nested segments and to support segments that have offsets that come before a point after the program headers. To support these cases and simplify one of the most critical parts llvm-objcopy I rewrote the layout algorithm. Laying out segments first solves most of the issues encountered by the previous algorithm. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D36494 llvm-svn: 311825
* [llvm][llvm-objcopy] When outputting to binary don't output segments that ↵Petr Hosek2017-08-041-2/+6
| | | | | | | | | | | | | | | | | cover no sections Sometimes LLD will produce a PT_LOAD segment that only covers the headers (and covers no sections). GNU objcopy does not output the segment contents for these sections. In particular this is an issue in building magenta because the final link step for the kernel would produce just such a PT_LOAD segment. This change is to support this case and to match what GNU objcopy does in this case. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D36196 llvm-svn: 310149
OpenPOWER on IntegriCloud