Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh -eu
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 tmp_file=$(mktemp)
0005 trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT
0006 
0007 cat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1
0008 void *p = &p;
0009 END
0010 $LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr \
0011   --use-android-relr-tags -o $tmp_file
0012 
0013 # Despite printing an error message, GNU nm still exits with exit code 0 if it
0014 # sees a relr section. So we need to check that nothing is printed to stderr.
0015 test -z "$($NM $tmp_file 2>&1 >/dev/null)"
0016 
0017 $OBJCOPY -O binary $tmp_file $tmp_file.bin