Skip to content

Commit

Permalink
Fix swapping of CPUType when crossing endians
Browse files Browse the repository at this point in the history
A cputype already in big endian (ex ppc) would be flipped into little
instead of staying in big, so grab the cputype in the native byte order
then flip to big if needed.
  • Loading branch information
CRKatri committed Dec 14, 2023
1 parent 52048d9 commit eb44f02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ldid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,8 +1599,8 @@ static void Allocate(const void *idata, size_t isize, std::streambuf &output, co
auto &mach_header(allocation.mach_header_);

fat_arch fat_arch;
fat_arch.cputype = Swap(mach_header->cputype);
fat_arch.cpusubtype = Swap(mach_header->cpusubtype);
fat_arch.cputype = Swap(mach_header.GetCPUType());
fat_arch.cpusubtype = Swap(mach_header.GetCPUSubtype());
fat_arch.offset = Swap(uint32_t(allocation.offset_));
fat_arch.size = Swap(uint32_t(allocation.limit_ + allocation.alloc_));
fat_arch.align = Swap(allocation.align_);
Expand Down

0 comments on commit eb44f02

Please sign in to comment.