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