aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/WinCOFFObjectWriter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-06-26Apply clang-tidy's modernize-loop-convert to lib/MC.Benjamin Kramer1-25/+24
Only minor manual fixes. No functionality change intended. llvm-svn: 273814
2016-06-21Delete some dead code.Rafael Espindola1-3/+0
Found by gcc 6. llvm-svn: 273303
2016-05-26coff: fix weak alias to local.Rafael Espindola1-32/+40
We were creating a weak external that tried to reference a static symbol. That would always fail to link with link.exe. We now create an external symbol in the same position as the local and refer to that. This works with link.exe and matches what gas does. llvm-svn: 270906
2016-05-26coff: fix the section of weak symbols.Rafael Espindola1-13/+16
llvm-svn: 270889
2016-05-26coff: fix the value of weak definitions.Rafael Espindola1-1/+1
It looks like this doesn't get a lot of use. llvm-svn: 270883
2016-02-05[MC] Add support for encoding CodeView variable definition rangesDavid Majnemer1-0/+4
CodeView, like most other debug formats, represents the live range of a variable so that debuggers might print them out. They use a variety of records to represent how a particular variable might be available (in a register, in a frame pointer, etc.) along with a set of ranges where this debug information is relevant. However, the format only allows us to use ranges which are limited to a maximum of 0xF000 in size. This means that we need to split our debug information into chunks of 0xF000. Because the layout of code is not known until *very* late, we must use a new fragment to record the information we need until we can know *exactly* what the range is. llvm-svn: 259868
2016-01-24[COFF] Simplify SetSectionNameDavid Majnemer1-12/+10
Consolidate the code which handles string table offsets less than 999999 with the code for offsets less than 9999999. While we are here, simplify the code by not using sprintf to generate the string. llvm-svn: 258664
2016-01-14Update to use new name alignTo().Rui Ueyama1-1/+1
llvm-svn: 257804
2016-01-06Make WinCOFFObjectWriter.cpp's timestamp writing not use ENABLE_TIMESTAMPSNico Weber1-7/+1
LLVM_ENABLE_TIMESTAMPS controls if timestamps are embedded into llvm's binaries. Turning it off is useful for deterministic builds. r246905 made it so that the define suddenly also controls if the binaries that the llvm binaries _create_ embed timestamps or not – but this shouldn't be a configure-time option. r256203/r256204 added a driver option to toggle this on and off, so this patch now passes this driver option in LLVM_ENABLE_TIMESTAMPS builds so that if LLVM_ENABLE_TIMESTAMPS is set, the build of LLVM is deterministic – but the built clang can still write timestamps into other executables when requested. This also allows removing some of the test machinery added in r292012 to work around this problem. See PR24740 for background. http://reviews.llvm.org/D15783 llvm-svn: 256958
2015-12-21[MC, COFF] Support link /incremental conditionallyDavid Majnemer1-5/+12
Today, we always take into account the possibility that object files produced by MC may be consumed by an incremental linker. This results in us initialing fields which vary with time (TimeDateStamp) which harms hermetic builds (e.g. verifying a self-host went well) and produces sub-optimal code because we cannot assume anything about the relative position of functions within a section (call sites can get redirected through incremental linker thunks). Let's provide an MCTargetOption which controls this behavior so that we can disable this functionality if we know a-priori that the build will not rely on /incremental. llvm-svn: 256203
2015-12-21[MC, COFF] Unbreak support for COFF timestampsDavid Majnemer1-0/+1
Support for COFF timestamps was unintentionally broken in r246905 when it was conditionally available depending on whether or not LLVM was configured with LLVM_ENABLE_TIMESTAMPS. However, Config/config.h was never included which essentially broke the feature. Due to lax testing, the breakage was never identified until we observed strange failures during incremental links of Chromium. This issue is resolved by simply including Config/config.h in WinCOFFObjectWriter and teaching lit that the MC/COFF/timestamp.s test is conditionally supported depending on LLVM_ENABLE_TIMESTAMPS. With this in place, we can strengthen the test to ensure that it will not accidentally get broken in the future. This fixes PR25891. llvm-svn: 256137
2015-11-26MC: Simplify handling of temporary symbols in COFF writer.Peter Collingbourne1-81/+23
The COFF object writer was previously adding unnecessary symbols to its temporary data structures and cleaning them up later. This made the code harder to understand and caused a bug (aliases classed as temporary symbols would cause an assertion failure). A much simpler way of handling such symbols is to ask the layout for their section-relative position when needed. Tested with a bootstrap on Windows and by building Chrome. Differential Revision: http://reviews.llvm.org/D14975 llvm-svn: 254183
2015-11-18Fix bug where WinCOFFObjectWriter would assume starting from an empty output.Manuel Klimek1-1/+1
Starting on an input stream that is not at offset 0 would trigger the assert in WinCOFFObjectWriter.cpp:1065: assert(getStream().tell() <= (*i)->Header.PointerToRawData && "Section::PointerToRawData is insane!"); llvm-svn: 253464
2015-11-17[Assembler] Make fatal assembler errors non-fatalOliver Stannard1-7/+14
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-23Add a RAW mode to StringTableBuilder.Rafael Espindola1-2/+2
In this mode it just tries to tail merge the strings without imposing any other format constrains. It will not, for example, add a null byte between them. Also add support for keeping a tentative size and offset if we decide to not optimize after all. This will be used shortly in lld for merging SHF_STRINGS sections. llvm-svn: 251153
2015-09-16Add assembler fatal error for undefined assembler labels in COFF writerReid Kleckner1-0/+5
llvm-svn: 247814
2015-09-05WinCOFFObjectWriter.cpp: Roll back TimeDateStamp along ENABLE_TIMESTAMPS.NAKAMURA Takumi1-0/+5
We want a deterministic output. GNU AS leaves it zero. FIXME: It may be optional by its user, like llc and clang. llvm-svn: 246905
2015-09-04[MC] Replace comparison with isUInt<32>.David Majnemer1-1/+1
Casting to unsigned long can cause the time to get truncated to 32-bits, making it appear to be a valid timestamp. Just use isUInt<32> instead. llvm-svn: 246840
2015-09-04WinCOFFObjectWriter.cpp: Appease a warning in checking std::time_t. ↵NAKAMURA Takumi1-1/+1
[-Wsign-compare] llvm-svn: 246839
2015-09-01[MC] Generate a timestamp for COFF object filesDavid Majnemer1-2/+7
The MS incremental linker seems to inspect the timestamp written into the object file to determine whether or not it's contents need to be considered. Failing to set the timestamp to a date newer than the executable will result in the object file not participating in subsequent links. To ameliorate this, write the current time into the object file's TimeDateStamp field. llvm-svn: 246607
2015-09-01[MC] Add support for generating COFF CRCsDavid Majnemer1-0/+28
COFF sections are accompanied with an auxiliary symbol which includes a checksum. This checksum used to be filled with just zero but this seems to upset LINK.exe when it is processing a /INCREMENTAL link job. Instead, fill the CheckSum field with the JamCRC of the section contents. This matches MSVC's behavior. This fixes PR19666. N.B. A rather simple implementation of JamCRC is given. It implements a byte-wise calculation using the method given by Sarwate. There are implementations with higher throughput like slice-by-eight and making use of PCLMULQDQ. We can switch to one of those techniques if it turns out to be a significant use of time. llvm-svn: 246590
2015-09-01[MC] Allow MCObjectWriter's output stream to be swapped outDavid Majnemer1-5/+6
There are occasions where it is useful to consider the entirety of the contents of a section. For example, compressed debug info needs the entire section available before it can compress it and write it out. The compressed debug info scenario was previously implemented by mirroring the implementation of writeSectionData in the ELFObjectWriter. Instead, allow the output stream to be swapped on demand. This lets callers redirect the output stream to a more convenient location before it hits the object file. No functionality change is intended. Differential Revision: http://reviews.llvm.org/D12509 llvm-svn: 246554
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-11[WinEH] Create an llvm.x86.seh.exceptioninfo intrinsicReid Kleckner1-5/+4
This intrinsic is like framerecover plus a load. It recovers the EH registration stack allocation from the parent frame and loads the exception information field out of it, giving back a pointer to an EXCEPTION_POINTERS struct. It's designed for clang to use in SEH filter expressions instead of accessing the EXCEPTION_POINTERS parameter that is available on x64. This required a minor change to MC to allow defining a label variable to another absolute framerecover label variable. llvm-svn: 239567
2015-06-08Move all of the MCSymbol COFF flags logic in to MCSymbolCOFF.Pete Cooper1-4/+3
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-5/+5
Reviewed by Rafael Espíndola. llvm-svn: 239312
2015-06-04MC: Clean up the naming for MCMachObjectWriter. NFC.Jim Grosbach1-7/+7
s/ExecutePostLayoutBinding/executePostLayoutBinding/ s/ComputeSymbolTable/computeSymbolTable/ s/BindIndirectSymbols/bindIndirectSymbols/ s/RecordTLVPRelocation/recordTLVPRelocation/ s/RecordScatteredRelocation/recordScatteredRelocation/ s/WriteLinkerOptionsLoadCommand/writeLinkerOptionsLoadCommand/ s/WriteLinkeditLoadCommand/writeLinkeditLoadCommand/ s/WriteNlist/writeNlist/ s/WriteDysymtabLoadCommand/writeDysymtabLoadCommand/ s/WriteSymtabLoadCommand/writeSymtabLoadCommand/ s/WriteSection/writeSection/ s/WriteSegmentLoadCommand/writeSegmentLoadCommand/ s/WriteHeader/writeHeader/ llvm-svn: 239119
2015-06-04MC: Clean up naming in MCObjectWriter. NFC.Jim Grosbach1-64/+64
s/WriteObject/writeObject/ s/RecordRelocation/recordRelocation/ s/IsSymbolRefDifferenceFullyResolved/isSymbolRefDifferenceFullyResolved/ s/Write8/write8/ s/WriteLE16/writeLE16/ s/WriteLE32/writeLE32/ s/WriteLE64/writeLE64/ s/WriteBE16/writeBE16/ s/WriteBE32/writeBE32/ s/WriteBE64/writeBE64/ s/Write16/write16/ s/Write32/write32/ s/Write64/write64/ s/WriteZeroes/writeZeroes/ s/WriteBytes/writeBytes/ llvm-svn: 239108
2015-06-01Rename HasData to IsRegistered.Rafael Espindola1-1/+1
There is no MCSectionData, so the old name is now meaningless. Also remove some asserts/checks that were there just because the information they used was in MCSectionData. llvm-svn: 238708
2015-06-01Remove trivial forwarding function.Rafael Espindola1-1/+1
llvm-svn: 238707
2015-06-01Store a bit in MCSection saying if it was registered with MCAssembler.Rafael Espindola1-1/+1
With this we can replace a SetVector with a plain std::vector. llvm-svn: 238706
2015-05-30[WinCOFF] Add support for the .safeseh directiveDavid Majnemer1-17/+27
.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-29Remove getData.Rafael Espindola1-18/+10
This completes the mechanical part of merging MCSymbol and MCSymbolData. llvm-svn: 238617
2015-05-29Remove the MCSymbolData typedef.Rafael Espindola1-6/+6
The getData member function is next. llvm-svn: 238611
2015-05-29Move Flags from MCSymbolData to MCSymbol.Rafael Espindola1-5/+4
llvm-svn: 238598
2015-05-29Move common symbol related information from MCSectionData to MCSymbol.Rafael Espindola1-3/+3
llvm-svn: 238583
2015-05-28Remove a trivial forwarding function. NFC.Rafael Espindola1-4/+4
llvm-svn: 238506
2015-05-28Use range loops for accessing file names. NFC.Rafael Espindola1-6/+5
llvm-svn: 238446
2015-05-27Stop using MCSectionData in WinCOFFObjectWriter.cpp.Rafael Espindola1-15/+8
llvm-svn: 238329
2015-05-27clang-format WinCOFFObjectWriter.cpp. NFC.Rafael Espindola1-82/+102
llvm-svn: 238328
2015-05-26Remove most uses of MCSectionData from MCAssembler.Rafael Espindola1-1/+1
llvm-svn: 238172
2015-05-26Stop using MCSectionData in MCAsmLayout.h.Rafael Espindola1-2/+1
llvm-svn: 238170
2015-05-26Return a MCSection from MCFragment::getParent().Rafael Espindola1-5/+4
Another step in merging MCSectionData and MCSection. llvm-svn: 238162
2015-05-25Turn MCSectionData into a field of MCSection.Rafael Espindola1-4/+5
This also changes MCAssembler to store a vector of MCSections instead of an iplist of MCSectionData. llvm-svn: 238159
2015-05-21Stop forwarding (get|set)Aligment from MCSectionData to MCSection.Rafael Espindola1-1/+1
llvm-svn: 237956
2015-05-20MC: Stop using MCSymbolData::getSymbol() in WinCOFF, NFCDuncan P. N. Exon Smith1-26/+23
Move APIs over from `MCSymbolData` to `MCSymbol`. llvm-svn: 237826
2015-05-20MC: Use MCSymbol in MCObjectWriter::isWeak(), NFCDuncan P. N. Exon Smith1-3/+3
Continue to prefer `MCSymbol` when we need both. llvm-svn: 237798
2015-05-19MC: Use MCSymbol in MCAsmLayout::getSymbolOffset(), NFCDuncan P. N. Exon Smith1-3/+3
Continue to canonicalize on MCSymbol instead of MCSymbolData when both are needed. llvm-svn: 237749
2015-05-18MC: Clean up method names in MCContext.Jim Grosbach1-3/+3
The naming was a mish-mash of old and new style. Update to be consistent with the new. NFC. llvm-svn: 237594