[PATCH] D138982: [XCOFF] adjust the Fixedvalue for R_RBR relocations.

Esme Yi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 18:39:33 PST 2022


Esme added inline comments.


================
Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:653
+        SectionMap[SymASec]->Address - BRInstrAddress + Target.getConstant();
   }
 
----------------
shchenz wrote:
> For the other `else`(relocation types), maybe we should add an assertion here to avoid any other unhandled relocation type that may introduce in `PPCXCOFFObjectWriter::getRelocTypeAndSignSize()` in future. The assertion will help us address the root cause early like the one for `XCOFF::RelocationType::R_RBR`.
Good point!


================
Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:646-647
+                              Fixup.getOffset();
+    // The FixedValue should be the difference between SymA csect address and BR
+    // instr address plus any constant value.
+    FixedValue =
----------------
stephenpeckham wrote:
> // The FixedValue is the difference between the SymA address and BRInstrAddress plus any constant value. 
> 
> The documentation for R_RBR is easy to misunderstand. The documentation doesn't describe what should be computed for the FixedValue.  It describes how the FixedValue should be adjusted at link time. This adjustment is based both on the change to the address of SymA (pre-link vs. post-link) and the change to the address of the branch instruction (or its csect--they're equivalent)
@stephenpeckham Thank you for your explanation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138982/new/

https://reviews.llvm.org/D138982



More information about the llvm-commits mailing list