f4ffe0a026
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>
46 lines
2.2 KiB
Go
46 lines
2.2 KiB
Go
// Copyright 2015 Google Inc. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package config
|
|
|
|
type toolchainBionic struct {
|
|
toolchainBase
|
|
}
|
|
|
|
var (
|
|
bionicDefaultSharedLibraries = []string{"libc", "libm", "libdl"}
|
|
|
|
bionicCrtBeginStaticBinary, bionicCrtEndStaticBinary = []string{"crtbegin_static"}, []string{"crtend_android"}
|
|
bionicCrtBeginSharedBinary, bionicCrtEndSharedBinary = []string{"crtbegin_dynamic"}, []string{"crtend_android"}
|
|
bionicCrtBeginSharedLibrary, bionicCrtEndSharedLibrary = []string{"crtbegin_so"}, []string{"crtend_so"}
|
|
bionicCrtPadSegmentSharedLibrary = []string{"crt_pad_segment"}
|
|
)
|
|
|
|
func (toolchainBionic) Bionic() bool { return true }
|
|
|
|
func (toolchainBionic) DefaultSharedLibraries() []string { return bionicDefaultSharedLibraries }
|
|
|
|
func (toolchainBionic) ShlibSuffix() string { return ".so" }
|
|
|
|
func (toolchainBionic) ExecutableSuffix() string { return "" }
|
|
|
|
func (toolchainBionic) AvailableLibraries() []string { return nil }
|
|
|
|
func (toolchainBionic) CrtBeginStaticBinary() []string { return bionicCrtBeginStaticBinary }
|
|
func (toolchainBionic) CrtBeginSharedBinary() []string { return bionicCrtBeginSharedBinary }
|
|
func (toolchainBionic) CrtBeginSharedLibrary() []string { return bionicCrtBeginSharedLibrary }
|
|
func (toolchainBionic) CrtEndStaticBinary() []string { return bionicCrtEndStaticBinary }
|
|
func (toolchainBionic) CrtEndSharedBinary() []string { return bionicCrtEndSharedBinary }
|
|
func (toolchainBionic) CrtEndSharedLibrary() []string { return bionicCrtEndSharedLibrary }
|
|
func (toolchainBionic) CrtPadSegmentSharedLibrary() []string { return bionicCrtPadSegmentSharedLibrary }
|