[PATCH] D111164: Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations

Nuri Amari via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 5 10:33:42 PDT 2021


nuriamari created this revision.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a subscriber: abrachet.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
nuriamari edited the summary of this revision.
nuriamari added a reviewer: drodriguez.
nuriamari added a reviewer: steven_wu.
nuriamari updated this revision to Diff 377293.
nuriamari added a comment.
nuriamari published this revision for review.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

Rename CodeSignatureSectionInfo struct


**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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111164

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111164.377293.patch
Type: text/x-patch
Size: 28427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211005/75177e84/attachment-0001.bin>


More information about the llvm-commits mailing list