symbol_inject: add step to codesign Mach-O binaries.
The adhoc codesign of Macho-O binaries is broken after symbol
injection. MacOS refuses to run the binaries unless we sign
them again.
Bug: 241493489
Test: build and run simpleperf_ndk64 on MacOS
Change-Id: I25ef5c6413bd97e1bfa0a4ec5d04eaefb6fea54c
diff --git a/symbol_inject/macho.go b/symbol_inject/macho.go
index 6ee3f4f..9946d34 100644
--- a/symbol_inject/macho.go
+++ b/symbol_inject/macho.go
@@ -18,6 +18,7 @@
"debug/macho"
"fmt"
"io"
+ "os/exec"
"sort"
"strings"
)
@@ -40,7 +41,7 @@
return symbols[i].Value < symbols[j].Value
})
- file := &File{}
+ file := &File{IsMachoFile: true}
for _, section := range machoFile.Sections {
file.Sections = append(file.Sections, &Section{
@@ -95,3 +96,8 @@
return nil
}
+
+func CodeSignMachoFile(path string) error {
+ cmd := exec.Command("/usr/bin/codesign", "--force", "-s", "-", path)
+ return cmd.Run()
+}