[ELF] Fix early overflow check in finalizeAddressDependentContent
authorAndreu Carminati <andreu.carminati@hightec-rt.com>
Wed, 14 Jun 2023 22:26:31 +0000 (15:26 -0700)
committerFangrui Song <i@maskray.me>
Wed, 14 Jun 2023 22:26:31 +0000 (15:26 -0700)
commite4118a7ac0fc2347e78d7c87a1663b70e8ab71ed
tree9448d2792ee5ae4699972469060a33cd5ae4c217
parent58789ed62ad462d421e5c9272f0f80105f6025bf
[ELF] Fix early overflow check in finalizeAddressDependentContent

LLD terminates with errors when it detects overflows in the
finalizeAddressDependentContent calculation. Although, sometimes, those errors
are not really errors, but an intermediate result of an ongoing address
calculation.  If we continue the fixed-point algorithm we can converge to the
correct result.

This patch

* Removes the verification inside the fixed point algorithm.
* Calls checkMemoryRegions at the end.

Reviewed By: peter.smith, MaskRay

Differential Revision: https://reviews.llvm.org/D152170
lld/ELF/LinkerScript.cpp
lld/ELF/LinkerScript.h
lld/ELF/Writer.cpp
lld/test/ELF/linkerscript/end-overflow-check.test [new file with mode: 0644]
lld/test/ELF/linkerscript/memory-err.s