summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/ELF/Object.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-objcopy] - Calculate the string table section sizes correctly.George Rimar2019-03-181-11/+11
| | | | | | | | | | | | | | This fixes the https://bugs.llvm.org/show_bug.cgi?id=40980. Previously if string optimization occurred as a result of StringTableBuilder's finalize() method, the size wasn't updated. This hopefully also makes the interaction between sections during finalization processes a bit more clear. Differential revision: https://reviews.llvm.org/D59488 llvm-svn: 356371
* llvm-objcopy: Remove unused field. NFCI.Peter Collingbourne2019-03-121-3/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D59126 llvm-svn: 355892
* [llvm-objcopy] - Fix --compress-debug-sections when there are relocations.George Rimar2019-03-111-0/+15
| | | | | | | | | | | | | | | When --compress-debug-sections is given, llvm-objcopy removes the uncompressed sections and adds compressed to the section list. This makes all the pointers to old sections to be outdated. Currently, code already has logic for replacing the target sections of the relocation sections. But we also have to update the relocations by themselves. This fixes https://bugs.llvm.org/show_bug.cgi?id=40885. Differential revision: https://reviews.llvm.org/D58960 llvm-svn: 355821
* [llvm-objcopy] - Remove dead code. NFCI.George Rimar2019-03-061-7/+1
| | | | | | | | | | | | | | DecompressedSection can only be created if --decompress-debug-sections is specified. https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/ELF/ELFObjcopy.cpp#L492 If it is specified when !zlib::isAvailable(), we error out early when parsing the options: https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/CopyConfig.cpp#L657 What means the code I am removing in this patch is dead. Differential revision: https://reviews.llvm.org/D59017 llvm-svn: 355505
* [llvm-objcopy] - Remove an excessive zlib::isAvailable() check and dead code.George Rimar2019-03-061-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are 2 places where llvm-objcopy creates CompressedSection: For --compress-debug-sections. It might create the compressed section from regular here: https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/ELF/ELFObjcopy.cpp#L486 All initially compressed sections are created as CompressedSection during reading the sections from an object: https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/ELF/Object.cpp#L1118 Those have DebugCompressionType::None type and a different constructor. Case 1 has the following code in its constructor: if (!zlib::isAvailable()) { CompressionType = DebugCompressionType::None; return; } (https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/ELF/Object.cpp#L267) We can never reach that code with because would report an error much earlier: https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/CopyConfig.cpp#L480 So the code I am removing is dead. Landing this will address the issue mentioned in https://bugs.llvm.org/show_bug.cgi?id=40886. Differential revision: https://reviews.llvm.org/D59019 llvm-svn: 355503
* [llvm-objcopy] - Fix incorrect CompressedSection creation.George Rimar2019-03-061-1/+2
| | | | | | | | | | We should create CompressedSection only if the section has SHF_COMPRESSED flag or it's name starts from '.zdebug'. Currently, we create it if section's data starts from ZLIB signature. Differential revision: https://reviews.llvm.org/D59018 llvm-svn: 355501
* [llvm-objdump] - Improve the error message for "removing a section that is ↵George Rimar2019-02-281-6/+6
| | | | | | | | | | used by relocation" case. This refines/improves the error message introduced in D58625 Differential revision: https://reviews.llvm.org/D58709 llvm-svn: 355074
* [llvm-objcopy] - Check for invalidated relocations when removing a section.George Rimar2019-02-271-3/+22
| | | | | | | | | | | This is https://bugs.llvm.org/show_bug.cgi?id=40818 Removing a section that is used by relocation is an error we did not report. The patch fixes that. Differential revision: https://reviews.llvm.org/D58625 llvm-svn: 354962
* [llvm-objcopy] Make removeSectionReferences batchedJordan Rupprecht2019-02-211-13/+22
| | | | | | | | | | | | | | | | | | | | | | Summary: Removing a large number of sections from a file with a lot of symbols can have abysmal (i.e. O(n^2)) performance, e.g. when running `--only-section` to extract one section out of a large file. This comes from iterating over all symbols in the symbol table each time we remove a section, to remove references to the section we just removed. Instead, do just one pass of symbol removal by passing a hash set of all the sections we'd like to remove references to. This fixes a regression when running llvm-objcopy -j <one section> on an object file with many sections and symbols -- on my machine, running `objcopy -j .keep_me huge-input.o /tmp/foo.o` takes .3s with GNU objcopy, 1.3s with an updated llvm-objcopy, and 7+ minutes with llvm-objcopy prior to this patch. Reviewers: MaskRay, jhenderson, jakehehrlich, alexshap, espindola Reviewed By: MaskRay, jhenderson Subscribers: echristo, emaste, arichardson, mgrang, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58296 llvm-svn: 354597
* [llvm-objcopy][NFC] Propagate errors in removeSymbols/removeSectionReferencesJordan Rupprecht2019-02-011-46/+63
| | | | | | | | | | | | | | Reviewers: jhenderson, alexshap, jakehehrlich, espindola Reviewed By: jhenderson Subscribers: emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57543 llvm-svn: 352877
* [llvm-objcopy] Return Error from Buffer::allocate(), ↵Jordan Rupprecht2019-01-221-10/+12
| | | | | | | | | | | | | | | | | | | | | | | [ELF]Writer::finalize(), and [ELF]Writer::commit() Summary: This patch changes a few methods to return Error instead of manually calling error/reportError to abort. This will make it easier to extract into a library. Note that error() takes just a string (this patch also adds an overload that takes an Error), while reportError() takes string + [error/code]. To help unify things, use FileError to associate a given filename with an error. Note that this takes some special care (for now), e.g. calling reportError(FileName, <something that could be FileError>) will duplicate the filename. The goal is to eventually remove reportError() and have every error associated with a file to be a FileError, and just one error handling block at the tool level. This change was suggested in D56806. I took it a little further than suggested, but completely fixing llvm-objcopy will take a couple more patches. If this approach looks good, I'll commit this and apply similar patche(s) for the rest. This change is NFC in terms of non-error related code, although the error message changes in one context. Reviewers: alexshap, jhenderson, jakehehrlich, mstorsjo, espindola Reviewed By: alexshap, jhenderson Subscribers: llvm-commits, emaste, arichardson Differential Revision: https://reviews.llvm.org/D56930 llvm-svn: 351896
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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] Fix buildbots on older compilersJordan Rupprecht2019-01-031-3/+2
| | | | 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-031-29/+98
| | | | | | | | | | | | | | | | | | | | | 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] 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-201-2/+6
| | | | | | | | | | | 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
* 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] Don't apply --localize flags to common symbolsJordan Rupprecht2018-11-011-0/+2
| | | | | | | | | | | | | | | | | 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] 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] Move elf-specific code into subfolderAlexander Shaposhnikov2018-10-291-0/+1621
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
OpenPOWER on IntegriCloud