[PATCH] D152777: [XCOFF] FixupOffsetInCsect should be 0 for R_REF relocation.
Esme Yi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 14 22:34:17 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG028a261350ba: [XCOFF] FixupOffsetInCsect should be 0 for R_REF relocation. (authored by Esme).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152777/new/
https://reviews.llvm.org/D152777
Files:
llvm/lib/MC/XCOFFObjectWriter.cpp
llvm/test/CodeGen/PowerPC/pgo-ref-directive.ll
Index: llvm/test/CodeGen/PowerPC/pgo-ref-directive.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/pgo-ref-directive.ll
+++ llvm/test/CodeGen/PowerPC/pgo-ref-directive.ll
@@ -73,8 +73,8 @@
; NOVNDS-NEXT: .ref __llvm_prf_names[RO]
; NOVNDS-NOT: .ref __llvm_prf_vnds
-; NOVNDS-OBJ: 00000008 R_REF __llvm_prf_data
-; NOVNDS-OBJ: 00000008 R_REF __llvm_prf_names
+; NOVNDS-OBJ: 00000000 R_REF __llvm_prf_data
+; NOVNDS-OBJ: 00000000 R_REF __llvm_prf_names
; NOVNDS-OBJ-NOT: R_REF __llvm_prf_vnds
;--- with-vnds.ll
@@ -115,8 +115,8 @@
; WITHVNDS-OBJ: RELOCATION RECORDS FOR [.data]:
; WITHVNDS-OBJ-NEXT: OFFSET TYPE VALUE
-; WITHVNDS-OBJ-NEXT: 00000008 R_REF __llvm_prf_data
-; WITHVNDS-OBJ-NEXT: 00000008 R_REF __llvm_prf_names
-; WITHVNDS-OBJ-NEXT: 00000008 R_REF __llvm_prf_vnds
+; WITHVNDS-OBJ-NEXT: 00000000 R_REF __llvm_prf_data
+; WITHVNDS-OBJ-NEXT: 00000000 R_REF __llvm_prf_names
+; WITHVNDS-OBJ-NEXT: 00000000 R_REF __llvm_prf_vnds
; WITHVNDS-OBJ-NEXT: 00000100 R_POS .main
; WITHVNDS-OBJ-NEXT: 00000104 R_POS TOC
Index: llvm/lib/MC/XCOFFObjectWriter.cpp
===================================================================
--- llvm/lib/MC/XCOFFObjectWriter.cpp
+++ llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -618,6 +618,12 @@
assert(SectionMap.contains(SymASec) &&
"Expected containing csect to exist in map.");
+ assert((Fixup.getOffset() <=
+ MaxRawDataSize - Layout.getFragmentOffset(Fragment)) &&
+ "Fragment offset + fixup offset is overflowed.");
+ uint32_t FixupOffsetInCsect =
+ Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
+
const uint32_t Index = getIndex(SymA, SymASec);
if (Type == XCOFF::RelocationType::R_POS ||
Type == XCOFF::RelocationType::R_TLS)
@@ -656,23 +662,18 @@
// The address of the branch instruction should be the sum of section
// address, fragment offset and Fixup offset.
- uint64_t BRInstrAddress = SectionMap[ParentSec]->Address +
- Layout.getFragmentOffset(Fragment) +
- Fixup.getOffset();
+ uint64_t BRInstrAddress =
+ SectionMap[ParentSec]->Address + FixupOffsetInCsect;
// The FixedValue should be the difference between SymA csect address and BR
// instr address plus any constant value.
FixedValue =
SectionMap[SymASec]->Address - BRInstrAddress + Target.getConstant();
- } else if (Type == XCOFF::RelocationType::R_REF)
- // The FixedValue should always be 0 since it specifies a nonrelocating
- // reference.
+ } else if (Type == XCOFF::RelocationType::R_REF) {
+ // The FixedValue and FixupOffsetInCsect should always be 0 since it
+ // specifies a nonrelocating reference.
FixedValue = 0;
-
- assert((Fixup.getOffset() <=
- MaxRawDataSize - Layout.getFragmentOffset(Fragment)) &&
- "Fragment offset + fixup offset is overflowed.");
- uint32_t FixupOffsetInCsect =
- Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
+ FixupOffsetInCsect = 0;
+ }
XCOFFRelocation Reloc = {Index, FixupOffsetInCsect, SignAndSize, Type};
MCSectionXCOFF *RelocationSec = cast<MCSectionXCOFF>(Fragment->getParent());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152777.531614.patch
Type: text/x-patch
Size: 3418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230615/e5d48b45/attachment.bin>
More information about the llvm-commits
mailing list