| OLD | NEW |
| 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 /// \file | 10 /// \file |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 size_t ELFRelocationSection::getSectionDataSize() const { | 78 size_t ELFRelocationSection::getSectionDataSize() const { |
| 79 return Fixups.size() * Header.sh_entsize; | 79 return Fixups.size() * Header.sh_entsize; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Symbol tables. | 82 // Symbol tables. |
| 83 | 83 |
| 84 void ELFSymbolTableSection::createNullSymbol(ELFSection *NullSection) { | 84 void ELFSymbolTableSection::createNullSymbol(ELFSection *NullSection) { |
| 85 // The first entry in the symbol table should be a NULL entry, | 85 // The first entry in the symbol table should be a NULL entry, so make sure |
| 86 // so make sure the map is still empty. | 86 // the map is still empty. |
| 87 assert(LocalSymbols.empty()); | 87 assert(LocalSymbols.empty()); |
| 88 const IceString NullSymName(""); | 88 const IceString NullSymName(""); |
| 89 createDefinedSym(NullSymName, STT_NOTYPE, STB_LOCAL, NullSection, 0, 0); | 89 createDefinedSym(NullSymName, STT_NOTYPE, STB_LOCAL, NullSection, 0, 0); |
| 90 NullSymbol = findSymbol(NullSymName); | 90 NullSymbol = findSymbol(NullSymName); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void ELFSymbolTableSection::createDefinedSym(const IceString &Name, | 93 void ELFSymbolTableSection::createDefinedSym(const IceString &Name, |
| 94 uint8_t Type, uint8_t Binding, | 94 uint8_t Type, uint8_t Binding, |
| 95 ELFSection *Section, | 95 ELFSection *Section, |
| 96 RelocOffsetT Offset, SizeT Size) { | 96 RelocOffsetT Offset, SizeT Size) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 assert(!isLaidOut()); | 201 assert(!isLaidOut()); |
| 202 llvm::StringRef Prev; | 202 llvm::StringRef Prev; |
| 203 | 203 |
| 204 // String table starts with 0 byte. | 204 // String table starts with 0 byte. |
| 205 StringData.push_back(0); | 205 StringData.push_back(0); |
| 206 | 206 |
| 207 for (auto &StringIndex : StringToIndexMap) { | 207 for (auto &StringIndex : StringToIndexMap) { |
| 208 assert(StringIndex.second == UnknownIndex); | 208 assert(StringIndex.second == UnknownIndex); |
| 209 llvm::StringRef Cur = llvm::StringRef(StringIndex.first); | 209 llvm::StringRef Cur = llvm::StringRef(StringIndex.first); |
| 210 if (Prev.endswith(Cur)) { | 210 if (Prev.endswith(Cur)) { |
| 211 // Prev is already in the StringData, and Cur is shorter than Prev | 211 // Prev is already in the StringData, and Cur is shorter than Prev based |
| 212 // based on the sort. | 212 // on the sort. |
| 213 StringIndex.second = StringData.size() - Cur.size() - 1; | 213 StringIndex.second = StringData.size() - Cur.size() - 1; |
| 214 continue; | 214 continue; |
| 215 } | 215 } |
| 216 StringIndex.second = StringData.size(); | 216 StringIndex.second = StringData.size(); |
| 217 std::copy(Cur.begin(), Cur.end(), back_inserter(StringData)); | 217 std::copy(Cur.begin(), Cur.end(), back_inserter(StringData)); |
| 218 StringData.push_back(0); | 218 StringData.push_back(0); |
| 219 Prev = Cur; | 219 Prev = Cur; |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // end of namespace Ice | 223 } // end of namespace Ice |
| OLD | NEW |