Commit graph

5 commits

Author SHA1 Message Date
Kalesh Singh
f4ffe0a026 soong: Add crt_pad_segment to .so's
crt_pad_segment adds a NOTE to the ELF which is used by the binoic
loader to determine whether it should pad segments when mapping them
into the virtual address space, such that there are no gaps between
mappings of consecutive segments. This avoids an increase in
unreclaimable kernel slab memory usage for VMAs on devices where the
runtime-page-size > elf-segment-p_align.

Since -fandroid-pad-segment [1] respects -nostdlib used in android
platform builds, soong must link in crt_pad_segment to platform shared
libraries.

For simplicity, link crt_pad_segment everywhere that crtend_so is
applicable, ignoring nocrt property, as there is no other reason
to track these separately.

Example:

❯ readelf -WS /system/lib64/libc++.so [Output simplified]

...
Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
...
  [ 2] .note.android.pad_segment NOTE            0000000000000288 000288 000018 00   A  0   0  4
...

[1] https://github.com/llvm/llvm-project/pull/77244

Bug: 316403210
Test: readelf -WS <lib>.so
Change-Id: Icc06611376cfd5ee4de7281b4134f9f8ffe7ca60
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-01-31 19:42:31 -08:00
Colin Cross
fc3b064c9a Make toolchain more compose-y
Remove many of the overridden methods from toolchainBase in favor
of having smaller composable types.  toolchainNoCrt, toolchain32Bit
and toolchain64Bit now only provide a few methods and can be mixed
in to any toolchain type.  toolchainLinux, toolchainBionic,
toolchainWindows and toolchainDarwin now embed toolchainBase to provide
the default flags methods for when they don't override them.

This avoids the need for disambiguation methods required when a
type embeds two types that implement the same method.

Test: cc_test.go
Change-Id: I641da2a47aba597c517f693efedb65cf41273c82
2022-09-01 14:21:36 -07:00
Colin Cross
d1a2813063 Move default crt objects into Toolchain
Move the crt objects spread around cc/library.go and cc/binary.go
into the Toolchain.  This will simplify adding new toolchains that
have custom crt objects.

Test: m checkbuild
Test: go test ./cc/...
Change-Id: I7fdc1f53769799cb9c10e3e5816dabee0f918768
2021-06-22 16:54:40 -07:00
Colin Cross
c85446836d Add DefaultSharedLibraries to Toolchain
Move the default value for system_shared_libs out of linker.go and into
a new DefaultSharedLibraries method in Toolchain.  This will simplify
adding system_shared_libs to cc_object, and adding new toolchains with
different default system_shared_libs.

Test: m checkbuild
Test: go test ./cc/...
Change-Id: I422315f090be20719c08a4d33bd39b0b26a93d6c
2021-06-22 16:54:39 -07:00
Colin Cross
e3fee34a3d Create toolchainBionic for the various bionic-based toolchains to inherit from
Host bionic and each of the device bionic architectures will share some
new toolchain functionality in common, create a toolchainBionic and embed
it into the toolchains.  Use it to implement Bionic() once and change
the default implementation from true to false.

Test: go test ./cc/...
Test: m checkbuild
Change-Id: Ia34b80d9691edc4ab1cbdbd005d1ffc950d0881c
2021-06-22 16:54:39 -07:00