[DynInst_API:] [dyninst/dyninst] e4fe78: AMDGPU: fix SOPP short-branch relocation off-by-on...


Date: Fri, 10 Jul 2026 08:07:05 -0700
From: bbiiggppiigg <noreply@xxxxxxxxxx>
Subject: [DynInst_API:] [dyninst/dyninst] e4fe78: AMDGPU: fix SOPP short-branch relocation off-by-on...
  Branch: refs/heads/master
  Home:   https://github.com/dyninst/dyninst
  Commit: e4fe78607b9d0ef541216dc82df80a07f054885c
      https://github.com/dyninst/dyninst/commit/e4fe78607b9d0ef541216dc82df80a07f054885c
  Author: bbiiggppiigg <bbiiggppiigg@xxxxxxxxx>
  Date:   2026-07-10 (Fri, 10 Jul 2026)

  Changed paths:
    M dyninstAPI/src/codegen/codegen-amdgpu.C

  Log Message:
  -----------
  AMDGPU: fix SOPP short-branch relocation off-by-one (S_BRANCH PC+4) (#2316)

gfx908 S_BRANCH / s_cbranch_* (SOPP) compute their destination relative to the
instruction AFTER the branch: target = (PC_of_branch + 4) + SIMM16*4. The
short-branch emitters in codegen-amdgpu.C encoded SIMM16 = disp/4, omitting the
-1 that accounts for that +4, so every displacement-computed short branch landed
one instruction (4 bytes) past its intended target.

Fix the three displacement-based emitters to compute SIMM16 = disp/4 - 1:
  - insnCodeGen::generateBranch (short-jump path)
  - insnCodeGen::modifyJump
  - insnCodeGen::modifyJcc (the jump-to-target of the conditional-branch expansion)

The -1 is direction-agnostic (it is +4 expressed in dword units) and holds for
both forward and backward jumps. emitLongJump already accounts for this
(fromAddress + 4); the literal emitShortJump(1) skip-jumps in modifyJcc are
intentionally SIMM16=1 and are unchanged.

This affects short branches only, which are emitted when relocating a function
that has internal control flow (loops, if/else); straight-line functions relocate
using only long jumps, so the bug was previously latent.

Co-authored-by: Claude Opus 4.8 <noreply@xxxxxxxxxxxxx>



To unsubscribe from these emails, change your notification settings at https://github.com/dyninst/dyninst/settings/notifications
[← Prev in Thread] Current Thread [Next in Thread→]
  • [DynInst_API:] [dyninst/dyninst] e4fe78: AMDGPU: fix SOPP short-branch relocation off-by-on..., bbiiggppiigg <=