llvm-project/llvm/tools/llvm-objcopy
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
..
COFF [llvm-objcopy][COFF] Fix test for debug dir presence 2021-09-10 09:57:18 +01:00
ELF [llvm-objcopy] Rename relocation sections together with their targets. 2021-09-29 16:36:37 +07:00
MachO Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations 2021-10-26 14:51:13 -07:00
wasm [llvm-strip][WebAssembly] Support strip flags 2021-07-14 14:17:02 -07:00
BitcodeStripOpts.td [llvm-objcopy][MachO] Add llvm-bitcode-strip driver 2020-09-18 18:13:05 -07:00
CMakeLists.txt [llvm-objcopy] Refactor CopyConfig structure. 2021-05-20 13:14:51 +03:00
CommonConfig.h [llvm-objcopy][NFC] Refactor CopyConfig structure - categorize options. 2021-09-08 19:16:38 +03:00
CommonOpts.td [llvm-objcopy][MachO] Add support for --keep-undefined 2021-03-08 18:57:25 -08:00
ConfigManager.cpp [tools] Delete redundant 'static' from namespace scope 'static const'. NFC 2021-10-18 22:38:42 -07:00
ConfigManager.h [llvm-objcopy][NFC] Refactor CopyConfig structure - remove lazy options processing. 2021-05-31 14:40:27 +03:00
InstallNameToolOpts.td [llvm-install-name-tool] Add -prepend_rpath option 2020-10-23 15:01:03 -07:00
MultiFormatConfig.h [llvm-objcopy] Refactor CopyConfig structure. 2021-05-20 13:14:51 +03:00
ObjcopyOpts.td [llvm-objcopy][docs] Add missing options to the help output and the command guide 2021-09-24 09:44:46 +01:00
StripOpts.td
llvm-objcopy.cpp [llvm] Rename StringRef _lower() method calls to _insensitive() 2021-06-25 00:22:01 +03:00
llvm-objcopy.h [llvm-objcopy] Refactor CopyConfig structure. 2021-05-20 13:14:51 +03:00