Skip to content

Commit

Permalink
fix(mem): Fix elf loading byte counting (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
zarubaf authored Nov 15, 2024
1 parent d2f38da commit df4f7df
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/test/csrc/common/elfloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,8 @@ long readFromElf(void *ptr, const char *file_name, long buf_size) {
std::memcpy((uint8_t *)ptr + offset, section.data_src, section.data_len);
len_written += len;
}
return len_written;
// Since we are unpacking the sections, the total amount of bytes is the last
// section offset plus its size.
auto last_section = elf_file.sections.back();
return last_section.data_dst - base_addr + last_section.data_len + last_section.zero_len;
}

0 comments on commit df4f7df

Please sign in to comment.