Commit graph

623 commits

Author SHA1 Message Date
Elliott Hughes
604ab0fe82 riscv64: enable the version scripts.
Test: treehugger
Change-Id: Idd7b3610bd3321d7e1a4e868cf5dbaf2980909ab
2022-10-17 21:06:10 +00:00
Elliott Hughes
ebc19a9ccb riscv64: add bionic assembler and string functions.
Pull the portable C string functions from FreeBSD, and do fairly literal
translations of our existing .S files for the bionic-specific stuff.

Test: treehugger
Change-Id: Id42e5b8a51ed73155be020d74edd7011a2103574
2022-10-14 23:25:36 +00:00
Elliott Hughes
704772bda0 riscv64 syscall stub and seccomp filter generation.
These are sufficiently intertwined that they need to be done together.
riscv64 is our first primary-only architecture, so that required some
changes. The .bp changes are to support this --- we need to only show
the python scripts the architectures they'll actually be using, rather
than showing them everything and ignoring some of the results.

riscv64 is also the first architecture that post-dates the kernel's
64-bit time work, so there's a bit of extra fiddling needed to handle
the __NR3264_ indirection in the uapi headers.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: local builds for x86-64 and riscv64
Change-Id: I74044744e80b312088f805c44fbd667c9bfcdc69
2022-10-13 23:41:53 +00:00
Jingwen Chen
95ca177c58 Use allowlists.go for all bp2build config and remove Android.bp prop.
This was introduced when we didn't have allowlists.

Bug: 251197532
Test: presubmits
Change-Id: I83713dd9a0a059acda8e4565677d0c8c6b966749
2022-10-10 14:35:15 +00:00
Elliott Hughes
48e5333dd0 Pull in the riscv64 uapi headers for riscv64 builds.
Test: treehugger
Change-Id: I0c41a1a5b9805057609c68a49f67e6e24d4a0572
2022-10-07 20:39:25 +00:00
Florian Mayer
f8d7761525 Merge "Give init visibility into bionic headers." 2022-09-14 01:22:45 +00:00
Florian Mayer
f5d70cef37 Give init visibility into bionic headers.
Change-Id: Ia17a7382c6e3c51dab3694030e55796852d8b411
2022-09-13 13:59:26 -07:00
Spandan Das
6feb2ccfe9 Declare the headers of the ndk_library
This creates a dependency edge between the ndk_library and its headers,
which should be a no-op in regular Soong builds. This dependency edge
will be used in the Multi-tree project to export the relevant .h files into a well
known location

Test: m nothing
Bug: 239044713
Change-Id: I3f38edfbb8ce6b47dd4e73de4e1e0ad7a371799c
2022-09-08 23:44:35 +00:00
Treehugger Robot
2526b660fd Merge changes from topics "gwp-asan-headers", "native_handle_fdsan"
* changes:
  Open libasync_safe to any APEX
  Remove gwp_asan_headers from libc_defaults
2022-09-06 22:48:31 +00:00
Mitch Phillips
b09a3ca076 Remove gwp_asan_headers from libc_defaults
This turns out to over-export GWP-ASan headers to apexes. This is
unnecessary, GWP-ASan headers should only be referenced by libc
internally and debuggerd.

Test: m
Bug: N/A
Change-Id: I04bb8ceb094e681366a4931185906e67ce420c17
2022-09-02 11:52:20 -07:00
Treehugger Robot
d3c7700aa0 Merge "Exclude BUILD files from musl sysroot globs" 2022-08-12 21:14:52 +00:00
Colin Cross
1c0a7a09ff Exclude BUILD files from musl sysroot globs
Don't package the BUILD files into musl sysroots.

Test: build musl sysroot
Change-Id: I260a59a8c0cdd5b4249b657c8435c01fbb56eeb7
2022-08-12 11:49:24 -07:00
Elliott Hughes
f9fac36f15 Merge "Add C23's memset_explicit()." 2022-08-11 22:01:28 +00:00
Elliott Hughes
1f462dec34 Add %b and %B support to the scanf/wscanf and strto*/wcsto* families.
Coming to C23 via WG14 N2630.

This one is a little interesting, because it actually changes existing
behavior. Previously "0b101" would be parsed as "0", "b", "101" by these
functions. I'm led to believe that glibc plans to actually have separate
versions of these functions for C23 and pre-C23, so callers can have the
behavior they (implicitly) specify by virtue of which -std= they compile
with. Android has never really done anything like that, and I'm pretty
sure app developers have more than enough to worry about with API levels
without having to deal with the cartesian product of API level and C
standard.

Therefore, my plan A is "if you're running on Android >= U, you get C23
behavior". My plan B in the (I think unlikely) event that that actually
causes trouble for anyone is "if you're _targeting_ Android >= U, you
get C23 behavior". I don't think we'd actually want to have two versions
of each of these functions under any circumstances --- that seems by far
the most confusing option.

Test: treehugger
Change-Id: I0bbb30315d3fabd306905ad1484361f5d8745935
2022-08-11 00:25:08 +00:00
Elliott Hughes
0d64243407 Add C23's memset_explicit().
https://open-std.org/jtc1/sc22/wg14/www/docs/n2897.htm

Test: treehugger
Change-Id: Ia0cfc72bdf3c22eda6a4fc9adaa4c0ca0ff9a7c8
2022-08-10 23:36:16 +00:00
Elliott Hughes
ed777145e7 Tidy up the x86 atom/silvermont stuff similar to x86-64.
Get rid of the bad precedent of having the architecture variant in the
file name *and* directory name.

Test: treehugger
Change-Id: I78582c12b4390578c51d52d4dd86f57470129abf
2022-07-25 16:27:25 +00:00
ahs
919fb7f2e0 avx2 implementation for memset.
This patch includes handwritten avx2
assembly for memset 64-bit. Uses
non-temporal stores for very large sizes.
Also includes dynamic dispatch for APIs
having multiple implementations.

Convincing benchmark improvements for sizes above 512 bytes, and
although the slight regression for small sizes is unfortunate, it's
probably small enough to be okay?

Before:

  BM_string_memset/8/0            3.06 ns         3.04 ns    222703428 bytes_per_second=2.45261G/s
  BM_string_memset/16/0           3.50 ns         3.47 ns    202569932 bytes_per_second=4.29686G/s
  BM_string_memset/32/0           3.50 ns         3.48 ns    200064955 bytes_per_second=8.57386G/s
  BM_string_memset/64/0           3.49 ns         3.46 ns    201928186 bytes_per_second=17.2184G/s
  BM_string_memset/512/0          14.8 ns         14.7 ns     47776178 bytes_per_second=32.3887G/s
  BM_string_memset/1024/0         27.3 ns         27.1 ns     25884933 bytes_per_second=35.2515G/s
  BM_string_memset/8192/0          203 ns          201 ns      3476903 bytes_per_second=37.9311G/s
  BM_string_memset/16384/0         402 ns          399 ns      1750471 bytes_per_second=38.2725G/s
  BM_string_memset/32768/0         932 ns          925 ns       755750 bytes_per_second=33.0071G/s
  BM_string_memset/65536/0        2038 ns         2014 ns       347060 bytes_per_second=30.3057G/s
  BM_string_memset/131072/0       4012 ns         3980 ns       175186 bytes_per_second=30.6682G/s

After:

  BM_string_memset/8/0            3.32 ns         3.23 ns    208939089 bytes_per_second=2.3051G/s
  BM_string_memset/16/0           4.07 ns         3.98 ns    173479615 bytes_per_second=3.74822G/s
  BM_string_memset/32/0           4.07 ns         3.95 ns    177208119 bytes_per_second=7.54344G/s
  BM_string_memset/64/0           4.09 ns         4.00 ns    174729144 bytes_per_second=14.8878G/s
  BM_string_memset/512/0          10.7 ns         10.4 ns     65922763 bytes_per_second=45.6611G/s
  BM_string_memset/1024/0         18.0 ns         17.6 ns     40489136 bytes_per_second=54.3166G/s
  BM_string_memset/8192/0          109 ns          106 ns      6577711 bytes_per_second=71.7667G/s
  BM_string_memset/16384/0         221 ns          210 ns      3343800 bytes_per_second=72.684G/s
  BM_string_memset/32768/0         655 ns          623 ns      1153501 bytes_per_second=48.9781G/s
  BM_string_memset/65536/0        1547 ns         1495 ns       461702 bytes_per_second=40.8154G/s
  BM_string_memset/131072/0       2991 ns         2924 ns       240189 bytes_per_second=41.7438G/s

This patch drops the wmemset() code because we don't even have a
microbenchmark for it, we have as many implementations checked in as we
have non-test call sites (!), so at this point it seems like we've spent
more time maintaining wmemset() than running it!

Test: bionic/tests/run-on-host.sh 64
Signed-off-by: ahs <amrita.h.s@intel.com>
Change-Id: Ie5047df5300638c1e4c69f8285d33d034f79c83b
2022-07-22 21:48:50 +00:00
MarkDacek
d88d7ea329 Rename deps in libc to account for name/src collision work.
Test: m
Bug: 198619163
Change-Id: Ic41f7c1611d69c0c0936b8f5869a3450f1542b5c
2022-07-06 17:26:20 +00:00
Elliott Hughes
291f98a66d Switch to the more common idiom for scripts in genrules.
Bug: http://b/198619163
Test: treehugger
Change-Id: I8a6e9e179aef45e1b0622a2e15f80f92041f9736
2022-06-30 23:35:11 +00:00
Almaz Mingaleev
a52a0daf84 Set TZDEFAULT to NULL.
TZDEFAULT not applicable to bionic as there is no file per time
zone mapping.

Bug: 25413083

Test: CtsLibcoreTestCases
Test: CtsLibcoreOjTestCases
Test: CtsBionicTestCases
Change-Id: Ie489b5b2cda6c6f623f32e5413da77ec5eaa823f
2022-06-07 10:00:16 +01:00
Almaz Mingaleev
5411aff6bb Bump tzcode from 2016g to 2022a*.
Upstream has renamed tzsetlcl to tzset_unlocked. As bionic's
implementation of tzset_unlock differs from upstream, these changes were
skipped.

Also, upstream has removed constants (SECSPERMIN, etc) from tzfile.h. As
they are used in strptime.c, I've decided to leave them in tzfile.h and
to not bring them into strptime.c.

HAVE_TZNAME and USG_COMPAT flags semantics were updated, thus setting
their values to 2 in Android.bp file. See
1a27ec76bc

* 4742526b7e
and 0e8f0b06ac
were picked up, which are not part of 2022a.

Changes were applied using following commands:
  1) Checkout tzcode repo
  2) Prepare patches for all tzcode file using
    git diff 2016g 2021e -- <file-name> > <file-name-patch>
  3) Apply these patches to files in bionic using
    patch -p1 <file-name> <file-name-patch>

Bug: 25413083
Test: CtsLibcoreTestCases
Test: CtsLibcoreOjTestCases
Test: CtsBionicTestCases

Change-Id: I9aba4cbeab30171a32f94d20c8e4057804a4c01f
2022-06-07 09:59:16 +01:00
Mitch Phillips
3865c8f942 Merge "[GWP-ASan] Provide runtime configuration through an env var + sysprop." 2022-04-21 18:12:43 +00:00
Mitch Phillips
e6997d52de [GWP-ASan] Provide runtime configuration through an env var + sysprop.
This patch introduces GWP-ASan system properties and environment
variables to control the internal sampling rates of GWP-ASan. This can
be used for:

 1. "Torture testing" the system, i.e. running it under an extremely
    high sampling rate under GWP-ASan.
 2. Increasing sampling remotely to allow further crash report
    collection of rare issues.

There are three sets of system properites:
 1. libc.debug.gwp_asan.*.system_default: Default values for native
    executables and system apps.
 2. libc.debug.gwp_asan.*.app_default: Default values for non-system
    apps, and
 3. libc.debug.gwp_asan.*.<basename/app_name>: Default values for an
    individual app or native process.

There are three variables that can be changed:
 1. The allocation sampling rate (default: 2500) - using the environment
    variable GWP_ASAN_SAMPLE_RATE or the libc.debug.gwp_asan.sample_rate.*
    system property.
 2. The process sampling rate (default: 128 for system apps/processes, 1
    for opted-in apps) - using the environment variable
    GWP_ASAN_PROCESS_SAMPLING or the libc.debug.gwp_asan.process_sampling.*
    system property,
 3. The number of slots available (default: 32) - using the environment
    variable GWP_ASAN_MAX_ALLOCS or the libc.debug.gwp_asan.max_allocs.*
    system property.

If not specified, #3 will be calculated as a ratio of the default
|2500 SampleRate : 32 slots|. So, a sample rate of "1250" (i.e. twice as
frequent sampling) will result in a doubling of the max_allocs to "64".

Bug: 219651032
Test: atest bionic-unit-tests
Change-Id: Idb40a2a4d074e01ce3c4e635ad639a91a32d570f
2022-04-20 11:26:00 -07:00
Dan Albert
2d8d2a0064 Disable strict abigail checking pending asm fix.
Test: m ndk
Bug: http://b/190554910
Change-Id: Ideb0c6d8ac5428c2ebe211393929f1d5c891dfba
2022-03-29 15:59:00 -07:00
Colin Cross
471bef4d34 Merge "Use single module for libclang_rt.builtins-exported" 2022-03-08 06:51:43 +00:00
Christopher Ferris
d9b8d13a3a Remove dead subdirs directive.
I removed the bionic/scudo directory a while ago, but I must have
missed removing the subdirs from the Android.bp file.

Test: Builds.
Change-Id: I3e2a1f42b91273a566e587e923c7c3889a71ed17
2022-03-02 21:16:37 +00:00
Colin Cross
335e27b740 Use single module for libclang_rt.builtins-exported
The clang prebuilts now provide a single module with per-architecture
variants instead of a module per architecture.

Bug: 220019988
Test: m checkbuild
Ignore-AOSP-First: topic contains vendor projects
Change-Id: I079f36f94b13e06d59a16cf665b65db76084021a
Merged-In: I079f36f94b13e06d59a16cf665b65db76084021a
2022-03-01 11:36:55 -08:00
Colin Cross
ad33d02faa Add bionic NOTICE file to musl sysroot
Add the bionic NOTICE file to cover the headers included in the
musl sysroot.

Bug: 190084016
Test: examine libc_musl_sysroot.zip
Change-Id: I2b5e1b89e997ac370983e5959a83f09cdcc240e8
2022-02-25 18:27:04 -08:00
Colin Cross
aeef9f04d4 Avoid duplicate genrule locations
The bp2build build is failing with:
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:execinfo/include/execinfo.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:kernel/android/uapi/linux/compiler.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:b64/include/bionic/b64.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:kernel/uapi/linux/capability.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:kernel/android/scsi/scsi/scsi.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'

Rewrite the genrule to avoid referring to the same header twice by
using the NOTICE file as a known location in the bionic/libc directory.

Bug: 190084016
Bug: 218405924
Test: libc_musl_sysroot.zip has same contents
Change-Id: Id1a0484a3ed623bcc03b015d02eef19bbb31c06a
2022-02-07 21:08:41 -08:00
Colin Cross
9d4a56e490 Export kernel uapi, execinfo and b64 headers to musl sysroot
The musl sysroot needs kernel uapi headers, export them as a zip
file.  Also include the execinfo and b64 headers for libexecinfo
and libb64 that are embedded in musl libc.

Bug: 190084016
Test: m USE_HOST_MUSL=true libc_musl_sysroot
Change-Id: Ie862934f6dabd3fc6cbb9f5be01e21549bce51c2
2022-02-03 16:25:38 -08:00
Colin Cross
9da85fa4a0 Export bionic's resolv base64 functions to musl
Musl doesn't provide the resolv b64_* functions, but adb uses them.
Export them from bionic.

Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: I37837e6179a15754d4cbd89e67649df9dea9d9f1
2022-02-03 16:25:26 -08:00
Colin Cross
2a9843fe63 Export bionic's execinfo functions to musl
Musl doesn't provide the execinfo function.  Export the from bionic.

Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: I0361b84b0160d419cd857f5bb1314a58d0a69234
2022-02-03 16:25:21 -08:00
Elliott Hughes
a13d0660fe Use -fno-builtin for libc and libm.
clang was getting in the way of a strftime(3) optimization, and smaller
hammers weren't working, and this seems like the right choice for libc
anyway? If we have code that can usefully be optimized, we should do it
in the source. In general, though, no libc/libm author should be
ignorant of memset(3) or memcpy(3), and would have used it themselves if
it made sense. (And the compiler isn't using profiling data or anything;
it's just always assuming it should use the functions, and doesn't
consider whether the cost of the calls can be amortized or not.)

Test: treehugger
Change-Id: Ia7e22623e47bfbfcfe46c1af0d95ef7e8669c0f6
2021-12-02 14:42:16 -08:00
Yi Kong
9e33b76c67 Re-enable LTO for linker
Clang cannot build ifunc with LTO. This is a KI: https://bugs.llvm.org/show_bug.cgi?id=46488

Move the LTO: never down to libc itself, so that we can have LTO for the
rest of linker.

Test: m GLOBAL_THINLTO=true linker
Change-Id: I483fc3944e340638a664fb390279e211c2ae224b
2021-11-04 01:03:11 +08:00
Colin Cross
7edd008d6d Reland: "Make native bridge libc uninstallable"
The native bridge libc.so is overridden by
//frameworks/libs/native_bridge_support/libc:libc, mark it
installable: false to avoid a collision in the install rules.
Allows removing BUILD_BROKEN_DUP_RULES from cuttlefish builds.

Relands I5379aa9595a714efdbe1ddc1ff4f65bb45fc67e8 with a fix to
only apply to the shared variant.

Bug: 204136549
Test: m checkbuild
Change-Id: I84abb577e3bb924d39a369670d0b2dbfac45bbc4
2021-10-29 14:25:57 -07:00
Christopher Ferris
11526e2fc6 Add execinfo functionality.
Bug: 27877410

Test: Add new unit tests.
Change-Id: Id5d7eb27a23f50e99a04f5ee1ab64047ba269bab
2021-10-20 21:53:07 +00:00
Elliott Hughes
cf59e19e22 Add preadv2/pwritev2 wrappers.
They're in glibc, though not in musl.

Also add basic doc comments to the whole of <sys/uio.h>.

Bug: http://b/203002492
Test: treehugger
Change-Id: Ic607f7f349e5b7c9bf66c25b7bd68f827da530d6
2021-10-18 12:58:47 -07:00
Colin Cross
048f24ed2a Export fts as a static library for use with musl
musl libc doesn't provide fts, but elfutils and libabigail need it.
Export bionic's fts as a staic library that can be linked into elfutils
and libabigail when compiling against musl.

fts uses recallocarray, which musl doesn't provide, so also include
recallocarray.c in libfts.a.

Requires minor tweaks to fts.c and a wrapper around fts.h to make them
compatible with musl, primarily by providing local definitions of macros
provided in bionic's sys/cdefs.h.

Bug: 190084016
Test: m libfts
Change-Id: Ifac9a59e7504c0c1f5f8a3a5bd3c19a13980b83c
2021-09-08 15:53:10 -07:00
Colin Cross
69bcb8be27 Compile fts.c in libc_openbsd_ndk
fts.c is from openbsd and has compatibility macros to make it compile
as part of bionic.  Move it into libc_openbsd_ndk where it will
get the workarounds from -include openbsd-compat.h instead.

Test: m libc
Change-Id: I213d423af8f010e39460b611e902acbf3561ae7a
2021-09-08 13:26:46 -07:00
Colin Cross
5d50dbb5f0 Export kernel headers for musl
Musl will reuse bionic's kernel headers.

Bug: 190084016
Test: m libc_musl
Change-Id: Ie750556f9a055984eb9bab41fa61faa965f037e5
2021-07-23 15:01:58 -07:00
Colin Cross
02f813703a Rename cc_object default_shared_libs to system_shared_libs
default_shared_libs has been removed, go back to the system_shared_libs
property that now has the same behavior.

Bug: 193559105
Test: m checkbuild
Change-Id: I9edac93f7e6d9d4b99883b7a7b14ab52942c0ef2
2021-07-22 12:02:10 -07:00
Treehugger Robot
2ffa0eb7d3 Merge "Move system_shared_libs into target.bionic clause" 2021-07-22 17:44:32 +00:00
Bowgo Tsai
8f14b65032 Revert "Adding system property tracing"
Revert submission 1403568-sysprop_trace

Reason for revert: makes property get/set non-reentrant
Reverted Changes:
I6f85f3f52:Add systrace tag for system property
Id2b93acb2:Adding system property tracing
Id78992d23:Add systrace tag for system property
I1ba9fc7bd:Add systrace tag for system property

Bug: 193050299
Test: build and boot a device
Change-Id: Ic7a83fb01a39113d408ed0c95d27f694d5a2649c
Merged-In: Ic7a83fb01a39113d408ed0c95d27f694d5a2649c
(cherry picked from commit 61a5a8380d)
2021-07-21 09:15:41 +08:00
Colin Cross
b5bfe0bd51 Move system_shared_libs into target.bionic clause
Use target.bionic.system_shared_libs when it is used to limit the
default shared libraries (as opposed to remove them completely).
This avoids attempting to add a host dependency on libc when
system_shared_libs is modified to apply to all variants.

Bug: 193559105
Test: m checkbuild
Change-Id: I8d623321ce5145cf2968f83f78b5cb50711290f4
2021-07-13 16:26:28 -07:00
Colin Cross
ab1b143efa Remove obsolete visibility entries from libc_headers
cc_objects get libc headers by default now unless they opt out through
system_shared_libs: [] or default_shared_libs: [], so they no longer
need explicit visibility.

Fixes: b/153662223
Test: m nothing
Change-Id: Ib61a597cbfee4616a632abdfbf4b4f108d35c2b6
2021-07-12 15:57:01 -07:00
Colin Cross
10d9268676 Add default_shared_libs to crt objects
cc_object modules will now honor the default_shared_libs, override
it to empty to avoid circular dependencies.

Bug: 153662223
Test: m checkbuild
Change-Id: I02dd9510fcc0b6bf724d9cdd7c3e80c08430a7b9
2021-06-23 16:44:57 -07:00
Lukacs T. Berki
a2b7c3fbec Remove sort_bss_symbols_by_size .
Test: Presubmits.
Change-Id: I03b502e75e0964942ec2bf197722c77542e956db
2021-06-02 08:12:04 +02:00
Colin Cross
a0a4a6c296 Replace llndk_library with llndk clause in cc_library
Remove the vestigial llndk_library and replace it with properties
in the llndk clause of the implementation cc_library.

In order to reduce duplication of the arch-specific headers used
by the implementation and LLNDK, rename libc_headers_arch to
libc_llndk_headers and hoist the "include" directory out of it,
since that directory is preproccessed separately for LLNDK
libraries.

Bug: 170784825
Test: m checkbuild
Test: compare out/soong/build.ninja
Change-Id: I75f0ff9129d910640da55eee6a6387467e6e4a9d
2021-04-26 17:45:57 -07:00
Treehugger Robot
4b42ad753e Merge "Reorder libc.llndk headers to match libc_headers_arch" 2021-04-23 02:51:32 +00:00
Rupert Shuttleworth
ed80dcd775 Add missing liblog_headers dependency to libc_defaults.
This unblocks several targets building with Bazel, see https://android-review.googlesource.com/c/platform/build/soong/+/1677125.

Test: bp2build; bazel build //bionic/...
Change-Id: I4206241fc56cf4df5d5f1e65a367844da85a1360
2021-04-22 01:52:53 -04:00
Colin Cross
96be371187 Reorder libc.llndk headers to match libc_headers_arch
Ease later comparisons by making libc.llndk match libc_headers_arch.

Bug: 170784825
Test: m checkbuild
Change-Id: I90162c0bc5f6f0e79fe974208fde47cca7489fa1
2021-04-21 16:29:50 -07:00
Elliott Hughes
f20b021903 Merge "Make res_init() work again." 2021-04-12 17:44:50 +00:00
Elliott Hughes
d0bbfa8327 Make res_init() work again.
Change 75830fb836 to fix _nres
initialization to be thread safe accidentally introduced a behavior
change whereby res_init() became a no-op. It also failed to remove all
direct accesses to _nres.

Move the file over to C++ so we can let RAII ensure we're always holding
a lock while using the global state, make all callers access the global
state via this class, and restore the previous behavior of res_init().

Test: atest DnsResolverTest
Bug: 166235340
Change-Id: Ib390a7eac063bc0ff5eeba755e8c74ef1383004e
2021-04-08 12:04:05 -07:00
Bram Bonné
bca8a4474b Revert "Reland: Soft-enable MAC address restrictions with allowlist."
Revert "Updates CTS tests for MAC address restrictions."

Revert submission 1528409-mac-softrestrict

Reason for revert: App compatibility
Reverted Changes:
I74a50b990:Return anonymized MAC for apps targeting SDK < 30
I8738f7912:Reland: Soft-enable MAC address restrictions with ...
Id13670747:Updates CTS tests for MAC address restrictions.

Change-Id: I64e17cb04acf2862bc657e60694067a456b4f936
2021-04-08 11:39:33 +02:00
Liz Kammer
eb33b5b7a8 Merge "Remove bazel_module.label from bionic genrules" 2021-03-16 21:40:04 +00:00
Treehugger Robot
35428fe99d Merge "Depend on libasync_safe module instead of breaking package boundary." 2021-03-16 17:01:07 +00:00
Liz Kammer
6a4177c42d Merge "Add missing includes for crtend modules" 2021-03-16 12:43:35 +00:00
Rupert Shuttleworth
78f48a511f Depend on libasync_safe module instead of breaking package boundary.
This makes Bazel conversion easier (because in Bazel package boundaries really matter).

Test: m libc still builds, and m also builds.
Change-Id: I5cfc9d83dffd3110ffad9ce03198e6141c8c5b33
2021-03-16 06:39:19 +00:00
Liz Kammer
aab2ad700b Add missing includes for crtend modules
Test: convert bp2build_available targets to BUILD and bazel build
      --platforms=//build/bazel/platforms:generic_arm64 //bionic/...
Change-Id: I1cbdbf1d65d7dbe95665aaac08004c80f82433e9
2021-03-15 18:03:24 -04:00
Mitch Phillips
87f4a2e50b Merge "Mark MTE elf notes as sdk_version to allow SDK linkage." 2021-03-15 21:33:07 +00:00
Liz Kammer
e718dd720d Merge crt cc_objects
Currently there is a pattern of `crtbegin_${type}1` and `crtbegin_${type}` modules, where the former
has sources and the latter depends on the former. The two modules for a type share many properties,
rather than duplicating these, we merge modules, such that each type only has a `crtbegin_${type}`
module.

Test: Treehugger
Change-Id: I7803ea0e97d660f620c334b6bfdfac22cb6e36d7
2021-03-10 19:32:17 +00:00
Mitch Phillips
22c90755ed Mark MTE elf notes as sdk_version to allow SDK linkage.
Binaries defined in Makefiles that use the SDK need a variant to link
to. Generate a SDK variant of the ELF note as well. This is necessary to
allow makefile-generated binaries and CTS tests to use heap MTE.

Bug: 156029370
Bug: 181133973

Test: atest CtsBionicTestCases on QEMU+MTE, observe previously-failing
      tests will now succeed.
Change-Id: I0a8243b0920769a196e7596904259e30c4a93105
2021-03-03 15:39:57 -08:00
Liz Kammer
8d7082ebda Remove bazel_module.label from bionic genrules
Mixed builds can now use the label from an automatically converted
target.

Test: build/bazel/scripts/milestone-2/demo.sh full
Test: build/bazel/scripts/milestone-2/demo.sh generate
      build/bazel/scripts/milestone-2/demo.sh sync
      mixed build of libc
      build/bazel/scripts/milestone-2/demo.sh cleanup
Change-Id: I1499b75f1348bf342b4cd134606786150b2f8b26
2021-03-03 15:25:18 +00:00
Josh Gao
974721431d Merge "Add wrappers for pidfd_{open,getfd,send_signal}." 2021-03-01 21:06:17 +00:00
Josh Gao
3de19151e5 Add wrappers for pidfd_{open,getfd,send_signal}.
Bug: http://b/172518739
Test: `/data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter="*pidfd*"` on blueline
Change-Id: Ibae32bbedbcf26535a80a5cbfb55ce180906b610
2021-02-25 13:55:12 -08:00
Christopher Parsons
47b5c5d752 Merge "Make libc genrules and its tool dep bp2build_available" 2021-02-25 16:23:46 +00:00
Chris Parsons
98b92e00c8 Make libc genrules and its tool dep bp2build_available
Test: lunch aosp_flame && USE_BAZEL_ANALYSIS=1 m libc
Test: lunch aosp_flame && USE_BAZEL_ANALYSIS=1 m crtbegin_so1
Change-Id: I12380ef9294f8b7c3b00ea700d804c1abde7ad04
2021-02-24 14:32:16 -05:00
Jingwen Chen
7e13cf2160 bp2build: convert more cc_objects
This is the last of remaining cc_objects in the libc package.

Test: go tests.

Test: build/bazel/scripts/milestone-2/demo.sh
Change-Id: Ib9c01be0faae10707305b81e72d3fac22bf96356
2021-02-24 01:21:01 -05:00
Jingwen Chen
19787b9412 bp2build: mark filegroups as bp2build_available.
Test: build/bazel/scripts/milestone-2/demo.sh
Change-Id: Ife199b1860521c55baa96cadc42bd021556c62cd
2021-02-22 03:08:45 -05:00
Bob Badour
8ae9d017f3 Merge "Add LOCAL_LICENSE_KINDS to bionic" 2021-02-21 15:24:32 +00:00
Jingwen Chen
5e4a499e25 Merge "bp2build: convert more cc_objects." 2021-02-20 04:53:19 +00:00
Bob Badour
aa7d835fdd Add LOCAL_LICENSE_KINDS to bionic
Added SPDX-license-identifier-Apache-2.0 to:
  apex/Android.bp
  libdl/Android.bp
  tools/Android.bp
  tools/versioner/Android.bp
  tools/versioner/src/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  benchmarks/Android.bp
  benchmarks/linker_relocation/gen/Android.bp
  libc/malloc_debug/Android.bp
  libc/system_properties/Android.bp
  tests/Android.bp
  tests/libs/Android.bp
  tests/libs/Android.build.dlext_testzip.mk
  tests/make_fortify_compile_test.mk

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-ISC SPDX-license-identifier-MIT
    legacy_notice legacy_unencumbered
to:
  libc/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT legacy_unencumbered
to:
  libm/Android.bp

Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered
to:
  libc/tools/Android.bp

Added SPDX-license-identifier-BSD
to:
  benchmarks/linker_relocation/Android.bp
  benchmarks/spawn/Android.bp
  libc/async_safe/Android.bp
  libc/malloc_hooks/Android.bp
  libfdtrack/Android.bp
  linker/Android.bp
  tests/headers/Android.bp
  tests/headers/posix/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Exempt-From-Owner-Approval: janitorial work
Change-Id: Ib05bcaa276b3aa71a7654ccbe8e67e1f16aec9f3
2021-02-19 23:38:28 +00:00
Treehugger Robot
b69a0d4969 Merge "Move __libc_int0x80 to an assembly file" 2021-02-19 19:27:48 +00:00
Jingwen Chen
0b1611e637 bp2build: convert more cc_objects.
This CL also discovered that a couple of cc_objects include headers from the bionic subdir, without declaring them in the local_include_dirs.

Test: build/bazel/scripts/milestone-2/demo.sh full && build/bazel/scripts/milestone-2/demo.sh cleanup
Change-Id: I943980b1d1c6dab39d3c27da8037e587f97f76e3
2021-02-19 09:29:41 -05:00
Jingwen Chen
5daf8f9c3f bp2build: mark crt_beginso1 as bp2build_available.
This leaf module is selected as the first cc_object module to be converted by
the bp2build converter.

Test: GENERATE_BAZEL_FILES=true m nothing && bp2build-sync write && bazel build //bionic/libc:crt_beginso1
Change-Id: Idf752e7b5251161a4fbd58ba52b52dd85c8fc92b
2021-02-19 00:27:32 +00:00
Pirama Arumuga Nainar
7b89be78f4 Move __libc_int0x80 to an assembly file
Bug: http://b/157081822

If __libc_int0x80 is in a C/C++ file, Clang's coverage instrumentation
adds instructions to count the number of times it gets executed [1].
With coverage instrumentation, __libc_sysinfo, used on 32-bit x86, is
initialized to the wrong value, causing dl.preinit_system_calls to fail.

Moving the function to an assembly file leaves __libc_sysinfo properly
initialized.

[1] We could change clang so it doesn't instrument functions marked
__attribute__((naked)) as a followup.

Test: `m CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS=bionic` and run
bionic-unit-tests

Change-Id: I73558253512392d345de8d5b66d38bb14b308fdf
2021-02-18 09:52:59 -08:00
Rupert Shuttleworth
fd64868a92 Mark cc_library_headers targets as being bp2build_available.
Test: build/bazel/scripts/bp2build-sync.sh write.
Change-Id: I78a491d20779f50757b55c8e5305b588bf613839
2021-02-16 03:39:20 +00:00
Jingwen Chen
d6a3b780de Mark //bionic filegroups/genrules as bp2build_available.
Test: GENERATE_BAZEL_FILES=true m nothing && build/bazel/scripts/bp2build-sync.sh write && bazel build //bionic/...
Change-Id: Ie3e0092a3a03ddc6228a9191e5b78ab206072dde
2021-02-08 01:44:35 -05:00
Jingwen Chen
ca36633eba Move gensseccomp and genfunctosyscallnrs next to their sources.
This is a manual refactoring to ensure that the modules respect package boundaries for input files.

Test: m gensseccomp genfunctosyscallnrs
Change-Id: I8ca6cbe85a50e41bfe874a899653c2309c59a822
2021-02-02 07:24:24 -05:00
Ryan Prichard
15ade069b1 Merge changes from topic "builtins-exported"
* changes:
  Use exported variants of arm32/x86 builtins
  Fix -Wl,--exclude-libs typo: x86->i686
2021-02-02 00:30:03 +00:00
Mitch Phillips
bfa3688606 Merge "[MemInit] Remove old API, introduce new MemInit API." 2021-02-01 23:32:24 +00:00
Ryan Prichard
c22562ce6f Use exported variants of arm32/x86 builtins
For backwards compatibility (e.g. with old apps), arm32 libc.so and
libm.so export some of the builtins. On 32-bit x86, libc.so also
exports some of the builtins.

The non-exported variant of the builtins will eventually have hidden
symbols but doesn't currently because D93431 hasn't been merged into
our toolchain yet. See:
 - https://reviews.llvm.org/D93431
 - I44ec79728db92c089e2f39823c35b6f97d24c1ab in toolchain/llvm_android

Bug: http://b/153025717
Test: bionic unit tests
Change-Id: Ic489cb06a07ef61412502fc65a21b0cf630c11ed
2021-01-28 15:42:37 -08:00
Mitch Phillips
9cad8424ff [MemInit] Remove old API, introduce new MemInit API.
Introduces new heap-zero-init API. We've realised that it's better to be
able to individually control MTE and heap zero-init. Having
heap-zero-init not be controllable without affecting MTE affects our
ability to turn off heap-zero-init in zygote-forked applications.

Bug: 135772972
Test: On FVP: atest -s localhost:5555 malloc#zero_init \
Test: malloc#disable_mte heap_tagging_level
Change-Id: I8c6722502733259934c699f4f1269eaf1641a09f
2021-01-25 15:19:31 -08:00
Jiyong Park
7cff764f3c Merge changes from topic "future_symbol"
* changes:
  crtbegin_static is built with min_sdk_version: "current"
  Guard __libc_current_sigrtmin/max with __builtin_available
  __INTRODUCED_IN macros add the availability attribute
2021-01-21 16:33:05 +00:00
Colin Cross
d65b31fad6 Merge "Don't set native_bridge_supported: true for ndk libraries" 2021-01-20 17:49:36 +00:00
Colin Cross
d9a9622c31 Don't set native_bridge_supported: true for ndk libraries
Native bridge modules will never compile against stubs, remove
native_bridge_supported: true.

Test: m checkbuild
Change-Id: I0eb93fe1a2c3f6ca34ce4dab17edda8807132ce8
2021-01-19 14:58:25 -08:00
Jiyong Park
268a60019d crtbegin_static is built with min_sdk_version: "current"
crtbegin_static is used by static exectuables which are guaranteed to be
with the latest library regardless of their target API level.

This change is in fact not a regression as crtbegin_static has been
built with __ANDROID_API__=10000 before
I645e6bb1234c27ae0a69b7b87a59206cfd350744 when __ANDROID_API__ tracked
sdk_version, not min_sdk_version. sdk_version was not set for crtbegin_*
objects and therefore the default "current" was (incorrectly) used.

With this change, we are recovering the original behavior for the static
variant, while the building of the dynamic variant becomes more correct
- it's now with __ANDROID_API__=16.

Without this change, several static executables fail to build as 1)
crtbegin_static for them is built with __ANDROID_API__=16 and 2)
libc_init_common.cpp uses pthread_atfork which is available only after
API level 23. We hit undefined symbol error when linking.

Bug: 134795810
Test: m

Change-Id: I1430e57302951df33530ea0ae91b0d7a0609bf3d
2021-01-15 10:40:51 +09:00
Ryan Prichard
cdf7175fa5 Switch libc.so and linker to prebuilt LLVM libunwind
For libc.so, use a special build of libunwind.a whose symbols aren't
hidden ("libunwind-exported"), because libc.so exports the _Unwind_*
APIs.

Bug: http://b/153025717
Test: bionic unit tests
Change-Id: I7435e076ec8cc4410e3e6086d3cf5d2c6011c80c
2021-01-14 17:35:05 -08:00
Elliott Hughes
b1ba762e34 Merge "Fewer copies of ALIGN()/ALIGNBYTES." 2021-01-11 21:50:40 +00:00
Elliott Hughes
e1dc4f62eb Fewer copies of ALIGN()/ALIGNBYTES.
Noticed while updating fts.c.

Bug: http://b/177003648
Test: treehugger
Change-Id: Ic3625c1c3af47c4dafb8ad686bbbddbc82b69b70
2021-01-11 11:51:29 -08:00
Peter Collingbourne
7e20117a36 Remove ANDROID_EXPERIMENTAL_MTE.
Now that the feature guarded by this flag has landed in Linux 5.10
we no longer need the flag, so we can remove it.

Bug: 135772972
Change-Id: I02fa50848cbd0486c23c8a229bb8f1ab5dd5a56f
2021-01-11 10:55:51 -08:00
Evgenii Stepanov
8564b8d9e6 Use ELF notes to set the desired memory tagging level.
Use a note in executables to specify
(none|sync|async) heap tagging level. To be extended with (heap x stack x
globals) in the future. A missing note disables all tagging.

Bug: b/135772972
Test: bionic-unit-tests (in a future change)

Change-Id: Iab145a922c7abe24cdce17323f9e0c1063cc1321
2021-01-06 16:08:18 -08:00
Treehugger Robot
5ec23f14b5 Merge "Changes to bionic/libc to demonstrate mixed builds." 2020-12-17 23:36:25 +00:00
Chris Parsons
8b768d3f1a Changes to bionic/libc to demonstrate mixed builds.
Test: source build/envsetup.sh && lunch 16 && source
build/soong/bazel/bazelenv.sh && m, then verify ninja
file was based on intermediates from bazel-out

Change-Id: I89f320dd58083710012ea1f8e3902e723602ea37
2020-12-17 11:05:01 -05:00
Bram Bonné
95ca52a7d6 Reland: Soft-enable MAC address restrictions with allowlist.
Soft-limits apps from calling bind() on NETLINK_ROUTE sockets, and
getting link info through getifaddrs(), while still allowing apps on the
allowlist to temporarily perform these actions.

This is different from existing behavior, where apps targeting an API
level < 30 were exempted from this restriction.

Actual enforcement will happen through SELinux (as is currently the
case for apps targeting API >= 30). This temporary change will then be
reverted.

If you arrived at this change due to an app showing unexpected behavior,
please file a bug at go/netlink-bug.

Bug: 170188668
Bug: 170214442
Test: Call bind() on NETLINK_ROUTE for an app on the allowlist.
Test: Call bind() on NETLINK_ROUTE for an app not on the allowlist.
Test: Call getifaddrs() for an app on the allowlist.
Test: Call getifaddrs() for an app not on the allowlist.
Test: Call bind() on a AF_UNIX socket with its protocol set to
NETLINK_ROUTE, confirm it can succeed.
Test: Verify that previously broken apps are no longer broken.

Change-Id: I8738f7912fdc816e0d30205557728ff9e84bf7e6
2020-12-15 16:52:58 +01:00
Bram Bonné
9e97280414 Revert "Soft-enable MAC address restrictions with allowlist."
Revert "Updates CTS tests for MAC address restrictions."

Revert submission 1518603-soft-restrict-mac

Reason for revert: Missing type check
Reverted Changes:
I0488932de:Soft-enable MAC address restrictions with allowlis...
Idb9d940e4:Updates CTS tests for MAC address restrictions.
I9461f287e:Return anonymized MAC for apps targeting SDK < 30

Change-Id: I7e8e593518088ff5c8f6083b34e6966852475b9b
2020-12-14 14:14:23 +01:00
Bram Bonné
0ed9f70122 Merge "Soft-enable MAC address restrictions with allowlist." 2020-12-11 11:01:40 +00:00
Bram Bonné
0ba499896a Soft-enable MAC address restrictions with allowlist.
Soft-limits apps from calling bind() on NETLINK_ROUTE sockets, and
getting link info through getifaddrs(), while still allowing apps on the
allowlist to temporarily perform these actions.

This is different from existing behavior, where apps targeting an API
level < 30 were exempted from this restriction.

Actual enforcement will happen through SELinux (as is currently the
case for apps targeting API >= 30). This temporary change will then be
reverted.

If you arrived at this change due to an app showing unexpected behavior,
please file a bug at go/netlink-bug.

Bug: 170188668
Bug: 170214442
Test: Call bind() on NETLINK_ROUTE for an app on the allowlist.
Test: Call bind() on NETLINK_ROUTE for an app not on the allowlist.
Test: Call getifaddrs() for an app on the allowlist.
Test: Call getifaddrs() for an app not on the allowlist.
Change-Id: I0488932deea2a7211e55a24bc33bfa3cfb16fba2
2020-12-10 11:55:45 +01:00
Elliott Hughes
439ebbd349 Simplify and improve tempnam() and tmpnam().
They're both obsolescent in POSIX.1-2008, and you really shouldn't be
using them, but since we can't actually delete them...

This change makes them both obey $TMPDIR if set, and fall back to
/data/local/tmp otherwise. That's as good as we've managed for anything
else such as tmpfile(3).

Also add some tests.

Bug: http://b/174682340
Test: treehugger
Change-Id: Ieef99dcc2062f84b2b7cbae046787fdfe975e772
2020-12-08 22:26:06 -08:00
Justin Yun
869a0faf21 Add "product_available" to product available modules
"vendor_available" modules were available to product modules.
However, not all "vendor_available" modules are required to be
available to product modules. Some modules want to be available only
to product modules but not vendor modules.

To cover the requirement, we separate "product_available" from
"vendor_available".
"vendor_available" will not provide product available module.

Bug: 150902910
Test: build
Change-Id: I13b8222e191333c6c2cb7794ef3344fdcc6ebe98
2020-11-11 15:29:47 +09:00
Yifan Hong
02bee7182e Merge "Make vendor_ramdisk_available." 2020-10-29 17:17:29 +00:00
Yifan Hong
b04490d7e5 Make vendor_ramdisk_available.
Test: pass
Bug: 156098440
Change-Id: I8fe2deb8fa3b24c227202be02d8af648629cffeb
2020-10-27 17:06:45 -07:00
Colin Cross
8393a8bc84 Make the connection between implementation and llndk_library explicit
Instead of assuming a module with the .llndk suffix exists, add an
llndk_stubs property to every cc_library module that has a
corresponding llndk_library.  Also rename the llndk_library to have
an explicit .llndk suffix.

Bug: 170784825
Test: no changes to build.ninja (excluding comments) or Android-${TARGET_PRODUCT}.mk
Change-Id: Ib5453472a09ebc64818ceb69bcbe1184720ce86a
2020-10-19 13:37:49 -07:00
Baligh Uddin
db0c6deed6 Fix visibility rules.
BUG: 163786882
Test: Local build + TH
Change-Id: I788af6cf17ebee1fa5001768389a2c8b855c3534
2020-10-16 15:46:59 +00:00
Steven Moreland
0cdf132f84 Expose per-process memory init.
In order to disable memory initialization for a process, the following
command can be used:

    android_mallopt(M_DISABLE_MEMORY_MITIGATIONS, nullptr, 0);

Since this is needed in vendor processes, this is exposing this
functionality to llndk. For convenience (and adding standard logging),
a helper function is being added into libcutils in order to use this,
w/o having to get into so many details.

Bug: 166675194
Test: use function from libcutils
Change-Id: Ia816089a9f3469c50c70afaa7244abeac5a51dcd
2020-10-09 00:33:30 +00:00
Peter Collingbourne
5d3aa86cd1 Add an API for per-process disabling memory initialization.
Introduce an android_mallopt(M_DISABLE_MEMORY_MITIGATIONS) API call
that may be used to disable zero- or pattern-init on non-MTE hardware,
or memory tagging on MTE hardware. The intent is that this function
may be called at any time, including when there are multiple threads
running.

Disabling zero- or pattern-init is quite trivial, we just need to set
a global variable to 0 via a Scudo API call (although there will be
some separate work required on the Scudo side to make this operation
thread-safe).

It is a bit more tricky to disable MTE across a process, because
the kernel does not provide an API for disabling tag checking in all
threads in a process, only per-thread. We need to send a signal to each
of the process's threads with a handler that issues the required prctl
call, and lock thread creation for the duration of the API call to
avoid races between thread enumeration and calls to pthread_create().

Bug: 135772972
Change-Id: I81ece86ace916eb6b435ab516cd431ec4b48a3bf
2020-10-08 14:02:36 -07:00
Yi Kong
15a05a77b4 No global ThinLTO for bionic
There are multiple build breakages with bionic when we enable ThinLTO
globally. Opt bionic out of ThinLTO for now.

#global-thinlto-opt-out

Test: TreeHugger
Bug: 169004486
Change-Id: I546a8074f9c3e0ddbd01d3b7cd730e215e3c0c49
2020-09-29 17:24:04 +00:00
Dan Albert
bda85584d1 Merge "Avoid explicit use of "10000" in build files." 2020-09-24 21:02:12 +00:00
Tom Cherry
379ed1ef62 Explicitly add the include path for android_filesystem_config.h
android_filesystem_config.h is found since system/core/include is on
the include path for all projects and contains a symlink to the real
android_filesystem_config.h.  This is fragile and the below bug seeks
to remove this symlink and have users correctly depend on
libcutils_headers.

In bionic, libcutils_headers header library cannot be used due to
cyclic dependencies, so it gets the actual include path instead, which
is less bad than depending on the build system injecting the for all
modules.

Bug: 165825252
Test: build
Change-Id: Id43bdea9553b1174ceb3efc2a3ed505888619c62
2020-09-21 10:09:25 -07:00
Bowgo Tsai
d0ecf0b30d Adding system property tracing
Introducing a new systrace tag, TRACE_TAG_SYSPROP, for use with
system property.

For property set, the tracing is added in __system_property_set() instead of
__system_property_update() / __system_property_add() so we can record
control properties like ctl.*, sys.powerctl.*, etc.., which won't be
updated via the latter two functions.

Bug: 147275573
Test: atest CtsBionicTestCases
Test: adb shell perfetto -o /data/misc/perfetto-traces/test_trace -t 10s bionic
Test: adb shell perfetto -o /data/misc/perfetto-traces/test_trace -t 10s sysprop
Test: adb shell /data/benchmarktest64/bionic-benchmarks/bionic-benchmarks \
      --benchmark_filter=BM_property --bionic_cpu=4, then compares the results
      of property benchmarks before and after the change, didn't see
      significant difference.

Change-Id: Id2b93acb2ce02b308c0e4889f836159151af3b46
Merged-In: Id2b93acb2ce02b308c0e4889f836159151af3b46
(cherry picked from commit 26970c3493)
2020-08-19 12:47:01 +08:00
Dan Albert
48943b20c0 Avoid explicit use of "10000" in build files.
Test: treehugger
Bug: None
Change-Id: Iab713c5f4b53665f8224b3857beaa6a1d19f8d69
2020-08-13 13:35:17 -07:00
Vy Nguyen
d4d7efc1f8 Merge "Add a thread-properties API (Based on proposal at https://sourceware.org/glibc/wiki/ThreadPropertiesAPI)" 2020-08-13 19:58:03 +00:00
Dan Albert
dc503f65ec Create per-API versions of the CRT objects.
Test: treehugger
Bug: http://b/159925977
Change-Id: I3ad629f9370503b26f4a73787bccb3f669c41a0a
2020-08-11 14:14:31 -07:00
Vy Nguyen
d500751443 Add a thread-properties API
(Based on proposal at https://sourceware.org/glibc/wiki/ThreadPropertiesAPI)

This includes API to:
 - locate static and dynamic TLS
 - register thread-exit and  dynamic TLS creation/destruction callbacks

Change-Id: Icd9d29a5b2f47495395645e19d3b2c96826f19c8
2020-08-11 16:51:43 +00:00
Elliott Hughes
f08e70a0d9 Merge "Reimplement our no-op utmp.h functions more simply." 2020-08-10 15:41:13 +00:00
Elliott Hughes
9a1d3976f1 Reimplement our no-op utmp.h functions more simply.
Now we're being marked down for our poor coverage, we may as well remove
more broken cruft. Despite the amount of effort that seems to have gone
into pututline(), it wasn't working with the other utmp.h functions (in
particular, utmpname()), and wasn't declared in the header file!

Test: treehugger
Change-Id: I1a583984189c751168c11c01431433f96f8c548b
2020-08-07 17:07:31 -07:00
Elliott Hughes
422b2044ea Merge "Switch to musl memmem (via OpenBSD)." 2020-08-07 20:01:17 +00:00
Elliott Hughes
5633caa285 Switch to musl memmem (via OpenBSD).
Similar to the musl strstr. This patch also increases test coverage for
memmem, again similar to the strstr tests.

Test: treehugger
Change-Id: I7f4a2ab93a610cb692994d06d2512976e657ae9f
2020-08-06 14:33:48 -07:00
Treehugger Robot
e41012fe2e Merge "Enable coverage for libc." 2020-08-05 23:23:48 +00:00
Pirama Arumuga Nainar
8035caa311 Enable coverage for libc.
Bug: http://b/157081822

- Disable coverage for libtest_check_rtld_next_from_library to make
dlfcn.rtld_next_from_library to pass.
- The coverage runtime sets an environment variable to prevent
clobbering of the coverage data on disk.  Include that variable as well
when checking `printenv` output.  This is done at runtime by checking
for LLVM_PROFILE_FILE environment variable.
- dl.preinit_system_calls still fails after this change.

Test: bionic tests with libc coverage turned on.

Change-Id: I3ea2b0800886d8c0984969a4ee8bfb0da03c33b0
2020-08-05 14:58:40 -07:00
Steven Moreland
7591bb5ee1 Merge "SCUDO fill options only when USE_SCUDO" 2020-08-04 17:47:36 +00:00
Bowgo Tsai
a9208f3ac2 Moving bionic_systrace.cpp out of libc_bionic_ndk
We'll be enabling system tracing in libsystemproperties, which requires
using bionic_systrace.cpp from libc_bionic_ndk. However, libc_bionic_ndk
already depends on libsystemproperties.

Introducing a new library libc_bionic_systrace for bionic_systrace.cpp,
which can be used by both libc_bionic_ndk and libsystemproperties.

Bug: 147275573
Test: atest CtsBionicTestCases
Test: adb shell perfetto -o /data/misc/perfetto-traces/test_trace -t 10s bionic
Change-Id: I7306f922f212fa1c911583e1922e33612bfeada6
2020-08-04 11:08:05 +08:00
Elliott Hughes
26b06073f6 Sync with upstream OpenBSD.
Test: treehugger
Change-Id: I1fc649ba5d79a3d95242c6b2240dbb05c85d30e9
2020-07-31 13:01:38 -07:00
Steven Moreland
fb65ee4c47 SCUDO fill options only when USE_SCUDO
For vanity reasons, this CL should be reverted after b/158870657, since
we want to make sure zero/pattern fill always happen when they are
requested.

Bug: 131355925
Bug: 158870657
Test: check build on normal devices hits USE_SCUDO branch with #error
Change-Id: I22d19dbc75004c8f7437e1247226bc3275cd4df5
2020-07-31 17:45:44 +00:00
Christopher Ferris
ef707f9056 Remove references to libc_scudo.
As scudo is now the default native allocator, there is no need to
keep this library around.

Test: Builds and walleye boots.
Change-Id: Id2918544651348854956d1348d2a634f6425b952
Merged-In: Id2918544651348854956d1348d2a634f6425b952
(cherry picked from commit 941ad56299)
2020-06-22 15:27:52 -07:00
Victor Hsieh
dbb8670dfd Use more inclusive language for seccomp filter
blacklist and whitelist are replaced with blocklist and allowlist
respectively.

Test: CtsSeccompHostTestCases
Change-Id: I39d9eda89038d1addbdaed59284a254a34cea1c6
2020-06-15 10:12:17 -07:00
Peter Collingbourne
dc39f6e23b Merge "Adopt remaining MTE string routines." 2020-06-11 19:30:15 +00:00
Peter Collingbourne
2361d4ef80 Adopt remaining MTE string routines.
ARM has released the remaining MTE string routines, so let's start
using them. The strnlen implementation is now compatible with MTE,
so it no longer needs to be an ifunc.

Bug: 135772972
Change-Id: I9de7fb44447aa1b878f4ad3f62cb0129857b43ad
2020-06-11 08:52:26 -07:00
Victor Khimenko
8e0707d82c Move exit.c from stdlib to bionic subdirectory.
Test: make

Change-Id: I2182d5a7c97abc0335e88d2d9dd9f77bc7e7f633
2020-06-10 16:38:05 +02:00
Peter Collingbourne
642b374e64 Merge "Define mte_supported() on non-aarch64." 2020-05-21 20:49:11 +00:00
Bram Bonné
acadd09c66 Speed up seccomp with priority list.
Allow to provide a list of prioritized syscalls (e.g., syscalls that we
know occur often) which are checked before other syscalls in seccomp.

When constructing the bpf seccomp filter, traverse prioritized syscalls
in a linear list before checking all other syscalls in a binary tree.

Bug: 156732794
Test: make, inspect generated *_system_policy.cpp files
Test: simpleperf on futex/ioctl-heavy app seems to show 5-10% less time
spent in seccomp call

Change-Id: I509343bcd32ada90c0591785ab5cb12d2a38c31e
(cherry picked from commit ce84677733)
2020-05-18 11:20:30 +02:00
Jooyung Han
1beacd440b libc_scudo: Set min_sdk_version to apex_inherit
Switched min_sdk_version from 29(hard-coded) to "apex_inherit".
From the build system perspective, nothing changes.

This change is to sync with internal code because it's been changed
while cherry-picking.

Bug: 145796956
Test: m
Change-Id: I567ddad0bd54087cdf9a30cbe42e239977a028dd
2020-05-13 16:55:10 +09:00
Peter Collingbourne
1541800aa7 Define mte_supported() on non-aarch64.
It turns out that we need this on non-aarch64 more than I thought
we would, so let's start defining it everywhere.

Also expose platform headers to sanitizer-status.

Bug: 135772972
Change-Id: Ia7fd8a9bca0c123c4ca2ecd5f250f3a628a5513b
2020-05-12 16:03:50 -07:00
Jiyong Park
262ff01d2b Merge "Set apex_available property" 2020-05-10 06:25:04 +00:00
Jiyong Park
4ede160cb1 Set apex_available property
The marked library(ies) were available to the APEXes via the
hand-written whitelist in build/soong/apex/apex.go. Trying to remove the
whitelist by adding apex_available property to the Android.bp of the
libraries.

Exempt-From-Owner-Approval: cherry-pick from internal

Bug: 150999716
Test: m
Merged-In: If64eff62b9e93af95089e5010c30eb586673b92e
(cherry picked from commit 693a7214d6)
Change-Id: If64eff62b9e93af95089e5010c30eb586673b92e
2020-05-10 06:24:42 +00:00
Treehugger Robot
073c3dc1eb Merge "Add goldfish-opengl to use bionic_libc_platform_headers" 2020-05-08 00:53:07 +00:00
Roman Kiryanov
067f51824b Add goldfish-opengl to use bionic_libc_platform_headers
We need __get_tls and TLS_SLOT_OPENGL for our
OpenGL implementation. We currently use .mk files
and this restriction does not apply, since we are
migrating to .bp we need to address restriction.

Bug: 154151802
Test: presubmit
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: I007664d919204cd4f6a623f9695a56e94bab7ae6
2020-05-07 15:06:55 -07:00
Martin Stjernholm
82d84bcd7e Make Bionic and kernel system includes explicit in the blueprints.
Before this Soong added hardcoded system include paths to
bionic/libc/{include,kernel}, which won't work when Bionic libs are
packaged up as prebuilts in an SDK module snapshot.

Test: Build and boot
Test: Check in out/verbose.log.gz that a C file doesn't get any bionic
  include path for linux_glibc.
Bug: 153590472
Change-Id: I13c8eb3dd7150d6e0fee001b290b53fcebebcfea
2020-05-05 13:34:14 +01:00
Jooyung Han
15c32a8e1a Set min_sdk_version for mainline dependencies
To enforce all modules included in mainline modules(apex/apk),
modules should set min_sdk_version which is the minimum sdk versions
that compiled artifacts run against.

Setting this doesn't change build output.

Bug: 145796956
Test: m
Change-Id: Ibbe3771592677d729c81343fe00859c0afa81918
2020-05-05 10:45:46 +09:00
Evgenii Stepanov
5a73e03305 [libc] Zero and pattern initialization of heap memory.
Bug: 155227507
Test: scudo_unit_tests

Change-Id: I85075acfd85172f6cc7e48f79eeb577e293d0d30
2020-05-01 14:06:54 -07:00
Martin Stjernholm
82c1096cac Merge "Reland "Make bionic_platform_headers available only for Bionic targets"." 2020-04-30 14:11:50 +00:00
Josh Gao
b107eab5ef fdtrack: add wrapper for socketpair.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I8b25accf00dc01f6fab351f3ba612f6b0ff9d094
2020-04-29 17:21:16 -07:00
Josh Gao
7de412443d fdtrack: add wrapper for eventfd.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I59013f0c4da0debbcc50269c64ae9db0cdc4eaa0
2020-04-29 17:21:16 -07:00
Martin Stjernholm
a276343e14 Reland "Make bionic_platform_headers available only for Bionic targets".
The triggering reason for this change is that the SDK snapshot
generation cannot readily handle header libraries that are required for
targets that the SDK itself isn't available for. However, these include
files shouldn't be used without Bionic anyway.

Relanding unchanged - the build problem was due to a split topic.

Test: m checkbuild (on aosp_taimen)
Test: m (on aosp_taimen_hwasan)
Test: atest CtsBionicTestCases
Test: lunch fvp-userdebug && mmm bionic
Bug: 152255951
Change-Id: Iaf49597ea265e6f2a042de5ee873238073b2e545
2020-04-29 18:14:11 +01:00
Martin Stjernholm
ed95d0134d Revert "Make bionic_platform_headers available only for Bionic t..."
Reason for revert: Breaks rvc-d1-dev-plus-aosp: http://ab/6443190
Reverted Changes:
Ide447b89a:bionic_libc_platform_headers is only available whe...
Ia93cd3ec8:bionic_libc_platform_headers is only available whe...
Icdc495588:Make bionic_platform_headers available only for Bi...
Idfd7c87dc:bionic_libc_platform_headers is only available whe...

Bug: 152255951
Bug: 155269399
Change-Id: I214f1165bb0a7e59d3b35a13b3cceb1965be922b
2020-04-29 12:18:36 +00:00
Martin Stjernholm
249f726583 Make bionic_platform_headers available only for Bionic targets.
The triggering reason for this change is that the SDK snapshot
generation cannot readily handle header libraries that are required for
targets that the SDK itself isn't available for. However, these include
files shouldn't be used without Bionic anyway.

Test: m checkbuild (on aosp_taimen)
Test: m (on aosp_taimen_hwasan)
Test: atest CtsBionicTestCases
Test: lunch fvp-userdebug && mmm bionic
Bug: 152255951
Change-Id: Icdc49558893c5355860f78d23275c49ba0119900
2020-04-27 19:07:01 +01:00
Jooyung Han
1d9ccdfb1a Merge "libc: Add stubs.versions=R" 2020-04-25 04:41:43 +00:00
Ryan Prichard
a992a06701 x86: Switch get_pc_thunk to comdat
Switch the __x86.get_pc_thunk.{bx,cx} functions from .gnu.linkonce to
comdat section groups. lld doesn't implement .gnu.linkonce and will
instead discard the input sections. Currently, it might produce a
faulty binary that has no get_pc_thunk function in it, which would
crash.

Normally, these functions are generated by GCC and are present in many
object files compiled with PIC. Clang doesn't use them, and instead
initializes the PIC base register with a "call 1f; 1: pop %ebx" pair.

Bug: http://b/154376560
Bug: https://bugs.llvm.org/show_bug.cgi?id=45594
Test: bionic-unit-tests
Change-Id: I3e4857aecdc281b32232270bff4880433e5b6afa
2020-04-20 14:28:10 -07:00
Peter Collingbourne
23ec1421b5 Merge "Add PTRACE_PEEKTAG to mte_kernel.h." 2020-04-17 18:16:05 +00:00
Jooyung Han
dbfa074a76 libc: Add stubs.versions=R
Add version R to libc so that APEXes can rely on version R stubs of
libc.

Bug: 152655956
Test: m
Merged-In: I70d17702d9885760af658e23ac6e3106405ff3bc
Change-Id: I70d17702d9885760af658e23ac6e3106405ff3bc
(cherry picked from commit 75e79c92dc)
2020-04-09 16:03:33 +09:00