本文整理匯總了Golang中debug/elf.File.DynString方法的典型用法代碼示例。如果您正苦於以下問題:Golang File.DynString方法的具體用法?Golang File.DynString怎麽用?Golang File.DynString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類debug/elf.File
的用法示例。
在下文中一共展示了File.DynString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: blacklisted
func blacklisted(file string, obj *elf.File) (bool, error) {
lib := regexp.MustCompile(`^.*/lib([\w-]+)\.so[\d.]*$`)
glcore := regexp.MustCompile(`libnvidia-e?glcore\.so`)
gldispatch := regexp.MustCompile(`libGLdispatch\.so`)
if m := lib.FindStringSubmatch(file); m != nil {
switch m[1] {
// Blacklist EGL/OpenGL libraries issued by other vendors
case "EGL":
fallthrough
case "GLESv1_CM":
fallthrough
case "GLESv2":
fallthrough
case "GL":
deps, err := obj.DynString(elf.DT_NEEDED)
if err != nil {
return false, err
}
for _, d := range deps {
if glcore.MatchString(d) || gldispatch.MatchString(d) {
return false, nil
}
}
return true, nil
// Blacklist TLS libraries using the old ABI (!= 2.3.99)
case "nvidia-tls":
const abi = 0x6300000003
s, err := obj.Section(".note.ABI-tag").Data()
if err != nil {
return false, err
}
return binary.LittleEndian.Uint64(s[24:]) != abi, nil
}
}
return false, nil
}
示例2: dump_dynstr
func dump_dynstr(file *elf.File) {
fmt.Printf("DynStrings:\n")
dynstrs, _ := file.DynString(elf.DT_NEEDED)
for _, e := range dynstrs {
fmt.Printf("\t%s\n", e)
}
dynstrs, _ = file.DynString(elf.DT_SONAME)
for _, e := range dynstrs {
fmt.Printf("\t%s\n", e)
}
dynstrs, _ = file.DynString(elf.DT_RPATH)
for _, e := range dynstrs {
fmt.Printf("\t%s\n", e)
}
dynstrs, _ = file.DynString(elf.DT_RUNPATH)
for _, e := range dynstrs {
fmt.Printf("\t%s\n", e)
}
}