[COFF] Use range for on relocations, NFC

This commit is contained in:
Reid Kleckner 2021-01-20 11:00:58 -08:00
parent 16d6e85271
commit 69e0bc77a5

View File

@ -357,9 +357,7 @@ void SectionChunk::writeTo(uint8_t *buf) const {
// Apply relocations. // Apply relocations.
size_t inputSize = getSize(); size_t inputSize = getSize();
for (size_t i = 0, e = relocsSize; i < e; i++) { for (const coff_relocation &rel : getRelocs()) {
const coff_relocation &rel = relocsData[i];
// Check for an invalid relocation offset. This check isn't perfect, because // Check for an invalid relocation offset. This check isn't perfect, because
// we don't have the relocation size, which is only known after checking the // we don't have the relocation size, which is only known after checking the
// machine and relocation type. As a result, a relocation may overwrite the // machine and relocation type. As a result, a relocation may overwrite the
@ -451,8 +449,7 @@ static uint8_t getBaserelType(const coff_relocation &rel) {
// fixed by the loader if load-time relocation is needed. // fixed by the loader if load-time relocation is needed.
// Only called when base relocation is enabled. // Only called when base relocation is enabled.
void SectionChunk::getBaserels(std::vector<Baserel> *res) { void SectionChunk::getBaserels(std::vector<Baserel> *res) {
for (size_t i = 0, e = relocsSize; i < e; i++) { for (const coff_relocation &rel : getRelocs()) {
const coff_relocation &rel = relocsData[i];
uint8_t ty = getBaserelType(rel); uint8_t ty = getBaserelType(rel);
if (ty == IMAGE_REL_BASED_ABSOLUTE) if (ty == IMAGE_REL_BASED_ABSOLUTE)
continue; continue;