Skip to content

Commit

Permalink
Apply mask to rela->r_addend to get the patching scheme (#8186)
Browse files Browse the repository at this point in the history
* Apply mask to rela->r_addend to get the patching scheme

* Change from CamelCase to snake_case

---------

Co-authored-by: dezhliao <[email protected]>
  • Loading branch information
dezhiAmd and dezhliao authored May 21, 2024
1 parent 5a757c1 commit c678a94
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime_src/core/common/api/xrt_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ class module_impl
// construct patcher objects for each argument.
class module_elf : public module_impl
{
// rela->addend have offset to base-bo-addr info along with schema
// [0:3] bit are used for patching schema, [4:31] used for base-bo-addr
constexpr static uint32_t addend_shift = 4;
constexpr static uint32_t addend_mask = ~((uint32_t)0) << addend_shift;
constexpr static uint32_t schema_mask = ~addend_mask;
xrt::elf m_elf;
uint8_t m_os_abi = Elf_Amd_Aie2p;
std::vector<ctrlcode> m_ctrlcodes;
Expand Down Expand Up @@ -658,7 +663,7 @@ class module_elf : public module_impl
if (auto search = arg2patchers.find(key_string); search != arg2patchers.end())
search->second.m_ctrlcode_offset.emplace_back(offset);
else {
auto symbol_type = static_cast<patcher::symbol_type>(rela->r_addend);
auto symbol_type = static_cast<patcher::symbol_type>(rela->r_addend & schema_mask);
arg2patchers.emplace(std::move(key_string), patcher{ symbol_type, {offset}, buf_type });
}
}
Expand Down

0 comments on commit c678a94

Please sign in to comment.