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