isa-l/tools/nasm-cet-filter.sh
H.J. Lu 8074e3fe1b x86: Generate .note.gnu.property section for ELF output
We should generate .note.gnu.property section with x86 assembly codes
for ELF outputs to mark Intel CET support when Intel CET is enabled
since all input files must be marked with Intel CET support in order
for linker to mark output with Intel CET support.  Since nasm and yasm
can't generate the proper .note.gnu.property section, yasm-cet-filter.sh
and yasm-filter.sh are added to generate the proper .note.gnu.property
with linker help.

Verified with

$ CC="gcc -Wl,-z,cet-report=error -fcf-protection" CXX="g++ -Wl,-z,cet-report=error -fcf-protection" .../configure x86_64-linux
$ make -j8

on Linux/x86-64.

Change-Id: I14e03a8a9031c8397dc36939a528cf5a827d775a
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2020-05-26 17:12:01 -07:00

57 lines
961 B
Bash
Executable File

#/bin/sh
# Filter out unnecessary options added by automake
while [ -n "$*" ]; do
case "$1" in
-o )
# Supported options with arg
options="$options $1 $2"
shift
object="$1"
shift
;;
-f | -D )
# Supported options with arg
options="$options $1 $2"
shift
shift
;;
-I | -i )
options="$options $1 $2/"
shift
shift
;;
--prefix* )
# Supported options without arg
options="$options $1"
shift
;;
-I* | -i* )
options="$options $1/"
shift
;;
-D* ) # For defines we need to remove spaces
case "$1" in
*' '* ) ;;
*) options="$options $1" ;;
esac
shift
;;
#-blah )
# Unsupported options with args - none known
-* )
# Unsupported options with no args
shift
;;
* )
args="$args $1"
shift
;;
esac
done
nasm $options $args
$CET_LD -r -z ibt -z shstk -o $object.tmp $object
mv $object.tmp $object