[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`.
This commit is contained in:
@@ -320,6 +320,8 @@ bool X86_64::deleteFallThruJmpInsn(InputSection &is, InputFile *file,
|
||||
bool X86_64::relaxOnce(int pass) const {
|
||||
uint64_t minVA = UINT64_MAX, maxVA = 0;
|
||||
for (OutputSection *osec : ctx.outputSections) {
|
||||
if (!(osec->flags & SHF_ALLOC))
|
||||
continue;
|
||||
minVA = std::min(minVA, osec->addr);
|
||||
maxVA = std::max(maxVA, osec->addr + osec->size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user