Skip to content

Commit

Permalink
MachO::Binary: treat thread local zerofill as global zerofill
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Dzenis <[email protected]>
  • Loading branch information
jalopezg-git and DzenIsRich committed Dec 10, 2024
1 parent 441bb46 commit 544ab8d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/MachO/Binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,8 @@ ok_error_t Binary::shift(size_t value) {

for (const std::unique_ptr<Section>& section : segment->sections_) {
if (section->virtual_address() >= loadcommands_end_va ||
section->type() == Section::TYPE::ZEROFILL)
section->type() == Section::TYPE::ZEROFILL ||
section->type() == Section::TYPE::THREAD_LOCAL_ZEROFILL)
{
section->virtual_address(section->virtual_address() + value);
}
Expand Down Expand Up @@ -1223,9 +1224,9 @@ bool Binary::extend_segment(const SegmentCommand& segment, size_t size) {
section->offset(section->offset() + size_aligned);
section->virtual_address(section->virtual_address() + size_aligned);
}

if (section->type() == Section::TYPE::ZEROFILL &&
section->virtual_address() > last_va)
else if (section->virtual_address() > last_va &&
(section->type() == Section::TYPE::ZEROFILL ||
section->type() == Section::TYPE::THREAD_LOCAL_ZEROFILL))
{
section->virtual_address(section->virtual_address() + size_aligned);
}
Expand Down

0 comments on commit 544ab8d

Please sign in to comment.