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

Side by Side Diff: src/IceELFSection.h

Issue 1197223002: Subzero: Use C++11 member initializers where practical. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase 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
« no previous file with comments | « src/IceELFObjectWriter.cpp ('k') | src/IceFixups.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 26 matching lines...) Expand all
37 // section index is actually known. The dummy NULL section will be assigned 37 // section index is actually known. The dummy NULL section will be assigned
38 // number 0, and it is referenced by the dummy 0-th symbol in the symbol 38 // number 0, and it is referenced by the dummy 0-th symbol in the symbol
39 // table, so use max() instead of 0. 39 // table, so use max() instead of 0.
40 enum { NoSectionNumber = std::numeric_limits<SizeT>::max() }; 40 enum { NoSectionNumber = std::numeric_limits<SizeT>::max() };
41 41
42 // Constructs an ELF section, filling in fields that will be known 42 // Constructs an ELF section, filling in fields that will be known
43 // once the *type* of section is decided. Other fields may be updated 43 // once the *type* of section is decided. Other fields may be updated
44 // incrementally or only after the program is completely defined. 44 // incrementally or only after the program is completely defined.
45 ELFSection(const IceString &Name, Elf64_Word ShType, Elf64_Xword ShFlags, 45 ELFSection(const IceString &Name, Elf64_Word ShType, Elf64_Xword ShFlags,
46 Elf64_Xword ShAddralign, Elf64_Xword ShEntsize) 46 Elf64_Xword ShAddralign, Elf64_Xword ShEntsize)
47 : Name(Name), Header(), Number(NoSectionNumber) { 47 : Name(Name), Header() {
48 Header.sh_type = ShType; 48 Header.sh_type = ShType;
49 Header.sh_flags = ShFlags; 49 Header.sh_flags = ShFlags;
50 Header.sh_addralign = ShAddralign; 50 Header.sh_addralign = ShAddralign;
51 Header.sh_entsize = ShEntsize; 51 Header.sh_entsize = ShEntsize;
52 } 52 }
53 53
54 // Set the section number/index after it is finally known. 54 // Set the section number/index after it is finally known.
55 void setNumber(SizeT N) { 55 void setNumber(SizeT N) {
56 // Should only set the number once: from NoSectionNumber -> N. 56 // Should only set the number once: from NoSectionNumber -> N.
57 assert(Number == NoSectionNumber); 57 assert(Number == NoSectionNumber);
(...skipping 16 matching lines...) Expand all
74 void setInfoNum(Elf64_Word sh_info) { Header.sh_info = sh_info; } 74 void setInfoNum(Elf64_Word sh_info) { Header.sh_info = sh_info; }
75 75
76 void setFileOffset(Elf64_Off sh_offset) { Header.sh_offset = sh_offset; } 76 void setFileOffset(Elf64_Off sh_offset) { Header.sh_offset = sh_offset; }
77 77
78 Elf64_Xword getSectionAlign() const { return Header.sh_addralign; } 78 Elf64_Xword getSectionAlign() const { return Header.sh_addralign; }
79 79
80 // Write the section header out with the given streamer. 80 // Write the section header out with the given streamer.
81 template <bool IsELF64> void writeHeader(ELFStreamer &Str); 81 template <bool IsELF64> void writeHeader(ELFStreamer &Str);
82 82
83 protected: 83 protected:
84 ~ELFSection() {} 84 ~ELFSection() = default;
85 85
86 // Name of the section in convenient string form (instead of a index 86 // Name of the section in convenient string form (instead of a index
87 // into the Section Header String Table, which is not known till later). 87 // into the Section Header String Table, which is not known till later).
88 const IceString Name; 88 const IceString Name;
89 89
90 // The fields of the header. May only be partially initialized, but should 90 // The fields of the header. May only be partially initialized, but should
91 // be fully initialized before writing. 91 // be fully initialized before writing.
92 Elf64_Shdr Header; 92 Elf64_Shdr Header;
93 93
94 // The number of the section after laying out sections. 94 // The number of the section after laying out sections.
95 SizeT Number; 95 SizeT Number = NoSectionNumber;
96 }; 96 };
97 97
98 // Models text/code sections. Code is written out incrementally and the 98 // Models text/code sections. Code is written out incrementally and the
99 // size of the section is then updated incrementally. 99 // size of the section is then updated incrementally.
100 class ELFTextSection : public ELFSection { 100 class ELFTextSection : public ELFSection {
101 ELFTextSection() = delete; 101 ELFTextSection() = delete;
102 ELFTextSection(const ELFTextSection &) = delete; 102 ELFTextSection(const ELFTextSection &) = delete;
103 ELFTextSection &operator=(const ELFTextSection &) = delete; 103 ELFTextSection &operator=(const ELFTextSection &) = delete;
104 104
105 public: 105 public:
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 Rel.setSymbolAndType(Symbol->getNumber(), Fixup.kind()); 374 Rel.setSymbolAndType(Symbol->getNumber(), Fixup.kind());
375 Str.writeAddrOrOffset<IsELF64>(Rel.r_offset); 375 Str.writeAddrOrOffset<IsELF64>(Rel.r_offset);
376 Str.writeELFWord<IsELF64>(Rel.r_info); 376 Str.writeELFWord<IsELF64>(Rel.r_info);
377 } 377 }
378 } 378 }
379 } 379 }
380 380
381 } // end of namespace Ice 381 } // end of namespace Ice
382 382
383 #endif // SUBZERO_SRC_ICEELFSECTION_H 383 #endif // SUBZERO_SRC_ICEELFSECTION_H
OLDNEW
« no previous file with comments | « src/IceELFObjectWriter.cpp ('k') | src/IceFixups.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698