summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/COFF
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-objcopy] [COFF] Fix a typo in a comment. NFC.Martin Storsjö2019-11-271-1/+1
|
* llvm-objcopy - fix uninitialized variable warnings. NFC.Simon Pilgrim2019-11-181-2/+2
|
* [llvm-objcopy][COFF] Add support for extended relocation tablesSergey Dmitriev2019-11-142-6/+20
| | | | | | | | | | | | | | Summary: This patch adds support for COFF objects with extended relocation tables to the llvm-objcopy tool. Reviewers: jhenderson, MaskRay, mstorsjo, alexshap, rupprecht Reviewed By: mstorsjo Subscribers: jakehehrlich, abrachet, seiya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70205
* [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
* [Object/COFF.h] - Stop returning std::error_code in a few methods. NFCI.George Rimar2019-08-191-12/+4
| | | | | | | | | | There are 4 methods that return std::error_code now, though they do not have to because they are always succeed. I refactored them. This allows to simplify the code in tools a bit. llvm-svn: 369263
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-1/+1
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* [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-262-24/+54
| | | | | | | | 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-224-17/+17
| | | | | | | | | | | | | | 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
* [Object] Change ObjectFile::getSectionContents to return ↵Fangrui Song2019-05-141-2/+2
| | | | | | | | | | | | | | | | | | | Expected<ArrayRef<uint8_t>> Change std::error_code getSectionContents(DataRefImpl, StringRef &) const; to Expected<ArrayRef<uint8_t>> getSectionContents(DataRefImpl) const; Many object formats use ArrayRef<uint8_t> as the underlying type, which is generally better than StringRef to represent binary data, so change the type to decrease the number of type conversions. Reviewed By: ruiu, sbc100 Differential Revision: https://reviews.llvm.org/D61781 llvm-svn: 360648
* [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
* [Object] Change getSectionName() to return Expected<StringRef>Fangrui Song2019-05-021-2/+4
| | | | | | | | | | Summary: It currently receives an output parameter and returns std::error_code. Expected<StringRef> fits for this purpose perfectly. Differential Revision: https://reviews.llvm.org/D61421 llvm-svn: 359774
* [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][NFC] Remove unnecessary llvm-objcopy.h #includesJordan Rupprecht2019-03-132-2/+0
| | | | llvm-svn: 356109
* [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-302-7/+9
| | | | | | | | | | | | 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-236-26/+76
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [llvm-objcopy] [COFF] Clear the unwritten tail of coff_section::Header::NameMartin Storsjo2019-01-231-0/+1
| | | | | | This should fix the add-gnu-debuglink test on all buildbots. llvm-svn: 351934
* Reapply: [llvm-objcopy] [COFF] Implement --add-gnu-debuglinkMartin Storsjo2019-01-235-7/+95
| | | | | | | | | | | 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
* [llvm-objcopy] Return Error from Buffer::allocate(), ↵Jordan Rupprecht2019-01-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | [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
* Revert "[llvm-objcopy] [COFF] Implement --add-gnu-debuglink"Martin Storsjo2019-01-225-95/+7
| | | | | | | 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-225-7/+95
| | | | | | Differential Revision: https://reviews.llvm.org/D57007 llvm-svn: 351801
* [llvm-objcopy] [COFF] Update symbol indices in weak externalsMartin Storsjo2019-01-225-6/+40
| | | | | | Differential Revision: https://reviews.llvm.org/D57006 llvm-svn: 351800
* [llvm-objcopy] Consistently use createStringError instead of ↵Martin Storsjo2019-01-224-36/+34
| | | | | | | | | | | | 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-198-32/+24
| | | | | | | | | | | | | | | | | 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-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-107-14/+199
| | | | | | Differential Revision: https://reviews.llvm.org/D55881 llvm-svn: 350893
* [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] [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
OpenPOWER on IntegriCloud