Commit graph

623 commits

Author SHA1 Message Date
Spandan Das
fe2907c133 Add versions property to libc_hwasan stubs
bp2build will generate the stub targets only if versions is not empty.

Test: b query //bionic/libc:* | grep libc_hwasan_stub_libs-current

Change-Id: Iac905497ae4955a44b7b29e2d29a2c702c86da8e
2023-04-18 16:38:46 +00:00
Florian Mayer
ff116eda61 Fix build error on darwin_arm64
Change-Id: Ie5bc9252de8349c3bfb8269919c0a173a9d9cc2d
2023-04-14 17:50:59 -07:00
Florian Mayer
4967017c86 Merge "Introduce hwasan mode for linker" 2023-04-14 23:27:56 +00:00
Florian Mayer
c10d064b5c Introduce hwasan mode for linker
This mode instructs the linker to search for libraries in hwasan
subdirectories of all library search paths. This is set up to contain a
hwasan-enabled copy of libc, which is needed for HWASan programs to
operate. There are two ways this mode can be enabled:

* for native binaries, by using the linker_hwasan64 symlink as its
  interpreter
* for apps: by setting the LD_HWASAN environment variable in wrap.sh

Bug: 276930343
Change-Id: I0f4117a50091616f26947fbe37a28ee573b97ad0
2023-04-14 01:33:30 -07:00
Treehugger Robot
97950cb186 Merge "Rename files/modules that have the same name" 2023-04-12 01:12:14 +00:00
Cole Faust
f5968d82f5 Rename files/modules that have the same name
Bazel doesn't like it when modules produce files with the same name
as the module itself, and gives warnings.

Rename either the module or file in this case so that the file has
an extension and the module doesn't.

Bug: 198619163
Test: m nothing
Change-Id: Ic4592b06f575496ffd54ac75cb4d682118b29d93
2023-04-11 15:20:19 -07:00
Treehugger Robot
4473a937df Merge "Revert "Workaround boot loop by turning off stack protector check for noreturn calls"" 2023-04-11 15:04:46 +00:00
Yi Kong
66c09671fa Revert "Workaround boot loop by turning off stack protector check for noreturn calls"
This reverts commit 9b4cf9733f.

Fixed by https://reviews.llvm.org/D147975.

Change-Id: I2de39359783d739fd7f9da410fd78421638dbd70
2023-04-11 06:56:31 +00:00
Dan Albert
eee46dc744 Exclude crtbrand.o from the NDK sysroot.
Bug: None
Test: None
Change-Id: I8cb860d9c47b9140926531d21f7864b8d7cbcba3
2023-04-04 23:27:52 +00:00
Yi Kong
ab3a319746 Merge "Workaround boot loop by turning off stack protector check for noreturn calls" 2023-03-24 13:19:52 +00:00
caowencheng
9a39eb3469 Increase the implementation of __memcpy_chk assembly
Use __memcpy_chk assembly to replace the implementation of c functions, which can reduce the use of instructions

Test: llvm-objdump

Change-Id: I5d75601626dc997626f6173d53af301183a64004
Signed-off-by: caowencheng <caowencheng@eswincomputing.com>
2023-03-21 02:05:14 +00:00
Yi Kong
9b4cf9733f Workaround boot loop by turning off stack protector check for noreturn calls
clang-r487747 added stack protector capability to check noreturn calls.
This caused the system to boot loop. Turn off the new capabilities as a
temporary workaround.

Test: build and boot
Change-Id: I62c912619dfdd2384672d504ce5d52330bf2a102
2023-03-12 19:45:55 +09:00
Elliott Hughes
529c16a678 Merge "memset_chk into assembly file" 2023-03-06 20:53:36 +00:00
caowencheng
ab457f9022 memset_chk into assembly file
Writing an assembly file can reduce several
assembly instructions, and compare it through
the disassembly of this file

Test: make libc
Change-Id: Ifdcc9c76742cc95b2ad9e3c14fac4796c36e12e6
Signed-off-by: caowencheng <caowencheng@eswincomputing.com>
2023-03-06 07:23:10 +00:00
Elliott Hughes
20dd3fed7a Pull flockfile/funlockfile/ftrylockfile into stdio.cpp.
These are just one-liners, and the _FLOCK() macro seemed to me more
obscure than just inlining it (especially because there are only four
call sites total, so it's not like anyone's going to see that macro very
often).

Also add the missing CHECK_FP() calls. I don't expect this to break
anything, but if it does we can add a target API level check.

Test: treehugger
Change-Id: Ifa1a39d5d9eee46cca783acbe9ec3b3a1e6283d9
2023-03-02 01:44:54 +00:00
Pierre-Clément Tosi
39aed9c58a Merge "librust_baremetal: Add libc_netbsd" 2023-02-24 19:42:45 +00:00
Pierre-Clément Tosi
eb46ac9ae4 librust_baremetal: Add libc_netbsd
Get bsearch and other baremetal-compatible functions from NetBSD.

Bug: 249723852
Bug: 262344886
Test: -
Change-Id: Idd90188ae13c84ed35af8f1475370cec0fe8cdbb
2023-02-21 15:47:01 +00:00
Treehugger Robot
f81027468c Merge "librust_baremetal: No HAVE_ASSEMBLER___MEMCPY_CHK" 2023-02-14 00:57:52 +00:00
Pierre-Clément Tosi
467e58e9ea libc_fortify: Fix typo
Test: -
Change-Id: I7ad5def655d0dbfe6b0138d322ca0c25c32c4635
2023-02-09 12:14:17 +00:00
Mitch Phillips
3d577a836d Merge "Add the recoverable GWP-ASan feature." 2023-02-03 18:35:08 +00:00
Mitch Phillips
a493fe4153 Add the recoverable GWP-ASan feature.
GWP-ASan's recoverable mode was landed upstream in
https://reviews.llvm.org/D140173.

This mode allows for a use-after-free or a buffer-overflow bug to be
detected by GWP-ASan, a crash report dumped, but then GWP-ASan (through
the preCrashReport() and postCrashReportRecoverableOnly() hooks) will
patch up the memory so that the process can continue, in spite of the
memory safety bug.

This is desirable, as it allows us to consider migrating non-system apps
from opt-in GWP-ASan to opt-out GWP-ASan. The major concern was "if we
make it opt-out, then bad apps will start crashing". If we don't crash,
problem solved :). Obviously, we'll need to do this with an amount of
process sampling to mitigate against the 70KiB memory overhead.

The biggest problem is that the debuggerd signal handler isn't the first
signal handler for apps, it's the sigchain handler inside of libart.
Clearly, the sigchain handler needs to ask us whether the crash is
GWP-ASan's fault, and if so, please patch up the allocator. Because of
linker namespace restrictions, libart can't directly ask the linker
(which is where debuggerd lies), so we provide a proxy function in libc.

Test: Build the platform, run sanitizer-status and various test apps
with recoverable gwp-asan. Assert that it doesn't crash, and we get a
debuggerd report.
Bug: 247012630

Change-Id: I86d5e27a9ca5531c8942e62647fd377c3cd36dfd
2023-02-02 15:35:25 -08:00
Elliott Hughes
98c641b096 Merge "Sync strptime.c with upstream." 2023-01-23 22:04:29 +00:00
Treehugger Robot
6ffb6e89f9 Merge "librust_baremetal: Add strtol" 2023-01-23 10:59:25 +00:00
Treehugger Robot
716ed9b931 Merge "librust_baremetal: Add memcpy_chk" 2023-01-12 16:26:17 +00:00
Treehugger Robot
c22ef226a3 Merge "Merge librust_baremetal_defaults into its library" 2023-01-05 20:01:06 +00:00
Chih-Hung Hsieh
e343db3f54 Disable clang-tidy for upstream files.
Bug: 264302877
Test: presubmit tests; make tidy-bionic_subset
Change-Id: I278201c62e70898103bf20ce8823106418c8fb05
2023-01-03 15:08:22 -08:00
Pierre-Clément Tosi
eeb53ac80a librust_baremetal: No HAVE_ASSEMBLER___MEMCPY_CHK
Stop defining the unnecessary CPP macro.

Test: TH
Change-Id: Ided365bdd77854f3840ed865537ef43d7cdd00c3
2023-01-03 18:08:31 +00:00
Pierre-Clément Tosi
816176ccd6 librust_baremetal: Add strtol
Add strtol (required by libfdt), which only depends on libc functions
the library already provides or requires.

Bug: 232900974
Test: m pvmfw_bin # with aosp/2314779
Change-Id: I460571b64369c6bf45fef213252f305e978c694d
2023-01-03 18:07:26 +00:00
Pierre-Clément Tosi
199a62e39b librust_baremetal: Add memcpy_chk
Add __memcpy_chk (used by BoringSSL) and start documenting the
dependencies that the baremetal environment needs to provide to
successfully link the library.

Bug: 256148034
Bug: 256827715
Test: m pvmfw_bin && atest vmbase_example.integration_test
Change-Id: I0d61f4efc5cc26a95b74870be7cd7eebeeb0bd3a
2023-01-03 18:05:30 +00:00
Pierre-Clément Tosi
3af5799387 Merge librust_baremetal_defaults into its library
Test: m pvmfw_bin
Change-Id: I14e74019fc64865af615d033f508bfb0d71eef2f
2023-01-03 17:57:42 +00:00
Treehugger Robot
746ed77a29 Merge "Introduce minimal static libc for baremetal Rust" 2022-12-15 00:22:20 +00:00
Pierre-Clément Tosi
74a1458116 Introduce minimal static libc for baremetal Rust
LLVM/rustc compiling no_std code expects a few libc symbols to be
defined (memcpy, memset, memcmp). Previously, we used the arm64 library
directly; instead, make the dependency arch-agnostic by exporting it
from Bionic, making it easier to add more libc functions (that might not
be implemented by the optimized routines), as necessary.

Test: m pvmfw_bin && atest vmbase_example.integration_test
Change-Id: I1d2cc69a25bbb7eddc67357a028b7b79d4909e79
2022-12-13 14:17:50 +00:00
Elliott Hughes
d3627a444f Sync strptime.c with upstream.
We still have local differences, but this minimizes (and documents) them.

Bug: http://b/167569813
Test: treehugger
Change-Id: Ib90e6ccc5ec1224e7ee89224a51b87fc48c9931f
2022-12-12 20:56:12 +00:00
Elliott Hughes
8d9549e28a Move some cruft from the build system to the source.
It's more intention-revealing this way round anyway...

Test: treehugger
Change-Id: I561d8ac3003fa6b7f19fcf7110a6646c69bdd936
2022-12-09 19:58:00 +00:00
Elliott Hughes
023e4e7840 Move to arm-optimized-routines memset().
This one's a bit simpler, because there is only one upstream memset()
implementation.

Test: treehugger
Change-Id: I2536d0eb72adaacfa6a0e40d2bd29fc833988c16
2022-11-17 19:28:06 +00:00
Elliott Hughes
7daf4596b7 Switch to the arm-optimized-routines memcpy() and memmove().
Outsource this to them, and choose the best of the two options available
based on the hardware we're running on.

Test: treehugger
Change-Id: I2fa7555c971b64a6decca132210e901ffa248efa
2022-11-17 00:38:49 +00:00
Treehugger Robot
d26d3c0b5c Merge "Implement __memset_chk as a copy & paste of __memcpy_chk." 2022-11-16 23:33:14 +00:00
Elliott Hughes
3cc366d3a2 Implement __memset_chk as a copy & paste of __memcpy_chk.
These two will stay behind when we move memcpy()/memmove()/memset() over
to arm-optimized-routines (which leaves fortify to us).

Test: treehugger
Change-Id: Ie683f71a5a141263ce3f4e8811df9eaf667584f4
2022-11-16 21:07:56 +00:00
Elliott Hughes
0d4d276253 Remove assembler wmemmove().
The compiler turns our C wmemmove() into one shift instruction and a
branch, which is plenty for a function no-one uses anyway.

Why don't I just leave this alone, since we already have it? Because I'm
looking at finishing the project of "switch to arm-optimized-routines"
and getting rid of our assembler here, and Arm agrees that this isn't
worth having optimized assembler for in their optimized assembler
project, judging by its absence.

Test: treehugger
Change-Id: I985801241a8cbd7dbda51a447946affb1402effb
2022-11-16 18:44:56 +00:00
Colin Cross
0f917240bd Merge "Add a zip package containing the crt*.o objects" 2022-10-21 17:43:15 +00:00
Colin Cross
290c495c24 Add a zip package containing the crt*.o objects
The ndk sysroot does not include the crt*.o objects, package them
separately for use in the llvm toolchain build.

Test: lunch aosp_riscv64-userdebug && m bionic_sysroot_crt_objects
Change-Id: I0bda12b7979a026441bb67387709ee94b3249b6b
2022-10-20 20:17:07 -07:00
Treehugger Robot
579088b354 Merge "Add riscv64 kernel headers to the ndk sysroot" 2022-10-21 02:34:59 +00:00
Colin Cross
bd26e0fd89 Add riscv64 kernel headers to the ndk sysroot
Add riscv64 kernel headers to the ndk sysroot for use by the LLVM
toolchain build.  They will not be shipped in the real NDK.

Test: lunch aosp_riscv64-userdebug && m ndk_sysroot
Change-Id: I804e66b56919b84fa5dc03d432ae673ea4f31615
2022-10-20 15:15:26 -07:00
Yu Liu
938ec9b7e8 Refactor the bp file to avoid arch variant in cc_genrule.
The arch variant of genrule.out will be soon disallowed in soong.

Bug: 253645813
Test: Manually build.
Change-Id: I2d5daa67b4e10f4abddebc98775df18df485843f
2022-10-18 17:23:17 -07:00
Treehugger Robot
8333532f3b Merge "Revert "Refactor the bp file to avoid arch variant in cc_genrule."" 2022-10-18 04:48:28 +00:00
Treehugger Robot
b15a64f722 Merge "riscv64 setjmp." 2022-10-18 04:09:55 +00:00
Yu Liu
3a57969a6f Revert "Refactor the bp file to avoid arch variant in cc_genrule."
This reverts commit ed2654cfdc.

Reason for revert: breaks aosp-master

Change-Id: I8236e3e31e208e8719df52f6b1488af919b37d94
2022-10-18 03:02:32 +00:00
Yu Liu
86ef94783b Merge "Refactor the bp file to avoid arch variant in cc_genrule." 2022-10-18 02:19:03 +00:00
Yu Liu
ed2654cfdc Refactor the bp file to avoid arch variant in cc_genrule.
The arch variant of genrule.out will be soon disallowed in soong.

Bug: 253645813
Test: Manually build.
Change-Id: Ia07d45195de8c22f18487aef34795279d2962c4c
2022-10-17 16:36:30 -07:00
Elliott Hughes
e1905ed629 riscv64 setjmp.
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: m
Change-Id: I02cf117f67bda74516e4de8cd6f4c05efdb9a85b
2022-10-17 23:23:36 +00:00
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