llvm-project/llvm/tools/llvm-objcopy/MachO
Nuri Amari a299b24712 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
2021-10-26 14:51:13 -07:00
..
MachOConfig.h [llvm-objcopy][NFC] Refactor CopyConfig structure - categorize options. 2021-09-08 19:16:38 +03:00
MachOLayoutBuilder.cpp Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00
MachOLayoutBuilder.h Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00
MachOObjcopy.cpp Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00
MachOObjcopy.h [llvm-objcopy][NFC] Refactor CopyConfig structure - categorize options. 2021-09-08 19:16:38 +03:00
MachOReader.cpp Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00
MachOReader.h [llvm-objcopy][MachO] Support LC_LINKER_OPTIMIZATION_HINT load command 2021-06-29 18:47:55 -07:00
MachOWriter.cpp Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00
MachOWriter.h Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00
Object.cpp Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00
Object.h Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00