findObjdump finds and returns path to preferred objdump binary. Order of preference is: llvm-objdump, objdump. On MacOS only, also looks for gobjdump with least preference. Accepts a list of paths and returns: a string with path to the preferred objdump binary if found, or an empty string if not fou
(paths []string)
| 161 | // a boolean if any acceptable objdump was found; |
| 162 | // a boolean indicating if it is an LLVM objdump. |
| 163 | func findObjdump(paths []string) (string, bool, bool) { |
| 164 | objdumpNames := []string{"llvm-objdump", "objdump"} |
| 165 | if runtime.GOOS == "darwin" { |
| 166 | objdumpNames = append(objdumpNames, "gobjdump") |
| 167 | } |
| 168 | |
| 169 | for _, objdumpName := range objdumpNames { |
| 170 | if objdump, objdumpFound := findExe(objdumpName, paths); objdumpFound { |
| 171 | cmdOut, err := exec.Command(objdump, "--version").Output() |
| 172 | if err != nil { |
| 173 | continue |
| 174 | } |
| 175 | if isLLVMObjdump(string(cmdOut)) { |
| 176 | return objdump, true, true |
| 177 | } |
| 178 | if isBuObjdump(string(cmdOut)) { |
| 179 | return objdump, true, false |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | return "", false, false |
| 184 | } |
| 185 | |
| 186 | // chooseExe finds and returns path to preferred binary. names is a list of |
| 187 | // names to search on both Linux and OSX. osxNames is a list of names specific |
searching dependent graphs…