16k: Align shared libraries and executables to 4k by default
The default ELF segment alignment will be 4096. This alignment can be overriden by setting the desired alignment in PRODUCT_MAX_PAGE_SIZE_SUPPORTED flag. The alignment has to be a multiple of the configured kernel page size. Test: Built changes for Pixel 4a, 6 and checked alignment. Bug: 276963698 Bug: 276801883 Change-Id: Icb380041a5b27da1fa0d86b302e1e7cde9a236d7
This commit is contained in:
@@ -176,6 +176,13 @@ func (c Config) RunningInsideUnitTest() bool {
|
||||
return c.config.TestProductVariables != nil
|
||||
}
|
||||
|
||||
// MaxPageSizeSupported returns the max page size supported by the device. This
|
||||
// value will define the ELF segment alignment for binaries (executables and
|
||||
// shared libraries).
|
||||
func (c Config) MaxPageSizeSupported() string {
|
||||
return String(c.config.productVariables.DeviceMaxPageSizeSupported)
|
||||
}
|
||||
|
||||
// A DeviceConfig object represents the configuration for a particular device
|
||||
// being built. For now there will only be one of these, but in the future there
|
||||
// may be multiple devices being built.
|
||||
|
@@ -218,6 +218,7 @@ type productVariables struct {
|
||||
DeviceVndkVersion *string `json:",omitempty"`
|
||||
DeviceCurrentApiLevelForVendorModules *string `json:",omitempty"`
|
||||
DeviceSystemSdkVersions []string `json:",omitempty"`
|
||||
DeviceMaxPageSizeSupported *string `json:",omitempty"`
|
||||
|
||||
RecoverySnapshotVersion *string `json:",omitempty"`
|
||||
|
||||
@@ -505,6 +506,7 @@ func (v *productVariables) SetDefaultConfig() {
|
||||
DeviceSecondaryArchVariant: stringPtr("armv8-a"),
|
||||
DeviceSecondaryCpuVariant: stringPtr("generic"),
|
||||
DeviceSecondaryAbi: []string{"armeabi-v7a", "armeabi"},
|
||||
DeviceMaxPageSizeSupported: stringPtr("4096"),
|
||||
|
||||
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
|
||||
AAPTPreferredConfig: stringPtr("xhdpi"),
|
||||
|
@@ -53,8 +53,7 @@ var (
|
||||
"-Wl,-z,separate-code",
|
||||
}
|
||||
|
||||
arm64Lldflags = append(arm64Ldflags,
|
||||
"-Wl,-z,max-page-size=4096")
|
||||
arm64Lldflags = arm64Ldflags
|
||||
|
||||
arm64Cppflags = []string{}
|
||||
|
||||
@@ -93,7 +92,13 @@ var (
|
||||
|
||||
func init() {
|
||||
exportedVars.ExportStringListStaticVariable("Arm64Ldflags", arm64Ldflags)
|
||||
exportedVars.ExportStringListStaticVariable("Arm64Lldflags", arm64Lldflags)
|
||||
|
||||
exportedVars.ExportStringList("Arm64Lldflags", arm64Lldflags)
|
||||
pctx.VariableFunc("Arm64Lldflags", func(ctx android.PackageVarContext) string {
|
||||
maxPageSizeFlag := "-Wl,-z,max-page-size=" + ctx.Config().MaxPageSizeSupported()
|
||||
flags := append(arm64Lldflags, maxPageSizeFlag)
|
||||
return strings.Join(flags, " ")
|
||||
})
|
||||
|
||||
exportedVars.ExportStringListStaticVariable("Arm64Cflags", arm64Cflags)
|
||||
exportedVars.ExportStringListStaticVariable("Arm64Cppflags", arm64Cppflags)
|
||||
|
@@ -185,7 +185,12 @@ func init() {
|
||||
exportedVars.ExportString("ArmClangTriple", clangTriple)
|
||||
|
||||
exportedVars.ExportStringListStaticVariable("ArmLdflags", armLdflags)
|
||||
exportedVars.ExportStringListStaticVariable("ArmLldflags", armLldflags)
|
||||
exportedVars.ExportStringList("ArmLldflags", armLldflags)
|
||||
pctx.VariableFunc("ArmLldflags", func(ctx android.PackageVarContext) string {
|
||||
maxPageSizeFlag := "-Wl,-z,max-page-size=" + ctx.Config().MaxPageSizeSupported()
|
||||
flags := append(armLldflags, maxPageSizeFlag)
|
||||
return strings.Join(flags, " ")
|
||||
})
|
||||
|
||||
exportedVars.ExportStringListStaticVariable("ArmFixCortexA8LdFlags", armFixCortexA8LdFlags)
|
||||
exportedVars.ExportStringListStaticVariable("ArmNoFixCortexA8LdFlags", armNoFixCortexA8LdFlags)
|
||||
|
Reference in New Issue
Block a user