From 40c2f62b277f6752354d58028d3beca712835300 Mon Sep 17 00:00:00 2001 From: Irwin D'Souza Date: Fri, 28 Jul 2023 16:54:12 -0400 Subject: [PATCH] Fix Crashes in 32-bit PPC due to incorrect relocation initialization The initialization of the `TR::ExternalOrderedPair32BitRelocation` object used for `TR_MethodEnterExitHookAddress` had a couple of issues: 1. It was missing the secondInstruction 2. It assumed that the constructor of `TR::ExternalOrderedPair32BitRelocation` took in two target addrs this commit fixes both issues by adding the second instruction, as well as adding a new constructor to take in two target addresses. Signed-off-by: Irwin D'Souza --- compiler/codegen/Relocation.cpp | 14 ++++++++++++++ compiler/codegen/Relocation.hpp | 18 +++++++++++++----- compiler/p/codegen/OMRCodeGenerator.cpp | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/compiler/codegen/Relocation.cpp b/compiler/codegen/Relocation.cpp index e648c7aefc7..65c624468f0 100644 --- a/compiler/codegen/Relocation.cpp +++ b/compiler/codegen/Relocation.cpp @@ -294,6 +294,20 @@ TR::ExternalOrderedPair32BitRelocation::ExternalOrderedPair32BitRelocation( setTargetKind(k); } +TR::ExternalOrderedPair32BitRelocation::ExternalOrderedPair32BitRelocation( + uint8_t *location1, + uint8_t *location2, + uint8_t *target, + uint8_t *target2, + TR_ExternalRelocationTargetKind k, + TR::CodeGenerator *cg) : + TR::ExternalRelocation(), _update2Location(location2) + { + setUpdateLocation(location1); + setTargetAddress(target); + setTargetAddress2(target2); + setTargetKind(k); + } uint8_t TR::ExternalOrderedPair32BitRelocation::collectModifier() { diff --git a/compiler/codegen/Relocation.hpp b/compiler/codegen/Relocation.hpp index 7aa17433f2e..8cbb7dd20f6 100644 --- a/compiler/codegen/Relocation.hpp +++ b/compiler/codegen/Relocation.hpp @@ -400,13 +400,14 @@ class ExternalRelocation : public TR::Relocation _relocationRecord(NULL) {} - uint8_t *getTargetAddress() {return _targetAddress;} - uint8_t *setTargetAddress(uint8_t *p) {return (_targetAddress = p);} + uint8_t *getTargetAddress() { return _targetAddress; } + uint8_t *setTargetAddress(uint8_t *p) { return (_targetAddress = p); } - uint8_t *getTargetAddress2() {return _targetAddress2;} + uint8_t *getTargetAddress2() { return _targetAddress2; } + uint8_t *setTargetAddress2(uint8_t *p) { return (_targetAddress2 = p); } - TR_ExternalRelocationTargetKind getTargetKind() {return _kind;} - TR_ExternalRelocationTargetKind setTargetKind(TR_ExternalRelocationTargetKind k) {return (_kind = k);} + TR_ExternalRelocationTargetKind getTargetKind() { return _kind; } + TR_ExternalRelocationTargetKind setTargetKind(TR_ExternalRelocationTargetKind k) { return (_kind = k); } TR::IteratedExternalRelocation *getRelocationRecord() {return _relocationRecord;} @@ -459,6 +460,13 @@ class ExternalOrderedPair32BitRelocation: public TR::ExternalRelocation TR_ExternalRelocationTargetKind k, TR::CodeGenerator *cg); + ExternalOrderedPair32BitRelocation(uint8_t *location1, + uint8_t *location2, + uint8_t *target, + uint8_t *target2, + TR_ExternalRelocationTargetKind k, + TR::CodeGenerator *cg); + uint8_t *getLocation2() {return _update2Location;} void setLocation2(uint8_t *l) {_update2Location = l;} diff --git a/compiler/p/codegen/OMRCodeGenerator.cpp b/compiler/p/codegen/OMRCodeGenerator.cpp index a8df425536a..e73b0eaf616 100644 --- a/compiler/p/codegen/OMRCodeGenerator.cpp +++ b/compiler/p/codegen/OMRCodeGenerator.cpp @@ -2166,6 +2166,7 @@ OMR::Power::CodeGenerator::addMetaDataForLoadIntConstantFixed( else if (typeAddress == TR_MethodEnterExitHookAddress) { self()->addExternalRelocation(new (self()->trHeapMemory()) TR::ExternalOrderedPair32BitRelocation((uint8_t *)firstInstruction, + (uint8_t *)secondInstruction, (uint8_t *)node->getSymbolReference(), (uint8_t *)orderedPairSequence2, (TR_ExternalRelocationTargetKind)TR_MethodEnterExitHookAddress, self()),