Skip to content

Commit

Permalink
add xrt::elf raw elf data constructor (Xilinx#7963)
Browse files Browse the repository at this point in the history
* add xrt::elf raw elf data constructor

* rename

* review comment

* review comments

Signed-off-by: HimanshuChoudhary-Xilinx <[email protected]>

---------

Signed-off-by: HimanshuChoudhary-Xilinx <[email protected]>
  • Loading branch information
HimanshuChoudhary-Xilinx authored Mar 13, 2024
1 parent 7f9377b commit d7e2096
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/runtime_src/core/common/api/xrt_elf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -85,6 +91,11 @@ elf(const std::string& fnm)
: detail::pimpl<elf_impl>{std::make_shared<elf_impl>(fnm)}
{}

elf::
elf(std::istream& stream)
: detail::pimpl<elf_impl>{std::make_shared<elf_impl>(stream)}
{}

xrt::uuid
elf::
get_cfg_uuid() const
Expand Down
13 changes: 12 additions & 1 deletion src/runtime_src/core/include/experimental/xrt_elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#ifdef __cplusplus
# include <string>
# include <istream>
#endif

#ifdef __cplusplus
Expand All @@ -32,7 +33,17 @@ class elf : public detail::pimpl<elf_impl>
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;
Expand Down

0 comments on commit d7e2096

Please sign in to comment.