From d472b24d05d4e16d1325136ad8f02a3c3242b864 Mon Sep 17 00:00:00 2001 From: Tony Tye Date: Thu, 25 Jan 2018 21:06:05 -0500 Subject: [PATCH] Add support for R_AMDGPU_RELATIVE64 - Add support for R_AMDGPU_RELATIVE64 relocation record. - Return status error if any unsupported relocation record encountered. Change-Id: Icbb5dcb81109a70c1f2195412a0df58a11be9da1 --- runtime/hsa-runtime/inc/amd_hsa_elf.h | 1 + runtime/hsa-runtime/loader/executable.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/runtime/hsa-runtime/inc/amd_hsa_elf.h b/runtime/hsa-runtime/inc/amd_hsa_elf.h index 95f89c6354..a24dc85b7a 100644 --- a/runtime/hsa-runtime/inc/amd_hsa_elf.h +++ b/runtime/hsa-runtime/inc/amd_hsa_elf.h @@ -116,6 +116,7 @@ typedef enum { #define R_AMDGPU_64 3 #define R_AMDGPU_INIT_SAMPLER 4 #define R_AMDGPU_INIT_IMAGE 5 +#define R_AMDGPU_RELATIVE64 13 // AMD GPU Note Type Enumeration Values. #define NT_AMDGPU_HSA_CODE_OBJECT_VERSION 1 diff --git a/runtime/hsa-runtime/loader/executable.cpp b/runtime/hsa-runtime/loader/executable.cpp index 7b88e0d4a3..2f138190df 100644 --- a/runtime/hsa-runtime/loader/executable.cpp +++ b/runtime/hsa-runtime/loader/executable.cpp @@ -1673,14 +1673,16 @@ hsa_status_t ExecutableImpl::ApplyDynamicRelocation(hsa_agent_t agent, amd::hsa: break; } - case R_AMDGPU_INIT_IMAGE: - case R_AMDGPU_INIT_SAMPLER: - // Images and samplers are not supported in v2.1. - return HSA_STATUS_ERROR_INVALID_CODE_OBJECT; + case R_AMDGPU_RELATIVE64: + { + int64_t baseDelta = reinterpret_cast(relSeg->Address(0)) - relSeg->VAddr(); + uint64_t relocatedAddr = baseDelta + rel->addend(); + relSeg->Copy(rel->offset(), &relocatedAddr, sizeof(relocatedAddr)); + break; + } default: - // Ignore. - break; + return HSA_STATUS_ERROR_INVALID_CODE_OBJECT; } return HSA_STATUS_SUCCESS; }