[lld] r240666 - COFF: Simplify. NFC.
Rui Ueyama
ruiu at google.com
Thu Jun 25 10:56:36 PDT 2015
Author: ruiu
Date: Thu Jun 25 12:56:36 2015
New Revision: 240666
URL: http://llvm.org/viewvc/llvm-project?rev=240666&view=rev
Log:
COFF: Simplify. NFC.
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=240666&r1=240665&r2=240666&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Thu Jun 25 12:56:36 2015
@@ -59,9 +59,8 @@ void SectionChunk::writeTo(uint8_t *Buf)
if (!hasData())
return;
// Copy section contents from source object file to output file.
- ArrayRef<uint8_t> Data;
- File->getCOFFObj()->getSectionContents(Header, Data);
- memcpy(Buf + FileOff, Data.data(), Data.size());
+ ArrayRef<uint8_t> A = getContents();
+ memcpy(Buf + FileOff, A.data(), A.size());
// Apply relocations.
for (const coff_relocation &Rel : Relocs) {
@@ -155,8 +154,7 @@ StringRef SectionChunk::getDebugName() {
}
uint64_t SectionChunk::getHash() const {
- ArrayRef<uint8_t> A;
- File->getCOFFObj()->getSectionContents(Header, A);
+ ArrayRef<uint8_t> A = getContents();
return hash_combine(getPermissions(),
llvm::hash_value(SectionName),
NumRelocs,
@@ -178,11 +176,7 @@ bool SectionChunk::equals(const SectionC
return false;
// Compare data
- ArrayRef<uint8_t> A, B;
- File->getCOFFObj()->getSectionContents(Header, A);
- X->File->getCOFFObj()->getSectionContents(X->Header, B);
- assert(A.size() == B.size());
- if (memcmp(A.data(), B.data(), A.size()))
+ if (getContents() != X->getContents())
return false;
// Compare relocations
@@ -202,6 +196,12 @@ bool SectionChunk::equals(const SectionC
return std::equal(Relocs.begin(), Relocs.end(), X->Relocs.begin(), Eq);
}
+ArrayRef<uint8_t> SectionChunk::getContents() const {
+ ArrayRef<uint8_t> A;
+ File->getCOFFObj()->getSectionContents(Header, A);
+ return A;
+}
+
// Returns a pointer to this chunk or its replacement.
SectionChunk *SectionChunk::repl() {
while (Ptr != Ptr->Ptr)
Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=240666&r1=240665&r2=240666&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Thu Jun 25 12:56:36 2015
@@ -150,6 +150,7 @@ public:
private:
void mark() override;
+ ArrayRef<uint8_t> getContents() const;
// A file this chunk was created from.
ObjectFile *File;
More information about the llvm-commits
mailing list