toolchain-flags 1.4 KB

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