[lld] [X86, lld] Handle relocation R_X86_64_REX2_GOTPCRELX (PR #109783)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 22:43:18 PDT 2024


================
@@ -897,6 +901,7 @@ RelExpr X86_64::adjustGotPcExpr(RelType type, int64_t addend,
 static void relaxGotNoPic(uint8_t *loc, uint64_t val, uint8_t op,
                           uint8_t modRm) {
   const uint8_t rex = loc[-3];
----------------
MaskRay wrote:

The code assumes correctly used relocations to avoid some bounds checking. 
We don't bother with erroneous relocation testing - for valid `R_X86_64_REX_GOTPCRELX`, `loc[-3]` should always be accessible.

However, if type is `R_X86_64_REX_GOTPCRELX`, `loc[-4]` could go out-of-bounds.

https://github.com/llvm/llvm-project/pull/109783


More information about the llvm-commits mailing list