mirror of
https://github.com/apache/nuttx.git
synced 2026-10-08 14:55:18 +00:00
arch/sim: replace macOS C++ constructor runtime hack with post-link patch
- Invoke `codesign` and after lief rewrites the binary, so the modified Mach-O remains loadable on macOS. - Run the patch script via a dedicated `sim_patch_macho_initsection` custom target attached to `nuttx_post`, instead of a POST_BUILD command on the `nuttx` target. Signed-off-by: Shoji Tokunaga <toku@mac.com>
This commit is contained in:
parent
754dfd980b
commit
5349a5ab0c
2 changed files with 15 additions and 3 deletions
|
|
@ -32,6 +32,7 @@ Requires: pip install lief
|
|||
"""
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
try:
|
||||
|
|
@ -65,6 +66,16 @@ def main():
|
|||
if patched:
|
||||
fat.write(args.binary)
|
||||
|
||||
if sys.platform == "darwin":
|
||||
subprocess.run(
|
||||
["codesign", "--force", "--sign", "-", args.binary],
|
||||
check=True,
|
||||
)
|
||||
subprocess.run(
|
||||
["codesign", "--verify", "--verbose", args.binary],
|
||||
check=True,
|
||||
)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -153,14 +153,15 @@ list(
|
|||
if(CONFIG_HOST_MACOS AND CONFIG_HAVE_CXXINITIALIZE)
|
||||
# Keep classic __mod_init_func format so post-link lief patching works
|
||||
target_link_options(nuttx PRIVATE -Wl,-ld_classic,-no_fixup_chains)
|
||||
add_custom_command(
|
||||
TARGET nuttx
|
||||
POST_BUILD
|
||||
add_custom_target(
|
||||
sim_patch_macho_initsection ALL
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../patch_macho_initsection.py
|
||||
$<TARGET_FILE:nuttx>
|
||||
DEPENDS nuttx
|
||||
COMMENT "Patching Mach-O init section type flags")
|
||||
add_dependencies(nuttx_post sim_patch_macho_initsection)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SIM_CAMERA_V4L2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue