aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/WinCOFFStreamer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-07-08[MC, COFF] Permit a variable to be redefinedDavid Majnemer1-19/+11
Our assertions in WinCOFFStreamer had unexpected side effects resulting in symbols getting unexpectedly marked as used. This fixes PR28462. llvm-svn: 274941
2016-04-11[Object] Make .alt_entry directive parsing MachO specific.Lang Hames1-1/+1
ELF and COFF will now treat .alt_entry like any other unrecognized directive. llvm-svn: 265975
2016-04-08[Object] Report an error if .alt_entry is used with ELF or COFF.Lang Hames1-0/+2
I'm looking into a better way to do this long-term, but for now at least don't crash. llvm-svn: 265815
2016-01-19Simplify MCFillFragment.Rafael Espindola1-1/+1
The value size was always 1 or 0, so we don't need to store it. In a no asserts build this takes the testcase of pr26208 from 11 to 10 seconds. llvm-svn: 258141
2015-11-17[Assembler] Make fatal assembler errors non-fatalOliver Stannard1-14/+21
Currently, if the assembler encounters an error after parsing (such as an out-of-range fixup), it reports this as a fatal error, and so stops after the first error. However, for most of these there is an obvious way to recover after emitting the error, such as emitting the fixup with a value of zero. This means that we can report on all of the errors in a file, not just the first one. MCContext::reportError records the fact that an error was encountered, so we won't actually emit an object file with the incorrect contents. Differential Revision: http://reviews.llvm.org/D14717 llvm-svn: 253328
2015-10-05Fix pr24486.Rafael Espindola1-2/+0
This extends the work done in r233995 so that now getFragment (in addition to getSection) also works for variable symbols. With that the existing logic to decide if a-b can be computed works even if a or b are variables. Given that, the expression evaluation can avoid expanding variables as aggressively and that in turn lets the relocation code see the original variable. In order for this to work with the asm streamer, there is now a dummy fragment per section. It is used to assign a section to a symbol when no other fragment exists. This patch is a joint work by Maxim Ostapenko andy myself. llvm-svn: 249303
2015-10-03Disallow assigning symbol a null section.Rafael Espindola1-2/+0
They are constructed without one and they can't go back, so this was effectively dead code. llvm-svn: 249220
2015-08-13Remove and forbid raw_svector_ostream::flush() calls.Yaron Keren1-2/+0
After r244870 flush() will only compare two null pointers and return, doing nothing but wasting run time. The call is not required any more as the stream and its SmallString are always in sync. Thanks to David Blaikie for reviewing. llvm-svn: 244928
2015-06-23Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko1-1/+1
Apparently, the style needs to be agreed upon first. llvm-svn: 240390
2015-06-19Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-1/+1
The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
2015-06-10[WinEH] Emit .safeseh directives for all 32-bit exception handlersReid Kleckner1-2/+8
Use a "safeseh" string attribute to do this. You would think we chould just accumulate the set of personalities like we do on dwarf, but this fails to account for the LSDA-loading thunks we use for __CxxFrameHandler3. Each of those needs to make it into .sxdata as well. The string attribute seemed like the most straightforward approach. llvm-svn: 239448
2015-06-08Move all of the MCSymbol COFF flags logic in to MCSymbolCOFF.Pete Cooper1-5/+4
All flags setting/getting is now done in the class with helper methods instead of users having to get the bits in the correct order. Reviewed by Rafael Espíndola. llvm-svn: 239314
2015-06-08Add MCSymbolCOFF class and use it to get and set the COFF type field.Pete Cooper1-2/+2
Reviewed by Rafael Espíndola. llvm-svn: 239312
2015-06-02Create a MCSymbolELF.Rafael Espindola1-4/+0
This create a MCSymbolELF class and moves SymbolSize since only ELF needs a size expression. This reduces the size of MCSymbol from 56 to 48 bytes. llvm-svn: 238801
2015-06-01[WinCOFF] Ignore .safeseh for non-x86 architecturesDavid Majnemer1-0/+6
We don't want to bother with creating .sxdata sections on Win64; all the relevant information is already in the .pdata section. llvm-svn: 238730
2015-05-30[WinCOFF] Add support for the .safeseh directiveDavid Majnemer1-0/+15
.safeseh adds an entry to the .sxdata section to register all the appropriate functions which may handle an exception. This entry is not a relocation to the symbol but instead the symbol table index of the function. llvm-svn: 238641
2015-05-30MC: Clean up MCExpr naming. NFC.Jim Grosbach1-2/+2
llvm-svn: 238634
2015-05-29Remove getData.Rafael Espindola1-8/+5
This completes the mechanical part of merging MCSymbol and MCSymbolData. llvm-svn: 238617
2015-05-29Remove the MCSymbolData typedef.Rafael Espindola1-3/+3
The getData member function is next. llvm-svn: 238611
2015-05-29Rename getOrCreateSymbolData to registerSymbol and return void.Rafael Espindola1-5/+8
Another step in merging MCSymbol and MCSymbolData. llvm-svn: 238607
2015-05-29Move Flags from MCSymbolData to MCSymbol.Rafael Espindola1-5/+6
llvm-svn: 238598
2015-05-29Move common symbol related information from MCSectionData to MCSymbol.Rafael Espindola1-1/+1
llvm-svn: 238583
2015-05-28Don't call utostr in Twine/raw_ostream contexts.Benjamin Kramer1-3/+2
Creating temporary std::strings there is unnecessary. llvm-svn: 238412
2015-05-26Replace getOrCreateSectionData with registerSection.Rafael Espindola1-3/+3
There is now no SectionData to be created. llvm-svn: 238208
2015-05-25Store a MCSection in MCFragment.Rafael Espindola1-3/+3
Part of the work to merge MCSectionData into MCSection. llvm-svn: 238160
2015-05-21Stop forwarding (get|set)Aligment from MCSectionData to MCSection.Rafael Espindola1-2/+2
llvm-svn: 237956
2015-05-21Move alignment from MCSectionData to MCSection.Rafael Espindola1-7/+5
This starts merging MCSection and MCSectionData. There are a few issues with the current split between MCSection and MCSectionData. * It optimizes the the not as important case. We want the production of .o files to be really fast, but the split puts the information used for .o emission in a separate data structure. * The ELF/COFF/MachO hierarchy is not represented in MCSectionData, leading to some ad-hoc ways to represent the various flags. * It makes it harder to remember where each item is. The attached patch starts merging the two by moving the alignment from MCSectionData to MCSection. Most of the patch is actually just dropping 'const', since MCSectionData is mutable, but MCSection was not. llvm-svn: 237936
2015-05-18MC: Clean up method names in MCContext.Jim Grosbach1-1/+1
The naming was a mish-mash of old and new style. Update to be consistent with the new. NFC. llvm-svn: 237594
2015-05-15MC: Update MCCodeEmitter naming. NFC.Jim Grosbach1-1/+1
s/EncodeInstruction/encodeInstruction/ llvm-svn: 237469
2015-05-15MC: Update MCFixup naming. NFC.Jim Grosbach1-2/+2
s/MCFixup::Create/MCFixup::create/ llvm-svn: 237468
2015-04-14Use raw_pwrite_stream in the object writer/streamer.Rafael Espindola1-1/+1
The ELF object writer will take advantage of that in the next commit. llvm-svn: 234950
2015-03-16Fix uses of reserved identifiers starting with an underscore followed by an ↵David Blaikie1-2/+2
uppercase letter This covers essentially all of llvm's headers and libs. One or two weird cases I wasn't sure were worth/appropriate to fix. llvm-svn: 232394
2015-01-14[cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth1-1/+1
utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
2014-11-11MC, COFF: Use relocations for function references inside the sectionDavid Majnemer1-1/+1
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
2014-10-15Simplify handling of --noexecstack by using getNonexecutableStackSection.Rafael Espindola1-1/+1
llvm-svn: 219799
2014-10-08Fix COFF section index relocation should be 16 bits, not 32Timur Iskhodzhanov1-1/+1
Original patch by Andrey Guskov! http://reviews.llvm.org/D5651 llvm-svn: 219327
2014-10-08COFF: Don't oversize COMMON symbols when targeting BFD ldDavid Majnemer1-5/+4
COFF normally doesn't allow us to describe the alignment of COMMON symbols. It turns out that most linkers use the symbol size as a hint as to how aligned the symbol should be. However the BFD folks have added a .drectve command, which we now support as of r219229, that allows us to specify the alignment precisely. With this in mind, stop rounding sizes up. llvm-svn: 219281
2014-10-07MC: add support for -aligncomm GNU extensionSaleem Abdulrasool1-8/+18
The GNU linker supports an -aligncomm directive that allows for power-of-2 alignment of common data. Add support to emit this directive. llvm-svn: 219229
2014-09-21MC: Support aligned COMMON symbols for COFFDavid Majnemer1-2/+15
link.exe: Fuzz testing has shown that COMMON symbols with size > 32 will always have an alignment of at least 32 and all symbols with size < 32 will have an alignment of at least the largest power of 2 less than the size of the symbol. binutils: The BFD linker essentially work like the link.exe behavior but with alignment 4 instead of 32. The BFD linker also supports an extension to COFF which adds an -aligncomm argument to the .drectve section which permits specifying a precise alignment for a variable but MC currently doesn't support editing .drectve in this way. With all of this in mind, we decide to play a little trick: we can ensure that the alignment will be respected by bumping the size of the global to it's alignment. llvm-svn: 218201
2014-08-09MC: cleanup includesSaleem Abdulrasool1-1/+0
Cleanup Win64EH header inclusion. NFC. llvm-svn: 215288
2014-06-29MC: rename EmitWin64EH routinesSaleem Abdulrasool1-1/+1
Rename the routines to reflect the reality that they are more related to call frame information than to Win64 EH. Although EH is implemented in an intertwined manner by augmenting with an exception handler and an associated parameter, the majority of these routines emit information required to unwind the frames. This also helps identify that these routines are generic for most windows platforms (they apply equally to nearly all architectures except x86) although the encoding of the information is architecture dependent. Unwinding data is emitted via EmitWinCFI* and exception handling information via EmitWinEH*. llvm-svn: 211994
2014-06-24Print a=b as an assignment.Rafael Espindola1-4/+0
In assembly the expression a=b is parsed as an assignment, so it should be printed as one. This remove a truly horrible hack for producing a label with "a=.". It would be used by codegen but would never be reached by the asm parser. Sorry I missed this when it was first committed. llvm-svn: 211639
2014-05-22MC: formalise some assertions into proper errorsSaleem Abdulrasool1-8/+23
Now that clang can be used as an assembler via the IAS, invalid assembler inputs would cause the assertions to trigger. Although we cannot recover from the errors here, nor provide caret diagnostics, attempt to handle them slightly more gracefully by reporting a fatal error. llvm-svn: 209387
2014-04-27Make getOrCreateSymbolData non virtual.Rafael Espindola1-4/+0
llvm-svn: 207367
2014-04-27MC: create X86WinCOFFStreamer for target specific behaviourSaleem Abdulrasool1-15/+1
This introduces a target specific streamer, X86WinCOFFStreamer, which handles the target specific behaviour (e.g. WinEH). This is mostly to ensure that differences between ARM and X86 remain disjoint and do not accidentally cross boundaries. This is the final staging change for enabling object emission for Windows on ARM. llvm-svn: 207344
2014-04-27MC: rename WinCOFFStreamer and move declaration out-of-lineSaleem Abdulrasool1-90/+57
This is in preparation for promoting WinCOFFStreamer to a base class which will be shared by the X86 and ARM specific target COFF streamers. Also add a new getOrCreateSymbolData interface (like MCELFStreamer) for the ARM COFF Streamer. This makes the COFFStreamer more similar to the ELFStreamer. llvm-svn: 207343
2014-04-27MC: style tweaks to WinCOFFStreamerSaleem Abdulrasool1-65/+57
Stylistic changes to prepare for splitting up the COFFStreamer into target specific streamers. Tweak some assertion messages. No functional change. llvm-svn: 207342
2014-04-22[Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth1-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
2014-04-16COFF: add support for .file symbolsSaleem Abdulrasool1-2/+1
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
2014-04-13[C++11] More 'nullptr' conversion or in some cases just using a boolean ↵Craig Topper1-9/+9
check instead of comparing to nullptr. llvm-svn: 206129