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

Side by Side Diff: src/IceELFSection.cpp

Issue 1017373002: Subzero: Assemble calls to constant addresses. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: move test back Created 5 years, 9 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/IceELFSection.h ('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.cpp - Representation of ELF sections -----===// 1 //===- subzero/src/IceELFSection.cpp - Representation of ELF sections -----===//
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 // This file defines how ELF sections are represented. 10 // This file defines how ELF sections are represented.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 F.set_position(BaseOff + F.position()); 73 F.set_position(BaseOff + F.position());
74 } 74 }
75 } 75 }
76 76
77 size_t ELFRelocationSection::getSectionDataSize() const { 77 size_t ELFRelocationSection::getSectionDataSize() const {
78 return Fixups.size() * Header.sh_entsize; 78 return Fixups.size() * Header.sh_entsize;
79 } 79 }
80 80
81 // Symbol tables. 81 // Symbol tables.
82 82
83 void ELFSymbolTableSection::createNullSymbol(ELFSection *NullSection) {
84 // The first entry in the symbol table should be a NULL entry,
85 // so make sure the map is still empty.
86 assert(LocalSymbols.empty());
87 const IceString NullSymName("");
88 createDefinedSym(NullSymName, STT_NOTYPE, STB_LOCAL, NullSection, 0, 0);
89 NullSymbol = findSymbol(NullSymName);
90 }
91
83 void ELFSymbolTableSection::createDefinedSym(const IceString &Name, 92 void ELFSymbolTableSection::createDefinedSym(const IceString &Name,
84 uint8_t Type, uint8_t Binding, 93 uint8_t Type, uint8_t Binding,
85 ELFSection *Section, 94 ELFSection *Section,
86 RelocOffsetT Offset, SizeT Size) { 95 RelocOffsetT Offset, SizeT Size) {
87 ELFSym NewSymbol = ELFSym(); 96 ELFSym NewSymbol = ELFSym();
88 NewSymbol.Sym.setBindingAndType(Binding, Type); 97 NewSymbol.Sym.setBindingAndType(Binding, Type);
89 NewSymbol.Sym.st_value = Offset; 98 NewSymbol.Sym.st_value = Offset;
90 NewSymbol.Sym.st_size = Size; 99 NewSymbol.Sym.st_size = Size;
91 NewSymbol.Section = Section; 100 NewSymbol.Section = Section;
92 NewSymbol.Number = ELFSym::UnknownNumber; 101 NewSymbol.Number = ELFSym::UnknownNumber;
93 bool Unique; 102 bool Unique;
94 if (Binding == STB_LOCAL) 103 if (Binding == STB_LOCAL)
95 Unique = LocalSymbols.insert(std::make_pair(Name, NewSymbol)).second; 104 Unique = LocalSymbols.insert(std::make_pair(Name, NewSymbol)).second;
96 else 105 else
97 Unique = GlobalSymbols.insert(std::make_pair(Name, NewSymbol)).second; 106 Unique = GlobalSymbols.insert(std::make_pair(Name, NewSymbol)).second;
98 assert(Unique); 107 assert(Unique);
99 (void)Unique; 108 (void)Unique;
100 } 109 }
101 110
102 void ELFSymbolTableSection::noteUndefinedSym(const IceString &Name, 111 void ELFSymbolTableSection::noteUndefinedSym(const IceString &Name,
103 ELFSection *NullSection) { 112 ELFSection *NullSection) {
104 ELFSym NewSymbol = ELFSym(); 113 ELFSym NewSymbol = ELFSym();
105 NewSymbol.Sym.setBindingAndType(STB_GLOBAL, STT_NOTYPE); 114 NewSymbol.Sym.setBindingAndType(STB_GLOBAL, STT_NOTYPE);
106 NewSymbol.Section = NullSection; 115 NewSymbol.Section = NullSection;
107 NewSymbol.Number = ELFSym::UnknownNumber; 116 NewSymbol.Number = ELFSym::UnknownNumber;
108 GlobalSymbols.insert(std::make_pair(Name, NewSymbol)); 117 bool Unique = GlobalSymbols.insert(std::make_pair(Name, NewSymbol)).second;
118 assert(Unique);
119 (void)Unique;
109 } 120 }
110 121
111 const ELFSym *ELFSymbolTableSection::findSymbol(const IceString &Name) const { 122 const ELFSym *ELFSymbolTableSection::findSymbol(const IceString &Name) const {
112 auto I = LocalSymbols.find(Name); 123 auto I = LocalSymbols.find(Name);
113 if (I != LocalSymbols.end()) 124 if (I != LocalSymbols.end())
114 return &I->second; 125 return &I->second;
115 I = GlobalSymbols.find(Name); 126 I = GlobalSymbols.find(Name);
116 if (I != GlobalSymbols.end()) 127 if (I != GlobalSymbols.end())
117 return &I->second; 128 return &I->second;
118 return nullptr; 129 return nullptr;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 continue; 213 continue;
203 } 214 }
204 StringIndex.second = StringData.size(); 215 StringIndex.second = StringData.size();
205 std::copy(Cur.begin(), Cur.end(), back_inserter(StringData)); 216 std::copy(Cur.begin(), Cur.end(), back_inserter(StringData));
206 StringData.push_back(0); 217 StringData.push_back(0);
207 Prev = Cur; 218 Prev = Cur;
208 } 219 }
209 } 220 }
210 221
211 } // end of namespace Ice 222 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceELFSection.h ('k') | src/IceFixups.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698