summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/WinCOFFObjectWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-formatted ranged loops and assignment, NFC.Yaron Keren2014-12-041-12/+12
| | | | llvm-svn: 223344
* MC, COFF: Use relocations for function references inside the sectionDavid Majnemer2014-11-111-0/+18
| | | | | | | | | | | | | | | | | | Referencing one symbol from another in the same section does not generally require a relocation. However, the MS linker has a feature called /INCREMENTAL which enables incremental links. It achieves this by creating thunks to the actual function and redirecting all relocations to point to the thunk. This breaks down with the old scheme if you have a function which references, say, itself. On x86_64, we would use %rip relative addressing to reference the start of the function from out current position. This would lead to miscompiles because other references might reference the thunk instead, breaking function pointer equality. This fixes PR21520. llvm-svn: 221678
* speling.Nico Weber2014-11-111-1/+1
| | | | llvm-svn: 221652
* MC: Bit pack MCSymbolData.Benjamin Kramer2014-10-111-4/+4
| | | | | | | | | On x86_64 this brings it from 80 bytes to 64 bytes. Also make any member variables private and clean up uses to go through the existing accessors. NFC. llvm-svn: 219573
* WinCOFFObjectWriter: optimize the string table for common sufficesHans Wennborg2014-09-291-85/+33
| | | | | | | | This is a follow-up from r207670 which did the same for ELF. Differential Revision: http://reviews.llvm.org/D5530 llvm-svn: 218636
* WinCOFFObjectWriter.cpp: make write_uint32_le more efficientHans Wennborg2014-09-281-6/+4
| | | | llvm-svn: 218574
* This add a reset method for WinCOFFObjectWriter, like other MC* classes.Yaron Keren2014-09-161-0/+16
| | | | llvm-svn: 217907
* Fix the build for MSVC, it doesn't support extended sizeofDavid Majnemer2014-09-151-4/+4
| | | | llvm-svn: 217820
* MC: Add support for BigObjDavid Majnemer2014-09-151-59/+91
| | | | | | | | | | | | | | | | | | | | | | | | Teach WinCOFFObjectWriter how to write -mbig-obj style object files; these object files allow for more sections inside an object file. Our support for BigObj is notably different from binutils and cl: we implicitly upgrade object files to BigObj instead of asking the user to compile the same file *again* but with another flag. This matches up with how LLVM treats ELF variants. This was tested by forcing LLVM to always emit BigObj files and running the entire test suite. A specific test has also been added. I've lowered the maximum number of sections in a normal COFF file, VS "14" CTP 3 supports no more than 65279 sections. This is important otherwise we might not switch to BigObj quickly enough, leaving us with a COFF file that we couldn't link. yaml2obj support is all that remains to implement. Differential Revision: http://reviews.llvm.org/D5349 llvm-svn: 217812
* Object: Add support for bigobjDavid Majnemer2014-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | This adds support for reading the "bigobj" variant of COFF produced by cl's /bigobj and mingw's -mbig-obj. The most significant difference that bigobj brings is more than 2**16 sections to COFF. bigobj brings a few interesting differences with it: - It doesn't have a Characteristics field in the file header. - It doesn't have a SizeOfOptionalHeader field in the file header (it's only used in executable files). - Auxiliary symbol records have the same width as a symbol table entry. Since symbol table entries are bigger, so are auxiliary symbol records. Write support will come soon. Differential Revision: http://reviews.llvm.org/D5259 llvm-svn: 217496
* Silence a -Wsign-compare warning. NFC.Aaron Ballman2014-08-281-1/+1
| | | | llvm-svn: 216666
* MC: Don't crash when the COFF section limit is reachedDavid Majnemer2014-08-281-6/+11
| | | | | | | I've decided not to commit a test, it takes 2.5 seconds to run on my an incredibly strong machine. llvm-svn: 216647
* MC: Let non-temporary COFF aliases be in symtabDavid Majnemer2014-07-131-8/+19
| | | | | | | | | | | | | | MC was aping a binutils bug where aliases would default their linkage to private instead of internal. I've sent a patch to the binutils maintainers and they've recently applied it to the GNU assembler sources. This fixes PR20152. Differential Revision: http://reviews.llvm.org/D4395 llvm-svn: 212899
* MC: Correct comment in ExportSymbolDavid Majnemer2014-07-041-1/+1
| | | | | | | No functionality changed, just make it so that the code _could_ be uncommented. llvm-svn: 212363
* MC: prevent early DCE of empty sectionsSaleem Abdulrasool2014-06-061-7/+3
| | | | | | | | | | | | | | | | Prevent the early elimination of sections in the object writer. There may be references to the section itself by other symbols, which may potentially not be possible to resolve. ML (Visual Studio's Macro Assembler) also seems to retain empty sections. The elimination of symbols and sections which are unused should really occur at the link phase. This will not cause any change in the resulting binary, simply in the generated object files. The adjustments to the other unit tests account for the fluctuating section index caused by the appearance of sections which were previously discarded. llvm-svn: 210373
* Fix a few issues with comdat handling on COFF.Rafael Espindola2014-06-061-6/+24
| | | | | | | | | | | | | | | | | | | | | * Section association cannot use just the section name as many sections can have the same name. With this patch, the comdat symbol in an assoc section is interpreted to mean a symbol in the associated section and the mapping is discovered from it. * Comdat symbols were not being set correctly. Instead we were getting whatever was output first for that section. A consequence is that associative sections now must use .section to set the association. Using .linkonce would not work since it is not possible to change a sections comdat symbol (it is used to decide if we should create a new section or reuse an existing one). This includes r210298, which was reverted because it was asserting on an associated section having the same comdat as the associated section. llvm-svn: 210367
* Revert r210298 'Correctly set the comdat symbol on COFF' as it asserts on ↵Timur Iskhodzhanov2014-06-061-13/+2
| | | | | | Windows llvm-svn: 210317
* Correctly set the comdat symbol on COFF.Rafael Espindola2014-06-051-2/+13
| | | | | | | | | | | | | | | | | | | | | We extended the .section syntax to allow multiple sections with the same name but different comdats, but currently we don't make sure that the output section has that comdat symbol. That happens to work with the code llc produces currently because it looks like .section secName, "dr", one_only, "COMDATSym" .globl COMDATSym COMDATSym: .... but that is not very friendly to anyone coding in assembly or even to llc once we get comdat support in the IR. This patch changes the coff object writer to make sure the comdat symbol is output just after the section symbol, as required by the coff spec. llvm-svn: 210298
* MC: introduce ability to restrict recorded relocationsSaleem Abdulrasool2014-05-211-1/+2
| | | | | | | | | Add support to allow a target specific COFF object writer to restrict the recorded resolutions in the emitted object files. This is motivated by the need in Windows on ARM, where an intermediate relocation needs to be prevented from being emitted in the object file. llvm-svn: 209336
* Fix typosAlp Toker2014-05-151-1/+1
| | | | llvm-svn: 208839
* MC: place .file records into the correct sectionSaleem Abdulrasool2014-05-021-0/+1
| | | | | | | | | .file records are supposed to have a section identifier of 65534 (IMAGE_SCN_DEBUG) rather than 0. This is spelt out clearly within the PE/COFF specification. Fix this minor oversight with the implementation for support for .file records. llvm-svn: 207851
* Don't propagate StorageClass and ComplexType to aliases.Rafael Espindola2014-05-011-2/+1
| | | | | | | | | This matches gas' behaviour on COFF. I think that this yak is now sufficiently shaved for aliases with offset to work. llvm-svn: 207786
* Compute the correct section for zed = foo + 1 in COFF.Rafael Espindola2014-05-011-10/+9
| | | | | | | | | This fixes pr19147. There are a few more related issues to fix, but the testcase in the bug now passes. llvm-svn: 207763
* Start fixing pr19147.Rafael Espindola2014-05-011-10/+13
| | | | | | | This makes the coff writer compute the correct symbol value for the test in pr19147. The section is still incorrect, that will be fixed in a followup patch. llvm-svn: 207728
* MC: range-loopifySaleem Abdulrasool2014-04-281-62/+49
| | | | | | Use C++11 range-based loops rather than explicit constructors. NFC. llvm-svn: 207393
* Add WoA object file emission supportSaleem Abdulrasool2014-04-271-0/+38
| | | | | | | | | | | | | | | | | | | | | | Introduce support for WoA PE/COFF object file emission from LLVM. Add the new target specific PE/COFF Streamer (ARMWinCOFFStreamer) that handles the ARM specific behaviour of PE/COFF object emission. ARM exception information is not yet emitted and is a TODO item. The ARM specific object writer (ARMWinCOFFObjectWriter) handles the ARM specific relocation handling in conjunction with the WinCOFFObjectWriter in the MC layer. The MC layer needs to be updated to deal with the relocation adjustments. Branch relocations are adjusted by 4 bytes (unlikely their ELF counterparts). Minor tweaks to switch multiple conditional checks into equivalent switch statements. The ObjectFileInfo is updated to relax the object file setup for Windows COFF. Move the architecture checks into an assertion. Windows COFF is currently only supported on x86, x86_64, and ARM (thumb). Rather than defaulting to ELF, we will refuse to generate an object file. This is better though as you do not get an (arbitrary) object file which is different from the request. llvm-svn: 207345
* Spread some const around for non-mutating uses of MCSymbolData.David Blaikie2014-04-241-2/+2
| | | | | | | | I discovered this const-hole while attempting to coalesnce the Symbol and SymbolMap data structures. There's some pending issues with that, but I figured this change was easy to flush early. llvm-svn: 207124
* [C++] Use 'nullptr'.Craig Topper2014-04-241-1/+1
| | | | llvm-svn: 207083
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-221-2/+2
| | | | | | | definition below all the header #include lines. This updates most of the miscellaneous other lib/... directories. A few left though. llvm-svn: 206845
* Add range access to MCAssembler's symbol collection.David Blaikie2014-04-181-7/+3
| | | | llvm-svn: 206631
* MC: rework static_assert to be MSVC compatibleSaleem Abdulrasool2014-04-171-4/+2
| | | | | | | | Visual Studio does not permit referencing a structure member as a static field for sizeof calculations. Resort to a pointer cast which is compatible across Visual Studio and other compilers. llvm-svn: 206445
* Simplify a static_assert so VS2013 can build itTimur Iskhodzhanov2014-04-161-2/+4
| | | | llvm-svn: 206363
* COFF: fix an off by one errorSaleem Abdulrasool2014-04-161-1/+1
| | | | | | | | | | Adjust the tests to validate the number of auxiliary entries used to store the filename. Thanks to majnemer's sharp eye for catching the missing - 1 in the round up calculation. llvm-svn: 206359
* COFF: add support for .file symbolsSaleem Abdulrasool2014-04-161-0/+29
| | | | | | | | | | | | | Add support for emitting .file records. This is mostly a quality of implementation change (more complete support for COFF file emission) that was noticed while working on COFF file emission for Windows on ARM. A .file record is emitted as a symbol with storage class FILE (103) and the name ".file". A series of auxiliary format 4 records follow which contain the file name. The filename is stored as an ANSI string and is padded with NULL if the length is not a multiple of COFF::SymbolSize (18). llvm-svn: 206355
* Use unique_ptr for section/segment ownership in WinCOFFObjectWriterDavid Blaikie2014-04-151-41/+32
| | | | llvm-svn: 206245
* MC: check machine magic when applying offset adjustmentsSaleem Abdulrasool2014-04-131-2/+4
| | | | | | | | | | | | | | | The values for the relocation type can (and do) overlap across various architectures. When performing an adjustment of the emitted relocation in the final object file, check that the file magic matches the target for which the relocation type is valid (e.g. a I386 relocation is only applied to an X86 object file, and an AMD64 relocation is only applied to an X86_64 object file). This was noticed while adding support for ARM WinCOFF object file emission. A test case for this is not really possible as the values for REL32 do not overlap on I386 and AMD64, which is why this was never noticed in practice. The ARM WinCOFF emission is not yet ready to merge into the tree. llvm-svn: 206138
* [C++11] More 'nullptr' conversion or in some cases just using a boolean ↵Craig Topper2014-04-131-13/+13
| | | | | | check instead of comparing to nullptr. llvm-svn: 206129
* WinCOFF: Emit common symbols as specified in the COFF specDavid Majnemer2014-04-081-1/+3
| | | | | | | | | | | | | | | | | | Summary: Local common symbols were properly inserted into the .bss section. However, putting external common symbols in the .bss section would give them a strong definition. Instead, encode them as undefined, external symbols who's symbol value is equivalent to their size. Reviewers: Bigcheese, rafael, rnk CC: llvm-commits Differential Revision: http://reviews.llvm.org/D3324 llvm-svn: 205811
* Completely rewrite ELFObjectWriter::RecordRelocation.Rafael Espindola2014-03-291-1/+3
| | | | | | | | | | | | | | | | | | | I started trying to fix a small issue, but this code has seen a small fix too many. The old code was fairly convoluted. Some of the issues it had: * It failed to check if a symbol difference was in the some section when converting a relocation to pcrel. * It failed to check if the relocation was already pcrel. * The pcrel value computation was wrong in some cases (relocation-pc.s) * It was missing quiet a few cases where it should not convert symbol relocations to section relocations, leaving the backends to patch it up. * It would not propagate the fact that it had changed a relocation to pcrel, requiring a quiet nasty work around in ARM. * It was missing comments. llvm-svn: 205076
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-081-8/+6
| | | | | | class. llvm-svn: 203340
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-2/+1
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* Reuse constants for COFF string table entry offsetsNico Rieck2014-02-251-7/+9
| | | | llvm-svn: 202130
* MC: Support COFF string tables larger than 10MBNico Rieck2014-02-221-1/+27
| | | | | | | | Offsets past the range of single-slash encoding are encoded as base64, padded to 6 characters, and prefixed with two slashes. This encoding is undocumented but used by MSVC. llvm-svn: 201940
* Fix PR18381 - print a minimal diagnostic rather than assert on unresolved ↵Timur Iskhodzhanov2014-01-301-0/+5
| | | | | | .secidx target llvm-svn: 200490
* MC: Fatally error if subtraction operand is badDavid Majnemer2014-01-061-5/+16
| | | | | | | | | Instead of crashing, raise an error when a subtraction expression involves an undefined symbol. This fixes PR18375. llvm-svn: 198590
* Correct word hyphenationsAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities and contractions in nearby lines. llvm-svn: 196471
* Fix a funny typo.Rafael Espindola2013-12-041-1/+1
| | | | | | Thanks for j`ey and Sean Silva for noticing it. llvm-svn: 196344
* Produce deterministic coff files.Rafael Espindola2013-12-041-1/+2
| | | | llvm-svn: 196341
* [weak vtables] Remove a bunch of weak vtablesJuergen Ributzka2013-11-191-1/+4
| | | | | | | | | | | | This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. The memory leaks in this version have been fixed. Thanks Alexey for pointing them out. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy llvm-svn: 195064
* Revert "COFF: Emit all MCSymbols rather than filtering out some of them"Reid Kleckner2013-11-181-2/+19
| | | | | | | | This reverts commit r190888, to fix PR17967. The original change wasn't the right way to get @feat.00 into the object file. The right fix is to make @feat.00 be a global symbol. llvm-svn: 195053
OpenPOWER on IntegriCloud