#!/bin/sh
#
# Check whether linker can handle cross-segment @segrel():
#
CC=$1
LD=$2
OBJDUMP=$3
dir=$(dirname $0)
tmp=${TMPDIR:-/tmp}
out=$tmp/out$$
$CC -c $dir/check-segrel.S -o $out.o
$LD -static -T$dir/check-segrel.lds $out.o -o $out
res=$($OBJDUMP --full --section .rodata $out | fgrep 000 | cut -f3 -d' ')
rm -f $out $out.o
if [ $res != 00000a00 ]; then
    echo " -DHAVE_BUGGY_SEGREL"
    cat >&2 <<EOF
warning: your linker cannot handle cross-segment segment-relative relocations.
         please upgrade to a newer version (it is safe to use this linker, but
         the kernel will be bigger than strictly necessary).
EOF
fi
