18c2ecf20Sopenharmony_ci#!/bin/sh 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 38c2ecf20Sopenharmony_ci# 48c2ecf20Sopenharmony_ci# Check whether linker can handle cross-segment @segrel(): 58c2ecf20Sopenharmony_ci# 68c2ecf20Sopenharmony_ciCPPFLAGS="" 78c2ecf20Sopenharmony_ciCC=$1 88c2ecf20Sopenharmony_ciOBJDUMP=$2 98c2ecf20Sopenharmony_ciREADELF=$3 108c2ecf20Sopenharmony_cidir=$(dirname $0) 118c2ecf20Sopenharmony_citmp=${TMPDIR:-/tmp} 128c2ecf20Sopenharmony_ciout=$tmp/out$$ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci# Check whether cross-segment segment-relative relocs work fine. We need 158c2ecf20Sopenharmony_ci# that for building the gate DSO: 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci$CC -nostdlib -static -Wl,-T$dir/check-segrel.lds $dir/check-segrel.S -o $out 188c2ecf20Sopenharmony_cires=$($OBJDUMP --full --section .rodata $out | fgrep 000 | cut -f3 -d' ') 198c2ecf20Sopenharmony_cirm -f $out 208c2ecf20Sopenharmony_ciif [ $res != 00000a00 ]; then 218c2ecf20Sopenharmony_ci CPPFLAGS="$CPPFLAGS -DHAVE_BUGGY_SEGREL" 228c2ecf20Sopenharmony_ci cat >&2 <<EOF 238c2ecf20Sopenharmony_ciwarning: your linker cannot handle cross-segment segment-relative relocations. 248c2ecf20Sopenharmony_ci please upgrade to a newer version (it is safe to use this linker, but 258c2ecf20Sopenharmony_ci the kernel will be bigger than strictly necessary). 268c2ecf20Sopenharmony_ciEOF 278c2ecf20Sopenharmony_cifi 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci# Check whether .align inside a function works as expected. 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci$CC -c $dir/check-text-align.S -o $out 328c2ecf20Sopenharmony_ci$READELF -u $out | fgrep -q 'prologue(rlen=12)' 338c2ecf20Sopenharmony_cires=$? 348c2ecf20Sopenharmony_cirm -f $out 358c2ecf20Sopenharmony_ciif [ $res -eq 0 ]; then 368c2ecf20Sopenharmony_ci CPPFLAGS="$CPPFLAGS -DHAVE_WORKING_TEXT_ALIGN" 378c2ecf20Sopenharmony_cifi 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciif ! $CC -c $dir/check-model.c -o $out 2>&1 | grep __model__ | grep -q attrib 408c2ecf20Sopenharmony_cithen 418c2ecf20Sopenharmony_ci CPPFLAGS="$CPPFLAGS -DHAVE_MODEL_SMALL_ATTRIBUTE" 428c2ecf20Sopenharmony_cifi 438c2ecf20Sopenharmony_cirm -f $out 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci# Check whether assembler supports .serialize.{data,instruction} directive. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci$CC -c $dir/check-serialize.S -o $out 2>/dev/null 488c2ecf20Sopenharmony_cires=$? 498c2ecf20Sopenharmony_cirm -f $out 508c2ecf20Sopenharmony_ciif [ $res -eq 0 ]; then 518c2ecf20Sopenharmony_ci CPPFLAGS="$CPPFLAGS -DHAVE_SERIALIZE_DIRECTIVE" 528c2ecf20Sopenharmony_cifi 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ciecho $CPPFLAGS 55