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 }
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) } }