github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/ldd/ldso_freebsd.go (about)

     1  // Copyright 2017-2019 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package ldd
     6  
     7  import (
     8  	"fmt"
     9  	"path/filepath"
    10  )
    11  
    12  // LdSo finds the loader binary.
    13  func LdSo(bit64 bool) (string, error) {
    14  	path := "/libexec/ld-elf32.so.*"
    15  	if bit64 {
    16  		path = "/libexec/ld-elf.so.*"
    17  	}
    18  	n, err := filepath.Glob(path)
    19  	if err != nil {
    20  		return "", err
    21  	}
    22  	if len(n) > 0 {
    23  		return n[0], nil
    24  	}
    25  	return "", fmt.Errorf("could not find ld.so in %v", path)
    26  }