summaryrefslogtreecommitdiff
path: root/nix/ld-utils.nix
blob: 6201b63124b1e6754a50ca2594ae594fa2e2e5a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# ld-utils is a collection of functions which are intended to be sourced into
# other scripts
pkgs: pkgs.writeShellScript "ld-utils.sh" ''

# returns the colon-delimited LD_LIBRARY_PATH for host installed libraries, as
# determined by ldconfig.
function host_ld_lib_path {
  ldconfig -v 2>/dev/null \
  | grep -v ^$'\t' \
  | cut -d':' -f1 \
  | tr -s ':\n' ':' \
  | head -c-1
}

# bin_ld_lib_path returns the colon-delimited LD_LIBRARY_PATH which is embedded
# into a particular binary as its RUNPATH.
function bin_ld_lib_path {
  objdump -x "$1" \
  | grep "RUNPATH" \
  | awk '{print $2}'
}
''