summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
Commit message (Collapse)AuthorAgeFilesLines
...
* MC, COFF: Use relocations for function references inside the sectionDavid Majnemer2014-11-112-1/+19
| | | | | | | | | | | | | | | | | | 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
* Add const. NFC.Rafael Espindola2014-11-111-1/+1
| | | | | | | This adds const to a few methods that already return const references or creates a const version when they reterun non-const references. llvm-svn: 221666
* speling.Nico Weber2014-11-111-1/+1
| | | | llvm-svn: 221652
* Use a StringRefMemoryObject. NFC.Rafael Espindola2014-11-071-26/+3
| | | | llvm-svn: 221503
* [mips64] Fix MIPS64 exception personality encodingPetar Jovanovic2014-11-051-0/+2
| | | | | | | | | | | Remove dynamic relocations of __gxx_personality_v0 from the .eh_frame. The MIPS64 follow-up of the MIPS32 fix (rL209907). Patch by Vladimir Stefanovic. Differential Revision: http://reviews.llvm.org/D6141 llvm-svn: 221408
* Don't produce relocations for a difference in a section with no symbols.Rafael Espindola2014-11-041-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | We were producing a relocation for ---------------- .section foo,bar La: Lb: .long La-Lb -------------- but not for --------------------- .section foo,bar zed: La: Lb: .long La-Lb ---------------- This patch handles the case where both fragments are part of the first atom in a section and there is no corresponding symbol to that atom. This fixes pr21328. llvm-svn: 221304
* Revert r221150, as it broke sanitizer testsOliver Stannard2014-11-034-24/+12
| | | | llvm-svn: 221151
* Emit .eh_frame with relocations to functions, rather than sectionsOliver Stannard2014-11-034-12/+24
| | | | | | | | | | | | | | | | | | | | | | | When LLVM emits DWARF call frame information, it currently creates a local, section-relative symbol in the code section, which is pointed to by a relocation on the .eh_frame section. However, for C++ we emit some functions in section groups, and the SysV ABI has some rules to make it easier to remove these sections (http://www.sco.com/developers/gabi/latest/ch4.sheader.html#section_group_rules): A symbol table entry with STB_LOCAL binding that is defined relative to one of a group's sections, and that is contained in a symbol table section that is not part of the group, must be discarded if the group members are discarded. References to this symbol table entry from outside the group are not allowed. This means that we need to use the function symbol for the relocation, not a temporary symbol. There was a comment in the code claiming that the local symbol was used to avoid creating a relocation, but a relocation must be created anyway as the code and CFI are in different sections. llvm-svn: 221150
* Attempt to fix the build after r220439David Majnemer2014-10-221-1/+1
| | | | llvm-svn: 220440
* [MC] Attach labels to existing fragments instead of using a separate fragmentDerek Schuff2014-10-221-9/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently when emitting a label, a new data fragment is created for it if the current fragment isn't a data fragment. This change instead enqueues the label and attaches it to the next fragment (e.g. created for the next instruction) if possible. When bundle alignment is not enabled, this has no functionality change (it just results in fewer extra fragments being created). For bundle alignment, previously labels would point to the beginning of the bundle padding instead of the beginning of the emitted instruction. This was not only less efficient (e.g. jumping to the nops instead of past them) but also led to miscalculation of the address of the GOT (since MC uses a label difference rather than emitting a "." symbol). Fixes https://code.google.com/p/nativeclient/issues/detail?id=3982 Test Plan: regression test attached Reviewers: jvoung, eliben Subscribers: jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D5915 llvm-svn: 220439
* Drop support for an old version of ld64 (from darwin 9).Rafael Espindola2014-10-213-16/+0
| | | | llvm-svn: 220310
* Fix a bit of confusion about .set and produce more readable assembly.Rafael Espindola2014-10-212-1/+2
| | | | | | | | | | | | | | | Every target we support has support for assembly that looks like a = b - c .long a What is special about MachO is that the above combination suppresses the production of a relocation. With this change we avoid producing the intermediary labels when they don't add any value. llvm-svn: 220256
* Add back commits r219835 and a fixed version of r219829.Rafael Espindola2014-10-173-50/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The only difference from r219829 is using getOrCreateSectionSymbol(*ELFSec) instead of GetOrCreateSymbol(ELFSec->getSectionName()) in ELFObjectWriter which causes us to use the correct section symbol even if we have multiple sections with the same name. Original messages: r219829: Correctly handle references to section symbols. When processing assembly like .long .text we were creating a new undefined symbol .text. GAS on the other hand would handle that as a reference to the .text section. This patch implements that by creating the section symbols earlier so that they are visible during asm parsing. The patch also updates llvm-readobj to print the symbol number in the relocation dump so that the test can differentiate between two sections with the same name. r219835: Allow forward references to section symbols. llvm-svn: 220021
* Revert commit r219835 and r219829.Rafael Espindola2014-10-173-61/+50
| | | | | | | | | Revert "Correctly handle references to section symbols." Revert "Allow forward references to section symbols." Rui found a regression I am debugging. llvm-svn: 220010
* Allow forward references to section symbols.Rafael Espindola2014-10-151-1/+8
| | | | llvm-svn: 219835
* Correctly handle references to section symbols.Rafael Espindola2014-10-153-50/+54
| | | | | | | | | | | | | | | | | When processing assembly like .long .text we were creating a new undefined symbol .text. GAS on the other hand would handle that as a reference to the .text section. This patch implements that by creating the section symbols earlier so that they are visible during asm parsing. The patch also updates llvm-readobj to print the symbol number in the relocation dump so that the test can differentiate between two sections with the same name. llvm-svn: 219829
* [MC] Make bundle alignment mode setting idempotent and support nested bundlesDerek Schuff2014-10-152-12/+36
| | | | | | | | | | | | | | | | | | | | | | Summary: Currently an error is thrown if bundle alignment mode is set more than once per module (either via the API or the .bundle_align_mode directive). This change allows setting it multiple times as long as the alignment doesn't change. Also nested bundle_lock groups are currently not allowed. This change allows them, with the effect that the group stays open until all nests are exited, and if any of the bundle_lock directives has the align_to_end flag, the group becomes align_to_end. These changes make the bundle aligment simpler to use in the compiler, and also better match the corresponding support in GNU as. Reviewers: jvoung, eliben Differential Revision: http://reviews.llvm.org/D5801 llvm-svn: 219811
* Simplify handling of --noexecstack by using getNonexecutableStackSection.Rafael Espindola2014-10-156-23/+18
| | | | llvm-svn: 219799
* Move getNonexecutableStackSection up to the base ELF class.Rafael Espindola2014-10-151-0/+9
| | | | | | The .note.GNU-stack section is not SystemZ/X86 specific. llvm-svn: 219796
* Remove method that is identical to the base class one.Rafael Espindola2014-10-141-1/+0
| | | | llvm-svn: 219700
* MC: Shrink MCSymbolRefExpr by only storing the bits we need.Benjamin Kramer2014-10-111-8/+19
| | | | | | 32 -> 16 bytes on x86_64. NFC. llvm-svn: 219574
* MC: Bit pack MCSymbolData.Benjamin Kramer2014-10-113-12/+11
| | | | | | | | | 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
* delete function name from commentSanjay Patel2014-10-091-2/+2
| | | | llvm-svn: 219443
* Fix COFF section index relocation should be 16 bits, not 32Timur Iskhodzhanov2014-10-081-1/+1
| | | | | | | Original patch by Andrey Guskov! http://reviews.llvm.org/D5651 llvm-svn: 219327
* COFF: Don't oversize COMMON symbols when targeting BFD ldDavid Majnemer2014-10-081-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
* MC: add support for -aligncomm GNU extensionSaleem Abdulrasool2014-10-071-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
* [asan-asm-instrumentation] CFI directives are generated for .S files.Yuri Gorshenin2014-10-071-0/+12
| | | | | | | | | | | | Summary: CFI directives are generated for .S files. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5520 llvm-svn: 219199
* MachObjectWriter: optimize the string table for common sufficesHans Wennborg2014-10-062-46/+41
| | | | | | | | This is a follow-up to r207670 (ELF) and r218636 (COFF). Differential Revision: http://reviews.llvm.org/D5622 llvm-svn: 219126
* Note that a gold bug has been fixed.Rafael Espindola2014-10-061-2/+3
| | | | | | We should be able to stop working around it at some point in the future. llvm-svn: 219115
* MCParser: Modernize memory handling.Benjamin Kramer2014-10-031-37/+22
| | | | | | NFC. llvm-svn: 218998
* [mips] Print warning when using register names not available in N32/64Daniel Sanders2014-10-031-0/+4
| | | | | | | | | | | | | | | | | | | Summary: The register names t4-t7 are not available in the N32 and N64 ABIs. This patch prints a warning, when those names are used in N32/64, along with a fix-it with the correct register names. Patch by Vasileios Kalintiris Reviewers: dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5272 llvm-svn: 218989
* Extend C disassembler API to allow specifying target featuresBradley Smith2014-09-301-10/+16
| | | | llvm-svn: 218682
* WinCOFFObjectWriter: optimize the string table for common sufficesHans Wennborg2014-09-293-91/+62
| | | | | | | | 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
* MC: Use @IMGREL instead of @IMGREL32, which we can't parseReid Kleckner2014-09-251-1/+1
| | | | | | | | | | | | Nico Rieck added support for this 32-bit COFF relocation some time ago for Win64 stuff. It appears that as an oversight, the assembly output used "foo"@IMGREL32 instead of "foo"@IMGREL, which is what we can parse. Sadly, there were actually tests that took in IMGREL and put out IMGREL32, and we didn't notice the inconsistency. Oh well. Now LLVM can assemble it's own output with slightly more fidelity. llvm-svn: 218437
* Revert r218380. This was breaking Apple internal build bots.Akira Hatanaka2014-09-241-6/+14
| | | | llvm-svn: 218409
* Replace a hand-written suffix compare with std::lexicographical_compare.Benjamin Kramer2014-09-241-14/+6
| | | | | | No functionality change. llvm-svn: 218380
* Downgrade DWARF2 section limit error to a warningOliver Stannard2014-09-222-5/+7
| | | | | | | | | We currently emit an error when trying to assemble a file with more than one section using DWARF2 debug info. This should be a warning instead, as the resulting file will still be usable, but with a degraded debug illusion. llvm-svn: 218241
* ms-inline-asm: Add a sema callback for looking up label namesEhsan Akhgari2014-09-221-6/+18
| | | | | | | | | | | | | | | The implementation of the callback in clang's Sema will return an internal name for labels. Test Plan: Will be tested in clang. Reviewers: rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D4587 llvm-svn: 218229
* MC: Support aligned COMMON symbols for COFFDavid Majnemer2014-09-212-5/+16
| | | | | | | | | | | | | | | | | | | | | 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
* MC: Fix MCSectionCOFF::PrintSwitchToSectionDavid Majnemer2014-09-201-7/+11
| | | | | | | | | | | | We had a few bugs: - We were considering the GVKind instead of just looking at the section characteristics - We would never print out 'y' when a section was meant to be unreadable - We would never print out 's' when a section was meant to be shared - We translated IMAGE_SCN_MEM_DISCARDABLE to 'n' when it should've meant IMAGE_SCN_LNK_REMOVE llvm-svn: 218189
* MC: Treat ReadOnlyWithRel and ReadOnlyWithRelLocal as ReadOnly for COFFDavid Majnemer2014-09-201-1/+1
| | | | | | | | | | | A problem with our old behavior becomes observable under x86-64 COFF when we need a read-only GV which has an initializer which is referenced using a relocation: we would mark the section as writable. Marking the section as writable interferes with section merging. This fixes PR21009. llvm-svn: 218179
* Elide unnecessary DenseMap copy.Benjamin Kramer2014-09-191-3/+3
| | | | | | No functionality change. llvm-svn: 218122
* Another required re-setting for MCStreamer::reset().Yaron Keren2014-09-171-0/+1
| | | | llvm-svn: 217970
* Add and update reset() and doInitialization() methods to MC* and passes.Yaron Keren2014-09-174-0/+15
| | | | | | This enables reusing a PassManager instead of re-constructing it every time. llvm-svn: 217948
* 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
* MC: correct DWARF line info for PE/COFFSaleem Abdulrasool2014-09-061-1/+2
| | | | | | | | | DWARF address ranges contain a reference to the debug_info section. This offset is an absolute relocation except on non-PE/COFF targets where it is section relative. We would emit this incorrectly, and trying to map the debug info from the address would fail. llvm-svn: 217317
OpenPOWER on IntegriCloud