summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-objcopy][COFF] Implement --redefine-sym and --redefine-symsFangrui Song2019-11-121-4/+9
| | | | | | | | | | | | | The parsing error tests in ELF/redefine-symbols.test are not specific to ELF. Move them to redefine-symbols.test. Add COFF/redefine-symbols.test for COFF specific tests. Also fix the documentation regarding --redefine-syms: the old and new names are separated by whitespace, not an equals sign. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D70036
* Unify the two CRC implementationsHans Wennborg2019-10-091-11/+2
| | | | | | | | | | | | | | | | | | | | | David added the JamCRC implementation in r246590. More recently, Eugene added a CRC-32 implementation in r357901, which falls back to zlib's crc32 function if present. These checksums are essentially the same, so having multiple implementations seems unnecessary. This replaces the CRC-32 implementation with the simpler one from JamCRC, and implements the JamCRC interface in terms of CRC-32 since this means it can use zlib's implementation when available, saving a few bytes and potentially making it faster. JamCRC took an ArrayRef<char> argument, and CRC-32 took a StringRef. This patch changes it to ArrayRef<uint8_t> which I think is the best choice, and simplifies a few of the callers nicely. Differential revision: https://reviews.llvm.org/D68570 llvm-svn: 374148
* [llvm-objcopy] Add --set-section-alignmentFangrui Song2019-10-021-4/+5
| | | | | | | | | | | | | Fixes PR43181. This option was recently added to GNU objcopy (binutils PR24942). `llvm-objcopy -I binary -O elf64-x86-64 --set-section-alignment .data=8` can set the alignment of .data. Reviewed By: grimar, jhenderson, rupprecht Differential Revision: https://reviews.llvm.org/D67656 llvm-svn: 373461
* [llvm-objcopy] Allow the visibility of symbols created by --binary andChris Jackson2019-08-301-8/+8
| | | | | | --add-symbol to be specified with --new-symbol-visibility llvm-svn: 370458
* [llvm-objcopy][NFC] Refactor symbol/section matchingJordan Rupprecht2019-08-221-5/+4
| | | | | | | | | | | | | | | | | | | Summary: The matchers for section/symbol related flags (e.g. `--keep-symbol=Name` or `--regex --keep-symbol=foo.*`) are currently just vectors that are matched linearlly. However, adding wildcard support would require negative matching too, e.g. a symbol should be removed if it matches a wildcard *but* doesn't match some other wildcard. To make the next patch simpler, consolidate matching logic to a class defined in CopyConfig that takes care of matching. Reviewers: jhenderson, seiya, MaskRay, espindola, alexshap Reviewed By: jhenderson, MaskRay Subscribers: emaste, arichardson, jakehehrlich, abrachet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66432 llvm-svn: 369689
* [llvm-objcopy] Improve --add-section argument string parsingSergey Dmitriev2019-07-291-3/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D65346 llvm-svn: 367236
* [llvm-objcopy] Add support for --add-section for COFFSergey Dmitriev2019-07-261-22/+52
| | | | | | | | This patch enables support for --add-section=... option for COFF objects. Differential Revision: https://reviews.llvm.org/D65040 llvm-svn: 367130
* [llvm-objcopy] Tidy up error messagesJames Henderson2019-05-221-2/+2
| | | | | | | | | | | | | | This patch brings various error messages into line with each other, by removing trailing full stops, and making the first letter lower-case. This addresses https://bugs.llvm.org/show_bug.cgi?id=40859. Reviewed by: jhenderson, rupprecht, jakehehrlich Differential Revision: https://reviews.llvm.org/D62072 Patch by Alex Brachet llvm-svn: 361384
* [llvm-objcopy] Add --prefix-alloc-sectionsJames Henderson2019-05-081-9/+9
| | | | | | | | | | | | | | | | This patch adds support for --prefix-alloc-sections, which adds a prefix to every allocated section names. It adds a prefix after renaming section names by --rename-section as GNU objcopy does. Fixes PR41266: https://bugs.llvm.org/show_bug.cgi?id=41266 Differential Revision: https://reviews.llvm.org/D60042 Patch by Seiya Nuta. llvm-svn: 360233
* [llvm-objcopy][llvm-strip] Add switch to allow removing referenced sectionsJames Henderson2019-04-181-11/+12
| | | | | | | | | | | | | | | | | | | | llvm-objcopy currently emits an error if a section to be removed is referenced by another section. This is a reasonable thing to do, but is different to GNU objcopy. We should allow users who know what they are doing to have a way to produce the invalid ELF. This change adds a new switch --allow-broken-links to both llvm-strip and llvm-objcopy to do precisely that. The corresponding sh_link field is then set to 0 instead of an error being emitted. I cannot use llvm-readelf/readobj to test the link fields because they emit an error if any sections, like the .dynsym, cannot be properly loaded. Reviewed by: rupprecht, grimar Differential Revision: https://reviews.llvm.org/D60324 llvm-svn: 358649
* [llvm-objcopy] Add --set-start, --change-start and --adjust-startEugene Leviant2019-02-261-1/+1
| | | | | | Differential revision: https://reviews.llvm.org/D58173 llvm-svn: 354854
* [llvm-objcopy] Add --add-symbolEugene Leviant2019-02-251-1/+2
| | | | | | Differential revision: https://reviews.llvm.org/D58234 llvm-svn: 354787
* [llvm-objcopy] Add --strip-unneeded-symbol(s)Eugene Leviant2019-02-131-4/+7
| | | | | | Differential revision: https://reviews.llvm.org/D58027 llvm-svn: 353919
* [llvm-objcopy] Support -X|--discard-locals.Jordan Rupprecht2019-01-301-4/+6
| | | | | | | | | | | | | | | | | | | Summary: This adds support for the --discard-locals flag, which acts similarly to --discard-all, except it only applies to compiler-generated symbols (i.e. symbols starting with `.L` in ELF). I am not sure about COFF local symbols: those appear to also use `.L` in most cases, but also use just `L` in other cases, so for now I am just leaving it unimplemented there. Fixes PR36160 Reviewers: jhenderson, alexshap, jakehehrlich, mstorsjo, espindola Reviewed By: jhenderson Subscribers: llvm-commits, emaste, arichardson Differential Revision: https://reviews.llvm.org/D57248 llvm-svn: 352626
* [llvm-objcopy][NFC] More error propagationJordan Rupprecht2019-01-301-5/+6
| | | | | | | | | | | | Summary: Do some more error cleanup, removing some dependencies from llvm-objcopy's error/reportError in [ELF/COFF]Objcopy methods. Reviewers: jhenderson, alexshap, jakehehrlich, mstorsjo, espindola Subscribers: emaste, arichardson Differential Revision: https://reviews.llvm.org/D57423 llvm-svn: 352625
* [llvm-objcopy] Implement --set-section-flags.Jordan Rupprecht2019-01-291-4/+4
| | | | | | | | | | | | | | | | | Summary: --set-section-flags is used to change the section flags (e.g. SHF_ALLOC) for given sections. The flags allowed are the same from the existing --rename-section=.old=.new[,flags] feature. Additionally, make sure that --set-section-flag cannot be used with --rename-section (either the source or destination), since --rename-section accepts flags. This avoids ambiguity for something like "--rename-section=.foo=.bar,alloc --set-section-flag=.bar,code". Reviewers: jhenderson, jakehehrlich, alexshap, espindola Reviewed By: jhenderson, jakehehrlich Subscribers: llvm-commits, emaste, arichardson Differential Revision: https://reviews.llvm.org/D57198 llvm-svn: 352505
* [llvm-objcopy] [COFF] Error out on use of unhandled optionsMartin Storsjo2019-01-231-0/+15
| | | | | | | | Prefer erroring out than silently not doing what was requested. Differential Revision: https://reviews.llvm.org/D57045 llvm-svn: 351948
* [llvm-objcopy] [COFF] Fix handling of aux symbols for big objectsMartin Storsjo2019-01-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The aux symbols were stored in an opaque std::vector<uint8_t>, with contents interpreted according to the rest of the symbol. All aux symbol types but one fit in 18 bytes (sizeof(coff_symbol16)), and if written to a bigobj, two extra padding bytes are written (as sizeof(coff_symbol32) is 20). In the storage agnostic intermediate representation, store the aux symbols as a series of coff_symbol16 sized opaque blobs. (In practice, all such aux symbols only consist of one aux symbol, so this is more flexible than what reality needs.) The special case is the file aux symbols, which are written in potentially more than one aux symbol slot, without any padding, as one single long string. This can't be stored in the same opaque vector of fixed sized aux symbol entries. The file aux symbols will occupy a different number of aux symbol slots depending on the type of output object file. As nothing in the intermediate process needs to have accurate raw symbol indices, updating that is moved into the writer class. Differential Revision: https://reviews.llvm.org/D57009 llvm-svn: 351947
* Reapply: [llvm-objcopy] [COFF] Implement --add-gnu-debuglinkMartin Storsjo2019-01-231-0/+61
| | | | | | | | | | | This was reverted since it broke a couple buildbots. The reason for the breakage is not yet known, but this time, the test has got more diagnostics added, to hopefully allow figuring out what goes wrong. Differential Revision: https://reviews.llvm.org/D57007 llvm-svn: 351931
* Revert "[llvm-objcopy] [COFF] Implement --add-gnu-debuglink"Martin Storsjo2019-01-221-61/+0
| | | | | | | This reverts commit r351801, as it caused errors on (so far) ppc64be and aarch64 buildbots - the reason is yet unknown. llvm-svn: 351811
* [llvm-objcopy] [COFF] Implement --add-gnu-debuglinkMartin Storsjo2019-01-221-0/+61
| | | | | | Differential Revision: https://reviews.llvm.org/D57007 llvm-svn: 351801
* [llvm-objcopy] Consistently use createStringError instead of ↵Martin Storsjo2019-01-221-4/+4
| | | | | | | | | | | | 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-191-0/+10
| | | | | | 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-191-1/+9
| | | | | | 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-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] [COFF] Implement --strip-all[-gnu] for symbolsMartin Storsjo2019-01-151-0/+10
| | | | | | 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] 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] Add support for removing symbolsMartin Storsjo2019-01-101-0/+27
| | | | | | Differential Revision: https://reviews.llvm.org/D55881 llvm-svn: 350893
* [llvm-objcopy] [COFF] Use Error/Expected returns instead of calling ↵Martin Storsjo2018-12-301-2/+6
| | | | | | | | reportError. NFC. Differential Revision: https://reviews.llvm.org/D55922 llvm-svn: 350168
* [llvm-objcopy] Initial COFF supportMartin Storsjo2018-12-191-0/+40
This is an initial implementation of no-op passthrough copying of COFF with objcopy. Differential Revision: https://reviews.llvm.org/D54939 llvm-svn: 349605
OpenPOWER on IntegriCloud