From ec66509986b32728f7ef27d638b23bebb9163093 Mon Sep 17 00:00:00 2001 From: Konstantin Zhuravlyov Date: Tue, 26 Mar 2024 18:46:24 -0400 Subject: [PATCH] Rename existing relocation types to legacy/v1 (NFC) Change-Id: Ided7f656c34131b8067a19c0d3b2955fc8823628 [ROCm/ROCR-Runtime commit: b2c32ad6cb38289de21e5566f3e8b0509150f942] --- .../runtime/hsa-runtime/inc/amd_hsa_elf.h | 16 ++++++------- .../libamdhsacode/amd_hsa_code.cpp | 6 ++--- .../runtime/hsa-runtime/loader/executable.cpp | 24 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/amd_hsa_elf.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/amd_hsa_elf.h index 757a67e78b..b71b4df27a 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/amd_hsa_elf.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/amd_hsa_elf.h @@ -263,14 +263,14 @@ typedef enum { // ELF Symbol Flag Enumeration Values. #define STF_AMDGPU_HSA_CONST AMDGPU_HSA_SYMBOL_FLAG_CONST -// AMD GPU Relocation Type Enumeration Values. -#define R_AMDGPU_NONE 0 -#define R_AMDGPU_32_LOW 1 -#define R_AMDGPU_32_HIGH 2 -#define R_AMDGPU_64 3 -#define R_AMDGPU_INIT_SAMPLER 4 -#define R_AMDGPU_INIT_IMAGE 5 -#define R_AMDGPU_RELATIVE64 13 +// Legacy/V1 AMD GPU Relocation Type Enumeration Values. +#define R_AMDGPU_V1_NONE 0 +#define R_AMDGPU_V1_32_LOW 1 +#define R_AMDGPU_V1_32_HIGH 2 +#define R_AMDGPU_V1_64 3 +#define R_AMDGPU_V1_INIT_SAMPLER 4 +#define R_AMDGPU_V1_INIT_IMAGE 5 +#define R_AMDGPU_V1_RELATIVE64 13 // AMD GPU Note Type Enumeration Values. #define NT_AMD_HSA_CODE_OBJECT_VERSION 1 diff --git a/projects/rocr-runtime/runtime/hsa-runtime/libamdhsacode/amd_hsa_code.cpp b/projects/rocr-runtime/runtime/hsa-runtime/libamdhsacode/amd_hsa_code.cpp index 183aff12b1..71c8a55a81 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/libamdhsacode/amd_hsa_code.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/libamdhsacode/amd_hsa_code.cpp @@ -954,7 +954,7 @@ namespace code { uint64_t offset = ImageInitSection()->addData(&desc, sizeof(desc), 8); amd::elf::Symbol* imageInit = img->symtab()->addSymbol(ImageInitSection(), "", offset, 0, STT_AMDGPU_HSA_METADATA, STB_LOCAL); - image->elfSym()->section()->relocationSection()->addRelocation(R_AMDGPU_INIT_IMAGE, imageInit, image->elfSym()->value() + destOffset, 0); + image->elfSym()->section()->relocationSection()->addRelocation(R_AMDGPU_V1_INIT_IMAGE, imageInit, image->elfSym()->value() + destOffset, 0); } void AmdHsaCode::AddImageInitializer( @@ -995,7 +995,7 @@ namespace code { uint64_t offset = SamplerInitSection()->addData(&desc, sizeof(desc), 8); amd::elf::Symbol* samplerInit = img->symtab()->addSymbol(SamplerInitSection(), "", offset, 0, STT_AMDGPU_HSA_METADATA, STB_LOCAL); - sampler->elfSym()->section()->relocationSection()->addRelocation(R_AMDGPU_INIT_SAMPLER, samplerInit, sampler->elfSym()->value() + destOffset, 0); + sampler->elfSym()->section()->relocationSection()->addRelocation(R_AMDGPU_V1_INIT_SAMPLER, samplerInit, sampler->elfSym()->value() + destOffset, 0); } void AmdHsaCode::AddSamplerInitializer(Symbol* sampler, uint64_t destOffset, @@ -1014,7 +1014,7 @@ namespace code { void AmdHsaCode::AddInitVarWithAddress(bool large, Symbol* dest, uint64_t destOffset, Symbol* addrOf, uint64_t addrAddend) { - uint32_t rtype = large ? R_AMDGPU_64 : R_AMDGPU_32_LOW; + uint32_t rtype = large ? R_AMDGPU_V1_64 : R_AMDGPU_V1_32_LOW; dest->elfSym()->section()->relocationSection()->addRelocation(rtype, addrOf->elfSym(), dest->elfSym()->value() + destOffset, addrAddend); } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/loader/executable.cpp b/projects/rocr-runtime/runtime/hsa-runtime/loader/executable.cpp index 2b6d09d080..f272b49cad 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/loader/executable.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/loader/executable.cpp @@ -1639,9 +1639,9 @@ hsa_status_t ExecutableImpl::ApplyStaticRelocation(hsa_agent_t agent, amd::hsa:: Segment* rseg = SectionSegment(agent, sec); size_t reladdr = sec->addr() + rel->offset(); switch (rel->type()) { - case R_AMDGPU_32_LOW: - case R_AMDGPU_32_HIGH: - case R_AMDGPU_64: + case R_AMDGPU_V1_32_LOW: + case R_AMDGPU_V1_32_HIGH: + case R_AMDGPU_V1_64: { uint64_t addr; switch (sym->type()) { @@ -1672,15 +1672,15 @@ hsa_status_t ExecutableImpl::ApplyStaticRelocation(hsa_agent_t agent, amd::hsa:: uint32_t addr32 = 0; switch (rel->type()) { - case R_AMDGPU_32_HIGH: + case R_AMDGPU_V1_32_HIGH: addr32 = uint32_t((addr >> 32) & 0xFFFFFFFF); rseg->Copy(reladdr, &addr32, sizeof(addr32)); break; - case R_AMDGPU_32_LOW: + case R_AMDGPU_V1_32_LOW: addr32 = uint32_t(addr & 0xFFFFFFFF); rseg->Copy(reladdr, &addr32, sizeof(addr32)); break; - case R_AMDGPU_64: + case R_AMDGPU_V1_64: rseg->Copy(reladdr, &addr, sizeof(addr)); break; default: @@ -1689,7 +1689,7 @@ hsa_status_t ExecutableImpl::ApplyStaticRelocation(hsa_agent_t agent, amd::hsa:: break; } - case R_AMDGPU_INIT_SAMPLER: + case R_AMDGPU_V1_INIT_SAMPLER: { if (STT_AMDGPU_HSA_METADATA != sym->type() || SHT_PROGBITS != sym->section()->type() || @@ -1720,7 +1720,7 @@ hsa_status_t ExecutableImpl::ApplyStaticRelocation(hsa_agent_t agent, amd::hsa:: break; } - case R_AMDGPU_INIT_IMAGE: + case R_AMDGPU_V1_INIT_IMAGE: { if (STT_AMDGPU_HSA_METADATA != sym->type() || SHT_PROGBITS != sym->section()->type() || @@ -1833,7 +1833,7 @@ hsa_status_t ExecutableImpl::ApplyDynamicRelocation(hsa_agent_t agent, amd::hsa: symAddr += rel->addend(); switch (rel->type()) { - case R_AMDGPU_32_HIGH: + case R_AMDGPU_V1_32_HIGH: { if (!symAddr) { logger_ << "LoaderError: symbol \"" << rel->symbol()->name() << "\" is undefined\n"; @@ -1845,7 +1845,7 @@ hsa_status_t ExecutableImpl::ApplyDynamicRelocation(hsa_agent_t agent, amd::hsa: break; } - case R_AMDGPU_32_LOW: + case R_AMDGPU_V1_32_LOW: { if (!symAddr) { logger_ << "LoaderError: symbol \"" << rel->symbol()->name() << "\" is undefined\n"; @@ -1857,7 +1857,7 @@ hsa_status_t ExecutableImpl::ApplyDynamicRelocation(hsa_agent_t agent, amd::hsa: break; } - case R_AMDGPU_64: + case R_AMDGPU_V1_64: { if (!symAddr) { logger_ << "LoaderError: symbol \"" << rel->symbol()->name() << "\" is undefined\n"; @@ -1868,7 +1868,7 @@ hsa_status_t ExecutableImpl::ApplyDynamicRelocation(hsa_agent_t agent, amd::hsa: break; } - case R_AMDGPU_RELATIVE64: + case R_AMDGPU_V1_RELATIVE64: { int64_t baseDelta = reinterpret_cast(relSeg->Address(0)) - relSeg->VAddr(); uint64_t relocatedAddr = baseDelta + rel->addend();