gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/ldd/ldso_linux.go (about)

     1  // Copyright 2017-2018 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  	bits := 32
    15  	if bit64 {
    16  		bits = 64
    17  	}
    18  	choices := []string{fmt.Sprintf("/lib%d/ld-*.so.*", bits), "/lib/ld-*.so.*"}
    19  	for _, d := range choices {
    20  		n, err := filepath.Glob(d)
    21  		if err != nil {
    22  			return "", err
    23  		}
    24  		if len(n) > 0 {
    25  			return n[0], nil
    26  		}
    27  	}
    28  	return "", fmt.Errorf("could not find ld.so in %v", choices)
    29  }