[PATCH] D98560: [RuntimeDyld] Fix range checks for R_X86_64_{8,16}
Rafael Auler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 12 14:57:25 PST 2021
rafauler created this revision.
rafauler added reviewers: MaskRay, lhames.
Herald added a subscriber: hiraditya.
rafauler requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
D97899 <https://reviews.llvm.org/D97899> added support for these relocations, but MaskRay noticed
the range check was incomplete. Fix it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98560
Files:
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Index: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
===================================================================
--- llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -268,7 +268,8 @@
break;
case ELF::R_X86_64_8: {
Value += Addend;
- assert((int64_t)Value <= INT8_MAX && (int64_t)Value >= INT8_MIN);
+ assert(((int64_t)Value <= INT8_MAX && (int64_t)Value >= INT8_MIN) ||
+ (Value <= UINT8_MAX));
uint8_t TruncatedAddr = (Value & 0xFF);
*Section.getAddressWithOffset(Offset) = TruncatedAddr;
LLVM_DEBUG(dbgs() << "Writing " << format("%p", TruncatedAddr) << " at "
@@ -277,7 +278,8 @@
}
case ELF::R_X86_64_16: {
Value += Addend;
- assert((int64_t)Value <= INT16_MAX && (int64_t)Value >= INT16_MIN);
+ assert(((int64_t)Value <= INT16_MAX && (int64_t)Value >= INT16_MIN) ||
+ (Value <= UINT16_MAX));
uint16_t TruncatedAddr = (Value & 0xFFFF);
support::ulittle16_t::ref(Section.getAddressWithOffset(Offset)) =
TruncatedAddr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98560.330379.patch
Type: text/x-patch
Size: 1098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210312/5b7f7f66/attachment.bin>
More information about the llvm-commits
mailing list