This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] Fix misaligned access to load command data.
ClosedPublic

Authored by drodriguez on Oct 28 2021, 11:51 AM.

Details

Summary

It seems that llvm-objcopy stores data temporarily misaligned with the
requirements of the underlaying struct from libBinaryFormat, and UBSan
generates a runtime error.

Instead of trying to reinterpret the memory as the struct itself, simply
access the char * pointer that we are interested in, and that do not
have alignment restrictions.

This problem was pointed out in a comment of D111164.

Diff Detail

Event Timeline

drodriguez created this revision.Oct 28 2021, 11:51 AM
drodriguez requested review of this revision.Oct 28 2021, 11:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2021, 11:51 AM
nuriamari accepted this revision.Oct 28 2021, 7:54 PM
This revision is now accepted and ready to land.Oct 28 2021, 7:54 PM