Commit graph

3495 commits

Author SHA1 Message Date
Treehugger Robot
af9c5273e5 Merge "Fix anonymous class error" into main am: 44b0e7a725
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3123411

Change-Id: I072883b3aa38d9d2b0557dfa2effc415c97d48cf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-06-10 21:01:09 +00:00
Zijun
eae85ad155 Fix anonymous class error
Fail to compile bionic/tests/complex_test.cpp when updating compiler due
to the conflict.

Bug: b/346349678
Test: change the clang version and then run mm to build
Change-Id: Ic22b7325b6e52006e620e13944f3f1d76030d782
2024-06-10 19:49:06 +00:00
Treehugger Robot
8be62724a0 Merge "[riscv][bionic] Prototype TLS Descriptor support" into main am: 7619ddbc4e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2940588

Change-Id: Iec6b5a1b5d5302adc2452643a3adcb685f0784ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-06-10 12:13:50 +00:00
Paul Kirth
4d4377881d [riscv][bionic] Prototype TLS Descriptor support
Add basic assembly stubs for TLS Descriptor support in the dynamic
linker, and enable several code paths related to TLSDESC for RISC-V.

Note: This patch requires an updated toolchain that supports TLSDESC
for RISC-V, and the `-mtls-dialect=` compiler option specifically.

Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter=*tls*
Bug: 322984914
Change-Id: I74bd0fa216b44b4ca2c5a5a6aec37b3fc47b00d9
2024-06-07 14:30:22 -07:00
Elliott Hughes
c87d87ca60 Merge "<stdio.h>: warn on some unused results." into main am: 5b57093ecc
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3110539

Change-Id: I4c15330dc742672b8ab675496543e5899c8f6e61
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-06-04 18:43:51 +00:00
Elliott Hughes
5b57093ecc Merge "<stdio.h>: warn on some unused results." into main 2024-06-04 18:20:48 +00:00
Elliott Hughes
6246e95adf Merge "setjmp_test: riscv64 does have callee-save fp registers." into main am: 1bebfd3c10
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3096178

Change-Id: I15624144982e01cb4e8bbeadc753e670868f7103
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-06-03 20:33:36 +00:00
Elliott Hughes
86968d95f1 setjmp_test: riscv64 does have callee-save fp registers.
The setjmp implementation is correct, but this comment was wrong, and we were missing the implementation of the test. This would be slightly simpler if we enabled Zfa in the build system and qemu, but this works for now.

Change-Id: Iad32771019584beacd8b35138ac2bf4c0a14c903
2024-06-03 18:38:10 +00:00
Elliott Hughes
78706d25d0 <stdio.h>: warn on some unused results.
This is fairly conservative, touching only those functions (such as feof()) where it's clearly an error to not use the return value.

Also fix a test that was ignoring the return value of feof() (because it was just checking whether the function could take the lock, and genuinely didn't care about the result).

Change-Id: If2ade10ae87df45a8b9bfcb24828e460201fa9a1
2024-05-31 22:55:22 +00:00
Elliott Hughes
cee6832eb3 Merge "Fix some wcwidth() special cases." into main am: f4a27aee8d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2983497

Change-Id: I0d71b38128f2bd43a6ab1da35c348c74c4f0fdf7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-30 11:59:03 +00:00
Elliott Hughes
f4a27aee8d Merge "Fix some wcwidth() special cases." into main 2024-05-30 11:41:24 +00:00
Elliott Hughes
20a9f99b3b Fix some wcwidth() special cases.
Detailed explanation in the code comments.

Test: treehugger
Change-Id: I2aef2510724c1c622b83e226b51d4c8429b88272
2024-05-29 21:45:51 +00:00
Treehugger Robot
38ad80a3ad Merge "Revert^2 "Convert Android.mk under bionic to Android.bp"" into main am: cdaaa0a6bb
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3102918

Change-Id: I4729be9e39b605bb802392afdd568ec3fb1546f5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-29 03:43:34 +00:00
Treehugger Robot
cdaaa0a6bb Merge "Revert^2 "Convert Android.mk under bionic to Android.bp"" into main 2024-05-29 03:25:37 +00:00
Kelly Hung
9fb1a6cdbd Revert^2 "Convert Android.mk under bionic to Android.bp"
This reverts commit 1e32ad88ff.

Reason for revert: 1. aosp/3099017 merged. 2. verified in ABDT run
https://android-build.corp.google.com/abtd/run/L00400030004085752/

Change-Id: I6f07c67ab84ea93406dee88a5d20d0674a2d2a79
2024-05-24 13:56:08 +00:00
Xin Li
431ecbca72 Merge Android 24Q2 Release (ab/11526283) to aosp-main-future
Bug: 337098550
Merged-In: Ibe2ffda9155246f2217aaa0e7d589ed7effec311
Change-Id: Ia5fa139b867a2043201c2253a7ccbff9607b8a83
2024-05-23 14:10:02 -07:00
Priyanka Advani
1e32ad88ff Revert "Convert Android.mk under bionic to Android.bp"
This reverts commit 12b2042a3f.

Reason for revert: Droidmonitor triggered revert due to build breakage in b/342029467. Will be verifying through ABTD before submission.

Change-Id: I801b4999047732b86985f0be2f4aae90b9998e4a
2024-05-22 00:34:12 +00:00
Elliott Hughes
c793bc00f5 Don't leak a thread when timer_create() fails.
We do the same thing in pthread_create().

This has the nice side-effect of letting us move part of the child setup that we were doing in the parent into the child where it belongs.

Bug: https://issuetracker.google.com/340125671
Change-Id: Ibe646d5ca9066f487d08fd40f004550349e8a02e
2024-05-21 21:35:49 +00:00
Elliott Hughes
abbec338f9 utils.h: quote regex match failure messages.
This still won't be easy to read, but it should at least be "less bad".

Change-Id: I14ecf06ffcc54a4bb48003e8cba3b731d8a0073d
2024-05-20 13:12:09 +00:00
kellyhung
12b2042a3f Convert Android.mk under bionic to Android.bp
Bug: b/311284462
Test: m bionic-compile-time-tests1-clang++; m bionic-compile-time-tests2-clang++

Change-Id: I538dda9f56f0c85bf3779cc55f721a7e1c1fcc5a
2024-05-20 01:13:54 +08:00
Christopher Ferris
f0247b6b68 Merge "Skip stack protector test on HWASan." into main 2024-05-15 17:53:50 +00:00
Yi Kong
11f696ad00 Use vmov.f64 for SET_FREG
When implemented using fcpyd, Clang sometimes generates redundant vmovs
after SET_FREGS on ARM32 and touches registers set, causing the test to
fail. Use vmov.f64 instead and that avoids the issue.

Test: atest CtsBionicTestCases:setjmp#setjmp_fp_registers -- --abi armeabi-v7a
Test: atest CtsBionicTestCases:setjmp#setjmp_fp_registers -- --abi arm64-v8a
Bug: 337903801
Change-Id: Ibd89b120f8a3cc80c34905069469fd244a902d1e
2024-05-15 15:29:29 +09:00
Christopher Ferris
0e0d600523 Skip stack protector test on HWASan.
On HWASan, it's not really possible to test scribbling on the
stack protector, so skip the test in this case.

Bug: 339529777

Test: Verified stack protector test is skipped.
Change-Id: I541416f8a84f649f83868574907b1e445d990aa0
2024-05-14 17:31:27 -07:00
Treehugger Robot
d06e2e7b29 Merge "Rename GWP-ASan android_mallopt() arguments" into main 2024-05-09 17:29:34 +00:00
Mitch Phillips
ebc2ac934f Rename GWP-ASan android_mallopt() arguments
The previous names were difficult to decipher. Now, let's change this
all to be more clear as it's actually one android_mallopt() call
depending on where it's called from, rather than the intended behaviour.

Also updated the comments so it's clear what happened across different
versions of Android.

Test: atest bionic-unit-tests CtsGwpAsanTestCases
Bug: N/a
Change-Id: I0582cab0b74aa09f4af54f9fbe5ba22697f82082
2024-05-03 13:20:45 +02:00
Elliott Hughes
a8cd731c2b Remove historical cruft.
We're definitely on a new enough clang now...

Change-Id: I7ec4ad0e78872edbde05a31574dd78f219bb115c
2024-05-01 22:43:31 +00:00
Treehugger Robot
4d9af810fd Merge "16k: bionic: Replace hardcoded page size with getpagesize()" into main 2024-05-01 16:14:52 +00:00
Vilas Bhat
297e7dd30f 16k: bionic: Replace hardcoded page size with getpagesize()
The optional block size for the /proc filesystem is set to page size.
The tests must reflect the same.

Bug: 315510913
Change-Id: Ifccf833829b4ea4ff9c7d375208124cdc43af04a
2024-05-01 01:14:56 +00:00
Treehugger Robot
cdbc7c75f5 Merge "[scudo] -1 is also valid for M_DECAY_TIME" into main 2024-04-29 20:07:46 +00:00
Chia-hung Duan
6abb406e0a [scudo] -1 is also valid for M_DECAY_TIME
Test: Run tests
Change-Id: I044ef84bf0ec97c0f8cb8d3a2340b82218d85efc
2024-04-26 15:24:24 -07:00
AdityaK
24705dbdb5 [RISC-V] Add misaligned load store tests
hwprobe test may be insufficient to guarantee fast (or even supported) unaligned access.
Test case based on: https://github.com/llvm/llvm-project/issues/88029

Previous commit got reverted due to compiler errors(b/336800888).
Not sure why the errors were not detected in pre-submit builds.

Bug: https://github.com/google/android-riscv64/issues/142

Change-Id: If1c4150701298c0f351baa9ce1870509a00c250a
2024-04-25 16:15:00 -07:00
Elliott Hughes
b266f6522f Add LINE_MAX.
LINE_MAX is a bad idea from the 1970s that we've ignored until now,
but there's already one hack in the AOSP tree (external/ltp) to work
around its absence, and kselftests would need another. Both uses are
bad code, but bad code exists, and iOS/macOS and musl/glibc all have
the same 2048 value, and it is in POSIX, so at least it's consistent
idiocy. Hopefully we're not encouraging more of it!

Bug: https://github.com/llvm/llvm-project/issues/88119
Change-Id: Ief219c3fe20b3d95da7040c4b9411f997b1c0470
2024-04-09 15:41:10 +00:00
Ryan Prichard
a35df79cd8 Merge "Fix StaticTlsLayout for atypical alignment values" into main 2024-03-21 21:38:59 +00:00
Ryan Prichard
439639268d Fix StaticTlsLayout for atypical alignment values
arm32/arm64: Previously, the loader miscalculated a negative value for
offset_bionic_tcb_ when the executable's alignment was greater than
(8 * sizeof(void*)). The process then tended to crash.

riscv: Previously, the loader didn't propagate the p_align field of the
PT_TLS segment into StaticTlsLayout::alignment_, so high alignment
values were ignored.

__bionic_check_tls_alignment: Stop capping alignment at page_size().
There is no need to cap it, and the uncapped value is necessary for
correctly positioning the TLS segment relative to the thread pointer
(TP) for ARM and x86. The uncapped value is now used for computing
static TLS layout, but only a page of alignment is actually provided:
 * static TLS: __allocate_thread_mapping uses mmap, which provides only
   a page's worth of alignment
 * dynamic TLS: BionicAllocator::memalign caps align to page_size()
 * There were no callers to StaticTlsLayout::alignment(), so remove it.

Allow PT_TLS.p_align to be 0: quietly convert it to 1.

For static TLS, ensure that the address of a TLS block is congruent to
p_vaddr, modulo p_align. That is, ensure this formula holds:

    (&tls_block % p_align) == (p_vaddr % p_align)

For dynamic TLS, a TLS block is still allocated congruent to 0 modulo
p_align. Fixing dynamic TLS congruence is mostly a separate problem
from fixing static TLS congruence, and requires changing the dynamic
TLS allocator and/or DTV structure, so it should be fixed in a
later follow-up commit.

Typically (p_vaddr % p_align) is zero, but it's currently possible to
get a non-zero value with LLD: when .tbss has greater than page
alignment, but .tdata does not, LLD can produce a TLS segment where
(p_vaddr % p_align) is non-zero. LLD calculates TP offsets assuming
the loader will align the segment using (p_vaddr % p_align).
Previously, Bionic and LLD disagreed on the offsets from the TP to
the executable's TLS variables.

Add unit tests for StaticTlsLayout in bionic-unit-tests-static.

See also:
 * https://github.com/llvm/llvm-project/issues/40872
 * https://sourceware.org/bugzilla/show_bug.cgi?id=24606
 * https://reviews.llvm.org/D61824
 * https://reviews.freebsd.org/D31538

Bug: http://b/133354825
Bug: http://b/328844725
Bug: http://b/328844839
Test: bionic-unit-tests bionic-unit-tests-static
Change-Id: I8850c32ff742a45d3450d8fc39075c10a1e11000
2024-03-20 17:01:35 -07:00
Elliott Hughes
a8b8cd7be9 Merge "Remove workaround for a fixed bug." into main 2024-03-18 16:04:06 +00:00
Elliott Hughes
7b95053aa0 Remove workaround for a fixed bug.
We're still copy & pasting this workaround about, but the bug was supposedly fixed years ago!

Bug: http://b/34945607
Bug: http://b/33942619
Bug: http://b/34195559
Change-Id: Icf3d184d2ddb447dff7dacccea1dc903da816505
2024-03-16 00:22:00 +00:00
Elliott Hughes
dc0510ec17 Flush all the streams if CHECK() fails.
It's usually more helpful to see all the output so far.

If we're worried about fflush() failing because of the state we're in, we shouldn't be using stdio at all!

If this _does_ become a problem, we should probably switch to using the internal functions: `__assert2` for bionic, `__assert_fail` for musl/glibc, and `__assert_rtn` for macOS.

Unfortunately although `__assert2` and `__assert_fail` take the same arguments, they're in a different order, so we can't simply add a symbol alias to make that difference go away, and it's not clear that there's enough value to adding an otherwise unused symbol.

Change-Id: I653183737ab6368890bbd9d0e2f37fc5cb2e1dec
2024-03-15 15:23:12 +00:00
Ryan Prichard
3abc30d6a6 Merge "Make tests/libs/CHECK.h work on the host" into main 2024-03-14 23:15:19 +00:00
Kalesh Singh
4fbcbbd522 Merge changes Ib76b022f,I98882edd,I575d626b into main
* changes:
  bionic: loader: Only zero the last partial page in RW segments
  Reapply "RELAND: bionic: loader: Extend GNU_RELRO protection"
  Reapply "RELAND: bionic: loader: Extend LOAD segment VMAs"
2024-03-14 20:22:26 +00:00
Ryan Prichard
e4912ac995 Make tests/libs/CHECK.h work on the host
The `__assert2` function is not provided by glibc, in particular.

Bug: none
Test: manual
Change-Id: I72c428fd0794aceec2bfaf37638be0ff6a02f289
2024-03-13 18:31:15 -07:00
Kalesh Singh
4084b555b2 Reapply "RELAND: bionic: loader: Extend LOAD segment VMAs"
This reverts commit 7a04fedc78.

Test: Dexcom G7 app
Bug: 328797737
Change-Id: I575d626b1313d1c66bf25f29c43a9a101024a4f8
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-03-13 13:37:30 -07:00
Elliott Hughes
8d8138aad1 Fix orthography of GetTestLibRoot().
Change-Id: Ib052329b3ebced12a7e2d75b3628b33c7043e0d8
2024-03-12 22:37:13 +00:00
Kalesh Singh
7a04fedc78 Revert "RELAND: bionic: loader: Extend LOAD segment VMAs"
Revert submission 2966884

Reason for revert: b/328266487

Reverted changes: /q/submissionid:2966884

Bug: 328266487
Change-Id: I45a2c5888eefab36c069f992de00ec8c87105288
2024-03-07 13:32:34 -08:00
Ryan Prichard
cda3150674 Remove an unused include
Bug: none
Test: bionic-unit-tests
Change-Id: I738c24c82b5c4af5db275ba6566a5ba6f7d538ac
2024-03-04 17:29:41 -08:00
Ryan Prichard
98731dc343 Revamp the elftls_dl.dtv_resize test
Split the test out into a separate executable to reduce the number of
ELF modules in the DTV, so that the test can more easily observe the
behavior of loading a module that requires doubling the DTV size. We
want to see the DTV expand from 5 entries (8 words w/header) to
13 entries (16 words w/header).

Make the test work with an initial number of ELF TLS modules between
2 and 4.

Bug: http://b/175635923
Test: bionic-unit-tests
Change-Id: I1e91b4462987a5c80e13838669c359053f5a62f6
2024-03-01 00:22:39 -08:00
Elliott Hughes
102ba4182d Merge "Add _Fork()." into main am: a216b269ef am: 335380e79a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2976351

Change-Id: I85962ff0cdcd88f849059668de7ad9e26318ddb7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-01 00:11:07 +00:00
Elliott Hughes
a216b269ef Merge "Add _Fork()." into main 2024-02-29 22:25:45 +00:00
Elliott Hughes
2411fff9f2 Add _Fork().
POSIX issue 8 function, already in musl/glibc (but not iOS/macOS).

Bug: https://austingroupbugs.net/view.php?id=62
Test: treehugger
Change-Id: Id51611afdab92dff36a540b7d8737fc0e31f3d36
2024-02-29 20:50:58 +00:00
Kalesh Singh
824fa8065c Merge changes from topic "reland_bionic_vma_fixes" into main am: f9c297d344 am: c5b4880d0a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2966884

Change-Id: Idab9845138b4ac32639d37717ad9e66ee05893cf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-28 17:45:55 +00:00
Kalesh Singh
f9c297d344 Merge changes from topic "reland_bionic_vma_fixes" into main
* changes:
  RELAND: bionic: loader: Extend GNU_RELRO protection
  RELAND: bionic: loader: Extend LOAD segment VMAs
2024-02-28 16:20:08 +00:00