toolchain-flags 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. #
  3. # Check whether linker can handle cross-segment @segrel():
  4. #
  5. CPPFLAGS=""
  6. CC=$1
  7. OBJDUMP=$2
  8. READELF=$3
  9. dir=$(dirname $0)
  10. tmp=${TMPDIR:-/tmp}
  11. out=$tmp/out$$
  12. # Check whether cross-segment segment-relative relocs work fine. We need
  13. # that for building the gate DSO:
  14. $CC -nostdlib -static -Wl,-T$dir/check-segrel.lds $dir/check-segrel.S -o $out
  15. res=$($OBJDUMP --full --section .rodata $out | fgrep 000 | cut -f3 -d' ')
  16. rm -f $out
  17. if [ $res != 00000a00 ]; then
  18. CPPFLAGS="$CPPFLAGS -DHAVE_BUGGY_SEGREL"
  19. cat >&2 <<EOF
  20. warning: your linker cannot handle cross-segment segment-relative relocations.
  21. please upgrade to a newer version (it is safe to use this linker, but
  22. the kernel will be bigger than strictly necessary).
  23. EOF
  24. fi
  25. # Check whether .align inside a function works as expected.
  26. $CC -c $dir/check-text-align.S -o $out
  27. $READELF -u $out | fgrep -q 'prologue(rlen=12)'
  28. res=$?
  29. rm -f $out
  30. if [ $res -eq 0 ]; then
  31. CPPFLAGS="$CPPFLAGS -DHAVE_WORKING_TEXT_ALIGN"
  32. fi
  33. if ! $CC -c $dir/check-model.c -o $out 2>&1 | grep __model__ | grep -q attrib
  34. then
  35. CPPFLAGS="$CPPFLAGS -DHAVE_MODEL_SMALL_ATTRIBUTE"
  36. fi
  37. rm -f $out
  38. # Check whether assembler supports .serialize.{data,instruction} directive.
  39. $CC -c $dir/check-serialize.S -o $out 2>/dev/null
  40. res=$?
  41. rm -f $out
  42. if [ $res -eq 0 ]; then
  43. CPPFLAGS="$CPPFLAGS -DHAVE_SERIALIZE_DIRECTIVE"
  44. fi
  45. echo $CPPFLAGS