COFF: Make Chunk::writeTo() const. NFC.
This should improve code readability especially because this function
is called inside parallel_for_each.
llvm-svn: 248103
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index 7168a03..ebf35fa 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -49,7 +49,7 @@
static void or16(uint8_t *P, uint16_t V) { write16le(P, read16le(P) | V); }
void SectionChunk::applyRelX64(uint8_t *Off, uint16_t Type, Defined *Sym,
- uint64_t P) {
+ uint64_t P) const {
uint64_t S = Sym->getRVA();
switch (Type) {
case IMAGE_REL_AMD64_ADDR32: add32(Off, S + Config->ImageBase); break;
@@ -69,7 +69,7 @@
}
void SectionChunk::applyRelX86(uint8_t *Off, uint16_t Type, Defined *Sym,
- uint64_t P) {
+ uint64_t P) const {
uint64_t S = Sym->getRVA();
switch (Type) {
case IMAGE_REL_I386_ABSOLUTE: break;
@@ -110,7 +110,7 @@
}
void SectionChunk::applyRelARM(uint8_t *Off, uint16_t Type, Defined *Sym,
- uint64_t P) {
+ uint64_t P) const {
uint64_t S = Sym->getRVA();
// Pointer to thumb code must have the LSB set.
if (Sym->isExecutable())
@@ -127,7 +127,7 @@
}
}
-void SectionChunk::writeTo(uint8_t *Buf) {
+void SectionChunk::writeTo(uint8_t *Buf) const {
if (!hasData())
return;
// Copy section contents from source object file to output file.
@@ -244,7 +244,7 @@
IMAGE_SCN_MEM_WRITE;
}
-void StringChunk::writeTo(uint8_t *Buf) {
+void StringChunk::writeTo(uint8_t *Buf) const {
memcpy(Buf + OutputSectionOff, Str.data(), Str.size());
}
@@ -254,7 +254,7 @@
Align = 16;
}
-void ImportThunkChunkX64::writeTo(uint8_t *Buf) {
+void ImportThunkChunkX64::writeTo(uint8_t *Buf) const {
memcpy(Buf + OutputSectionOff, ImportThunkX86, sizeof(ImportThunkX86));
// The first two bytes is a JMP instruction. Fill its operand.
write32le(Buf + OutputSectionOff + 2, ImpSymbol->getRVA() - RVA - getSize());
@@ -264,7 +264,7 @@
Res->emplace_back(getRVA() + 2);
}
-void ImportThunkChunkX86::writeTo(uint8_t *Buf) {
+void ImportThunkChunkX86::writeTo(uint8_t *Buf) const {
memcpy(Buf + OutputSectionOff, ImportThunkX86, sizeof(ImportThunkX86));
// The first two bytes is a JMP instruction. Fill its operand.
write32le(Buf + OutputSectionOff + 2,
@@ -275,7 +275,7 @@
Res->emplace_back(getRVA(), IMAGE_REL_BASED_ARM_MOV32T);
}
-void ImportThunkChunkARM::writeTo(uint8_t *Buf) {
+void ImportThunkChunkARM::writeTo(uint8_t *Buf) const {
memcpy(Buf + OutputSectionOff, ImportThunkARM, sizeof(ImportThunkARM));
// Fix mov.w and mov.t operands.
applyMOV32T(Buf + OutputSectionOff, ImpSymbol->getRVA() + Config->ImageBase);
@@ -289,7 +289,7 @@
return Config->is64() ? 8 : 4;
}
-void LocalImportChunk::writeTo(uint8_t *Buf) {
+void LocalImportChunk::writeTo(uint8_t *Buf) const {
if (Config->is64()) {
write64le(Buf + OutputSectionOff, Sym->getRVA() + Config->ImageBase);
} else {
@@ -297,7 +297,7 @@
}
}
-void SEHTableChunk::writeTo(uint8_t *Buf) {
+void SEHTableChunk::writeTo(uint8_t *Buf) const {
ulittle32_t *Begin = reinterpret_cast<ulittle32_t *>(Buf + OutputSectionOff);
size_t Cnt = 0;
for (Defined *D : Syms)
@@ -321,7 +321,7 @@
}
}
-void BaserelChunk::writeTo(uint8_t *Buf) {
+void BaserelChunk::writeTo(uint8_t *Buf) const {
memcpy(Buf + OutputSectionOff, Data.data(), Data.size());
}