aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/ELFObjectWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Provide basic type safety for array_pod_sort comparators.Benjamin Kramer2013-09-221-5/+4
| | | | | | | | This makes using array_pod_sort significantly safer. The implementation relies on function pointer casting but that should be safe as we're dealing with void* here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191175 91177308-0d34-0410-b5e6-96231b3b80d8
* Put ELF COMDAT relocations into the relevant COMDAT group.Tim Northover2013-07-101-2/+9
| | | | | | | | Patch from Игорь Пашев (I do hope we support utf-8 commit messages; I also hope he'll forgive me for transliterating it as Igor Pashev in case things go horribly wrong). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186034 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove MCELFObjectTargetWriter::adjustFixupOffset hackUlrich Weigand2013-05-151-3/+0
| | | | | | | | | | Now that PowerPC no longer uses adjustFixupOffset, and no other back-end (ever?) did, we can remove the infrastructure itself (incidentally addressing a FIXME to that effect). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181895 91177308-0d34-0410-b5e6-96231b3b80d8
* Commit the right files for r176762. Sigh.Nick Lewycky2013-03-091-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176763 91177308-0d34-0410-b5e6-96231b3b80d8
* ELF symbol table field st_other support, Jack Carter2013-02-191-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | excluding visibility bits. Generic STO handling at the Target level. The st_other field of the ELF symbol table is one byte in size. The first 2 bytes are used for generic visibility and are currently handled by llvm. The other six bits are processor specific and need to be set at the target level. A couple of notes: The new static methods for accessing and setting the "other" flags in include/llvm/MC/MCELF.h match the style guide and not the other methods in the file. I don't like the inconsistency, but feel I should follow the prescribed lowerUpper() convention. STO_ value definitions are not specified in gnu land as consistently as the STT_ and STB_ fields. Probably because the latter were defined in a standards doc and the former defined partially in code. I have stuck with the full byte definition of the flags. Contributer: Zoran Jovanovic git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175561 91177308-0d34-0410-b5e6-96231b3b80d8
* This patch just fixes up various llvm formattingJack Carter2013-02-121-1/+2
| | | | | | | | | | | violations such as tabs, blanks at eol and long lines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175007 91177308-0d34-0410-b5e6-96231b3b80d8
* Link .ARM.exidx with corresponding text section.Logan Chien2013-02-051-0/+18
| | | | | | | | | The sh_link in the ELF section header of .ARM.exidx should be filled with the section index of the corresponding text section. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174372 91177308-0d34-0410-b5e6-96231b3b80d8
* This patch reworks how llvm targets set Jack Carter2013-01-301-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | and update ELF header e_flags. Currently gathering information such as symbol, section and data is done by collecting it in an MCAssembler object. From MCAssembler and MCAsmLayout objects ELFObjectWriter::WriteObject() forms and streams out the ELF object file. This patch just adds a few members to the MCAssember class to store and access the e_flag settings. It allows for runtime additions to the e_flag by assembler directives. The standalone assembler can get to MCAssembler from getParser().getStreamer().getAssembler(). This patch is the generic infrastructure and will be followed by patches for ARM and Mips for their target specific use. Contributer: Jack Carter git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173882 91177308-0d34-0410-b5e6-96231b3b80d8
* This is a resubmittal. For some reason it broke the bots yesterdayJack Carter2013-01-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | but I cannot reproduce the problem and have scrubed my sources and even tested with llvm-lit -v --vg. Support for Mips register information sections. Mips ELF object files have a section that is dedicated to register use info. Some of this information such as the assumed Global Pointer value is used by the linker in relocation resolution. The register info file is .reginfo in o32 and .MIPS.options in 64 and n32 abi files. This patch contains the changes needed to create the sections, but leaves the actual register accounting for a future patch. Contributer: Jack Carter git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172847 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove redundant 'llvm::' qualificationsDmitri Gribenko2013-01-131-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172358 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the contents of encoded sections SmallVector<char, N> instead ofEli Bendersky2012-12-071-8/+8
| | | | | | | | | | | | | | SmallString. This makes it possible to use the length-erased SmallVectorImpl in the interface without imposing buffer size. Thus, the size of MCInstFragment is back down since a preallocated 8-byte contents buffer is enough. It would be generally a good idea to rid all the fragments of SmallString as contents, because a vector just makes more sense. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169644 91177308-0d34-0410-b5e6-96231b3b80d8
* Added Mapping Symbols for ARM ELFTim Northover2012-12-071-1/+1
| | | | | | | | | | Before this patch, when you objdump an LLVM-compiled file, objdump tried to decode data-in-code sections as if they were code. This patch adds the missing Mapping Symbols, as defined by "ELF for the ARM Architecture" (ARM IHI 0044D). Patch based on work by Greg Fitzgerald. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169609 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-4/+3
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* Initial TOC support for PowerPC64 object creationAdhemerval Zanella2012-10-251-5/+13
| | | | | | | | | | | | | | | | This patch adds initial PPC64 TOC MC object creation using the small mcmodel (a single 64K TOC) adding the some TOC relocations (R_PPC64_TOC, R_PPC64_TOC16, and R_PPC64_TOC16DS). The addition of 'undefinedExplicitRelSym' hook on 'MCELFObjectTargetWriter' is meant to avoid the creation of an unreferenced ".TOC." symbol (used in the .odp creation) as well to set the R_PPC64_TOC relocation target as the temporary ".TOC." symbol. On PPC64 ABI, the R_PPC64_TOC relocation should not point to any symbol. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166677 91177308-0d34-0410-b5e6-96231b3b80d8
* Check .rela instead of ELF64 for the compensation vaue resettingMichael Liao2012-10-161-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166051 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix comment.Rafael Espindola2012-08-271-3/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162678 91177308-0d34-0410-b5e6-96231b3b80d8
* The ELF relocation record format is different for N64 Jack Carter2012-06-271-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which many Mips 64 ABIs use than for O64 which many if not all other target ABIs use. Most architectures have the following 64 bit relocation record format: typedef struct { Elf64_Addr r_offset; /* Address of reference */ Elf64_Xword r_info; /* Symbol index and type of relocation */ } Elf64_Rel; typedef struct { Elf64_Addr r_offset; Elf64_Xword r_info; Elf64_Sxword r_addend; } Elf64_Rela; Whereas N64 has the following format: typedef struct { Elf64_Addr r_offset;/* Address of reference */ Elf64_Word r_sym; /* Symbol index */ Elf64_Byte r_ssym; /* Special symbol */ Elf64_Byte r_type3; /* Relocation type */ Elf64_Byte r_type2; /* Relocation type */ Elf64_Byte r_type; /* Relocation type */ } Elf64_Rel; typedef struct { Elf64_Addr r_offset;/* Address of reference */ Elf64_Word r_sym; /* Symbol index */ Elf64_Byte r_ssym; /* Special symbol */ Elf64_Byte r_type3; /* Relocation type */ Elf64_Byte r_type2; /* Relocation type */ Elf64_Byte r_type; /* Relocation type */ Elf64_Sxword r_addend; } Elf64_Rela; The structure is the same size, but the r_info data element is now 5 separate elements. Besides the content aspects, endian byte reordering will be different for the area with each element being endianized separately. I treat this as generic and continue to pass r_type as an integer masking and unmasking the byte sized N64 values for N64 mode. I've implemented this and it causes no affect on other current targets. This passes make check. Jack git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159299 91177308-0d34-0410-b5e6-96231b3b80d8
* Tidy up. Trailing whitespace.Jim Grosbach2012-05-111-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156602 91177308-0d34-0410-b5e6-96231b3b80d8
* Prune some includes and forward declarations.Craig Topper2012-03-261-3/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153429 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a hook in MCELFObjectTargetWriter to allow targets to sort relocationAkira Hatanaka2012-03-231-29/+5
| | | | | | | | entries in the relocation table before they are written out to the file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153345 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a bunch of unused variable assignments.Benjamin Kramer2012-01-201-9/+2
| | | | | | Found by the clang static analyzer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148541 91177308-0d34-0410-b5e6-96231b3b80d8
* Kill the monstrosity that was ELFObjectWriter.h.Rafael Espindola2011-12-221-1/+331
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147136 91177308-0d34-0410-b5e6-96231b3b80d8
* Misc cleanups.Rafael Espindola2011-12-221-20/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147135 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the Mips only bits of the ELF writer to lib/Target/Mips.Rafael Espindola2011-12-221-101/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147133 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the MBlaze ELF writer bits to lib/Target/MBlaze.Rafael Espindola2011-12-221-47/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147129 91177308-0d34-0410-b5e6-96231b3b80d8
* Move PPC bits to lib/Target/PowerPC.Rafael Espindola2011-12-221-75/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147124 91177308-0d34-0410-b5e6-96231b3b80d8
* Local dynamic TLS model for direct object output. Create the correct TLS MIPSAkira Hatanaka2011-12-221-0/+9
| | | | | | | | | | ELF relocations. Patch by Jack Carter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147118 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the ARM specific parts of the ELF writer to Target/ARM.Rafael Espindola2011-12-221-241/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147115 91177308-0d34-0410-b5e6-96231b3b80d8
* getEFlags is const.Rafael Espindola2011-12-221-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147114 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch from WriteEFlags to getEFlags in preparation for moving itRafael Espindola2011-12-211-6/+5
| | | | | | to Target/. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147087 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the X86 specific bits of the ELF writer to the Target/X86 directory.Rafael Espindola2011-12-211-191/+10
| | | | | | Other targets will follow shortly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147060 91177308-0d34-0410-b5e6-96231b3b80d8
* Reduce the exposure of Triple::OSType in the ELF object writer. This willRafael Espindola2011-12-211-5/+1
| | | | | | | avoid including ADT/Triple.h in many places when the target specific bits are moved. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147059 91177308-0d34-0410-b5e6-96231b3b80d8
* Small refactoring so that RelocNeedsGOT can stay in the target independentRafael Espindola2011-12-211-17/+10
| | | | | | side when the target specific bits are moved to the Target directory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147053 91177308-0d34-0410-b5e6-96231b3b80d8
* Relocation against a symbol, instead of against section. We had some extremeAkira Hatanaka2011-12-131-2/+2
| | | | | | | | | | | | test cases where there were a lot of relocations applied relative to a large rodata section. Gas would create a symbol for each of these whereas we would be relative to the beginning of the rodata section. This change mimics what gas does. Patch by Jack Carter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146468 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle reloc_signed_4byte in here. Not doing so was a regression from myRafael Espindola2011-12-091-0/+1
| | | | | | | previous commit. It is strange that we see it in 32 bits. We already have a fixme about it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146273 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle the case of the magical _GLOBAL_OFFSET_TABLE_ showing up in aRafael Espindola2011-12-091-7/+18
| | | | | | | | symbol difference. This matches gas behavior and fixes PR11513. We still don't handle _GLOBAL_OFFSET_TABLE_ in data sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146238 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a few moreLocal/Global R_MIPS_GOT related fixups andBruno Cardoso Lopes2011-12-071-1/+2
| | | | | | | | make the addend fixup code a bit more generic Patch by Jack Carter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145998 91177308-0d34-0410-b5e6-96231b3b80d8
* Explicit symbols for gnu mimicing relocations. Patch by Jack CarterBruno Cardoso Lopes2011-12-061-0/+14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145911 91177308-0d34-0410-b5e6-96231b3b80d8
* Tidy up. Hard tabs.Jim Grosbach2011-12-061-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145878 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch MCAssembler to method names starting w/ lower-case.Jim Grosbach2011-12-061-1/+1
| | | | | | per http://llvm.org/docs/CodingStandards.html#ll_naming git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145873 91177308-0d34-0410-b5e6-96231b3b80d8
* This patch addresses gp relative fixups/relocations for jump tables.Akira Hatanaka2011-11-231-0/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145112 91177308-0d34-0410-b5e6-96231b3b80d8
* Tidy up. 80 columns.Jim Grosbach2011-11-151-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144649 91177308-0d34-0410-b5e6-96231b3b80d8
* Add mips ELF relocation types. Patch by Jack Carter!Bruno Cardoso Lopes2011-11-041-6/+55
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143738 91177308-0d34-0410-b5e6-96231b3b80d8
* Also create a shndx even if there are no symbols. This lets us testNick Lewycky2011-10-111-0/+3
| | | | | | | | .symtab_shndx reading and writing together, and finally we have a testcase for r141440. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141641 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't emit the symbol table entry for the .symtab_shndx section either.Nick Lewycky2011-10-071-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141440 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove extraneous curlies. No functionality change.Nick Lewycky2011-10-071-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141439 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't emit a shstrtabindex in the reserved range. Spotted by inspection andNick Lewycky2011-10-071-1/+1
| | | | | | | patch by Cary Coutant! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141413 91177308-0d34-0410-b5e6-96231b3b80d8
* Clarify/fix typo. No functionality change.Nick Lewycky2011-10-071-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141412 91177308-0d34-0410-b5e6-96231b3b80d8
* Add definition of MipsELFObjectWriter.Akira Hatanaka2011-09-301-0/+18
| | | | | | | | | Patch by Reed Kotler at Mips Technologies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140891 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce adjustFixupOffset that adjusts the fixup offset of a relocation.Roman Divacky2011-08-041-12/+14
| | | | | | | | | | This is meant to be overriden by backends. Implement an override on PowerPC which adjusts the offset by 2 for ha16/lo16 relocation kinds. This removes a commented out hack and enables hello world to be compiled on PowerPC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136905 91177308-0d34-0410-b5e6-96231b3b80d8