Back to home page

LXR

 
 

    


0001 #!/bin/sh
0002 #
0003 # Check whether linker can handle cross-segment @segrel():
0004 #
0005 CPPFLAGS=""
0006 CC=$1
0007 OBJDUMP=$2
0008 READELF=$3
0009 dir=$(dirname $0)
0010 tmp=${TMPDIR:-/tmp}
0011 out=$tmp/out$$
0012 
0013 # Check whether cross-segment segment-relative relocs work fine.  We need
0014 # that for building the gate DSO:
0015 
0016 $CC -nostdlib -static -Wl,-T$dir/check-segrel.lds $dir/check-segrel.S -o $out
0017 res=$($OBJDUMP --full --section .rodata $out | fgrep 000 | cut -f3 -d' ')
0018 rm -f $out
0019 if [ $res != 00000a00 ]; then
0020     CPPFLAGS="$CPPFLAGS -DHAVE_BUGGY_SEGREL"
0021     cat >&2 <<EOF
0022 warning: your linker cannot handle cross-segment segment-relative relocations.
0023          please upgrade to a newer version (it is safe to use this linker, but
0024          the kernel will be bigger than strictly necessary).
0025 EOF
0026 fi
0027 
0028 # Check whether .align inside a function works as expected.
0029 
0030 $CC -c $dir/check-text-align.S -o $out
0031 $READELF -u $out | fgrep -q 'prologue(rlen=12)'
0032 res=$?
0033 rm -f $out
0034 if [ $res -eq 0 ]; then
0035     CPPFLAGS="$CPPFLAGS -DHAVE_WORKING_TEXT_ALIGN"
0036 fi
0037 
0038 if ! $CC -c $dir/check-model.c -o $out 2>&1 | grep  __model__ | grep -q attrib
0039 then
0040     CPPFLAGS="$CPPFLAGS -DHAVE_MODEL_SMALL_ATTRIBUTE"
0041 fi
0042 rm -f $out
0043 
0044 # Check whether assembler supports .serialize.{data,instruction} directive.
0045 
0046 $CC -c $dir/check-serialize.S -o $out 2>/dev/null
0047 res=$?
0048 rm -f $out
0049 if [ $res -eq 0 ]; then
0050     CPPFLAGS="$CPPFLAGS -DHAVE_SERIALIZE_DIRECTIVE"
0051 fi
0052 
0053 echo $CPPFLAGS