add cli parsing for remove strings
This commit is contained in:
parent
d11ef20f4a
commit
d534d62f5e
21
macho-go/internal/wrapper/action/remove_strings.go
Normal file
21
macho-go/internal/wrapper/action/remove_strings.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package action
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "ios-wrapper/internal/wrapper/ofile"
|
||||||
|
)
|
||||||
|
|
||||||
|
type removeStrings struct{}
|
||||||
|
|
||||||
|
func (action *removeStrings) withMacho(mf *MachoFile) error {
|
||||||
|
mf.Context().RemoveStrings()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (action *removeStrings) withFat(ff *FatFile) error {
|
||||||
|
return defaultWithFat(action, ff)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRemoveStringsAction() *removeStrings {
|
||||||
|
return &removeStrings{}
|
||||||
|
}
|
||||||
|
|
@ -117,6 +117,7 @@ func Cli() {
|
|||||||
pc.remove_inits = true
|
pc.remove_inits = true
|
||||||
pc.remove_codesign = true
|
pc.remove_codesign = true
|
||||||
pc.remove_others = true
|
pc.remove_others = true
|
||||||
|
pc.remove_string = true
|
||||||
}
|
}
|
||||||
pc.remove_imports = arg.RemoveBindSymbols
|
pc.remove_imports = arg.RemoveBindSymbols
|
||||||
pc.remove_codesign = arg.RemoveCodeSign
|
pc.remove_codesign = arg.RemoveCodeSign
|
||||||
@ -124,6 +125,7 @@ func Cli() {
|
|||||||
pc.remove_others = arg.RemoveOthers
|
pc.remove_others = arg.RemoveOthers
|
||||||
pc.remove_exports = arg.RemoveExports
|
pc.remove_exports = arg.RemoveExports
|
||||||
pc.remove_symbol_table = arg.RemoveSymbolTable
|
pc.remove_symbol_table = arg.RemoveSymbolTable
|
||||||
|
pc.remove_string = arg.RemoveStrings
|
||||||
pc.dylib_to_add = arg.Dylibs
|
pc.dylib_to_add = arg.Dylibs
|
||||||
pc.rpath_to_add = arg.Rpath
|
pc.rpath_to_add = arg.Rpath
|
||||||
pc.outfile = arg.Out
|
pc.outfile = arg.Out
|
||||||
@ -264,6 +266,7 @@ func bcell2header(bfile string, header string) {
|
|||||||
}
|
}
|
||||||
fmt.Fprintf(w, "};\n")
|
fmt.Fprintf(w, "};\n")
|
||||||
|
|
||||||
|
if info.Symbols != nil {
|
||||||
fmt.Fprintf(w, "__attribute__((section(\"__DATA,bshield\")))\n")
|
fmt.Fprintf(w, "__attribute__((section(\"__DATA,bshield\")))\n")
|
||||||
fmt.Fprintf(w, "char libs[] =\n")
|
fmt.Fprintf(w, "char libs[] =\n")
|
||||||
for _, lib := range info.Symbols.Libs {
|
for _, lib := range info.Symbols.Libs {
|
||||||
@ -299,6 +302,18 @@ func bcell2header(bfile string, header string) {
|
|||||||
}
|
}
|
||||||
fmt.Fprintf(w, "};\n")
|
fmt.Fprintf(w, "};\n")
|
||||||
fmt.Fprintf(w, "uint32_t n_instructions = %d;\n", n_instructions)
|
fmt.Fprintf(w, "uint32_t n_instructions = %d;\n", n_instructions)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(w, "__attribute__((section(\"__DATA,bshield\")))\n")
|
||||||
|
fmt.Fprintf(w, "char libs[] = {};\n")
|
||||||
|
|
||||||
|
fmt.Fprintf(w, "__attribute__((section(\"__DATA,bshield\")))\n")
|
||||||
|
fmt.Fprintf(w, "char symbols[] = {};\n")
|
||||||
|
|
||||||
|
fmt.Fprintf(w, "__attribute__((section(\"__DATA,bshield\")))\n")
|
||||||
|
fmt.Fprintf(w, "uint32_t encoded_table[] = {};\n")
|
||||||
|
|
||||||
|
fmt.Fprintf(w, "uint32_t n_instructions = %d;\n", 0)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Fprintf(w, "__attribute__((section(\"__DATA,bshield\")))\n")
|
fmt.Fprintf(w, "__attribute__((section(\"__DATA,bshield\")))\n")
|
||||||
fmt.Fprintf(w, "uint32_t special_selectors_idx[] = {\n")
|
fmt.Fprintf(w, "uint32_t special_selectors_idx[] = {\n")
|
||||||
|
@ -61,6 +61,7 @@ type PepeArgument struct {
|
|||||||
OFile string `arg help:"Path to Mach-O/Fat binary file" type:"existingfile"`
|
OFile string `arg help:"Path to Mach-O/Fat binary file" type:"existingfile"`
|
||||||
Dylibs []string `short:"l" help:"Add more LC_DYLIB"`
|
Dylibs []string `short:"l" help:"Add more LC_DYLIB"`
|
||||||
Rpath []string `short:"r" help:"Add more LC_RPATH"`
|
Rpath []string `short:"r" help:"Add more LC_RPATH"`
|
||||||
|
RemoveStrings bool `default:"false" negatable:"" help:"Remove static strings found in DATA and DATA_CONST section"`
|
||||||
RemoveCodeSign bool `default:"false" negatable:"" help:"Remove LC_CODE_SIGNATURE"`
|
RemoveCodeSign bool `default:"false" negatable:"" help:"Remove LC_CODE_SIGNATURE"`
|
||||||
RemoveExports bool `default:"false" negatable:"" help:"Clear the export table/trie"`
|
RemoveExports bool `default:"false" negatable:"" help:"Clear the export table/trie"`
|
||||||
RemoveSymbolTable bool `default:"false" negatable:"" help:"Remove LC_SYMTAB and LC_DYSYMTAB"`
|
RemoveSymbolTable bool `default:"false" negatable:"" help:"Remove LC_SYMTAB and LC_DYSYMTAB"`
|
||||||
|
@ -44,6 +44,7 @@ type ProgramContext struct {
|
|||||||
remove_others bool
|
remove_others bool
|
||||||
remove_exports bool
|
remove_exports bool
|
||||||
remove_symbol_table bool
|
remove_symbol_table bool
|
||||||
|
remove_string bool
|
||||||
dylib_to_add []string
|
dylib_to_add []string
|
||||||
rpath_to_add []string
|
rpath_to_add []string
|
||||||
symbols_keep []string
|
symbols_keep []string
|
||||||
@ -106,6 +107,9 @@ func (pc *ProgramContext) Process(ofile OFile) {
|
|||||||
if pc.remove_exports {
|
if pc.remove_exports {
|
||||||
pc.AddAction(NewRemoveExportsAction())
|
pc.AddAction(NewRemoveExportsAction())
|
||||||
}
|
}
|
||||||
|
if pc.remove_string {
|
||||||
|
pc.AddAction(NewRemoveStringsAction())
|
||||||
|
}
|
||||||
ExperimentalFeature("Remove Unnecessary Info", func() {
|
ExperimentalFeature("Remove Unnecessary Info", func() {
|
||||||
if pc.remove_others {
|
if pc.remove_others {
|
||||||
pc.AddAction(NewRemoveUnnecessaryInfoAction())
|
pc.AddAction(NewRemoveUnnecessaryInfoAction())
|
||||||
|
Loading…
Reference in New Issue
Block a user