platform_bionic/libc/arch-common/bionic
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
..
__dso_handle.h Remove an obsolete aarch64 hack. 2017-10-25 10:57:02 -07:00
__dso_handle_so.h Move __dso_handle to RELRO 2019-08-26 20:35:00 -07:00
asm_multiarch.h Properly align init/fini_arrays for crtend.o 2015-05-07 12:56:15 -07:00
atexit.h Fixes for __cxa_finalize 2014-05-05 11:36:57 -07:00
crtbegin.c Let executables not rely on sentinels in preinit_array/init_array/fini_array 2023-09-01 10:17:05 -07:00
crtbegin_so.c Remove __stack_chk_fail_local() completely. 2021-03-17 09:02:34 -07:00
crtbrand.S [NFCI] Change Android's NT_TYPE to NT_ANDROID_TYPE. 2022-02-07 13:49:20 -08:00
crtend.S Let executables not rely on sentinels in preinit_array/init_array/fini_array 2023-09-01 10:17:05 -07:00
crtend_so.S Remove #if cruft. 2023-03-01 20:26:41 +00:00
pthread_atfork.h Stop using the __ANDROID_API_x__ constants. 2019-12-20 13:26:14 -08:00