diff --git a/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp index bbe5aae1e3..7cad8119ef 100644 --- a/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp +++ b/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp @@ -1670,6 +1670,10 @@ if_aclLink(aclCompiler *cl, const void *ptr = cl->clAPI.extSec(cl, src_bin, &data_size, aclLLVMIR, &error_code); if (ptr == NULL) ptr = cl->clAPI.extSec(cl, src_bin, &data_size, aclSPIR, &error_code); + if (ptr == NULL) { + error_code = ACL_INVALID_FILE; + goto internal_link_failure; + } char *mod = new char[data_size]; memcpy(mod, ptr, data_size); module = cl->feAPI.toModule(ald, mod, data_size, context, &error_code); @@ -1677,7 +1681,10 @@ if_aclLink(aclCompiler *cl, const void *ptr = cl->clAPI.extSec(cl, libs[x], &data_size, aclLLVMIR, NULL); if (ptr == NULL) ptr = cl->clAPI.extSec(cl, libs[x], &data_size, aclSPIR, NULL); - if (ptr == NULL) continue; + if (ptr == NULL) { + error_code = ACL_INVALID_FILE; + goto internal_link_failure; + } mod = new char[data_size]; memcpy(mod, ptr, data_size); mod_libs[x] = cl->feAPI.toModule(ald, mod, data_size, context, &error_code); diff --git a/projects/clr/rocclr/compiler/lib/include/v0_8/acl.h b/projects/clr/rocclr/compiler/lib/include/v0_8/acl.h index ba2669196c..b70bd14fb7 100644 --- a/projects/clr/rocclr/compiler/lib/include/v0_8/acl.h +++ b/projects/clr/rocclr/compiler/lib/include/v0_8/acl.h @@ -98,6 +98,9 @@ acl_error ACL_API_ENTRY aclWriteToMem(aclBinary *bin, void **mem, size_t *size) ACL_API_0_8; +acl_error ACL_API_ENTRY + aclUpdateRawFile(aclBinary *bin); + aclBinary* ACL_API_ENTRY aclCreateFromBinary(const aclBinary *binary, aclBIFVersion version) ACL_API_0_8; diff --git a/projects/clr/rocclr/compiler/lib/utils/v0_8/libUtils.cpp b/projects/clr/rocclr/compiler/lib/utils/v0_8/libUtils.cpp index e4714be778..d6427e5e29 100644 --- a/projects/clr/rocclr/compiler/lib/utils/v0_8/libUtils.cpp +++ b/projects/clr/rocclr/compiler/lib/utils/v0_8/libUtils.cpp @@ -1043,3 +1043,8 @@ convertBIF31ToBIF30(aclBinary *src) { } return dst; } + +void dump(aclBinary *bin) { + bifbase *elfBin = reinterpret_cast(bin->bin); + elfBin->dump(); +} diff --git a/projects/clr/rocclr/compiler/lib/utils/v0_8/libUtils.h b/projects/clr/rocclr/compiler/lib/utils/v0_8/libUtils.h index 620e5c3724..06ed8a6105 100644 --- a/projects/clr/rocclr/compiler/lib/utils/v0_8/libUtils.h +++ b/projects/clr/rocclr/compiler/lib/utils/v0_8/libUtils.h @@ -391,4 +391,6 @@ isBcMagic(const char* p) return true; } +void dump(aclBinary *bin); + #endif // _CL_LIB_UTILS_0_8_H_ diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp index 3b915235b4..cc6fcb1178 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp @@ -1821,6 +1821,9 @@ HSAILProgram::linkImpl( buildLog_ += "Error while linking: Could not load SPIR-V" ; return false; } + // Need to update elf raw file since it will be used by + // aclCreateFromBinary. + aclUpdateRawFile(binaryElf_); } else { buildLog_ +="Error while linking : \ Invalid binary (Missing LLVMIR section)" ;