| OLD | NEW |
| 1 //===- subzero/src/IceELFObjectWriter.h - ELF object writer -----*- C++ -*-===// | 1 //===- subzero/src/IceELFObjectWriter.h - ELF object writer -----*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // Abstraction for a writer that is responsible for writing an ELF file. | 10 // Abstraction for a writer that is responsible for writing an ELF file. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // Higher level ELF object writer. Manages section information and writes | 26 // Higher level ELF object writer. Manages section information and writes |
| 27 // the final ELF object. The object writer will write to file the code | 27 // the final ELF object. The object writer will write to file the code |
| 28 // and data as it is being defined (rather than keep a copy). | 28 // and data as it is being defined (rather than keep a copy). |
| 29 // After all definitions are written out, it will finalize the bookkeeping | 29 // After all definitions are written out, it will finalize the bookkeeping |
| 30 // sections and write them out. Expected usage: | 30 // sections and write them out. Expected usage: |
| 31 // | 31 // |
| 32 // (1) writeInitialELFHeader (invoke once) | 32 // (1) writeInitialELFHeader (invoke once) |
| 33 // (2) writeDataSection (invoke once) | 33 // (2) writeDataSection (invoke once) |
| 34 // (3) writeFunctionCode (must invoke once per function) | 34 // (3) writeFunctionCode (must invoke once per function) |
| 35 // (4) writeConstantPool (must invoke once per pooled primitive type) | 35 // (4) writeConstantPool (must invoke once per pooled primitive type) |
| 36 // (5) writeNonUserSections (invoke once) | 36 // (5) setUndefinedSyms (invoke once) |
| 37 // (6) writeNonUserSections (invoke once) |
| 37 // | 38 // |
| 38 // The requirement for writeDataSection to be invoked only once can | 39 // The requirement for writeDataSection to be invoked only once can |
| 39 // be relaxed if using -fdata-sections. The requirement to invoke only once | 40 // be relaxed if using -fdata-sections. The requirement to invoke only once |
| 40 // without -fdata-sections is so that variables that belong to each possible | 41 // without -fdata-sections is so that variables that belong to each possible |
| 41 // SectionType are contiguous in the file. With -fdata-sections, each global | 42 // SectionType are contiguous in the file. With -fdata-sections, each global |
| 42 // variable is in a separate section and therefore the sections will be | 43 // variable is in a separate section and therefore the sections will be |
| 43 // trivially contiguous. | 44 // trivially contiguous. |
| 44 // | 45 // |
| 45 // The motivation for requiring that writeFunctionCode happen after | 46 // The motivation for requiring that writeFunctionCode happen after |
| 46 // writeDataSection: to keep the .text and .data sections contiguous in the | 47 // writeDataSection: to keep the .text and .data sections contiguous in the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 69 // Copy the text fixups for use after all functions are written. | 70 // Copy the text fixups for use after all functions are written. |
| 70 // The text buffer and fixups are extracted from the Assembler object. | 71 // The text buffer and fixups are extracted from the Assembler object. |
| 71 void writeFunctionCode(const IceString &FuncName, bool IsInternal, | 72 void writeFunctionCode(const IceString &FuncName, bool IsInternal, |
| 72 const Assembler *Asm); | 73 const Assembler *Asm); |
| 73 | 74 |
| 74 // Queries the GlobalContext for constant pools of the given type | 75 // Queries the GlobalContext for constant pools of the given type |
| 75 // and writes out read-only data sections for those constants. This also | 76 // and writes out read-only data sections for those constants. This also |
| 76 // fills the symbol table with labels for each constant pool entry. | 77 // fills the symbol table with labels for each constant pool entry. |
| 77 template <typename ConstType> void writeConstantPool(Type Ty); | 78 template <typename ConstType> void writeConstantPool(Type Ty); |
| 78 | 79 |
| 80 // Populate the symbol table with a list of external/undefined symbols. |
| 81 void setUndefinedSyms(const ConstantList &UndefSyms); |
| 82 |
| 79 // Do final layout and write out the rest of the object file. | 83 // Do final layout and write out the rest of the object file. |
| 80 // Finally, patch up the initial ELF header with the final info. | 84 // Finally, patch up the initial ELF header with the final info. |
| 81 void writeNonUserSections(); | 85 void writeNonUserSections(); |
| 82 | 86 |
| 83 // Which type of ELF section a global variable initializer belongs to. | 87 // Which type of ELF section a global variable initializer belongs to. |
| 84 // This is used as an array index so should start at 0 and be contiguous. | 88 // This is used as an array index so should start at 0 and be contiguous. |
| 85 enum SectionType { ROData = 0, Data, BSS, NumSectionTypes }; | 89 enum SectionType { ROData = 0, Data, BSS, NumSectionTypes }; |
| 86 | 90 |
| 87 private: | 91 private: |
| 88 GlobalContext &Ctx; | 92 GlobalContext &Ctx; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 159 |
| 156 // Write the ELF file header with the given information about sections. | 160 // Write the ELF file header with the given information about sections. |
| 157 template <bool IsELF64> | 161 template <bool IsELF64> |
| 158 void writeELFHeaderInternal(Elf64_Off SectionHeaderOffset, | 162 void writeELFHeaderInternal(Elf64_Off SectionHeaderOffset, |
| 159 SizeT SectHeaderStrIndex, SizeT NumSections); | 163 SizeT SectHeaderStrIndex, SizeT NumSections); |
| 160 }; | 164 }; |
| 161 | 165 |
| 162 } // end of namespace Ice | 166 } // end of namespace Ice |
| 163 | 167 |
| 164 #endif // SUBZERO_SRC_ICEELFOBJECTWRITER_H | 168 #endif // SUBZERO_SRC_ICEELFOBJECTWRITER_H |
| OLD | NEW |