Skip to content

Commit 6323541

Browse files
authored
[LLD][ELF] Skip non-SHF_ALLOC sections when checking max VA and max VA difference in relaxOnce() (#145863)
For non-SHF_ALLOC sections, sh_addr is set to 0. Skip sections without SHF_ALLOC flag, so `minVA` will not be set to 0 with non-SHF_ALLOC sections, and the size of non-SHF_ALLOC sections will not contribute to `maxVA`.
1 parent 6620db5 commit 6323541

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lld/ELF/Arch/X86_64.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ bool X86_64::deleteFallThruJmpInsn(InputSection &is, InputFile *file,
320320
bool X86_64::relaxOnce(int pass) const {
321321
uint64_t minVA = UINT64_MAX, maxVA = 0;
322322
for (OutputSection *osec : ctx.outputSections) {
323+
if (!(osec->flags & SHF_ALLOC))
324+
continue;
323325
minVA = std::min(minVA, osec->addr);
324326
maxVA = std::max(maxVA, osec->addr + osec->size);
325327
}

0 commit comments

Comments
 (0)