[lld] r313703 - [COFF] Adjust secrel limit check
Shoaib Meenai via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 19 17:21:58 PDT 2017
Author: smeenai
Date: Tue Sep 19 17:21:58 2017
New Revision: 313703
URL: http://llvm.org/viewvc/llvm-project?rev=313703&view=rev
Log:
[COFF] Adjust secrel limit check
According to Microsoft's PE/COFF documentation, a SECREL relocation is
"The 32-bit offset of the target from the beginning of its section". By
my reading, the "from the beginning of its section" implies that the
offset is unsigned.
Change from an assertion to an error, since it's possible to trigger
this condition normally for input files with very large sections, and we
should fail gracefully for those instead of asserting.
Differential Revision: https://reviews.llvm.org/D38020
Modified:
lld/trunk/COFF/Chunks.cpp
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=313703&r1=313702&r2=313703&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Tue Sep 19 17:21:58 2017
@@ -62,7 +62,10 @@ static void applySecRel(const SectionChu
fatal("SECREL relocation cannot be applied to absolute symbols");
}
uint64_t SecRel = S - OS->getRVA();
- assert(SecRel < INT32_MAX && "overflow in SECREL relocation");
+ if (SecRel > UINT32_MAX) {
+ error("overflow in SECREL relocation in section: " + Sec->getSectionName());
+ return;
+ }
add32(Off, SecRel);
}
More information about the llvm-commits
mailing list