[all-commits] [llvm/llvm-project] 8fbe1e: [llvm-objcopy] Fix misaligned access to load comma...

Daniel Rodríguez Troitiño via All-commits all-commits at lists.llvm.org
Thu Oct 28 22:17:15 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8fbe1e760224cc4941f1f014d1a3c7480f2e0e7c
      https://github.com/llvm/llvm-project/commit/8fbe1e760224cc4941f1f014d1a3c7480f2e0e7c
  Author: Daniel Rodríguez Troitiño <danielrodriguez at fb.com>
  Date:   2021-10-28 (Thu, 28 Oct 2021)

  Changed paths:
    M llvm/tools/llvm-objcopy/MachO/MachOReader.cpp

  Log Message:
  -----------
  [llvm-objcopy] Fix misaligned access to load command data.

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.

Differential Revision: https://reviews.llvm.org/D112744




More information about the All-commits mailing list