Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/IceELFObjectWriter.h

Issue 1179313004: Fix a bug that would cause subzero to fail when --threads=0. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Removes (newly introduces) unused parameter warning. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 23
24 namespace Ice { 24 namespace Ice {
25 25
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 (may be invoked multiple times, as long as
34 // SectionSuffix is unique)
Jim Stichnoth 2015/06/16 17:03:24 can you indent this by 4 characters?
John 2015/06/16 17:30:55 Done.
34 // (3) writeFunctionCode (must invoke once per function) 35 // (3) writeFunctionCode (must invoke once per function)
35 // (4) writeConstantPool (must invoke once per pooled primitive type) 36 // (4) writeConstantPool (must invoke once per pooled primitive type)
36 // (5) setUndefinedSyms (invoke once) 37 // (5) setUndefinedSyms (invoke once)
37 // (6) writeNonUserSections (invoke once) 38 // (6) writeNonUserSections (invoke once)
38 // 39 //
39 // The requirement for writeDataSection to be invoked only once can 40 // The requirement for writeDataSection to be invoked only once can
40 // be relaxed if using -fdata-sections. The requirement to invoke only once 41 // be relaxed if using -fdata-sections. The requirement to invoke only once
41 // without -fdata-sections is so that variables that belong to each possible 42 // without -fdata-sections is so that variables that belong to each possible
42 // SectionType are contiguous in the file. With -fdata-sections, each global 43 // SectionType are contiguous in the file. With -fdata-sections, each global
43 // variable is in a separate section and therefore the sections will be 44 // variable is in a separate section and therefore the sections will be
44 // trivially contiguous. 45 // trivially contiguous.
45 // 46 //
46 // The motivation for requiring that writeFunctionCode happen after 47 // TODO(jpp): explain what's going on here.
47 // writeDataSection: to keep the .text and .data sections contiguous in the
48 // file. Having both -fdata-sections and -ffunction-sections does allow
49 // relaxing this requirement.
50 class ELFObjectWriter { 48 class ELFObjectWriter {
51 ELFObjectWriter() = delete; 49 ELFObjectWriter() = delete;
52 ELFObjectWriter(const ELFObjectWriter &) = delete; 50 ELFObjectWriter(const ELFObjectWriter &) = delete;
53 ELFObjectWriter &operator=(const ELFObjectWriter &) = delete; 51 ELFObjectWriter &operator=(const ELFObjectWriter &) = delete;
54 52
55 public: 53 public:
56 ELFObjectWriter(GlobalContext &Ctx, ELFStreamer &Out); 54 ELFObjectWriter(GlobalContext &Ctx, ELFStreamer &Out);
57 55
58 // Write the initial ELF header. This is just to reserve space in the ELF 56 // Write the initial ELF header. This is just to reserve space in the ELF
59 // file. Reserving space allows the other functions to write text 57 // file. Reserving space allows the other functions to write text
60 // and data directly to the file and get the right file offsets. 58 // and data directly to the file and get the right file offsets.
61 void writeInitialELFHeader(); 59 void writeInitialELFHeader();
62 60
63 // Copy initializer data for globals to file and note the offset and size 61 // Copy initializer data for globals to file and note the offset and size
64 // of each global's definition in the symbol table. 62 // of each global's definition in the symbol table.
65 // Use the given target's RelocationKind for any relocations. 63 // Use the given target's RelocationKind for any relocations.
66 void writeDataSection(const VariableDeclarationList &Vars, 64 void writeDataSection(const VariableDeclarationList &Vars,
67 FixupKind RelocationKind); 65 FixupKind RelocationKind,
66 const IceString &SectionSuffix);
68 67
69 // Copy data of a function's text section to file and note the offset of the 68 // Copy data of a function's text section to file and note the offset of the
70 // symbol's definition in the symbol table. 69 // symbol's definition in the symbol table.
71 // Copy the text fixups for use after all functions are written. 70 // Copy the text fixups for use after all functions are written.
72 // The text buffer and fixups are extracted from the Assembler object. 71 // The text buffer and fixups are extracted from the Assembler object.
73 void writeFunctionCode(const IceString &FuncName, bool IsInternal, 72 void writeFunctionCode(const IceString &FuncName, bool IsInternal,
74 const Assembler *Asm); 73 const Assembler *Asm);
75 74
76 // Queries the GlobalContext for constant pools of the given type 75 // Queries the GlobalContext for constant pools of the given type
77 // 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
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 RelSectionList &RelSections, 143 RelSectionList &RelSections,
145 SectionList &AllSections); 144 SectionList &AllSections);
146 145
147 // Link the relocation sections to the symbol table. 146 // Link the relocation sections to the symbol table.
148 void assignRelLinkNum(SizeT SymTabNumber, RelSectionList &RelSections); 147 void assignRelLinkNum(SizeT SymTabNumber, RelSectionList &RelSections);
149 148
150 // Helper function for writeDataSection. Writes a data section of type 149 // Helper function for writeDataSection. Writes a data section of type
151 // SectionType, given the global variables Vars belonging to that SectionType. 150 // SectionType, given the global variables Vars belonging to that SectionType.
152 void writeDataOfType(SectionType SectionType, 151 void writeDataOfType(SectionType SectionType,
153 const VariableDeclarationList &Vars, 152 const VariableDeclarationList &Vars,
154 FixupKind RelocationKind); 153 FixupKind RelocationKind,
154 const IceString &SectionSuffix);
155 155
156 // Write the final relocation sections given the final symbol table. 156 // Write the final relocation sections given the final symbol table.
157 // May also be able to seek around the file and resolve function calls 157 // May also be able to seek around the file and resolve function calls
158 // that are for functions within the same section. 158 // that are for functions within the same section.
159 void writeAllRelocationSections(); 159 void writeAllRelocationSections();
160 void writeRelocationSections(RelSectionList &RelSections); 160 void writeRelocationSections(RelSectionList &RelSections);
161 161
162 // Write the ELF file header with the given information about sections. 162 // Write the ELF file header with the given information about sections.
163 template <bool IsELF64> 163 template <bool IsELF64>
164 void writeELFHeaderInternal(Elf64_Off SectionHeaderOffset, 164 void writeELFHeaderInternal(Elf64_Off SectionHeaderOffset,
165 SizeT SectHeaderStrIndex, SizeT NumSections); 165 SizeT SectHeaderStrIndex, SizeT NumSections);
166 }; 166 };
167 167
168 } // end of namespace Ice 168 } // end of namespace Ice
169 169
170 #endif // SUBZERO_SRC_ICEELFOBJECTWRITER_H 170 #endif // SUBZERO_SRC_ICEELFOBJECTWRITER_H
OLDNEW
« no previous file with comments | « src/IceCompiler.cpp ('k') | src/IceELFObjectWriter.cpp » ('j') | src/IceGlobalContext.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698