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

Side by Side Diff: src/IceELFSection.h

Issue 874353006: Write out global initializers and data rel directly to ELF file. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: misc stuff Created 5 years, 10 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/IceELFSection.h - Model of ELF sections ------*- C++ -*-===// 1 //===- subzero/src/IceELFSection.h - Model of ELF sections ------*- 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 // Representation of ELF sections. 10 // Representation of ELF sections.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // size of the section is then updated incrementally. 110 // size of the section is then updated incrementally.
111 // Some rodata sections may have fixed entsize and duplicates may be mergeable. 111 // Some rodata sections may have fixed entsize and duplicates may be mergeable.
112 class ELFDataSection : public ELFSection { 112 class ELFDataSection : public ELFSection {
113 ELFDataSection(const ELFDataSection &) = delete; 113 ELFDataSection(const ELFDataSection &) = delete;
114 ELFDataSection &operator=(const ELFDataSection &) = delete; 114 ELFDataSection &operator=(const ELFDataSection &) = delete;
115 115
116 public: 116 public:
117 using ELFSection::ELFSection; 117 using ELFSection::ELFSection;
118 118
119 void appendData(ELFStreamer &Str, const llvm::StringRef MoreData); 119 void appendData(ELFStreamer &Str, const llvm::StringRef MoreData);
120
121 void appendZeros(ELFStreamer &Str, SizeT NumBytes);
122
123 void appendRelocationOffset(ELFStreamer &Str, bool IsRela,
124 RelocOffsetT RelocOffset);
125
126 // Pad the next section offset for writing data elements to the requested
127 // alignment. If the section is NOBITS then do not actually write out
128 // the padding and only update the section size.
129 void padToAlignment(ELFStreamer &Str, Elf64_Xword Align);
130
120 }; 131 };
121 132
122 // Model of ELF symbol table entries. Besides keeping track of the fields 133 // Model of ELF symbol table entries. Besides keeping track of the fields
123 // required for an elf symbol table entry it also tracks the number that 134 // required for an elf symbol table entry it also tracks the number that
124 // represents the symbol's final index in the symbol table. 135 // represents the symbol's final index in the symbol table.
125 struct ELFSym { 136 struct ELFSym {
126 Elf64_Sym Sym; 137 Elf64_Sym Sym;
127 ELFSection *Section; 138 ELFSection *Section;
128 SizeT Number; 139 SizeT Number;
129 140
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 }; 199 };
189 200
190 // Models a relocation section. 201 // Models a relocation section.
191 class ELFRelocationSection : public ELFSection { 202 class ELFRelocationSection : public ELFSection {
192 ELFRelocationSection(const ELFRelocationSection &) = delete; 203 ELFRelocationSection(const ELFRelocationSection &) = delete;
193 ELFRelocationSection &operator=(const ELFRelocationSection &) = delete; 204 ELFRelocationSection &operator=(const ELFRelocationSection &) = delete;
194 205
195 public: 206 public:
196 using ELFSection::ELFSection; 207 using ELFSection::ELFSection;
197 208
198 ELFSection *getRelatedSection() const { return RelatedSection; } 209 const ELFSection *getRelatedSection() const { return RelatedSection; }
199 void setRelatedSection(ELFSection *Section) { RelatedSection = Section; } 210 void setRelatedSection(const ELFSection *Section) {
211 RelatedSection = Section;
212 }
200 213
201 // Track additional relocations which start out relative to offset 0, 214 // Track additional relocations which start out relative to offset 0,
202 // but should be adjusted to be relative to BaseOff. 215 // but should be adjusted to be relative to BaseOff.
203 void addRelocations(RelocOffsetT BaseOff, const FixupRefList &FixupRefs); 216 void addRelocations(RelocOffsetT BaseOff, const FixupRefList &FixupRefs);
204 217
218 // Track a single additional relocation.
219 void addRelocation(const AssemblerFixup &Fixup) { Fixups.push_back(Fixup); }
220
205 size_t getSectionDataSize(const GlobalContext &Ctx, 221 size_t getSectionDataSize(const GlobalContext &Ctx,
206 const ELFSymbolTableSection *SymTab) const; 222 const ELFSymbolTableSection *SymTab) const;
207 223
208 template <bool IsELF64> 224 template <bool IsELF64>
209 void writeData(const GlobalContext &Ctx, ELFStreamer &Str, 225 void writeData(const GlobalContext &Ctx, ELFStreamer &Str,
210 const ELFSymbolTableSection *SymTab); 226 const ELFSymbolTableSection *SymTab);
211 227
228 bool isRela() const { return Header.sh_type == SHT_RELA; }
229
212 private: 230 private:
213 ELFSection *RelatedSection; 231 const ELFSection *RelatedSection;
214 FixupList Fixups; 232 FixupList Fixups;
215 }; 233 };
216 234
217 // Models a string table. The user will build the string table by 235 // Models a string table. The user will build the string table by
218 // adding strings incrementally. At some point, all strings should be 236 // adding strings incrementally. At some point, all strings should be
219 // known and doLayout() should be called. After that, no other 237 // known and doLayout() should be called. After that, no other
220 // strings may be added. However, the final offsets of the strings 238 // strings may be added. However, the final offsets of the strings
221 // can be discovered and used to fill out section headers and symbol 239 // can be discovered and used to fill out section headers and symbol
222 // table entries. 240 // table entries.
223 class ELFStringTableSection : public ELFSection { 241 class ELFStringTableSection : public ELFSection {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 Str.writeAddrOrOffset<IsELF64>(Rel.r_offset); 353 Str.writeAddrOrOffset<IsELF64>(Rel.r_offset);
336 Str.writeELFWord<IsELF64>(Rel.r_info); 354 Str.writeELFWord<IsELF64>(Rel.r_info);
337 } 355 }
338 } 356 }
339 } 357 }
340 } 358 }
341 359
342 } // end of namespace Ice 360 } // end of namespace Ice
343 361
344 #endif // SUBZERO_SRC_ICEELFSECTION_H 362 #endif // SUBZERO_SRC_ICEELFSECTION_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698