Skip to content

Commit

Permalink
[MachO] Fix unaligned load in extractSections
Browse files Browse the repository at this point in the history
A recent change to ubsan
(llvm@7926744)
exposed an unaligned load in MachOReader (see
https://lab.llvm.org/buildbot/#/builders/85/builds/19482 for an example).

This patch fixes it by dropping the alignment.
  • Loading branch information
thurstond committed Oct 10, 2023
1 parent 97b989b commit b376873
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/ObjCopy/MachO/MachOReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Expected<std::vector<std::unique_ptr<Section>>> static extractSections(
LoadCmd.C.cmdsize);
Curr < End; ++Curr) {
SectionType Sec;
memcpy((void *)&Sec, Curr, sizeof(SectionType));
memcpy((void *)&Sec, reinterpret_cast<const char*>(Curr), sizeof(SectionType));

if (MachOObj.isLittleEndian() != sys::IsLittleEndianHost)
MachO::swapStruct(Sec);
Expand Down

0 comments on commit b376873

Please sign in to comment.