[all-commits] [llvm/llvm-project] a299b2: Regenerate LC_CODE_SIGNATURE during llvm-objcopy o...

Daniel Rodríguez Troitiño via All-commits all-commits at lists.llvm.org
Tue Oct 26 14:52:39 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a299b24712ccd0769ffa0d5b65cbc98211fd4d99
      https://github.com/llvm/llvm-project/commit/a299b24712ccd0769ffa0d5b65cbc98211fd4d99
  Author: Nuri Amari <nuriamari at fb.com>
  Date:   2021-10-26 (Tue, 26 Oct 2021)

  Changed paths:
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h
    A llvm/test/tools/llvm-objcopy/MachO/Inputs/code-signature-check.py
    M llvm/test/tools/llvm-objcopy/MachO/code_signature_lc.test
    A llvm/test/tools/llvm-objcopy/MachO/code_signature_lc_update.test
    M llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
    M llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.h
    M llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
    M llvm/tools/llvm-objcopy/MachO/MachOReader.cpp
    M llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp
    M llvm/tools/llvm-objcopy/MachO/MachOWriter.h
    M llvm/tools/llvm-objcopy/MachO/Object.cpp
    M llvm/tools/llvm-objcopy/MachO/Object.h

  Log Message:
  -----------
  Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations

**Context:**

This is a second attempt at introducing signature regeneration to llvm-objcopy. In this diff: https://reviews.llvm.org/D109840, a script was introduced to test
the validity of a code signature. In this diff: https://reviews.llvm.org/D109803 (now reverted), an effort was made to extract the signature generation behavior out of LLD into a common location for use in llvm-objcopy. In this diff: https://reviews.llvm.org/D109972 it was decided that there was no appropriate common location and that a small amount of duplication to bring signature generation to llvm-objcopy would be better. This diff introduces this duplication.

**Summary**

Prior to this change, if a LC_CODE_SIGNATURE load command
was included in the binary passed to llvm-objcopy, the command and
associated section were simply copied and included verbatim in the
new binary. If rest of the binary was modified at all, this results
in an invalid Mach-O file. This change regenerates the signature
rather than copying it.

The code_signature_lc.test test was modified to include the yaml
representation of a small signed MachO executable in order to
effectively test the signature generation.

Reviewed By: alexander-shaposhnikov, #lld-macho

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




More information about the All-commits mailing list