Skip to content

Commit d5dcac4

Browse files
committed
Add -z nobtcfi linker option if needed and supported
Recent versions of OpenBSD on recent x86 processors activate IBT control-flow integrity checks by default. The code generated by CompCert is not IBT conformant yet.
1 parent ce0f6ca commit d5dcac4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

configure

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ casmruntime=""
229229
clinker="${toolprefix}gcc"
230230
clinker_options=""
231231
clinker_needs_no_pie=true
232+
clinker_needs_nobtcfi=false
232233
cprepro="${toolprefix}gcc"
233234
cprepro_options="-E"
234235
archiver="${toolprefix}ar rcs"
@@ -358,6 +359,7 @@ if test "$arch" = "x86" -a "$bitsize" = "64"; then
358359
cprepro_options="-m64 -U__GNUC__ -U__SIZEOF_INT128__ -E"
359360
system="bsd"
360361
pic_supported=true
362+
clinker_needs_nobtcfi=true
361363
;;
362364
linux)
363365
abi="standard"
@@ -467,7 +469,7 @@ int main (void)
467469
EOF
468470
errout=$("$@" -o "$tmpout" "$tmpsrc" 2>&1 >/dev/null)
469471
retcode=$?
470-
errcount=$(echo "${errout}" | grep -ciE "(unknown|unsupported|unrecognized).*(option|argument)")
472+
errcount=$(echo "${errout}" | grep -ciE "(unknown|unsupported|unrecognized|ignored)")
471473
rm -f "$tmpsrc" "$tmpout"
472474
# Test failed or error is logged to stderr
473475
if [ "${retcode}" != "0" ] || [ "${errcount}" != "0" ]; then return 1; fi
@@ -512,6 +514,18 @@ if ($clinker_needs_no_pie) then
512514
fi
513515
fi
514516

517+
#
518+
# Test Availability of Option '-z nobtcfi' or '-Wl,-z,nobtcfi'
519+
#
520+
if ($clinker_needs_nobtcfi) then
521+
echo "Testing linker support for 'nobtcfi' option... " | tr -d '\n'
522+
if testcompiler ${cc} -z nobtcfi;
523+
then echo "yes, '-z nobtcfi'"; clinker_options="${clinker_options} -z nobtcfi"
524+
elif testcompiler ${cc} -Wl,-z,nobtcfi;
525+
then echo "yes, '-Wl,-z,nobtcfi'"; clinker_options="${clinker_options} -Wl,-z,nobtcfi"
526+
else echo "no"
527+
fi
528+
fi
515529

516530
#
517531
# Test Availability of Required Tools

0 commit comments

Comments
 (0)