loader: allow but skip static relocations for code object v2+
Change-Id: I4ae14cb5e740d7d45810b75038b15a0b94d2bf0b
This commit is contained in:
committed by
Konstantin Zhuravlyov
parent
b983c19729
commit
08c94463de
@@ -1624,15 +1624,24 @@ Segment* ExecutableImpl::SectionSegment(hsa_agent_t agent, code::Section* sec)
|
|||||||
hsa_status_t ExecutableImpl::ApplyRelocations(hsa_agent_t agent, amd::hsa::code::AmdHsaCode *c)
|
hsa_status_t ExecutableImpl::ApplyRelocations(hsa_agent_t agent, amd::hsa::code::AmdHsaCode *c)
|
||||||
{
|
{
|
||||||
hsa_status_t status = HSA_STATUS_SUCCESS;
|
hsa_status_t status = HSA_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
uint32_t majorVersion, minorVersion;
|
||||||
|
if (!c->GetCodeObjectVersion(&majorVersion, &minorVersion)) {
|
||||||
|
return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < c->RelocationSectionCount(); ++i) {
|
for (size_t i = 0; i < c->RelocationSectionCount(); ++i) {
|
||||||
if (c->GetRelocationSection(i)->targetSection()) {
|
if (c->GetRelocationSection(i)->targetSection()) {
|
||||||
|
// Static relocations may be present if --emit-relocs
|
||||||
|
// option was passed to lld, but they cannot be applied
|
||||||
|
// again, so skip it for code object v2 and up.
|
||||||
|
if (majorVersion >= 2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
status = ApplyStaticRelocationSection(agent, c->GetRelocationSection(i));
|
status = ApplyStaticRelocationSection(agent, c->GetRelocationSection(i));
|
||||||
} else {
|
} else {
|
||||||
// Dynamic relocations are supported starting code object v2.1.
|
// Dynamic relocations are supported starting code object v2.1.
|
||||||
uint32_t majorVersion, minorVersion;
|
|
||||||
if (!c->GetCodeObjectVersion(&majorVersion, &minorVersion)) {
|
|
||||||
return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
|
|
||||||
}
|
|
||||||
if (majorVersion < 2) {
|
if (majorVersion < 2) {
|
||||||
return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
|
return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user