// elfpack:命令行给 ELF 打壳(运维/调试用) // 用法: elfpack <目标ELF> <输出> package main import ( "fmt" "os" "path/filepath" "verification-platform-backend/internal/protect" ) func main() { if len(os.Args) != 4 { fmt.Fprintln(os.Stderr, "用法: elfpack <目标ELF> <输出> ") os.Exit(2) } src, err := os.ReadFile(os.Args[1]) must(err) cfg, err := os.ReadFile(os.Args[3]) must(err) det := protect.DetectFile(src, filepath.Base(os.Args[1])) out, info, err := protect.PatchAuto(src, cfg, filepath.Base(os.Args[1])) must(err) must(os.WriteFile(os.Args[2], out, 0o755)) fmt.Printf("kind=%s arch=%s %d → %d 字节\n", det.Kind, det.Arch, len(src), info.OutSize) fmt.Printf("入口 %#x → %#x 段 vaddr=%#x size=%d\n", info.EntryOld, info.EntryNew, info.SecRVA, info.SecSize) if info.Note != "" { fmt.Println("说明:", info.Note) } } func must(err error) { if err != nil { fmt.Fprintln(os.Stderr, "error:", err) os.Exit(1) } }