Commit graph

2321 commits

Author SHA1 Message Date
Christopher Ferris
44dfd3ebab Merge "Add android_mallopt M_GET_DECAY_TIME_ENABLED." into main am: 35aaed9e1b am: be90376e0c am: 41f64cc03d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2810911

Change-Id: Ib46ad5bb6ed2dbd74462544ffe940f348bf24586
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-31 03:56:04 +00:00
Christopher Ferris
b4e560ed7c Add android_mallopt M_GET_DECAY_TIME_ENABLED.
The bionic benchmarks set the decay time in various ways, but
don't necessarily restore it properly. Add a new method for
getting the current decay time and then a way to restore it.

Right now the assumption is that the decay time defaults to zero,
but in the near future that assumption might be incorrect. Therefore
using this method will future proof the code.

Bug: 302212507

Test: Unit tests pass for both static and dynamic executables.
Test: Ran bionic benchmarks that were modified.
Change-Id: Ia77ff9ffee3081c5c1c02cb4309880f33b284e82
2023-10-30 15:30:16 -07:00
Nate Myren
19d8167626 Merge "Write appcompat_override system properties" into main 2023-10-19 19:29:59 +00:00
Nate Myren
ae7f33dd57 Write appcompat_override system properties
Create a second set of system properties, that can be overlaid over the
real ones if necessary, for appcompat purposes.

Bug: 291814949
Ignore-AOSP-First: Aosp -> internal merge conflict
Test: manual, treehugger, system_properties_test

Change-Id: I884a78b67679c1f0b90a6c0159b17ab007f8cc60
2023-10-18 17:28:42 -07:00
Mitch Phillips
25ab1c2abf Merge "Use DYNAMIC entries for MTE enablement" into main am: 363e743200 am: 3b3a96de07 am: 059d2db070
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2765590

Change-Id: I307efae2207df52c9dffdfb920fa9df075d5c695
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-18 12:31:48 +00:00
Mitch Phillips
363e743200 Merge "Use DYNAMIC entries for MTE enablement" into main 2023-10-18 10:17:37 +00:00
Mitch Phillips
7c1f3770af Use DYNAMIC entries for MTE enablement
Adds support for the dynamic entries to specify MTE enablement. This is
now the preferred way for dynamically linked executables to specify to
the loader what mode MTE should be in, and whether stack MTE should be
enabled. In future, this is also needed for MTE globals support.

Leave the existing ELF note parsing as a backup option because dynamic
entries are not supported for fully static executables, and there's
still a bunch of glue sitting around in the build system and tests that
explicitly include the note. When -fsanitize=memtag* is specified, lld
will create the note implicitly (along with the new dynamic entries),
but at some point once we've cleaned up all the old references to the
note, we can remove the notegen from lld.

Bug: N/A
Test: atest bionic-unit-tests CtsBionicTestCases --test-filter=*Memtag*
Test: Build/boot the device under _fullmte.

Change-Id: I954b7e78afa5ff4274a3948b968cfad8eba94d88
2023-10-17 13:49:24 +02:00
Elliott Hughes
32c281cbb8 Merge "Clarify the fcntl() "that's not how F_SETFD works" error." into main am: b4e2219987 am: dfb9662b24 am: 4f1282b9bf am: 98c1a703b7 am: a4427fa9ab
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2780900

Change-Id: I7bc9c9f3e374731e0fdcf7b0815e09ff011a67b5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-12 20:35:45 +00:00
Elliott Hughes
25af17c587 Clarify the fcntl() "that's not how F_SETFD works" error.
The first app developer (we know of) that hit this didn't understand
what it was trying to tell them.

Before:
    FORTIFY: fcntl(F_SETFD) passed non-FD_CLOEXEC flag: 0x801

After:
    FORTIFY: fcntl(F_SETFD) only supports FD_CLOEXEC but was passed 0x801

Bug: https://issuetracker.google.com/304348746
Test: treehugger
Change-Id: I8522e851d8f74c91152ebae68b083b5272d49255
2023-10-12 16:04:14 +00:00
Elliott Hughes
f1ce4648a9 Merge "Remove <ctype.h> cruft." into main am: 389a40a0a8 am: a468e56569 am: bc717f9b8d am: 4ca2aabbff am: ac7ef66045
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2455758

Change-Id: If05fcc6343f23138f026fe0759948ca3f6fae967
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-07 00:59:27 +00:00
Elliott Hughes
389a40a0a8 Merge "Remove <ctype.h> cruft." into main 2023-10-06 19:49:26 +00:00
Elliott Hughes
e37068889d Remove <ctype.h> cruft.
The NDK only supports API 21 and later, so we don't need to worry
about older API levels any more.

All the functions in this file are trivial, being but a single
instruction on most architectures. For that reason, we inline them by
default. (We continue to also provide actual symbols for any caller
that needs them --- in particular existing binaries!)

Also inline all the _l() variants too. No-one should be using them,
but since we're already using trickery to only implement the non-_l()
variants once, we may as well use the same trick for both.

Test: treehugger
Change-Id: I17637c49dd14be9e5ecb8246e72e8acc662739f1
2023-10-06 15:06:17 +00:00
Elliott Hughes
7add1bbca8 Merge "Add strerrordesc_np() and strerrorname_np()." into main am: a67fe1b171 am: d37c19670a am: 5f921a71e1 am: 546379ea3d am: a2224bbe45
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2760166

Change-Id: Iae04cc2f17e272e0212b92dbeb5d776aeeb8cc62
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-28 04:05:28 +00:00
Elliott Hughes
2109f12c3b Add strerrordesc_np() and strerrorname_np().
strerrordesc_np() isn't very useful (being just another name for
strerror()), but strerrorname_np() lets you get "ENOSYS" for ENOSYS,
which will make some of our test assertion messages clearer when we
switch over from strerror().

This also adds `%#m` formatting to all the relevant functions.

Test: treehugger
Change-Id: Icfe07a39a307d591c3f4f2a09d008dc021643062
2023-09-27 11:21:12 -07:00
Elliott Hughes
7eac72c3cc Merge "Add epoll_pwait2()." into main am: 906d7d41e4 am: 484056aaf2 am: 96a6c6abc1 am: a607f6744f am: cbaea16804
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2656904

Change-Id: I8915b268e7ec3c1abe1ff11d8090ca8f84316b97
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-06 01:48:32 +00:00
Elliott Hughes
906d7d41e4 Merge "Add epoll_pwait2()." into main 2023-09-05 21:48:08 +00:00
Yabin Cui
ac668cc137 Merge "Let executables not rely on sentinels in preinit_array/init_array/fini_array" into main am: 4d3903eab9 am: 7ea5e44c24 am: 0774e1ef51 am: 745305bb5c am: afefe1c2c2
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2725997

Change-Id: I423ecb4bf9822058ceb7f2ae215c3b3f693ee7a2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-01 21:32:03 +00:00
Yabin Cui
0774e1ef51 Merge "Let executables not rely on sentinels in preinit_array/init_array/fini_array" into main am: 4d3903eab9 am: 7ea5e44c24
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2725997

Change-Id: Idcfe610a1a10dafdc5b999834dfa2ec4e72785e6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-01 19:01:34 +00:00
Yabin Cui
7ea5e44c24 Merge "Let executables not rely on sentinels in preinit_array/init_array/fini_array" into main am: 4d3903eab9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2725997

Change-Id: Ia86ca98c161ebdc6d631ccbdd1ea416298879858
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-01 18:08:55 +00:00
Yabin Cui
744cfd3720 Let executables not rely on sentinels in preinit_array/init_array/fini_array
Currently, we use sentinels (starting with -1 and ending with 0) in
preinit_array/init_array/fini_array in executables. But after using LTO,
the sentinels can be reordered by LLD and no longer work. So make below
changes to not rely on them:
  1. In crtbegin.c, use symbols (like __init_array_start) inserted by the
     linker.
  2. Add array_count fields in structors_array_t.
  3. In static libc, use array_count fields to decide array lengths.
  4. To make new dynamic executables work with old libc.so, create a fake
     fini_array with sentinels, and pass it to __libc_init. The fake
     fini_array contains a function to call functions in real fini_array.
  5. To make old dynamic executables work with new libc.so, libc.so
     still uses sentinels to decide the length of fini_array.

Bug: 295944813
Bug: https://github.com/android/ndk/issues/1461
Test: run bionic-unit-tests-static
Test: test static executables manually
Test: boot cf_gwear_x86-trunk_staging-userdebug
Change-Id: I1ce31f07bcfe0e99b4237984898a8fc9e98ff426
2023-09-01 10:17:05 -07:00
Elliott Hughes
4c238d8dea Merge "__riscv_hwprobe: don't try to set errno." into main am: 4de14c7499 am: e62a9e0329 am: d086dd0ef4 am: e888177487 am: 95c3c58d2e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2731044

Change-Id: Ia88d2ff7a36534c56969ba62a48518c164c35dea
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-30 20:15:29 +00:00
Elliott Hughes
d086dd0ef4 Merge "__riscv_hwprobe: don't try to set errno." into main am: 4de14c7499 am: e62a9e0329
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2731044

Change-Id: Ie20354036f9bd578b23344a5e6388ee68bfcb274
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-30 16:51:25 +00:00
Elliott Hughes
e62a9e0329 Merge "__riscv_hwprobe: don't try to set errno." into main am: 4de14c7499
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2731044

Change-Id: I9a73661a7e500e689285e62f57773b727d94ce5b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-30 16:02:53 +00:00
Elliott Hughes
92424f76cb Merge "<termios.h>: add two new POSIX functions." into main am: b130e6dae0 am: f9189bb67d am: 0e87776adc am: 42fd8dbd98 am: 678e06ac31
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2729340

Change-Id: I4289276cf2977a006d1a771e8bec2a74a7902912
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-30 01:39:55 +00:00
Elliott Hughes
0e87776adc Merge "<termios.h>: add two new POSIX functions." into main am: b130e6dae0 am: f9189bb67d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2729340

Change-Id: I42a8041d25c29bd58ffdd91e29a3feef8ec85be4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-29 23:16:11 +00:00
Elliott Hughes
fce8a155df __riscv_hwprobe: don't try to set errno.
When used in an ifunc resolver, errno@plt won't be available. This is
the API the rivos folks contributing to glibc are leaning towards, for
the same reason. Hit by the berberis folks because they don't implement
the syscall so they were trying to set errno to ENOSYS.

Tested by looking at the generated assembler, and also disabling the
vdso (since on actual systems, this will go via the vdso).

Test: treehugger
Change-Id: Ie2779110f141f20efe97cb892fbdefd808b5339b
2023-08-29 15:41:36 -07:00
Elliott Hughes
f9189bb67d Merge "<termios.h>: add two new POSIX functions." into main am: b130e6dae0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2729340

Change-Id: I8640dfffbc43c7a5c0a5b1dcd42d8b031b25eb4b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-29 22:25:52 +00:00
Elliott Hughes
647472db9b <termios.h>: add two new POSIX functions.
musl already added tcgetwinsize() and tcsetwinsize(), but I didn't
notice.

Trivial single-line inlines added to a header that's already written
that way.

Test: treehugger
Change-Id: Iac95ea6a89f3872025c512f7e61987b81d0aafa7
2023-08-29 09:33:04 -07:00
Xin Li
5439bde949 Merge "Merge Android U (ab/10368041)" into aosp-main-future 2023-08-28 22:13:38 +00:00
Elliott Hughes
7dae3812d7 Merge "sysconf(): implement cache queries." into main am: a71a15fe34 am: 3996bbe901 am: a9ca959498 am: 3e268603ec am: 6a12624063
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721536

Change-Id: I115e6e6175972cf111078edad7ed67ed8de76df3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-28 17:54:43 +00:00
Elliott Hughes
a71a15fe34 Merge "sysconf(): implement cache queries." into main 2023-08-28 14:48:20 +00:00
Elliott Hughes
02df7388f1 sysconf(): implement cache queries.
This is a bit disappointing. I'd not implemented this in the past
because it wasn't available on all platforms, and -- although the
riscv64 implementation was just a cool optimization -- I thought that
the /sys stuff was actually portable, until I ran it on arm64 hardware.
So here we have getauxval() for riscv64, /sys for x86-64, and our best
guess based on ctr_el0 for arm64.

Bug: http://b/294034962
Test: ran tests on the host, an arm64 device, and riscv64 host and qemu
Change-Id: I420b69b976d30668d4d2ac548c4229e2a4eafb20
2023-08-28 14:48:12 +00:00
Elliott Hughes
4c62e59fe6 Add epoll_pwait2().
I've also added doc comments for everything in <sys/epoll.h>.

I've also broken up the old "smoke" test (which was taking 2s on my
riscv64 qemu) to keep the total runtime for all the tests down to 200ms.

Test: treehugger
Change-Id: Icd939af51886fdf21432653a07373c1a0f26e422
2023-08-23 15:59:12 -07:00
Xin Li
661155efcb Merge Android U (ab/10368041)
Bug: 291102124
Merged-In: I89679e7152f197f9d0961eee352189bc7d1d1c50
Change-Id: I02dd1d48d478b0e0d702f1653271437e2cf7cef7
2023-08-23 14:43:14 -07:00
Kalesh Singh
ac516c4239 Merge "bionic: libc_init_static: Use page_size()" into main am: 8cd1ddcbf0 am: 5c7512474e am: 9ac016c5df am: 542dc8ea3f am: f4fa351c9c
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719578

Change-Id: I33f2ad296febef576d344601004c4d99ba249caa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-23 03:27:00 +00:00
Kalesh Singh
8cd1ddcbf0 Merge "bionic: libc_init_static: Use page_size()" into main 2023-08-23 00:16:26 +00:00
Juan Yescas
9e24def386 Merge "bionic: Use max_page_size() instead of PAGE_SIZE" into main am: ac587f827c am: c48775c9fa am: 94f8520923 am: 83395bc0c3 am: 31a450554d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719394

Change-Id: I41be7b98903fd23e2ae3c9f5763c4cbf2e95b90e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 18:09:37 +00:00
Elliott Hughes
8c4e1adab2 Merge "riscv64: fix ifuncs, improve the ifunc tests." into main am: d53ad05e38 am: c512636d31 am: 96591865e3 am: b889ba04ca am: 28765348af
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2695693

Change-Id: I4010768df4e17016fa731f8ba7451f752464177f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 18:08:30 +00:00
Juan Yescas
ac587f827c Merge "bionic: Use max_page_size() instead of PAGE_SIZE" into main 2023-08-22 15:22:44 +00:00
Juan Yescas
3649db34a1 bionic: Use max_page_size() instead of PAGE_SIZE
Android V will support page size agnostic targets. The bionic macro
PAGE_SIZE won't be defined for the agnostic targets.

The PAGE_SIZE macro will be replaced by max_page_size() instead.

- For not agnostic builds, max_page_size() will be replaced by 4096.
- For agnostic builds, it will  be replaced by 16384

Bug: 296907948
Test: source build/envsetup.sh
      lunch aosp_cf_arm64_phone_pgagnostic
      m

      source build/envsetup.sh
      aosp_cf_x86_64_phone-userdebug
      m

Change-Id: I81731a2ec59decd19ab9fd714d4f2ac20df873b7
2023-08-22 05:34:55 +00:00
Kalesh Singh
183f58bb2a bionic: libc_init_static: Use page_size()
Use the real page size from getauxval() for memtag stack
MTE protection.

Bug: 296275298
Test: atest -c bionic-unit-tests
Change-Id: I1711291b918b09e5464f1d15358dd1ff7fa2f371
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-21 16:55:41 -07:00
Elliott Hughes
620a72252e riscv64: fix ifuncs, improve the ifunc tests.
Talking futher to the person doing the glibc risc-v ifunc work, they
clarified that glibc _is_ passing hwcap as the first argument, and the
null pointer is actually the second argument.

https://sourceware.org/pipermail/libc-alpha/2023-August/150967.html

So since our whole purpose here was source compatibility, let's do what
they're actually doing, and let's add some tests. I've also added a test
that __riscv_hwprobe() works from an ifunc resolver because that's one
place where it might well be used. That said, one other thing that came
out of the discussion is that I actually went away and looked at a
sample of top apps to see how many are using ifuncs currently. The
result? Zero. So although this _might_ be interesting long term
(especially if clang gets riscv64 FMV), I think we've done more than we
need to with riscv64 ifuncs for now!

Test: ran locally, both dynamic and static tests
Change-Id: Ie2044d9f4e47c32c00ad381f045c537f4df38b08
2023-08-21 16:17:35 -07:00
Elliott Hughes
99fe0dfbe0 Merge "Point to the riscv64 psABI frame pointer documentation." into main am: c983dbf0b2 am: 948133436e am: a52ed9c983 am: 9ae386ef4d am: 6be58129c0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2707397

Change-Id: If0a85a2463ad72eeed780d49fc73eb9eec658429
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-16 19:13:34 +00:00
Elliott Hughes
f9571ec851 Point to the riscv64 psABI frame pointer documentation.
Test: N/A
Change-Id: I6639ecfe75a4f0e3caaf7347676997e0e214f6c8
2023-08-14 19:19:39 +00:00
Dan Albert
1adec823d5 Merge changes I1a60d6ef,Idabf0107 into main am: 1982dce568 am: d5ef5029fe am: 0378513f6d am: cdd4a25109 am: a287663d1c
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2670156

Change-Id: I9e3dfb1928d414dd66db5fe1b2309a83f5147a71
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-07 21:47:46 +00:00
Dan Albert
1982dce568 Merge changes I1a60d6ef,Idabf0107 into main
* changes:
  Fix result for zero-length non-null conversion.
  Fix mismatched return types for surrogate pairs.
2023-08-07 17:55:09 +00:00
Christopher Ferris
282a23364d Merge "Increase time to set allocation limit." into main am: 636b9b9bf2 am: 8e060cc24f am: 8223f8601d am: 7e16f5b009 am: 92de0990f5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2694747

Change-Id: I3d5a9788b696cfa1fec8ba99ccddb48f667cd5ef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-05 02:00:44 +00:00
Treehugger Robot
0293cd474c Merge changes Ia6b8cff4,I390ea200 into main am: 007bb4d1e8 am: 8003988d69 am: e1be10f328 am: 0d863ca056 am: 9f60001427
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2670165

Change-Id: I79c687319663c740feed983847eefaf4c2824698
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-05 01:59:51 +00:00
Christopher Ferris
636b9b9bf2 Merge "Increase time to set allocation limit." into main 2023-08-04 22:54:05 +00:00
Christopher Ferris
e9ffc52da7 Increase time to set allocation limit.
Under some circumstances, it's possible to fail the enable allocation
limit android_mallopt call. Increase the total allowed time for the
function to complete.

In addition, if the enable fails, allow another limit call to succeed
in the future.

Finally, change the limit test to use _exit instead of exit.

Bug: 291672185

Test: Ran limit test thousands of times.
Test: Forced the limit to fail and verified the second call passes.
Change-Id: I0948e6fd97231a7538b9b82b76f0a207386681b1
2023-08-04 13:10:48 -07:00