本文整理汇总了Golang中debug/macho.File类的典型用法代码示例。如果您正苦于以下问题:Golang File类的具体用法?Golang File怎么用?Golang File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了File类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: findEntry
func findEntry(f *macho.File, bits int) (uint64, error) {
var entry uint64
for _, l := range f.Loads {
var cmd macho.LoadCmd
data := l.Raw()
binary.Read(bytes.NewReader(data), f.ByteOrder, &cmd)
if cmd == macho.LoadCmdUnixThread {
// LC_UNIXTHREAD
if bits == 64 {
ip := 144
entry = f.ByteOrder.Uint64(data[ip : ip+8])
} else {
ip := 56
entry = uint64(f.ByteOrder.Uint32(data[ip : ip+4]))
}
return entry, nil
} else if cmd == machoLoadCmdMain {
// [8:16] == entry - __TEXT, data[16:24] == stack size
__TEXT := f.Segment("__TEXT")
if __TEXT == nil {
return 0, errors.New("Found LC_MAIN but did not find __TEXT segment.")
}
entry = f.ByteOrder.Uint64(data[8:16]) + __TEXT.Addr
return entry, nil
}
}
return 0, errors.New("Could not find entry point.")
}
开发者ID:practicalswift,项目名称:usercorn,代码行数:28,代码来源:macho.go
示例2: printFileInformation
func printFileInformation(f *macho.File) {
log.Printf("ByteOrder: %s", f.ByteOrder)
printHeader(&f.FileHeader)
// Also f.FileHeader.Ncmd
log.Printf("file has %d load commands", len(f.Loads))
log.Printf("file has %d sections", len(f.Sections))
printSections(f.Sections)
printSymtab(f.Symtab)
printDysymtab(f.Dysymtab)
printImportedLibraries(f.ImportedLibraries())
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:13,代码来源:macho.go
示例3: open
// Open an input file.
func open(name string) (*file, error) {
efile, err := Open(name)
var mfile *macho.File
if err != nil {
var merr error
mfile, merr = macho.Open(name)
if merr != nil {
return nil, err
}
}
r := &file{elf: efile, macho: mfile}
if efile != nil {
r.dwarf, err = efile.DWARF()
} else {
r.dwarf, err = mfile.DWARF()
}
if err != nil {
return nil, err
}
var syms []sym
if efile != nil {
esyms, err := efile.Symbols()
if err != nil {
return nil, err
}
syms = make([]sym, 0, len(esyms))
for _, s := range esyms {
if ST_TYPE(s.Info) == STT_FUNC {
syms = append(syms, sym{s.Name, uintptr(s.Value)})
}
}
} else {
syms = make([]sym, 0, len(mfile.Symtab.Syms))
for _, s := range mfile.Symtab.Syms {
syms = append(syms, sym{s.Name, uintptr(s.Value)})
}
}
r.symsByName = make([]sym, len(syms))
copy(r.symsByName, syms)
sort.Sort(symsByName(r.symsByName))
r.symsByAddr = syms
sort.Sort(symsByAddr(r.symsByAddr))
return r, nil
}
开发者ID:anuvazhayil,项目名称:HelloWorld_32bitOS,代码行数:51,代码来源:runtime.go
示例4: parseDebugLineInfo
func (dbp *Process) parseDebugLineInfo(exe *macho.File, wg *sync.WaitGroup) {
defer wg.Done()
if sec := exe.Section("__debug_line"); sec != nil {
debugLine, err := exe.Section("__debug_line").Data()
if err != nil {
fmt.Println("could not get __debug_line section", err)
os.Exit(1)
}
dbp.lineInfo = line.Parse(debugLine)
} else {
fmt.Println("could not find __debug_line section in binary")
os.Exit(1)
}
}
开发者ID:alaska,项目名称:delve,代码行数:15,代码来源:proc_darwin.go
示例5: parseDebugFrame
func (dbp *Process) parseDebugFrame(exe *macho.File, wg *sync.WaitGroup) {
defer wg.Done()
if sec := exe.Section("__debug_frame"); sec != nil {
debugFrame, err := exe.Section("__debug_frame").Data()
if err != nil {
fmt.Println("could not get __debug_frame section", err)
os.Exit(1)
}
dbp.frameEntries = frame.Parse(debugFrame)
} else {
fmt.Println("could not find __debug_frame section in binary")
os.Exit(1)
}
}
开发者ID:alaska,项目名称:delve,代码行数:15,代码来源:proc_darwin.go
示例6: main
//============================================================================
// main : Entry point.
//----------------------------------------------------------------------------
func main() {
var dwarfData *dwarf.Data
var theFile *macho.File
var theErr os.Error
var relativeAddress uint64
var runtimeAddress uint64
var loadAddress uint64
var segmentAddress uint64
var pathMacho string
var pathDsym string
// Parse our arguments
flag.Uint64Var(&runtimeAddress, "raddr", 0, "")
flag.Uint64Var(&loadAddress, "laddr", 0, "")
flag.StringVar(&pathMacho, "macho", "", "")
flag.StringVar(&pathDsym, "dsym", "", "")
flag.Parse()
if runtimeAddress == 0 || loadAddress == 0 || pathMacho == "" || pathDsym == "" {
printHelp()
}
// Find the text segment address
theFile, theErr = macho.Open(pathMacho)
if theErr != nil {
fatalError("Can't open Mach-O file: " + theErr.String())
}
segmentAddress = theFile.Segment("__TEXT").Addr
theFile.Close()
// Calculate the target address
relativeAddress = runtimeAddress - loadAddress
gTargetAddress = segmentAddress + relativeAddress
// Find the target
theFile, theErr = macho.Open(pathDsym)
if theErr != nil {
fatalError("Can't open .dsym file: " + theErr.String())
}
dwarfData, theErr = theFile.DWARF()
if theErr != nil {
fatalError("Can't find DWARF info: " + theErr.String())
}
processChildren(dwarfData.Reader(), 0, false)
theFile.Close()
}
开发者ID:refnum,项目名称:gatos,代码行数:55,代码来源:gatos.go
示例7: obtainGoSymbols
func (dbp *Process) obtainGoSymbols(exe *macho.File, wg *sync.WaitGroup) {
defer wg.Done()
var (
symdat []byte
pclndat []byte
err error
)
if sec := exe.Section("__gosymtab"); sec != nil {
symdat, err = sec.Data()
if err != nil {
fmt.Println("could not get .gosymtab section", err)
os.Exit(1)
}
}
if sec := exe.Section("__gopclntab"); sec != nil {
pclndat, err = sec.Data()
if err != nil {
fmt.Println("could not get .gopclntab section", err)
os.Exit(1)
}
}
pcln := gosym.NewLineTable(pclndat, exe.Section("__text").Addr)
tab, err := gosym.NewTable(symdat, pcln)
if err != nil {
fmt.Println("could not get initialize line table", err)
os.Exit(1)
}
dbp.goSymTable = tab
}
开发者ID:alaska,项目名称:delve,代码行数:34,代码来源:proc_darwin.go
注:本文中的debug/macho.File类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论