[lld] r240661 - COFF: Don't use COFFHeader->NumberOfRelocations.
Rui Ueyama
ruiu at google.com
Thu Jun 25 10:43:37 PDT 2015
Author: ruiu
Date: Thu Jun 25 12:43:37 2015
New Revision: 240661
URL: http://llvm.org/viewvc/llvm-project?rev=240661&view=rev
Log:
COFF: Don't use COFFHeader->NumberOfRelocations.
The size of the field is 16 bit, so it's inaccurate if the
number of relocations in a section is more than 65535.
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/COFF/Chunks.h
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=240661&r1=240660&r2=240661&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Thu Jun 25 12:43:37 2015
@@ -29,7 +29,8 @@ namespace coff {
SectionChunk::SectionChunk(ObjectFile *F, const coff_section *H)
: File(F), Ptr(this), Header(H),
- Relocs(File->getCOFFObj()->getRelocations(Header)) {
+ Relocs(File->getCOFFObj()->getRelocations(Header)),
+ NumRelocs(std::distance(Relocs.begin(), Relocs.end())) {
// Initialize SectionName.
File->getCOFFObj()->getSectionName(Header, SectionName);
@@ -156,9 +157,11 @@ StringRef SectionChunk::getDebugName() {
uint64_t SectionChunk::getHash() const {
ArrayRef<uint8_t> A;
File->getCOFFObj()->getSectionContents(Header, A);
- return hash_combine(getPermissions(), llvm::hash_value(SectionName),
+ return hash_combine(getPermissions(),
+ llvm::hash_value(SectionName),
+ NumRelocs,
uint32_t(Header->SizeOfRawData),
- uint32_t(Header->NumberOfRelocations),
+ std::distance(Relocs.end(), Relocs.begin()),
hash_combine_range(A.data(), A.data() + A.size()));
}
@@ -171,7 +174,7 @@ bool SectionChunk::equals(const SectionC
return false;
if (Header->SizeOfRawData != X->Header->SizeOfRawData)
return false;
- if (Header->NumberOfRelocations != X->Header->NumberOfRelocations)
+ if (NumRelocs != X->NumRelocs)
return false;
// Compare data
Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=240661&r1=240660&r2=240661&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Thu Jun 25 12:43:37 2015
@@ -164,6 +164,7 @@ private:
StringRef SectionName;
std::vector<Chunk *> AssocChildren;
llvm::iterator_range<const coff_relocation *> Relocs;
+ size_t NumRelocs;
// Chunks are basically unnamed chunks of bytes.
// Symbols are associated for debugging and logging purposs only.
More information about the llvm-commits
mailing list