forked from OSchip/llvm-project
Change return types of split{Non,}Strings.
They return new vectors, but at the same time they mutate other vectors, so returning values doesn't make much sense. We should just mutate two vectors. llvm-svn: 287979
This commit is contained in:
parent
72b1ee2533
commit
e8a077badf
|
|
@ -703,9 +703,8 @@ static size_t findNull(ArrayRef<uint8_t> A, size_t EntSize) {
|
||||||
// Split SHF_STRINGS section. Such section is a sequence of
|
// Split SHF_STRINGS section. Such section is a sequence of
|
||||||
// null-terminated strings.
|
// null-terminated strings.
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
std::vector<SectionPiece>
|
void MergeInputSection<ELFT>::splitStrings(ArrayRef<uint8_t> Data,
|
||||||
MergeInputSection<ELFT>::splitStrings(ArrayRef<uint8_t> Data, size_t EntSize) {
|
size_t EntSize) {
|
||||||
std::vector<SectionPiece> V;
|
|
||||||
size_t Off = 0;
|
size_t Off = 0;
|
||||||
bool IsAlloc = this->Flags & SHF_ALLOC;
|
bool IsAlloc = this->Flags & SHF_ALLOC;
|
||||||
while (!Data.empty()) {
|
while (!Data.empty()) {
|
||||||
|
|
@ -713,12 +712,11 @@ MergeInputSection<ELFT>::splitStrings(ArrayRef<uint8_t> Data, size_t EntSize) {
|
||||||
if (End == StringRef::npos)
|
if (End == StringRef::npos)
|
||||||
fatal(toString(this) + ": string is not null terminated");
|
fatal(toString(this) + ": string is not null terminated");
|
||||||
size_t Size = End + EntSize;
|
size_t Size = End + EntSize;
|
||||||
V.emplace_back(Off, !IsAlloc);
|
Pieces.emplace_back(Off, !IsAlloc);
|
||||||
Hashes.push_back(hash_value(toStringRef(Data.slice(0, Size))));
|
Hashes.push_back(hash_value(toStringRef(Data.slice(0, Size))));
|
||||||
Data = Data.slice(Size);
|
Data = Data.slice(Size);
|
||||||
Off += Size;
|
Off += Size;
|
||||||
}
|
}
|
||||||
return V;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns I'th piece's data.
|
// Returns I'th piece's data.
|
||||||
|
|
@ -734,18 +732,15 @@ CachedHashStringRef MergeInputSection<ELFT>::getData(size_t I) const {
|
||||||
// Split non-SHF_STRINGS section. Such section is a sequence of
|
// Split non-SHF_STRINGS section. Such section is a sequence of
|
||||||
// fixed size records.
|
// fixed size records.
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
std::vector<SectionPiece>
|
void MergeInputSection<ELFT>::splitNonStrings(ArrayRef<uint8_t> Data,
|
||||||
MergeInputSection<ELFT>::splitNonStrings(ArrayRef<uint8_t> Data,
|
|
||||||
size_t EntSize) {
|
size_t EntSize) {
|
||||||
std::vector<SectionPiece> V;
|
|
||||||
size_t Size = Data.size();
|
size_t Size = Data.size();
|
||||||
assert((Size % EntSize) == 0);
|
assert((Size % EntSize) == 0);
|
||||||
bool IsAlloc = this->Flags & SHF_ALLOC;
|
bool IsAlloc = this->Flags & SHF_ALLOC;
|
||||||
for (unsigned I = 0, N = Size; I != N; I += EntSize) {
|
for (unsigned I = 0, N = Size; I != N; I += EntSize) {
|
||||||
Hashes.push_back(hash_value(toStringRef(Data.slice(I, EntSize))));
|
Hashes.push_back(hash_value(toStringRef(Data.slice(I, EntSize))));
|
||||||
V.emplace_back(I, !IsAlloc);
|
Pieces.emplace_back(I, !IsAlloc);
|
||||||
}
|
}
|
||||||
return V;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
|
|
@ -764,9 +759,9 @@ template <class ELFT> void MergeInputSection<ELFT>::splitIntoPieces() {
|
||||||
ArrayRef<uint8_t> Data = this->Data;
|
ArrayRef<uint8_t> Data = this->Data;
|
||||||
uintX_t EntSize = this->Entsize;
|
uintX_t EntSize = this->Entsize;
|
||||||
if (this->Flags & SHF_STRINGS)
|
if (this->Flags & SHF_STRINGS)
|
||||||
this->Pieces = splitStrings(Data, EntSize);
|
splitStrings(Data, EntSize);
|
||||||
else
|
else
|
||||||
this->Pieces = splitNonStrings(Data, EntSize);
|
splitNonStrings(Data, EntSize);
|
||||||
|
|
||||||
if (Config->GcSections && (this->Flags & SHF_ALLOC))
|
if (Config->GcSections && (this->Flags & SHF_ALLOC))
|
||||||
for (uintX_t Off : LiveOffsets)
|
for (uintX_t Off : LiveOffsets)
|
||||||
|
|
|
||||||
|
|
@ -201,8 +201,8 @@ public:
|
||||||
const SectionPiece *getSectionPiece(uintX_t Offset) const;
|
const SectionPiece *getSectionPiece(uintX_t Offset) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SectionPiece> splitStrings(ArrayRef<uint8_t> A, size_t Size);
|
void splitStrings(ArrayRef<uint8_t> A, size_t Size);
|
||||||
std::vector<SectionPiece> splitNonStrings(ArrayRef<uint8_t> A, size_t Size);
|
void splitNonStrings(ArrayRef<uint8_t> A, size_t Size);
|
||||||
|
|
||||||
std::vector<uint32_t> Hashes;
|
std::vector<uint32_t> Hashes;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue