summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2015-12-25 02:25:51 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2015-12-25 02:25:51 +0800
commit91eebb25259df06c4719ad33c82b452a95d232c7 (patch)
tree1e25a70bed1f2e011eeba9dd009e0701f7697e0a
parentdb48bef30295f66d062e871ba4eed391640fb694 (diff)
add static_compile.sh help to generate the static binary
with NDK and gcc toolchain only Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rw-r--r--android-tools/static-binary/src/Makefile.64198
-rw-r--r--android-tools/static-binary/src/Makefile.64.good208
-rwxr-xr-xandroid-tools/static-binary/src/static_compile.sh235
3 files changed, 581 insertions, 60 deletions
diff --git a/android-tools/static-binary/src/Makefile.64 b/android-tools/static-binary/src/Makefile.64
index 2e95f7d..ab2efcd 100644
--- a/android-tools/static-binary/src/Makefile.64
+++ b/android-tools/static-binary/src/Makefile.64
@@ -1,60 +1,122 @@
BASE=/data/armv8/marshmallow/
NDK=/SATA3/android-ndk-r10e/
-
-
SYSROOT=$(NDK)/platforms/android-21/arch-arm64/
-# Do NOT use double quotes around CC, i.e. CC="bla bla"
TOOLCHAIN_GOOGLE_64=$(BASE)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
INCLUDE_GOOGLE_64=$(OOLCHAIN_GOOGLE_64)/lib/gcc/aarch64-linux-android/4.9.x-google/include
-CC_google_64=$(TOOLCHAIN_LINARO_64)/bin/aarch64-linux-android-gcc --sysroot=$(SYSROOT)
+CC_google_64=$(TOOLCHAIN_GOOGLE_64)/bin/aarch64-linux-android-gcc
TOOLCHAIN_LINARO_64=$(BASE)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-5.3-linaro/
INCLUDE_LINARO_64=$(OOLCHAIN_LINARO_64)/lib/gcc/aarch64-linux-android/5.3.0/include
-CC_linaro_64=$(TOOLCHAIN_LINARO_64)/bin/aarch64-linux-android-gcc --sysroot=$(SYSROOT) -I$(NDK)/platforms/android-21/arch-arm/usr/include
-
-#using linaro src tree hdr stead o ndk sysroot
-#CC_linaro=$(TOOLCHAIN_LINARO)/bin/arm-linux-androideabi-gcc -I$(BASE)/tkts/1491/bionic_linaro/libc/include -I$(BASE)/tkts/1491/bionic_linaro/libc/kernel/uapi -I$(BASE)/tkts/1491/bionic_linaro/libc/kernel/uapi/asm-arm
-
-
-FILTER=$(filter-out Makefile.64, $^)
-
-TARGET_GLOBAL_CFLAGS := -Wl,--no-undefined
-TARGET_GLOBAL_CFLAGS += \
- -fno-strict-aliasing \
- -fstack-protector \
- -ffunction-sections \
- -fdata-sections \
- -funwind-tables \
- -Wa,--noexecstack \
- -Wformat \
- -Werror=format-security \
- -D_FORTIFY_SOURCE=2 \
- -fno-short-enums \
- -no-canonical-prefixes \
- -fno-canonical-system-headers \
- -mcpu=cortex-a53
- -Werror=pointer-to-int-cast \
- -Werror=int-to-pointer-cast \
- -Werror=implicit-function-declaration \
- -fno-strict-volatile-bitfields \
- -Wno-psabi \
- -Wl,-z,noexecstack \
- -Wl,-z,relro \
- -Wl,-z,now \
- -Wl,--build-id=md5 \
- -Wl,--warn-shared-textrel \
- -Wl,--fatal-warnings \
- -Wl,-maarch64linux \
- -Wl,--hash-style=gnu \
- -Wl,--fix-cortex-a53-843419 \
- -Wl,--allow-shlib-undefined \
- -fvisibility-inlines-hidden \
- -O2
-
-CFLAGS2=-fPIE -pie
-CFLAGS=$(TARGET_GLOBAL_CFLAGS)
+CC_linaro_64=$(TOOLCHAIN_LINARO_64)/bin/aarch64-linux-android-gcc
+
+LDFLAGS_LIBS := \
+ -Wl,--start-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib/libc.a \
+ $(TOOLCHAIN_GOOGLE_64)/aarch64-linux-android/lib64/libatomic.a $(TOOLCHAIN_GOOGLE_64)/lib/gcc/aarch64-linux-android/4.9.x-google/libgcc.a \
+ $(TOOLCHAIN_LINARO_64)/aarch64-linux-android/lib64/libatomic.a $(TOOLCHAIN_LINARO_64)/lib/gcc/aarch64-linux-android/5.3.0/libgcc.a \
+ -Wl,--end-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib-bootstrap/crtend_android.o \
+ -Lout/target/product/hikey/obj/lib out/target/product/hikey/obj/lib/crtbegin_static.o
+
+# out/target/product/hikey/obj/STATIC_LIBRARIES/libdl_intermediates/libdl.a \
+ out/target/product/hikey/obj/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a
+
+CFLAGS_INCLUDES := \
+ -isystem $(BASE)/bionic/libc/arch-arm64/include \
+ -isystem $(BASE)/bionic/libc/include \
+ -isystem $(BASE)/bionic/libc/kernel/uapi \
+ -isystem $(BASE)/bionic/libc/kernel/uapi/asm-arm64 \
+ -isystem $(BASE)/bionic/libm/include \
+ -isystem $(BASE)/bionic/libm/include/arm64 \
+ -include $(BASE)/build/core/combo/include/arch/linux-arm64/AndroidConfig.h \
+ -I $(BASE)/build/core/combo/include/arch/linux-arm64/ \
+
+# -I external/libcxx/include \
+ -I libnativehelper/include/nativehelper \
+ -isystem system/core/include \
+ -isystem system/media/audio/include \
+ -isystem hardware/libhardware/include \
+ -isystem hardware/libhardware_legacy/include \
+ -isystem hardware/ril/include \
+ -isystem libnativehelper/include \
+ -isystem frameworks/native/include \
+ -isystem frameworks/native/opengl/include \
+ -isystem frameworks/av/include \
+ -isystem frameworks/base/include \
+ -isystem out/target/product/hikey/obj/include \
+
+CFLAGS_OPTIONS_GOOD := \
+ -fno-strict-aliasing \
+ -fstack-protector \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -Wa,--noexecstack \
+ -Wformat \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -fno-short-enums \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ -mcpu=cortex-a53 \
+ -Werror=pointer-to-int-cast \
+ -Werror=int-to-pointer-cast \
+ -Werror=implicit-function-declaration \
+ -fno-strict-volatile-bitfields \
+ -Wno-psabi \
+ -std=c11 \
+ -O2
+
+CFLAGS_OPTIONS_EXTRA := \
+ -fno-exceptions \
+ -Wno-multichar \
+ -DANDROID \
+ -fmessage-length=0 \
+ -W \
+ -Wall \
+ -Wno-unused \
+ -Winit-self \
+ -Wpointer-arith \
+ -Werror=return-type \
+ -Werror=non-virtual-dtor \
+ -Werror=address \
+ -Werror=sequence-point \
+ -DNDEBUG \
+ -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -DNDEBUG \
+ -UDEBUG \
+ -fpie \
+ -D_USING_LIBCXX \
+ -Werror=int-to-pointer-cast \
+ -Werror=pointer-to-int-cast \
+
+CFLAGS_OPTIONS := $(CFLAGS_OPTIONS_GOOD) $(CFLAGS_OPTIONS_EXTRA)
+CFLAGS := $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS)
+
+LDFLAGS_OPTIONS_GOOD := \
+ -Wl,-z,noexecstack \
+ -Wl,-z,relro \
+ -Wl,-z,now \
+ -Wl,--build-id=md5 \
+ -Wl,--warn-shared-textrel \
+ -Wl,--fatal-warnings \
+ -Wl,-maarch64linux \
+ -Wl,--hash-style=gnu \
+ -Wl,--fix-cortex-a53-843419 \
+ -Wl,--allow-shlib-undefined \
+ -Wl,--no-undefined \
+
+LDFLAGS_OPTIONS_EXTRA := \
+ -nostdlib \
+ -Wl,--gc-sections \
+ -Wl,--whole-archive \
+ -Wl,--no-whole-archive \
+
+LDFLAGS_OPTIONS := $(LDFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_EXTRA)
all: strcpy_test_linaro \
strcpy_test_linaro_static \
@@ -97,11 +159,11 @@ all: strcpy_test_linaro \
# -mfloat-abi=name
# Specifies which floating-point ABI to use. Permissible values are: soft, softfp and hard.
# soft causes GCC to generate output containing library calls for floating-point operations.
-# softfp allows the generation of code using hardware floating-point instructions, but still uses the soft-float calling conventions.
+# softfp allows the generation of code using hardware floating-point instructions, but still uses the soft-float calling conventions.
# hard allows generation of floating-point instructions and uses FPU-specific calling conventions.
#
# The default depends on the specific target configuration.
-# Note that the hard-float and soft-float ABIs are not link-compatible;
+# Note that the hard-float and soft-float ABIs are not link-compatible;
# you must compile your entire program with the same ABI, and link with a compatible set of libraries.
# -msoft-float
@@ -116,25 +178,41 @@ all: strcpy_test_linaro \
#src := main_strcpy.c Makefile.64 string_copy_linaro_wrapper.S string_copy_linaro.S string_copy_google_wrapper.S string_copy_google.S
-src := main_strcpy.c Makefile.64 string_copy_linaro_wrapper.S string_copy_google_wrapper.S
+src := main_strcpy.c string_copy_linaro_wrapper.S string_copy_google_wrapper.S
#src += asm/asm.h asm/bionic_asm.h asm/bitsperlong.h asm/unistd.h
## -mfloat-abi=softfp and -mhard-float are not supported by aarch64 gcc
strcpy_test_linaro_static: $(src)
- $(CC_linaro_64) $(CFLAGS) $(CFLAGS2) -static -Bstatic \
- $(FILTER) -o $@
-
-strcpy_test_linaro: $(src)
- $(CC_linaro_64) $(CFLAGS) $(CFLAGS2) \
- $(FILTER) -o $@
+ $(CC_linaro_64) $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_GOOD) \
+ -static -Bstatic \
+ $(CFLAGS_OPTIONS_EXTRA) $(LDFLAGS_OPTIONS_EXTRA) \
+ -Wl,--start-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib/libc.a \
+ $(TOOLCHAIN_LINARO_64)/aarch64-linux-android/lib64/libatomic.a $(TOOLCHAIN_LINARO_64)/lib/gcc/aarch64-linux-android/5.3.0/libgcc.a \
+ -Wl,--end-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib-bootstrap/crtend_android.o \
+ -L$(BASE)/out/target/product/hikey/obj/lib/crtbegin_static.o \
+ $^ -o $@
strcpy_test_google_static: $(src)
- $(CC_google_64) $(CFLAGS) $(CFLAGS2) -static -Bstatic \
- $(FILTER) -o $@
+ $(CC_google_64) $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_GOOD) \
+ -static -Bstatic \
+ $(CFLAGS_OPTIONS_EXTRA) $(LDFLAGS_OPTIONS_EXTRA) \
+ -Wl,--start-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib/libc.a \
+ $(TOOLCHAIN_GOOGLE_64)/aarch64-linux-android/lib64/libatomic.a $(TOOLCHAIN_GOOGLE_64)/lib/gcc/aarch64-linux-android/4.9.x-google/libgcc.a \
+ -Wl,--end-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib-bootstrap/crtend_android.o \
+ -L$(BASE)/out/target/product/hikey/obj/lib/crtbegin_static.o \
+ $^ -o $@
+
+strcpy_test_linaro: $(src)
+ $(CC_linaro_64) $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_GOOD) \
+ --sysroot=$(SYSROOT) \
+ -fPIE -pie \
+ $^ -o $@
strcpy_test_google: $(src)
- $(CC_google_64) $(CFLAGS) $(CFLAGS2) \
- $(FILTER) -o $@
+ $(CC_google_64) $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_GOOD) \
+ --sysroot=$(SYSROOT) \
+ -fPIE -pie \
+ $^ -o $@
move:
@mkdir -p bin/
diff --git a/android-tools/static-binary/src/Makefile.64.good b/android-tools/static-binary/src/Makefile.64.good
new file mode 100644
index 0000000..5977de3
--- /dev/null
+++ b/android-tools/static-binary/src/Makefile.64.good
@@ -0,0 +1,208 @@
+BASE=/data/armv8/marshmallow/
+NDK=/SATA3/android-ndk-r10e/
+
+SYSROOT=$(NDK)/platforms/android-21/arch-arm64/
+
+TOOLCHAIN_GOOGLE_64=$(BASE)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
+INCLUDE_GOOGLE_64=$(OOLCHAIN_GOOGLE_64)/lib/gcc/aarch64-linux-android/4.9.x-google/include
+CC_google_64=$(TOOLCHAIN_GOOGLE_64)/bin/aarch64-linux-android-gcc
+
+TOOLCHAIN_LINARO_64=$(BASE)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-5.3-linaro/
+INCLUDE_LINARO_64=$(OOLCHAIN_LINARO_64)/lib/gcc/aarch64-linux-android/5.3.0/include
+CC_linaro_64=$(TOOLCHAIN_LINARO_64)/bin/aarch64-linux-android-gcc
+
+CFLAGS_INCLUDES := \
+ -isystem $(BASE)/bionic/libc/arch-arm64/include \
+ -isystem $(BASE)/bionic/libc/include \
+ -isystem $(BASE)/bionic/libc/kernel/uapi \
+ -isystem $(BASE)/bionic/libc/kernel/uapi/asm-arm64 \
+ -isystem $(BASE)/bionic/libm/include \
+ -isystem $(BASE)/bionic/libm/include/arm64 \
+ -include $(BASE)/build/core/combo/include/arch/linux-arm64/AndroidConfig.h \
+ -I $(BASE)/build/core/combo/include/arch/linux-arm64/ \
+
+CFLAGS_OPTIONS_GOOD := \
+ -fno-strict-aliasing \
+ -fstack-protector \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -Wa,--noexecstack \
+ -Wformat \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -fno-short-enums \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ -mcpu=cortex-a53 \
+ -Werror=pointer-to-int-cast \
+ -Werror=int-to-pointer-cast \
+ -Werror=implicit-function-declaration \
+ -fno-strict-volatile-bitfields \
+ -Wno-psabi \
+ -std=c11 \
+ -O2
+
+CFLAGS_OPTIONS_EXTRA := \
+ -fno-exceptions \
+ -Wno-multichar \
+ -DANDROID \
+ -fmessage-length=0 \
+ -W \
+ -Wall \
+ -Wno-unused \
+ -Winit-self \
+ -Wpointer-arith \
+ -Werror=return-type \
+ -Werror=non-virtual-dtor \
+ -Werror=address \
+ -Werror=sequence-point \
+ -DNDEBUG \
+ -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -DNDEBUG \
+ -UDEBUG \
+ -fpie \
+ -D_USING_LIBCXX \
+ -Werror=int-to-pointer-cast \
+ -Werror=pointer-to-int-cast \
+
+LDFLAGS_OPTIONS_GOOD := \
+ -Wl,-z,noexecstack \
+ -Wl,-z,relro \
+ -Wl,-z,now \
+ -Wl,--build-id=md5 \
+ -Wl,--warn-shared-textrel \
+ -Wl,--fatal-warnings \
+ -Wl,-maarch64linux \
+ -Wl,--hash-style=gnu \
+ -Wl,--fix-cortex-a53-843419 \
+ -Wl,--allow-shlib-undefined \
+ -Wl,--no-undefined \
+
+LDFLAGS_OPTIONS_EXTRA := \
+ -Wl,--gc-sections \
+
+all: strcpy_test_linaro \
+ strcpy_test_linaro_static \
+ strcpy_test_google \
+ strcpy_test_google_static \
+ move
+
+#############################################################################
+############## meanings of GCC options ######################################
+#############################################################################
+# -I dir
+# Add the directory dir to the list of directories to be searched for header files.
+# Directories named by -I are searched before the standard system include directories.
+# If the directory dir is a standard system include directory, the option is ignored to ensure that the default search order for system directories and the special treatment of system headers are not defeated .
+# If dir begins with "=", then the "=" will be replaced by the sysroot prefix; see --sysroot and -isysroot.
+
+# -isystem dir
+# Search dir for header files, after all directories specified by -I but before the standard system directories.
+# Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories.
+# If dir begins with "=", then the "=" will be replaced by the sysroot prefix; see --sysroot and -isysroot.
+
+# -include file
+# Process file as if "#include "file"" appeared as the first line of the primary source file.
+# However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file.
+# If not found there, it is searched for in the remainder of the "#include "..."" search chain as normal.
+# If multiple -include options are given, the files are included in the order they appear on the command line.
+
+# -isysroot dir
+# This option is like the --sysroot option, but applies only to header files (except for Darwin targets, where it applies to both header files and libraries).
+# See the --sysroot option for more information
+
+# --sysroot=dir
+# Use dir as the logical root directory for headers and libraries.
+# For example, if the compiler normally searches for headers in /usr/include and libraries in /usr/lib,
+# it instead searches dir/usr/include and dir/usr/lib.
+# If you use both this option and the -isysroot option, then the --sysroot option applies to libraries, but the -isysroot option applies to header files.
+# The GNU linker (beginning with version 2.16) has the necessary support for this option.
+# If your linker does not support this option, the header file aspect of --sysroot still works, but the library aspect does not.
+
+# -mfloat-abi=name
+# Specifies which floating-point ABI to use. Permissible values are: soft, softfp and hard.
+# soft causes GCC to generate output containing library calls for floating-point operations.
+# softfp allows the generation of code using hardware floating-point instructions, but still uses the soft-float calling conventions.
+# hard allows generation of floating-point instructions and uses FPU-specific calling conventions.
+#
+# The default depends on the specific target configuration.
+# Note that the hard-float and soft-float ABIs are not link-compatible;
+# you must compile your entire program with the same ABI, and link with a compatible set of libraries.
+
+# -msoft-float
+# Use library routines for floating-point operations.
+
+# -mhard-float
+# Use hardware instructions for floating-point operations.
+
+# -static
+# On systems that support dynamic linking, this prevents linking with the shared libraries.
+# On other systems, this option has no effect.
+
+# -nostdlib
+# Do not use the standard system startup files or libraries when linking.
+# No startup files and only the libraries you specify are passed to the linker, and options specifying linkage of the system libraries,
+# such as "-static-libgcc" or "-shared-libgcc", are ignored.
+# The compiler may generate calls to "memcmp", "memset", "memcpy" and "memmove".
+# These entries are usually resolved by entries in libc.
+# These entry points should be supplied through some other mechanism when this option is specified.
+#
+# One of the standard libraries bypassed by -nostdlib and -nodefaultlibs is libgcc.a,
+# a library of internal subroutines which GCC uses to overcome shortcomings of particular machines, or special needs for some languages.
+# In most cases, you need libgcc.a even when you want to avoid other standard libraries.
+# In other words, when you specify -nostdlib or -nodefaultlibs you should usually specify -lgcc as well.
+# This ensures that you have no unresolved references to internal GCC library subroutines.
+# (An example of such an internal subroutine is __main, used to ensure C++ constructors are called.)
+
+# -pie
+# Produce a position independent executable on targets that support it.
+# For predictable results, you must also specify the same set of options used for compilation (-fpie, -fPIE, or model suboptions) when you specify this linker option.
+
+#src := main_strcpy.c Makefile.64 string_copy_linaro_wrapper.S string_copy_linaro.S string_copy_google_wrapper.S string_copy_google.S
+src := main_strcpy.c string_copy_linaro_wrapper.S string_copy_google_wrapper.S
+#src += asm/asm.h asm/bionic_asm.h asm/bitsperlong.h asm/unistd.h
+
+## -mfloat-abi=softfp and -mhard-float are not supported by aarch64 gcc
+strcpy_test_linaro_static: $(src)
+ $(CC_linaro_64) $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_GOOD) \
+ -nostdlib -static -Bstatic -static-libgcc -static-libstdc++ -lgcc\
+ $^ -o $@ \
+ /SATA3/android-ndk-r10e/platforms/android-21/arch-arm64/usr/lib/crtbegin_static.o \
+ -pie \
+ -Wl,--start-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib/libc.a \
+ $(TOOLCHAIN_LINARO_64)/lib/gcc/aarch64-linux-android/5.3.0/libgcc.a \
+ -Wl,--end-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib-bootstrap/crtend_android.o \
+
+strcpy_test_google_static: $(src)
+ $(CC_google_64) $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_GOOD) \
+ -nostdlib -static -Bstatic -static-libgcc -static-libstdc++ -lgcc\
+ $^ -o $@ \
+ /SATA3/android-ndk-r10e/platforms/android-21/arch-arm64/usr/lib/crtbegin_static.o \
+ -fPIE -pie \
+ -Wl,--start-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib/libc.a \
+ $(TOOLCHAIN_GOOGLE_64)/aarch64-linux-android/lib64/libatomic.a $(TOOLCHAIN_GOOGLE_64)/lib/gcc/aarch64-linux-android/4.9.x-google/libgcc.a \
+ -Wl,--end-group $(BASE)/development/ndk/platforms/android-21/arch-arm64/lib-bootstrap/crtend_android.o \
+
+strcpy_test_linaro: $(src)
+ $(CC_linaro_64) $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_GOOD) \
+ --sysroot=$(SYSROOT) \
+ -fPIE -pie \
+ $^ -o $@
+
+strcpy_test_google: $(src)
+ $(CC_google_64) $(CFLAGS_INCLUDES) $(CFLAGS_OPTIONS_GOOD) $(LDFLAGS_OPTIONS_GOOD) \
+ --sysroot=$(SYSROOT) \
+ -fPIE -pie \
+ $^ -o $@
+
+move:
+ @mkdir -p bin/
+ @mv strcpy_test* bin/
+
+clean:
+ rm -f bin/strcpy_test*
diff --git a/android-tools/static-binary/src/static_compile.sh b/android-tools/static-binary/src/static_compile.sh
new file mode 100755
index 0000000..84319a1
--- /dev/null
+++ b/android-tools/static-binary/src/static_compile.sh
@@ -0,0 +1,235 @@
+#!/bin/bash
+BASE="/home/liuyq/data/armv8/marshmallow/"
+NDK="/SATA3/android-ndk-r10e/"
+NDK_21_ARM64="${NDK}/platforms/android-21/arch-arm64/"
+TOOLCHAIN_GOOGLE_64="${BASE}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/"
+LIBGCC_GOOGLE=${TOOLCHAIN_GOOGLE_64}/lib/gcc/aarch64-linux-android/4.9.x-google/libgcc.a
+
+TOOLCHAIN_LINARO_64="${BASE}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-5.3-linaro/"
+LIBGCC_LINARO=${TOOLCHAIN_LINARO_64}/lib/gcc/aarch64-linux-android/5.3.0/libgcc.a
+
+function compile(){
+ local toolchain=$1
+ local libgcc=$2
+ local output=$3
+ if [ ! -x "${toolchain}/bin/aarch64-linux-android-gcc" ]; then
+ echo "gcc command does not exist under: ${toolchain}"
+ exit 1
+ fi
+ if [ ! -f "${libgcc}" ]; then
+ echo "file libgcc.a does not exist under: ${toolchain}"
+ exit 1
+ fi
+ if [ -z "${output}" ]; then
+ echo "Please specify the name for output file"
+ exit 1
+ fi
+ rm -vfr "${output}" main_strcpy.o string_copy_google_wrapper.o string_copy_linaro_wrapper.o
+
+ ${toolchain}/bin/aarch64-linux-android-gcc \
+ -isystem ${BASE}/bionic/libc/arch-arm64/include \
+ -isystem ${BASE}/bionic/libc/include \
+ -isystem ${BASE}/bionic/libc/kernel/uapi \
+ -isystem ${BASE}/bionic/libc/kernel/uapi/asm-arm64 \
+ -isystem ${BASE}/bionic/libm/include \
+ -isystem ${BASE}/bionic/libm/include/arm64 \
+ -include ${BASE}/build/core/combo/include/arch/linux-arm64/AndroidConfig.h \
+ -I ${BASE}/build/core/combo/include/arch/linux-arm64/ \
+ -c \
+ -fno-exceptions \
+ -Wno-multichar \
+ -fno-strict-aliasing \
+ -fstack-protector \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -fno-short-enums \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ -mcpu=cortex-a53 \
+ -Werror=pointer-to-int-cast \
+ -Werror=int-to-pointer-cast \
+ -Werror=implicit-function-declaration \
+ -fno-strict-volatile-bitfields \
+ -Wno-psabi \
+ -DANDROID \
+ -fmessage-length=0 \
+ -W \
+ -Wall \
+ -Wno-unused \
+ -Winit-self \
+ -Wpointer-arith \
+ -Werror=return-type \
+ -Werror=non-virtual-dtor \
+ -Werror=address \
+ -Werror=sequence-point \
+ -O2 \
+ -DNDEBUG \
+ -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -DNDEBUG \
+ -UDEBUG \
+ -D__ASSEMBLY__ \
+ -o string_copy_google_wrapper.o \
+ string_copy_google_wrapper.S
+
+ ${toolchain}/bin/aarch64-linux-android-gcc \
+ -isystem ${BASE}/bionic/libc/arch-arm64/include \
+ -isystem ${BASE}/bionic/libc/include \
+ -isystem ${BASE}/bionic/libc/kernel/uapi \
+ -isystem ${BASE}/bionic/libc/kernel/uapi/asm-arm64 \
+ -isystem ${BASE}/bionic/libm/include \
+ -isystem ${BASE}/bionic/libm/include/arm64 \
+ -include ${BASE}/build/core/combo/include/arch/linux-arm64/AndroidConfig.h \
+ -I ${BASE}/build/core/combo/include/arch/linux-arm64/ \
+ -c \
+ -fno-exceptions \
+ -Wno-multichar \
+ -fno-strict-aliasing \
+ -fstack-protector \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -fno-short-enums \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ -mcpu=cortex-a53 \
+ -Werror=pointer-to-int-cast \
+ -Werror=int-to-pointer-cast \
+ -Werror=implicit-function-declaration \
+ -fno-strict-volatile-bitfields \
+ -Wno-psabi \
+ -DANDROID \
+ -fmessage-length=0 \
+ -W \
+ -Wall \
+ -Wno-unused \
+ -Winit-self \
+ -Wpointer-arith \
+ -Werror=return-type \
+ -Werror=non-virtual-dtor \
+ -Werror=address \
+ -Werror=sequence-point \
+ -O2 \
+ -DNDEBUG \
+ -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -DNDEBUG \
+ -UDEBUG \
+ -D__ASSEMBLY__ \
+ -o string_copy_linaro_wrapper.o \
+ string_copy_linaro_wrapper.S
+
+ ${toolchain}/bin/aarch64-linux-android-gcc \
+ -isystem ${BASE}/bionic/libc/arch-arm64/include \
+ -isystem ${BASE}/bionic/libc/include \
+ -isystem ${BASE}/bionic/libc/kernel/uapi \
+ -isystem ${BASE}/bionic/libc/kernel/uapi/asm-arm64 \
+ -isystem ${BASE}/bionic/libm/include \
+ -isystem ${BASE}/bionic/libm/include/arm64 \
+ -include ${BASE}/build/core/combo/include/arch/linux-arm64/AndroidConfig.h \
+ -I ${BASE}/build/core/combo/include/arch/linux-arm64/ \
+ -c \
+ -fno-exceptions \
+ -Wno-multichar \
+ -fno-strict-aliasing \
+ -fstack-protector \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -fno-short-enums \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ -mcpu=cortex-a53 \
+ -Werror=pointer-to-int-cast \
+ -Werror=int-to-pointer-cast \
+ -Werror=implicit-function-declaration \
+ -fno-strict-volatile-bitfields \
+ -Wno-psabi \
+ -DANDROID \
+ -fmessage-length=0 \
+ -W \
+ -Wall \
+ -Wno-unused \
+ -Winit-self \
+ -Wpointer-arith \
+ -Werror=return-type \
+ -Werror=non-virtual-dtor \
+ -Werror=address \
+ -Werror=sequence-point \
+ -O2 \
+ -DNDEBUG \
+ -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -DNDEBUG \
+ -UDEBUG \
+ -std=gnu99 \
+ -fpie \
+ -D_USING_LIBCXX \
+ -Werror=int-to-pointer-cast \
+ -Werror=pointer-to-int-cast \
+ -o main_strcpy.o \
+ main_strcpy.c
+
+
+ ${toolchain}/bin/aarch64-linux-android-gcc \
+ -nostdlib \
+ -Bstatic \
+ -static \
+ -Wl,--gc-sections \
+ string_copy_linaro_wrapper.o \
+ string_copy_google_wrapper.o \
+ main_strcpy.o \
+ -o "${output}" \
+ ${NDK_21_ARM64}/usr/lib/crtbegin_static.o \
+ -Wl,-z,noexecstack \
+ -Wl,-z,relro -Wl,-z,now \
+ -Wl,--build-id=md5 \
+ -Wl,--warn-shared-textrel \
+ -Wl,--fatal-warnings \
+ -Wl,-maarch64linux \
+ -Wl,--hash-style=gnu \
+ -Wl,--fix-cortex-a53-843419 \
+ -Wl,--allow-shlib-undefined \
+ -Wl,--no-undefined \
+ -Wl,--whole-archive \
+ -Wl,--no-whole-archive \
+ -Wl,--start-group \
+ ${NDK_21_ARM64}/usr/lib/libc.a \
+ ${libgcc} \
+ -Wl,--end-group \
+ ${NDK_21_ARM64}/usr/lib/crtend_android.o
+
+ ls -l "${output}"
+ file "${output}"
+}
+
+function main(){
+ rm -fr bin
+ compile "${TOOLCHAIN_GOOGLE_64}" "${LIBGCC_GOOGLE}" "strcpy_google_static"
+ compile "${TOOLCHAIN_LINARO_64}" "${LIBGCC_LINARO}" "strcpy_linaro_static"
+ mkdir -p bin
+ mv -v "strcpy_google_static" "strcpy_linaro_static" bin
+ rm -fr main_strcpy.o string_copy_google_wrapper.o string_copy_linaro_wrapper.o
+}
+
+main "$@"
+