Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply mask to rela->r_addend to get the patching scheme #8186

Merged
merged 3 commits into from
May 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -408,6 +408,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;
dezhiAmd marked this conversation as resolved.
Show resolved Hide resolved
xrt::elf m_elf;
uint8_t m_os_abi = Elf_Amd_Aie2p;
std::vector<ctrlcode> m_ctrlcodes;
Expand Down Expand Up @@ -637,7 +642,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
Loading