1LOCAL_PATH:= $(call my-dir) 2 3include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk 4 5# Define the common source files for all the libc instances 6# ========================================================= 7libc_common_src_files := \ 8 $(syscall_src) \ 9 unistd/abort.c \ 10 unistd/alarm.c \ 11 unistd/brk.c \ 12 unistd/daemon.c \ 13 unistd/eventfd.c \ 14 unistd/exec.c \ 15 unistd/fcntl.c \ 16 unistd/fnmatch.c \ 17 unistd/fstatfs.c \ 18 unistd/ftime.c \ 19 unistd/ftok.c \ 20 unistd/getdtablesize.c \ 21 unistd/gethostname.c \ 22 unistd/getopt_long.c \ 23 unistd/getpgrp.c \ 24 unistd/getpriority.c \ 25 unistd/getpt.c \ 26 unistd/initgroups.c \ 27 unistd/isatty.c \ 28 unistd/issetugid.c \ 29 unistd/killpg.c \ 30 unistd/lseek64.c \ 31 unistd/mmap.c \ 32 unistd/open.c \ 33 unistd/openat.c \ 34 unistd/opendir.c \ 35 unistd/pathconf.c \ 36 unistd/perror.c \ 37 unistd/popen.c \ 38 unistd/pread.c \ 39 unistd/pselect.c \ 40 unistd/ptsname.c \ 41 unistd/ptsname_r.c \ 42 unistd/pwrite.c \ 43 unistd/raise.c \ 44 unistd/reboot.c \ 45 unistd/recv.c \ 46 unistd/sbrk.c \ 47 unistd/send.c \ 48 unistd/setegid.c \ 49 unistd/setuid.c \ 50 unistd/seteuid.c \ 51 unistd/setreuid.c \ 52 unistd/setresuid.c \ 53 unistd/setpgrp.c \ 54 unistd/sigblock.c \ 55 unistd/siginterrupt.c \ 56 unistd/siglist.c \ 57 unistd/signal.c \ 58 unistd/signame.c \ 59 unistd/sigsetmask.c \ 60 unistd/sigsuspend.c \ 61 unistd/sigwait.c \ 62 unistd/sleep.c \ 63 unistd/statfs.c \ 64 unistd/syslog.c \ 65 unistd/system.c \ 66 unistd/tcgetpgrp.c \ 67 unistd/tcsetpgrp.c \ 68 unistd/time.c \ 69 unistd/umount.c \ 70 unistd/unlockpt.c \ 71 unistd/usleep.c \ 72 unistd/wait.c \ 73 stdio/asprintf.c \ 74 stdio/clrerr.c \ 75 stdio/fclose.c \ 76 stdio/fdopen.c \ 77 stdio/feof.c \ 78 stdio/ferror.c \ 79 stdio/fflush.c \ 80 stdio/fgetc.c \ 81 stdio/fgetln.c \ 82 stdio/fgetpos.c \ 83 stdio/fgets.c \ 84 stdio/fileno.c \ 85 stdio/findfp.c \ 86 stdio/flags.c \ 87 stdio/flockfile.c \ 88 stdio/fopen.c \ 89 stdio/fprintf.c \ 90 stdio/fpurge.c \ 91 stdio/fputc.c \ 92 stdio/fputs.c \ 93 stdio/fread.c \ 94 stdio/freopen.c \ 95 stdio/fscanf.c \ 96 stdio/fseek.c \ 97 stdio/fsetpos.c \ 98 stdio/ftell.c \ 99 stdio/funopen.c \ 100 stdio/fvwrite.c \ 101 stdio/fwalk.c \ 102 stdio/fwrite.c \ 103 stdio/getc.c \ 104 stdio/getchar.c \ 105 stdio/gets.c \ 106 stdio/makebuf.c \ 107 stdio/mktemp.c \ 108 stdio/printf.c \ 109 stdio/putc.c \ 110 stdio/putchar.c \ 111 stdio/puts.c \ 112 stdio/putw.c \ 113 stdio/refill.c \ 114 stdio/remove.c \ 115 stdio/rewind.c \ 116 stdio/rget.c \ 117 stdio/scanf.c \ 118 stdio/setbuf.c \ 119 stdio/setbuffer.c \ 120 stdio/setvbuf.c \ 121 stdio/snprintf.c\ 122 stdio/sprintf.c \ 123 stdio/sscanf.c \ 124 stdio/stdio.c \ 125 stdio/tempnam.c \ 126 stdio/tmpfile.c \ 127 stdio/tmpnam.c \ 128 stdio/ungetc.c \ 129 stdio/vasprintf.c \ 130 stdio/vfprintf.c \ 131 stdio/vfscanf.c \ 132 stdio/vprintf.c \ 133 stdio/vsnprintf.c \ 134 stdio/vsprintf.c \ 135 stdio/vscanf.c \ 136 stdio/vsscanf.c \ 137 stdio/wbuf.c \ 138 stdio/wsetup.c \ 139 stdio/__fgets_chk.c \ 140 stdio/__snprintf_chk.c \ 141 stdio/__sprintf_chk.c \ 142 stdio/__vsnprintf_chk.c \ 143 stdio/__vsprintf_chk.c \ 144 stdlib/_rand48.c \ 145 stdlib/assert.c \ 146 stdlib/atexit.c \ 147 stdlib/atoi.c \ 148 stdlib/atol.c \ 149 stdlib/atoll.c \ 150 stdlib/bsearch.c \ 151 stdlib/ctype_.c \ 152 stdlib/div.c \ 153 stdlib/exit.c \ 154 stdlib/getenv.c \ 155 stdlib/jrand48.c \ 156 stdlib/ldiv.c \ 157 stdlib/lldiv.c \ 158 stdlib/locale.c \ 159 stdlib/lrand48.c \ 160 stdlib/mrand48.c \ 161 stdlib/nrand48.c \ 162 stdlib/putenv.c \ 163 stdlib/qsort.c \ 164 stdlib/seed48.c \ 165 stdlib/setenv.c \ 166 stdlib/setjmperr.c \ 167 stdlib/srand48.c \ 168 stdlib/strntoimax.c \ 169 stdlib/strntoumax.c \ 170 stdlib/strtod.c \ 171 stdlib/strtoimax.c \ 172 stdlib/strtol.c \ 173 stdlib/strtoll.c \ 174 stdlib/strtoul.c \ 175 stdlib/strtoull.c \ 176 stdlib/strtoumax.c \ 177 stdlib/tolower_.c \ 178 stdlib/toupper_.c \ 179 stdlib/wchar.c \ 180 string/index.c \ 181 string/memccpy.c \ 182 string/memchr.c \ 183 string/memmem.c \ 184 string/memrchr.c \ 185 string/memswap.c \ 186 string/strcasecmp.c \ 187 string/strcasestr.c \ 188 string/strcat.c \ 189 string/strchr.c \ 190 string/strcoll.c \ 191 string/strcspn.c \ 192 string/strdup.c \ 193 string/strlcat.c \ 194 string/strlcpy.c \ 195 string/strncat.c \ 196 string/strncpy.c \ 197 string/strndup.c \ 198 string/strnlen.c \ 199 string/strpbrk.c \ 200 string/strrchr.c \ 201 string/strsep.c \ 202 string/strspn.c \ 203 string/strstr.c \ 204 string/strtok.c \ 205 string/strtotimeval.c \ 206 string/__memcpy_chk.c \ 207 string/__memmove_chk.c \ 208 string/__memset_chk.c \ 209 string/__strcat_chk.c \ 210 string/__strcpy_chk.c \ 211 string/__strlcat_chk.c \ 212 string/__strlcpy_chk.c \ 213 string/__strlen_chk.c \ 214 string/__strncat_chk.c \ 215 string/__strncpy_chk.c \ 216 wchar/wcpcpy.c \ 217 wchar/wcpncpy.c \ 218 wchar/wcscasecmp.c \ 219 wchar/wcscat.c \ 220 wchar/wcschr.c \ 221 wchar/wcscmp.c \ 222 wchar/wcscoll.c \ 223 wchar/wcscpy.c \ 224 wchar/wcscspn.c \ 225 wchar/wcsdup.c \ 226 wchar/wcslcat.c \ 227 wchar/wcslcpy.c \ 228 wchar/wcslen.c \ 229 wchar/wcsncasecmp.c \ 230 wchar/wcsncat.c \ 231 wchar/wcsncmp.c \ 232 wchar/wcsncpy.c \ 233 wchar/wcsnlen.c \ 234 wchar/wcspbrk.c \ 235 wchar/wcsrchr.c \ 236 wchar/wcsspn.c \ 237 wchar/wcsstr.c \ 238 wchar/wcstok.c \ 239 wchar/wcswidth.c \ 240 wchar/wcsxfrm.c \ 241 wchar/wmemchr.c \ 242 wchar/wmemcmp.c \ 243 wchar/wmemcpy.c \ 244 wchar/wmemmove.c \ 245 wchar/wmemset.c \ 246 inet/bindresvport.c \ 247 inet/inet_addr.c \ 248 inet/inet_aton.c \ 249 inet/inet_ntoa.c \ 250 inet/inet_ntop.c \ 251 inet/inet_pton.c \ 252 inet/ether_aton.c \ 253 inet/ether_ntoa.c \ 254 tzcode/asctime.c \ 255 tzcode/difftime.c \ 256 tzcode/localtime.c \ 257 tzcode/strftime.c \ 258 tzcode/strptime.c \ 259 bionic/__set_errno.c \ 260 bionic/bionic_clone.c \ 261 bionic/cpuacct.c \ 262 bionic/arc4random.c \ 263 bionic/basename.c \ 264 bionic/basename_r.c \ 265 bionic/clearenv.c \ 266 bionic/dirname.c \ 267 bionic/dirname_r.c \ 268 bionic/drand48.c \ 269 bionic/erand48.c \ 270 bionic/err.c \ 271 bionic/fdprintf.c \ 272 bionic/fork.c \ 273 bionic/fts.c \ 274 bionic/getcwd.cpp \ 275 bionic/if_nametoindex.c \ 276 bionic/if_indextoname.c \ 277 bionic/ioctl.c \ 278 bionic/ldexp.c \ 279 bionic/libc_init_common.c \ 280 bionic/logd_write.c \ 281 bionic/md5.c \ 282 bionic/memmove_words.c \ 283 bionic/pututline.c \ 284 bionic/realpath.c \ 285 bionic/sched_getaffinity.c \ 286 bionic/sched_getcpu.c \ 287 bionic/sched_cpualloc.c \ 288 bionic/sched_cpucount.c \ 289 bionic/semaphore.c \ 290 bionic/sha1.c \ 291 bionic/strerror.cpp \ 292 bionic/strerror_r.cpp \ 293 bionic/strsignal.cpp \ 294 bionic/stubs.cpp \ 295 bionic/system_properties.c \ 296 bionic/tdestroy.c \ 297 bionic/time64.c \ 298 bionic/thread_atexit.c \ 299 bionic/utime.c \ 300 bionic/utmp.c \ 301 netbsd/gethnamaddr.c \ 302 netbsd/isc/ev_timers.c \ 303 netbsd/isc/ev_streams.c \ 304 netbsd/inet/nsap_addr.c \ 305 netbsd/resolv/__dn_comp.c \ 306 netbsd/resolv/__res_close.c \ 307 netbsd/resolv/__res_send.c \ 308 netbsd/resolv/herror.c \ 309 netbsd/resolv/res_comp.c \ 310 netbsd/resolv/res_data.c \ 311 netbsd/resolv/res_debug.c \ 312 netbsd/resolv/res_init.c \ 313 netbsd/resolv/res_mkquery.c \ 314 netbsd/resolv/res_query.c \ 315 netbsd/resolv/res_send.c \ 316 netbsd/resolv/res_state.c \ 317 netbsd/resolv/res_cache.c \ 318 netbsd/net/nsdispatch.c \ 319 netbsd/net/getaddrinfo.c \ 320 netbsd/net/getnameinfo.c \ 321 netbsd/net/getservbyname.c \ 322 netbsd/net/getservent.c \ 323 netbsd/net/base64.c \ 324 netbsd/net/getservbyport.c \ 325 netbsd/nameser/ns_name.c \ 326 netbsd/nameser/ns_parse.c \ 327 netbsd/nameser/ns_ttl.c \ 328 netbsd/nameser/ns_netint.c \ 329 netbsd/nameser/ns_print.c \ 330 netbsd/nameser/ns_samedomain.c \ 331 332libc_upstream_netbsd_src_files := \ 333 upstream-netbsd/libc/compat-43/creat.c \ 334 upstream-netbsd/libc/gen/ftw.c \ 335 upstream-netbsd/libc/gen/nftw.c \ 336 upstream-netbsd/libc/gen/nice.c \ 337 upstream-netbsd/libc/gen/psignal.c \ 338 upstream-netbsd/libc/regex/regcomp.c \ 339 upstream-netbsd/libc/regex/regerror.c \ 340 upstream-netbsd/libc/regex/regexec.c \ 341 upstream-netbsd/libc/regex/regfree.c \ 342 upstream-netbsd/libc/stdlib/tdelete.c \ 343 upstream-netbsd/libc/stdlib/tfind.c \ 344 upstream-netbsd/libc/stdlib/tsearch.c \ 345 upstream-netbsd/libc/string/strxfrm.c \ 346 347# The following files are common, but must be compiled 348# with different C flags when building a static C library. 349# 350# The reason for this is the implementation of __get_tls() 351# that will differ between the shared and static versions 352# of the library. 353# 354# See comments in private/bionic_tls.h for more details. 355# 356# NOTE: bionic/pthread.c is added later to this list 357# because it needs special handling on ARM, see 358# below. 359# 360libc_static_common_src_files := \ 361 unistd/sysconf.c \ 362 bionic/__errno.c \ 363 364# Architecture specific source files go here 365# ========================================================= 366ifeq ($(TARGET_ARCH),arm) 367libc_common_src_files += \ 368 arch-arm/bionic/__get_sp.S \ 369 arch-arm/bionic/_exit_with_stack_teardown.S \ 370 arch-arm/bionic/_setjmp.S \ 371 arch-arm/bionic/abort_arm.S \ 372 arch-arm/bionic/atomics_arm.c \ 373 arch-arm/bionic/clone.S \ 374 arch-arm/bionic/eabi.c \ 375 arch-arm/bionic/ffs.S \ 376 arch-arm/bionic/futex_arm.S \ 377 arch-arm/bionic/kill.S \ 378 arch-arm/bionic/libgcc_compat.c \ 379 arch-arm/bionic/tkill.S \ 380 arch-arm/bionic/tgkill.S \ 381 arch-arm/bionic/memcmp.S \ 382 arch-arm/bionic/memcmp16.S \ 383 arch-arm/bionic/memcpy.S \ 384 arch-arm/bionic/memset.S \ 385 arch-arm/bionic/setjmp.S \ 386 arch-arm/bionic/sigsetjmp.S \ 387 arch-arm/bionic/strlen.c.arm \ 388 arch-arm/bionic/strcpy.S \ 389 arch-arm/bionic/strcmp.S \ 390 arch-arm/bionic/syscall.S \ 391 string/memmove.c.arm \ 392 string/bcopy.c \ 393 string/strncmp.c \ 394 unistd/socketcalls.c 395 396# These files need to be arm so that gdbserver 397# can set breakpoints in them without messing 398# up any thumb code. 399libc_common_src_files += \ 400 bionic/pthread-atfork.c.arm \ 401 bionic/pthread-rwlocks.c.arm \ 402 bionic/pthread-timers.c.arm \ 403 bionic/ptrace.c.arm 404 405libc_static_common_src_files += \ 406 bionic/pthread.c.arm \ 407 408# these are used by the static and dynamic versions of the libc 409# respectively 410libc_arch_static_src_files := \ 411 arch-arm/bionic/exidx_static.c 412 413libc_arch_dynamic_src_files := \ 414 arch-arm/bionic/exidx_dynamic.c 415endif # arm 416 417ifeq ($(TARGET_ARCH),x86) 418libc_common_src_files += \ 419 arch-x86/bionic/__get_sp.S \ 420 arch-x86/bionic/__get_tls.c \ 421 arch-x86/bionic/__set_tls.c \ 422 arch-x86/bionic/clone.S \ 423 arch-x86/bionic/_exit_with_stack_teardown.S \ 424 arch-x86/bionic/futex_x86.S \ 425 arch-x86/bionic/setjmp.S \ 426 arch-x86/bionic/_setjmp.S \ 427 arch-x86/bionic/sigsetjmp.S \ 428 arch-x86/bionic/vfork.S \ 429 arch-x86/bionic/syscall.S \ 430 arch-x86/string/bcopy_wrapper.S \ 431 arch-x86/string/memcpy_wrapper.S \ 432 arch-x86/string/memmove_wrapper.S \ 433 arch-x86/string/bzero_wrapper.S \ 434 arch-x86/string/memcmp_wrapper.S \ 435 arch-x86/string/memset_wrapper.S \ 436 arch-x86/string/strcmp_wrapper.S \ 437 arch-x86/string/strncmp_wrapper.S \ 438 arch-x86/string/strlen_wrapper.S \ 439 string/strcpy.c \ 440 bionic/pthread-atfork.c \ 441 bionic/pthread-rwlocks.c \ 442 bionic/pthread-timers.c \ 443 bionic/ptrace.c 444 445libc_static_common_src_files += \ 446 bionic/pthread.c \ 447 448libc_arch_static_src_files := \ 449 bionic/dl_iterate_phdr_static.c 450 451libc_arch_dynamic_src_files := 452endif # x86 453 454ifeq ($(TARGET_ARCH),mips) 455libc_common_src_files += \ 456 arch-mips/bionic/__get_sp.S \ 457 arch-mips/bionic/__get_tls.c \ 458 arch-mips/bionic/__set_tls.c \ 459 arch-mips/bionic/_exit_with_stack_teardown.S \ 460 arch-mips/bionic/_setjmp.S \ 461 arch-mips/bionic/futex_mips.S \ 462 arch-mips/bionic/bzero.S \ 463 arch-mips/bionic/cacheflush.c \ 464 arch-mips/bionic/clone.S \ 465 arch-mips/bionic/ffs.S \ 466 arch-mips/bionic/memcmp16.S \ 467 arch-mips/bionic/memmove.c \ 468 arch-mips/bionic/pipe.S \ 469 arch-mips/bionic/setjmp.S \ 470 arch-mips/bionic/sigsetjmp.S \ 471 arch-mips/bionic/vfork.S 472 473libc_common_src_files += \ 474 arch-mips/string/memset.S \ 475 arch-mips/string/memcpy.S \ 476 arch-mips/string/mips_strlen.c 477 478libc_common_src_files += \ 479 string/bcopy.c \ 480 string/memcmp.c \ 481 string/strcmp.c \ 482 string/strcpy.c \ 483 string/strncmp.c 484 485libc_common_src_files += \ 486 bionic/pthread-atfork.c \ 487 bionic/pthread-rwlocks.c \ 488 bionic/pthread-timers.c \ 489 bionic/ptrace.c 490 491libc_static_common_src_files += \ 492 bionic/pthread.c 493 494libc_arch_static_src_files := \ 495 bionic/dl_iterate_phdr_static.c 496 497libc_arch_dynamic_src_files := 498endif # mips 499 500# Define some common cflags 501# ======================================================== 502libc_common_cflags := \ 503 -DWITH_ERRLIST \ 504 -DANDROID_CHANGES \ 505 -D_LIBC=1 \ 506 -DFLOATING_POINT \ 507 -DINET6 \ 508 -I$(LOCAL_PATH)/private \ 509 -DPOSIX_MISTAKE \ 510 -DLOG_ON_HEAP_ERROR \ 511 -std=gnu99 \ 512 -Wall -Wextra 513 514# these macro definitions are required to implement the 515# 'timezone' and 'daylight' global variables, as well as 516# properly update the 'tm_gmtoff' field in 'struct tm'. 517# 518libc_common_cflags += \ 519 -DTM_GMTOFF=tm_gmtoff \ 520 -DUSG_COMPAT=1 521 522ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true) 523 libc_common_cflags += -DDEBUG 524endif 525 526# To customize dlmalloc's alignment, set BOARD_MALLOC_ALIGNMENT in 527# the appropriate BoardConfig.mk file. 528# 529ifneq ($(BOARD_MALLOC_ALIGNMENT),) 530 libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT) 531endif 532 533ifeq ($(TARGET_ARCH),arm) 534 libc_common_cflags += -DSOFTFLOAT 535 libc_common_cflags += -fstrict-aliasing 536 libc_crt_target_cflags := -mthumb-interwork 537 # 538 # Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library 539 # that it should access the hardware TLS register directly in 540 # private/bionic_tls.h 541 # 542 # The value must match your kernel configuration 543 # 544 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) 545 libc_common_cflags += -DHAVE_ARM_TLS_REGISTER 546 endif 547 # 548 # Define HAVE_32_BYTE_CACHE_LINES to indicate to C 549 # library it should use to 32-byte version of memcpy, and not 550 # the 64-byte version. 551 # 552 ifeq ($(ARCH_ARM_HAVE_32_BYTE_CACHE_LINES),true) 553 libc_common_cflags += -DHAVE_32_BYTE_CACHE_LINE 554 endif 555 ifeq ($(ARCH_ARM_USE_NON_NEON_MEMCPY),true) 556 libc_common_cflags += -DARCH_ARM_USE_NON_NEON_MEMCPY 557 endif 558endif # !arm 559 560ifeq ($(TARGET_ARCH),x86) 561 libc_common_cflags += -DSOFTFLOAT 562 libc_crt_target_cflags := 563 ifeq ($(ARCH_X86_HAVE_SSE2),true) 564 libc_crt_target_cflags += -DUSE_SSE2=1 565 endif 566 ifeq ($(ARCH_X86_HAVE_SSSE3),true) 567 libc_crt_target_cflags += -DUSE_SSSE3=1 568 endif 569endif # x86 570 571ifeq ($(TARGET_ARCH),mips) 572 ifneq ($(ARCH_MIPS_HAS_FPU),true) 573 libc_common_cflags += -DSOFTFLOAT 574 endif 575 libc_common_cflags += -fstrict-aliasing 576 libc_crt_target_cflags := $(TARGET_GLOBAL_CFLAGS) 577endif # mips 578 579# Define ANDROID_SMP appropriately. 580ifeq ($(TARGET_CPU_SMP),true) 581 libc_common_cflags += -DANDROID_SMP=1 582else 583 libc_common_cflags += -DANDROID_SMP=0 584endif 585 586# crtbrand.c needs <stdint.h> and a #define for the platform SDK version. 587libc_crt_target_cflags += \ 588 -I$(LOCAL_PATH)/include \ 589 -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) 590 591# Define some common includes 592# ======================================================== 593libc_common_c_includes := \ 594 $(LOCAL_PATH)/stdlib \ 595 $(LOCAL_PATH)/string \ 596 $(LOCAL_PATH)/stdio \ 597 external/safe-iop/include 598 599# Needed to access private/__dso_handle.h from 600# crtbegin_xxx.S and crtend_xxx.S 601libc_crt_target_cflags += \ 602 -I$(LOCAL_PATH)/private \ 603 -I$(LOCAL_PATH)/arch-$(TARGET_ARCH)/include 604 605# Define the libc run-time (crt) support object files that must be built, 606# which are needed to build all other objects (shared/static libs and 607# executables) 608# ========================================================================== 609# ARM, MIPS, and x86 all need crtbegin_so/crtend_so. 610# 611# For x86, the .init section must point to a function that calls all 612# entries in the .ctors section. (on ARM this is done through the 613# .init_array section instead). 614# 615# For all the platforms, the .fini_array section must point to a function 616# that will call __cxa_finalize(&__dso_handle) in order to ensure that 617# static C++ destructors are properly called on dlclose(). 618# 619ifeq ($(TARGET_ARCH),arm) 620 libc_crtbegin_extension := c 621 libc_crt_target_so_cflags := 622endif 623ifeq ($(TARGET_ARCH),mips) 624 libc_crtbegin_extension := S 625 libc_crt_target_so_cflags := -fPIC 626endif 627ifeq ($(TARGET_ARCH),x86) 628 libc_crtbegin_extension := S 629 libc_crt_target_so_cflags := -fPIC 630endif 631ifeq ($(libc_crtbegin_extension),) 632 $(error $(TARGET_ARCH) not supported) 633endif 634libc_crt_target_so_cflags += $(libc_crt_target_cflags) 635libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.$(libc_crtbegin_extension) 636libc_crt_target_crtbegin_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.$(libc_crtbegin_extension) 637 638# See the comment in crtbrand.c for the reason why we need to generate 639# crtbrand.s before generating crtbrand.o. 640GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.s 641$(GEN): $(LOCAL_PATH)/bionic/crtbrand.c 642 @mkdir -p $(dir $@) 643 $(hide) $(TARGET_CC) $(libc_crt_target_so_cflags) -S \ 644 -MD -MF $(@:%.s=%.d) -o $@ $< 645 $(hide) sed -i -e '/\.note\.ABI-tag/s/progbits/note/' $@ 646 $(call transform-d-to-p-args,$(@:%.s=%.d),$(@:%.s=%.P)) 647-include $(GEN:%.s=%.P) 648ALL_GENERATED_SOURCES += $(GEN) 649 650GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o 651$(GEN): $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.s 652 @mkdir -p $(dir $@) 653 $(hide) $(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $< 654ALL_GENERATED_SOURCES += $(GEN) 655 656GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o 657$(GEN): $(libc_crt_target_crtbegin_so_file) 658 @mkdir -p $(dir $@) 659 $(hide) $(TARGET_CC) $(libc_crt_target_so_cflags) \ 660 -MD -MF $(@:%.o=%.d) -o $@ -c $< 661 $(transform-d-to-p) 662-include $(GEN:%.o=%.P) 663ALL_GENERATED_SOURCES += $(GEN) 664 665GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o 666$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S 667 @mkdir -p $(dir $@) 668 $(hide) $(TARGET_CC) $(libc_crt_target_so_cflags) \ 669 -MD -MF $(@:%.o=%.d) -o $@ -c $< 670 $(transform-d-to-p) 671-include $(GEN:%.o=%.P) 672ALL_GENERATED_SOURCES += $(GEN) 673 674# The following two are installed to device 675GEN := $(TARGET_OUT_SHARED_LIBRARIES)/crtbegin_so.o 676$(GEN): $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o 677 $(hide) mkdir -p $(dir $@) && cp -f $< $@ 678ALL_GENERATED_SOURCES += $(GEN) 679 680GEN := $(TARGET_OUT_SHARED_LIBRARIES)/crtend_so.o 681$(GEN): $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o 682 $(hide) mkdir -p $(dir $@) && cp -f $< $@ 683ALL_GENERATED_SOURCES += $(GEN) 684 685 686GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static1.o 687$(GEN): $(libc_crt_target_crtbegin_file) 688 @mkdir -p $(dir $@) 689 $(hide) $(TARGET_CC) $(libc_crt_target_cflags) \ 690 -MD -MF $(@:%.o=%.d) -o $@ -c $< 691 $(transform-d-to-p) 692-include $(GEN:%.o=%.P) 693ALL_GENERATED_SOURCES += $(GEN) 694 695GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o 696$(GEN): $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static1.o $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o 697 @mkdir -p $(dir $@) 698 $(hide) $(TARGET_LD) -r -o $@ $^ 699ALL_GENERATED_SOURCES += $(GEN) 700 701GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic1.o 702$(GEN): $(libc_crt_target_crtbegin_file) 703 @mkdir -p $(dir $@) 704 $(hide) $(TARGET_CC) $(libc_crt_target_cflags) \ 705 -MD -MF $(@:%.o=%.d) -o $@ -c $< 706 $(transform-d-to-p) 707-include $(GEN:%.o=%.P) 708ALL_GENERATED_SOURCES += $(GEN) 709 710GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o 711$(GEN): $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic1.o $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o 712 @mkdir -p $(dir $@) 713 $(hide) $(TARGET_LD) -r -o $@ $^ 714ALL_GENERATED_SOURCES += $(GEN) 715 716# We rename crtend.o to crtend_android.o to avoid a 717# name clash between gcc and bionic. 718GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o 719$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S 720 @mkdir -p $(dir $@) 721 $(hide) $(TARGET_CC) $(libc_crt_target_cflags) \ 722 -MD -MF $(@:%.o=%.d) -o $@ -c $< 723 $(transform-d-to-p) 724-include $(GEN:%.o=%.P) 725ALL_GENERATED_SOURCES += $(GEN) 726 727 728# To enable malloc leak check for statically linked programs, add 729# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk 730WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A)) 731 732# ======================================================== 733# libbionic_ssp.a - stack protector code 734# ======================================================== 735# 736# The stack protector code needs to be compiled 737# with -fno-stack-protector, since it modifies the 738# stack canary. 739 740include $(CLEAR_VARS) 741 742LOCAL_SRC_FILES := bionic/ssp.c 743LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector 744LOCAL_C_INCLUDES := $(libc_common_c_includes) 745LOCAL_MODULE := libbionic_ssp 746LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 747LOCAL_SYSTEM_SHARED_LIBRARIES := 748 749include $(BUILD_STATIC_LIBRARY) 750 751 752# ======================================================== 753# libc_netbsd.a - upstream NetBSD C library code 754# ======================================================== 755# 756# These files are built with the netbsd-compat.h header file 757# automatically included. 758 759include $(CLEAR_VARS) 760 761LOCAL_SRC_FILES := $(libc_upstream_netbsd_src_files) 762LOCAL_CFLAGS := \ 763 $(libc_common_cflags) \ 764 -I$(LOCAL_PATH)/upstream-netbsd \ 765 -include upstream-netbsd/netbsd-compat.h 766LOCAL_C_INCLUDES := $(libc_common_c_includes) 767LOCAL_MODULE := libc_netbsd 768LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 769LOCAL_SYSTEM_SHARED_LIBRARIES := 770 771include $(BUILD_STATIC_LIBRARY) 772 773 774# ======================================================== 775# libc_common.a 776# ======================================================== 777 778include $(CLEAR_VARS) 779 780LOCAL_SRC_FILES := $(libc_common_src_files) 781LOCAL_CFLAGS := $(libc_common_cflags) 782LOCAL_C_INCLUDES := $(libc_common_c_includes) 783LOCAL_MODULE := libc_common 784LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 785LOCAL_WHOLE_STATIC_LIBRARIES := libbionic_ssp libc_netbsd 786LOCAL_SYSTEM_SHARED_LIBRARIES := 787 788include $(BUILD_STATIC_LIBRARY) 789 790 791# ======================================================== 792# libc_nomalloc.a 793# ======================================================== 794# 795# This is a version of the static C library that does not 796# include malloc. It's useful in situations when calling 797# the user wants to provide their own malloc implementation, 798# or wants to explicitly disallow the use of the use of malloc, 799# like the dynamic loader. 800 801include $(CLEAR_VARS) 802 803LOCAL_SRC_FILES := \ 804 $(libc_arch_static_src_files) \ 805 $(libc_static_common_src_files) \ 806 bionic/libc_init_static.c 807 808LOCAL_C_INCLUDES := $(libc_common_c_includes) 809LOCAL_CFLAGS := $(libc_common_cflags) \ 810 -DLIBC_STATIC 811 812LOCAL_MODULE := libc_nomalloc 813LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 814LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 815LOCAL_SYSTEM_SHARED_LIBRARIES := 816 817include $(BUILD_STATIC_LIBRARY) 818 819 820# ======================================================== 821# libc.a 822# ======================================================== 823include $(CLEAR_VARS) 824 825LOCAL_SRC_FILES := \ 826 $(libc_arch_static_src_files) \ 827 $(libc_static_common_src_files) \ 828 bionic/dlmalloc.c \ 829 bionic/malloc_debug_common.cpp \ 830 bionic/libc_init_static.c 831 832LOCAL_CFLAGS := $(libc_common_cflags) \ 833 -DLIBC_STATIC 834LOCAL_C_INCLUDES := $(libc_common_c_includes) 835LOCAL_MODULE := libc 836LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 837LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 838LOCAL_SYSTEM_SHARED_LIBRARIES := 839 840include $(BUILD_STATIC_LIBRARY) 841 842 843# ======================================================== 844# libc.so 845# ======================================================== 846include $(CLEAR_VARS) 847 848# pthread deadlock prediction: 849# set -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=1 to enable support for 850# pthread deadlock prediction. 851# Since this code is experimental it is disabled by default. 852# see libc/bionic/pthread_debug.c for details 853 854LOCAL_CFLAGS := $(libc_common_cflags) -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=0 855LOCAL_C_INCLUDES := $(libc_common_c_includes) 856 857LOCAL_SRC_FILES := \ 858 $(libc_arch_dynamic_src_files) \ 859 $(libc_static_common_src_files) \ 860 bionic/dlmalloc.c \ 861 bionic/malloc_debug_common.cpp \ 862 bionic/pthread_debug.c \ 863 bionic/libc_init_dynamic.c 864 865ifeq ($(TARGET_ARCH),arm) 866 LOCAL_NO_CRT := true 867 LOCAL_CFLAGS += -DCRT_LEGACY_WORKAROUND 868 869 LOCAL_SRC_FILES := \ 870 arch-arm/bionic/crtbegin_so.c \ 871 arch-arm/bionic/atexit_legacy.c \ 872 $(LOCAL_SRC_FILES) \ 873 arch-arm/bionic/crtend_so.S 874endif 875 876LOCAL_MODULE:= libc 877LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 878 879# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries, 880# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries. This 881# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared 882# external; if that were the case, then libc would not pull those symbols from libgcc.a as it 883# should, instead relying on the external symbols from the dependent libraries. That would 884# create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what 885# you wanted! 886 887LOCAL_SHARED_LIBRARIES := libdl 888LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 889LOCAL_SYSTEM_SHARED_LIBRARIES := 890 891include $(BUILD_SHARED_LIBRARY) 892 893 894# For all builds, except for the -user build we will enable memory 895# allocation checking (including memory leaks, buffer overwrites, etc.) 896# Note that all these checks are also controlled by env. settings 897# that can enable, or disable specific checks. Note also that some of 898# the checks are available only in emulator and are implemeted in 899# libc_malloc_qemu_instrumented.so. 900ifneq ($(TARGET_BUILD_VARIANT),user) 901 902# ======================================================== 903# libc_malloc_debug_leak.so 904# ======================================================== 905include $(CLEAR_VARS) 906 907LOCAL_CFLAGS := \ 908 $(libc_common_cflags) \ 909 -DMALLOC_LEAK_CHECK 910 911LOCAL_C_INCLUDES := $(libc_common_c_includes) 912 913LOCAL_SRC_FILES := \ 914 bionic/malloc_debug_leak.cpp \ 915 bionic/malloc_debug_check.cpp \ 916 bionic/malloc_debug_check_mapinfo.cpp \ 917 bionic/malloc_debug_stacktrace.cpp 918 919LOCAL_MODULE:= libc_malloc_debug_leak 920LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 921 922LOCAL_SHARED_LIBRARIES := libc libdl 923LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 924LOCAL_SYSTEM_SHARED_LIBRARIES := 925LOCAL_ALLOW_UNDEFINED_SYMBOLS := true 926 927# Don't install on release build 928LOCAL_MODULE_TAGS := eng debug 929 930include $(BUILD_SHARED_LIBRARY) 931 932 933# ======================================================== 934# libc_malloc_debug_qemu.so 935# ======================================================== 936include $(CLEAR_VARS) 937 938LOCAL_CFLAGS := \ 939 $(libc_common_cflags) \ 940 -DMALLOC_QEMU_INSTRUMENT 941 942LOCAL_C_INCLUDES := $(libc_common_c_includes) 943 944LOCAL_SRC_FILES := \ 945 bionic/malloc_debug_qemu.cpp 946 947LOCAL_MODULE:= libc_malloc_debug_qemu 948LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 949 950LOCAL_SHARED_LIBRARIES := libc libdl 951LOCAL_WHOLE_STATIC_LIBRARIES := libc_common 952LOCAL_SYSTEM_SHARED_LIBRARIES := 953 954# Don't install on release build 955LOCAL_MODULE_TAGS := eng debug 956 957include $(BUILD_SHARED_LIBRARY) 958 959endif #!user 960 961 962# ======================================================== 963include $(call all-makefiles-under,$(LOCAL_PATH)) 964