[lld] r303973 - [ELF] - Simplify implementation of constant pool when building .gdb_index
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri May 26 05:01:40 PDT 2017
Author: grimar
Date: Fri May 26 07:01:40 2017
New Revision: 303973
URL: http://llvm.org/viewvc/llvm-project?rev=303973&view=rev
Log:
[ELF] - Simplify implementation of constant pool when building .gdb_index
https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html says:
"A CU vector in the constant pool is a sequence of offset_type values.
The first value is the number of CU indices in the vector.
Each subsequent value is the index and symbol attributes of a CU in the CU list."
Previously we keeped 2 values until the end, what was useless.
Initially was a part of D32647, though it is possible to split out.
Patch do that.
Differential revision: https://reviews.llvm.org/D33551
Modified:
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=303973&r1=303972&r2=303973&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Fri May 26 07:01:40 2017
@@ -1778,11 +1778,11 @@ void GdbIndexSection::readDwarf(InputSec
std::tie(IsNew, Sym) = SymbolTable.add(Hash, Offset);
if (IsNew) {
Sym->CuVectorIndex = CuVectors.size();
- CuVectors.push_back({{CuId, Pair.second}});
- continue;
+ CuVectors.push_back({});
}
- CuVectors[Sym->CuVectorIndex].push_back({CuId, Pair.second});
+ CuVectors[Sym->CuVectorIndex].push_back((Pair.second << 24) |
+ (uint32_t)CuId);
}
}
@@ -1806,7 +1806,7 @@ void GdbIndexSection::finalizeContents()
ConstantPoolOffset =
SymTabOffset + SymbolTable.getCapacity() * SymTabEntrySize;
- for (std::vector<std::pair<uint32_t, uint8_t>> &CuVec : CuVectors) {
+ for (std::vector<uint32_t> &CuVec : CuVectors) {
CuVectorsOffset.push_back(CuVectorsSize);
CuVectorsSize += OffsetTypeSize * (CuVec.size() + 1);
}
@@ -1859,14 +1859,11 @@ void GdbIndexSection::writeTo(uint8_t *B
}
// Write the CU vectors into the constant pool.
- for (std::vector<std::pair<uint32_t, uint8_t>> &CuVec : CuVectors) {
+ for (std::vector<uint32_t> &CuVec : CuVectors) {
write32le(Buf, CuVec.size());
Buf += 4;
- for (std::pair<uint32_t, uint8_t> &P : CuVec) {
- uint32_t Index = P.first;
- uint8_t Flags = P.second;
- Index |= Flags << 24;
- write32le(Buf, Index);
+ for (uint32_t Val : CuVec) {
+ write32le(Buf, Val);
Buf += 4;
}
}
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=303973&r1=303972&r2=303973&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Fri May 26 07:01:40 2017
@@ -515,7 +515,7 @@ public:
GdbHashTab SymbolTable;
// The CU vector portion of the constant pool.
- std::vector<std::vector<std::pair<uint32_t, uint8_t>>> CuVectors;
+ std::vector<std::vector<uint32_t>> CuVectors;
std::vector<AddressEntry> AddressArea;
More information about the llvm-commits
mailing list