From d1f4e7ea548c450dc4f29635b3fe981beb0cba46 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Fri, 29 Mar 2019 17:57:17 -0400 Subject: [PATCH] append the ELF flags for sram-ecc and xnack to the target triple per code object [ROCm/clr commit: 4d0dc45078580b09a7ad969ab1af8fb9b24f1870] --- .../include/hip/hcc_detail/code_object_bundle.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/projects/clr/hipamd/include/hip/hcc_detail/code_object_bundle.hpp b/projects/clr/hipamd/include/hip/hcc_detail/code_object_bundle.hpp index 89b341afa7..173a915409 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/code_object_bundle.hpp +++ b/projects/clr/hipamd/include/hip/hcc_detail/code_object_bundle.hpp @@ -31,6 +31,8 @@ THE SOFTWARE. #include #include #include +#include +#include "elfio/elfio.hpp" namespace hip_impl { @@ -124,6 +126,18 @@ class Bundled_code_header { std::copy_n(f + y.header.offset, y.header.bundle_sz, std::back_inserter(y.blob)); + // we need to read the blob (ELF) for this bundle to get the feature flags + std::stringstream tmp{std::string{y.blob.cbegin(), y.blob.cend()}}; + ELFIO::elfio reader; + if (reader.load(tmp)) { + unsigned int xnack_enabled = reader.get_flags() & 0x100; + unsigned int sram_ecc_enabled = reader.get_flags() & 0x200; + if (xnack_enabled) + y.triple.append("+xnack"); + if (sram_ecc_enabled) + y.triple.append("+sram-ecc"); + } + it += y.header.triple_sz; x.bundled_code_size = std::max(x.bundled_code_size,