From d7e2096b65b40c0130aa2d6e4d6047524893a302 Mon Sep 17 00:00:00 2001 From: HimanshuChoudhary-Xilinx <114978536+HimanshuChoudhary-Xilinx@users.noreply.github.com> Date: Wed, 13 Mar 2024 21:37:40 +0530 Subject: [PATCH] add xrt::elf raw elf data constructor (#7963) * add xrt::elf raw elf data constructor * rename * review comment * review comments Signed-off-by: HimanshuChoudhary-Xilinx --------- Signed-off-by: HimanshuChoudhary-Xilinx --- src/runtime_src/core/common/api/xrt_elf.cpp | 11 +++++++++++ src/runtime_src/core/include/experimental/xrt_elf.h | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/runtime_src/core/common/api/xrt_elf.cpp b/src/runtime_src/core/common/api/xrt_elf.cpp index eacb89058cc..39043cfd792 100644 --- a/src/runtime_src/core/common/api/xrt_elf.cpp +++ b/src/runtime_src/core/common/api/xrt_elf.cpp @@ -28,6 +28,12 @@ class elf_impl throw std::runtime_error(fnm + " is not found or is not a valid ELF file"); } + elf_impl(std::istream& stream) + { + if (!m_elf.load(stream)) + throw std::runtime_error("not a valid ELF stream"); + } + const ELFIO::elfio& get_elfio() const { @@ -85,6 +91,11 @@ elf(const std::string& fnm) : detail::pimpl{std::make_shared(fnm)} {} +elf:: +elf(std::istream& stream) + : detail::pimpl{std::make_shared(stream)} +{} + xrt::uuid elf:: get_cfg_uuid() const diff --git a/src/runtime_src/core/include/experimental/xrt_elf.h b/src/runtime_src/core/include/experimental/xrt_elf.h index eff052332cb..d333adb8db5 100644 --- a/src/runtime_src/core/include/experimental/xrt_elf.h +++ b/src/runtime_src/core/include/experimental/xrt_elf.h @@ -9,6 +9,7 @@ #ifdef __cplusplus # include +# include #endif #ifdef __cplusplus @@ -32,7 +33,17 @@ class elf : public detail::pimpl public: XRT_API_EXPORT elf(const std::string& fnm); - + + /** + * elf() - Constructor from raw ELF data + * + * @param data + * Raw data of elf + * + */ + XRT_API_EXPORT + elf(std::istream& stream); + XRT_API_EXPORT xrt::uuid get_cfg_uuid() const;