summaryrefslogtreecommitdiff
path: root/android-tools/static-binary/src/Makefile.64
blob: 2e95f7d5fdbc770e78e323535fdf73b1de18a228 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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)

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)

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.


#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 += 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 $@

strcpy_test_google_static: $(src)
	$(CC_google_64) $(CFLAGS) $(CFLAGS2) -static -Bstatic \
	    $(FILTER) -o $@

strcpy_test_google: $(src)
	$(CC_google_64) $(CFLAGS) $(CFLAGS2) \
	    $(FILTER) -o $@

move:
	@mkdir -p bin/
	@mv strcpy_test* bin/

clean:
	rm -f bin/strcpy_test*