/usr/share/libhugetlbfs/ld.hugetlbfs is in libhugetlbfs-dev 2.17-0ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #! /bin/bash
# Paranoid check to make sure we don't reinvoke ourselves, effectively
# making a fork()bomb
if [ -n "$LD_HUGETLBFS_RECURSION" ]; then
exit 99
fi
export LD_HUGETLBFS_RECURSION=1
HUGETLB_LDSCRIPT_PATH=/usr/share/libhugetlbfs/ldscripts
if [ -z "$HUGETLB_LDSCRIPT_PATH" ]; then
# Assume this script is running from the libhugetlbfs source tree,
# and look for the ldscripts accordingly
HUGETLB_LDSCRIPT_PATH=$(dirname $(readlink $0))/ldscripts
fi
CUSTOM_LDSCRIPTS="yes"
if [ -z "$CUSTOM_LDSCRIPTS" ]; then
# Assume this script is running from the libhugetlbfs source tree,
# and set CUSTOM_LDSCRIPTS to default "yes"
CUSTOM_LDSCRIPTS="yes"
fi
# Try to figure out what's the underlying linker to invoke
if [ -z "$LD" ]; then
for x in $(which -a ld); do
if [ "$x" != "$0" ]; then
LD="$x"
break
fi
done
fi
i=0
while [ -n "$1" ]; do
arg="$1"
case "$arg" in
-m*)
EMU="${arg#-m}"
args[$i]="$arg"
i=$[i+1]
if [ -z "$EMU" ]; then
shift
EMU="$1"
args[$i]="$1"
i=$[i+1]
fi
;;
--hugetlbfs-link=*)
if [ -z "$HUGETLB_DEPRECATED_LINK" ]; then
echo -n "ld.hugetlbfs: --hugetlbfs-link is deprecated. " 1>&2
echo "Migrate to --hugetlbfs-align." 1>&2
fi
HTLB_LINK="${arg#--hugetlbfs-link=}"
;;
--hugetlbfs-script-path=*)
HUGETLB_LDSCRIPT_PATH="${arg#--hugetlbfs-script-path=}"
;;
--hugetlbfs-align)
HTLB_ALIGN="slice"
;;
--)
args=("${args[@]}" "$@")
break
;;
*)
args[$i]="$arg"
i=$[i+1]
;;
esac
shift
done
if [ -n "$HTLB_LINK" ]; then
if [ "$CUSTOM_LDSCRIPTS" == "no" ]; then
echo -n "ld.hugetlbfs: --hugetlbfs-link is not supported on this " 1>&2
echo "platform. Use --hugetlbfs-align instead." 1>&2
fi
HTLB_ALIGN="" # --hugetlbfs-link overrides --hugetlbfs-align
LDSCRIPT="$EMU.x$HTLB_LINK"
HTLBOPTS="-T${HUGETLB_LDSCRIPT_PATH}/${LDSCRIPT}"
fi
MB=$((1024*1024))
case "$EMU" in
elf32ppclinux|elf64ppc) HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
elf_i386|elf_x86_64) HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
elf_s390|elf64_s390) HPAGE_SIZE=$((1*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
armelf_linux_eabi|aarch64elf) HPAGE_SIZE=$((2*MB)) SLICE_SIZE=$HPAGE_SIZE ;;
esac
if [ "$HTLB_ALIGN" == "slice" ]; then
HTLBOPTS="-zcommon-page-size=$SLICE_SIZE -zmax-page-size=$SLICE_SIZE"
HTLBOPTS="$HTLBOPTS -lhugetlbfs"
# targeting the ARM platform one needs to explicitly set the text segment offset
# otherwise it will be NULL.
if [ "$EMU" == "armelf_linux_eabi" ]; then
HTLBOPTS="$HTLBOPTS -Ttext-segment=$SLICE_SIZE"
fi
fi
${LD} "${args[@]}" ${HTLBOPTS}
|