Commit graph

39155 commits

Author SHA1 Message Date
Ryan Prichard
e722c756a5 Merge "linker_main: acquire loader lock earlier and release it later" into main 2023-08-21 21:06:39 +00:00
Treehugger Robot
d8708ba8b6 Merge "sys_hwprobe_test.cpp: compare vdso to syscall." into main 2023-08-21 20:47:52 +00:00
Mitch Phillips
e219a4179f Merge "Move bionic test libraries to a default, for easy consumption in cts." into main 2023-08-21 16:32:11 +00:00
Mitch Phillips
f5c9a65046 Move bionic test libraries to a default, for easy consumption in cts.
This list has diverged between cts/ and bionic/. Instead of having to
maintain the list, let's just make cts/ inherit the one from bionic.

Bug: 296832150
Test: atest bionic-unit-tests CtsBionicTestCases
Change-Id: I271668e83aed239107b9129dfb707f03bae47cfa
2023-08-21 13:55:10 +02:00
Juan Yescas
8ff3886ff7 Merge "bionic: Fix typo in the argument passed to getauxval()" into main 2023-08-20 17:05:31 +00:00
Juan Yescas
4c562594d9 Merge changes from topic "bionic_max_pgsize" into main
* changes:
  bionic: libc: WriteProtected use max_page_size()
  bionic: Introduce max_page_size()
2023-08-20 17:05:07 +00:00
Treehugger Robot
0c56cbad11 Merge "Add some new risc-v ELF relocations." into main 2023-08-20 08:20:14 +00:00
Kalesh Singh
2bdf22e992 bionic: libc: WriteProtected use max_page_size()
In the 4k targets there is no fucntional difference since
max_page_size() == page_size() == 4096.

On a 16kb device max_page_size() == 65536 and page_size() == 16384.
However, aligning up does not incur any memory regressions
since the .bss section is still be backes in page-sizeed chunks.

See: go/16k-page-aligned-variables

Bug: 296275298
Test: mma
Change-Id: I41c3e410f3b84c24eeb969c9aeca4b33a8d6170a
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-19 00:05:12 +00:00
Kalesh Singh
307bae7afe bionic: Introduce max_page_size()
This can be used to "page-align" variables at build time -
__attribute__((aligned(max_pge_size()))), so it is a
preprocessor macro instead of an inline function.

There is no functional change to the 4kB-only build targets
(!defined(__BIONIC_NO_PAGE_SIZE_MACRO))

Bug: 296275298
Test: mma
Change-Id: I462e9f971a176b6b59e32e449a2e11f95c3f1b45
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-19 00:04:53 +00:00
Ryan Prichard
67e8f22cf5 linker_main: acquire loader lock earlier and release it later
__linker_init calls soinfo::~soinfo after __linker_init_post_relocation
has returned, and ~soinfo modifies global loader state
(g_soinfo_handles_map), so the loader lock must be held.

Use a variable with a destructor (~DlMutexUnlocker) to release the
loader lock after ~soinfo returns.

It's not clear to me when the mutex should be acquired.
pthread_mutex_lock in theory can use __bionic_tls (ScopedTrace), but
that should only happen if the mutex is contended, and it won't be.
The loader constructors shouldn't be spawning a thread, and the vdso
shouldn't really have a constructor. ifunc relocations presumably don't
spawn a thread either. It probably doesn't matter much as long as it's
held before calling constructors in the executable or shared objects.

Bug: http://b/290318196
Test: treehugger
Test: bionic-unit-tests
Change-Id: I544ad65db07e5fe83315ad4489d77536d463a0a4
2023-08-18 16:23:34 -07:00
Elliott Hughes
f517b68c82 Add some new risc-v ELF relocations.
Also add the link to the canonical source.

Test: treehugger
Change-Id: I06c5d1ded5e1b372630c6963c81947450946c29a
2023-08-18 17:51:53 +00:00
Juan Yescas
0bd4117f3f bionic: Fix typo in the argument passed to getauxval()
AT_PAGESZ is the correct argument for getauxval() to get the page size.

Bug: 277272383
Test: source build/envsetup.sh
      lunch aosp_cf_arm64_phone_pgagnostic
Change-Id: Ied2db77e9fda73b58f65b2f489ad7fab743c2fe7
2023-08-18 03:49:15 +00:00
Elliott Hughes
c983dbf0b2 Merge "Point to the riscv64 psABI frame pointer documentation." into main 2023-08-16 14:36:42 +00:00
Elliott Hughes
728aaf6800 sys_hwprobe_test.cpp: compare vdso to syscall.
Also fix a __has_include() that was copy & pasted without modification
from a different test.

Test: treehugger
Change-Id: Iafceb331a95ec788596ffdad60aa2202b692e589
2023-08-14 14:58:33 -07: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
Juan Yescas
6e73f92f04 Merge changes from topic "bionic no page size macro" into main
* changes:
  bionic: PAGE_SIZE macro won't be used in page size agnostic targets
  bionic: Use getauxval(AT_PAGESZ) for page agnostic targets
2023-08-11 05:45:07 +00:00
Juan Yescas
7de2012422 bionic: PAGE_SIZE macro won't be used in page size agnostic targets
When the C flag -D__BIONIC_NO_PAGE_SIZE_MACRO is defined,
the PAGE_SIZE macro won't be used for page size agnostic builds.

Note: Only arm64 architectures support page size agnostic builds.

Bug: 277272383
Bug: 289419664

Test: source build/envsetup.sh
      lunch aosp_cf_arm64_phone_pgagnostic
      m

      source build/envsetup.sh
      lunch aosp_cf_x86_64_phone
      m

Change-Id: I755d5fcdd493fe6da5277a60d8e90805e9b2754d
2023-08-10 15:33:02 -07:00
Juan Yescas
49fdb0babf bionic: Use getauxval(AT_PAGESZ) for page agnostic targets
When the C flag -D__BIONIC_NO_PAGE_SIZE_MACRO is defined,
the function getauxval(AT_PAGESZ) will be called instead of
using the PAGE_SIZE macro for the arm64 architectures.

Bug: 277272383
Bug: 289419664

Test: source build/envsetup.sh
      lunch aosp_raven_pgagnostic_64-userdebug
      m

      source build/envsetup.sh
      lunch aosp_cf_x86_64_phone
      m

Change-Id: Ie904ee5601365abbcf93ee371922a351844eccff
2023-08-10 15:28:19 -07:00
Treehugger Robot
c5c913b0f5 Merge "Clarify a confusing passage in the docs." into main 2023-08-10 20:32:05 +00:00
Elliott Hughes
9b81e58ff9 Clarify a confusing passage in the docs.
Test: N/A
Change-Id: I23a89cb062982ed292bf62b4c187300b0776aa3d
2023-08-10 19:26:36 +00:00
Elliott Hughes
20ad9129e7 Merge "Rename prop_bt." into main 2023-08-08 18:40:49 +00:00
Elliott Hughes
c37aa7ad3c Rename prop_bt.
Presumably "bt" was "binary tree", but "trie_node" is a bit more
specific and removes the guesswork.

Test: treehugger
Change-Id: Ib5fb2dcbcf261ce516728099d484ed9cd6c069bd
2023-08-08 14:05:01 +00:00
Kalesh Singh
b88dba9a70 Merge "linker_block_alloctor: Remove 4k page size assumption" into main 2023-08-07 23:16:30 +00:00
Treehugger Robot
8b96b46a9e Merge "Use L() in libc/arch-x86_64/bionic/*.S." into main 2023-08-07 19:20:39 +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
Elliott Hughes
072ff571d9 Use L() in libc/arch-x86_64/bionic/*.S.
I did look at a wider cleanup of libc/arch-x86_64/string/*.S but was
horrified by what I found there, with apparently-useless macros that
may actually be relevant because source files include each other. So
I'll leave the Intel-written stuff alone until/unless I actually have
reason to touch it, and just clean up our corner instead.

Test: treehugger
Change-Id: Id749f79d2fab4a2956efe9e807a067e16cd606ec
2023-08-07 09:34:06 -07:00
Treehugger Robot
6b2aa54a78 Merge "Add the L() macro for local labels to <private/bionic_asm.h>." into main 2023-08-05 00:50:09 +00:00
Kalesh Singh
ff8e00e7bc linker_block_alloctor: Remove 4k page size assumption
Block allocator mmaps arbitary large area ("LinkerBlockAllocatorPage")
of size 4kB * 100. In order to reduce mmap-* syscall and kernel VMA
memory usage.

This works fine for 16kB page size since 100 4kB page are equal to 25
16kB pages.

But for 64kB page size the area will include a partial page (16kB sized
region at the end).

Change the size to 96 4kb pages (6 64kB pages), this will work for all
aarch64 supported page sizes.

And remove the use of PAGE_SIZE

Bug: 294438799
Test: atest -c linker-unit-tests
Change-Id: I7782406d1470183097ce9391c9b70b177e1750e6
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-04 23:08:34 +00:00
Christopher Ferris
636b9b9bf2 Merge "Increase time to set allocation limit." into main 2023-08-04 22:54:05 +00:00
Treehugger Robot
b00078830d Merge "Update NOTICE file." into main 2023-08-04 22:50:15 +00:00
Treehugger Robot
23c97e925c Merge "Fix signature of mbstate_reset_and_return." into main 2023-08-04 22:36:05 +00:00
Treehugger Robot
007bb4d1e8 Merge changes Ia6b8cff4,I390ea200 into main
* changes:
  Make multibyte result constants public.
  Disable 0b parsing test for glibc.
2023-08-04 22:35:29 +00:00
Dan Albert
e1fbf3e15a Merge changes I51c6536e,Ifa0a555e,Iead5eb01,I11236609,Ia307cbd6 into main
* changes:
  Improve output for failed wcsto* tests.
  Add missing setlocale/uselocale for glibc tests.
  Fix test for out of range multibyte characters.
  Fix wchar tests for zero length conversions.
  Fix wcsto*_l tests for glibc.
2023-08-04 22:18:23 +00:00
Elliott Hughes
bc192cff55 Add the L() macro for local labels to <private/bionic_asm.h>.
This lets us remove the riscv64 "sys/asm.h" file. It turns out everyone
loves this macro --- tons of x86 and arm assembler is already using it!

I'll clean up some of the now-duplicate definitions separately, and I'll
move the assembler we wrote ourselves over to this macro (rather than
the current `.L_foo` style) too.

Test: built riscv64 _and_ arm/arm64 _and_ x86/x86-64
Change-Id: If3f93c9b71094a8bed1fd1bb81bb83ec60ce409e
2023-08-04 15:12:30 -07: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
Dan Albert
16007d5204 Fix result for zero-length non-null conversion.
Bug: None
Test: deleted the xfail half of the test
Change-Id: I1a60d6ef27ebad14de79ac3bc637a6f2280334d8
2023-08-04 19:48:56 +00:00
Dan Albert
013d747dd3 Fix signature of mbstate_reset_and_return.
Bug: None
Test: None
Change-Id: Ifab9f68f542354fafa8514bf4ea73b185796bdad
2023-08-04 19:48:35 +00:00
Dan Albert
a9e914dd2f Make multibyte result constants public.
The magic numbers that C defines are obnoxious. We had partial
definitions for these internally. Add the missing one and move them to
a public header for anyone else that may want to use them.

Bug: None
Test: None
Change-Id: Ia6b8cff4310bcccb23078c52216528db668ac966
2023-08-04 19:48:35 +00:00
Dan Albert
3a8fed1ac3 Fix mismatched return types for surrogate pairs.
We've had these backward all this time. The relevant quote is in a
code comment in the implementation, but the first call after
completely decoding a code point that requires a surrogate pair should
return the number of bytes decoded by the most recent call, and the
second call should return -3 (if only C had given those some named
constants that might have been more obviously wrong).

Bug: https://issuetracker.google.com/289419882
Test: Fixed the test, tests run against glibc and musl to confirm
Change-Id: Idabf01075b1cad35b604ede8d676d6f0b1dc91e6
2023-08-04 19:48:35 +00:00
Dan Albert
9f30c6ba92 Disable 0b parsing test for glibc.
Bug: None
Test: ran on glibc
Change-Id: I390ea20015f94b26ab3cdbeb6ade6cbcfefa7b0a
2023-08-04 19:48:34 +00:00
Elliott Hughes
a137234742 Update NOTICE file.
I don't know why we seem to keep missing this so much these days...

Test: treehugger
Change-Id: I018a528f35aa938f8fc5cdafe2eaf3f1bbc1a6d9
2023-08-04 12:43:21 -07:00
Elliott Hughes
9a80691e38 Merge "Sync upstream FreeBSD libm." into main 2023-08-04 14:51:38 +00:00
Dan Albert
a40159fa22 Improve output for failed wcsto* tests.
Bug: None
Test: ran these and finally understood which sub-test was failing
Change-Id: I51c6536eba4b9c82ed4b062b1702128e23cf339c
2023-08-03 21:05:29 +00:00
Dan Albert
9f78c51e03 Add missing setlocale/uselocale for glibc tests.
Bug: None
Test: these
Change-Id: Ifa0a555e3a771b27ba733b1316f7531c7b262f8b
2023-08-03 21:05:29 +00:00
Dan Albert
5325653b0f Fix test for out of range multibyte characters.
Same as in uchar_test.cpp: glibc implements a much older unicode
standard which allows these.

Bug: None
Test: this is a test
Change-Id: Iead5eb01d391be85a7b1a034ea9e7f8828e81cdb
2023-08-03 21:04:31 +00:00
Elliott Hughes
4088e3a587 Sync upstream FreeBSD libm.
Test: treehugger
Change-Id: I583a3e93821d512c975db34fc1610ffd22445d58
2023-08-03 13:33:56 -07:00
Dan Albert
512469a858 Fix wchar tests for zero length conversions.
Same as the previous change for the uchar tests: the tests are wrong
to match bionic's wrong implementation. Fix the test to encode the bug
for now while I get the tests into good shape, then I'll be back to
fix the bugs and remove the test differences.

Bug: None
Test: this is a test
Change-Id: I1123660994f755f8bac1f2656f6890d5a43310b3
2023-08-03 20:03:28 +00:00
Dan Albert
686e67d077 Fix wcsto*_l tests for glibc.
glibc immediately dereferences the locale passed to all wcsto*_l
functions, even if it won't be used, and even if it's
LC_GLOBAL_LOCALE, which isn't a pointer to valid memory.

Bug: None
Test: this is the test
Change-Id: Ia307cbd6a5c5b4b904c978a03e6d06c1cef6ceed
2023-08-03 19:59:11 +00:00
Treehugger Robot
e31c863307 Merge "Define gettid symbol when testing on glibc < 2.30" into main 2023-08-03 16:44:11 +00:00
Tomasz Wasilczyk
704e4e6936 Define gettid symbol when testing on glibc < 2.30
Bug: 289414897
Test: it builds
Change-Id: Ic44514953f34096e8a681ef2587439953096ba53
2023-08-03 07:19:17 -07:00